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 * Signals that you can add callbacks for are:
15 * clicked,double - The user has double-clicked or pressed enter on
16 * a item. The event_infoparameter is the Gengrid item
17 * that was double-clicked.
19 * selected - The user has made an item selected. The event_info
20 * parameter is the Gengrid item that was selected.
22 * unselected - The user has made an item unselected. The event_info
23 * parameter is the Gengrid item that was unselected.
25 * realized - This is called when the item in the Gengrid is created
26 * as a real evas object. event_info is the Gengrid item that was
27 * created. The object may be deleted at any time, so it is up to the
28 * caller to not use the object pointer from
29 * elm_gengrid_item_object_get() in a way where it may point to freed
32 * unrealized - This is called when the real evas object for this item
33 * is deleted. event_info is the Gengrid item that was created.
35 * changed - Called when an item is added, removed, resized or moved
36 * and when gengrid is resized or horizontal property changes.
38 * drag,start,up - Called when the item in the Gengrid has been
39 * dragged (not scrolled) up.
41 * drag,start,down - Called when the item in the Gengrid has been
42 * dragged (not scrolled) down.
44 * drag,start,left - Called when the item in the Gengrid has been
45 * dragged (not scrolled) left.
47 * drag,start,right - Called when the item in the Gengrid has been
48 * dragged (not scrolled) right.
50 * drag,stop - Called when the item in the Gengrid has stopped being
53 * drag - Called when the item in the Gengrid is being dragged.
55 * scroll - called when the content has been scrolled (moved).
57 * scroll,drag,start - called when dragging the content has started.
59 * scroll,drag,stop - called when dragging the content has stopped.
62 * A item in the Gengrid can have 0 or more text labels (they can be
63 * regular text or textblock - that's up to the style to determine), 0
64 * or more icons (which are simply objects swallowed into the Gengrid
65 * item) and 0 or more boolean states that can be used for check,
66 * radio or other indicators by the edje theme style. A item may be
67 * one of several styles (Elementary provides 1 by default -
68 * "default", but this can be extended by system or application custom
69 * themes/overlays/extensions).
71 * In order to implement the ability to add and delete items on the
72 * fly, Gengrid implements a class/callback system where the
73 * application provides a structure with information about that type
74 * of item (Gengrid may contain multiple different items with
75 * different classes, states and styles). Gengrid will call the
76 * functions in this struct (methods) when a item is "realized" (that
77 * is created dynamically while scrolling). All objects will simply be
78 * deleted when no longer needed with evas_object_del(). The
79 * Elm_GenGrid_Item_Class structure contains the following members:
81 * item_style - This is a constant string and simply defines the name
82 * of the item style. It must be specified and the default should be
85 * func.label_get - This function is called when an actual item object
86 * is created. The data parameter is the one passed to
87 * elm_gengrid_item_append() and related item creation functions. The
88 * obj parameter is the Gengrid object and the part parameter is the
89 * string name of the text part in the edje design that is listed as
90 * one of the possible labels that can be set. This function must
91 * return a strdup'()ed string as the caller will free() it when done.
93 * func.icon_get - This function is called when an actual item object
94 * is created. The data parameter is the one passed to
95 * elm_gengrid_item_append() and related item creation functions. The
96 * obj parameter is the Gengrid object and the part parameter is the
97 * string name of the icon part in the edje design that is listed as
98 * one of the possible icons that can be set. This must return NULL
99 * for no object or a valid object. The object will be deleted by
100 * Gengrid on shutdown or when the item is unrealized.
102 * func.state_get - This function is called when an actual item object
103 * is created. The data parameter is the one passed to
104 * elm_gengrid_item_append() and related item creation functions. The
105 * obj parameter is the Gengrid object and the part parameter is the
106 * string name of th state part in the edje design that is listed as
107 * one of the possible states that can be set. Return 0 for false and
108 * 1 for true. Gengrid will emit a signal to the edje object with
109 * "elm,state,XXX,active" "elm" when true (the default is false),
110 * where XXX is the name of the part.
112 * func.del - This is called when elm_gengrid_item_del() is called on
113 * a item or elm_gengrid_clear() is called on the Gengrid. This is
114 * intended for use when actual Gengrid items are deleted, so any
115 * backing data attached to the item (e.g. its data parameter on
116 * creation) can be deleted.
118 * If the application wants multiple items to be able to be selected,
119 * elm_gengrid_multi_select_set() can enable this. If the Gengrid is
120 * single-selection only (the default), then
121 * elm_gengrid_select_item_get() will return the selected item, if
122 * any, or NULL if none is selected. If the Gengrid is multi-select
123 * then elm_gengrid_selected_items_get() will return a list (that is
124 * only valid as long as no items are modified (added, deleted,
125 * selected or unselected).
127 * If a item changes (state of boolean changes, label or icons
128 * change), then use elm_gengrid_item_update() to have Gengrid update
129 * the item with the new state. Gengrid will re-realize the item thus
130 * call the functions in the _Elm_Gengrid_Item_Class for that item.
132 * To programmatically (un)select a item use
133 * elm_gengrid_item_selected_set(). To get its selected state use
134 * elm_gengrid_item_selected_get(). To make a item disabled (unable to
135 * be selected and appear differently) use
136 * elm_gengrid_item_disabled_set() to set this and
137 * elm_gengrid_item_disabled_get() to get the disabled state.
139 * Cells will only call their selection func and callback when first
140 * becoming selected. Any further clicks will do nothing, unless you
141 * enable always select with
142 * elm_gengrid_always_select_mode_set(). This means event if selected,
143 * every click will make the selected callbacks be called.
144 * elm_gengrid_no_select_mode_set() will turn off the ability to
145 * select items entirely and they will neither appear selected nor
146 * call selected callback function.
148 * Remember that you can create new styles and add your own theme
149 * augmentation per application with elm_theme_extension_add(). If you
150 * absolutely must have a specific style that overrides any theme the
151 * user or system sets up you can use elm_theme_overlay_add() to add
156 * * Handle non-homogeneous objects too.
159 typedef struct _Widget_Data Widget_Data;
160 typedef struct _Pan Pan;
164 struct _Elm_Gengrid_Item
166 Elm_Widget_Item base;
169 const Elm_Gengrid_Item_Class *gic;
170 Ecore_Timer *long_timer;
172 Eina_List *labels, *icons, *states, *icon_objs;
179 Evas_Coord x, y, dx, dy;
186 Elm_Tooltip_Item_Content_Cb content_cb;
187 Evas_Smart_Cb del_cb;
191 const char *mouse_cursor;
193 Eina_Bool want_unrealize : 1;
194 Eina_Bool realized : 1;
195 Eina_Bool dragging : 1;
197 Eina_Bool delete_me : 1;
198 Eina_Bool display_only : 1;
199 Eina_Bool disabled : 1;
200 Eina_Bool selected : 1;
201 Eina_Bool hilighted : 1;
206 Evas_Object *self, *scr;
207 Evas_Object *pan_smart;
212 Elm_Gengrid_Item *last_selected_item;
213 double align_x, align_y;
215 Evas_Coord pan_x, pan_y;
216 Evas_Coord item_width, item_height; /* Each item size */
217 Evas_Coord minw, minh; /* Total obj size */
222 Eina_Bool horizontal : 1;
223 Eina_Bool on_hold : 1;
224 Eina_Bool longpressed : 1;
226 Eina_Bool no_select : 1;
227 Eina_Bool wasselected : 1;
228 Eina_Bool always_select : 1;
229 Eina_Bool clear_me : 1;
232 #define ELM_GENGRID_ITEM_FROM_INLIST(item) \
233 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
237 Evas_Object_Smart_Clipped_Data __clipped_data;
241 static const char *widtype = NULL;
242 static void _item_hilight(Elm_Gengrid_Item *item);
243 static void _item_unrealize(Elm_Gengrid_Item *item);
244 static void _item_select(Elm_Gengrid_Item *item);
245 static void _item_unselect(Elm_Gengrid_Item *item);
246 static void _calc_job(void *data);
247 static void _on_focus_hook(void *data,
249 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
250 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
251 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
252 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
253 static Eina_Bool _item_single_select_up(Widget_Data *wd);
254 static Eina_Bool _item_single_select_down(Widget_Data *wd);
255 static Eina_Bool _item_single_select_left(Widget_Data *wd);
256 static Eina_Bool _item_single_select_right(Widget_Data *wd);
257 static Eina_Bool _event_hook(Evas_Object *obj,
259 Evas_Callback_Type type,
261 static Eina_Bool _deselect_all_items(Widget_Data *wd);
263 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
264 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
267 _event_hook(Evas_Object *obj,
268 Evas_Object *src __UNUSED__,
269 Evas_Callback_Type type,
272 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
273 Evas_Event_Key_Down *ev = event_info;
274 Widget_Data *wd = elm_widget_data_get(obj);
275 if (!wd) return EINA_FALSE;
276 if (!wd->items) return EINA_FALSE;
277 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
278 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
280 Elm_Gengrid_Item *item = NULL;
283 Evas_Coord step_x = 0;
284 Evas_Coord step_y = 0;
287 Evas_Coord page_x = 0;
288 Evas_Coord page_y = 0;
290 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
291 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
292 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
293 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
295 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
297 if ((wd->horizontal) &&
298 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
299 (_item_multi_select_up(wd)))
300 || (_item_single_select_up(wd))))
302 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
305 else if ((!wd->horizontal) &&
306 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
307 (_item_multi_select_left(wd)))
308 || (_item_single_select_left(wd))))
310 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
316 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
318 if ((wd->horizontal) &&
319 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
320 (_item_multi_select_down(wd)))
321 || (_item_single_select_down(wd))))
323 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
326 else if ((!wd->horizontal) &&
327 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
328 (_item_multi_select_right(wd)))
329 || (_item_single_select_right(wd))))
331 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
337 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
339 if ((wd->horizontal) &&
340 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
341 (_item_multi_select_left(wd)))
342 || (_item_single_select_left(wd))))
344 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
347 else if ((!wd->horizontal) &&
348 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
349 (_item_multi_select_up(wd)))
350 || (_item_single_select_up(wd))))
352 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
358 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
360 if ((wd->horizontal) &&
361 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
362 (_item_multi_select_right(wd)))
363 || (_item_single_select_right(wd))))
365 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
368 else if ((!wd->horizontal) &&
369 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
370 (_item_multi_select_down(wd)))
371 || (_item_single_select_down(wd))))
373 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
379 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
381 item = elm_gengrid_first_item_get(obj);
382 elm_gengrid_item_bring_in(item);
383 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
386 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
388 item = elm_gengrid_last_item_get(obj);
389 elm_gengrid_item_bring_in(item);
390 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
393 else if ((!strcmp(ev->keyname, "Prior")) ||
394 (!strcmp(ev->keyname, "KP_Prior")))
399 x -= -(page_x * v_w) / 100;
406 y -= -(page_y * v_h) / 100;
411 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
416 x += -(page_x * v_w) / 100;
423 y += -(page_y * v_h) / 100;
428 else if (!strcmp(ev->keyname, "Escape"))
430 if (!_deselect_all_items(wd)) return EINA_FALSE;
431 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
434 else if ((!strcmp(ev->keyname, "Return")) ||
435 (!strcmp(ev->keyname, "KP_Enter")) ||
436 (!strcmp(ev->keyname, "space")))
438 item = elm_gengrid_selected_item_get(obj);
439 evas_object_smart_callback_call(item->wd->self, "clicked,double", item);
440 evas_object_smart_callback_call(item->wd->self, "clicked", item); // will be removed
442 else return EINA_FALSE;
444 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
445 elm_smart_scroller_child_pos_set(wd->scr, x, y);
450 _deselect_all_items(Widget_Data *wd)
452 if (!wd->selected) return EINA_FALSE;
454 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
460 _item_multi_select_left(Widget_Data *wd)
462 if (!wd->selected) return EINA_FALSE;
464 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
465 if (!prev) return EINA_TRUE;
466 if (elm_gengrid_item_selected_get(prev))
468 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
469 wd->last_selected_item = prev;
470 elm_gengrid_item_show(wd->last_selected_item);
474 elm_gengrid_item_selected_set(prev, EINA_TRUE);
475 elm_gengrid_item_show(prev);
482 _item_multi_select_right(Widget_Data *wd)
484 if (!wd->selected) return EINA_FALSE;
486 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
487 if (!next) return EINA_TRUE;
488 if (elm_gengrid_item_selected_get(next))
490 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
491 wd->last_selected_item = next;
492 elm_gengrid_item_show(wd->last_selected_item);
496 elm_gengrid_item_selected_set(next, EINA_TRUE);
497 elm_gengrid_item_show(next);
504 _item_multi_select_up(Widget_Data *wd)
507 Eina_Bool r = EINA_TRUE;
509 if (!wd->selected) return EINA_FALSE;
511 for (i = 0; (r) && (i < wd->nmax); i++)
512 r &= _item_multi_select_left(wd);
518 _item_multi_select_down(Widget_Data *wd)
521 Eina_Bool r = EINA_TRUE;
523 if (!wd->selected) return EINA_FALSE;
525 for (i = 0; (r) && (i < wd->nmax); i++)
526 r &= _item_multi_select_right(wd);
532 _item_single_select_up(Widget_Data *wd)
536 Elm_Gengrid_Item *prev;
540 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
541 while ((prev) && (prev->delete_me))
542 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
543 elm_gengrid_item_selected_set(prev, EINA_TRUE);
544 elm_gengrid_item_show(prev);
547 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
549 if (!prev) return EINA_FALSE;
551 for (i = 1; i < wd->nmax; i++)
553 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
554 if (!tmp) return EINA_FALSE;
558 _deselect_all_items(wd);
560 elm_gengrid_item_selected_set(prev, EINA_TRUE);
561 elm_gengrid_item_show(prev);
566 _item_single_select_down(Widget_Data *wd)
570 Elm_Gengrid_Item *next;
574 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
575 while ((next) && (next->delete_me))
576 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
577 elm_gengrid_item_selected_set(next, EINA_TRUE);
578 elm_gengrid_item_show(next);
581 else next = elm_gengrid_item_next_get(wd->last_selected_item);
583 if (!next) return EINA_FALSE;
585 for (i = 1; i < wd->nmax; i++)
587 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
588 if (!tmp) return EINA_FALSE;
592 _deselect_all_items(wd);
594 elm_gengrid_item_selected_set(next, EINA_TRUE);
595 elm_gengrid_item_show(next);
600 _item_single_select_left(Widget_Data *wd)
602 Elm_Gengrid_Item *prev;
605 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
606 while ((prev) && (prev->delete_me))
607 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
609 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
611 if (!prev) return EINA_FALSE;
613 _deselect_all_items(wd);
615 elm_gengrid_item_selected_set(prev, EINA_TRUE);
616 elm_gengrid_item_show(prev);
621 _item_single_select_right(Widget_Data *wd)
623 Elm_Gengrid_Item *next;
626 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
627 while ((next) && (next->delete_me))
628 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
630 else next = elm_gengrid_item_next_get(wd->last_selected_item);
632 if (!next) return EINA_FALSE;
634 _deselect_all_items(wd);
636 elm_gengrid_item_selected_set(next, EINA_TRUE);
637 elm_gengrid_item_show(next);
642 _on_focus_hook(void *data __UNUSED__,
645 Widget_Data *wd = elm_widget_data_get(obj);
647 if (elm_widget_focus_get(obj))
649 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
650 evas_object_focus_set(wd->self, EINA_TRUE);
651 if ((wd->selected) && (!wd->last_selected_item))
652 wd->last_selected_item = eina_list_data_get(wd->selected);
656 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
657 evas_object_focus_set(wd->self, EINA_FALSE);
662 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
664 Widget_Data *wd = elm_widget_data_get(obj);
665 Elm_Gengrid_Item *item;
667 elm_smart_scroller_mirrored_set(wd->scr, rtl);
668 if (!wd->items) return;
669 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
673 edje_object_mirrored_set(item->base.view, rtl);
674 elm_gengrid_item_update(item);
675 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
680 _theme_hook(Evas_Object *obj)
682 Widget_Data *wd = elm_widget_data_get(obj);
684 _elm_widget_mirrored_reload(obj);
685 _mirrored_set(obj, elm_widget_mirrored_get(obj));
686 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
687 elm_widget_style_get(obj));
691 _del_pre_hook(Evas_Object *obj)
693 Widget_Data *wd = elm_widget_data_get(obj);
695 elm_gengrid_clear(obj);
696 evas_object_del(wd->pan_smart);
697 wd->pan_smart = NULL;
701 _del_hook(Evas_Object *obj)
703 Widget_Data *wd = elm_widget_data_get(obj);
708 _signal_emit_hook(Evas_Object *obj,
709 const char *emission,
712 Widget_Data *wd = elm_widget_data_get(obj);
714 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
719 _mouse_move(void *data,
720 Evas *evas __UNUSED__,
724 Elm_Gengrid_Item *item = data;
725 Evas_Event_Mouse_Move *ev = event_info;
726 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
728 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
730 if (!item->wd->on_hold)
732 item->wd->on_hold = EINA_TRUE;
733 if (!item->wd->wasselected)
734 _item_unselect(item);
737 if ((item->dragging) && (item->down))
739 if (item->long_timer)
741 ecore_timer_del(item->long_timer);
742 item->long_timer = NULL;
744 evas_object_smart_callback_call(item->wd->self, "drag", item);
747 if ((!item->down) || (item->wd->longpressed))
749 if (item->long_timer)
751 ecore_timer_del(item->long_timer);
752 item->long_timer = NULL;
756 if (!item->display_only)
757 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
758 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
759 x = ev->cur.canvas.x - x;
760 y = ev->cur.canvas.y - y;
763 if (adx < 0) adx = -dx;
766 if (ady < 0) ady = -dy;
769 if ((adx > minw) || (ady > minh))
771 const char *left_drag, *right_drag;
772 if (!elm_widget_mirrored_get(item->wd->self))
774 left_drag = "drag,start,left";
775 right_drag = "drag,start,right";
779 left_drag = "drag,start,right";
780 right_drag = "drag,start,left";
784 if (item->long_timer)
786 ecore_timer_del(item->long_timer);
787 item->long_timer = NULL;
789 if (!item->wd->wasselected)
790 _item_unselect(item);
794 evas_object_smart_callback_call(item->wd->self, "drag,start,up",
799 evas_object_smart_callback_call(item->wd->self,
806 evas_object_smart_callback_call(item->wd->self,
807 "drag,start,down", item);
811 evas_object_smart_callback_call(item->wd->self,
814 evas_object_smart_callback_call(item->wd->self,
822 _long_press(void *data)
824 Elm_Gengrid_Item *item = data;
826 item->long_timer = NULL;
827 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
828 item->wd->longpressed = EINA_TRUE;
829 evas_object_smart_callback_call(item->wd->self, "longpressed", item);
830 return ECORE_CALLBACK_CANCEL;
834 _mouse_down(void *data,
835 Evas *evas __UNUSED__,
839 Elm_Gengrid_Item *item = data;
840 Evas_Event_Mouse_Down *ev = event_info;
843 if (ev->button != 1) return;
846 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
847 item->dx = ev->canvas.x - x;
848 item->dy = ev->canvas.y - y;
849 item->wd->longpressed = EINA_FALSE;
850 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
851 else item->wd->on_hold = EINA_FALSE;
852 item->wd->wasselected = item->selected;
854 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
856 evas_object_smart_callback_call(item->wd->self, "clicked,double", item);
857 evas_object_smart_callback_call(item->wd->self, "clicked", item); // will be removed
859 if (item->long_timer) ecore_timer_del(item->long_timer);
861 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
864 item->long_timer = NULL;
868 _mouse_up(void *data,
869 Evas *evas __UNUSED__,
870 Evas_Object *obj __UNUSED__,
873 Elm_Gengrid_Item *item = data;
874 Evas_Event_Mouse_Up *ev = event_info;
875 Eina_Bool dragged = EINA_FALSE;
877 if (ev->button != 1) return;
878 item->down = EINA_FALSE;
879 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
880 else item->wd->on_hold = EINA_FALSE;
881 if (item->long_timer)
883 ecore_timer_del(item->long_timer);
884 item->long_timer = NULL;
888 item->dragging = EINA_FALSE;
889 evas_object_smart_callback_call(item->wd->self, "drag,stop", item);
892 if (item->wd->on_hold)
894 item->wd->longpressed = EINA_FALSE;
895 item->wd->on_hold = EINA_FALSE;
898 if (item->wd->longpressed)
900 item->wd->longpressed = EINA_FALSE;
901 if (!item->wd->wasselected) _item_unselect(item);
902 item->wd->wasselected = EINA_FALSE;
907 if (item->want_unrealize) _item_unrealize(item);
909 if ((item->disabled) || (dragged)) return;
917 else _item_unselect(item);
923 while (item->wd->selected)
924 _item_unselect(item->wd->selected->data);
928 const Eina_List *l, *l_next;
929 Elm_Gengrid_Item *item2;
931 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
932 if (item2 != item) _item_unselect(item2);
940 _item_hilight(Elm_Gengrid_Item *item)
942 if ((item->wd->no_select) || (item->delete_me) || (item->hilighted)) return;
943 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
944 item->hilighted = EINA_TRUE;
948 _item_realize(Elm_Gengrid_Item *item)
953 if ((item->realized) || (item->delete_me)) return;
954 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
955 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
957 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
958 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
959 elm_widget_sub_object_add(item->wd->self, item->base.view);
960 snprintf(style, sizeof(style), "item/%s",
961 item->gic->item_style ? item->gic->item_style : "default");
962 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
963 elm_widget_style_get(item->wd->self));
965 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
966 evas_object_color_set(item->spacer, 0, 0, 0, 0);
967 elm_widget_sub_object_add(item->wd->self, item->spacer);
968 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
969 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
971 if (item->gic->func.label_get)
977 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
979 EINA_LIST_FOREACH(item->labels, l, key)
981 char *s = item->gic->func.label_get
982 ((void *)item->base.data, item->wd->self, l->data);
985 edje_object_part_text_set(item->base.view, l->data, s);
991 if (item->gic->func.icon_get)
997 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
999 EINA_LIST_FOREACH(item->icons, l, key)
1001 Evas_Object *ic = item->gic->func.icon_get
1002 ((void *)item->base.data, item->wd->self, l->data);
1005 item->icon_objs = eina_list_append(item->icon_objs, ic);
1006 edje_object_part_swallow(item->base.view, key, ic);
1007 evas_object_show(ic);
1008 elm_widget_sub_object_add(item->wd->self, ic);
1013 if (item->gic->func.state_get)
1019 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1021 EINA_LIST_FOREACH(item->states, l, key)
1023 Eina_Bool on = item->gic->func.state_get
1024 ((void *)item->base.data, item->wd->self, l->data);
1027 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1028 edje_object_signal_emit(item->base.view, buf, "elm");
1033 if ((!item->wd->item_width) && (!item->wd->item_height))
1035 edje_object_size_min_restricted_calc(item->base.view,
1036 &item->wd->item_width,
1037 &item->wd->item_height,
1038 item->wd->item_width,
1039 item->wd->item_height);
1040 elm_coords_finger_size_adjust(1, &item->wd->item_width,
1041 1, &item->wd->item_height);
1044 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1046 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
1048 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1052 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
1054 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
1056 evas_object_show(item->base.view);
1058 if (item->tooltip.content_cb)
1060 elm_widget_item_tooltip_content_cb_set(item,
1061 item->tooltip.content_cb,
1062 item->tooltip.data, NULL);
1063 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1066 if (item->mouse_cursor)
1067 elm_widget_item_cursor_set(item, item->mouse_cursor);
1069 item->realized = EINA_TRUE;
1070 item->want_unrealize = EINA_FALSE;
1074 _item_unrealize(Elm_Gengrid_Item *item)
1078 if (!item->realized) return;
1079 if (item->long_timer)
1081 ecore_timer_del(item->long_timer);
1082 item->long_timer = NULL;
1084 evas_object_del(item->base.view);
1085 item->base.view = NULL;
1086 evas_object_del(item->spacer);
1087 item->spacer = NULL;
1088 elm_widget_stringlist_free(item->labels);
1089 item->labels = NULL;
1090 elm_widget_stringlist_free(item->icons);
1092 elm_widget_stringlist_free(item->states);
1093 item->states = NULL;
1095 EINA_LIST_FREE(item->icon_objs, icon)
1096 evas_object_del(icon);
1098 item->realized = EINA_FALSE;
1099 item->want_unrealize = EINA_FALSE;
1103 _item_place(Elm_Gengrid_Item *item,
1107 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh;
1108 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1111 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1113 /* Preload rows/columns at each side of the Gengrid */
1114 cvx = ox - PRELOAD * item->wd->item_width;
1115 cvy = oy - PRELOAD * item->wd->item_height;
1116 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1117 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1122 if (item->wd->horizontal)
1124 int columns, items_visible = 0, items_row;
1126 if (item->wd->item_height > 0)
1127 items_visible = vh / item->wd->item_height;
1128 if (items_visible < 1)
1131 columns = item->wd->count / items_visible;
1132 if (item->wd->count % items_visible)
1135 tcw = item->wd->item_width * columns;
1136 alignw = (vw - tcw) * item->wd->align_x;
1138 items_row = items_visible;
1139 if (items_row > item->wd->count)
1140 items_row = item->wd->count;
1141 tch = items_row * item->wd->item_height;
1142 alignh = (vh - tch) * item->wd->align_y;
1146 int rows, items_visible = 0, items_col;
1148 if (item->wd->item_width > 0)
1149 items_visible = vw / item->wd->item_width;
1150 if (items_visible < 1)
1153 rows = item->wd->count / items_visible;
1154 if (item->wd->count % items_visible)
1157 tch = item->wd->item_height * rows;
1158 alignh = (vh - tch) * item->wd->align_y;
1160 items_col = items_visible;
1161 if (items_col > item->wd->count)
1162 items_col = item->wd->count;
1163 tcw = items_col * item->wd->item_width;
1164 alignw = (vw - tcw) * item->wd->align_x;
1167 x = cx * item->wd->item_width - item->wd->pan_x + ox + alignw;
1168 if (elm_widget_mirrored_get(item->wd->self))
1169 { /* Switch items side and componsate for pan_x when in RTL mode */
1171 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1172 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1175 y = cy * item->wd->item_height - item->wd->pan_y + oy + alignh;
1177 Eina_Bool was_realized = item->realized;
1178 if (ELM_RECTS_INTERSECT(x, y, item->wd->item_width, item->wd->item_height,
1179 cvx, cvy, cvw, cvh))
1181 _item_realize(item);
1183 evas_object_smart_callback_call(item->wd->self, "realized", item);
1184 evas_object_move(item->base.view, x, y);
1185 evas_object_resize(item->base.view, item->wd->item_width,
1186 item->wd->item_height);
1190 _item_unrealize(item);
1192 evas_object_smart_callback_call(item->wd->self, "unrealized", item);
1196 static Elm_Gengrid_Item *
1197 _item_create(Widget_Data *wd,
1198 const Elm_Gengrid_Item_Class *gic,
1201 const void *func_data)
1203 Elm_Gengrid_Item *item;
1205 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1206 if (!item) return NULL;
1210 item->base.data = data;
1211 item->func.func = func;
1212 item->func.data = func_data;
1213 item->mouse_cursor = NULL;
1218 _item_del(Elm_Gengrid_Item *item)
1220 elm_widget_item_pre_notify_del(item);
1222 item->wd->selected = eina_list_remove(item->wd->selected, item);
1223 if (item->realized) _item_unrealize(item);
1224 if ((!item->delete_me) && (item->gic->func.del))
1225 item->gic->func.del((void *)item->base.data, item->wd->self);
1226 item->delete_me = EINA_TRUE;
1227 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1228 if (item->long_timer) ecore_timer_del(item->long_timer);
1229 if (item->tooltip.del_cb)
1230 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1231 item->wd->walking -= item->walking;
1233 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1234 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1235 elm_widget_item_del(item);
1239 _item_select(Elm_Gengrid_Item *item)
1241 if ((item->wd->no_select) || (item->delete_me)) return;
1244 if (item->wd->always_select) goto call;
1247 item->selected = EINA_TRUE;
1248 item->wd->selected = eina_list_append(item->wd->selected, item);
1251 item->wd->walking++;
1252 if (item->func.func)
1253 item->func.func((void *)item->func.data, item->wd->self, item);
1254 if (!item->delete_me)
1255 evas_object_smart_callback_call(item->wd->self, "selected", item);
1257 item->wd->walking--;
1258 if ((item->wd->clear_me) && (!item->wd->walking))
1259 elm_gengrid_clear(item->base.widget);
1262 if ((!item->walking) && (item->delete_me))
1263 if (!item->relcount) _item_del(item);
1265 item->wd->last_selected_item = item;
1269 _item_unselect(Elm_Gengrid_Item *item)
1271 if ((item->delete_me) || (!item->hilighted)) return;
1272 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1273 item->hilighted = EINA_FALSE;
1276 item->selected = EINA_FALSE;
1277 item->wd->selected = eina_list_remove(item->wd->selected, item);
1278 evas_object_smart_callback_call(item->wd->self, "unselected", item);
1283 _calc_job(void *data)
1285 Widget_Data *wd = data;
1286 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1289 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1290 if ((cvw != 0) || (cvh != 0))
1292 if ((wd->horizontal) && (wd->item_height > 0))
1293 nmax = cvh / wd->item_height;
1294 else if (wd->item_width > 0)
1295 nmax = cvw / wd->item_width;
1303 minw = ceil(count / (float)nmax) * wd->item_width;
1304 minh = nmax * wd->item_height;
1308 minw = nmax * wd->item_width;
1309 minh = ceil(count / (float)nmax) * wd->item_height;
1312 if ((minw != wd->minw) || (minh != wd->minh))
1316 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1320 wd->calc_job = NULL;
1321 evas_object_smart_changed(wd->pan_smart);
1326 _pan_add(Evas_Object *obj)
1329 Evas_Object_Smart_Clipped_Data *cd;
1332 cd = evas_object_smart_data_get(obj);
1335 sd->__clipped_data = *cd;
1337 evas_object_smart_data_set(obj, sd);
1341 _pan_del(Evas_Object *obj)
1343 Pan *sd = evas_object_smart_data_get(obj);
1350 _pan_set(Evas_Object *obj,
1354 Pan *sd = evas_object_smart_data_get(obj);
1355 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1358 evas_object_smart_changed(obj);
1362 _pan_get(Evas_Object *obj,
1366 Pan *sd = evas_object_smart_data_get(obj);
1367 if (x) *x = sd->wd->pan_x;
1368 if (y) *y = sd->wd->pan_y;
1372 _pan_child_size_get(Evas_Object *obj,
1376 Pan *sd = evas_object_smart_data_get(obj);
1377 if (w) *w = sd->wd->minw;
1378 if (h) *h = sd->wd->minh;
1382 _pan_max_get(Evas_Object *obj,
1386 Pan *sd = evas_object_smart_data_get(obj);
1390 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1392 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1394 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1398 _pan_min_get(Evas_Object *obj,
1402 Pan *sd = evas_object_smart_data_get(obj);
1406 _pan_max_get(obj, &mx, &my);
1408 *x = -mx * sd->wd->align_x;
1410 *y = -my * sd->wd->align_y;
1414 _pan_resize(Evas_Object *obj,
1418 Pan *sd = evas_object_smart_data_get(obj);
1421 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1422 if ((ow == w) && (oh == h)) return;
1423 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1424 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1428 _pan_calculate(Evas_Object *obj)
1430 Pan *sd = evas_object_smart_data_get(obj);
1431 Evas_Coord cx = 0, cy = 0;
1432 Elm_Gengrid_Item *item;
1435 if (!sd->wd->nmax) return;
1437 EINA_INLIST_FOREACH(sd->wd->items, item)
1439 _item_place(item, cx, cy);
1440 if (sd->wd->horizontal)
1442 cy = (cy + 1) % sd->wd->nmax;
1447 cx = (cx + 1) % sd->wd->nmax;
1451 evas_object_smart_callback_call(sd->wd->self, "changed", NULL);
1455 _pan_move(Evas_Object *obj,
1456 Evas_Coord x __UNUSED__,
1457 Evas_Coord y __UNUSED__)
1459 Pan *sd = evas_object_smart_data_get(obj);
1461 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1462 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1466 _hold_on(void *data __UNUSED__,
1468 void *event_info __UNUSED__)
1470 Widget_Data *wd = elm_widget_data_get(obj);
1472 elm_smart_scroller_hold_set(wd->scr, 1);
1476 _hold_off(void *data __UNUSED__,
1478 void *event_info __UNUSED__)
1480 Widget_Data *wd = elm_widget_data_get(obj);
1482 elm_smart_scroller_hold_set(wd->scr, 0);
1486 _freeze_on(void *data __UNUSED__,
1488 void *event_info __UNUSED__)
1490 Widget_Data *wd = elm_widget_data_get(obj);
1492 elm_smart_scroller_freeze_set(wd->scr, 1);
1496 _freeze_off(void *data __UNUSED__,
1498 void *event_info __UNUSED__)
1500 Widget_Data *wd = elm_widget_data_get(obj);
1502 elm_smart_scroller_freeze_set(wd->scr, 0);
1506 _scr_drag_start(void *data,
1507 Evas_Object *obj __UNUSED__,
1508 void *event_info __UNUSED__)
1510 evas_object_smart_callback_call(data, "scroll,drag,start", NULL);
1514 _scr_drag_stop(void *data,
1515 Evas_Object *obj __UNUSED__,
1516 void *event_info __UNUSED__)
1518 evas_object_smart_callback_call(data, "scroll,drag,stop", NULL);
1522 _scr_scroll(void *data,
1523 Evas_Object *obj __UNUSED__,
1524 void *event_info __UNUSED__)
1526 evas_object_smart_callback_call(data, "scroll", NULL);
1530 * Add a new Gengrid object.
1532 * @param parent The parent object.
1533 * @return The new object or NULL if it cannot be created.
1535 * @see elm_gengrid_item_size_set()
1536 * @see elm_gengrid_horizontal_set()
1537 * @see elm_gengrid_item_append()
1538 * @see elm_gengrid_item_del()
1539 * @see elm_gengrid_clear()
1544 elm_gengrid_add(Evas_Object *parent)
1549 static Evas_Smart *smart = NULL;
1550 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1552 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1554 ELM_SET_WIDTYPE(widtype, "gengrid");
1555 elm_widget_type_set(obj, "gengrid");
1556 elm_widget_sub_object_add(parent, obj);
1557 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1558 elm_widget_data_set(obj, wd);
1559 elm_widget_del_hook_set(obj, _del_hook);
1560 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1561 elm_widget_theme_hook_set(obj, _theme_hook);
1562 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1563 elm_widget_can_focus_set(obj, EINA_TRUE);
1564 elm_widget_event_hook_set(obj, _event_hook);
1566 wd->scr = elm_smart_scroller_add(e);
1567 elm_smart_scroller_widget_set(wd->scr, obj);
1568 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1570 elm_widget_resize_object_set(obj, wd->scr);
1572 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1573 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1574 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1576 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1581 wd->no_select = EINA_FALSE;
1583 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1584 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1585 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1586 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1590 static Evas_Smart_Class sc;
1592 evas_object_smart_clipped_smart_set(&_pan_sc);
1594 sc.name = "elm_gengrid_pan";
1595 sc.version = EVAS_SMART_CLASS_VERSION;
1598 sc.resize = _pan_resize;
1599 sc.move = _pan_move;
1600 sc.calculate = _pan_calculate;
1601 smart = evas_smart_class_new(&sc);
1605 wd->pan_smart = evas_object_smart_add(e, smart);
1606 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1610 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1611 _pan_set, _pan_get, _pan_max_get,
1612 _pan_min_get, _pan_child_size_get);
1614 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1619 * Set the size for the item of the Gengrid.
1621 * @param obj The Gengrid object.
1622 * @param w The item's width.
1623 * @param h The item's height;
1625 * @see elm_gengrid_item_size_get()
1630 elm_gengrid_item_size_set(Evas_Object *obj,
1634 ELM_CHECK_WIDTYPE(obj, widtype);
1635 Widget_Data *wd = elm_widget_data_get(obj);
1637 if ((wd->item_width == w) && (wd->item_height == h)) return;
1639 wd->item_height = h;
1640 if (wd->calc_job) ecore_job_del(wd->calc_job);
1641 wd->calc_job = ecore_job_add(_calc_job, wd);
1645 * Get the size of the item of the Gengrid.
1647 * @param obj The Gengrid object.
1648 * @param w Pointer to the item's width.
1649 * @param h Pointer to the item's height.
1651 * @see elm_gengrid_item_size_get()
1656 elm_gengrid_item_size_get(const Evas_Object *obj,
1660 ELM_CHECK_WIDTYPE(obj, widtype);
1661 Widget_Data *wd = elm_widget_data_get(obj);
1663 if (w) *w = wd->item_width;
1664 if (h) *h = wd->item_height;
1668 * Set item's alignment within the scroller.
1670 * @param obj The Gengrid object.
1671 * @param align_x The x alignment (0 <= x <= 1).
1672 * @param align_y The y alignment (0 <= y <= 1).
1674 * @see elm_gengrid_align_get()
1679 elm_gengrid_align_set(Evas_Object *obj,
1683 ELM_CHECK_WIDTYPE(obj, widtype);
1684 Widget_Data *wd = elm_widget_data_get(obj);
1688 else if (align_x < 0.0)
1690 wd->align_x = align_x;
1694 else if (align_y < 0.0)
1696 wd->align_y = align_y;
1700 * Get the alignenment set for the Gengrid object.
1702 * @param obj The Gengrid object.
1703 * @param align_x Pointer to x alignenment.
1704 * @param align_y Pointer to y alignenment.
1706 * @see elm_gengrid_align_set()
1711 elm_gengrid_align_get(const Evas_Object *obj,
1715 ELM_CHECK_WIDTYPE(obj, widtype);
1716 Widget_Data *wd = elm_widget_data_get(obj);
1717 if (align_x) *align_x = wd->align_x;
1718 if (align_y) *align_y = wd->align_y;
1722 * Add item to the end of the Gengrid.
1724 * @param obj The Gengrid object.
1725 * @param gic The item class for the item.
1726 * @param data The item data.
1727 * @param func Convenience function called when item is selected.
1728 * @param func_data Data passed to @p func above.
1729 * @return A handle to the item added or NULL if not possible.
1731 * @see elm_gengrid_item_prepend()
1732 * @see elm_gengrid_item_insert_before()
1733 * @see elm_gengrid_item_insert_after()
1734 * @see elm_gengrid_item_del()
1738 EAPI Elm_Gengrid_Item *
1739 elm_gengrid_item_append(Evas_Object *obj,
1740 const Elm_Gengrid_Item_Class *gic,
1743 const void *func_data)
1745 Elm_Gengrid_Item *item;
1746 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1747 Widget_Data *wd = elm_widget_data_get(obj);
1748 if (!wd) return NULL;
1750 item = _item_create(wd, gic, data, func, func_data);
1751 if (!item) return NULL;
1752 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
1754 if (wd->calc_job) ecore_job_del(wd->calc_job);
1755 wd->calc_job = ecore_job_add(_calc_job, wd);
1761 * Add item at start of the Gengrid.
1763 * This adds an item to the beginning of the grid.
1765 * @param obj The Gengrid object.
1766 * @param gic The item class for the item.
1767 * @param data The item data.
1768 * @param func Convenience function called when item is selected.
1769 * @param func_data Data passed to @p func above.
1770 * @return A handle to the item added or NULL if not possible.
1772 * @see elm_gengrid_item_append()
1773 * @see elm_gengrid_item_insert_before()
1774 * @see elm_gengrid_item_insert_after()
1775 * @see elm_gengrid_item_del()
1779 EAPI Elm_Gengrid_Item *
1780 elm_gengrid_item_prepend(Evas_Object *obj,
1781 const Elm_Gengrid_Item_Class *gic,
1784 const void *func_data)
1786 Elm_Gengrid_Item *item;
1787 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1788 Widget_Data *wd = elm_widget_data_get(obj);
1789 if (!wd) return NULL;
1791 item = _item_create(wd, gic, data, func, func_data);
1792 if (!item) return NULL;
1793 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
1795 if (wd->calc_job) ecore_job_del(wd->calc_job);
1796 wd->calc_job = ecore_job_add(_calc_job, wd);
1802 * Insert and item before another in the Gengrid.
1804 * This inserts an item before another in the grid.
1806 * @param obj The Gengrid object.
1807 * @param gic The item class for the item.
1808 * @param data The item data.
1809 * @param relative The item to which insert before.
1810 * @param func Convenience function called when item is selected.
1811 * @param func_data Data passed to @p func above.
1812 * @return A handle to the item added or NULL if not possible.
1814 * @see elm_gengrid_item_append()
1815 * @see elm_gengrid_item_prepend()
1816 * @see elm_gengrid_item_insert_after()
1817 * @see elm_gengrid_item_del()
1821 EAPI Elm_Gengrid_Item *
1822 elm_gengrid_item_insert_before(Evas_Object *obj,
1823 const Elm_Gengrid_Item_Class *gic,
1825 Elm_Gengrid_Item *relative,
1827 const void *func_data)
1829 Elm_Gengrid_Item *item;
1830 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1831 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1832 Widget_Data *wd = elm_widget_data_get(obj);
1833 if (!wd) return NULL;
1835 item = _item_create(wd, gic, data, func, func_data);
1836 if (!item) return NULL;
1837 wd->items = eina_inlist_prepend_relative
1838 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1840 if (wd->calc_job) ecore_job_del(wd->calc_job);
1841 wd->calc_job = ecore_job_add(_calc_job, wd);
1847 * Insert and item after another in the Gengrid.
1849 * This inserts an item after another in the grid.
1851 * @param obj The Gengrid object.
1852 * @param gic The item class for the item.
1853 * @param data The item data.
1854 * @param relative The item to which insert after.
1855 * @param func Convenience function called when item is selected.
1856 * @param func_data Data passed to @p func above.
1857 * @return A handle to the item added or NULL if not possible.
1859 * @see elm_gengrid_item_append()
1860 * @see elm_gengrid_item_prepend()
1861 * @see elm_gengrid_item_insert_before()
1862 * @see elm_gengrid_item_del()
1866 EAPI Elm_Gengrid_Item *
1867 elm_gengrid_item_insert_after(Evas_Object *obj,
1868 const Elm_Gengrid_Item_Class *gic,
1870 Elm_Gengrid_Item *relative,
1872 const void *func_data)
1874 Elm_Gengrid_Item *item;
1875 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1876 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1877 Widget_Data *wd = elm_widget_data_get(obj);
1878 if (!wd) return NULL;
1880 item = _item_create(wd, gic, data, func, func_data);
1881 if (!item) return NULL;
1882 wd->items = eina_inlist_append_relative
1883 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1885 if (wd->calc_job) ecore_job_del(wd->calc_job);
1886 wd->calc_job = ecore_job_add(_calc_job, wd);
1892 * Remove a item from the Gengrid.
1894 * @param item The item to be removed.
1895 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise.
1897 * @see elm_gengrid_clear() to remove all items of the Gengrid.
1902 elm_gengrid_item_del(Elm_Gengrid_Item *item)
1904 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1905 if ((item->relcount > 0) || (item->walking > 0))
1907 item->delete_me = EINA_TRUE;
1908 elm_widget_item_pre_notify_del(item);
1910 item->wd->selected = eina_list_remove(item->wd->selected, item);
1911 if (item->gic->func.del)
1912 item->gic->func.del((void *)item->base.data, item->wd->self);
1920 * Set for what direction the Gengrid will expand.
1922 * @param obj The Gengrid object.
1923 * @param setting If @c EINA_TRUE the Gengrid will expand horizontally
1924 * or vertically if @c EINA_FALSE.
1929 elm_gengrid_horizontal_set(Evas_Object *obj,
1932 ELM_CHECK_WIDTYPE(obj, widtype);
1933 Widget_Data *wd = elm_widget_data_get(obj);
1935 if (setting == wd->horizontal) return;
1936 wd->horizontal = setting;
1938 /* Update the items to conform to the new layout */
1939 if (wd->calc_job) ecore_job_del(wd->calc_job);
1940 wd->calc_job = ecore_job_add(_calc_job, wd);
1946 * This clears all items in the Gengrid, leaving it empty.
1948 * @param obj The Gengrid object.
1950 * @see elm_gengrid_item_del() to remove just one item.
1955 elm_gengrid_clear(Evas_Object *obj)
1957 ELM_CHECK_WIDTYPE(obj, widtype);
1958 Widget_Data *wd = elm_widget_data_get(obj);
1963 ecore_job_del(wd->calc_job);
1964 wd->calc_job = NULL;
1967 if (wd->walking > 0)
1969 Elm_Gengrid_Item *item;
1971 EINA_INLIST_FOREACH(wd->items, item)
1972 item->delete_me = 1;
1978 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
1980 wd->items = eina_inlist_remove(wd->items, wd->items);
1981 elm_widget_item_pre_notify_del(item);
1982 if (item->realized) _item_unrealize(item);
1983 if (item->gic->func.del)
1984 item->gic->func.del((void *)item->base.data, wd->self);
1985 if (item->long_timer) ecore_timer_del(item->long_timer);
1986 elm_widget_item_del(item);
1991 eina_list_free(wd->selected);
1992 wd->selected = NULL;
2000 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2001 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2005 * Get the real evas object of the Gengrid item
2007 * This returns the actual evas object used for the specified Gengrid
2008 * item. This may be NULL as it may not be created, and may be
2009 * deleted at any time by Gengrid. Do not modify this object (move,
2010 * resize, show, hide etc.) as Gengrid is controlling it. This
2011 * function is for querying, emitting custom signals or hooking lower
2012 * level callbacks for events. Do not delete this object under any
2015 * @param item The Gengrid item.
2016 * @return the evas object associated to this item.
2018 * @see elm_gengrid_item_data_get()
2022 EAPI const Evas_Object *
2023 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
2025 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2026 return item->base.view;
2030 * Update the contents of an item
2032 * This updates an item by calling all the item class functions again
2033 * to get the icons, labels and states. Use this when the original
2034 * item data has changed and the changes are desired to be reflected.
2036 * @param item The item
2041 elm_gengrid_item_update(Elm_Gengrid_Item *item)
2043 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2044 if (!item->realized) return;
2045 if (item->want_unrealize) return;
2046 _item_unrealize(item);
2047 _item_realize(item);
2048 _item_place(item, item->x, item->y);
2052 * Returns the data associated to a item
2054 * This returns the data value passed on the elm_gengrid_item_append()
2055 * and related item addition calls.
2057 * @param item The Gengrid item.
2058 * @return the data associated to this item.
2060 * @see elm_gengrid_item_append()
2061 * @see elm_gengrid_item_object_get()
2066 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2068 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2069 return elm_widget_item_data_get(item);
2073 * Set the data item from the gengrid item
2075 * This set the data value passed on the elm_gengrid_item_append() and
2076 * related item addition calls. This function will also call
2077 * elm_gengrid_item_update() so the item will be updated to reflect
2080 * @param item The item
2081 * @param data The new data pointer to set
2086 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2089 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2090 elm_widget_item_data_set(item, data);
2091 elm_gengrid_item_update(item);
2095 * Get the item's coordinates.
2097 * This returns the logical position of the item whithin the Gengrid.
2099 * @param item The Gengrid item.
2100 * @param x The x-axis coordinate pointer.
2101 * @param y The y-axis coordinate pointer.
2106 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2110 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2111 if (x) *x = item->x;
2112 if (y) *y = item->y;
2116 * Enable or disable multi-select in the Gengrid.
2118 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
2119 * the Gengrid. This allows more than 1 item to be selected.
2121 * @param obj The Gengrid object.
2122 * @param multi Multi-select enabled/disabled
2127 elm_gengrid_multi_select_set(Evas_Object *obj,
2130 ELM_CHECK_WIDTYPE(obj, widtype);
2131 Widget_Data *wd = elm_widget_data_get(obj);
2137 * Get if multi-select in Gengrid is enabled or disabled
2139 * @param obj The Gengrid object
2140 * @return Multi-select enable/disable
2141 * (EINA_TRUE = enabled / EINA_FALSE = disabled)
2146 elm_gengrid_multi_select_get(const Evas_Object *obj)
2148 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2149 Widget_Data *wd = elm_widget_data_get(obj);
2150 if (!wd) return EINA_FALSE;
2155 * Get the selected item in the Gengrid
2157 * This gets the selected item in the Gengrid (if multi-select is
2158 * enabled only the first item in the list is selected - which is not
2159 * very useful, so see elm_gengrid_selected_items_get() for when
2160 * multi-select is used).
2162 * If no item is selected, NULL is returned.
2164 * @param obj The Gengrid object.
2165 * @return The selected item, or NULL if none.
2169 EAPI Elm_Gengrid_Item *
2170 elm_gengrid_selected_item_get(const Evas_Object *obj)
2172 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2173 Widget_Data *wd = elm_widget_data_get(obj);
2174 if (!wd) return NULL;
2175 if (wd->selected) return wd->selected->data;
2180 * Get a list of selected items in the Gengrid.
2182 * This returns a list of the selected items. This list pointer is
2183 * only valid so long as no items are selected or unselected (or
2184 * unselected implictly by deletion). The list contains
2185 * Elm_Gengrid_Item pointers.
2187 * @param obj The Gengrid object.
2188 * @return The list of selected items, or NULL if none are selected.
2192 EAPI const Eina_List *
2193 elm_gengrid_selected_items_get(const Evas_Object *obj)
2195 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2196 Widget_Data *wd = elm_widget_data_get(obj);
2197 if (!wd) return NULL;
2198 return wd->selected;
2202 * Set the selected state of a item.
2204 * This sets the selected state of a item. If multi-select is not
2205 * enabled and selected is EINA_TRUE, previously selected items are
2208 * @param item The item
2209 * @param selected The selected state.
2214 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2217 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2218 Widget_Data *wd = item->wd;
2220 if (item->delete_me) return;
2221 selected = !!selected;
2222 if (item->selected == selected) return;
2228 while (wd->selected)
2229 _item_unselect(wd->selected->data);
2231 _item_hilight(item);
2235 _item_unselect(item);
2239 * Get the selected state of a item.
2241 * This gets the selected state of a item (1 selected, 0 not selected).
2243 * @param item The item
2244 * @return The selected state
2249 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2251 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2252 return item->selected;
2256 * Sets the disabled state of a item.
2258 * A disabled item cannot be selected or unselected. It will also
2259 * change appearance to disabled. This sets the disabled state (1
2260 * disabled, 0 not disabled).
2262 * @param item The item
2263 * @param disabled The disabled state
2268 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2271 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2272 if (item->disabled == disabled) return;
2273 if (item->delete_me) return;
2274 item->disabled = disabled;
2278 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2280 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2285 * Get the disabled state of a item.
2287 * This gets the disabled state of the given item.
2289 * @param item The item
2290 * @return The disabled state
2295 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2297 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2298 if (item->delete_me) return EINA_FALSE;
2299 return item->disabled;
2302 static Evas_Object *
2303 _elm_gengrid_item_label_create(void *data,
2305 void *item __UNUSED__)
2307 Evas_Object *label = elm_label_add(obj);
2310 elm_object_style_set(label, "tooltip");
2311 elm_label_label_set(label, data);
2316 _elm_gengrid_item_label_del_cb(void *data,
2317 Evas_Object *obj __UNUSED__,
2318 void *event_info __UNUSED__)
2320 eina_stringshare_del(data);
2324 * Set the text to be shown in the gengrid item.
2326 * @param item Target item
2327 * @param text The text to set in the content
2329 * Setup the text as tooltip to object. The item can have only one
2330 * tooltip, so any previous tooltip data is removed.
2335 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2338 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2339 text = eina_stringshare_add(text);
2340 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2342 _elm_gengrid_item_label_del_cb);
2346 * Set the content to be shown in the tooltip item
2348 * Setup the tooltip to item. The item can have only one tooltip, so
2349 * any previous tooltip data is removed. @p func(with @p data) will be
2350 * called every time that need show the tooltip and it should return a
2351 * valid Evas_Object. This object is then managed fully by tooltip
2352 * system and is deleted when the tooltip is gone.
2354 * @param item the gengrid item being attached a tooltip.
2355 * @param func the function used to create the tooltip contents.
2356 * @param data what to provide to @a func as callback data/context.
2357 * @param del_cb called when data is not needed anymore, either when
2358 * another callback replaces @func, the tooltip is unset with
2359 * elm_gengrid_item_tooltip_unset() or the owner @a item
2360 * dies. This callback receives as the first parameter the
2361 * given @a data, and @c event_info is the item.
2366 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2367 Elm_Tooltip_Item_Content_Cb func,
2369 Evas_Smart_Cb del_cb)
2371 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2373 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2376 if (item->tooltip.del_cb)
2377 item->tooltip.del_cb((void *)item->tooltip.data,
2378 item->base.widget, item);
2379 item->tooltip.content_cb = func;
2380 item->tooltip.data = data;
2381 item->tooltip.del_cb = del_cb;
2382 if (item->base.view)
2384 elm_widget_item_tooltip_content_cb_set(item,
2385 item->tooltip.content_cb,
2386 item->tooltip.data, NULL);
2387 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2393 if (del_cb) del_cb((void *)data, NULL, NULL);
2397 * Unset tooltip from item
2399 * @param item gengrid item to remove previously set tooltip.
2401 * Remove tooltip from item. The callback provided as del_cb to
2402 * elm_gengrid_item_tooltip_content_cb_set() will be called to notify
2403 * it is not used anymore.
2405 * @see elm_gengrid_item_tooltip_content_cb_set()
2410 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2412 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2413 if ((item->base.view) && (item->tooltip.content_cb))
2414 elm_widget_item_tooltip_unset(item);
2416 if (item->tooltip.del_cb)
2417 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2418 item->tooltip.del_cb = NULL;
2419 item->tooltip.content_cb = NULL;
2420 item->tooltip.data = NULL;
2421 if (item->tooltip.style)
2422 elm_gengrid_item_tooltip_style_set(item, NULL);
2426 * Sets a different style for this item tooltip.
2428 * @note before you set a style you should define a tooltip with
2429 * elm_gengrid_item_tooltip_content_cb_set() or
2430 * elm_gengrid_item_tooltip_text_set()
2432 * @param item gengrid item with tooltip already set.
2433 * @param style the theme style to use (default, transparent, ...)
2438 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2441 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2442 eina_stringshare_replace(&item->tooltip.style, style);
2443 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2447 * Get the style for this item tooltip.
2449 * @param item gengrid item with tooltip already set.
2450 * @return style the theme style in use, defaults to "default". If the
2451 * object does not have a tooltip set, then NULL is returned.
2456 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2458 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2459 return item->tooltip.style;
2463 * Set the cursor to be shown when mouse is over the gengrid item
2465 * @param item Target item
2466 * @param cursor the cursor name to be used.
2468 * @see elm_object_cursor_set()
2472 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2475 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2476 eina_stringshare_replace(&item->mouse_cursor, cursor);
2477 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2481 * Get the cursor to be shown when mouse is over the gengrid item
2483 * @param item gengrid item with cursor already set.
2484 * @return the cursor name.
2489 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2491 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2492 return elm_widget_item_cursor_get(item);
2496 * Unset the cursor to be shown when mouse is over the gengrid item
2498 * @param item Target item
2500 * @see elm_object_cursor_unset()
2504 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2506 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2507 if (!item->mouse_cursor)
2510 if (item->base.view)
2511 elm_widget_item_cursor_unset(item);
2513 eina_stringshare_del(item->mouse_cursor);
2514 item->mouse_cursor = NULL;
2518 * Sets a different style for this item cursor.
2520 * @note before you set a style you should define a cursor with
2521 * elm_gengrid_item_cursor_set()
2523 * @param item gengrid item with cursor already set.
2524 * @param style the theme style to use (default, transparent, ...)
2529 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2532 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2533 elm_widget_item_cursor_style_set(item, style);
2537 * Get the style for this item cursor.
2539 * @param item gengrid item with cursor already set.
2540 * @return style the theme style in use, defaults to "default". If the
2541 * object does not have a cursor set, then NULL is returned.
2546 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2548 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2549 return elm_widget_item_cursor_style_get(item);
2553 * Set if the cursor set should be searched on the theme or should use
2554 * the provided by the engine, only.
2556 * @note before you set if should look on theme you should define a
2557 * cursor with elm_object_cursor_set(). By default it will only look
2558 * for cursors provided by the engine.
2560 * @param item widget item with cursor already set.
2561 * @param engine_only boolean to define it cursors should be looked
2562 * only between the provided by the engine or searched on widget's
2568 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2569 Eina_Bool engine_only)
2571 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2572 elm_widget_item_cursor_engine_only_set(item, engine_only);
2576 * Get the cursor engine only usage for this item cursor.
2578 * @param item widget item with cursor already set.
2579 * @return engine_only boolean to define it cursors should be looked
2580 * only between the provided by the engine or searched on widget's
2581 * theme as well. If the object does not have a cursor set, then
2582 * EINA_FALSE is returned.
2587 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2589 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2590 return elm_widget_item_cursor_engine_only_get(item);
2594 * Set the always select mode.
2596 * Cells will only call their selection func and callback when first
2597 * becoming selected. Any further clicks will do nothing, unless you
2598 * enable always select with
2599 * elm_gengrid_always_select_mode_set(). This means even if selected,
2600 * every click will make the selected callbacks be called.
2602 * @param obj The Gengrid object
2603 * @param always_select The always select mode (EINA_TRUE = on,
2609 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2610 Eina_Bool always_select)
2612 ELM_CHECK_WIDTYPE(obj, widtype);
2613 Widget_Data *wd = elm_widget_data_get(obj);
2615 wd->always_select = always_select;
2619 * Get the always select mode.
2621 * @param obj The Gengrid object.
2622 * @return The always select mode (EINA_TRUE = on, EINA_FALSE = off)
2627 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2629 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2630 Widget_Data *wd = elm_widget_data_get(obj);
2631 if (!wd) return EINA_FALSE;
2632 return wd->always_select;
2636 * Set no select mode.
2638 * This will turn off the ability to select items entirely and they
2639 * will neither appear selected nor call selected callback functions.
2641 * @param obj The Gengrid object
2642 * @param no_select The no select mode (EINA_TRUE = on, EINA_FALSE = off)
2647 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2648 Eina_Bool no_select)
2650 ELM_CHECK_WIDTYPE(obj, widtype);
2651 Widget_Data *wd = elm_widget_data_get(obj);
2653 wd->no_select = no_select;
2657 * Gets no select mode.
2659 * @param obj The Gengrid object
2660 * @return The no select mode (EINA_TRUE = on, EINA_FALSE = off)
2665 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2667 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2668 Widget_Data *wd = elm_widget_data_get(obj);
2669 if (!wd) return EINA_FALSE;
2670 return wd->no_select;
2676 * This will enable or disable the scroller bounce mode for the
2677 * Gengrid. See elm_scroller_bounce_set() for details.
2679 * @param obj The Gengrid object
2680 * @param h_bounce Allow bounce horizontally
2681 * @param v_bounce Allow bounce vertically
2686 elm_gengrid_bounce_set(Evas_Object *obj,
2690 ELM_CHECK_WIDTYPE(obj, widtype);
2691 Widget_Data *wd = elm_widget_data_get(obj);
2693 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2697 * Get the bounce mode
2699 * @param obj The Gengrid object
2700 * @param h_bounce Allow bounce horizontally
2701 * @param v_bounce Allow bounce vertically
2706 elm_gengrid_bounce_get(const Evas_Object *obj,
2707 Eina_Bool *h_bounce,
2708 Eina_Bool *v_bounce)
2710 ELM_CHECK_WIDTYPE(obj, widtype);
2711 Widget_Data *wd = elm_widget_data_get(obj);
2713 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
2717 * Get all items in the Gengrid.
2719 * This returns a list of the Gengrid items. The list contains
2720 * Elm_Gengrid_Item pointers.
2722 * @param obj The Gengrid object.
2723 * @return The list of items, or NULL if none.
2729 * Set gengrid scroll page size relative to viewport size.
2731 * The gengrid scroller is capable of limiting scrolling by the user
2732 * to "pages" That is to jump by and only show a "whole page" at a
2733 * time as if the continuous area of the scroller content is split
2734 * into page sized pieces. This sets the size of a page relative to
2735 * the viewport of the scroller. 1.0 is "1 viewport" is size
2736 * (horizontally or vertically). 0.0 turns it off in that axis. This
2737 * is mutually exclusive with page size (see
2738 * elm_gengrid_page_size_set() for more information). Likewise 0.5 is
2739 * "half a viewport". Sane usable valus are normally between 0.0 and
2740 * 1.0 including 1.0. If you only want 1 axis to be page "limited",
2741 * use 0.0 for the other axis.
2743 * @param obj The gengrid object
2744 * @param h_pagerel The horizontal page relative size
2745 * @param v_pagerel The vertical page relative size
2750 elm_gengrid_page_relative_set(Evas_Object *obj,
2754 Evas_Coord pagesize_h;
2755 Evas_Coord pagesize_v;
2757 ELM_CHECK_WIDTYPE(obj, widtype);
2758 Widget_Data *wd = elm_widget_data_get(obj);
2761 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
2762 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
2767 * Set gengrid scroll page size.
2769 * See also elm_gengrid_page_relative_set(). This, instead of a page
2770 * size being relative to the viewport, sets it to an absolute fixed
2771 * value, with 0 turning it off for that axis.
2773 * @param obj The gengrid object
2774 * @param h_pagesize The horizontal page size
2775 * @param v_pagesize The vertical page size
2780 elm_gengrid_page_size_set(Evas_Object *obj,
2781 Evas_Coord h_pagesize,
2782 Evas_Coord v_pagesize)
2787 ELM_CHECK_WIDTYPE(obj, widtype);
2788 Widget_Data *wd = elm_widget_data_get(obj);
2790 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
2791 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
2796 * Get the first item in the gengrid
2798 * This returns the first item in the list.
2800 * @param obj The gengrid object
2801 * @return The first item, or NULL if none
2805 EAPI Elm_Gengrid_Item *
2806 elm_gengrid_first_item_get(const Evas_Object *obj)
2808 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2809 Widget_Data *wd = elm_widget_data_get(obj);
2810 if (!wd) return NULL;
2811 if (!wd->items) return NULL;
2812 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2813 while ((item) && (item->delete_me))
2814 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2819 * Get the last item in the gengrid
2821 * This returns the last item in the list.
2823 * @return The last item, or NULL if none
2827 EAPI Elm_Gengrid_Item *
2828 elm_gengrid_last_item_get(const Evas_Object *obj)
2830 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2831 Widget_Data *wd = elm_widget_data_get(obj);
2832 if (!wd) return NULL;
2833 if (!wd->items) return NULL;
2834 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
2835 while ((item) && (item->delete_me))
2836 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2841 * Get the next item in the gengrid
2843 * This returns the item after the item @p item.
2845 * @param item The item
2846 * @return The item after @p item, or NULL if none
2850 EAPI Elm_Gengrid_Item *
2851 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
2853 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2856 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2857 if ((item) && (!item->delete_me)) break;
2859 return (Elm_Gengrid_Item *)item;
2863 * Get the previous item in the gengrid
2865 * This returns the item before the item @p item.
2867 * @param item The item
2868 * @return The item before @p item, or NULL if none
2872 EAPI Elm_Gengrid_Item *
2873 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
2875 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2878 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2879 if ((item) && (!item->delete_me)) break;
2881 return (Elm_Gengrid_Item *)item;
2885 * Get the gengrid object from an item
2887 * This returns the gengrid object itself that an item belongs to.
2889 * @param item The item
2890 * @return The gengrid object
2895 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
2897 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2898 return item->base.widget;
2902 * Show the given item
2904 * This causes gengrid to jump to the given item @p item and show it
2905 * (by scrolling), if it is not fully visible.
2907 * @param item The item
2912 elm_gengrid_item_show(Elm_Gengrid_Item *item)
2914 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2915 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2916 Evas_Coord minx = 0, miny = 0;
2919 if ((!item) || (item->delete_me)) return;
2920 _pan_min_get(wd->pan_smart, &minx, &miny);
2922 elm_smart_scroller_child_region_show(item->wd->scr,
2923 item->x * wd->item_width + minx,
2924 item->y * wd->item_height + miny,
2925 item->wd->item_width,
2926 item->wd->item_height);
2930 * Bring in the given item
2932 * This causes gengrig to jump to the given item @p item and show it
2933 * (by scrolling), if it is not fully visible. This may use animation
2934 * to do so and take a period of time
2936 * @param item The item
2941 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
2943 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2944 if (item->delete_me) return;
2946 Evas_Coord minx = 0, miny = 0;
2947 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2949 _pan_min_get(wd->pan_smart, &minx, &miny);
2951 elm_smart_scroller_region_bring_in(item->wd->scr,
2952 item->x * wd->item_width + minx,
2953 item->y * wd->item_height + miny,
2954 item->wd->item_width,
2955 item->wd->item_height);