1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 * @defgroup Gengrid Gengrid
8 * This widget aims to position objects in a grid layout while
9 * actually building only the visible ones, using the same idea as
10 * genlist: the user define a class for each item, specifying
11 * functions that will be called at object creation and deletion.
13 * A item in the Gengrid can have 0 or more text labels (they can be
14 * regular text or textblock - that's up to the style to determine), 0
15 * or more icons (which are simply objects swallowed into the Gengrid
16 * item) and 0 or more boolean states that can be used for check,
17 * radio or other indicators by the edje theme style. A item may be
18 * one of several styles (Elementary provides 1 by default -
19 * "default", but this can be extended by system or application custom
20 * themes/overlays/extensions).
22 * In order to implement the ability to add and delete items on the
23 * fly, Gengrid implements a class/callback system where the
24 * application provides a structure with information about that type
25 * of item (Gengrid may contain multiple different items with
26 * different classes, states and styles). Gengrid will call the
27 * functions in this struct (methods) when a item is "realized" (that
28 * is created dynamically while scrolling). All objects will simply be
29 * deleted when no longer needed with evas_object_del(). The
30 * Elm_GenGrid_Item_Class structure contains the following members:
32 * item_style - This is a constant string and simply defines the name
33 * of the item style. It must be specified and the default should be
36 * func.label_get - This function is called when an actual item object
37 * is created. The data parameter is the one passed to
38 * elm_gengrid_item_append() and related item creation functions. The
39 * obj parameter is the Gengrid object and the part parameter is the
40 * string name of the text part in the edje design that is listed as
41 * one of the possible labels that can be set. This function must
42 * return a strdup'()ed string as the caller will free() it when done.
44 * func.icon_get - This function is called when an actual item object
45 * is created. The data parameter is the one passed to
46 * elm_gengrid_item_append() and related item creation functions. The
47 * obj parameter is the Gengrid object and the part parameter is the
48 * string name of the icon part in the edje design that is listed as
49 * one of the possible icons that can be set. This must return NULL
50 * for no object or a valid object. The object will be deleted by
51 * Gengrid on shutdown or when the item is unrealized.
53 * func.state_get - This function is called when an actual item object
54 * is created. The data parameter is the one passed to
55 * elm_gengrid_item_append() and related item creation functions. The
56 * obj parameter is the Gengrid object and the part parameter is the
57 * string name of th state part in the edje design that is listed as
58 * one of the possible states that can be set. Return 0 for false and
59 * 1 for true. Gengrid will emit a signal to the edje object with
60 * "elm,state,XXX,active" "elm" when true (the default is false),
61 * where XXX is the name of the part.
63 * func.del - This is called when elm_gengrid_item_del() is called on
64 * a item or elm_gengrid_clear() is called on the Gengrid. This is
65 * intended for use when actual Gengrid items are deleted, so any
66 * backing data attached to the item (e.g. its data parameter on
67 * creation) can be deleted.
69 * If the application wants multiple items to be able to be selected,
70 * elm_gengrid_multi_select_set() can enable this. If the Gengrid is
71 * single-selection only (the default), then
72 * elm_gengrid_select_item_get() will return the selected item, if
73 * any, or NULL if none is selected. If the Gengrid is multi-select
74 * then elm_gengrid_selected_items_get() will return a list (that is
75 * only valid as long as no items are modified (added, deleted,
76 * selected or unselected).
78 * If a item changes (state of boolean changes, label or icons
79 * change), then use elm_gengrid_item_update() to have Gengrid update
80 * the item with the new state. Gengrid will re-realize the item thus
81 * call the functions in the _Elm_Gengrid_Item_Class for that item.
83 * To programmatically (un)select a item use
84 * elm_gengrid_item_selected_set(). To get its selected state use
85 * elm_gengrid_item_selected_get(). To make a item disabled (unable to
86 * be selected and appear differently) use
87 * elm_gengrid_item_disabled_set() to set this and
88 * elm_gengrid_item_disabled_get() to get the disabled state.
90 * Cells will only call their selection func and callback when first
91 * becoming selected. Any further clicks will do nothing, unless you
92 * enable always select with
93 * elm_gengrid_always_select_mode_set(). This means event if selected,
94 * every click will make the selected callbacks be called.
95 * elm_gengrid_no_select_mode_set() will turn off the ability to
96 * select items entirely and they will neither appear selected nor
97 * call selected callback function.
99 * Remember that you can create new styles and add your own theme
100 * augmentation per application with elm_theme_extension_add(). If you
101 * absolutely must have a specific style that overrides any theme the
102 * user or system sets up you can use elm_theme_overlay_add() to add
105 * Signals that you can add callbacks for are:
107 * "clicked,double" - The user has double-clicked or pressed enter on
108 * a item. The event_infoparameter is the Gengrid item
109 * that was double-clicked.
110 * "selected" - The user has made an item selected. The event_info
111 * parameter is the Gengrid item that was selected.
112 * "unselected" - The user has made an item unselected. The event_info
113 * parameter is the Gengrid item that was unselected.
114 * "realized" - This is called when the item in the Gengrid is created
115 * as a real evas object. event_info is the Gengrid item that was
116 * created. The object may be deleted at any time, so it is up to
117 * the caller to not use the object pointer from
118 * elm_gengrid_item_object_get() in a way where it may point to
120 * "unrealized" - This is called when the real evas object for this item
121 * is deleted. event_info is the Gengrid item that was created.
122 * "changed" - Called when an item is added, removed, resized or moved
123 * and when gengrid is resized or horizontal property changes.
124 * "drag,start,up" - Called when the item in the Gengrid has been
125 * dragged (not scrolled) up.
126 * "drag,start,down" - Called when the item in the Gengrid has been
127 * dragged (not scrolled) down.
128 * "drag,start,left" - Called when the item in the Gengrid has been
129 * dragged (not scrolled) left.
130 * "drag,start,right" - Called when the item in the Gengrid has been
131 * dragged (not scrolled) right.
132 * "drag,stop" - Called when the item in the Gengrid has stopped being
134 * "drag" - Called when the item in the Gengrid is being dragged.
135 * "scroll" - called when the content has been scrolled (moved).
136 * "scroll,drag,start" - called when dragging the content has started.
137 * "scroll,drag,stop" - called when dragging the content has stopped.
141 * Handle non-homogeneous objects too.
144 typedef struct _Widget_Data Widget_Data;
145 typedef struct _Pan Pan;
149 struct _Elm_Gengrid_Item
151 Elm_Widget_Item base;
154 const Elm_Gengrid_Item_Class *gic;
155 Ecore_Timer *long_timer;
157 Eina_List *labels, *icons, *states, *icon_objs;
164 Evas_Coord x, y, dx, dy;
171 Elm_Tooltip_Item_Content_Cb content_cb;
172 Evas_Smart_Cb del_cb;
176 const char *mouse_cursor;
178 Eina_Bool want_unrealize : 1;
179 Eina_Bool realized : 1;
180 Eina_Bool dragging : 1;
182 Eina_Bool delete_me : 1;
183 Eina_Bool display_only : 1;
184 Eina_Bool disabled : 1;
185 Eina_Bool selected : 1;
186 Eina_Bool hilighted : 1;
191 Evas_Object *self, *scr;
192 Evas_Object *pan_smart;
197 Elm_Gengrid_Item *last_selected_item;
198 double align_x, align_y;
200 Evas_Coord pan_x, pan_y;
201 Evas_Coord item_width, item_height; /* Each item size */
202 Evas_Coord minw, minh; /* Total obj size */
207 Eina_Bool horizontal : 1;
208 Eina_Bool on_hold : 1;
209 Eina_Bool longpressed : 1;
211 Eina_Bool no_select : 1;
212 Eina_Bool wasselected : 1;
213 Eina_Bool always_select : 1;
214 Eina_Bool clear_me : 1;
217 #define ELM_GENGRID_ITEM_FROM_INLIST(item) \
218 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
222 Evas_Object_Smart_Clipped_Data __clipped_data;
226 static const char *widtype = NULL;
227 static void _item_hilight(Elm_Gengrid_Item *item);
228 static void _item_unrealize(Elm_Gengrid_Item *item);
229 static void _item_select(Elm_Gengrid_Item *item);
230 static void _item_unselect(Elm_Gengrid_Item *item);
231 static void _calc_job(void *data);
232 static void _on_focus_hook(void *data,
234 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
235 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
236 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
237 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
238 static Eina_Bool _item_single_select_up(Widget_Data *wd);
239 static Eina_Bool _item_single_select_down(Widget_Data *wd);
240 static Eina_Bool _item_single_select_left(Widget_Data *wd);
241 static Eina_Bool _item_single_select_right(Widget_Data *wd);
242 static Eina_Bool _event_hook(Evas_Object *obj,
244 Evas_Callback_Type type,
246 static Eina_Bool _deselect_all_items(Widget_Data *wd);
248 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
249 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
252 _event_hook(Evas_Object *obj,
253 Evas_Object *src __UNUSED__,
254 Evas_Callback_Type type,
257 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
258 Evas_Event_Key_Down *ev = event_info;
259 Widget_Data *wd = elm_widget_data_get(obj);
260 if (!wd) return EINA_FALSE;
261 if (!wd->items) return EINA_FALSE;
262 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
263 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
265 Elm_Gengrid_Item *item = NULL;
268 Evas_Coord step_x = 0;
269 Evas_Coord step_y = 0;
272 Evas_Coord page_x = 0;
273 Evas_Coord page_y = 0;
275 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
276 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
277 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
278 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
280 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
282 if ((wd->horizontal) &&
283 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
284 (_item_multi_select_up(wd)))
285 || (_item_single_select_up(wd))))
287 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
290 else if ((!wd->horizontal) &&
291 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
292 (_item_multi_select_left(wd)))
293 || (_item_single_select_left(wd))))
295 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
301 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
303 if ((wd->horizontal) &&
304 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
305 (_item_multi_select_down(wd)))
306 || (_item_single_select_down(wd))))
308 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
311 else if ((!wd->horizontal) &&
312 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
313 (_item_multi_select_right(wd)))
314 || (_item_single_select_right(wd))))
316 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
322 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
324 if ((wd->horizontal) &&
325 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
326 (_item_multi_select_left(wd)))
327 || (_item_single_select_left(wd))))
329 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
332 else if ((!wd->horizontal) &&
333 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
334 (_item_multi_select_up(wd)))
335 || (_item_single_select_up(wd))))
337 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
343 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
345 if ((wd->horizontal) &&
346 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
347 (_item_multi_select_right(wd)))
348 || (_item_single_select_right(wd))))
350 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
353 else if ((!wd->horizontal) &&
354 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
355 (_item_multi_select_down(wd)))
356 || (_item_single_select_down(wd))))
358 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
364 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
366 item = elm_gengrid_first_item_get(obj);
367 elm_gengrid_item_bring_in(item);
368 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
371 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
373 item = elm_gengrid_last_item_get(obj);
374 elm_gengrid_item_bring_in(item);
375 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
378 else if ((!strcmp(ev->keyname, "Prior")) ||
379 (!strcmp(ev->keyname, "KP_Prior")))
384 x -= -(page_x * v_w) / 100;
391 y -= -(page_y * v_h) / 100;
396 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
401 x += -(page_x * v_w) / 100;
408 y += -(page_y * v_h) / 100;
413 else if (!strcmp(ev->keyname, "Escape"))
415 if (!_deselect_all_items(wd)) return EINA_FALSE;
416 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
419 else if ((!strcmp(ev->keyname, "Return")) ||
420 (!strcmp(ev->keyname, "KP_Enter")) ||
421 (!strcmp(ev->keyname, "space")))
423 item = elm_gengrid_selected_item_get(obj);
424 evas_object_smart_callback_call(item->wd->self, "clicked,double", item);
425 evas_object_smart_callback_call(item->wd->self, "clicked", item); // will be removed
427 else return EINA_FALSE;
429 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
430 elm_smart_scroller_child_pos_set(wd->scr, x, y);
435 _deselect_all_items(Widget_Data *wd)
437 if (!wd->selected) return EINA_FALSE;
439 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
445 _item_multi_select_left(Widget_Data *wd)
447 if (!wd->selected) return EINA_FALSE;
449 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
450 if (!prev) return EINA_TRUE;
451 if (elm_gengrid_item_selected_get(prev))
453 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
454 wd->last_selected_item = prev;
455 elm_gengrid_item_show(wd->last_selected_item);
459 elm_gengrid_item_selected_set(prev, EINA_TRUE);
460 elm_gengrid_item_show(prev);
467 _item_multi_select_right(Widget_Data *wd)
469 if (!wd->selected) return EINA_FALSE;
471 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
472 if (!next) return EINA_TRUE;
473 if (elm_gengrid_item_selected_get(next))
475 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
476 wd->last_selected_item = next;
477 elm_gengrid_item_show(wd->last_selected_item);
481 elm_gengrid_item_selected_set(next, EINA_TRUE);
482 elm_gengrid_item_show(next);
489 _item_multi_select_up(Widget_Data *wd)
492 Eina_Bool r = EINA_TRUE;
494 if (!wd->selected) return EINA_FALSE;
496 for (i = 0; (r) && (i < wd->nmax); i++)
497 r &= _item_multi_select_left(wd);
503 _item_multi_select_down(Widget_Data *wd)
506 Eina_Bool r = EINA_TRUE;
508 if (!wd->selected) return EINA_FALSE;
510 for (i = 0; (r) && (i < wd->nmax); i++)
511 r &= _item_multi_select_right(wd);
517 _item_single_select_up(Widget_Data *wd)
521 Elm_Gengrid_Item *prev;
525 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
526 while ((prev) && (prev->delete_me))
527 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
528 elm_gengrid_item_selected_set(prev, EINA_TRUE);
529 elm_gengrid_item_show(prev);
532 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
534 if (!prev) return EINA_FALSE;
536 for (i = 1; i < wd->nmax; i++)
538 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
539 if (!tmp) return EINA_FALSE;
543 _deselect_all_items(wd);
545 elm_gengrid_item_selected_set(prev, EINA_TRUE);
546 elm_gengrid_item_show(prev);
551 _item_single_select_down(Widget_Data *wd)
555 Elm_Gengrid_Item *next;
559 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
560 while ((next) && (next->delete_me))
561 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
562 elm_gengrid_item_selected_set(next, EINA_TRUE);
563 elm_gengrid_item_show(next);
566 else next = elm_gengrid_item_next_get(wd->last_selected_item);
568 if (!next) return EINA_FALSE;
570 for (i = 1; i < wd->nmax; i++)
572 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
573 if (!tmp) return EINA_FALSE;
577 _deselect_all_items(wd);
579 elm_gengrid_item_selected_set(next, EINA_TRUE);
580 elm_gengrid_item_show(next);
585 _item_single_select_left(Widget_Data *wd)
587 Elm_Gengrid_Item *prev;
590 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
591 while ((prev) && (prev->delete_me))
592 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
594 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
596 if (!prev) return EINA_FALSE;
598 _deselect_all_items(wd);
600 elm_gengrid_item_selected_set(prev, EINA_TRUE);
601 elm_gengrid_item_show(prev);
606 _item_single_select_right(Widget_Data *wd)
608 Elm_Gengrid_Item *next;
611 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
612 while ((next) && (next->delete_me))
613 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
615 else next = elm_gengrid_item_next_get(wd->last_selected_item);
617 if (!next) return EINA_FALSE;
619 _deselect_all_items(wd);
621 elm_gengrid_item_selected_set(next, EINA_TRUE);
622 elm_gengrid_item_show(next);
627 _on_focus_hook(void *data __UNUSED__,
630 Widget_Data *wd = elm_widget_data_get(obj);
632 if (elm_widget_focus_get(obj))
634 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
635 evas_object_focus_set(wd->self, EINA_TRUE);
636 if ((wd->selected) && (!wd->last_selected_item))
637 wd->last_selected_item = eina_list_data_get(wd->selected);
641 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
642 evas_object_focus_set(wd->self, EINA_FALSE);
647 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
649 Widget_Data *wd = elm_widget_data_get(obj);
650 Elm_Gengrid_Item *item;
652 elm_smart_scroller_mirrored_set(wd->scr, rtl);
653 if (!wd->items) return;
654 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
658 edje_object_mirrored_set(item->base.view, rtl);
659 elm_gengrid_item_update(item);
660 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
665 _theme_hook(Evas_Object *obj)
667 Widget_Data *wd = elm_widget_data_get(obj);
669 _elm_widget_mirrored_reload(obj);
670 _mirrored_set(obj, elm_widget_mirrored_get(obj));
671 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
672 elm_widget_style_get(obj));
676 _del_pre_hook(Evas_Object *obj)
678 Widget_Data *wd = elm_widget_data_get(obj);
680 elm_gengrid_clear(obj);
681 evas_object_del(wd->pan_smart);
682 wd->pan_smart = NULL;
686 _del_hook(Evas_Object *obj)
688 Widget_Data *wd = elm_widget_data_get(obj);
693 _signal_emit_hook(Evas_Object *obj,
694 const char *emission,
697 Widget_Data *wd = elm_widget_data_get(obj);
699 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
704 _mouse_move(void *data,
705 Evas *evas __UNUSED__,
709 Elm_Gengrid_Item *item = data;
710 Evas_Event_Mouse_Move *ev = event_info;
711 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
713 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
715 if (!item->wd->on_hold)
717 item->wd->on_hold = EINA_TRUE;
718 if (!item->wd->wasselected)
719 _item_unselect(item);
722 if ((item->dragging) && (item->down))
724 if (item->long_timer)
726 ecore_timer_del(item->long_timer);
727 item->long_timer = NULL;
729 evas_object_smart_callback_call(item->wd->self, "drag", item);
732 if ((!item->down) || (item->wd->longpressed))
734 if (item->long_timer)
736 ecore_timer_del(item->long_timer);
737 item->long_timer = NULL;
741 if (!item->display_only)
742 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
743 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
744 x = ev->cur.canvas.x - x;
745 y = ev->cur.canvas.y - y;
748 if (adx < 0) adx = -dx;
751 if (ady < 0) ady = -dy;
754 if ((adx > minw) || (ady > minh))
756 const char *left_drag, *right_drag;
757 if (!elm_widget_mirrored_get(item->wd->self))
759 left_drag = "drag,start,left";
760 right_drag = "drag,start,right";
764 left_drag = "drag,start,right";
765 right_drag = "drag,start,left";
769 if (item->long_timer)
771 ecore_timer_del(item->long_timer);
772 item->long_timer = NULL;
774 if (!item->wd->wasselected)
775 _item_unselect(item);
779 evas_object_smart_callback_call(item->wd->self, "drag,start,up",
784 evas_object_smart_callback_call(item->wd->self,
791 evas_object_smart_callback_call(item->wd->self,
792 "drag,start,down", item);
796 evas_object_smart_callback_call(item->wd->self,
799 evas_object_smart_callback_call(item->wd->self,
807 _long_press(void *data)
809 Elm_Gengrid_Item *item = data;
811 item->long_timer = NULL;
812 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
813 item->wd->longpressed = EINA_TRUE;
814 evas_object_smart_callback_call(item->wd->self, "longpressed", item);
815 return ECORE_CALLBACK_CANCEL;
819 _mouse_down(void *data,
820 Evas *evas __UNUSED__,
824 Elm_Gengrid_Item *item = data;
825 Evas_Event_Mouse_Down *ev = event_info;
828 if (ev->button != 1) return;
831 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
832 item->dx = ev->canvas.x - x;
833 item->dy = ev->canvas.y - y;
834 item->wd->longpressed = EINA_FALSE;
835 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
836 else item->wd->on_hold = EINA_FALSE;
837 item->wd->wasselected = item->selected;
839 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
841 evas_object_smart_callback_call(item->wd->self, "clicked,double", item);
842 evas_object_smart_callback_call(item->wd->self, "clicked", item); // will be removed
844 if (item->long_timer) ecore_timer_del(item->long_timer);
846 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
849 item->long_timer = NULL;
853 _mouse_up(void *data,
854 Evas *evas __UNUSED__,
855 Evas_Object *obj __UNUSED__,
858 Elm_Gengrid_Item *item = data;
859 Evas_Event_Mouse_Up *ev = event_info;
860 Eina_Bool dragged = EINA_FALSE;
862 if (ev->button != 1) return;
863 item->down = EINA_FALSE;
864 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
865 else item->wd->on_hold = EINA_FALSE;
866 if (item->long_timer)
868 ecore_timer_del(item->long_timer);
869 item->long_timer = NULL;
873 item->dragging = EINA_FALSE;
874 evas_object_smart_callback_call(item->wd->self, "drag,stop", item);
877 if (item->wd->on_hold)
879 item->wd->longpressed = EINA_FALSE;
880 item->wd->on_hold = EINA_FALSE;
883 if (item->wd->longpressed)
885 item->wd->longpressed = EINA_FALSE;
886 if (!item->wd->wasselected) _item_unselect(item);
887 item->wd->wasselected = EINA_FALSE;
892 if (item->want_unrealize) _item_unrealize(item);
894 if ((item->disabled) || (dragged)) return;
902 else _item_unselect(item);
908 while (item->wd->selected)
909 _item_unselect(item->wd->selected->data);
913 const Eina_List *l, *l_next;
914 Elm_Gengrid_Item *item2;
916 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
917 if (item2 != item) _item_unselect(item2);
925 _item_hilight(Elm_Gengrid_Item *item)
927 if ((item->wd->no_select) || (item->delete_me) || (item->hilighted)) return;
928 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
929 item->hilighted = EINA_TRUE;
933 _item_realize(Elm_Gengrid_Item *item)
938 if ((item->realized) || (item->delete_me)) return;
939 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
940 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
942 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
943 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
944 elm_widget_sub_object_add(item->wd->self, item->base.view);
945 snprintf(style, sizeof(style), "item/%s",
946 item->gic->item_style ? item->gic->item_style : "default");
947 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
948 elm_widget_style_get(item->wd->self));
950 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
951 evas_object_color_set(item->spacer, 0, 0, 0, 0);
952 elm_widget_sub_object_add(item->wd->self, item->spacer);
953 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
954 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
956 if (item->gic->func.label_get)
962 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
964 EINA_LIST_FOREACH(item->labels, l, key)
966 char *s = item->gic->func.label_get
967 ((void *)item->base.data, item->wd->self, l->data);
970 edje_object_part_text_set(item->base.view, l->data, s);
976 if (item->gic->func.icon_get)
982 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
984 EINA_LIST_FOREACH(item->icons, l, key)
986 Evas_Object *ic = item->gic->func.icon_get
987 ((void *)item->base.data, item->wd->self, l->data);
990 item->icon_objs = eina_list_append(item->icon_objs, ic);
991 edje_object_part_swallow(item->base.view, key, ic);
992 evas_object_show(ic);
993 elm_widget_sub_object_add(item->wd->self, ic);
998 if (item->gic->func.state_get)
1004 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1006 EINA_LIST_FOREACH(item->states, l, key)
1008 Eina_Bool on = item->gic->func.state_get
1009 ((void *)item->base.data, item->wd->self, l->data);
1012 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1013 edje_object_signal_emit(item->base.view, buf, "elm");
1018 if ((!item->wd->item_width) && (!item->wd->item_height))
1020 edje_object_size_min_restricted_calc(item->base.view,
1021 &item->wd->item_width,
1022 &item->wd->item_height,
1023 item->wd->item_width,
1024 item->wd->item_height);
1025 elm_coords_finger_size_adjust(1, &item->wd->item_width,
1026 1, &item->wd->item_height);
1029 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1031 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
1033 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1037 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
1039 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
1041 evas_object_show(item->base.view);
1043 if (item->tooltip.content_cb)
1045 elm_widget_item_tooltip_content_cb_set(item,
1046 item->tooltip.content_cb,
1047 item->tooltip.data, NULL);
1048 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1051 if (item->mouse_cursor)
1052 elm_widget_item_cursor_set(item, item->mouse_cursor);
1054 item->realized = EINA_TRUE;
1055 item->want_unrealize = EINA_FALSE;
1059 _item_unrealize(Elm_Gengrid_Item *item)
1063 if (!item->realized) return;
1064 if (item->long_timer)
1066 ecore_timer_del(item->long_timer);
1067 item->long_timer = NULL;
1069 evas_object_del(item->base.view);
1070 item->base.view = NULL;
1071 evas_object_del(item->spacer);
1072 item->spacer = NULL;
1073 elm_widget_stringlist_free(item->labels);
1074 item->labels = NULL;
1075 elm_widget_stringlist_free(item->icons);
1077 elm_widget_stringlist_free(item->states);
1078 item->states = NULL;
1080 EINA_LIST_FREE(item->icon_objs, icon)
1081 evas_object_del(icon);
1083 item->realized = EINA_FALSE;
1084 item->want_unrealize = EINA_FALSE;
1088 _item_place(Elm_Gengrid_Item *item,
1092 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh;
1093 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1096 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1098 /* Preload rows/columns at each side of the Gengrid */
1099 cvx = ox - PRELOAD * item->wd->item_width;
1100 cvy = oy - PRELOAD * item->wd->item_height;
1101 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1102 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1107 if (item->wd->horizontal)
1109 int columns, items_visible = 0, items_row;
1111 if (item->wd->item_height > 0)
1112 items_visible = vh / item->wd->item_height;
1113 if (items_visible < 1)
1116 columns = item->wd->count / items_visible;
1117 if (item->wd->count % items_visible)
1120 tcw = item->wd->item_width * columns;
1121 alignw = (vw - tcw) * item->wd->align_x;
1123 items_row = items_visible;
1124 if (items_row > item->wd->count)
1125 items_row = item->wd->count;
1126 tch = items_row * item->wd->item_height;
1127 alignh = (vh - tch) * item->wd->align_y;
1131 int rows, items_visible = 0, items_col;
1133 if (item->wd->item_width > 0)
1134 items_visible = vw / item->wd->item_width;
1135 if (items_visible < 1)
1138 rows = item->wd->count / items_visible;
1139 if (item->wd->count % items_visible)
1142 tch = item->wd->item_height * rows;
1143 alignh = (vh - tch) * item->wd->align_y;
1145 items_col = items_visible;
1146 if (items_col > item->wd->count)
1147 items_col = item->wd->count;
1148 tcw = items_col * item->wd->item_width;
1149 alignw = (vw - tcw) * item->wd->align_x;
1152 x = cx * item->wd->item_width - item->wd->pan_x + ox + alignw;
1153 if (elm_widget_mirrored_get(item->wd->self))
1154 { /* Switch items side and componsate for pan_x when in RTL mode */
1156 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1157 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1160 y = cy * item->wd->item_height - item->wd->pan_y + oy + alignh;
1162 Eina_Bool was_realized = item->realized;
1163 if (ELM_RECTS_INTERSECT(x, y, item->wd->item_width, item->wd->item_height,
1164 cvx, cvy, cvw, cvh))
1166 _item_realize(item);
1168 evas_object_smart_callback_call(item->wd->self, "realized", item);
1169 evas_object_move(item->base.view, x, y);
1170 evas_object_resize(item->base.view, item->wd->item_width,
1171 item->wd->item_height);
1175 _item_unrealize(item);
1177 evas_object_smart_callback_call(item->wd->self, "unrealized", item);
1181 static Elm_Gengrid_Item *
1182 _item_create(Widget_Data *wd,
1183 const Elm_Gengrid_Item_Class *gic,
1186 const void *func_data)
1188 Elm_Gengrid_Item *item;
1190 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1191 if (!item) return NULL;
1195 item->base.data = data;
1196 item->func.func = func;
1197 item->func.data = func_data;
1198 item->mouse_cursor = NULL;
1203 _item_del(Elm_Gengrid_Item *item)
1205 elm_widget_item_pre_notify_del(item);
1207 item->wd->selected = eina_list_remove(item->wd->selected, item);
1208 if (item->realized) _item_unrealize(item);
1209 if ((!item->delete_me) && (item->gic->func.del))
1210 item->gic->func.del((void *)item->base.data, item->wd->self);
1211 item->delete_me = EINA_TRUE;
1212 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1213 if (item->long_timer) ecore_timer_del(item->long_timer);
1214 if (item->tooltip.del_cb)
1215 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1216 item->wd->walking -= item->walking;
1218 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1219 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1220 elm_widget_item_del(item);
1224 _item_select(Elm_Gengrid_Item *item)
1226 if ((item->wd->no_select) || (item->delete_me)) return;
1229 if (item->wd->always_select) goto call;
1232 item->selected = EINA_TRUE;
1233 item->wd->selected = eina_list_append(item->wd->selected, item);
1236 item->wd->walking++;
1237 if (item->func.func)
1238 item->func.func((void *)item->func.data, item->wd->self, item);
1239 if (!item->delete_me)
1240 evas_object_smart_callback_call(item->wd->self, "selected", item);
1242 item->wd->walking--;
1243 if ((item->wd->clear_me) && (!item->wd->walking))
1244 elm_gengrid_clear(item->base.widget);
1247 if ((!item->walking) && (item->delete_me))
1248 if (!item->relcount) _item_del(item);
1250 item->wd->last_selected_item = item;
1254 _item_unselect(Elm_Gengrid_Item *item)
1256 if ((item->delete_me) || (!item->hilighted)) return;
1257 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1258 item->hilighted = EINA_FALSE;
1261 item->selected = EINA_FALSE;
1262 item->wd->selected = eina_list_remove(item->wd->selected, item);
1263 evas_object_smart_callback_call(item->wd->self, "unselected", item);
1268 _calc_job(void *data)
1270 Widget_Data *wd = data;
1271 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1274 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1275 if ((cvw != 0) || (cvh != 0))
1277 if ((wd->horizontal) && (wd->item_height > 0))
1278 nmax = cvh / wd->item_height;
1279 else if (wd->item_width > 0)
1280 nmax = cvw / wd->item_width;
1288 minw = ceil(count / (float)nmax) * wd->item_width;
1289 minh = nmax * wd->item_height;
1293 minw = nmax * wd->item_width;
1294 minh = ceil(count / (float)nmax) * wd->item_height;
1297 if ((minw != wd->minw) || (minh != wd->minh))
1301 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1305 wd->calc_job = NULL;
1306 evas_object_smart_changed(wd->pan_smart);
1311 _pan_add(Evas_Object *obj)
1314 Evas_Object_Smart_Clipped_Data *cd;
1317 cd = evas_object_smart_data_get(obj);
1320 sd->__clipped_data = *cd;
1322 evas_object_smart_data_set(obj, sd);
1326 _pan_del(Evas_Object *obj)
1328 Pan *sd = evas_object_smart_data_get(obj);
1335 _pan_set(Evas_Object *obj,
1339 Pan *sd = evas_object_smart_data_get(obj);
1340 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1343 evas_object_smart_changed(obj);
1347 _pan_get(Evas_Object *obj,
1351 Pan *sd = evas_object_smart_data_get(obj);
1352 if (x) *x = sd->wd->pan_x;
1353 if (y) *y = sd->wd->pan_y;
1357 _pan_child_size_get(Evas_Object *obj,
1361 Pan *sd = evas_object_smart_data_get(obj);
1362 if (w) *w = sd->wd->minw;
1363 if (h) *h = sd->wd->minh;
1367 _pan_max_get(Evas_Object *obj,
1371 Pan *sd = evas_object_smart_data_get(obj);
1375 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1377 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1379 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1383 _pan_min_get(Evas_Object *obj,
1387 Pan *sd = evas_object_smart_data_get(obj);
1391 _pan_max_get(obj, &mx, &my);
1393 *x = -mx * sd->wd->align_x;
1395 *y = -my * sd->wd->align_y;
1399 _pan_resize(Evas_Object *obj,
1403 Pan *sd = evas_object_smart_data_get(obj);
1406 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1407 if ((ow == w) && (oh == h)) return;
1408 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1409 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1413 _pan_calculate(Evas_Object *obj)
1415 Pan *sd = evas_object_smart_data_get(obj);
1416 Evas_Coord cx = 0, cy = 0;
1417 Elm_Gengrid_Item *item;
1420 if (!sd->wd->nmax) return;
1422 EINA_INLIST_FOREACH(sd->wd->items, item)
1424 _item_place(item, cx, cy);
1425 if (sd->wd->horizontal)
1427 cy = (cy + 1) % sd->wd->nmax;
1432 cx = (cx + 1) % sd->wd->nmax;
1436 evas_object_smart_callback_call(sd->wd->self, "changed", NULL);
1440 _pan_move(Evas_Object *obj,
1441 Evas_Coord x __UNUSED__,
1442 Evas_Coord y __UNUSED__)
1444 Pan *sd = evas_object_smart_data_get(obj);
1446 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1447 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1451 _hold_on(void *data __UNUSED__,
1453 void *event_info __UNUSED__)
1455 Widget_Data *wd = elm_widget_data_get(obj);
1457 elm_smart_scroller_hold_set(wd->scr, 1);
1461 _hold_off(void *data __UNUSED__,
1463 void *event_info __UNUSED__)
1465 Widget_Data *wd = elm_widget_data_get(obj);
1467 elm_smart_scroller_hold_set(wd->scr, 0);
1471 _freeze_on(void *data __UNUSED__,
1473 void *event_info __UNUSED__)
1475 Widget_Data *wd = elm_widget_data_get(obj);
1477 elm_smart_scroller_freeze_set(wd->scr, 1);
1481 _freeze_off(void *data __UNUSED__,
1483 void *event_info __UNUSED__)
1485 Widget_Data *wd = elm_widget_data_get(obj);
1487 elm_smart_scroller_freeze_set(wd->scr, 0);
1491 _scr_drag_start(void *data,
1492 Evas_Object *obj __UNUSED__,
1493 void *event_info __UNUSED__)
1495 evas_object_smart_callback_call(data, "scroll,drag,start", NULL);
1499 _scr_drag_stop(void *data,
1500 Evas_Object *obj __UNUSED__,
1501 void *event_info __UNUSED__)
1503 evas_object_smart_callback_call(data, "scroll,drag,stop", NULL);
1507 _scr_scroll(void *data,
1508 Evas_Object *obj __UNUSED__,
1509 void *event_info __UNUSED__)
1511 evas_object_smart_callback_call(data, "scroll", NULL);
1515 * Add a new Gengrid object.
1517 * @param parent The parent object.
1518 * @return The new object or NULL if it cannot be created.
1520 * @see elm_gengrid_item_size_set()
1521 * @see elm_gengrid_horizontal_set()
1522 * @see elm_gengrid_item_append()
1523 * @see elm_gengrid_item_del()
1524 * @see elm_gengrid_clear()
1529 elm_gengrid_add(Evas_Object *parent)
1534 static Evas_Smart *smart = NULL;
1535 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1537 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1539 ELM_SET_WIDTYPE(widtype, "gengrid");
1540 elm_widget_type_set(obj, "gengrid");
1541 elm_widget_sub_object_add(parent, obj);
1542 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1543 elm_widget_data_set(obj, wd);
1544 elm_widget_del_hook_set(obj, _del_hook);
1545 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1546 elm_widget_theme_hook_set(obj, _theme_hook);
1547 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1548 elm_widget_can_focus_set(obj, EINA_TRUE);
1549 elm_widget_event_hook_set(obj, _event_hook);
1551 wd->scr = elm_smart_scroller_add(e);
1552 elm_smart_scroller_widget_set(wd->scr, obj);
1553 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1555 elm_widget_resize_object_set(obj, wd->scr);
1557 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1558 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1559 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1561 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1566 wd->no_select = EINA_FALSE;
1568 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1569 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1570 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1571 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1575 static Evas_Smart_Class sc;
1577 evas_object_smart_clipped_smart_set(&_pan_sc);
1579 sc.name = "elm_gengrid_pan";
1580 sc.version = EVAS_SMART_CLASS_VERSION;
1583 sc.resize = _pan_resize;
1584 sc.move = _pan_move;
1585 sc.calculate = _pan_calculate;
1586 smart = evas_smart_class_new(&sc);
1590 wd->pan_smart = evas_object_smart_add(e, smart);
1591 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1595 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1596 _pan_set, _pan_get, _pan_max_get,
1597 _pan_min_get, _pan_child_size_get);
1599 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1604 * Set the size for the item of the Gengrid.
1606 * @param obj The Gengrid object.
1607 * @param w The item's width.
1608 * @param h The item's height;
1610 * @see elm_gengrid_item_size_get()
1615 elm_gengrid_item_size_set(Evas_Object *obj,
1619 ELM_CHECK_WIDTYPE(obj, widtype);
1620 Widget_Data *wd = elm_widget_data_get(obj);
1622 if ((wd->item_width == w) && (wd->item_height == h)) return;
1624 wd->item_height = h;
1625 if (wd->calc_job) ecore_job_del(wd->calc_job);
1626 wd->calc_job = ecore_job_add(_calc_job, wd);
1630 * Get the size of the item of the Gengrid.
1632 * @param obj The Gengrid object.
1633 * @param w Pointer to the item's width.
1634 * @param h Pointer to the item's height.
1636 * @see elm_gengrid_item_size_get()
1641 elm_gengrid_item_size_get(const Evas_Object *obj,
1645 ELM_CHECK_WIDTYPE(obj, widtype);
1646 Widget_Data *wd = elm_widget_data_get(obj);
1648 if (w) *w = wd->item_width;
1649 if (h) *h = wd->item_height;
1653 * Set item's alignment within the scroller.
1655 * @param obj The Gengrid object.
1656 * @param align_x The x alignment (0 <= x <= 1).
1657 * @param align_y The y alignment (0 <= y <= 1).
1659 * @see elm_gengrid_align_get()
1664 elm_gengrid_align_set(Evas_Object *obj,
1668 ELM_CHECK_WIDTYPE(obj, widtype);
1669 Widget_Data *wd = elm_widget_data_get(obj);
1673 else if (align_x < 0.0)
1675 wd->align_x = align_x;
1679 else if (align_y < 0.0)
1681 wd->align_y = align_y;
1685 * Get the alignenment set for the Gengrid object.
1687 * @param obj The Gengrid object.
1688 * @param align_x Pointer to x alignenment.
1689 * @param align_y Pointer to y alignenment.
1691 * @see elm_gengrid_align_set()
1696 elm_gengrid_align_get(const Evas_Object *obj,
1700 ELM_CHECK_WIDTYPE(obj, widtype);
1701 Widget_Data *wd = elm_widget_data_get(obj);
1702 if (align_x) *align_x = wd->align_x;
1703 if (align_y) *align_y = wd->align_y;
1707 * Add item to the end of the Gengrid.
1709 * @param obj The Gengrid object.
1710 * @param gic The item class for the item.
1711 * @param data The item data.
1712 * @param func Convenience function called when item is selected.
1713 * @param func_data Data passed to @p func above.
1714 * @return A handle to the item added or NULL if not possible.
1716 * @see elm_gengrid_item_prepend()
1717 * @see elm_gengrid_item_insert_before()
1718 * @see elm_gengrid_item_insert_after()
1719 * @see elm_gengrid_item_del()
1723 EAPI Elm_Gengrid_Item *
1724 elm_gengrid_item_append(Evas_Object *obj,
1725 const Elm_Gengrid_Item_Class *gic,
1728 const void *func_data)
1730 Elm_Gengrid_Item *item;
1731 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1732 Widget_Data *wd = elm_widget_data_get(obj);
1733 if (!wd) return NULL;
1735 item = _item_create(wd, gic, data, func, func_data);
1736 if (!item) return NULL;
1737 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
1739 if (wd->calc_job) ecore_job_del(wd->calc_job);
1740 wd->calc_job = ecore_job_add(_calc_job, wd);
1746 * Add item at start of the Gengrid.
1748 * This adds an item to the beginning of the grid.
1750 * @param obj The Gengrid object.
1751 * @param gic The item class for the item.
1752 * @param data The item data.
1753 * @param func Convenience function called when item is selected.
1754 * @param func_data Data passed to @p func above.
1755 * @return A handle to the item added or NULL if not possible.
1757 * @see elm_gengrid_item_append()
1758 * @see elm_gengrid_item_insert_before()
1759 * @see elm_gengrid_item_insert_after()
1760 * @see elm_gengrid_item_del()
1764 EAPI Elm_Gengrid_Item *
1765 elm_gengrid_item_prepend(Evas_Object *obj,
1766 const Elm_Gengrid_Item_Class *gic,
1769 const void *func_data)
1771 Elm_Gengrid_Item *item;
1772 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1773 Widget_Data *wd = elm_widget_data_get(obj);
1774 if (!wd) return NULL;
1776 item = _item_create(wd, gic, data, func, func_data);
1777 if (!item) return NULL;
1778 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
1780 if (wd->calc_job) ecore_job_del(wd->calc_job);
1781 wd->calc_job = ecore_job_add(_calc_job, wd);
1787 * Insert and item before another in the Gengrid.
1789 * This inserts an item before another in the grid.
1791 * @param obj The Gengrid object.
1792 * @param gic The item class for the item.
1793 * @param data The item data.
1794 * @param relative The item to which insert before.
1795 * @param func Convenience function called when item is selected.
1796 * @param func_data Data passed to @p func above.
1797 * @return A handle to the item added or NULL if not possible.
1799 * @see elm_gengrid_item_append()
1800 * @see elm_gengrid_item_prepend()
1801 * @see elm_gengrid_item_insert_after()
1802 * @see elm_gengrid_item_del()
1806 EAPI Elm_Gengrid_Item *
1807 elm_gengrid_item_insert_before(Evas_Object *obj,
1808 const Elm_Gengrid_Item_Class *gic,
1810 Elm_Gengrid_Item *relative,
1812 const void *func_data)
1814 Elm_Gengrid_Item *item;
1815 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1816 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1817 Widget_Data *wd = elm_widget_data_get(obj);
1818 if (!wd) return NULL;
1820 item = _item_create(wd, gic, data, func, func_data);
1821 if (!item) return NULL;
1822 wd->items = eina_inlist_prepend_relative
1823 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1825 if (wd->calc_job) ecore_job_del(wd->calc_job);
1826 wd->calc_job = ecore_job_add(_calc_job, wd);
1832 * Insert and item after another in the Gengrid.
1834 * This inserts an item after another in the grid.
1836 * @param obj The Gengrid object.
1837 * @param gic The item class for the item.
1838 * @param data The item data.
1839 * @param relative The item to which insert after.
1840 * @param func Convenience function called when item is selected.
1841 * @param func_data Data passed to @p func above.
1842 * @return A handle to the item added or NULL if not possible.
1844 * @see elm_gengrid_item_append()
1845 * @see elm_gengrid_item_prepend()
1846 * @see elm_gengrid_item_insert_before()
1847 * @see elm_gengrid_item_del()
1851 EAPI Elm_Gengrid_Item *
1852 elm_gengrid_item_insert_after(Evas_Object *obj,
1853 const Elm_Gengrid_Item_Class *gic,
1855 Elm_Gengrid_Item *relative,
1857 const void *func_data)
1859 Elm_Gengrid_Item *item;
1860 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1861 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1862 Widget_Data *wd = elm_widget_data_get(obj);
1863 if (!wd) return NULL;
1865 item = _item_create(wd, gic, data, func, func_data);
1866 if (!item) return NULL;
1867 wd->items = eina_inlist_append_relative
1868 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1870 if (wd->calc_job) ecore_job_del(wd->calc_job);
1871 wd->calc_job = ecore_job_add(_calc_job, wd);
1877 * Remove a item from the Gengrid.
1879 * @param item The item to be removed.
1880 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise.
1882 * @see elm_gengrid_clear() to remove all items of the Gengrid.
1887 elm_gengrid_item_del(Elm_Gengrid_Item *item)
1889 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1890 if ((item->relcount > 0) || (item->walking > 0))
1892 item->delete_me = EINA_TRUE;
1893 elm_widget_item_pre_notify_del(item);
1895 item->wd->selected = eina_list_remove(item->wd->selected, item);
1896 if (item->gic->func.del)
1897 item->gic->func.del((void *)item->base.data, item->wd->self);
1905 * Set for what direction the Gengrid will expand.
1907 * @param obj The Gengrid object.
1908 * @param setting If @c EINA_TRUE the Gengrid will expand horizontally
1909 * or vertically if @c EINA_FALSE.
1914 elm_gengrid_horizontal_set(Evas_Object *obj,
1917 ELM_CHECK_WIDTYPE(obj, widtype);
1918 Widget_Data *wd = elm_widget_data_get(obj);
1920 if (setting == wd->horizontal) return;
1921 wd->horizontal = setting;
1923 /* Update the items to conform to the new layout */
1924 if (wd->calc_job) ecore_job_del(wd->calc_job);
1925 wd->calc_job = ecore_job_add(_calc_job, wd);
1931 * This clears all items in the Gengrid, leaving it empty.
1933 * @param obj The Gengrid object.
1935 * @see elm_gengrid_item_del() to remove just one item.
1940 elm_gengrid_clear(Evas_Object *obj)
1942 ELM_CHECK_WIDTYPE(obj, widtype);
1943 Widget_Data *wd = elm_widget_data_get(obj);
1948 ecore_job_del(wd->calc_job);
1949 wd->calc_job = NULL;
1952 if (wd->walking > 0)
1954 Elm_Gengrid_Item *item;
1956 EINA_INLIST_FOREACH(wd->items, item)
1957 item->delete_me = 1;
1963 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
1965 wd->items = eina_inlist_remove(wd->items, wd->items);
1966 elm_widget_item_pre_notify_del(item);
1967 if (item->realized) _item_unrealize(item);
1968 if (item->gic->func.del)
1969 item->gic->func.del((void *)item->base.data, wd->self);
1970 if (item->long_timer) ecore_timer_del(item->long_timer);
1971 elm_widget_item_del(item);
1976 eina_list_free(wd->selected);
1977 wd->selected = NULL;
1985 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
1986 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1990 * Get the real evas object of the Gengrid item
1992 * This returns the actual evas object used for the specified Gengrid
1993 * item. This may be NULL as it may not be created, and may be
1994 * deleted at any time by Gengrid. Do not modify this object (move,
1995 * resize, show, hide etc.) as Gengrid is controlling it. This
1996 * function is for querying, emitting custom signals or hooking lower
1997 * level callbacks for events. Do not delete this object under any
2000 * @param item The Gengrid item.
2001 * @return the evas object associated to this item.
2003 * @see elm_gengrid_item_data_get()
2007 EAPI const Evas_Object *
2008 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
2010 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2011 return item->base.view;
2015 * Update the contents of an item
2017 * This updates an item by calling all the item class functions again
2018 * to get the icons, labels and states. Use this when the original
2019 * item data has changed and the changes are desired to be reflected.
2021 * @param item The item
2026 elm_gengrid_item_update(Elm_Gengrid_Item *item)
2028 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2029 if (!item->realized) return;
2030 if (item->want_unrealize) return;
2031 _item_unrealize(item);
2032 _item_realize(item);
2033 _item_place(item, item->x, item->y);
2037 * Returns the data associated to a item
2039 * This returns the data value passed on the elm_gengrid_item_append()
2040 * and related item addition calls.
2042 * @param item The Gengrid item.
2043 * @return the data associated to this item.
2045 * @see elm_gengrid_item_append()
2046 * @see elm_gengrid_item_object_get()
2051 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2053 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2054 return elm_widget_item_data_get(item);
2058 * Set the data item from the gengrid item
2060 * This set the data value passed on the elm_gengrid_item_append() and
2061 * related item addition calls. This function will also call
2062 * elm_gengrid_item_update() so the item will be updated to reflect
2065 * @param item The item
2066 * @param data The new data pointer to set
2071 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2074 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2075 elm_widget_item_data_set(item, data);
2076 elm_gengrid_item_update(item);
2080 * Get the item's coordinates.
2082 * This returns the logical position of the item whithin the Gengrid.
2084 * @param item The Gengrid item.
2085 * @param x The x-axis coordinate pointer.
2086 * @param y The y-axis coordinate pointer.
2091 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2095 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2096 if (x) *x = item->x;
2097 if (y) *y = item->y;
2101 * Enable or disable multi-select in the Gengrid.
2103 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
2104 * the Gengrid. This allows more than 1 item to be selected.
2106 * @param obj The Gengrid object.
2107 * @param multi Multi-select enabled/disabled
2112 elm_gengrid_multi_select_set(Evas_Object *obj,
2115 ELM_CHECK_WIDTYPE(obj, widtype);
2116 Widget_Data *wd = elm_widget_data_get(obj);
2122 * Get if multi-select in Gengrid is enabled or disabled
2124 * @param obj The Gengrid object
2125 * @return Multi-select enable/disable
2126 * (EINA_TRUE = enabled / EINA_FALSE = disabled)
2131 elm_gengrid_multi_select_get(const Evas_Object *obj)
2133 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2134 Widget_Data *wd = elm_widget_data_get(obj);
2135 if (!wd) return EINA_FALSE;
2140 * Get the selected item in the Gengrid
2142 * This gets the selected item in the Gengrid (if multi-select is
2143 * enabled only the first item in the list is selected - which is not
2144 * very useful, so see elm_gengrid_selected_items_get() for when
2145 * multi-select is used).
2147 * If no item is selected, NULL is returned.
2149 * @param obj The Gengrid object.
2150 * @return The selected item, or NULL if none.
2154 EAPI Elm_Gengrid_Item *
2155 elm_gengrid_selected_item_get(const Evas_Object *obj)
2157 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2158 Widget_Data *wd = elm_widget_data_get(obj);
2159 if (!wd) return NULL;
2160 if (wd->selected) return wd->selected->data;
2165 * Get a list of selected items in the Gengrid.
2167 * This returns a list of the selected items. This list pointer is
2168 * only valid so long as no items are selected or unselected (or
2169 * unselected implictly by deletion). The list contains
2170 * Elm_Gengrid_Item pointers.
2172 * @param obj The Gengrid object.
2173 * @return The list of selected items, or NULL if none are selected.
2177 EAPI const Eina_List *
2178 elm_gengrid_selected_items_get(const Evas_Object *obj)
2180 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2181 Widget_Data *wd = elm_widget_data_get(obj);
2182 if (!wd) return NULL;
2183 return wd->selected;
2187 * Set the selected state of a item.
2189 * This sets the selected state of a item. If multi-select is not
2190 * enabled and selected is EINA_TRUE, previously selected items are
2193 * @param item The item
2194 * @param selected The selected state.
2199 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2202 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2203 Widget_Data *wd = item->wd;
2205 if (item->delete_me) return;
2206 selected = !!selected;
2207 if (item->selected == selected) return;
2213 while (wd->selected)
2214 _item_unselect(wd->selected->data);
2216 _item_hilight(item);
2220 _item_unselect(item);
2224 * Get the selected state of a item.
2226 * This gets the selected state of a item (1 selected, 0 not selected).
2228 * @param item The item
2229 * @return The selected state
2234 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2236 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2237 return item->selected;
2241 * Sets the disabled state of a item.
2243 * A disabled item cannot be selected or unselected. It will also
2244 * change appearance to disabled. This sets the disabled state (1
2245 * disabled, 0 not disabled).
2247 * @param item The item
2248 * @param disabled The disabled state
2253 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2256 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2257 if (item->disabled == disabled) return;
2258 if (item->delete_me) return;
2259 item->disabled = disabled;
2263 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2265 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2270 * Get the disabled state of a item.
2272 * This gets the disabled state of the given item.
2274 * @param item The item
2275 * @return The disabled state
2280 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2282 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2283 if (item->delete_me) return EINA_FALSE;
2284 return item->disabled;
2287 static Evas_Object *
2288 _elm_gengrid_item_label_create(void *data,
2290 void *item __UNUSED__)
2292 Evas_Object *label = elm_label_add(obj);
2295 elm_object_style_set(label, "tooltip");
2296 elm_label_label_set(label, data);
2301 _elm_gengrid_item_label_del_cb(void *data,
2302 Evas_Object *obj __UNUSED__,
2303 void *event_info __UNUSED__)
2305 eina_stringshare_del(data);
2309 * Set the text to be shown in the gengrid item.
2311 * @param item Target item
2312 * @param text The text to set in the content
2314 * Setup the text as tooltip to object. The item can have only one
2315 * tooltip, so any previous tooltip data is removed.
2320 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2323 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2324 text = eina_stringshare_add(text);
2325 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2327 _elm_gengrid_item_label_del_cb);
2331 * Set the content to be shown in the tooltip item
2333 * Setup the tooltip to item. The item can have only one tooltip, so
2334 * any previous tooltip data is removed. @p func(with @p data) will be
2335 * called every time that need show the tooltip and it should return a
2336 * valid Evas_Object. This object is then managed fully by tooltip
2337 * system and is deleted when the tooltip is gone.
2339 * @param item the gengrid item being attached a tooltip.
2340 * @param func the function used to create the tooltip contents.
2341 * @param data what to provide to @a func as callback data/context.
2342 * @param del_cb called when data is not needed anymore, either when
2343 * another callback replaces @func, the tooltip is unset with
2344 * elm_gengrid_item_tooltip_unset() or the owner @a item
2345 * dies. This callback receives as the first parameter the
2346 * given @a data, and @c event_info is the item.
2351 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2352 Elm_Tooltip_Item_Content_Cb func,
2354 Evas_Smart_Cb del_cb)
2356 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2358 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2361 if (item->tooltip.del_cb)
2362 item->tooltip.del_cb((void *)item->tooltip.data,
2363 item->base.widget, item);
2364 item->tooltip.content_cb = func;
2365 item->tooltip.data = data;
2366 item->tooltip.del_cb = del_cb;
2367 if (item->base.view)
2369 elm_widget_item_tooltip_content_cb_set(item,
2370 item->tooltip.content_cb,
2371 item->tooltip.data, NULL);
2372 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2378 if (del_cb) del_cb((void *)data, NULL, NULL);
2382 * Unset tooltip from item
2384 * @param item gengrid item to remove previously set tooltip.
2386 * Remove tooltip from item. The callback provided as del_cb to
2387 * elm_gengrid_item_tooltip_content_cb_set() will be called to notify
2388 * it is not used anymore.
2390 * @see elm_gengrid_item_tooltip_content_cb_set()
2395 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2397 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2398 if ((item->base.view) && (item->tooltip.content_cb))
2399 elm_widget_item_tooltip_unset(item);
2401 if (item->tooltip.del_cb)
2402 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2403 item->tooltip.del_cb = NULL;
2404 item->tooltip.content_cb = NULL;
2405 item->tooltip.data = NULL;
2406 if (item->tooltip.style)
2407 elm_gengrid_item_tooltip_style_set(item, NULL);
2411 * Sets a different style for this item tooltip.
2413 * @note before you set a style you should define a tooltip with
2414 * elm_gengrid_item_tooltip_content_cb_set() or
2415 * elm_gengrid_item_tooltip_text_set()
2417 * @param item gengrid item with tooltip already set.
2418 * @param style the theme style to use (default, transparent, ...)
2423 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2426 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2427 eina_stringshare_replace(&item->tooltip.style, style);
2428 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2432 * Get the style for this item tooltip.
2434 * @param item gengrid item with tooltip already set.
2435 * @return style the theme style in use, defaults to "default". If the
2436 * object does not have a tooltip set, then NULL is returned.
2441 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2443 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2444 return item->tooltip.style;
2448 * Set the cursor to be shown when mouse is over the gengrid item
2450 * @param item Target item
2451 * @param cursor the cursor name to be used.
2453 * @see elm_object_cursor_set()
2457 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2460 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2461 eina_stringshare_replace(&item->mouse_cursor, cursor);
2462 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2466 * Get the cursor to be shown when mouse is over the gengrid item
2468 * @param item gengrid item with cursor already set.
2469 * @return the cursor name.
2474 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2476 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2477 return elm_widget_item_cursor_get(item);
2481 * Unset the cursor to be shown when mouse is over the gengrid item
2483 * @param item Target item
2485 * @see elm_object_cursor_unset()
2489 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2491 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2492 if (!item->mouse_cursor)
2495 if (item->base.view)
2496 elm_widget_item_cursor_unset(item);
2498 eina_stringshare_del(item->mouse_cursor);
2499 item->mouse_cursor = NULL;
2503 * Sets a different style for this item cursor.
2505 * @note before you set a style you should define a cursor with
2506 * elm_gengrid_item_cursor_set()
2508 * @param item gengrid item with cursor already set.
2509 * @param style the theme style to use (default, transparent, ...)
2514 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2517 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2518 elm_widget_item_cursor_style_set(item, style);
2522 * Get the style for this item cursor.
2524 * @param item gengrid item with cursor already set.
2525 * @return style the theme style in use, defaults to "default". If the
2526 * object does not have a cursor set, then NULL is returned.
2531 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2533 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2534 return elm_widget_item_cursor_style_get(item);
2538 * Set if the cursor set should be searched on the theme or should use
2539 * the provided by the engine, only.
2541 * @note before you set if should look on theme you should define a
2542 * cursor with elm_object_cursor_set(). By default it will only look
2543 * for cursors provided by the engine.
2545 * @param item widget item with cursor already set.
2546 * @param engine_only boolean to define it cursors should be looked
2547 * only between the provided by the engine or searched on widget's
2553 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2554 Eina_Bool engine_only)
2556 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2557 elm_widget_item_cursor_engine_only_set(item, engine_only);
2561 * Get the cursor engine only usage for this item cursor.
2563 * @param item widget item with cursor already set.
2564 * @return engine_only boolean to define it cursors should be looked
2565 * only between the provided by the engine or searched on widget's
2566 * theme as well. If the object does not have a cursor set, then
2567 * EINA_FALSE is returned.
2572 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2574 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2575 return elm_widget_item_cursor_engine_only_get(item);
2579 * Set the always select mode.
2581 * Cells will only call their selection func and callback when first
2582 * becoming selected. Any further clicks will do nothing, unless you
2583 * enable always select with
2584 * elm_gengrid_always_select_mode_set(). This means even if selected,
2585 * every click will make the selected callbacks be called.
2587 * @param obj The Gengrid object
2588 * @param always_select The always select mode (EINA_TRUE = on,
2594 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2595 Eina_Bool always_select)
2597 ELM_CHECK_WIDTYPE(obj, widtype);
2598 Widget_Data *wd = elm_widget_data_get(obj);
2600 wd->always_select = always_select;
2604 * Get the always select mode.
2606 * @param obj The Gengrid object.
2607 * @return The always select mode (EINA_TRUE = on, EINA_FALSE = off)
2612 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2614 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2615 Widget_Data *wd = elm_widget_data_get(obj);
2616 if (!wd) return EINA_FALSE;
2617 return wd->always_select;
2621 * Set no select mode.
2623 * This will turn off the ability to select items entirely and they
2624 * will neither appear selected nor call selected callback functions.
2626 * @param obj The Gengrid object
2627 * @param no_select The no select mode (EINA_TRUE = on, EINA_FALSE = off)
2632 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2633 Eina_Bool no_select)
2635 ELM_CHECK_WIDTYPE(obj, widtype);
2636 Widget_Data *wd = elm_widget_data_get(obj);
2638 wd->no_select = no_select;
2642 * Gets no select mode.
2644 * @param obj The Gengrid object
2645 * @return The no select mode (EINA_TRUE = on, EINA_FALSE = off)
2650 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2652 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2653 Widget_Data *wd = elm_widget_data_get(obj);
2654 if (!wd) return EINA_FALSE;
2655 return wd->no_select;
2661 * This will enable or disable the scroller bounce mode for the
2662 * Gengrid. See elm_scroller_bounce_set() for details.
2664 * @param obj The Gengrid object
2665 * @param h_bounce Allow bounce horizontally
2666 * @param v_bounce Allow bounce vertically
2671 elm_gengrid_bounce_set(Evas_Object *obj,
2675 ELM_CHECK_WIDTYPE(obj, widtype);
2676 Widget_Data *wd = elm_widget_data_get(obj);
2678 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2682 * Get the bounce mode
2684 * @param obj The Gengrid object
2685 * @param h_bounce Allow bounce horizontally
2686 * @param v_bounce Allow bounce vertically
2691 elm_gengrid_bounce_get(const Evas_Object *obj,
2692 Eina_Bool *h_bounce,
2693 Eina_Bool *v_bounce)
2695 ELM_CHECK_WIDTYPE(obj, widtype);
2696 Widget_Data *wd = elm_widget_data_get(obj);
2698 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
2702 * Get all items in the Gengrid.
2704 * This returns a list of the Gengrid items. The list contains
2705 * Elm_Gengrid_Item pointers.
2707 * @param obj The Gengrid object.
2708 * @return The list of items, or NULL if none.
2714 * Set gengrid scroll page size relative to viewport size.
2716 * The gengrid scroller is capable of limiting scrolling by the user
2717 * to "pages" That is to jump by and only show a "whole page" at a
2718 * time as if the continuous area of the scroller content is split
2719 * into page sized pieces. This sets the size of a page relative to
2720 * the viewport of the scroller. 1.0 is "1 viewport" is size
2721 * (horizontally or vertically). 0.0 turns it off in that axis. This
2722 * is mutually exclusive with page size (see
2723 * elm_gengrid_page_size_set() for more information). Likewise 0.5 is
2724 * "half a viewport". Sane usable valus are normally between 0.0 and
2725 * 1.0 including 1.0. If you only want 1 axis to be page "limited",
2726 * use 0.0 for the other axis.
2728 * @param obj The gengrid object
2729 * @param h_pagerel The horizontal page relative size
2730 * @param v_pagerel The vertical page relative size
2735 elm_gengrid_page_relative_set(Evas_Object *obj,
2739 Evas_Coord pagesize_h;
2740 Evas_Coord pagesize_v;
2742 ELM_CHECK_WIDTYPE(obj, widtype);
2743 Widget_Data *wd = elm_widget_data_get(obj);
2746 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
2747 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
2752 * Set gengrid scroll page size.
2754 * See also elm_gengrid_page_relative_set(). This, instead of a page
2755 * size being relative to the viewport, sets it to an absolute fixed
2756 * value, with 0 turning it off for that axis.
2758 * @param obj The gengrid object
2759 * @param h_pagesize The horizontal page size
2760 * @param v_pagesize The vertical page size
2765 elm_gengrid_page_size_set(Evas_Object *obj,
2766 Evas_Coord h_pagesize,
2767 Evas_Coord v_pagesize)
2772 ELM_CHECK_WIDTYPE(obj, widtype);
2773 Widget_Data *wd = elm_widget_data_get(obj);
2775 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
2776 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
2781 * Get the first item in the gengrid
2783 * This returns the first item in the list.
2785 * @param obj The gengrid object
2786 * @return The first item, or NULL if none
2790 EAPI Elm_Gengrid_Item *
2791 elm_gengrid_first_item_get(const Evas_Object *obj)
2793 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2794 Widget_Data *wd = elm_widget_data_get(obj);
2795 if (!wd) return NULL;
2796 if (!wd->items) return NULL;
2797 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2798 while ((item) && (item->delete_me))
2799 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2804 * Get the last item in the gengrid
2806 * This returns the last item in the list.
2808 * @return The last item, or NULL if none
2812 EAPI Elm_Gengrid_Item *
2813 elm_gengrid_last_item_get(const Evas_Object *obj)
2815 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2816 Widget_Data *wd = elm_widget_data_get(obj);
2817 if (!wd) return NULL;
2818 if (!wd->items) return NULL;
2819 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
2820 while ((item) && (item->delete_me))
2821 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2826 * Get the next item in the gengrid
2828 * This returns the item after the item @p item.
2830 * @param item The item
2831 * @return The item after @p item, or NULL if none
2835 EAPI Elm_Gengrid_Item *
2836 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
2838 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2841 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2842 if ((item) && (!item->delete_me)) break;
2844 return (Elm_Gengrid_Item *)item;
2848 * Get the previous item in the gengrid
2850 * This returns the item before the item @p item.
2852 * @param item The item
2853 * @return The item before @p item, or NULL if none
2857 EAPI Elm_Gengrid_Item *
2858 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
2860 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2863 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2864 if ((item) && (!item->delete_me)) break;
2866 return (Elm_Gengrid_Item *)item;
2870 * Get the gengrid object from an item
2872 * This returns the gengrid object itself that an item belongs to.
2874 * @param item The item
2875 * @return The gengrid object
2880 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
2882 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2883 return item->base.widget;
2887 * Show the given item
2889 * This causes gengrid to jump to the given item @p item and show it
2890 * (by scrolling), if it is not fully visible.
2892 * @param item The item
2897 elm_gengrid_item_show(Elm_Gengrid_Item *item)
2899 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2900 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2901 Evas_Coord minx = 0, miny = 0;
2904 if ((!item) || (item->delete_me)) return;
2905 _pan_min_get(wd->pan_smart, &minx, &miny);
2907 elm_smart_scroller_child_region_show(item->wd->scr,
2908 item->x * wd->item_width + minx,
2909 item->y * wd->item_height + miny,
2910 item->wd->item_width,
2911 item->wd->item_height);
2915 * Bring in the given item
2917 * This causes gengrig to jump to the given item @p item and show it
2918 * (by scrolling), if it is not fully visible. This may use animation
2919 * to do so and take a period of time
2921 * @param item The item
2926 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
2928 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2929 if (item->delete_me) return;
2931 Evas_Coord minx = 0, miny = 0;
2932 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2934 _pan_min_get(wd->pan_smart, &minx, &miny);
2936 elm_smart_scroller_region_bring_in(item->wd->scr,
2937 item->x * wd->item_width + minx,
2938 item->y * wd->item_height + miny,
2939 item->wd->item_width,
2940 item->wd->item_height);