1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 * @defgroup Gengrid Gengrid
8 * This widget aims to position objects in a grid layout while
9 * actually building only the visible ones, using the same idea as
10 * genlist: the user define a class for each item, specifying
11 * functions that will be called at object creation and deletion.
13 * A item in the Gengrid can have 0 or more text labels (they can be
14 * regular text or textblock - that's up to the style to determine), 0
15 * or more icons (which are simply objects swallowed into the Gengrid
16 * item) and 0 or more boolean states that can be used for check,
17 * radio or other indicators by the edje theme style. A item may be
18 * one of several styles (Elementary provides 1 by default -
19 * "default", but this can be extended by system or application custom
20 * themes/overlays/extensions).
22 * In order to implement the ability to add and delete items on the
23 * fly, Gengrid implements a class/callback system where the
24 * application provides a structure with information about that type
25 * of item (Gengrid may contain multiple different items with
26 * different classes, states and styles). Gengrid will call the
27 * functions in this struct (methods) when an item is "realized" (that
28 * is created dynamically while scrolling). All objects will simply be
29 * deleted when no longer needed with evas_object_del(). The
30 * Elm_GenGrid_Item_Class structure contains the following members:
32 * item_style - This is a constant string and simply defines the name
33 * of the item style. It must be specified and the default should be
36 * func.label_get - This function is called when an actual item object
37 * is created. The data parameter is the one passed to
38 * elm_gengrid_item_append() and related item creation functions. The
39 * obj parameter is the Gengrid object and the part parameter is the
40 * string name of the text part in the edje design that is listed as
41 * one of the possible labels that can be set. This function must
42 * return a strdup'()ed string as the caller will free() it when done.
44 * func.icon_get - This function is called when an actual item object
45 * is created. The data parameter is the one passed to
46 * elm_gengrid_item_append() and related item creation functions. The
47 * obj parameter is the Gengrid object and the part parameter is the
48 * string name of the icon part in the edje design that is listed as
49 * one of the possible icons that can be set. This must return NULL
50 * for no object or a valid object. The object will be deleted by
51 * Gengrid on shutdown or when the item is unrealized.
53 * func.state_get - This function is called when an actual item object
54 * is created. The data parameter is the one passed to
55 * elm_gengrid_item_append() and related item creation functions. The
56 * obj parameter is the Gengrid object and the part parameter is the
57 * string name of th state part in the edje design that is listed as
58 * one of the possible states that can be set. Return 0 for false and
59 * 1 for true. Gengrid will emit a signal to the edje object with
60 * "elm,state,XXX,active" "elm" when true (the default is false),
61 * where XXX is the name of the part.
63 * func.del - This is called when elm_gengrid_item_del() is called on
64 * an item or elm_gengrid_clear() is called on the Gengrid. This is
65 * intended for use when actual Gengrid items are deleted, so any
66 * backing data attached to the item (e.g. its data parameter on
67 * creation) can be deleted.
69 * If the application wants multiple items to be able to be selected,
70 * elm_gengrid_multi_select_set() can enable this. If the Gengrid is
71 * single-selection only (the default), then
72 * elm_gengrid_select_item_get() will return the selected item, if
73 * any, or NULL if none is selected. If the Gengrid is multi-select
74 * then elm_gengrid_selected_items_get() will return a list (that is
75 * only valid as long as no items are modified (added, deleted,
76 * selected or unselected).
78 * If an item changes (state of boolean changes, label or icons
79 * change), then use elm_gengrid_item_update() to have Gengrid update
80 * the item with the new state. Gengrid will re-realize the item thus
81 * call the functions in the _Elm_Gengrid_Item_Class for that item.
83 * To programmatically (un)select an item use
84 * elm_gengrid_item_selected_set(). To get its selected state use
85 * elm_gengrid_item_selected_get(). To make an item disabled (unable to
86 * be selected and appear differently) use
87 * elm_gengrid_item_disabled_set() to set this and
88 * elm_gengrid_item_disabled_get() to get the disabled state.
90 * Cells will only call their selection func and callback when first
91 * becoming selected. Any further clicks will do nothing, unless you
92 * enable always select with
93 * elm_gengrid_always_select_mode_set(). This means event if selected,
94 * every click will make the selected callbacks be called.
95 * elm_gengrid_no_select_mode_set() will turn off the ability to
96 * select items entirely and they will neither appear selected nor
97 * call selected callback function.
99 * Remember that you can create new styles and add your own theme
100 * augmentation per application with elm_theme_extension_add(). If you
101 * absolutely must have a specific style that overrides any theme the
102 * user or system sets up you can use elm_theme_overlay_add() to add
105 * Signals that you can add callbacks for are:
107 * "clicked,double" - The user has double-clicked or pressed enter on
108 * an item. The event_infoparameter is the Gengrid item
109 * that was double-clicked.
110 * "selected" - The user has made an item selected. The event_info
111 * parameter is the Gengrid item that was selected.
112 * "unselected" - The user has made an item unselected. The event_info
113 * parameter is the Gengrid item that was unselected.
114 * "realized" - This is called when the item in the Gengrid is created
115 * as a real evas object. event_info is the Gengrid item that was
116 * created. The object may be deleted at any time, so it is up to
117 * the caller to not use the object pointer from
118 * elm_gengrid_item_object_get() in a way where it may point to
120 * "unrealized" - This is called when the real evas object for this item
121 * is deleted. event_info is the Gengrid item that was created.
122 * "changed" - Called when an item is added, removed, resized or moved
123 * and when gengrid is resized or horizontal property changes.
124 * "drag,start,up" - Called when the item in the Gengrid has been
125 * dragged (not scrolled) up.
126 * "drag,start,down" - Called when the item in the Gengrid has been
127 * dragged (not scrolled) down.
128 * "drag,start,left" - Called when the item in the Gengrid has been
129 * dragged (not scrolled) left.
130 * "drag,start,right" - Called when the item in the Gengrid has been
131 * dragged (not scrolled) right.
132 * "drag,stop" - Called when the item in the Gengrid has stopped being
134 * "drag" - Called when the item in the Gengrid is being dragged.
135 * "scroll" - called when the content has been scrolled (moved).
136 * "scroll,drag,start" - called when dragging the content has started.
137 * "scroll,drag,stop" - called when dragging the content has stopped.
141 * Handle non-homogeneous objects too.
144 typedef struct _Widget_Data Widget_Data;
145 typedef struct _Pan Pan;
148 #define REORDER_EFFECT_TIME 0.5
150 struct _Elm_Gengrid_Item
152 Elm_Widget_Item base;
155 const Elm_Gengrid_Item_Class *gic;
156 Ecore_Timer *long_timer;
157 Ecore_Animator *item_moving_effect_timer;
159 Eina_List *labels, *icons, *states, *icon_objs;
166 Evas_Coord x, y, dx, dy, ox, oy, tx, ty, rx, ry;
167 unsigned int moving_effect_start_time;
174 Elm_Tooltip_Item_Content_Cb content_cb;
175 Evas_Smart_Cb del_cb;
179 const char *mouse_cursor;
181 Eina_Bool want_unrealize : 1;
182 Eina_Bool realized : 1;
183 Eina_Bool dragging : 1;
185 Eina_Bool delete_me : 1;
186 Eina_Bool display_only : 1;
187 Eina_Bool disabled : 1;
188 Eina_Bool selected : 1;
189 Eina_Bool hilighted : 1;
190 Eina_Bool moving : 1;
195 Evas_Object *self, *scr;
196 Evas_Object *pan_smart;
201 Elm_Gengrid_Item *last_selected_item, *reorder_item;
202 double align_x, align_y;
204 Evas_Coord pan_x, pan_y, old_pan_x, old_pan_y;
205 Evas_Coord item_width, item_height; /* Each item size */
206 Evas_Coord minw, minh; /* Total obj size */
207 Evas_Coord reorder_item_x, reorder_item_y;
212 Eina_Bool horizontal : 1;
213 Eina_Bool on_hold : 1;
214 Eina_Bool longpressed : 1;
216 Eina_Bool no_select : 1;
217 Eina_Bool wasselected : 1;
218 Eina_Bool always_select : 1;
219 Eina_Bool clear_me : 1;
220 Eina_Bool h_bounce : 1;
221 Eina_Bool v_bounce : 1;
222 Eina_Bool reorder_mode : 1;
223 Eina_Bool reorder_item_changed : 1;
224 Eina_Bool move_effect_enabled : 1;
227 #define ELM_GENGRID_ITEM_FROM_INLIST(item) \
228 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
232 Evas_Object_Smart_Clipped_Data __clipped_data;
236 static const char *widtype = NULL;
237 static void _item_hilight(Elm_Gengrid_Item *item);
238 static void _item_unrealize(Elm_Gengrid_Item *item);
239 static void _item_select(Elm_Gengrid_Item *item);
240 static void _item_unselect(Elm_Gengrid_Item *item);
241 static void _calc_job(void *data);
242 static void _on_focus_hook(void *data,
244 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
245 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
246 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
247 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
248 static Eina_Bool _item_single_select_up(Widget_Data *wd);
249 static Eina_Bool _item_single_select_down(Widget_Data *wd);
250 static Eina_Bool _item_single_select_left(Widget_Data *wd);
251 static Eina_Bool _item_single_select_right(Widget_Data *wd);
252 static Eina_Bool _event_hook(Evas_Object *obj,
254 Evas_Callback_Type type,
256 static Eina_Bool _deselect_all_items(Widget_Data *wd);
258 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
259 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
261 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
262 static const char SIG_SELECTED[] = "selected";
263 static const char SIG_UNSELECTED[] = "unselected";
264 static const char SIG_REALIZED[] = "realized";
265 static const char SIG_UNREALIZED[] = "unrealized";
266 static const char SIG_CHANGED[] = "changed";
267 static const char SIG_DRAG_START_UP[] = "drag,start,up";
268 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
269 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
270 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
271 static const char SIG_DRAG_STOP[] = "drag,stop";
272 static const char SIG_DRAG[] = "drag";
273 static const char SIG_SCROLL[] = "scroll";
274 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
275 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
276 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
277 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
278 static const char SIG_MOVED[] = "moved";
280 static const Evas_Smart_Cb_Description _signals[] = {
281 {SIG_CLICKED_DOUBLE, ""},
283 {SIG_UNSELECTED, ""},
285 {SIG_UNREALIZED, ""},
287 {SIG_DRAG_START_UP, ""},
288 {SIG_DRAG_START_DOWN, ""},
289 {SIG_DRAG_START_LEFT, ""},
290 {SIG_DRAG_START_RIGHT, ""},
294 {SIG_SCROLL_ANIM_START, ""},
295 {SIG_SCROLL_ANIM_STOP, ""},
296 {SIG_SCROLL_DRAG_START, ""},
297 {SIG_SCROLL_DRAG_STOP, ""},
302 static Eina_Compare_Cb _elm_gengrid_item_compare_cb;
303 static Eina_Compare_Cb _elm_gengrid_item_compare_data_cb;
306 _event_hook(Evas_Object *obj,
307 Evas_Object *src __UNUSED__,
308 Evas_Callback_Type type,
311 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
312 Evas_Event_Key_Down *ev = event_info;
313 Widget_Data *wd = elm_widget_data_get(obj);
314 if (!wd) return EINA_FALSE;
315 if (!wd->items) return EINA_FALSE;
316 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
317 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
319 Elm_Gengrid_Item *item = NULL;
322 Evas_Coord step_x = 0;
323 Evas_Coord step_y = 0;
326 Evas_Coord page_x = 0;
327 Evas_Coord page_y = 0;
329 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
330 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
331 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
332 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
334 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
336 if ((wd->horizontal) &&
337 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
338 (_item_multi_select_up(wd)))
339 || (_item_single_select_up(wd))))
341 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
344 else if ((!wd->horizontal) &&
345 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
346 (_item_multi_select_left(wd)))
347 || (_item_single_select_left(wd))))
349 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
355 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
357 if ((wd->horizontal) &&
358 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
359 (_item_multi_select_down(wd)))
360 || (_item_single_select_down(wd))))
362 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
365 else if ((!wd->horizontal) &&
366 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
367 (_item_multi_select_right(wd)))
368 || (_item_single_select_right(wd))))
370 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
376 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
378 if ((wd->horizontal) &&
379 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
380 (_item_multi_select_left(wd)))
381 || (_item_single_select_left(wd))))
383 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
386 else if ((!wd->horizontal) &&
387 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
388 (_item_multi_select_up(wd)))
389 || (_item_single_select_up(wd))))
391 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
397 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
399 if ((wd->horizontal) &&
400 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
401 (_item_multi_select_right(wd)))
402 || (_item_single_select_right(wd))))
404 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
407 else if ((!wd->horizontal) &&
408 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
409 (_item_multi_select_down(wd)))
410 || (_item_single_select_down(wd))))
412 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
418 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
420 item = elm_gengrid_first_item_get(obj);
421 elm_gengrid_item_bring_in(item);
422 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
425 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
427 item = elm_gengrid_last_item_get(obj);
428 elm_gengrid_item_bring_in(item);
429 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
432 else if ((!strcmp(ev->keyname, "Prior")) ||
433 (!strcmp(ev->keyname, "KP_Prior")))
438 x -= -(page_x * v_w) / 100;
445 y -= -(page_y * v_h) / 100;
450 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
455 x += -(page_x * v_w) / 100;
462 y += -(page_y * v_h) / 100;
467 else if (!strcmp(ev->keyname, "Escape"))
469 if (!_deselect_all_items(wd)) return EINA_FALSE;
470 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
473 else if ((!strcmp(ev->keyname, "Return")) ||
474 (!strcmp(ev->keyname, "KP_Enter")) ||
475 (!strcmp(ev->keyname, "space")))
477 item = elm_gengrid_selected_item_get(obj);
478 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
480 else return EINA_FALSE;
482 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
483 elm_smart_scroller_child_pos_set(wd->scr, x, y);
488 _deselect_all_items(Widget_Data *wd)
490 if (!wd->selected) return EINA_FALSE;
492 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
498 _item_multi_select_left(Widget_Data *wd)
500 if (!wd->selected) return EINA_FALSE;
502 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
503 if (!prev) return EINA_TRUE;
504 if (elm_gengrid_item_selected_get(prev))
506 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
507 wd->last_selected_item = prev;
508 elm_gengrid_item_show(wd->last_selected_item);
512 elm_gengrid_item_selected_set(prev, EINA_TRUE);
513 elm_gengrid_item_show(prev);
520 _item_multi_select_right(Widget_Data *wd)
522 if (!wd->selected) return EINA_FALSE;
524 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
525 if (!next) return EINA_TRUE;
526 if (elm_gengrid_item_selected_get(next))
528 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
529 wd->last_selected_item = next;
530 elm_gengrid_item_show(wd->last_selected_item);
534 elm_gengrid_item_selected_set(next, EINA_TRUE);
535 elm_gengrid_item_show(next);
542 _item_multi_select_up(Widget_Data *wd)
545 Eina_Bool r = EINA_TRUE;
547 if (!wd->selected) return EINA_FALSE;
549 for (i = 0; (r) && (i < wd->nmax); i++)
550 r &= _item_multi_select_left(wd);
556 _item_multi_select_down(Widget_Data *wd)
559 Eina_Bool r = EINA_TRUE;
561 if (!wd->selected) return EINA_FALSE;
563 for (i = 0; (r) && (i < wd->nmax); i++)
564 r &= _item_multi_select_right(wd);
570 _item_single_select_up(Widget_Data *wd)
574 Elm_Gengrid_Item *prev;
578 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
579 while ((prev) && (prev->delete_me))
580 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
581 elm_gengrid_item_selected_set(prev, EINA_TRUE);
582 elm_gengrid_item_show(prev);
585 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
587 if (!prev) return EINA_FALSE;
589 for (i = 1; i < wd->nmax; i++)
591 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
592 if (!tmp) return EINA_FALSE;
596 _deselect_all_items(wd);
598 elm_gengrid_item_selected_set(prev, EINA_TRUE);
599 elm_gengrid_item_show(prev);
604 _item_single_select_down(Widget_Data *wd)
608 Elm_Gengrid_Item *next;
612 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
613 while ((next) && (next->delete_me))
614 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
615 elm_gengrid_item_selected_set(next, EINA_TRUE);
616 elm_gengrid_item_show(next);
619 else next = elm_gengrid_item_next_get(wd->last_selected_item);
621 if (!next) return EINA_FALSE;
623 for (i = 1; i < wd->nmax; i++)
625 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
626 if (!tmp) return EINA_FALSE;
630 _deselect_all_items(wd);
632 elm_gengrid_item_selected_set(next, EINA_TRUE);
633 elm_gengrid_item_show(next);
638 _item_single_select_left(Widget_Data *wd)
640 Elm_Gengrid_Item *prev;
643 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
644 while ((prev) && (prev->delete_me))
645 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
647 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
649 if (!prev) return EINA_FALSE;
651 _deselect_all_items(wd);
653 elm_gengrid_item_selected_set(prev, EINA_TRUE);
654 elm_gengrid_item_show(prev);
659 _item_single_select_right(Widget_Data *wd)
661 Elm_Gengrid_Item *next;
664 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
665 while ((next) && (next->delete_me))
666 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
668 else next = elm_gengrid_item_next_get(wd->last_selected_item);
670 if (!next) return EINA_FALSE;
672 _deselect_all_items(wd);
674 elm_gengrid_item_selected_set(next, EINA_TRUE);
675 elm_gengrid_item_show(next);
680 _on_focus_hook(void *data __UNUSED__,
683 Widget_Data *wd = elm_widget_data_get(obj);
685 if (elm_widget_focus_get(obj))
687 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
688 evas_object_focus_set(wd->self, EINA_TRUE);
689 if ((wd->selected) && (!wd->last_selected_item))
690 wd->last_selected_item = eina_list_data_get(wd->selected);
694 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
695 evas_object_focus_set(wd->self, EINA_FALSE);
700 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
702 Widget_Data *wd = elm_widget_data_get(obj);
703 Elm_Gengrid_Item *item;
705 elm_smart_scroller_mirrored_set(wd->scr, rtl);
706 if (!wd->items) return;
707 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
711 edje_object_mirrored_set(item->base.view, rtl);
712 elm_gengrid_item_update(item);
713 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
718 _theme_hook(Evas_Object *obj)
720 Widget_Data *wd = elm_widget_data_get(obj);
722 _elm_widget_mirrored_reload(obj);
723 _mirrored_set(obj, elm_widget_mirrored_get(obj));
724 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
725 elm_widget_style_get(obj));
729 _del_pre_hook(Evas_Object *obj)
731 Widget_Data *wd = elm_widget_data_get(obj);
733 elm_gengrid_clear(obj);
734 evas_object_del(wd->pan_smart);
735 wd->pan_smart = NULL;
739 _del_hook(Evas_Object *obj)
741 Widget_Data *wd = elm_widget_data_get(obj);
746 _signal_emit_hook(Evas_Object *obj,
747 const char *emission,
750 Widget_Data *wd = elm_widget_data_get(obj);
752 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
757 _mouse_move(void *data,
758 Evas *evas __UNUSED__,
762 Elm_Gengrid_Item *item = data;
763 Evas_Event_Mouse_Move *ev = event_info;
764 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
765 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
767 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
769 if (!item->wd->on_hold)
771 item->wd->on_hold = EINA_TRUE;
772 if (!item->wd->wasselected)
773 _item_unselect(item);
776 if ((item->dragging) && (item->down))
778 if (item->long_timer)
780 ecore_timer_del(item->long_timer);
781 item->long_timer = NULL;
783 evas_object_smart_callback_call(item->wd->self, SIG_DRAG, item);
786 if ((!item->down) || (item->wd->longpressed))
788 if (item->long_timer)
790 ecore_timer_del(item->long_timer);
791 item->long_timer = NULL;
793 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
795 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &ow, &oh);
797 it_scrl_x = ev->cur.canvas.x - item->wd->reorder_item->dx;
798 it_scrl_y = ev->cur.canvas.y - item->wd->reorder_item->dy;
800 if (it_scrl_x < ox) item->wd->reorder_item_x = ox;
801 else if (it_scrl_x + item->wd->item_width > ox + ow)
802 item->wd->reorder_item_x = ox + ow - item->wd->item_width;
803 else item->wd->reorder_item_x = it_scrl_x;
805 if (it_scrl_y < oy) item->wd->reorder_item_y = oy;
806 else if (it_scrl_y + item->wd->item_height > oy + oh)
807 item->wd->reorder_item_y = oy + oh - item->wd->item_height;
808 else item->wd->reorder_item_y = it_scrl_y;
810 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
811 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
815 if (!item->display_only)
816 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
817 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
818 x = ev->cur.canvas.x - x;
819 y = ev->cur.canvas.y - y;
822 if (adx < 0) adx = -dx;
825 if (ady < 0) ady = -dy;
828 if ((adx > minw) || (ady > minh))
830 const char *left_drag, *right_drag;
831 if (!elm_widget_mirrored_get(item->wd->self))
833 left_drag = SIG_DRAG_START_LEFT;
834 right_drag = SIG_DRAG_START_RIGHT;
838 left_drag = SIG_DRAG_START_RIGHT;
839 right_drag = SIG_DRAG_START_LEFT;
843 if (item->long_timer)
845 ecore_timer_del(item->long_timer);
846 item->long_timer = NULL;
848 if (!item->wd->wasselected)
849 _item_unselect(item);
853 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_START_UP,
858 evas_object_smart_callback_call(item->wd->self,
865 evas_object_smart_callback_call(item->wd->self,
866 SIG_DRAG_START_DOWN, item);
870 evas_object_smart_callback_call(item->wd->self,
873 evas_object_smart_callback_call(item->wd->self,
881 _long_press(void *data)
883 Elm_Gengrid_Item *item = data;
885 item->long_timer = NULL;
886 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
887 item->wd->longpressed = EINA_TRUE;
888 evas_object_smart_callback_call(item->wd->self, "longpressed", item);
889 if (item->wd->reorder_mode)
891 item->wd->reorder_item = item;
892 evas_object_raise(item->base.view);
893 elm_smart_scroller_hold_set(item->wd->scr, EINA_TRUE);
894 elm_smart_scroller_bounce_allow_set(item->wd->scr, EINA_FALSE, EINA_FALSE);
895 edje_object_signal_emit(item->base.view, "elm,state,reorder,enabled", "elm");
897 return ECORE_CALLBACK_CANCEL;
901 _mouse_down(void *data,
902 Evas *evas __UNUSED__,
906 Elm_Gengrid_Item *item = data;
907 Evas_Event_Mouse_Down *ev = event_info;
910 if (ev->button != 1) return;
913 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
914 item->dx = ev->canvas.x - x;
915 item->dy = ev->canvas.y - y;
916 item->wd->longpressed = EINA_FALSE;
917 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
918 else item->wd->on_hold = EINA_FALSE;
919 item->wd->wasselected = item->selected;
921 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
922 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
923 if (item->long_timer) ecore_timer_del(item->long_timer);
925 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
928 item->long_timer = NULL;
932 _mouse_up(void *data,
933 Evas *evas __UNUSED__,
934 Evas_Object *obj __UNUSED__,
937 Elm_Gengrid_Item *item = data;
938 Evas_Event_Mouse_Up *ev = event_info;
939 Eina_Bool dragged = EINA_FALSE;
941 if (ev->button != 1) return;
942 item->down = EINA_FALSE;
943 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
944 else item->wd->on_hold = EINA_FALSE;
945 if (item->long_timer)
947 ecore_timer_del(item->long_timer);
948 item->long_timer = NULL;
952 item->dragging = EINA_FALSE;
953 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_STOP, item);
956 if (item->wd->on_hold)
958 item->wd->longpressed = EINA_FALSE;
959 item->wd->on_hold = EINA_FALSE;
962 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
964 evas_object_smart_callback_call(item->wd->self, SIG_MOVED, item->wd->reorder_item);
965 item->wd->reorder_item = NULL;
966 item->wd->move_effect_enabled = EINA_FALSE;
967 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
968 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
970 elm_smart_scroller_hold_set(item->wd->scr, EINA_FALSE);
971 elm_smart_scroller_bounce_allow_set(item->wd->scr, item->wd->h_bounce, item->wd->v_bounce);
972 edje_object_signal_emit(item->base.view, "elm,state,reorder,disabled", "elm");
974 if (item->wd->longpressed)
976 item->wd->longpressed = EINA_FALSE;
977 if (!item->wd->wasselected) _item_unselect(item);
978 item->wd->wasselected = EINA_FALSE;
983 if (item->want_unrealize) _item_unrealize(item);
985 if ((item->disabled) || (dragged)) return;
993 else _item_unselect(item);
999 while (item->wd->selected)
1000 _item_unselect(item->wd->selected->data);
1004 const Eina_List *l, *l_next;
1005 Elm_Gengrid_Item *item2;
1007 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
1008 if (item2 != item) _item_unselect(item2);
1010 _item_hilight(item);
1016 _item_hilight(Elm_Gengrid_Item *item)
1018 if ((item->wd->no_select) || (item->delete_me) || (item->hilighted)) return;
1019 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
1020 item->hilighted = EINA_TRUE;
1024 _item_realize(Elm_Gengrid_Item *item)
1029 if ((item->realized) || (item->delete_me)) return;
1030 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
1031 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
1032 _elm_config->scale);
1033 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
1034 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
1035 elm_widget_sub_object_add(item->wd->self, item->base.view);
1036 snprintf(style, sizeof(style), "item/%s",
1037 item->gic->item_style ? item->gic->item_style : "default");
1038 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
1039 elm_widget_style_get(item->wd->self));
1041 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
1042 evas_object_color_set(item->spacer, 0, 0, 0, 0);
1043 elm_widget_sub_object_add(item->wd->self, item->spacer);
1044 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
1045 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
1047 if (item->gic->func.label_get)
1053 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1055 EINA_LIST_FOREACH(item->labels, l, key)
1057 char *s = item->gic->func.label_get
1058 ((void *)item->base.data, item->wd->self, l->data);
1061 edje_object_part_text_set(item->base.view, l->data, s);
1067 if (item->gic->func.icon_get)
1073 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1075 EINA_LIST_FOREACH(item->icons, l, key)
1077 Evas_Object *ic = item->gic->func.icon_get
1078 ((void *)item->base.data, item->wd->self, l->data);
1081 item->icon_objs = eina_list_append(item->icon_objs, ic);
1082 edje_object_part_swallow(item->base.view, key, ic);
1083 evas_object_show(ic);
1084 elm_widget_sub_object_add(item->wd->self, ic);
1089 if (item->gic->func.state_get)
1095 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1097 EINA_LIST_FOREACH(item->states, l, key)
1099 Eina_Bool on = item->gic->func.state_get
1100 ((void *)item->base.data, item->wd->self, l->data);
1103 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1104 edje_object_signal_emit(item->base.view, buf, "elm");
1109 if ((!item->wd->item_width) && (!item->wd->item_height))
1111 edje_object_size_min_restricted_calc(item->base.view,
1112 &item->wd->item_width,
1113 &item->wd->item_height,
1114 item->wd->item_width,
1115 item->wd->item_height);
1116 elm_coords_finger_size_adjust(1, &item->wd->item_width,
1117 1, &item->wd->item_height);
1120 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1122 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
1124 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1128 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
1130 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
1132 evas_object_show(item->base.view);
1134 if (item->tooltip.content_cb)
1136 elm_widget_item_tooltip_content_cb_set(item,
1137 item->tooltip.content_cb,
1138 item->tooltip.data, NULL);
1139 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1142 if (item->mouse_cursor)
1143 elm_widget_item_cursor_set(item, item->mouse_cursor);
1145 item->realized = EINA_TRUE;
1146 item->want_unrealize = EINA_FALSE;
1150 _item_unrealize(Elm_Gengrid_Item *item)
1154 if (!item->realized) return;
1155 if (item->long_timer)
1157 ecore_timer_del(item->long_timer);
1158 item->long_timer = NULL;
1160 evas_object_del(item->base.view);
1161 item->base.view = NULL;
1162 evas_object_del(item->spacer);
1163 item->spacer = NULL;
1164 elm_widget_stringlist_free(item->labels);
1165 item->labels = NULL;
1166 elm_widget_stringlist_free(item->icons);
1168 elm_widget_stringlist_free(item->states);
1169 item->states = NULL;
1171 EINA_LIST_FREE(item->icon_objs, icon)
1172 evas_object_del(icon);
1174 item->realized = EINA_FALSE;
1175 item->want_unrealize = EINA_FALSE;
1179 _reorder_item_moving_effect_timer_cb(void *data)
1181 Elm_Gengrid_Item *item = data;
1185 time = REORDER_EFFECT_TIME;
1186 t = ((0.0 > (t = ecore_loop_time_get()-item->moving_effect_start_time)) ? 0.0 : t);
1187 dx = ((item->tx - item->ox) / 10) * _elm_config->scale;
1188 dy = ((item->ty - item->oy) / 10) * _elm_config->scale;
1192 item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
1193 item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
1201 if ((((dx > 0) && (item->rx >= item->tx)) || ((dx <= 0) && (item->rx <= item->tx))) &&
1202 (((dy > 0) && (item->ry >= item->ty)) || ((dy <= 0) && (item->ry <= item->ty))))
1204 evas_object_move(item->base.view, item->tx, item->ty);
1205 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1206 item->moving = EINA_FALSE;
1207 item->item_moving_effect_timer = NULL;
1208 return ECORE_CALLBACK_CANCEL;
1211 evas_object_move(item->base.view, item->rx, item->ry);
1212 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1214 return ECORE_CALLBACK_RENEW;
1218 _item_place(Elm_Gengrid_Item *item,
1222 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh;
1223 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1224 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1227 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1229 /* Preload rows/columns at each side of the Gengrid */
1230 cvx = ox - PRELOAD * item->wd->item_width;
1231 cvy = oy - PRELOAD * item->wd->item_height;
1232 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1233 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1238 if (item->wd->horizontal)
1240 int columns, items_visible = 0, items_row;
1242 if (item->wd->item_height > 0)
1243 items_visible = vh / item->wd->item_height;
1244 if (items_visible < 1)
1247 columns = item->wd->count / items_visible;
1248 if (item->wd->count % items_visible)
1251 tcw = item->wd->item_width * columns;
1252 alignw = (vw - tcw) * item->wd->align_x;
1254 items_row = items_visible;
1255 if (items_row > item->wd->count)
1256 items_row = item->wd->count;
1257 tch = items_row * item->wd->item_height;
1258 alignh = (vh - tch) * item->wd->align_y;
1262 int rows, items_visible = 0, items_col;
1264 if (item->wd->item_width > 0)
1265 items_visible = vw / item->wd->item_width;
1266 if (items_visible < 1)
1269 rows = item->wd->count / items_visible;
1270 if (item->wd->count % items_visible)
1273 tch = item->wd->item_height * rows;
1274 alignh = (vh - tch) * item->wd->align_y;
1276 items_col = items_visible;
1277 if (items_col > item->wd->count)
1278 items_col = item->wd->count;
1279 tcw = items_col * item->wd->item_width;
1280 alignw = (vw - tcw) * item->wd->align_x;
1283 x = cx * item->wd->item_width - item->wd->pan_x + ox + alignw;
1284 if (elm_widget_mirrored_get(item->wd->self))
1285 { /* Switch items side and componsate for pan_x when in RTL mode */
1287 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1288 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1291 y = cy * item->wd->item_height - item->wd->pan_y + oy + alignh;
1293 Eina_Bool was_realized = item->realized;
1294 if (ELM_RECTS_INTERSECT(x, y, item->wd->item_width, item->wd->item_height,
1295 cvx, cvy, cvw, cvh))
1297 _item_realize(item);
1299 evas_object_smart_callback_call(item->wd->self, SIG_REALIZED, item);
1300 if (item->wd->reorder_mode)
1302 if (item->wd->reorder_item)
1304 if (item->moving) return;
1306 if (!item->wd->move_effect_enabled)
1311 if (item->wd->reorder_item == item)
1313 evas_object_move(item->base.view,
1314 item->wd->reorder_item_x, item->wd->reorder_item_y);
1315 evas_object_resize(item->base.view,
1316 item->wd->item_width, item->wd->item_height);
1321 if (item->wd->move_effect_enabled)
1323 if ((item->ox != x) || (item->oy != y))
1325 if (((item->wd->old_pan_x == item->wd->pan_x) && (item->wd->old_pan_y == item->wd->pan_y)) ||
1326 ((item->wd->old_pan_x != item->wd->pan_x) && !(item->ox - item->wd->pan_x + item->wd->old_pan_x == x)) ||
1327 ((item->wd->old_pan_y != item->wd->pan_y) && !(item->oy - item->wd->pan_y + item->wd->old_pan_y == y)))
1331 item->rx = item->ox;
1332 item->ry = item->oy;
1333 item->moving = EINA_TRUE;
1334 item->moving_effect_start_time = ecore_loop_time_get();
1335 item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, item);
1341 if (ELM_RECTS_INTERSECT(item->wd->reorder_item_x, item->wd->reorder_item_y,
1342 item->wd->item_width, item->wd->item_height,
1343 x+(item->wd->item_width/2), y+(item->wd->item_height/2),
1346 if (item->wd->horizontal)
1348 if ((item->wd->nmax * item->wd->reorder_item->x + item->wd->reorder_item->y) >
1349 (item->wd->nmax * item->x + item->y))
1350 reorder_item_move_forward = EINA_TRUE;
1354 if ((item->wd->nmax * item->wd->reorder_item->y + item->wd->reorder_item->x) >
1355 (item->wd->nmax * item->y + item->x))
1356 reorder_item_move_forward = EINA_TRUE;
1359 item->wd->items = eina_inlist_remove(item->wd->items,
1360 EINA_INLIST_GET(item->wd->reorder_item));
1361 if (reorder_item_move_forward)
1362 item->wd->items = eina_inlist_prepend_relative(item->wd->items,
1363 EINA_INLIST_GET(item->wd->reorder_item),
1364 EINA_INLIST_GET(item));
1366 item->wd->items = eina_inlist_append_relative(item->wd->items,
1367 EINA_INLIST_GET(item->wd->reorder_item),
1368 EINA_INLIST_GET(item));
1370 item->wd->reorder_item_changed = EINA_TRUE;
1371 item->wd->move_effect_enabled = EINA_TRUE;
1372 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1373 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1379 else if (item->item_moving_effect_timer)
1381 ecore_animator_del(item->item_moving_effect_timer);
1382 item->item_moving_effect_timer = NULL;
1383 item->moving = EINA_FALSE;
1386 evas_object_move(item->base.view, x, y);
1387 evas_object_resize(item->base.view, item->wd->item_width,
1388 item->wd->item_height);
1392 _item_unrealize(item);
1394 evas_object_smart_callback_call(item->wd->self, SIG_UNREALIZED, item);
1398 static Elm_Gengrid_Item *
1399 _item_create(Widget_Data *wd,
1400 const Elm_Gengrid_Item_Class *gic,
1403 const void *func_data)
1405 Elm_Gengrid_Item *item;
1407 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1408 if (!item) return NULL;
1412 item->base.data = data;
1413 item->func.func = func;
1414 item->func.data = func_data;
1415 item->mouse_cursor = NULL;
1420 _item_del(Elm_Gengrid_Item *item)
1422 elm_widget_item_pre_notify_del(item);
1424 item->wd->selected = eina_list_remove(item->wd->selected, item);
1425 if (item->realized) _item_unrealize(item);
1426 if ((!item->delete_me) && (item->gic->func.del))
1427 item->gic->func.del((void *)item->base.data, item->wd->self);
1428 item->delete_me = EINA_TRUE;
1429 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1430 if (item->long_timer) ecore_timer_del(item->long_timer);
1431 if (item->tooltip.del_cb)
1432 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1433 item->wd->walking -= item->walking;
1435 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1436 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1437 elm_widget_item_del(item);
1441 _item_select(Elm_Gengrid_Item *item)
1443 if ((item->wd->no_select) || (item->delete_me)) return;
1446 if (item->wd->always_select) goto call;
1449 item->selected = EINA_TRUE;
1450 item->wd->selected = eina_list_append(item->wd->selected, item);
1453 item->wd->walking++;
1454 if (item->func.func)
1455 item->func.func((void *)item->func.data, item->wd->self, item);
1456 if (!item->delete_me)
1457 evas_object_smart_callback_call(item->wd->self, SIG_SELECTED, item);
1459 item->wd->walking--;
1460 item->wd->last_selected_item = item;
1461 if ((item->wd->clear_me) && (!item->wd->walking))
1462 elm_gengrid_clear(item->base.widget);
1465 if ((!item->walking) && (item->delete_me))
1466 if (!item->relcount) _item_del(item);
1471 _item_unselect(Elm_Gengrid_Item *item)
1473 if ((item->delete_me) || (!item->hilighted)) return;
1474 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1475 item->hilighted = EINA_FALSE;
1478 item->selected = EINA_FALSE;
1479 item->wd->selected = eina_list_remove(item->wd->selected, item);
1480 evas_object_smart_callback_call(item->wd->self, SIG_UNSELECTED, item);
1485 _calc_job(void *data)
1487 Widget_Data *wd = data;
1488 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1491 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1492 if ((cvw != 0) || (cvh != 0))
1494 if ((wd->horizontal) && (wd->item_height > 0))
1495 nmax = cvh / wd->item_height;
1496 else if (wd->item_width > 0)
1497 nmax = cvw / wd->item_width;
1505 minw = ceil(count / (float)nmax) * wd->item_width;
1506 minh = nmax * wd->item_height;
1510 minw = nmax * wd->item_width;
1511 minh = ceil(count / (float)nmax) * wd->item_height;
1514 if ((minw != wd->minw) || (minh != wd->minh))
1518 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1522 evas_object_smart_changed(wd->pan_smart);
1524 wd->calc_job = NULL;
1528 _pan_add(Evas_Object *obj)
1531 Evas_Object_Smart_Clipped_Data *cd;
1534 cd = evas_object_smart_data_get(obj);
1537 sd->__clipped_data = *cd;
1539 evas_object_smart_data_set(obj, sd);
1543 _pan_del(Evas_Object *obj)
1545 Pan *sd = evas_object_smart_data_get(obj);
1552 _pan_set(Evas_Object *obj,
1556 Pan *sd = evas_object_smart_data_get(obj);
1557 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1560 evas_object_smart_changed(obj);
1564 _pan_get(Evas_Object *obj,
1568 Pan *sd = evas_object_smart_data_get(obj);
1569 if (x) *x = sd->wd->pan_x;
1570 if (y) *y = sd->wd->pan_y;
1574 _pan_child_size_get(Evas_Object *obj,
1578 Pan *sd = evas_object_smart_data_get(obj);
1579 if (w) *w = sd->wd->minw;
1580 if (h) *h = sd->wd->minh;
1584 _pan_max_get(Evas_Object *obj,
1588 Pan *sd = evas_object_smart_data_get(obj);
1592 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1594 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1596 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1600 _pan_min_get(Evas_Object *obj,
1604 Pan *sd = evas_object_smart_data_get(obj);
1608 _pan_max_get(obj, &mx, &my);
1610 *x = -mx * sd->wd->align_x;
1612 *y = -my * sd->wd->align_y;
1616 _pan_resize(Evas_Object *obj,
1620 Pan *sd = evas_object_smart_data_get(obj);
1623 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1624 if ((ow == w) && (oh == h)) return;
1625 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1626 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1630 _pan_calculate(Evas_Object *obj)
1632 Pan *sd = evas_object_smart_data_get(obj);
1633 Evas_Coord cx = 0, cy = 0;
1634 Elm_Gengrid_Item *item;
1637 if (!sd->wd->nmax) return;
1639 sd->wd->reorder_item_changed = EINA_FALSE;
1641 EINA_INLIST_FOREACH(sd->wd->items, item)
1643 _item_place(item, cx, cy);
1644 if (sd->wd->reorder_item_changed) return;
1645 if (sd->wd->horizontal)
1647 cy = (cy + 1) % sd->wd->nmax;
1652 cx = (cx + 1) % sd->wd->nmax;
1657 if ((sd->wd->reorder_mode) && (sd->wd->reorder_item))
1659 if (!sd->wd->reorder_item_changed)
1661 sd->wd->old_pan_x = sd->wd->pan_x;
1662 sd->wd->old_pan_y = sd->wd->pan_y;
1664 sd->wd->move_effect_enabled = EINA_FALSE;
1666 evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
1670 _pan_move(Evas_Object *obj,
1671 Evas_Coord x __UNUSED__,
1672 Evas_Coord y __UNUSED__)
1674 Pan *sd = evas_object_smart_data_get(obj);
1676 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1677 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1681 _hold_on(void *data __UNUSED__,
1683 void *event_info __UNUSED__)
1685 Widget_Data *wd = elm_widget_data_get(obj);
1687 elm_smart_scroller_hold_set(wd->scr, 1);
1691 _hold_off(void *data __UNUSED__,
1693 void *event_info __UNUSED__)
1695 Widget_Data *wd = elm_widget_data_get(obj);
1697 elm_smart_scroller_hold_set(wd->scr, 0);
1701 _freeze_on(void *data __UNUSED__,
1703 void *event_info __UNUSED__)
1705 Widget_Data *wd = elm_widget_data_get(obj);
1707 elm_smart_scroller_freeze_set(wd->scr, 1);
1711 _freeze_off(void *data __UNUSED__,
1713 void *event_info __UNUSED__)
1715 Widget_Data *wd = elm_widget_data_get(obj);
1717 elm_smart_scroller_freeze_set(wd->scr, 0);
1721 _scr_anim_start(void *data,
1722 Evas_Object *obj __UNUSED__,
1723 void *event_info __UNUSED__)
1725 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1729 _scr_anim_stop(void *data,
1730 Evas_Object *obj __UNUSED__,
1731 void *event_info __UNUSED__)
1733 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1737 _scr_drag_start(void *data,
1738 Evas_Object *obj __UNUSED__,
1739 void *event_info __UNUSED__)
1741 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1745 _scr_drag_stop(void *data,
1746 Evas_Object *obj __UNUSED__,
1747 void *event_info __UNUSED__)
1749 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1753 _scr_scroll(void *data,
1754 Evas_Object *obj __UNUSED__,
1755 void *event_info __UNUSED__)
1757 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1761 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1763 const Elm_Gengrid_Item *item = data;
1764 const Elm_Gengrid_Item *item1 = data1;
1766 return _elm_gengrid_item_compare_data_cb(item->base.data, item1->base.data);
1770 _elm_gengrid_item_compare(const void *data, const void *data1)
1772 Elm_Gengrid_Item *item, *item1;
1773 item = ELM_GENGRID_ITEM_FROM_INLIST(data);
1774 item1 = ELM_GENGRID_ITEM_FROM_INLIST(data1);
1775 return _elm_gengrid_item_compare_cb(item, item1);
1779 * Add a new Gengrid object.
1781 * @param parent The parent object.
1782 * @return The new object or NULL if it cannot be created.
1784 * @see elm_gengrid_item_size_set()
1785 * @see elm_gengrid_horizontal_set()
1786 * @see elm_gengrid_item_append()
1787 * @see elm_gengrid_item_del()
1788 * @see elm_gengrid_clear()
1793 elm_gengrid_add(Evas_Object *parent)
1798 static Evas_Smart *smart = NULL;
1799 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1801 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1803 ELM_SET_WIDTYPE(widtype, "gengrid");
1804 elm_widget_type_set(obj, "gengrid");
1805 elm_widget_sub_object_add(parent, obj);
1806 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1807 elm_widget_data_set(obj, wd);
1808 elm_widget_del_hook_set(obj, _del_hook);
1809 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1810 elm_widget_theme_hook_set(obj, _theme_hook);
1811 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1812 elm_widget_can_focus_set(obj, EINA_TRUE);
1813 elm_widget_event_hook_set(obj, _event_hook);
1815 wd->scr = elm_smart_scroller_add(e);
1816 elm_smart_scroller_widget_set(wd->scr, obj);
1817 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1819 elm_widget_resize_object_set(obj, wd->scr);
1821 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1822 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1823 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1824 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1825 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1827 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1832 wd->h_bounce = bounce;
1833 wd->v_bounce = bounce;
1834 wd->no_select = EINA_FALSE;
1836 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1837 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1838 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1839 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1841 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1845 static Evas_Smart_Class sc;
1847 evas_object_smart_clipped_smart_set(&_pan_sc);
1849 sc.name = "elm_gengrid_pan";
1850 sc.version = EVAS_SMART_CLASS_VERSION;
1853 sc.resize = _pan_resize;
1854 sc.move = _pan_move;
1855 sc.calculate = _pan_calculate;
1856 smart = evas_smart_class_new(&sc);
1860 wd->pan_smart = evas_object_smart_add(e, smart);
1861 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1865 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1866 _pan_set, _pan_get, _pan_max_get,
1867 _pan_min_get, _pan_child_size_get);
1869 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1874 * Set the size for the item of the Gengrid.
1876 * @param obj The Gengrid object.
1877 * @param w The item's width.
1878 * @param h The item's height;
1880 * @see elm_gengrid_item_size_get()
1885 elm_gengrid_item_size_set(Evas_Object *obj,
1889 ELM_CHECK_WIDTYPE(obj, widtype);
1890 Widget_Data *wd = elm_widget_data_get(obj);
1892 if ((wd->item_width == w) && (wd->item_height == h)) return;
1894 wd->item_height = h;
1895 if (wd->calc_job) ecore_job_del(wd->calc_job);
1896 wd->calc_job = ecore_job_add(_calc_job, wd);
1900 * Get the size of the item of the Gengrid.
1902 * @param obj The Gengrid object.
1903 * @param w Pointer to the item's width.
1904 * @param h Pointer to the item's height.
1906 * @see elm_gengrid_item_size_get()
1911 elm_gengrid_item_size_get(const Evas_Object *obj,
1915 ELM_CHECK_WIDTYPE(obj, widtype);
1916 Widget_Data *wd = elm_widget_data_get(obj);
1918 if (w) *w = wd->item_width;
1919 if (h) *h = wd->item_height;
1923 * Set item's alignment within the scroller.
1925 * @param obj The Gengrid object.
1926 * @param align_x The x alignment (0 <= x <= 1).
1927 * @param align_y The y alignment (0 <= y <= 1).
1929 * @see elm_gengrid_align_get()
1934 elm_gengrid_align_set(Evas_Object *obj,
1938 ELM_CHECK_WIDTYPE(obj, widtype);
1939 Widget_Data *wd = elm_widget_data_get(obj);
1943 else if (align_x < 0.0)
1945 wd->align_x = align_x;
1949 else if (align_y < 0.0)
1951 wd->align_y = align_y;
1955 * Get the alignenment set for the Gengrid object.
1957 * @param obj The Gengrid object.
1958 * @param align_x Pointer to x alignenment.
1959 * @param align_y Pointer to y alignenment.
1961 * @see elm_gengrid_align_set()
1966 elm_gengrid_align_get(const Evas_Object *obj,
1970 ELM_CHECK_WIDTYPE(obj, widtype);
1971 Widget_Data *wd = elm_widget_data_get(obj);
1972 if (align_x) *align_x = wd->align_x;
1973 if (align_y) *align_y = wd->align_y;
1977 * Add item to the end of the Gengrid.
1979 * @param obj The Gengrid object.
1980 * @param gic The item class for the item.
1981 * @param data The item data.
1982 * @param func Convenience function called when item is selected.
1983 * @param func_data Data passed to @p func above.
1984 * @return A handle to the item added or NULL if not possible.
1986 * @see elm_gengrid_item_prepend()
1987 * @see elm_gengrid_item_insert_before()
1988 * @see elm_gengrid_item_insert_after()
1989 * @see elm_gengrid_item_del()
1993 EAPI Elm_Gengrid_Item *
1994 elm_gengrid_item_append(Evas_Object *obj,
1995 const Elm_Gengrid_Item_Class *gic,
1998 const void *func_data)
2000 Elm_Gengrid_Item *item;
2001 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2002 Widget_Data *wd = elm_widget_data_get(obj);
2003 if (!wd) return NULL;
2005 item = _item_create(wd, gic, data, func, func_data);
2006 if (!item) return NULL;
2007 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
2009 if (wd->calc_job) ecore_job_del(wd->calc_job);
2010 wd->calc_job = ecore_job_add(_calc_job, wd);
2016 * Add item at start of the Gengrid.
2018 * This adds an item to the beginning of the grid.
2020 * @param obj The Gengrid object.
2021 * @param gic The item class for the item.
2022 * @param data The item data.
2023 * @param func Convenience function called when item is selected.
2024 * @param func_data Data passed to @p func above.
2025 * @return A handle to the item added or NULL if not possible.
2027 * @see elm_gengrid_item_append()
2028 * @see elm_gengrid_item_insert_before()
2029 * @see elm_gengrid_item_insert_after()
2030 * @see elm_gengrid_item_del()
2034 EAPI Elm_Gengrid_Item *
2035 elm_gengrid_item_prepend(Evas_Object *obj,
2036 const Elm_Gengrid_Item_Class *gic,
2039 const void *func_data)
2041 Elm_Gengrid_Item *item;
2042 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2043 Widget_Data *wd = elm_widget_data_get(obj);
2044 if (!wd) return NULL;
2046 item = _item_create(wd, gic, data, func, func_data);
2047 if (!item) return NULL;
2048 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
2050 if (wd->calc_job) ecore_job_del(wd->calc_job);
2051 wd->calc_job = ecore_job_add(_calc_job, wd);
2057 * Insert and item before another in the Gengrid.
2059 * This inserts an item before another in the grid.
2061 * @param obj The Gengrid object.
2062 * @param gic The item class for the item.
2063 * @param data The item data.
2064 * @param relative The item to which insert before.
2065 * @param func Convenience function called when item is selected.
2066 * @param func_data Data passed to @p func above.
2067 * @return A handle to the item added or NULL if not possible.
2069 * @see elm_gengrid_item_append()
2070 * @see elm_gengrid_item_prepend()
2071 * @see elm_gengrid_item_insert_after()
2072 * @see elm_gengrid_item_del()
2076 EAPI Elm_Gengrid_Item *
2077 elm_gengrid_item_insert_before(Evas_Object *obj,
2078 const Elm_Gengrid_Item_Class *gic,
2080 Elm_Gengrid_Item *relative,
2082 const void *func_data)
2084 Elm_Gengrid_Item *item;
2085 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2086 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2087 Widget_Data *wd = elm_widget_data_get(obj);
2088 if (!wd) return NULL;
2090 item = _item_create(wd, gic, data, func, func_data);
2091 if (!item) return NULL;
2092 wd->items = eina_inlist_prepend_relative
2093 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
2095 if (wd->calc_job) ecore_job_del(wd->calc_job);
2096 wd->calc_job = ecore_job_add(_calc_job, wd);
2102 * Insert and item after another in the Gengrid.
2104 * This inserts an item after another in the grid.
2106 * @param obj The Gengrid object.
2107 * @param gic The item class for the item.
2108 * @param data The item data.
2109 * @param relative The item to which insert after.
2110 * @param func Convenience function called when item is selected.
2111 * @param func_data Data passed to @p func above.
2112 * @return A handle to the item added or NULL if not possible.
2114 * @see elm_gengrid_item_append()
2115 * @see elm_gengrid_item_prepend()
2116 * @see elm_gengrid_item_insert_before()
2117 * @see elm_gengrid_item_del()
2121 EAPI Elm_Gengrid_Item *
2122 elm_gengrid_item_insert_after(Evas_Object *obj,
2123 const Elm_Gengrid_Item_Class *gic,
2125 Elm_Gengrid_Item *relative,
2127 const void *func_data)
2129 Elm_Gengrid_Item *item;
2130 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2131 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2132 Widget_Data *wd = elm_widget_data_get(obj);
2133 if (!wd) return NULL;
2135 item = _item_create(wd, gic, data, func, func_data);
2136 if (!item) return NULL;
2137 wd->items = eina_inlist_append_relative
2138 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
2140 if (wd->calc_job) ecore_job_del(wd->calc_job);
2141 wd->calc_job = ecore_job_add(_calc_job, wd);
2146 EAPI Elm_Gengrid_Item *
2147 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
2148 const Elm_Gengrid_Item_Class *gic,
2150 Eina_Compare_Cb comp,
2152 const void *func_data)
2154 Elm_Gengrid_Item *item;
2155 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2156 Widget_Data *wd = elm_widget_data_get(obj);
2157 if (!wd) return NULL;
2159 item = _item_create(wd, gic, data, func, func_data);
2160 if (!item) return NULL;
2162 _elm_gengrid_item_compare_cb = comp;
2163 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(item),
2164 _elm_gengrid_item_compare);
2165 if (wd->calc_job) ecore_job_del(wd->calc_job);
2166 wd->calc_job = ecore_job_add(_calc_job, wd);
2171 EAPI Elm_Gengrid_Item *
2172 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2173 const Elm_Gengrid_Item_Class *gic,
2175 Eina_Compare_Cb comp,
2177 const void *func_data)
2179 _elm_gengrid_item_compare_data_cb = comp;
2181 return elm_gengrid_item_direct_sorted_insert(obj, gic, data, _elm_gengrid_item_compare_data, func, func_data);
2185 * Remove an item from the Gengrid.
2187 * @param item The item to be removed.
2188 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise.
2190 * @see elm_gengrid_clear() to remove all items of the Gengrid.
2195 elm_gengrid_item_del(Elm_Gengrid_Item *item)
2197 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2198 if ((item->relcount > 0) || (item->walking > 0))
2200 item->delete_me = EINA_TRUE;
2201 elm_widget_item_pre_notify_del(item);
2203 item->wd->selected = eina_list_remove(item->wd->selected, item);
2204 if (item->gic->func.del)
2205 item->gic->func.del((void *)item->base.data, item->wd->self);
2213 * Set for what direction the Gengrid will expand.
2215 * @param obj The Gengrid object.
2216 * @param setting If @c EINA_TRUE the Gengrid will expand horizontally
2217 * or vertically if @c EINA_FALSE.
2222 elm_gengrid_horizontal_set(Evas_Object *obj,
2225 ELM_CHECK_WIDTYPE(obj, widtype);
2226 Widget_Data *wd = elm_widget_data_get(obj);
2228 if (setting == wd->horizontal) return;
2229 wd->horizontal = setting;
2231 /* Update the items to conform to the new layout */
2232 if (wd->calc_job) ecore_job_del(wd->calc_job);
2233 wd->calc_job = ecore_job_add(_calc_job, wd);
2237 * Get for what direction the Gengrid is expanded.
2239 * @param obj The Gengrid object.
2240 * @return If the Gengrid is expanded horizontally return @c EINA_TRUE
2241 * else @c EINA_FALSE.
2246 elm_gengrid_horizontal_get(const Evas_Object *obj)
2248 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2249 Widget_Data *wd = elm_widget_data_get(obj);
2250 if (!wd) return EINA_FALSE;
2251 return wd->horizontal;
2257 * This clears all items in the Gengrid, leaving it empty.
2259 * @param obj The Gengrid object.
2261 * @see elm_gengrid_item_del() to remove just one item.
2266 elm_gengrid_clear(Evas_Object *obj)
2268 ELM_CHECK_WIDTYPE(obj, widtype);
2269 Widget_Data *wd = elm_widget_data_get(obj);
2274 ecore_job_del(wd->calc_job);
2275 wd->calc_job = NULL;
2278 if (wd->walking > 0)
2280 Elm_Gengrid_Item *item;
2282 EINA_INLIST_FOREACH(wd->items, item)
2283 item->delete_me = 1;
2289 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2291 wd->items = eina_inlist_remove(wd->items, wd->items);
2292 elm_widget_item_pre_notify_del(item);
2293 if (item->realized) _item_unrealize(item);
2294 if (item->gic->func.del)
2295 item->gic->func.del((void *)item->base.data, wd->self);
2296 if (item->long_timer) ecore_timer_del(item->long_timer);
2297 elm_widget_item_del(item);
2302 eina_list_free(wd->selected);
2303 wd->selected = NULL;
2311 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2312 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2316 * Get the real evas object of the Gengrid item
2318 * This returns the actual evas object used for the specified Gengrid
2319 * item. This may be NULL as it may not be created, and may be
2320 * deleted at any time by Gengrid. Do not modify this object (move,
2321 * resize, show, hide etc.) as Gengrid is controlling it. This
2322 * function is for querying, emitting custom signals or hooking lower
2323 * level callbacks for events. Do not delete this object under any
2326 * @param item The Gengrid item.
2327 * @return the evas object associated to this item.
2329 * @see elm_gengrid_item_data_get()
2333 EAPI const Evas_Object *
2334 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
2336 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2337 return item->base.view;
2341 * Update the contents of an item
2343 * This updates an item by calling all the item class functions again
2344 * to get the icons, labels and states. Use this when the original
2345 * item data has changed and the changes are desired to be reflected.
2347 * @param item The item
2352 elm_gengrid_item_update(Elm_Gengrid_Item *item)
2354 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2355 if (!item->realized) return;
2356 if (item->want_unrealize) return;
2357 _item_unrealize(item);
2358 _item_realize(item);
2359 _item_place(item, item->x, item->y);
2363 * Returns the data associated to an item
2365 * This returns the data value passed on the elm_gengrid_item_append()
2366 * and related item addition calls.
2368 * @param item The Gengrid item.
2369 * @return the data associated to this item.
2371 * @see elm_gengrid_item_append()
2372 * @see elm_gengrid_item_object_get()
2377 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2379 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2380 return elm_widget_item_data_get(item);
2384 * Set the datan item from the gengrid item
2386 * This set the data value passed on the elm_gengrid_item_append() and
2387 * related item addition calls. This function will also call
2388 * elm_gengrid_item_update() so the item will be updated to reflect
2391 * @param item The item
2392 * @param data The new data pointer to set
2397 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2400 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2401 elm_widget_item_data_set(item, data);
2402 elm_gengrid_item_update(item);
2405 EAPI const Elm_Gengrid_Item_Class *
2406 elm_gengrid_item_item_class_get(const Elm_Gengrid_Item *item)
2408 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2409 if (item->delete_me) return NULL;
2414 elm_gengrid_item_item_class_set(Elm_Gengrid_Item *item,
2415 const Elm_Gengrid_Item_Class *gic)
2417 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2418 EINA_SAFETY_ON_NULL_RETURN(gic);
2419 if (item->delete_me) return;
2421 elm_gengrid_item_update(item);
2425 * Get the item's coordinates.
2427 * This returns the logical position of the item whithin the Gengrid.
2429 * @param item The Gengrid item.
2430 * @param x The x-axis coordinate pointer.
2431 * @param y The y-axis coordinate pointer.
2436 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2440 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2441 if (x) *x = item->x;
2442 if (y) *y = item->y;
2446 * Enable or disable multi-select in the Gengrid.
2448 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
2449 * the Gengrid. This allows more than 1 item to be selected.
2451 * @param obj The Gengrid object.
2452 * @param multi Multi-select enabled/disabled
2457 elm_gengrid_multi_select_set(Evas_Object *obj,
2460 ELM_CHECK_WIDTYPE(obj, widtype);
2461 Widget_Data *wd = elm_widget_data_get(obj);
2467 * Get if multi-select in Gengrid is enabled or disabled
2469 * @param obj The Gengrid object
2470 * @return Multi-select enable/disable
2471 * (EINA_TRUE = enabled / EINA_FALSE = disabled)
2476 elm_gengrid_multi_select_get(const Evas_Object *obj)
2478 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2479 Widget_Data *wd = elm_widget_data_get(obj);
2480 if (!wd) return EINA_FALSE;
2485 * Get the selected item in the Gengrid
2487 * This gets the selected item in the Gengrid (if multi-select is
2488 * enabled only the first item in the list is selected - which is not
2489 * very useful, so see elm_gengrid_selected_items_get() for when
2490 * multi-select is used).
2492 * If no item is selected, NULL is returned.
2494 * @param obj The Gengrid object.
2495 * @return The selected item, or NULL if none.
2499 EAPI Elm_Gengrid_Item *
2500 elm_gengrid_selected_item_get(const Evas_Object *obj)
2502 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2503 Widget_Data *wd = elm_widget_data_get(obj);
2504 if (!wd) return NULL;
2505 if (wd->selected) return wd->selected->data;
2510 * Get a list of selected items in the Gengrid.
2512 * This returns a list of the selected items. This list pointer is
2513 * only valid so long as no items are selected or unselected (or
2514 * unselected implictly by deletion). The list contains
2515 * Elm_Gengrid_Item pointers.
2517 * @param obj The Gengrid object.
2518 * @return The list of selected items, or NULL if none are selected.
2522 EAPI const Eina_List *
2523 elm_gengrid_selected_items_get(const Evas_Object *obj)
2525 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2526 Widget_Data *wd = elm_widget_data_get(obj);
2527 if (!wd) return NULL;
2528 return wd->selected;
2532 * Set the selected state of an item.
2534 * This sets the selected state of an item. If multi-select is not
2535 * enabled and selected is EINA_TRUE, previously selected items are
2538 * @param item The item
2539 * @param selected The selected state.
2544 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2547 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2548 Widget_Data *wd = item->wd;
2550 if (item->delete_me) return;
2551 selected = !!selected;
2552 if (item->selected == selected) return;
2558 while (wd->selected)
2559 _item_unselect(wd->selected->data);
2561 _item_hilight(item);
2565 _item_unselect(item);
2569 * Get the selected state of an item.
2571 * This gets the selected state of an item (1 selected, 0 not selected).
2573 * @param item The item
2574 * @return The selected state
2579 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2581 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2582 return item->selected;
2586 * Sets the disabled state of an item.
2588 * A disabled item cannot be selected or unselected. It will also
2589 * change appearance to disabled. This sets the disabled state (1
2590 * disabled, 0 not disabled).
2592 * @param item The item
2593 * @param disabled The disabled state
2598 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2601 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2602 if (item->disabled == disabled) return;
2603 if (item->delete_me) return;
2604 item->disabled = !!disabled;
2608 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2610 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2615 * Get the disabled state of an item.
2617 * This gets the disabled state of the given item.
2619 * @param item The item
2620 * @return The disabled state
2625 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2627 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2628 if (item->delete_me) return EINA_FALSE;
2629 return item->disabled;
2632 static Evas_Object *
2633 _elm_gengrid_item_label_create(void *data,
2635 void *item __UNUSED__)
2637 Evas_Object *label = elm_label_add(obj);
2640 elm_object_style_set(label, "tooltip");
2641 elm_object_text_set(label, data);
2646 _elm_gengrid_item_label_del_cb(void *data,
2647 Evas_Object *obj __UNUSED__,
2648 void *event_info __UNUSED__)
2650 eina_stringshare_del(data);
2654 * Set the text to be shown in the gengrid item.
2656 * @param item Target item
2657 * @param text The text to set in the content
2659 * Setup the text as tooltip to object. The item can have only one
2660 * tooltip, so any previous tooltip data is removed.
2665 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2668 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2669 text = eina_stringshare_add(text);
2670 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2672 _elm_gengrid_item_label_del_cb);
2676 * Set the content to be shown in the tooltip item
2678 * Setup the tooltip to item. The item can have only one tooltip, so
2679 * any previous tooltip data is removed. @p func(with @p data) will be
2680 * called every time that need show the tooltip and it should return a
2681 * valid Evas_Object. This object is then managed fully by tooltip
2682 * system and is deleted when the tooltip is gone.
2684 * @param item the gengrid item being attached a tooltip.
2685 * @param func the function used to create the tooltip contents.
2686 * @param data what to provide to @a func as callback data/context.
2687 * @param del_cb called when data is not needed anymore, either when
2688 * another callback replaces @func, the tooltip is unset with
2689 * elm_gengrid_item_tooltip_unset() or the owner @an item
2690 * dies. This callback receives as the first parameter the
2691 * given @a data, and @c event_info is the item.
2696 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2697 Elm_Tooltip_Item_Content_Cb func,
2699 Evas_Smart_Cb del_cb)
2701 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2703 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2706 if (item->tooltip.del_cb)
2707 item->tooltip.del_cb((void *)item->tooltip.data,
2708 item->base.widget, item);
2709 item->tooltip.content_cb = func;
2710 item->tooltip.data = data;
2711 item->tooltip.del_cb = del_cb;
2712 if (item->base.view)
2714 elm_widget_item_tooltip_content_cb_set(item,
2715 item->tooltip.content_cb,
2716 item->tooltip.data, NULL);
2717 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2723 if (del_cb) del_cb((void *)data, NULL, NULL);
2727 * Unset tooltip from item
2729 * @param item gengrid item to remove previously set tooltip.
2731 * Remove tooltip from item. The callback provided as del_cb to
2732 * elm_gengrid_item_tooltip_content_cb_set() will be called to notify
2733 * it is not used anymore.
2735 * @see elm_gengrid_item_tooltip_content_cb_set()
2740 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2742 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2743 if ((item->base.view) && (item->tooltip.content_cb))
2744 elm_widget_item_tooltip_unset(item);
2746 if (item->tooltip.del_cb)
2747 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2748 item->tooltip.del_cb = NULL;
2749 item->tooltip.content_cb = NULL;
2750 item->tooltip.data = NULL;
2751 if (item->tooltip.style)
2752 elm_gengrid_item_tooltip_style_set(item, NULL);
2756 * Sets a different style for this item tooltip.
2758 * @note before you set a style you should define a tooltip with
2759 * elm_gengrid_item_tooltip_content_cb_set() or
2760 * elm_gengrid_item_tooltip_text_set()
2762 * @param item gengrid item with tooltip already set.
2763 * @param style the theme style to use (default, transparent, ...)
2768 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2771 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2772 eina_stringshare_replace(&item->tooltip.style, style);
2773 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2777 * Get the style for this item tooltip.
2779 * @param item gengrid item with tooltip already set.
2780 * @return style the theme style in use, defaults to "default". If the
2781 * object does not have a tooltip set, then NULL is returned.
2786 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2788 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2789 return item->tooltip.style;
2793 * Set the cursor to be shown when mouse is over the gengrid item
2795 * @param item Target item
2796 * @param cursor the cursor name to be used.
2798 * @see elm_object_cursor_set()
2802 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2805 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2806 eina_stringshare_replace(&item->mouse_cursor, cursor);
2807 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2811 * Get the cursor to be shown when mouse is over the gengrid item
2813 * @param item gengrid item with cursor already set.
2814 * @return the cursor name.
2819 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2821 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2822 return elm_widget_item_cursor_get(item);
2826 * Unset the cursor to be shown when mouse is over the gengrid item
2828 * @param item Target item
2830 * @see elm_object_cursor_unset()
2834 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2836 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2837 if (!item->mouse_cursor)
2840 if (item->base.view)
2841 elm_widget_item_cursor_unset(item);
2843 eina_stringshare_del(item->mouse_cursor);
2844 item->mouse_cursor = NULL;
2848 * Sets a different style for this item cursor.
2850 * @note before you set a style you should define a cursor with
2851 * elm_gengrid_item_cursor_set()
2853 * @param item gengrid item with cursor already set.
2854 * @param style the theme style to use (default, transparent, ...)
2859 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2862 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2863 elm_widget_item_cursor_style_set(item, style);
2867 * Get the style for this item cursor.
2869 * @param item gengrid item with cursor already set.
2870 * @return style the theme style in use, defaults to "default". If the
2871 * object does not have a cursor set, then NULL is returned.
2876 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2878 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2879 return elm_widget_item_cursor_style_get(item);
2883 * Set if the cursor set should be searched on the theme or should use
2884 * the provided by the engine, only.
2886 * @note before you set if should look on theme you should define a
2887 * cursor with elm_object_cursor_set(). By default it will only look
2888 * for cursors provided by the engine.
2890 * @param item widget item with cursor already set.
2891 * @param engine_only boolean to define it cursors should be looked
2892 * only between the provided by the engine or searched on widget's
2898 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2899 Eina_Bool engine_only)
2901 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2902 elm_widget_item_cursor_engine_only_set(item, engine_only);
2906 * Get the cursor engine only usage for this item cursor.
2908 * @param item widget item with cursor already set.
2909 * @return engine_only boolean to define it cursors should be looked
2910 * only between the provided by the engine or searched on widget's
2911 * theme as well. If the object does not have a cursor set, then
2912 * EINA_FALSE is returned.
2917 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2919 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2920 return elm_widget_item_cursor_engine_only_get(item);
2924 * Set the reorder mode
2926 * @param obj The Gengrid object
2927 * @param reorder_mode The reorder mode
2928 * (EINA_TRUE = on, EINA_FALSE = off)
2933 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2934 Eina_Bool reorder_mode)
2936 ELM_CHECK_WIDTYPE(obj, widtype);
2937 Widget_Data *wd = elm_widget_data_get(obj);
2939 wd->reorder_mode = reorder_mode;
2943 * Get the reorder mode
2945 * @param obj The Gengrid object
2946 * @return The reorder mode
2947 * (EINA_TRUE = on, EINA_FALSE = off)
2952 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2954 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2955 Widget_Data *wd = elm_widget_data_get(obj);
2956 if (!wd) return EINA_FALSE;
2957 return wd->reorder_mode;
2961 * Set the always select mode.
2963 * Cells will only call their selection func and callback when first
2964 * becoming selected. Any further clicks will do nothing, unless you
2965 * enable always select with
2966 * elm_gengrid_always_select_mode_set(). This means even if selected,
2967 * every click will make the selected callbacks be called.
2969 * @param obj The Gengrid object
2970 * @param always_select The always select mode (EINA_TRUE = on,
2976 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2977 Eina_Bool always_select)
2979 ELM_CHECK_WIDTYPE(obj, widtype);
2980 Widget_Data *wd = elm_widget_data_get(obj);
2982 wd->always_select = always_select;
2986 * Get the always select mode.
2988 * @param obj The Gengrid object.
2989 * @return The always select mode (EINA_TRUE = on, EINA_FALSE = off)
2994 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2996 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2997 Widget_Data *wd = elm_widget_data_get(obj);
2998 if (!wd) return EINA_FALSE;
2999 return wd->always_select;
3003 * Set no select mode.
3005 * This will turn off the ability to select items entirely and they
3006 * will neither appear selected nor call selected callback functions.
3008 * @param obj The Gengrid object
3009 * @param no_select The no select mode (EINA_TRUE = on, EINA_FALSE = off)
3014 elm_gengrid_no_select_mode_set(Evas_Object *obj,
3015 Eina_Bool no_select)
3017 ELM_CHECK_WIDTYPE(obj, widtype);
3018 Widget_Data *wd = elm_widget_data_get(obj);
3020 wd->no_select = no_select;
3024 * Gets no select mode.
3026 * @param obj The Gengrid object
3027 * @return The no select mode (EINA_TRUE = on, EINA_FALSE = off)
3032 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
3034 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3035 Widget_Data *wd = elm_widget_data_get(obj);
3036 if (!wd) return EINA_FALSE;
3037 return wd->no_select;
3043 * This will enable or disable the scroller bounce mode for the
3044 * Gengrid. See elm_scroller_bounce_set() for details.
3046 * @param obj The Gengrid object
3047 * @param h_bounce Allow bounce horizontally
3048 * @param v_bounce Allow bounce vertically
3053 elm_gengrid_bounce_set(Evas_Object *obj,
3057 ELM_CHECK_WIDTYPE(obj, widtype);
3058 Widget_Data *wd = elm_widget_data_get(obj);
3060 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
3061 wd->h_bounce = h_bounce;
3062 wd->v_bounce = v_bounce;
3066 * Get the bounce mode
3068 * @param obj The Gengrid object
3069 * @param h_bounce Allow bounce horizontally
3070 * @param v_bounce Allow bounce vertically
3075 elm_gengrid_bounce_get(const Evas_Object *obj,
3076 Eina_Bool *h_bounce,
3077 Eina_Bool *v_bounce)
3079 ELM_CHECK_WIDTYPE(obj, widtype);
3080 Widget_Data *wd = elm_widget_data_get(obj);
3082 *h_bounce = wd->h_bounce;
3083 *v_bounce = wd->v_bounce;
3087 * Get all items in the Gengrid.
3089 * This returns a list of the Gengrid items. The list contains
3090 * Elm_Gengrid_Item pointers.
3092 * @param obj The Gengrid object.
3093 * @return The list of items, or NULL if none.
3099 * Set gengrid scroll page size relative to viewport size.
3101 * The gengrid scroller is capable of limiting scrolling by the user
3102 * to "pages" That is to jump by and only show a "whole page" at a
3103 * time as if the continuous area of the scroller content is split
3104 * into page sized pieces. This sets the size of a page relative to
3105 * the viewport of the scroller. 1.0 is "1 viewport" is size
3106 * (horizontally or vertically). 0.0 turns it off in that axis. This
3107 * is mutually exclusive with page size (see
3108 * elm_gengrid_page_size_set() for more information). Likewise 0.5 is
3109 * "half a viewport". Sane usable valus are normally between 0.0 and
3110 * 1.0 including 1.0. If you only want 1 axis to be page "limited",
3111 * use 0.0 for the other axis.
3113 * @param obj The gengrid object
3114 * @param h_pagerel The horizontal page relative size
3115 * @param v_pagerel The vertical page relative size
3120 elm_gengrid_page_relative_set(Evas_Object *obj,
3124 Evas_Coord pagesize_h;
3125 Evas_Coord pagesize_v;
3127 ELM_CHECK_WIDTYPE(obj, widtype);
3128 Widget_Data *wd = elm_widget_data_get(obj);
3131 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
3132 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
3137 * Get gengrid scroll page size relative to viewport size.
3139 * The gengrid scroller is capable of limiting scrolling by the user
3140 * to "pages" That is to jump by and only show a "whole page" at a
3141 * time as if the continuous area of the scroller content is split
3142 * into page sized pieces. This sets the size of a page relative to
3143 * the viewport of the scroller. 1.0 is "1 viewport" is size
3144 * (horizontally or vertically). 0.0 turns it off in that axis. This
3145 * is mutually exclusive with page size (see
3146 * elm_gengrid_page_size_set() for more information). Likewise 0.5 is
3147 * "half a viewport". Sane usable valus are normally between 0.0 and
3148 * 1.0 including 1.0. If you only want 1 axis to be page "limited",
3149 * use 0.0 for the other axis.
3151 * @param obj The gengrid object
3152 * @param h_pagerel The horizontal page relative size
3153 * @param v_pagerel The vertical page relative size
3158 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
3160 ELM_CHECK_WIDTYPE(obj, widtype);
3161 Widget_Data *wd = elm_widget_data_get(obj);
3164 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
3168 * Set gengrid scroll page size.
3170 * See also elm_gengrid_page_relative_set(). This, instead of a page
3171 * size being relative to the viewport, sets it to an absolute fixed
3172 * value, with 0 turning it off for that axis.
3174 * @param obj The gengrid object
3175 * @param h_pagesize The horizontal page size
3176 * @param v_pagesize The vertical page size
3181 elm_gengrid_page_size_set(Evas_Object *obj,
3182 Evas_Coord h_pagesize,
3183 Evas_Coord v_pagesize)
3188 ELM_CHECK_WIDTYPE(obj, widtype);
3189 Widget_Data *wd = elm_widget_data_get(obj);
3191 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
3192 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
3197 * Get the first item in the gengrid
3199 * This returns the first item in the list.
3201 * @param obj The gengrid object
3202 * @return The first item, or NULL if none
3206 EAPI Elm_Gengrid_Item *
3207 elm_gengrid_first_item_get(const Evas_Object *obj)
3209 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3210 Widget_Data *wd = elm_widget_data_get(obj);
3211 if (!wd) return NULL;
3212 if (!wd->items) return NULL;
3213 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
3214 while ((item) && (item->delete_me))
3215 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
3220 * Get the last item in the gengrid
3222 * This returns the last item in the list.
3224 * @return The last item, or NULL if none
3228 EAPI Elm_Gengrid_Item *
3229 elm_gengrid_last_item_get(const Evas_Object *obj)
3231 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3232 Widget_Data *wd = elm_widget_data_get(obj);
3233 if (!wd) return NULL;
3234 if (!wd->items) return NULL;
3235 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
3236 while ((item) && (item->delete_me))
3237 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
3242 * Get the next item in the gengrid
3244 * This returns the item after the item @p item.
3246 * @param item The item
3247 * @return The item after @p item, or NULL if none
3251 EAPI Elm_Gengrid_Item *
3252 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
3254 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
3257 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
3258 if ((item) && (!item->delete_me)) break;
3260 return (Elm_Gengrid_Item *)item;
3264 * Get the previous item in the gengrid
3266 * This returns the item before the item @p item.
3268 * @param item The item
3269 * @return The item before @p item, or NULL if none
3273 EAPI Elm_Gengrid_Item *
3274 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
3276 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
3279 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
3280 if ((item) && (!item->delete_me)) break;
3282 return (Elm_Gengrid_Item *)item;
3286 * Get the gengrid object from an item
3288 * This returns the gengrid object itself that an item belongs to.
3290 * @param item The item
3291 * @return The gengrid object
3296 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
3298 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
3299 return item->base.widget;
3303 * Show the given item
3305 * This causes gengrid to jump to the given item @p item and show it
3306 * (by scrolling), if it is not fully visible.
3308 * @param item The item
3313 elm_gengrid_item_show(Elm_Gengrid_Item *item)
3315 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
3316 Widget_Data *wd = elm_widget_data_get(item->wd->self);
3317 Evas_Coord minx = 0, miny = 0;
3320 if ((!item) || (item->delete_me)) return;
3321 _pan_min_get(wd->pan_smart, &minx, &miny);
3323 elm_smart_scroller_child_region_show(item->wd->scr,
3324 item->x * wd->item_width + minx,
3325 item->y * wd->item_height + miny,
3326 item->wd->item_width,
3327 item->wd->item_height);
3331 * Bring in the given item
3333 * This causes gengrig to jump to the given item @p item and show it
3334 * (by scrolling), if it is not fully visible. This may use animation
3335 * to do so and take a period of time
3337 * @param item The item
3342 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
3344 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
3345 if (item->delete_me) return;
3347 Evas_Coord minx = 0, miny = 0;
3348 Widget_Data *wd = elm_widget_data_get(item->wd->self);
3350 _pan_min_get(wd->pan_smart, &minx, &miny);
3352 elm_smart_scroller_region_bring_in(item->wd->scr,
3353 item->x * wd->item_width + minx,
3354 item->y * wd->item_height + miny,
3355 item->wd->item_width,
3356 item->wd->item_height);