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 - 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"))
436 item = elm_gengrid_selected_item_get(obj);
437 evas_object_smart_callback_call(item->wd->self, "clicked", item);
439 else return EINA_FALSE;
441 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
442 elm_smart_scroller_child_pos_set(wd->scr, x, y);
447 _deselect_all_items(Widget_Data *wd)
449 if (!wd->selected) return EINA_FALSE;
451 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
457 _item_multi_select_left(Widget_Data *wd)
459 if (!wd->selected) return EINA_FALSE;
461 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
462 if (!prev) return EINA_TRUE;
463 if (elm_gengrid_item_selected_get(prev))
465 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
466 wd->last_selected_item = prev;
467 elm_gengrid_item_show(wd->last_selected_item);
471 elm_gengrid_item_selected_set(prev, EINA_TRUE);
472 elm_gengrid_item_show(prev);
479 _item_multi_select_right(Widget_Data *wd)
481 if (!wd->selected) return EINA_FALSE;
483 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
484 if (!next) return EINA_TRUE;
485 if (elm_gengrid_item_selected_get(next))
487 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
488 wd->last_selected_item = next;
489 elm_gengrid_item_show(wd->last_selected_item);
493 elm_gengrid_item_selected_set(next, EINA_TRUE);
494 elm_gengrid_item_show(next);
501 _item_multi_select_up(Widget_Data *wd)
504 Eina_Bool r = EINA_TRUE;
506 if (!wd->selected) return EINA_FALSE;
508 for (i = 0; (r) && (i < wd->nmax); i++)
509 r &= _item_multi_select_left(wd);
515 _item_multi_select_down(Widget_Data *wd)
518 Eina_Bool r = EINA_TRUE;
520 if (!wd->selected) return EINA_FALSE;
522 for (i = 0; (r) && (i < wd->nmax); i++)
523 r &= _item_multi_select_right(wd);
529 _item_single_select_up(Widget_Data *wd)
533 Elm_Gengrid_Item *prev;
537 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
538 while ((prev) && (prev->delete_me))
539 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
540 elm_gengrid_item_selected_set(prev, EINA_TRUE);
541 elm_gengrid_item_show(prev);
544 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
546 if (!prev) return EINA_FALSE;
548 for (i = 1; i < wd->nmax; i++)
550 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
551 if (!tmp) return EINA_FALSE;
555 _deselect_all_items(wd);
557 elm_gengrid_item_selected_set(prev, EINA_TRUE);
558 elm_gengrid_item_show(prev);
563 _item_single_select_down(Widget_Data *wd)
567 Elm_Gengrid_Item *next;
571 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
572 while ((next) && (next->delete_me))
573 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
574 elm_gengrid_item_selected_set(next, EINA_TRUE);
575 elm_gengrid_item_show(next);
578 else next = elm_gengrid_item_next_get(wd->last_selected_item);
580 if (!next) return EINA_FALSE;
582 for (i = 1; i < wd->nmax; i++)
584 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
585 if (!tmp) return EINA_FALSE;
589 _deselect_all_items(wd);
591 elm_gengrid_item_selected_set(next, EINA_TRUE);
592 elm_gengrid_item_show(next);
597 _item_single_select_left(Widget_Data *wd)
599 Elm_Gengrid_Item *prev;
602 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
603 while ((prev) && (prev->delete_me))
604 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
606 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
608 if (!prev) return EINA_FALSE;
610 _deselect_all_items(wd);
612 elm_gengrid_item_selected_set(prev, EINA_TRUE);
613 elm_gengrid_item_show(prev);
618 _item_single_select_right(Widget_Data *wd)
620 Elm_Gengrid_Item *next;
623 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
624 while ((next) && (next->delete_me))
625 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
627 else next = elm_gengrid_item_next_get(wd->last_selected_item);
629 if (!next) return EINA_FALSE;
631 _deselect_all_items(wd);
633 elm_gengrid_item_selected_set(next, EINA_TRUE);
634 elm_gengrid_item_show(next);
639 _on_focus_hook(void *data __UNUSED__,
642 Widget_Data *wd = elm_widget_data_get(obj);
644 if (elm_widget_focus_get(obj))
646 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
647 evas_object_focus_set(wd->self, EINA_TRUE);
648 if ((wd->selected) && (!wd->last_selected_item))
649 wd->last_selected_item = eina_list_data_get(wd->selected);
653 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
654 evas_object_focus_set(wd->self, EINA_FALSE);
659 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
661 Widget_Data *wd = elm_widget_data_get(obj);
662 Elm_Gengrid_Item *item;
664 elm_smart_scroller_mirrored_set(wd->scr, rtl);
665 if (!wd->items) return;
666 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
670 edje_object_mirrored_set(item->base.view, rtl);
671 elm_gengrid_item_update(item);
672 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
677 _theme_hook(Evas_Object *obj)
679 Widget_Data *wd = elm_widget_data_get(obj);
681 _elm_widget_mirrored_reload(obj);
682 _mirrored_set(obj, elm_widget_mirrored_get(obj));
683 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
684 elm_widget_style_get(obj));
688 _del_pre_hook(Evas_Object *obj)
690 Widget_Data *wd = elm_widget_data_get(obj);
692 elm_gengrid_clear(obj);
693 evas_object_del(wd->pan_smart);
694 wd->pan_smart = NULL;
698 _del_hook(Evas_Object *obj)
700 Widget_Data *wd = elm_widget_data_get(obj);
705 _signal_emit_hook(Evas_Object *obj,
706 const char *emission,
709 Widget_Data *wd = elm_widget_data_get(obj);
711 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
716 _mouse_move(void *data,
717 Evas *evas __UNUSED__,
721 Elm_Gengrid_Item *item = data;
722 Evas_Event_Mouse_Move *ev = event_info;
723 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
725 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
727 if (!item->wd->on_hold)
729 item->wd->on_hold = EINA_TRUE;
730 if (!item->wd->wasselected)
731 _item_unselect(item);
734 if ((item->dragging) && (item->down))
736 if (item->long_timer)
738 ecore_timer_del(item->long_timer);
739 item->long_timer = NULL;
741 evas_object_smart_callback_call(item->wd->self, "drag", item);
744 if ((!item->down) || (item->wd->longpressed))
746 if (item->long_timer)
748 ecore_timer_del(item->long_timer);
749 item->long_timer = NULL;
753 if (!item->display_only)
754 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
755 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
756 x = ev->cur.canvas.x - x;
757 y = ev->cur.canvas.y - y;
760 if (adx < 0) adx = -dx;
763 if (ady < 0) ady = -dy;
766 if ((adx > minw) || (ady > minh))
768 const char *left_drag, *right_drag;
769 if (!elm_widget_mirrored_get(item->wd->self))
771 left_drag = "drag,start,left";
772 right_drag = "drag,start,right";
776 left_drag = "drag,start,right";
777 right_drag = "drag,start,left";
781 if (item->long_timer)
783 ecore_timer_del(item->long_timer);
784 item->long_timer = NULL;
786 if (!item->wd->wasselected)
787 _item_unselect(item);
791 evas_object_smart_callback_call(item->wd->self, "drag,start,up",
796 evas_object_smart_callback_call(item->wd->self,
803 evas_object_smart_callback_call(item->wd->self,
804 "drag,start,down", item);
808 evas_object_smart_callback_call(item->wd->self,
811 evas_object_smart_callback_call(item->wd->self,
819 _long_press(void *data)
821 Elm_Gengrid_Item *item = data;
823 item->long_timer = NULL;
824 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
825 item->wd->longpressed = EINA_TRUE;
826 evas_object_smart_callback_call(item->wd->self, "longpressed", item);
827 return ECORE_CALLBACK_CANCEL;
831 _mouse_down(void *data,
832 Evas *evas __UNUSED__,
836 Elm_Gengrid_Item *item = data;
837 Evas_Event_Mouse_Down *ev = event_info;
840 if (ev->button != 1) return;
843 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
844 item->dx = ev->canvas.x - x;
845 item->dy = ev->canvas.y - y;
846 item->wd->longpressed = EINA_FALSE;
847 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
848 else item->wd->on_hold = EINA_FALSE;
849 item->wd->wasselected = item->selected;
851 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
852 evas_object_smart_callback_call(item->wd->self, "clicked", item);
853 if (item->long_timer) ecore_timer_del(item->long_timer);
855 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
858 item->long_timer = NULL;
862 _mouse_up(void *data,
863 Evas *evas __UNUSED__,
864 Evas_Object *obj __UNUSED__,
867 Elm_Gengrid_Item *item = data;
868 Evas_Event_Mouse_Up *ev = event_info;
869 Eina_Bool dragged = EINA_FALSE;
871 if (ev->button != 1) return;
872 item->down = EINA_FALSE;
873 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
874 else item->wd->on_hold = EINA_FALSE;
875 if (item->long_timer)
877 ecore_timer_del(item->long_timer);
878 item->long_timer = NULL;
882 item->dragging = EINA_FALSE;
883 evas_object_smart_callback_call(item->wd->self, "drag,stop", item);
886 if (item->wd->on_hold)
888 item->wd->longpressed = EINA_FALSE;
889 item->wd->on_hold = EINA_FALSE;
892 if (item->wd->longpressed)
894 item->wd->longpressed = EINA_FALSE;
895 if (!item->wd->wasselected) _item_unselect(item);
896 item->wd->wasselected = EINA_FALSE;
901 if (item->want_unrealize) _item_unrealize(item);
903 if ((item->disabled) || (dragged)) return;
911 else _item_unselect(item);
917 while (item->wd->selected)
918 _item_unselect(item->wd->selected->data);
922 const Eina_List *l, *l_next;
923 Elm_Gengrid_Item *item2;
925 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
926 if (item2 != item) _item_unselect(item2);
934 _item_hilight(Elm_Gengrid_Item *item)
936 if ((item->wd->no_select) || (item->delete_me) || (item->hilighted)) return;
937 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
938 item->hilighted = EINA_TRUE;
942 _item_realize(Elm_Gengrid_Item *item)
947 if ((item->realized) || (item->delete_me)) return;
948 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
949 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
951 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
952 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
953 elm_widget_sub_object_add(item->wd->self, item->base.view);
954 snprintf(style, sizeof(style), "item/%s",
955 item->gic->item_style ? item->gic->item_style : "default");
956 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
957 elm_widget_style_get(item->wd->self));
959 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
960 evas_object_color_set(item->spacer, 0, 0, 0, 0);
961 elm_widget_sub_object_add(item->wd->self, item->spacer);
962 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
963 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
965 if (item->gic->func.label_get)
971 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
973 EINA_LIST_FOREACH(item->labels, l, key)
975 char *s = item->gic->func.label_get
976 ((void *)item->base.data, item->wd->self, l->data);
979 edje_object_part_text_set(item->base.view, l->data, s);
985 if (item->gic->func.icon_get)
991 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
993 EINA_LIST_FOREACH(item->icons, l, key)
995 Evas_Object *ic = item->gic->func.icon_get
996 ((void *)item->base.data, item->wd->self, l->data);
999 item->icon_objs = eina_list_append(item->icon_objs, ic);
1000 edje_object_part_swallow(item->base.view, key, ic);
1001 evas_object_show(ic);
1002 elm_widget_sub_object_add(item->wd->self, ic);
1007 if (item->gic->func.state_get)
1013 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1015 EINA_LIST_FOREACH(item->states, l, key)
1017 Eina_Bool on = item->gic->func.state_get
1018 ((void *)item->base.data, item->wd->self, l->data);
1021 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1022 edje_object_signal_emit(item->base.view, buf, "elm");
1027 if ((!item->wd->item_width) && (!item->wd->item_height))
1029 edje_object_size_min_restricted_calc(item->base.view,
1030 &item->wd->item_width,
1031 &item->wd->item_height,
1032 item->wd->item_width,
1033 item->wd->item_height);
1034 elm_coords_finger_size_adjust(1, &item->wd->item_width,
1035 1, &item->wd->item_height);
1038 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1040 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
1042 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1046 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
1048 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
1050 evas_object_show(item->base.view);
1052 if (item->tooltip.content_cb)
1054 elm_widget_item_tooltip_content_cb_set(item,
1055 item->tooltip.content_cb,
1056 item->tooltip.data, NULL);
1057 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1060 if (item->mouse_cursor)
1061 elm_widget_item_cursor_set(item, item->mouse_cursor);
1063 item->realized = EINA_TRUE;
1064 item->want_unrealize = EINA_FALSE;
1068 _item_unrealize(Elm_Gengrid_Item *item)
1072 if (!item->realized) return;
1073 if (item->long_timer)
1075 ecore_timer_del(item->long_timer);
1076 item->long_timer = NULL;
1078 evas_object_del(item->base.view);
1079 item->base.view = NULL;
1080 evas_object_del(item->spacer);
1081 item->spacer = NULL;
1082 elm_widget_stringlist_free(item->labels);
1083 item->labels = NULL;
1084 elm_widget_stringlist_free(item->icons);
1086 elm_widget_stringlist_free(item->states);
1087 item->states = NULL;
1089 EINA_LIST_FREE(item->icon_objs, icon)
1090 evas_object_del(icon);
1092 item->realized = EINA_FALSE;
1093 item->want_unrealize = EINA_FALSE;
1097 _item_place(Elm_Gengrid_Item *item,
1101 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh;
1102 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1105 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1107 /* Preload rows/columns at each side of the Gengrid */
1108 cvx = ox - PRELOAD * item->wd->item_width;
1109 cvy = oy - PRELOAD * item->wd->item_height;
1110 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1111 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1116 if (item->wd->horizontal)
1118 int columns, items_visible = 0, items_row;
1120 if (item->wd->item_height > 0)
1121 items_visible = vh / item->wd->item_height;
1122 if (items_visible < 1)
1125 columns = item->wd->count / items_visible;
1126 if (item->wd->count % items_visible)
1129 tcw = item->wd->item_width * columns;
1130 alignw = (vw - tcw) * item->wd->align_x;
1132 items_row = items_visible;
1133 if (items_row > item->wd->count)
1134 items_row = item->wd->count;
1135 tch = items_row * item->wd->item_height;
1136 alignh = (vh - tch) * item->wd->align_y;
1140 int rows, items_visible = 0, items_col;
1142 if (item->wd->item_width > 0)
1143 items_visible = vw / item->wd->item_width;
1144 if (items_visible < 1)
1147 rows = item->wd->count / items_visible;
1148 if (item->wd->count % items_visible)
1151 tch = item->wd->item_height * rows;
1152 alignh = (vh - tch) * item->wd->align_y;
1154 items_col = items_visible;
1155 if (items_col > item->wd->count)
1156 items_col = item->wd->count;
1157 tcw = items_col * item->wd->item_width;
1158 alignw = (vw - tcw) * item->wd->align_x;
1161 x = cx * item->wd->item_width - item->wd->pan_x + ox + alignw;
1162 if (elm_widget_mirrored_get(item->wd->self))
1163 { /* Switch items side and componsate for pan_x when in RTL mode */
1165 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1166 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1169 y = cy * item->wd->item_height - item->wd->pan_y + oy + alignh;
1171 Eina_Bool was_realized = item->realized;
1172 if (ELM_RECTS_INTERSECT(x, y, item->wd->item_width, item->wd->item_height,
1173 cvx, cvy, cvw, cvh))
1175 _item_realize(item);
1177 evas_object_smart_callback_call(item->wd->self, "realized", item);
1178 evas_object_move(item->base.view, x, y);
1179 evas_object_resize(item->base.view, item->wd->item_width,
1180 item->wd->item_height);
1184 _item_unrealize(item);
1186 evas_object_smart_callback_call(item->wd->self, "unrealized", item);
1190 static Elm_Gengrid_Item *
1191 _item_create(Widget_Data *wd,
1192 const Elm_Gengrid_Item_Class *gic,
1195 const void *func_data)
1197 Elm_Gengrid_Item *item;
1199 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1200 if (!item) return NULL;
1204 item->base.data = data;
1205 item->func.func = func;
1206 item->func.data = func_data;
1207 item->mouse_cursor = NULL;
1212 _item_del(Elm_Gengrid_Item *item)
1214 elm_widget_item_pre_notify_del(item);
1216 item->wd->selected = eina_list_remove(item->wd->selected, item);
1217 if (item->realized) _item_unrealize(item);
1218 if ((!item->delete_me) && (item->gic->func.del))
1219 item->gic->func.del((void *)item->base.data, item->wd->self);
1220 item->delete_me = EINA_TRUE;
1221 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1222 if (item->long_timer) ecore_timer_del(item->long_timer);
1223 if (item->tooltip.del_cb)
1224 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1225 item->wd->walking -= item->walking;
1227 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1228 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1229 elm_widget_item_del(item);
1233 _item_select(Elm_Gengrid_Item *item)
1235 if ((item->wd->no_select) || (item->delete_me)) return;
1238 if (item->wd->always_select) goto call;
1241 item->selected = EINA_TRUE;
1242 item->wd->selected = eina_list_append(item->wd->selected, item);
1245 item->wd->walking++;
1246 if (item->func.func)
1247 item->func.func((void *)item->func.data, item->wd->self, item);
1248 if (!item->delete_me)
1249 evas_object_smart_callback_call(item->wd->self, "selected", item);
1251 item->wd->walking--;
1252 if ((item->wd->clear_me) && (!item->wd->walking))
1253 elm_gengrid_clear(item->base.widget);
1256 if ((!item->walking) && (item->delete_me))
1257 if (!item->relcount) _item_del(item);
1259 item->wd->last_selected_item = item;
1263 _item_unselect(Elm_Gengrid_Item *item)
1265 if ((item->delete_me) || (!item->hilighted)) return;
1266 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1267 item->hilighted = EINA_FALSE;
1270 item->selected = EINA_FALSE;
1271 item->wd->selected = eina_list_remove(item->wd->selected, item);
1272 evas_object_smart_callback_call(item->wd->self, "unselected", item);
1277 _calc_job(void *data)
1279 Widget_Data *wd = data;
1280 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1283 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1284 if ((wd->horizontal) && (wd->item_height > 0))
1285 nmax = cvh / wd->item_height;
1286 else if (wd->item_width > 0)
1287 nmax = cvw / wd->item_width;
1295 minw = ceil(count / (float)nmax) * wd->item_width;
1296 minh = nmax * wd->item_height;
1300 minw = nmax * wd->item_width;
1301 minh = ceil(count / (float)nmax) * wd->item_height;
1304 if ((minw != wd->minw) || (minh != wd->minh))
1308 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1312 wd->calc_job = NULL;
1313 evas_object_smart_changed(wd->pan_smart);
1317 _pan_add(Evas_Object *obj)
1320 Evas_Object_Smart_Clipped_Data *cd;
1323 cd = evas_object_smart_data_get(obj);
1326 sd->__clipped_data = *cd;
1328 evas_object_smart_data_set(obj, sd);
1332 _pan_del(Evas_Object *obj)
1334 Pan *sd = evas_object_smart_data_get(obj);
1341 _pan_set(Evas_Object *obj,
1345 Pan *sd = evas_object_smart_data_get(obj);
1346 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1349 evas_object_smart_changed(obj);
1353 _pan_get(Evas_Object *obj,
1357 Pan *sd = evas_object_smart_data_get(obj);
1358 if (x) *x = sd->wd->pan_x;
1359 if (y) *y = sd->wd->pan_y;
1363 _pan_child_size_get(Evas_Object *obj,
1367 Pan *sd = evas_object_smart_data_get(obj);
1368 if (w) *w = sd->wd->minw;
1369 if (h) *h = sd->wd->minh;
1373 _pan_max_get(Evas_Object *obj,
1377 Pan *sd = evas_object_smart_data_get(obj);
1381 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1383 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1385 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1389 _pan_min_get(Evas_Object *obj,
1393 Pan *sd = evas_object_smart_data_get(obj);
1397 _pan_max_get(obj, &mx, &my);
1399 *x = -mx * sd->wd->align_x;
1401 *y = -my * sd->wd->align_y;
1405 _pan_resize(Evas_Object *obj,
1409 Pan *sd = evas_object_smart_data_get(obj);
1412 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1413 if ((ow == w) && (oh == h)) return;
1414 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1415 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1419 _pan_calculate(Evas_Object *obj)
1421 Pan *sd = evas_object_smart_data_get(obj);
1422 Evas_Coord cx = 0, cy = 0;
1423 Elm_Gengrid_Item *item;
1426 if (!sd->wd->nmax) return;
1428 EINA_INLIST_FOREACH(sd->wd->items, item)
1430 _item_place(item, cx, cy);
1431 if (sd->wd->horizontal)
1433 cy = (cy + 1) % sd->wd->nmax;
1438 cx = (cx + 1) % sd->wd->nmax;
1442 evas_object_smart_callback_call(sd->wd->self, "changed", NULL);
1446 _pan_move(Evas_Object *obj,
1447 Evas_Coord x __UNUSED__,
1448 Evas_Coord y __UNUSED__)
1450 Pan *sd = evas_object_smart_data_get(obj);
1452 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1453 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1457 _hold_on(void *data __UNUSED__,
1459 void *event_info __UNUSED__)
1461 Widget_Data *wd = elm_widget_data_get(obj);
1463 elm_smart_scroller_hold_set(wd->scr, 1);
1467 _hold_off(void *data __UNUSED__,
1469 void *event_info __UNUSED__)
1471 Widget_Data *wd = elm_widget_data_get(obj);
1473 elm_smart_scroller_hold_set(wd->scr, 0);
1477 _freeze_on(void *data __UNUSED__,
1479 void *event_info __UNUSED__)
1481 Widget_Data *wd = elm_widget_data_get(obj);
1483 elm_smart_scroller_freeze_set(wd->scr, 1);
1487 _freeze_off(void *data __UNUSED__,
1489 void *event_info __UNUSED__)
1491 Widget_Data *wd = elm_widget_data_get(obj);
1493 elm_smart_scroller_freeze_set(wd->scr, 0);
1497 _scr_drag_start(void *data,
1498 Evas_Object *obj __UNUSED__,
1499 void *event_info __UNUSED__)
1501 evas_object_smart_callback_call(data, "scroll,drag,start", NULL);
1505 _scr_drag_stop(void *data,
1506 Evas_Object *obj __UNUSED__,
1507 void *event_info __UNUSED__)
1509 evas_object_smart_callback_call(data, "scroll,drag,stop", NULL);
1513 _scr_scroll(void *data,
1514 Evas_Object *obj __UNUSED__,
1515 void *event_info __UNUSED__)
1517 evas_object_smart_callback_call(data, "scroll", NULL);
1521 * Add a new Gengrid object.
1523 * @param parent The parent object.
1524 * @return The new object or NULL if it cannot be created.
1526 * @see elm_gengrid_item_size_set()
1527 * @see elm_gengrid_horizontal_set()
1528 * @see elm_gengrid_item_append()
1529 * @see elm_gengrid_item_del()
1530 * @see elm_gengrid_clear()
1535 elm_gengrid_add(Evas_Object *parent)
1540 static Evas_Smart *smart = NULL;
1541 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1543 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
1545 wd = ELM_NEW(Widget_Data);
1546 e = evas_object_evas_get(parent);
1547 if (!e) return NULL;
1548 obj = elm_widget_add(e);
1549 ELM_SET_WIDTYPE(widtype, "gengrid");
1550 elm_widget_type_set(obj, "gengrid");
1551 elm_widget_sub_object_add(parent, obj);
1552 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1553 elm_widget_data_set(obj, wd);
1554 elm_widget_del_hook_set(obj, _del_hook);
1555 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1556 elm_widget_theme_hook_set(obj, _theme_hook);
1557 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1558 elm_widget_can_focus_set(obj, EINA_TRUE);
1559 elm_widget_event_hook_set(obj, _event_hook);
1561 wd->scr = elm_smart_scroller_add(e);
1562 elm_smart_scroller_widget_set(wd->scr, obj);
1563 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1565 elm_widget_resize_object_set(obj, wd->scr);
1567 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1568 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1569 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1571 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1576 wd->no_select = EINA_FALSE;
1578 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1579 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1580 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1581 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1585 static Evas_Smart_Class sc;
1587 evas_object_smart_clipped_smart_set(&_pan_sc);
1589 sc.name = "elm_gengrid_pan";
1590 sc.version = EVAS_SMART_CLASS_VERSION;
1593 sc.resize = _pan_resize;
1594 sc.move = _pan_move;
1595 sc.calculate = _pan_calculate;
1596 smart = evas_smart_class_new(&sc);
1600 wd->pan_smart = evas_object_smart_add(e, smart);
1601 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1605 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1606 _pan_set, _pan_get, _pan_max_get,
1607 _pan_min_get, _pan_child_size_get);
1609 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1614 * Set the size for the item of the Gengrid.
1616 * @param obj The Gengrid object.
1617 * @param w The item's width.
1618 * @param h The item's height;
1620 * @see elm_gengrid_item_size_get()
1625 elm_gengrid_item_size_set(Evas_Object *obj,
1629 ELM_CHECK_WIDTYPE(obj, widtype);
1630 Widget_Data *wd = elm_widget_data_get(obj);
1632 if ((wd->item_width == w) && (wd->item_height == h)) return;
1634 wd->item_height = h;
1635 if (wd->calc_job) ecore_job_del(wd->calc_job);
1636 wd->calc_job = ecore_job_add(_calc_job, wd);
1640 * Get the size of the item of the Gengrid.
1642 * @param obj The Gengrid object.
1643 * @param w Pointer to the item's width.
1644 * @param h Pointer to the item's height.
1646 * @see elm_gengrid_item_size_get()
1651 elm_gengrid_item_size_get(const Evas_Object *obj,
1655 ELM_CHECK_WIDTYPE(obj, widtype);
1656 Widget_Data *wd = elm_widget_data_get(obj);
1658 if (w) *w = wd->item_width;
1659 if (h) *h = wd->item_height;
1663 * Set item's alignment within the scroller.
1665 * @param obj The Gengrid object.
1666 * @param align_x The x alignment (0 <= x <= 1).
1667 * @param align_y The y alignment (0 <= y <= 1).
1669 * @see elm_gengrid_align_get()
1674 elm_gengrid_align_set(Evas_Object *obj,
1678 ELM_CHECK_WIDTYPE(obj, widtype);
1679 Widget_Data *wd = elm_widget_data_get(obj);
1683 else if (align_x < 0.0)
1685 wd->align_x = align_x;
1689 else if (align_y < 0.0)
1691 wd->align_y = align_y;
1695 * Get the alignenment set for the Gengrid object.
1697 * @param obj The Gengrid object.
1698 * @param align_x Pointer to x alignenment.
1699 * @param align_y Pointer to y alignenment.
1701 * @see elm_gengrid_align_set()
1706 elm_gengrid_align_get(const Evas_Object *obj,
1710 ELM_CHECK_WIDTYPE(obj, widtype);
1711 Widget_Data *wd = elm_widget_data_get(obj);
1712 if (align_x) *align_x = wd->align_x;
1713 if (align_y) *align_y = wd->align_y;
1717 * Add item to the end of the Gengrid.
1719 * @param obj The Gengrid object.
1720 * @param gic The item class for the item.
1721 * @param data The item data.
1722 * @param func Convenience function called when item is selected.
1723 * @param func_data Data passed to @p func above.
1724 * @return A handle to the item added or NULL if not possible.
1726 * @see elm_gengrid_item_prepend()
1727 * @see elm_gengrid_item_insert_before()
1728 * @see elm_gengrid_item_insert_after()
1729 * @see elm_gengrid_item_del()
1733 EAPI Elm_Gengrid_Item *
1734 elm_gengrid_item_append(Evas_Object *obj,
1735 const Elm_Gengrid_Item_Class *gic,
1738 const void *func_data)
1740 Elm_Gengrid_Item *item;
1741 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1742 Widget_Data *wd = elm_widget_data_get(obj);
1743 if (!wd) return NULL;
1745 item = _item_create(wd, gic, data, func, func_data);
1746 if (!item) return NULL;
1747 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
1749 if (wd->calc_job) ecore_job_del(wd->calc_job);
1750 wd->calc_job = ecore_job_add(_calc_job, wd);
1756 * Add item at start of the Gengrid.
1758 * This adds an item to the beginning of the grid.
1760 * @param obj The Gengrid object.
1761 * @param gic The item class for the item.
1762 * @param data The item data.
1763 * @param func Convenience function called when item is selected.
1764 * @param func_data Data passed to @p func above.
1765 * @return A handle to the item added or NULL if not possible.
1767 * @see elm_gengrid_item_append()
1768 * @see elm_gengrid_item_insert_before()
1769 * @see elm_gengrid_item_insert_after()
1770 * @see elm_gengrid_item_del()
1774 EAPI Elm_Gengrid_Item *
1775 elm_gengrid_item_prepend(Evas_Object *obj,
1776 const Elm_Gengrid_Item_Class *gic,
1779 const void *func_data)
1781 Elm_Gengrid_Item *item;
1782 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1783 Widget_Data *wd = elm_widget_data_get(obj);
1784 if (!wd) return NULL;
1786 item = _item_create(wd, gic, data, func, func_data);
1787 if (!item) return NULL;
1788 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
1790 if (wd->calc_job) ecore_job_del(wd->calc_job);
1791 wd->calc_job = ecore_job_add(_calc_job, wd);
1797 * Insert and item before another in the Gengrid.
1799 * This inserts an item before another in the grid.
1801 * @param obj The Gengrid object.
1802 * @param gic The item class for the item.
1803 * @param data The item data.
1804 * @param relative The item to which insert before.
1805 * @param func Convenience function called when item is selected.
1806 * @param func_data Data passed to @p func above.
1807 * @return A handle to the item added or NULL if not possible.
1809 * @see elm_gengrid_item_append()
1810 * @see elm_gengrid_item_prepend()
1811 * @see elm_gengrid_item_insert_after()
1812 * @see elm_gengrid_item_del()
1816 EAPI Elm_Gengrid_Item *
1817 elm_gengrid_item_insert_before(Evas_Object *obj,
1818 const Elm_Gengrid_Item_Class *gic,
1820 Elm_Gengrid_Item *relative,
1822 const void *func_data)
1824 Elm_Gengrid_Item *item;
1825 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1826 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1827 Widget_Data *wd = elm_widget_data_get(obj);
1828 if (!wd) return NULL;
1830 item = _item_create(wd, gic, data, func, func_data);
1831 if (!item) return NULL;
1832 wd->items = eina_inlist_prepend_relative
1833 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1835 if (wd->calc_job) ecore_job_del(wd->calc_job);
1836 wd->calc_job = ecore_job_add(_calc_job, wd);
1842 * Insert and item after another in the Gengrid.
1844 * This inserts an item after another in the grid.
1846 * @param obj The Gengrid object.
1847 * @param gic The item class for the item.
1848 * @param data The item data.
1849 * @param relative The item to which insert after.
1850 * @param func Convenience function called when item is selected.
1851 * @param func_data Data passed to @p func above.
1852 * @return A handle to the item added or NULL if not possible.
1854 * @see elm_gengrid_item_append()
1855 * @see elm_gengrid_item_prepend()
1856 * @see elm_gengrid_item_insert_before()
1857 * @see elm_gengrid_item_del()
1861 EAPI Elm_Gengrid_Item *
1862 elm_gengrid_item_insert_after(Evas_Object *obj,
1863 const Elm_Gengrid_Item_Class *gic,
1865 Elm_Gengrid_Item *relative,
1867 const void *func_data)
1869 Elm_Gengrid_Item *item;
1870 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1871 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1872 Widget_Data *wd = elm_widget_data_get(obj);
1873 if (!wd) return NULL;
1875 item = _item_create(wd, gic, data, func, func_data);
1876 if (!item) return NULL;
1877 wd->items = eina_inlist_append_relative
1878 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1880 if (wd->calc_job) ecore_job_del(wd->calc_job);
1881 wd->calc_job = ecore_job_add(_calc_job, wd);
1887 * Remove a item from the Gengrid.
1889 * @param item The item to be removed.
1890 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise.
1892 * @see elm_gengrid_clear() to remove all items of the Gengrid.
1897 elm_gengrid_item_del(Elm_Gengrid_Item *item)
1899 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1900 if ((item->relcount > 0) || (item->walking > 0))
1902 item->delete_me = EINA_TRUE;
1903 elm_widget_item_pre_notify_del(item);
1905 item->wd->selected = eina_list_remove(item->wd->selected, item);
1906 if (item->gic->func.del)
1907 item->gic->func.del((void *)item->base.data, item->wd->self);
1915 * Set for what direction the Gengrid will expand.
1917 * @param obj The Gengrid object.
1918 * @param setting If @c EINA_TRUE the Gengrid will expand horizontally
1919 * or vertically if @c EINA_FALSE.
1924 elm_gengrid_horizontal_set(Evas_Object *obj,
1927 ELM_CHECK_WIDTYPE(obj, widtype);
1928 Widget_Data *wd = elm_widget_data_get(obj);
1930 if (setting == wd->horizontal) return;
1931 wd->horizontal = setting;
1933 /* Update the items to conform to the new layout */
1934 if (wd->calc_job) ecore_job_del(wd->calc_job);
1935 wd->calc_job = ecore_job_add(_calc_job, wd);
1941 * This clears all items in the Gengrid, leaving it empty.
1943 * @param obj The Gengrid object.
1945 * @see elm_gengrid_item_del() to remove just one item.
1950 elm_gengrid_clear(Evas_Object *obj)
1952 ELM_CHECK_WIDTYPE(obj, widtype);
1953 Widget_Data *wd = elm_widget_data_get(obj);
1958 ecore_job_del(wd->calc_job);
1959 wd->calc_job = NULL;
1962 if (wd->walking > 0)
1964 Elm_Gengrid_Item *item;
1966 EINA_INLIST_FOREACH(wd->items, item)
1967 item->delete_me = 1;
1973 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
1975 wd->items = eina_inlist_remove(wd->items, wd->items);
1976 elm_widget_item_pre_notify_del(item);
1977 if (item->realized) _item_unrealize(item);
1978 if (item->gic->func.del)
1979 item->gic->func.del((void *)item->base.data, wd->self);
1980 if (item->long_timer) ecore_timer_del(item->long_timer);
1981 elm_widget_item_del(item);
1986 eina_list_free(wd->selected);
1987 wd->selected = NULL;
1995 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
1996 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2000 * Get the real evas object of the Gengrid item
2002 * This returns the actual evas object used for the specified Gengrid
2003 * item. This may be NULL as it may not be created, and may be
2004 * deleted at any time by Gengrid. Do not modify this object (move,
2005 * resize, show, hide etc.) as Gengrid is controlling it. This
2006 * function is for querying, emitting custom signals or hooking lower
2007 * level callbacks for events. Do not delete this object under any
2010 * @param item The Gengrid item.
2011 * @return the evas object associated to this item.
2013 * @see elm_gengrid_item_data_get()
2017 EAPI const Evas_Object *
2018 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
2020 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2021 return item->base.view;
2025 * Update the contents of an item
2027 * This updates an item by calling all the item class functions again
2028 * to get the icons, labels and states. Use this when the original
2029 * item data has changed and the changes are desired to be reflected.
2031 * @param item The item
2036 elm_gengrid_item_update(Elm_Gengrid_Item *item)
2038 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2039 if (!item->realized) return;
2040 if (item->want_unrealize) return;
2041 _item_unrealize(item);
2042 _item_realize(item);
2043 _item_place(item, item->x, item->y);
2047 * Returns the data associated to a item
2049 * This returns the data value passed on the elm_gengrid_item_append()
2050 * and related item addition calls.
2052 * @param item The Gengrid item.
2053 * @return the data associated to this item.
2055 * @see elm_gengrid_item_append()
2056 * @see elm_gengrid_item_object_get()
2061 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2063 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2064 return elm_widget_item_data_get(item);
2068 * Set the data item from the gengrid item
2070 * This set the data value passed on the elm_gengrid_item_append() and
2071 * related item addition calls. This function will also call
2072 * elm_gengrid_item_update() so the item will be updated to reflect
2075 * @param item The item
2076 * @param data The new data pointer to set
2081 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2084 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2085 elm_widget_item_data_set(item, data);
2086 elm_gengrid_item_update(item);
2090 * Get the item's coordinates.
2092 * This returns the logical position of the item whithin the Gengrid.
2094 * @param item The Gengrid item.
2095 * @param x The x-axis coordinate pointer.
2096 * @param y The y-axis coordinate pointer.
2101 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2105 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2106 if (x) *x = item->x;
2107 if (y) *y = item->y;
2111 * Enable or disable multi-select in the Gengrid.
2113 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
2114 * the Gengrid. This allows more than 1 item to be selected.
2116 * @param obj The Gengrid object.
2117 * @param multi Multi-select enabled/disabled
2122 elm_gengrid_multi_select_set(Evas_Object *obj,
2125 ELM_CHECK_WIDTYPE(obj, widtype);
2126 Widget_Data *wd = elm_widget_data_get(obj);
2132 * Get if multi-select in Gengrid is enabled or disabled
2134 * @param obj The Gengrid object
2135 * @return Multi-select enable/disable
2136 * (EINA_TRUE = enabled / EINA_FALSE = disabled)
2141 elm_gengrid_multi_select_get(const Evas_Object *obj)
2143 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2144 Widget_Data *wd = elm_widget_data_get(obj);
2145 if (!wd) return EINA_FALSE;
2150 * Get the selected item in the Gengrid
2152 * This gets the selected item in the Gengrid (if multi-select is
2153 * enabled only the first item in the list is selected - which is not
2154 * very useful, so see elm_gengrid_selected_items_get() for when
2155 * multi-select is used).
2157 * If no item is selected, NULL is returned.
2159 * @param obj The Gengrid object.
2160 * @return The selected item, or NULL if none.
2164 EAPI Elm_Gengrid_Item *
2165 elm_gengrid_selected_item_get(const Evas_Object *obj)
2167 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2168 Widget_Data *wd = elm_widget_data_get(obj);
2169 if (!wd) return NULL;
2170 if (wd->selected) return wd->selected->data;
2175 * Get a list of selected items in the Gengrid.
2177 * This returns a list of the selected items. This list pointer is
2178 * only valid so long as no items are selected or unselected (or
2179 * unselected implictly by deletion). The list contains
2180 * Elm_Gengrid_Item pointers.
2182 * @param obj The Gengrid object.
2183 * @return The list of selected items, or NULL if none are selected.
2187 EAPI const Eina_List *
2188 elm_gengrid_selected_items_get(const Evas_Object *obj)
2190 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2191 Widget_Data *wd = elm_widget_data_get(obj);
2192 if (!wd) return NULL;
2193 return wd->selected;
2197 * Set the selected state of a item.
2199 * This sets the selected state of a item. If multi-select is not
2200 * enabled and selected is EINA_TRUE, previously selected items are
2203 * @param item The item
2204 * @param selected The selected state.
2209 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2212 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2213 Widget_Data *wd = item->wd;
2215 if (item->delete_me) return;
2216 selected = !!selected;
2217 if (item->selected == selected) return;
2223 while (wd->selected)
2224 _item_unselect(wd->selected->data);
2226 _item_hilight(item);
2230 _item_unselect(item);
2234 * Get the selected state of a item.
2236 * This gets the selected state of a item (1 selected, 0 not selected).
2238 * @param item The item
2239 * @return The selected state
2244 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2246 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2247 return item->selected;
2251 * Sets the disabled state of a item.
2253 * A disabled item cannot be selected or unselected. It will also
2254 * change appearance to disabled. This sets the disabled state (1
2255 * disabled, 0 not disabled).
2257 * @param item The item
2258 * @param disabled The disabled state
2263 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2266 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2267 if (item->disabled == disabled) return;
2268 if (item->delete_me) return;
2269 item->disabled = disabled;
2273 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2275 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2280 * Get the disabled state of a item.
2282 * This gets the disabled state of the given item.
2284 * @param item The item
2285 * @return The disabled state
2290 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2292 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2293 if (item->delete_me) return EINA_FALSE;
2294 return item->disabled;
2297 static Evas_Object *
2298 _elm_gengrid_item_label_create(void *data,
2300 void *item __UNUSED__)
2302 Evas_Object *label = elm_label_add(obj);
2305 elm_object_style_set(label, "tooltip");
2306 elm_label_label_set(label, data);
2311 _elm_gengrid_item_label_del_cb(void *data,
2312 Evas_Object *obj __UNUSED__,
2313 void *event_info __UNUSED__)
2315 eina_stringshare_del(data);
2319 * Set the text to be shown in the gengrid item.
2321 * @param item Target item
2322 * @param text The text to set in the content
2324 * Setup the text as tooltip to object. The item can have only one
2325 * tooltip, so any previous tooltip data is removed.
2330 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2333 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2334 text = eina_stringshare_add(text);
2335 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2337 _elm_gengrid_item_label_del_cb);
2341 * Set the content to be shown in the tooltip item
2343 * Setup the tooltip to item. The item can have only one tooltip, so
2344 * any previous tooltip data is removed. @p func(with @p data) will be
2345 * called every time that need show the tooltip and it should return a
2346 * valid Evas_Object. This object is then managed fully by tooltip
2347 * system and is deleted when the tooltip is gone.
2349 * @param item the gengrid item being attached a tooltip.
2350 * @param func the function used to create the tooltip contents.
2351 * @param data what to provide to @a func as callback data/context.
2352 * @param del_cb called when data is not needed anymore, either when
2353 * another callback replaces @func, the tooltip is unset with
2354 * elm_gengrid_item_tooltip_unset() or the owner @a item
2355 * dies. This callback receives as the first parameter the
2356 * given @a data, and @c event_info is the item.
2361 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2362 Elm_Tooltip_Item_Content_Cb func,
2364 Evas_Smart_Cb del_cb)
2366 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2368 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2371 if (item->tooltip.del_cb)
2372 item->tooltip.del_cb((void *)item->tooltip.data,
2373 item->base.widget, item);
2374 item->tooltip.content_cb = func;
2375 item->tooltip.data = data;
2376 item->tooltip.del_cb = del_cb;
2377 if (item->base.view)
2379 elm_widget_item_tooltip_content_cb_set(item,
2380 item->tooltip.content_cb,
2381 item->tooltip.data, NULL);
2382 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2388 if (del_cb) del_cb((void *)data, NULL, NULL);
2392 * Unset tooltip from item
2394 * @param item gengrid item to remove previously set tooltip.
2396 * Remove tooltip from item. The callback provided as del_cb to
2397 * elm_gengrid_item_tooltip_content_cb_set() will be called to notify
2398 * it is not used anymore.
2400 * @see elm_gengrid_item_tooltip_content_cb_set()
2405 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2407 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2408 if ((item->base.view) && (item->tooltip.content_cb))
2409 elm_widget_item_tooltip_unset(item);
2411 if (item->tooltip.del_cb)
2412 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2413 item->tooltip.del_cb = NULL;
2414 item->tooltip.content_cb = NULL;
2415 item->tooltip.data = NULL;
2416 if (item->tooltip.style)
2417 elm_gengrid_item_tooltip_style_set(item, NULL);
2421 * Sets a different style for this item tooltip.
2423 * @note before you set a style you should define a tooltip with
2424 * elm_gengrid_item_tooltip_content_cb_set() or
2425 * elm_gengrid_item_tooltip_text_set()
2427 * @param item gengrid item with tooltip already set.
2428 * @param style the theme style to use (default, transparent, ...)
2433 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2436 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2437 eina_stringshare_replace(&item->tooltip.style, style);
2438 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2442 * Get the style for this item tooltip.
2444 * @param item gengrid item with tooltip already set.
2445 * @return style the theme style in use, defaults to "default". If the
2446 * object does not have a tooltip set, then NULL is returned.
2451 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2453 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2454 return item->tooltip.style;
2458 * Set the cursor to be shown when mouse is over the gengrid item
2460 * @param item Target item
2461 * @param cursor the cursor name to be used.
2463 * @see elm_object_cursor_set()
2467 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2470 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2471 eina_stringshare_replace(&item->mouse_cursor, cursor);
2472 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2476 * Get the cursor to be shown when mouse is over the gengrid item
2478 * @param item gengrid item with cursor already set.
2479 * @return the cursor name.
2484 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2486 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2487 return elm_widget_item_cursor_get(item);
2491 * Unset the cursor to be shown when mouse is over the gengrid item
2493 * @param item Target item
2495 * @see elm_object_cursor_unset()
2499 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2501 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2502 if (!item->mouse_cursor)
2505 if (item->base.view)
2506 elm_widget_item_cursor_unset(item);
2508 eina_stringshare_del(item->mouse_cursor);
2509 item->mouse_cursor = NULL;
2513 * Sets a different style for this item cursor.
2515 * @note before you set a style you should define a cursor with
2516 * elm_gengrid_item_cursor_set()
2518 * @param item gengrid item with cursor already set.
2519 * @param style the theme style to use (default, transparent, ...)
2524 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2527 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2528 elm_widget_item_cursor_style_set(item, style);
2532 * Get the style for this item cursor.
2534 * @param item gengrid item with cursor already set.
2535 * @return style the theme style in use, defaults to "default". If the
2536 * object does not have a cursor set, then NULL is returned.
2541 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2543 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2544 return elm_widget_item_cursor_style_get(item);
2548 * Set if the cursor set should be searched on the theme or should use
2549 * the provided by the engine, only.
2551 * @note before you set if should look on theme you should define a
2552 * cursor with elm_object_cursor_set(). By default it will only look
2553 * for cursors provided by the engine.
2555 * @param item widget item with cursor already set.
2556 * @param engine_only boolean to define it cursors should be looked
2557 * only between the provided by the engine or searched on widget's
2563 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2564 Eina_Bool engine_only)
2566 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2567 elm_widget_item_cursor_engine_only_set(item, engine_only);
2571 * Get the cursor engine only usage for this item cursor.
2573 * @param item widget item with cursor already set.
2574 * @return engine_only boolean to define it cursors should be looked
2575 * only between the provided by the engine or searched on widget's
2576 * theme as well. If the object does not have a cursor set, then
2577 * EINA_FALSE is returned.
2582 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2584 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2585 return elm_widget_item_cursor_engine_only_get(item);
2589 * Set the always select mode.
2591 * Cells will only call their selection func and callback when first
2592 * becoming selected. Any further clicks will do nothing, unless you
2593 * enable always select with
2594 * elm_gengrid_always_select_mode_set(). This means even if selected,
2595 * every click will make the selected callbacks be called.
2597 * @param obj The Gengrid object
2598 * @param always_select The always select mode (EINA_TRUE = on,
2604 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2605 Eina_Bool always_select)
2607 ELM_CHECK_WIDTYPE(obj, widtype);
2608 Widget_Data *wd = elm_widget_data_get(obj);
2610 wd->always_select = always_select;
2614 * Get the always select mode.
2616 * @param obj The Gengrid object.
2617 * @return The always select mode (EINA_TRUE = on, EINA_FALSE = off)
2622 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2624 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2625 Widget_Data *wd = elm_widget_data_get(obj);
2626 if (!wd) return EINA_FALSE;
2627 return wd->always_select;
2631 * Set no select mode.
2633 * This will turn off the ability to select items entirely and they
2634 * will neither appear selected nor call selected callback functions.
2636 * @param obj The Gengrid object
2637 * @param no_select The no select mode (EINA_TRUE = on, EINA_FALSE = off)
2642 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2643 Eina_Bool no_select)
2645 ELM_CHECK_WIDTYPE(obj, widtype);
2646 Widget_Data *wd = elm_widget_data_get(obj);
2648 wd->no_select = no_select;
2652 * Gets no select mode.
2654 * @param obj The Gengrid object
2655 * @return The no select mode (EINA_TRUE = on, EINA_FALSE = off)
2660 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2662 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2663 Widget_Data *wd = elm_widget_data_get(obj);
2664 if (!wd) return EINA_FALSE;
2665 return wd->no_select;
2671 * This will enable or disable the scroller bounce mode for the
2672 * Gengrid. See elm_scroller_bounce_set() for details.
2674 * @param obj The Gengrid object
2675 * @param h_bounce Allow bounce horizontally
2676 * @param v_bounce Allow bounce vertically
2681 elm_gengrid_bounce_set(Evas_Object *obj,
2685 ELM_CHECK_WIDTYPE(obj, widtype);
2686 Widget_Data *wd = elm_widget_data_get(obj);
2688 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2692 * Get the bounce mode
2694 * @param obj The Gengrid object
2695 * @param h_bounce Allow bounce horizontally
2696 * @param v_bounce Allow bounce vertically
2701 elm_gengrid_bounce_get(const Evas_Object *obj,
2702 Eina_Bool *h_bounce,
2703 Eina_Bool *v_bounce)
2705 ELM_CHECK_WIDTYPE(obj, widtype);
2706 Widget_Data *wd = elm_widget_data_get(obj);
2708 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
2712 * Get all items in the Gengrid.
2714 * This returns a list of the Gengrid items. The list contains
2715 * Elm_Gengrid_Item pointers.
2717 * @param obj The Gengrid object.
2718 * @return The list of items, or NULL if none.
2724 * Set gengrid scroll page size relative to viewport size.
2726 * The gengrid scroller is capable of limiting scrolling by the user
2727 * to "pages" That is to jump by and only show a "whole page" at a
2728 * time as if the continuous area of the scroller content is split
2729 * into page sized pieces. This sets the size of a page relative to
2730 * the viewport of the scroller. 1.0 is "1 viewport" is size
2731 * (horizontally or vertically). 0.0 turns it off in that axis. This
2732 * is mutually exclusive with page size (see
2733 * elm_gengrid_page_size_set() for more information). Likewise 0.5 is
2734 * "half a viewport". Sane usable valus are normally between 0.0 and
2735 * 1.0 including 1.0. If you only want 1 axis to be page "limited",
2736 * use 0.0 for the other axis.
2738 * @param obj The gengrid object
2739 * @param h_pagerel The horizontal page relative size
2740 * @param v_pagerel The vertical page relative size
2745 elm_gengrid_page_relative_set(Evas_Object *obj,
2749 Evas_Coord pagesize_h;
2750 Evas_Coord pagesize_v;
2752 ELM_CHECK_WIDTYPE(obj, widtype);
2753 Widget_Data *wd = elm_widget_data_get(obj);
2756 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
2757 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
2762 * Set gengrid scroll page size.
2764 * See also elm_gengrid_page_relative_set(). This, instead of a page
2765 * size being relative to the viewport, sets it to an absolute fixed
2766 * value, with 0 turning it off for that axis.
2768 * @param obj The gengrid object
2769 * @param h_pagesize The horizontal page size
2770 * @param v_pagesize The vertical page size
2775 elm_gengrid_page_size_set(Evas_Object *obj,
2776 Evas_Coord h_pagesize,
2777 Evas_Coord v_pagesize)
2782 ELM_CHECK_WIDTYPE(obj, widtype);
2783 Widget_Data *wd = elm_widget_data_get(obj);
2785 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
2786 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
2791 * Get the first item in the gengrid
2793 * This returns the first item in the list.
2795 * @param obj The gengrid object
2796 * @return The first item, or NULL if none
2800 EAPI Elm_Gengrid_Item *
2801 elm_gengrid_first_item_get(const Evas_Object *obj)
2803 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2804 Widget_Data *wd = elm_widget_data_get(obj);
2805 if (!wd) return NULL;
2806 if (!wd->items) return NULL;
2807 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2808 while ((item) && (item->delete_me))
2809 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2814 * Get the last item in the gengrid
2816 * This returns the last item in the list.
2818 * @return The last item, or NULL if none
2822 EAPI Elm_Gengrid_Item *
2823 elm_gengrid_last_item_get(const Evas_Object *obj)
2825 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2826 Widget_Data *wd = elm_widget_data_get(obj);
2827 if (!wd) return NULL;
2828 if (!wd->items) return NULL;
2829 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
2830 while ((item) && (item->delete_me))
2831 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2836 * Get the next item in the gengrid
2838 * This returns the item after the item @p item.
2840 * @param item The item
2841 * @return The item after @p item, or NULL if none
2845 EAPI Elm_Gengrid_Item *
2846 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
2848 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2851 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2852 if ((item) && (!item->delete_me)) break;
2854 return (Elm_Gengrid_Item *)item;
2858 * Get the previous item in the gengrid
2860 * This returns the item before the item @p item.
2862 * @param item The item
2863 * @return The item before @p item, or NULL if none
2867 EAPI Elm_Gengrid_Item *
2868 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
2870 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2873 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2874 if ((item) && (!item->delete_me)) break;
2876 return (Elm_Gengrid_Item *)item;
2880 * Get the gengrid object from an item
2882 * This returns the gengrid object itself that an item belongs to.
2884 * @param item The item
2885 * @return The gengrid object
2890 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
2892 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2893 return item->base.widget;
2897 * Show the given item
2899 * This causes gengrid to jump to the given item @p item and show it
2900 * (by scrolling), if it is not fully visible.
2902 * @param item The item
2907 elm_gengrid_item_show(Elm_Gengrid_Item *item)
2909 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2910 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2911 Evas_Coord minx = 0, miny = 0;
2914 if ((!item) || (item->delete_me)) return;
2915 _pan_min_get(wd->pan_smart, &minx, &miny);
2917 elm_smart_scroller_child_region_show(item->wd->scr,
2918 item->x * wd->item_width + minx,
2919 item->y * wd->item_height + miny,
2920 item->wd->item_width,
2921 item->wd->item_height);
2925 * Bring in the given item
2927 * This causes gengrig to jump to the given item @p item and show it
2928 * (by scrolling), if it is not fully visible. This may use animation
2929 * to do so and take a period of time
2931 * @param item The item
2936 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
2938 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2939 if (item->delete_me) return;
2941 Evas_Coord minx = 0, miny = 0;
2942 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2944 _pan_min_get(wd->pan_smart, &minx, &miny);
2946 elm_smart_scroller_region_bring_in(item->wd->scr,
2947 item->x * wd->item_width + minx,
2948 item->y * wd->item_height + miny,
2949 item->wd->item_width,
2950 item->wd->item_height);