[elm] Documenting/exemplifying the following:
- elm_gengrid_add - elm_gengrid_align_get - elm_gengrid_align_set - elm_gengrid_always_select_mode_get - elm_gengrid_always_select_mode_set - elm_gengrid_bounce_get - elm_gengrid_bounce_set - elm_gengrid_clear - elm_gengrid_horizontal_get - elm_gengrid_horizontal_set - elm_gengrid_multi_select_get - elm_gengrid_multi_select_set - elm_gengrid_no_select_mode_get - elm_gengrid_no_select_mode_set - elm_gengrid_page_relative_get - elm_gengrid_page_relative_set - elm_gengrid_page_size_set SVN revision: 61704
This commit is contained in:
parent
e86e02b9f9
commit
ddc04e41b4
|
@ -32,7 +32,7 @@
|
|||
* @ref calendar_example_06
|
||||
*
|
||||
* @ref clock_example
|
||||
|
||||
*
|
||||
* @ref diskselector_example_01
|
||||
*
|
||||
* @ref diskselector_example_02
|
||||
|
@ -48,6 +48,8 @@
|
|||
* @ref index_example_01
|
||||
*
|
||||
* @ref index_example_02
|
||||
*
|
||||
* @ref gengrid_example
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -3060,6 +3062,219 @@
|
|||
* @example panel_example_01.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* @page gengrid_example Gengrid widget example
|
||||
*
|
||||
* This application is a thorough exercise on the gengrid widget's
|
||||
* API. We place an Elementary gengrid widget on a window, with
|
||||
* various knobs below its viewport, each one acting on it somehow.
|
||||
*
|
||||
* The code's relevant part begins at the grid's creation. After
|
||||
* instantiating it, we set its items sizes, so that we don't end with
|
||||
* items one finger size wide, only. We're setting them to fat, 150
|
||||
* pixel wide ones, for this example. We give it some size hints, not
|
||||
* to be discussed in this context and, than, we register a callback
|
||||
* on one of its smart events -- the one coming each time an item gets
|
||||
* doubly clicked. There, we just print the item handle's value.
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip grid = elm_gengrid_add
|
||||
* @until evas_object_sho
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip item double click callback
|
||||
* @until }
|
||||
*
|
||||
* Before we actually start to deal with the items API, let's show
|
||||
* some things items will be using throughout all the code. The first
|
||||
* of them is a struct to be used as item data, for all of them:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip typedef struct
|
||||
* @until Item;
|
||||
*
|
||||
* That path will be used to index an image, to be swallowed into one
|
||||
* of the item's icon spots. The imagens themselves are distributed
|
||||
* with Elementary:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip static const char *imgs
|
||||
* @until ;
|
||||
*
|
||||
* We also have an (unique) gengrid item class we'll be using for
|
||||
* items in the example:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip static Elm_Gengrid_Item_Class
|
||||
* @until static Elm_Gengrid_Item_Class
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip item_style =
|
||||
* @until _grid_del
|
||||
*
|
||||
* As you see, our items will follow the default theme on gengrid
|
||||
* items. For the label fetching code, we return a string composed of
|
||||
* the item's image path:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip label fetching callback
|
||||
* @until }
|
||||
*
|
||||
* For item icons, we'll be populating the item default theme's two
|
||||
* icon spots, @c "elm.swallow.icon" and @c "elm.swallow.end". The
|
||||
* former will receive one of the images in our list (in the form of
|
||||
* a @ref bg_02_example_page "background"), while the latter will be
|
||||
* a check widget. Note that we prevent the check to propagate click
|
||||
* events, so that the user can toggle its state without messing with
|
||||
* the respective item's selection in the grid:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip icon fetching callback
|
||||
* @until return NULL
|
||||
* @until }
|
||||
*
|
||||
* As the default gengrid item's theme does not have parts
|
||||
* implementing item states, we'll be just returning false for every
|
||||
* item state:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip state fetching callback
|
||||
* @until }
|
||||
*
|
||||
* Finally, the deletion callback on gengrid items takes care of
|
||||
* freeing the item's label string and its data struct:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip deletion callback
|
||||
* @until }
|
||||
*
|
||||
* Let's move to item insertion/deletion knobs, them. They are four
|
||||
* buttons, above the grid's viewport, namely
|
||||
* - "Append" (to append an item to the grid),
|
||||
* - "Prepend" (to prepend an item to the grid),
|
||||
* - "Insert before" (to insert an item before the selection, on the
|
||||
* grid),
|
||||
* - "Insert after" (to insert an item after the selection, on the
|
||||
* grid),
|
||||
* - "Clear" (to delete all items in the grid),
|
||||
* .
|
||||
* which are displaced and declared in that order. We're not dealing
|
||||
* with the buttons' creation code (see @ref button_example_01
|
||||
* "a button example", for more details on it), but with their @c
|
||||
* "clicked" registered callbacks. For all of them, the grid's handle
|
||||
* is passed as @c data. The ones creating new items use a common
|
||||
* code, which just gives a new @c Example_Item struct, with @c path
|
||||
* filled with a random image in our images list:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip new item with random path
|
||||
* @until }
|
||||
*
|
||||
* Moreover, that ones will set a common function to be issued on the
|
||||
* selection of the items. There, we print the item handle's value,
|
||||
* along with the callback function data. The latter will be @c NULL,
|
||||
* always, because it's what we pass when adding all icons.
|
||||
*
|
||||
* The appending button will exercise elm_gengrid_item_append(), simply:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip append an item
|
||||
* @until }
|
||||
*
|
||||
* The prepending, naturally, is analogous, but exercising
|
||||
* elm_gengrid_item_prepend(), on its turn. The "Insert before" one
|
||||
* will expect an item to be selected in the grid, so that it will
|
||||
* insert a new item just before it:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip "insert before" callback
|
||||
* @until }
|
||||
*
|
||||
* The "Insert after" is analogous, just using
|
||||
* elm_gengrid_item_insert_after(), instead. The "Clear" button will,
|
||||
* as expected, just issue elm_gengrid_clear():
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip delete items
|
||||
* @until }
|
||||
*
|
||||
* To change the grid's cell (items) size, we've placed a spinner,
|
||||
* which has the following @c "changed" smart callback:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip change items' size
|
||||
* @until }
|
||||
*
|
||||
* Experiment with it and see how the items are affected. To toggle
|
||||
* between horizontal and vertical layouting modes on the grid, use
|
||||
* the "Horizontal mode" check, which will call the respective API
|
||||
* function on the grid:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip change layouting mode
|
||||
* @until }
|
||||
*
|
||||
* If you toggle the check right after that one, "Always select",
|
||||
* you'll notice all subsequent clicks on the @b same grid item will
|
||||
* still issue the selection callback on it, what is different from
|
||||
* when it's not checked. This is the
|
||||
* elm_gengrid_always_select_mode_set() behavior:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip "always select" callback
|
||||
* @until }
|
||||
*
|
||||
* One more check follows, "Bouncing", which will turn on/off the
|
||||
* bouncing animations on the grid, when one scrolls past its
|
||||
* borders. Experiment with scrolling the grid to get the idea, having
|
||||
* it turned on and off:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip "bouncing mode" callback
|
||||
* @until }
|
||||
*
|
||||
* The next two checks will affect items selection on the grid. The
|
||||
* first, "Multi-selection", will make it possible to select more the
|
||||
* one item on the grid. Because it wouldn't make sense to fetch for
|
||||
* an unique selected item on this case, we also disable two of the
|
||||
* buttons, which insert items relatively, if multi-selection is on:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip multi-selection callback
|
||||
* @until }
|
||||
*
|
||||
* Note that we also @b unselect all items in the grid, when returning
|
||||
* from multi-selection mode, making use of
|
||||
* elm_gengrid_item_selected_set().
|
||||
*
|
||||
* The second check acting on selection, "No selection", is just what
|
||||
* its name depicts -- no selection will be allowed anymore, on the
|
||||
* grid, while it's on. Check it out for yourself, interacting with
|
||||
* the program:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip no selection callback
|
||||
* @until }
|
||||
*
|
||||
* We have, finally, one more line of knobs, now sliders, to change
|
||||
* the grids behavior. The two first will change the horizontal @b
|
||||
* alignment of the whole actual grid of items within the gengrid's
|
||||
* viewport:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip items grid horizontal alignment change
|
||||
* @until }
|
||||
*
|
||||
* Naturally, the vertical counterpart just issues
|
||||
* elm_gengrid_align_set() changing the second alignment component,
|
||||
* instead.
|
||||
*
|
||||
* The last slider will change the grid's <b>page size</b>, relative
|
||||
* to its own one. Try to change those values and, one manner of
|
||||
* observing the paging behavior, is to scroll softly and release the
|
||||
* mouse button, with different page sizes, at different grid
|
||||
* positions, while having lots of items in it -- you'll see it
|
||||
* snapping to page boundaries differenty, for each configuration:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip page relative size change
|
||||
* @until }
|
||||
*
|
||||
* This is how the example program's window looks like:
|
||||
* @image html screenshots/gengrid_example.png
|
||||
* @image latex screenshots/gengrid_example.eps
|
||||
*
|
||||
* Note that it starts with three items which we included at will:
|
||||
* @dontinclude gengrid_example.c
|
||||
* @skip _clicked(grid,
|
||||
* @until _clicked(grid,
|
||||
* @until _clicked(grid,
|
||||
* @until _clicked(grid,
|
||||
*
|
||||
* See the full @ref gengrid_example_c "source code" for
|
||||
* this example.
|
||||
*
|
||||
* @example gengrid_example.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* @page bg_example_01_c bg_example_01.c
|
||||
* @include bg_example_01.c
|
||||
|
@ -3177,4 +3392,9 @@
|
|||
*
|
||||
* @include layout_example.edc
|
||||
* @example layout_example.edc
|
||||
|
||||
/**
|
||||
* @page gengrid_example_c Gengrid example
|
||||
* @include gengrid_example.c
|
||||
* @example gengrid_example.c
|
||||
*/
|
||||
|
|
|
@ -80,7 +80,8 @@ SRCS = \
|
|||
pager_example_01.c \
|
||||
separator_example_01.c \
|
||||
radio_example_01.c \
|
||||
panel_example_01.c
|
||||
panel_example_01.c \
|
||||
gengrid_example.c
|
||||
|
||||
pkglib_PROGRAMS =
|
||||
|
||||
|
@ -151,7 +152,8 @@ pkglib_PROGRAMS += \
|
|||
separator_example_01 \
|
||||
radio_example_01 \
|
||||
toggle_example_01 \
|
||||
panel_example_01
|
||||
panel_example_01 \
|
||||
gengrid_example
|
||||
|
||||
# This variable will hold the list of screenshots that will be made
|
||||
# by "make screenshots". Each item in the list is of the form:
|
||||
|
@ -197,7 +199,8 @@ SCREENSHOTS = \
|
|||
separator_example_01:separator_example_01.png:0.0 \
|
||||
radio_example_01:radio_example_01.png:0.0 \
|
||||
toggle_example_01:toggle_example_01.png:0.0 \
|
||||
panel_example_01:panel_example_01.png:0.0
|
||||
panel_example_01:panel_example_01.png:0.0 \
|
||||
gengrid_example:gengrid_example.png:0.0
|
||||
|
||||
HTML_SS_DIR=$(top_builddir)/doc/html/screenshots
|
||||
LATEX_SS_DIR=$(top_builddir)/doc/latex/screenshots
|
||||
|
|
|
@ -0,0 +1,536 @@
|
|||
/**
|
||||
* Simple Elementary's <b>gengrid widget</b> example, illustrating its
|
||||
* usage and API.
|
||||
*
|
||||
* See stdout/stderr for output. Compile with:
|
||||
*
|
||||
* @verbatim
|
||||
* gcc -g `pkg-config --cflags --libs elementary` gengrid_example.c -o gengrid_example
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
#include <Elementary.h>
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "elementary_config.h"
|
||||
#else
|
||||
# define __UNUSED__
|
||||
# define PACKAGE_DATA_DIR "../../data"
|
||||
#endif
|
||||
|
||||
typedef struct _Example_Item
|
||||
{
|
||||
const char *path;
|
||||
} Example_Item;
|
||||
|
||||
static const char *imgs[9] =
|
||||
{
|
||||
"panel_01.jpg",
|
||||
"plant_01.jpg",
|
||||
"rock_01.jpg",
|
||||
"rock_02.jpg",
|
||||
"sky_01.jpg",
|
||||
"sky_02.jpg",
|
||||
"sky_03.jpg",
|
||||
"sky_04.jpg",
|
||||
"wood_01.jpg",
|
||||
};
|
||||
|
||||
static Elm_Gengrid_Item_Class gic;
|
||||
Evas_Object *before_bt, *after_bt;
|
||||
|
||||
static void
|
||||
_on_done(void *data __UNUSED__,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
elm_exit();
|
||||
}
|
||||
|
||||
/* change layouting mode */
|
||||
static void
|
||||
_horizontal_grid(void *data,
|
||||
Evas_Object *obj,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *grid = data;
|
||||
|
||||
elm_gengrid_horizontal_set(grid, elm_check_state_get(obj));
|
||||
}
|
||||
|
||||
/* "always select" callback */
|
||||
static void
|
||||
_always_select_change(void *data,
|
||||
Evas_Object *obj,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *grid = data;
|
||||
Eina_Bool always = elm_check_state_get(obj);
|
||||
|
||||
elm_gengrid_always_select_mode_set(grid, always);
|
||||
|
||||
fprintf(stdout, "\"Always select\" mode for gengrid items is now %s\n",
|
||||
always ? "on" : "off");
|
||||
}
|
||||
|
||||
/* "bouncing mode" callback */
|
||||
static void
|
||||
_bouncing_change(void *data,
|
||||
Evas_Object *obj,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *grid = data;
|
||||
Eina_Bool bounce = elm_check_state_get(obj);
|
||||
|
||||
elm_gengrid_bounce_set(grid, bounce, bounce);
|
||||
|
||||
fprintf(stdout, "Bouncing effect for gengrid is now %s\n",
|
||||
bounce ? "on" : "off");
|
||||
}
|
||||
|
||||
/* multi-selection callback */
|
||||
static void
|
||||
_multi_change(void *data,
|
||||
Evas_Object *obj,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *grid = data;
|
||||
Eina_Bool multi = elm_check_state_get(obj);
|
||||
|
||||
elm_gengrid_multi_select_set(grid, multi);
|
||||
|
||||
fprintf(stdout, "Multi-selection for gengrid is now %s\n",
|
||||
multi ? "on" : "off");
|
||||
|
||||
elm_object_disabled_set(before_bt, multi);
|
||||
elm_object_disabled_set(after_bt, multi);
|
||||
|
||||
if (!multi)
|
||||
{
|
||||
Elm_Gengrid_Item *it;
|
||||
const Eina_List *selected = elm_gengrid_selected_items_get(grid), *l;
|
||||
EINA_LIST_FOREACH(selected, l, it)
|
||||
elm_gengrid_item_selected_set(it, EINA_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* no selection callback */
|
||||
static void
|
||||
_no_sel_change(void *data,
|
||||
Evas_Object *obj,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *grid = data;
|
||||
Eina_Bool no_sel = elm_check_state_get(obj);
|
||||
|
||||
elm_gengrid_no_select_mode_set(grid, no_sel);
|
||||
|
||||
fprintf(stdout, "Selection for gengrid items is now %s\n",
|
||||
no_sel ? "disabled" : "enabled");
|
||||
}
|
||||
|
||||
/* item selection callback */
|
||||
static void
|
||||
_grid_sel(void *data,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
void *event_info)
|
||||
{
|
||||
fprintf(stdout, "Item [%p], with data [%p], has been selected\n",
|
||||
event_info, data);
|
||||
}
|
||||
|
||||
/* new item with random path */
|
||||
static Example_Item *
|
||||
_item_new(void)
|
||||
{
|
||||
Example_Item *it;
|
||||
|
||||
it = malloc(sizeof(*it));
|
||||
it->path = eina_stringshare_add(imgs[rand() % (sizeof(imgs) /
|
||||
sizeof(imgs[0]))]);
|
||||
return it;
|
||||
}
|
||||
|
||||
/* "insert before" callback */
|
||||
static void
|
||||
_before_bt_clicked(void *data,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Example_Item *it;
|
||||
Evas_Object *grid = data;
|
||||
Elm_Gengrid_Item *sel;
|
||||
|
||||
sel = elm_gengrid_selected_item_get(grid);
|
||||
if (!sel)
|
||||
return;
|
||||
|
||||
it = _item_new();
|
||||
elm_gengrid_item_insert_before(grid, &gic, it, sel, _grid_sel, NULL);
|
||||
}
|
||||
|
||||
/* "insert after" callback */
|
||||
static void
|
||||
_after_bt_clicked(void *data,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Example_Item *it;
|
||||
Evas_Object *grid = data;
|
||||
Elm_Gengrid_Item *sel;
|
||||
|
||||
sel = elm_gengrid_selected_item_get(grid);
|
||||
if (!sel)
|
||||
return;
|
||||
|
||||
it = _item_new();
|
||||
elm_gengrid_item_insert_after(grid, &gic, it, sel, _grid_sel, NULL);
|
||||
}
|
||||
|
||||
/* prepend an item */
|
||||
static void
|
||||
_prepend_bt_clicked(void *data,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Example_Item *it;
|
||||
Evas_Object *grid = data;
|
||||
|
||||
it = _item_new();
|
||||
elm_gengrid_item_prepend(grid, &gic, it, _grid_sel, NULL);
|
||||
}
|
||||
|
||||
/* append an item */
|
||||
static void
|
||||
_append_bt_clicked(void *data,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *grid = data;
|
||||
Example_Item *it = _item_new();
|
||||
|
||||
elm_gengrid_item_append(grid, &gic, it, _grid_sel, NULL);
|
||||
}
|
||||
|
||||
/* delete items */
|
||||
static void
|
||||
_clear_cb(void *data,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
elm_gengrid_clear(data);
|
||||
|
||||
fprintf(stdout, "Clearing the grid!\n");
|
||||
}
|
||||
|
||||
/* change items' size */
|
||||
static void
|
||||
_size_changed(void *data,
|
||||
Evas_Object *obj,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *grid = data;
|
||||
int size = elm_spinner_value_get(obj);
|
||||
|
||||
elm_gengrid_item_size_set(grid, size, size);
|
||||
}
|
||||
|
||||
/* item double click callback */
|
||||
static void
|
||||
_double_click(void *data __UNUSED__,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
void *event_info)
|
||||
{
|
||||
fprintf(stdout, "Double click on item with handle %p\n", event_info);
|
||||
}
|
||||
|
||||
/* label fetching callback */
|
||||
static char *
|
||||
_grid_label_get(void *data,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
const char *part __UNUSED__)
|
||||
{
|
||||
const Example_Item *it = data;
|
||||
char buf[256];
|
||||
|
||||
snprintf(buf, sizeof(buf), "Photo %s", it->path);
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
/* icon fetching callback */
|
||||
static Evas_Object *
|
||||
_grid_icon_get(void *data,
|
||||
Evas_Object *obj,
|
||||
const char *part)
|
||||
{
|
||||
const Example_Item *it = data;
|
||||
|
||||
if (!strcmp(part, "elm.swallow.icon"))
|
||||
{
|
||||
Evas_Object *icon = elm_bg_add(obj);
|
||||
char buf[PATH_MAX];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/images/%s", PACKAGE_DATA_DIR,
|
||||
it->path);
|
||||
|
||||
elm_bg_file_set(icon, buf, NULL);
|
||||
evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1,
|
||||
1);
|
||||
evas_object_show(icon);
|
||||
return icon;
|
||||
}
|
||||
else if (!strcmp(part, "elm.swallow.end"))
|
||||
{
|
||||
Evas_Object *ck;
|
||||
ck = elm_check_add(obj);
|
||||
evas_object_propagate_events_set(ck, EINA_FALSE);
|
||||
evas_object_show(ck);
|
||||
return ck;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* state fetching callback */
|
||||
static Eina_Bool
|
||||
_grid_state_get(void *data __UNUSED__,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
const char *part __UNUSED__)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
/* deletion callback */
|
||||
static void
|
||||
_grid_del(void *data,
|
||||
Evas_Object *obj __UNUSED__)
|
||||
{
|
||||
Example_Item *it = data;
|
||||
|
||||
eina_stringshare_del(it->path);
|
||||
free(it);
|
||||
}
|
||||
|
||||
/* items grid horizontal alignment change */
|
||||
static void
|
||||
_h_align_change_cb(void *data,
|
||||
Evas_Object *obj,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
double v_align;
|
||||
double val = elm_slider_value_get(obj);
|
||||
|
||||
elm_gengrid_align_get(data, NULL, &v_align);
|
||||
|
||||
fprintf(stdout, "Setting horizontal alignment to %f\n", val);
|
||||
elm_gengrid_align_set(data, val, v_align);
|
||||
}
|
||||
|
||||
static void
|
||||
_v_align_change_cb(void *data,
|
||||
Evas_Object *obj,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
double h_align;
|
||||
double val = elm_slider_value_get(obj);
|
||||
|
||||
elm_gengrid_align_get(data, &h_align, NULL);
|
||||
|
||||
fprintf(stdout, "Setting vertical alignment to %f\n", val);
|
||||
elm_gengrid_align_set(data, h_align, val);
|
||||
}
|
||||
|
||||
/* page relative size change */
|
||||
static void
|
||||
_page_change_cb(void *data,
|
||||
Evas_Object *obj,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
double val = elm_slider_value_get(obj);
|
||||
|
||||
elm_gengrid_page_relative_set(data, val, val);
|
||||
|
||||
fprintf(stdout, "Setting grid page's relative size to %f\n", val);
|
||||
}
|
||||
|
||||
int
|
||||
elm_main(int argc __UNUSED__,
|
||||
char **argv __UNUSED__)
|
||||
{
|
||||
Evas_Object *win, *bg, *grid, *bx, *hbx_1, *hbx_2, *hbx_3, *bt, *ck, *sl,
|
||||
*sp;
|
||||
Eina_Bool bounce;
|
||||
double h, v;
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
win = elm_win_add(NULL, "gengrid", ELM_WIN_BASIC);
|
||||
elm_win_title_set(win, "Generic Grid Example");
|
||||
evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
|
||||
|
||||
bg = elm_bg_add(win);
|
||||
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_win_resize_object_add(win, bg);
|
||||
evas_object_show(bg);
|
||||
|
||||
bx = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_win_resize_object_add(win, bx);
|
||||
evas_object_show(bx);
|
||||
|
||||
grid = elm_gengrid_add(win);
|
||||
elm_gengrid_item_size_set(grid, 150, 150);
|
||||
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_min_set(grid, 600, 500);
|
||||
elm_box_pack_end(bx, grid);
|
||||
evas_object_smart_callback_add(grid, "clicked,double", _double_click, NULL);
|
||||
evas_object_show(grid);
|
||||
|
||||
hbx_1 = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(hbx_1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_box_horizontal_set(hbx_1, EINA_TRUE);
|
||||
elm_box_pack_end(bx, hbx_1);
|
||||
evas_object_show(hbx_1);
|
||||
|
||||
bt = elm_button_add(win);
|
||||
elm_object_text_set(bt, "Append");
|
||||
evas_object_smart_callback_add(bt, "clicked", _append_bt_clicked, grid);
|
||||
elm_box_pack_end(hbx_1, bt);
|
||||
evas_object_show(bt);
|
||||
|
||||
bt = elm_button_add(win);
|
||||
elm_object_text_set(bt, "Prepend");
|
||||
evas_object_smart_callback_add(bt, "clicked", _prepend_bt_clicked, grid);
|
||||
elm_box_pack_end(hbx_1, bt);
|
||||
evas_object_show(bt);
|
||||
|
||||
before_bt = elm_button_add(win);
|
||||
elm_object_text_set(before_bt, "Insert before");
|
||||
evas_object_smart_callback_add(before_bt, "clicked", _before_bt_clicked,
|
||||
grid);
|
||||
elm_box_pack_end(hbx_1, before_bt);
|
||||
evas_object_show(before_bt);
|
||||
|
||||
after_bt = elm_button_add(win);
|
||||
elm_object_text_set(after_bt, "Insert after");
|
||||
evas_object_smart_callback_add(after_bt, "clicked", _after_bt_clicked, grid);
|
||||
elm_box_pack_end(hbx_1, after_bt);
|
||||
evas_object_show(after_bt);
|
||||
|
||||
bt = elm_button_add(win);
|
||||
elm_object_text_set(bt, "Clear");
|
||||
evas_object_smart_callback_add(bt, "clicked", _clear_cb, grid);
|
||||
elm_box_pack_end(hbx_1, bt);
|
||||
evas_object_show(bt);
|
||||
|
||||
sp = elm_spinner_add(win);
|
||||
elm_spinner_min_max_set(sp, 10, 1024);
|
||||
elm_spinner_value_set(sp, 150);
|
||||
elm_spinner_label_format_set(sp, "Item size: %.0f");
|
||||
evas_object_smart_callback_add(sp, "changed", _size_changed, grid);
|
||||
evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_box_pack_end(hbx_1, sp);
|
||||
evas_object_show(sp);
|
||||
|
||||
hbx_2 = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(hbx_2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_box_horizontal_set(hbx_2, EINA_TRUE);
|
||||
elm_box_pack_end(bx, hbx_2);
|
||||
evas_object_show(hbx_2);
|
||||
|
||||
ck = elm_check_add(win);
|
||||
elm_object_text_set(ck, "Horizontal mode");
|
||||
evas_object_smart_callback_add(ck, "changed", _horizontal_grid, grid);
|
||||
elm_box_pack_end(hbx_2, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
ck = elm_check_add(win);
|
||||
elm_object_text_set(ck, "Always select");
|
||||
evas_object_smart_callback_add(ck, "changed", _always_select_change, grid);
|
||||
elm_box_pack_end(hbx_2, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
ck = elm_check_add(win);
|
||||
elm_gengrid_bounce_get(grid, &bounce, NULL);
|
||||
elm_object_text_set(ck, "Bouncing");
|
||||
elm_check_state_set(ck, bounce);
|
||||
evas_object_smart_callback_add(ck, "changed", _bouncing_change, grid);
|
||||
elm_box_pack_end(hbx_2, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
ck = elm_check_add(win);
|
||||
elm_object_text_set(ck, "Multi-selection");
|
||||
elm_check_state_set(ck, elm_gengrid_multi_select_get(grid));
|
||||
evas_object_smart_callback_add(ck, "changed", _multi_change, grid);
|
||||
elm_box_pack_end(hbx_2, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
ck = elm_check_add(win);
|
||||
elm_object_text_set(ck, "No selection");
|
||||
evas_object_smart_callback_add(ck, "changed", _no_sel_change, grid);
|
||||
elm_box_pack_end(hbx_2, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
hbx_3 = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(hbx_3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_box_horizontal_set(hbx_3, EINA_TRUE);
|
||||
elm_box_pack_end(bx, hbx_3);
|
||||
evas_object_show(hbx_3);
|
||||
|
||||
elm_gengrid_align_get(grid, &h, &v);
|
||||
|
||||
sl = elm_slider_add(win);
|
||||
elm_object_text_set(sl, "Horiz. alignment");
|
||||
elm_slider_span_size_set(sl, 100);
|
||||
evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND);
|
||||
elm_slider_indicator_format_set(sl, "%1.1f");
|
||||
elm_slider_value_set(sl, h);
|
||||
elm_box_pack_end(hbx_3, sl);
|
||||
evas_object_show(sl);
|
||||
|
||||
evas_object_smart_callback_add(sl, "changed", _h_align_change_cb, grid);
|
||||
|
||||
sl = elm_slider_add(win);
|
||||
elm_object_text_set(sl, "Vert. alignment");
|
||||
elm_slider_span_size_set(sl, 100);
|
||||
evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND);
|
||||
elm_slider_indicator_format_set(sl, "%1.1f");
|
||||
elm_slider_value_set(sl, v);
|
||||
elm_box_pack_end(hbx_3, sl);
|
||||
evas_object_show(sl);
|
||||
|
||||
evas_object_smart_callback_add(sl, "changed", _v_align_change_cb, grid);
|
||||
|
||||
elm_gengrid_align_get(grid, &h, &v);
|
||||
|
||||
sl = elm_slider_add(win);
|
||||
elm_object_text_set(sl, "Page rel. size");
|
||||
elm_slider_span_size_set(sl, 100);
|
||||
evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND);
|
||||
elm_slider_indicator_format_set(sl, "%1.1f");
|
||||
elm_slider_value_set(sl, h);
|
||||
elm_box_pack_end(hbx_3, sl);
|
||||
evas_object_show(sl);
|
||||
|
||||
evas_object_smart_callback_add(sl, "changed", _page_change_cb, grid);
|
||||
|
||||
gic.item_style = "default";
|
||||
gic.func.label_get = _grid_label_get;
|
||||
gic.func.icon_get = _grid_icon_get;
|
||||
gic.func.state_get = _grid_state_get;
|
||||
gic.func.del = _grid_del;
|
||||
|
||||
_append_bt_clicked(grid, NULL, NULL);
|
||||
_append_bt_clicked(grid, NULL, NULL);
|
||||
_append_bt_clicked(grid, NULL, NULL);
|
||||
|
||||
evas_object_resize(win, 600, 600);
|
||||
evas_object_show(win);
|
||||
|
||||
elm_run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ELM_MAIN()
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue