1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 * @defgroup Gengrid Gengrid
8 * This widget aims to position objects in a grid layout while
9 * actually building only the visible ones, using the same idea as
10 * genlist: the user define a class for each item, specifying
11 * functions that will be called at object creation and deletion.
13 * A item in the Gengrid can have 0 or more text labels (they can be
14 * regular text or textblock - that's up to the style to determine), 0
15 * or more icons (which are simply objects swallowed into the Gengrid
16 * item) and 0 or more boolean states that can be used for check,
17 * radio or other indicators by the edje theme style. A item may be
18 * one of several styles (Elementary provides 1 by default -
19 * "default", but this can be extended by system or application custom
20 * themes/overlays/extensions).
22 * In order to implement the ability to add and delete items on the
23 * fly, Gengrid implements a class/callback system where the
24 * application provides a structure with information about that type
25 * of item (Gengrid may contain multiple different items with
26 * different classes, states and styles). Gengrid will call the
27 * functions in this struct (methods) when an item is "realized" (that
28 * is created dynamically while scrolling). All objects will simply be
29 * deleted when no longer needed with evas_object_del(). The
30 * Elm_GenGrid_Item_Class structure contains the following members:
32 * item_style - This is a constant string and simply defines the name
33 * of the item style. It must be specified and the default should be
36 * func.label_get - This function is called when an actual item object
37 * is created. The data parameter is the one passed to
38 * elm_gengrid_item_append() and related item creation functions. The
39 * obj parameter is the Gengrid object and the part parameter is the
40 * string name of the text part in the edje design that is listed as
41 * one of the possible labels that can be set. This function must
42 * return a strdup'()ed string as the caller will free() it when done.
44 * func.icon_get - This function is called when an actual item object
45 * is created. The data parameter is the one passed to
46 * elm_gengrid_item_append() and related item creation functions. The
47 * obj parameter is the Gengrid object and the part parameter is the
48 * string name of the icon part in the edje design that is listed as
49 * one of the possible icons that can be set. This must return NULL
50 * for no object or a valid object. The object will be deleted by
51 * Gengrid on shutdown or when the item is unrealized.
53 * func.state_get - This function is called when an actual item object
54 * is created. The data parameter is the one passed to
55 * elm_gengrid_item_append() and related item creation functions. The
56 * obj parameter is the Gengrid object and the part parameter is the
57 * string name of th state part in the edje design that is listed as
58 * one of the possible states that can be set. Return 0 for false and
59 * 1 for true. Gengrid will emit a signal to the edje object with
60 * "elm,state,XXX,active" "elm" when true (the default is false),
61 * where XXX is the name of the part.
63 * func.del - This is called when elm_gengrid_item_del() is called on
64 * an item or elm_gengrid_clear() is called on the Gengrid. This is
65 * intended for use when actual Gengrid items are deleted, so any
66 * backing data attached to the item (e.g. its data parameter on
67 * creation) can be deleted.
69 * If the application wants multiple items to be able to be selected,
70 * elm_gengrid_multi_select_set() can enable this. If the Gengrid is
71 * single-selection only (the default), then
72 * elm_gengrid_select_item_get() will return the selected item, if
73 * any, or NULL if none is selected. If the Gengrid is multi-select
74 * then elm_gengrid_selected_items_get() will return a list (that is
75 * only valid as long as no items are modified (added, deleted,
76 * selected or unselected).
78 * If an item changes (state of boolean changes, label or icons
79 * change), then use elm_gengrid_item_update() to have Gengrid update
80 * the item with the new state. Gengrid will re-realize the item thus
81 * call the functions in the _Elm_Gengrid_Item_Class for that item.
83 * To programmatically (un)select an item use
84 * elm_gengrid_item_selected_set(). To get its selected state use
85 * elm_gengrid_item_selected_get(). To make an item disabled (unable to
86 * be selected and appear differently) use
87 * elm_gengrid_item_disabled_set() to set this and
88 * elm_gengrid_item_disabled_get() to get the disabled state.
90 * Cells will only call their selection func and callback when first
91 * becoming selected. Any further clicks will do nothing, unless you
92 * enable always select with
93 * elm_gengrid_always_select_mode_set(). This means event if selected,
94 * every click will make the selected callbacks be called.
95 * elm_gengrid_no_select_mode_set() will turn off the ability to
96 * select items entirely and they will neither appear selected nor
97 * call selected callback function.
99 * Remember that you can create new styles and add your own theme
100 * augmentation per application with elm_theme_extension_add(). If you
101 * absolutely must have a specific style that overrides any theme the
102 * user or system sets up you can use elm_theme_overlay_add() to add
105 * Signals that you can add callbacks for are:
107 * "clicked,double" - The user has double-clicked or pressed enter on
108 * an item. The event_infoparameter is the Gengrid item
109 * that was double-clicked.
110 * "selected" - The user has made an item selected. The event_info
111 * parameter is the Gengrid item that was selected.
112 * "unselected" - The user has made an item unselected. The event_info
113 * parameter is the Gengrid item that was unselected.
114 * "realized" - This is called when the item in the Gengrid is created
115 * as a real evas object. event_info is the Gengrid item that was
116 * created. The object may be deleted at any time, so it is up to
117 * the caller to not use the object pointer from
118 * elm_gengrid_item_object_get() in a way where it may point to
120 * "unrealized" - This is called when the real evas object for this item
121 * is deleted. event_info is the Gengrid item that was created.
122 * "changed" - Called when an item is added, removed, resized or moved
123 * and when gengrid is resized or horizontal property changes.
124 * "drag,start,up" - Called when the item in the Gengrid has been
125 * dragged (not scrolled) up.
126 * "drag,start,down" - Called when the item in the Gengrid has been
127 * dragged (not scrolled) down.
128 * "drag,start,left" - Called when the item in the Gengrid has been
129 * dragged (not scrolled) left.
130 * "drag,start,right" - Called when the item in the Gengrid has been
131 * dragged (not scrolled) right.
132 * "drag,stop" - Called when the item in the Gengrid has stopped being
134 * "drag" - Called when the item in the Gengrid is being dragged.
135 * "scroll" - called when the content has been scrolled (moved).
136 * "scroll,drag,start" - called when dragging the content has started.
137 * "scroll,drag,stop" - called when dragging the content has stopped.
141 * Handle non-homogeneous objects too.
144 typedef struct _Widget_Data Widget_Data;
145 typedef struct _Pan Pan;
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);
251 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
252 static const char SIG_SELECTED[] = "selected";
253 static const char SIG_UNSELECTED[] = "unselected";
254 static const char SIG_REALIZED[] = "realized";
255 static const char SIG_UNREALIZED[] = "unrealized";
256 static const char SIG_CHANGED[] = "changed";
257 static const char SIG_DRAG_START_UP[] = "drag,start,up";
258 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
259 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
260 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
261 static const char SIG_DRAG_STOP[] = "drag,stop";
262 static const char SIG_DRAG[] = "drag";
263 static const char SIG_SCROLL[] = "scroll";
264 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
265 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
267 static const Evas_Smart_Cb_Description _signals[] = {
268 {SIG_CLICKED_DOUBLE, ""},
270 {SIG_UNSELECTED, ""},
272 {SIG_UNREALIZED, ""},
274 {SIG_DRAG_START_UP, ""},
275 {SIG_DRAG_START_DOWN, ""},
276 {SIG_DRAG_START_LEFT, ""},
277 {SIG_DRAG_START_RIGHT, ""},
281 {SIG_SCROLL_DRAG_START, ""},
282 {SIG_SCROLL_DRAG_STOP, ""},
289 _event_hook(Evas_Object *obj,
290 Evas_Object *src __UNUSED__,
291 Evas_Callback_Type type,
294 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
295 Evas_Event_Key_Down *ev = event_info;
296 Widget_Data *wd = elm_widget_data_get(obj);
297 if (!wd) return EINA_FALSE;
298 if (!wd->items) return EINA_FALSE;
299 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
300 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
302 Elm_Gengrid_Item *item = NULL;
305 Evas_Coord step_x = 0;
306 Evas_Coord step_y = 0;
309 Evas_Coord page_x = 0;
310 Evas_Coord page_y = 0;
312 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
313 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
314 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
315 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
317 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
319 if ((wd->horizontal) &&
320 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
321 (_item_multi_select_up(wd)))
322 || (_item_single_select_up(wd))))
324 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
327 else if ((!wd->horizontal) &&
328 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
329 (_item_multi_select_left(wd)))
330 || (_item_single_select_left(wd))))
332 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
338 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
340 if ((wd->horizontal) &&
341 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
342 (_item_multi_select_down(wd)))
343 || (_item_single_select_down(wd))))
345 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
348 else if ((!wd->horizontal) &&
349 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
350 (_item_multi_select_right(wd)))
351 || (_item_single_select_right(wd))))
353 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
359 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
361 if ((wd->horizontal) &&
362 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
363 (_item_multi_select_left(wd)))
364 || (_item_single_select_left(wd))))
366 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
369 else if ((!wd->horizontal) &&
370 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
371 (_item_multi_select_up(wd)))
372 || (_item_single_select_up(wd))))
374 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
380 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
382 if ((wd->horizontal) &&
383 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
384 (_item_multi_select_right(wd)))
385 || (_item_single_select_right(wd))))
387 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
390 else if ((!wd->horizontal) &&
391 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
392 (_item_multi_select_down(wd)))
393 || (_item_single_select_down(wd))))
395 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
401 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
403 item = elm_gengrid_first_item_get(obj);
404 elm_gengrid_item_bring_in(item);
405 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
408 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
410 item = elm_gengrid_last_item_get(obj);
411 elm_gengrid_item_bring_in(item);
412 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
415 else if ((!strcmp(ev->keyname, "Prior")) ||
416 (!strcmp(ev->keyname, "KP_Prior")))
421 x -= -(page_x * v_w) / 100;
428 y -= -(page_y * v_h) / 100;
433 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
438 x += -(page_x * v_w) / 100;
445 y += -(page_y * v_h) / 100;
450 else if (!strcmp(ev->keyname, "Escape"))
452 if (!_deselect_all_items(wd)) return EINA_FALSE;
453 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
456 else if ((!strcmp(ev->keyname, "Return")) ||
457 (!strcmp(ev->keyname, "KP_Enter")) ||
458 (!strcmp(ev->keyname, "space")))
460 item = elm_gengrid_selected_item_get(obj);
461 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
462 evas_object_smart_callback_call(item->wd->self, "clicked", item); // will be removed
464 else return EINA_FALSE;
466 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
467 elm_smart_scroller_child_pos_set(wd->scr, x, y);
472 _deselect_all_items(Widget_Data *wd)
474 if (!wd->selected) return EINA_FALSE;
476 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
482 _item_multi_select_left(Widget_Data *wd)
484 if (!wd->selected) return EINA_FALSE;
486 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
487 if (!prev) return EINA_TRUE;
488 if (elm_gengrid_item_selected_get(prev))
490 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
491 wd->last_selected_item = prev;
492 elm_gengrid_item_show(wd->last_selected_item);
496 elm_gengrid_item_selected_set(prev, EINA_TRUE);
497 elm_gengrid_item_show(prev);
504 _item_multi_select_right(Widget_Data *wd)
506 if (!wd->selected) return EINA_FALSE;
508 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
509 if (!next) return EINA_TRUE;
510 if (elm_gengrid_item_selected_get(next))
512 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
513 wd->last_selected_item = next;
514 elm_gengrid_item_show(wd->last_selected_item);
518 elm_gengrid_item_selected_set(next, EINA_TRUE);
519 elm_gengrid_item_show(next);
526 _item_multi_select_up(Widget_Data *wd)
529 Eina_Bool r = EINA_TRUE;
531 if (!wd->selected) return EINA_FALSE;
533 for (i = 0; (r) && (i < wd->nmax); i++)
534 r &= _item_multi_select_left(wd);
540 _item_multi_select_down(Widget_Data *wd)
543 Eina_Bool r = EINA_TRUE;
545 if (!wd->selected) return EINA_FALSE;
547 for (i = 0; (r) && (i < wd->nmax); i++)
548 r &= _item_multi_select_right(wd);
554 _item_single_select_up(Widget_Data *wd)
558 Elm_Gengrid_Item *prev;
562 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
563 while ((prev) && (prev->delete_me))
564 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
565 elm_gengrid_item_selected_set(prev, EINA_TRUE);
566 elm_gengrid_item_show(prev);
569 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
571 if (!prev) return EINA_FALSE;
573 for (i = 1; i < wd->nmax; i++)
575 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
576 if (!tmp) return EINA_FALSE;
580 _deselect_all_items(wd);
582 elm_gengrid_item_selected_set(prev, EINA_TRUE);
583 elm_gengrid_item_show(prev);
588 _item_single_select_down(Widget_Data *wd)
592 Elm_Gengrid_Item *next;
596 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
597 while ((next) && (next->delete_me))
598 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
599 elm_gengrid_item_selected_set(next, EINA_TRUE);
600 elm_gengrid_item_show(next);
603 else next = elm_gengrid_item_next_get(wd->last_selected_item);
605 if (!next) return EINA_FALSE;
607 for (i = 1; i < wd->nmax; i++)
609 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
610 if (!tmp) return EINA_FALSE;
614 _deselect_all_items(wd);
616 elm_gengrid_item_selected_set(next, EINA_TRUE);
617 elm_gengrid_item_show(next);
622 _item_single_select_left(Widget_Data *wd)
624 Elm_Gengrid_Item *prev;
627 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
628 while ((prev) && (prev->delete_me))
629 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
631 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
633 if (!prev) return EINA_FALSE;
635 _deselect_all_items(wd);
637 elm_gengrid_item_selected_set(prev, EINA_TRUE);
638 elm_gengrid_item_show(prev);
643 _item_single_select_right(Widget_Data *wd)
645 Elm_Gengrid_Item *next;
648 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
649 while ((next) && (next->delete_me))
650 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
652 else next = elm_gengrid_item_next_get(wd->last_selected_item);
654 if (!next) return EINA_FALSE;
656 _deselect_all_items(wd);
658 elm_gengrid_item_selected_set(next, EINA_TRUE);
659 elm_gengrid_item_show(next);
664 _on_focus_hook(void *data __UNUSED__,
667 Widget_Data *wd = elm_widget_data_get(obj);
669 if (elm_widget_focus_get(obj))
671 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
672 evas_object_focus_set(wd->self, EINA_TRUE);
673 if ((wd->selected) && (!wd->last_selected_item))
674 wd->last_selected_item = eina_list_data_get(wd->selected);
678 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
679 evas_object_focus_set(wd->self, EINA_FALSE);
684 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
686 Widget_Data *wd = elm_widget_data_get(obj);
687 Elm_Gengrid_Item *item;
689 elm_smart_scroller_mirrored_set(wd->scr, rtl);
690 if (!wd->items) return;
691 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
695 edje_object_mirrored_set(item->base.view, rtl);
696 elm_gengrid_item_update(item);
697 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
702 _theme_hook(Evas_Object *obj)
704 Widget_Data *wd = elm_widget_data_get(obj);
706 _elm_widget_mirrored_reload(obj);
707 _mirrored_set(obj, elm_widget_mirrored_get(obj));
708 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
709 elm_widget_style_get(obj));
713 _del_pre_hook(Evas_Object *obj)
715 Widget_Data *wd = elm_widget_data_get(obj);
717 elm_gengrid_clear(obj);
718 evas_object_del(wd->pan_smart);
719 wd->pan_smart = NULL;
723 _del_hook(Evas_Object *obj)
725 Widget_Data *wd = elm_widget_data_get(obj);
730 _signal_emit_hook(Evas_Object *obj,
731 const char *emission,
734 Widget_Data *wd = elm_widget_data_get(obj);
736 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
741 _mouse_move(void *data,
742 Evas *evas __UNUSED__,
746 Elm_Gengrid_Item *item = data;
747 Evas_Event_Mouse_Move *ev = event_info;
748 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
750 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
752 if (!item->wd->on_hold)
754 item->wd->on_hold = EINA_TRUE;
755 if (!item->wd->wasselected)
756 _item_unselect(item);
759 if ((item->dragging) && (item->down))
761 if (item->long_timer)
763 ecore_timer_del(item->long_timer);
764 item->long_timer = NULL;
766 evas_object_smart_callback_call(item->wd->self, SIG_DRAG, item);
769 if ((!item->down) || (item->wd->longpressed))
771 if (item->long_timer)
773 ecore_timer_del(item->long_timer);
774 item->long_timer = NULL;
778 if (!item->display_only)
779 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
780 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
781 x = ev->cur.canvas.x - x;
782 y = ev->cur.canvas.y - y;
785 if (adx < 0) adx = -dx;
788 if (ady < 0) ady = -dy;
791 if ((adx > minw) || (ady > minh))
793 const char *left_drag, *right_drag;
794 if (!elm_widget_mirrored_get(item->wd->self))
796 left_drag = SIG_DRAG_START_LEFT;
797 right_drag = SIG_DRAG_START_RIGHT;
801 left_drag = SIG_DRAG_START_RIGHT;
802 right_drag = SIG_DRAG_START_LEFT;
806 if (item->long_timer)
808 ecore_timer_del(item->long_timer);
809 item->long_timer = NULL;
811 if (!item->wd->wasselected)
812 _item_unselect(item);
816 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_START_UP,
821 evas_object_smart_callback_call(item->wd->self,
828 evas_object_smart_callback_call(item->wd->self,
829 SIG_DRAG_START_DOWN, item);
833 evas_object_smart_callback_call(item->wd->self,
836 evas_object_smart_callback_call(item->wd->self,
844 _long_press(void *data)
846 Elm_Gengrid_Item *item = data;
848 item->long_timer = NULL;
849 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
850 item->wd->longpressed = EINA_TRUE;
851 evas_object_smart_callback_call(item->wd->self, "longpressed", item);
852 return ECORE_CALLBACK_CANCEL;
856 _mouse_down(void *data,
857 Evas *evas __UNUSED__,
861 Elm_Gengrid_Item *item = data;
862 Evas_Event_Mouse_Down *ev = event_info;
865 if (ev->button != 1) return;
868 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
869 item->dx = ev->canvas.x - x;
870 item->dy = ev->canvas.y - y;
871 item->wd->longpressed = EINA_FALSE;
872 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
873 else item->wd->on_hold = EINA_FALSE;
874 item->wd->wasselected = item->selected;
876 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
878 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
879 evas_object_smart_callback_call(item->wd->self, "clicked", item); // will be removed
881 if (item->long_timer) ecore_timer_del(item->long_timer);
883 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
886 item->long_timer = NULL;
890 _mouse_up(void *data,
891 Evas *evas __UNUSED__,
892 Evas_Object *obj __UNUSED__,
895 Elm_Gengrid_Item *item = data;
896 Evas_Event_Mouse_Up *ev = event_info;
897 Eina_Bool dragged = EINA_FALSE;
899 if (ev->button != 1) return;
900 item->down = EINA_FALSE;
901 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
902 else item->wd->on_hold = EINA_FALSE;
903 if (item->long_timer)
905 ecore_timer_del(item->long_timer);
906 item->long_timer = NULL;
910 item->dragging = EINA_FALSE;
911 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_STOP, item);
914 if (item->wd->on_hold)
916 item->wd->longpressed = EINA_FALSE;
917 item->wd->on_hold = EINA_FALSE;
920 if (item->wd->longpressed)
922 item->wd->longpressed = EINA_FALSE;
923 if (!item->wd->wasselected) _item_unselect(item);
924 item->wd->wasselected = EINA_FALSE;
929 if (item->want_unrealize) _item_unrealize(item);
931 if ((item->disabled) || (dragged)) return;
939 else _item_unselect(item);
945 while (item->wd->selected)
946 _item_unselect(item->wd->selected->data);
950 const Eina_List *l, *l_next;
951 Elm_Gengrid_Item *item2;
953 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
954 if (item2 != item) _item_unselect(item2);
962 _item_hilight(Elm_Gengrid_Item *item)
964 if ((item->wd->no_select) || (item->delete_me) || (item->hilighted)) return;
965 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
966 item->hilighted = EINA_TRUE;
970 _item_realize(Elm_Gengrid_Item *item)
975 if ((item->realized) || (item->delete_me)) return;
976 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
977 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
979 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
980 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
981 elm_widget_sub_object_add(item->wd->self, item->base.view);
982 snprintf(style, sizeof(style), "item/%s",
983 item->gic->item_style ? item->gic->item_style : "default");
984 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
985 elm_widget_style_get(item->wd->self));
987 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
988 evas_object_color_set(item->spacer, 0, 0, 0, 0);
989 elm_widget_sub_object_add(item->wd->self, item->spacer);
990 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
991 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
993 if (item->gic->func.label_get)
999 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1001 EINA_LIST_FOREACH(item->labels, l, key)
1003 char *s = item->gic->func.label_get
1004 ((void *)item->base.data, item->wd->self, l->data);
1007 edje_object_part_text_set(item->base.view, l->data, s);
1013 if (item->gic->func.icon_get)
1019 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1021 EINA_LIST_FOREACH(item->icons, l, key)
1023 Evas_Object *ic = item->gic->func.icon_get
1024 ((void *)item->base.data, item->wd->self, l->data);
1027 item->icon_objs = eina_list_append(item->icon_objs, ic);
1028 edje_object_part_swallow(item->base.view, key, ic);
1029 evas_object_show(ic);
1030 elm_widget_sub_object_add(item->wd->self, ic);
1035 if (item->gic->func.state_get)
1041 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1043 EINA_LIST_FOREACH(item->states, l, key)
1045 Eina_Bool on = item->gic->func.state_get
1046 ((void *)item->base.data, item->wd->self, l->data);
1049 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1050 edje_object_signal_emit(item->base.view, buf, "elm");
1055 if ((!item->wd->item_width) && (!item->wd->item_height))
1057 edje_object_size_min_restricted_calc(item->base.view,
1058 &item->wd->item_width,
1059 &item->wd->item_height,
1060 item->wd->item_width,
1061 item->wd->item_height);
1062 elm_coords_finger_size_adjust(1, &item->wd->item_width,
1063 1, &item->wd->item_height);
1066 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1068 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
1070 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1074 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
1076 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
1078 evas_object_show(item->base.view);
1080 if (item->tooltip.content_cb)
1082 elm_widget_item_tooltip_content_cb_set(item,
1083 item->tooltip.content_cb,
1084 item->tooltip.data, NULL);
1085 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1088 if (item->mouse_cursor)
1089 elm_widget_item_cursor_set(item, item->mouse_cursor);
1091 item->realized = EINA_TRUE;
1092 item->want_unrealize = EINA_FALSE;
1096 _item_unrealize(Elm_Gengrid_Item *item)
1100 if (!item->realized) return;
1101 if (item->long_timer)
1103 ecore_timer_del(item->long_timer);
1104 item->long_timer = NULL;
1106 evas_object_del(item->base.view);
1107 item->base.view = NULL;
1108 evas_object_del(item->spacer);
1109 item->spacer = NULL;
1110 elm_widget_stringlist_free(item->labels);
1111 item->labels = NULL;
1112 elm_widget_stringlist_free(item->icons);
1114 elm_widget_stringlist_free(item->states);
1115 item->states = NULL;
1117 EINA_LIST_FREE(item->icon_objs, icon)
1118 evas_object_del(icon);
1120 item->realized = EINA_FALSE;
1121 item->want_unrealize = EINA_FALSE;
1125 _item_place(Elm_Gengrid_Item *item,
1129 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh;
1130 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1133 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1135 /* Preload rows/columns at each side of the Gengrid */
1136 cvx = ox - PRELOAD * item->wd->item_width;
1137 cvy = oy - PRELOAD * item->wd->item_height;
1138 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1139 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1144 if (item->wd->horizontal)
1146 int columns, items_visible = 0, items_row;
1148 if (item->wd->item_height > 0)
1149 items_visible = vh / item->wd->item_height;
1150 if (items_visible < 1)
1153 columns = item->wd->count / items_visible;
1154 if (item->wd->count % items_visible)
1157 tcw = item->wd->item_width * columns;
1158 alignw = (vw - tcw) * item->wd->align_x;
1160 items_row = items_visible;
1161 if (items_row > item->wd->count)
1162 items_row = item->wd->count;
1163 tch = items_row * item->wd->item_height;
1164 alignh = (vh - tch) * item->wd->align_y;
1168 int rows, items_visible = 0, items_col;
1170 if (item->wd->item_width > 0)
1171 items_visible = vw / item->wd->item_width;
1172 if (items_visible < 1)
1175 rows = item->wd->count / items_visible;
1176 if (item->wd->count % items_visible)
1179 tch = item->wd->item_height * rows;
1180 alignh = (vh - tch) * item->wd->align_y;
1182 items_col = items_visible;
1183 if (items_col > item->wd->count)
1184 items_col = item->wd->count;
1185 tcw = items_col * item->wd->item_width;
1186 alignw = (vw - tcw) * item->wd->align_x;
1189 x = cx * item->wd->item_width - item->wd->pan_x + ox + alignw;
1190 if (elm_widget_mirrored_get(item->wd->self))
1191 { /* Switch items side and componsate for pan_x when in RTL mode */
1193 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1194 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1197 y = cy * item->wd->item_height - item->wd->pan_y + oy + alignh;
1199 Eina_Bool was_realized = item->realized;
1200 if (ELM_RECTS_INTERSECT(x, y, item->wd->item_width, item->wd->item_height,
1201 cvx, cvy, cvw, cvh))
1203 _item_realize(item);
1205 evas_object_smart_callback_call(item->wd->self, SIG_REALIZED, item);
1206 evas_object_move(item->base.view, x, y);
1207 evas_object_resize(item->base.view, item->wd->item_width,
1208 item->wd->item_height);
1212 _item_unrealize(item);
1214 evas_object_smart_callback_call(item->wd->self, SIG_UNREALIZED, item);
1218 static Elm_Gengrid_Item *
1219 _item_create(Widget_Data *wd,
1220 const Elm_Gengrid_Item_Class *gic,
1223 const void *func_data)
1225 Elm_Gengrid_Item *item;
1227 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1228 if (!item) return NULL;
1232 item->base.data = data;
1233 item->func.func = func;
1234 item->func.data = func_data;
1235 item->mouse_cursor = NULL;
1240 _item_del(Elm_Gengrid_Item *item)
1242 elm_widget_item_pre_notify_del(item);
1244 item->wd->selected = eina_list_remove(item->wd->selected, item);
1245 if (item->realized) _item_unrealize(item);
1246 if ((!item->delete_me) && (item->gic->func.del))
1247 item->gic->func.del((void *)item->base.data, item->wd->self);
1248 item->delete_me = EINA_TRUE;
1249 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1250 if (item->long_timer) ecore_timer_del(item->long_timer);
1251 if (item->tooltip.del_cb)
1252 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1253 item->wd->walking -= item->walking;
1255 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1256 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1257 elm_widget_item_del(item);
1261 _item_select(Elm_Gengrid_Item *item)
1263 if ((item->wd->no_select) || (item->delete_me)) return;
1266 if (item->wd->always_select) goto call;
1269 item->selected = EINA_TRUE;
1270 item->wd->selected = eina_list_append(item->wd->selected, item);
1273 item->wd->walking++;
1274 if (item->func.func)
1275 item->func.func((void *)item->func.data, item->wd->self, item);
1276 if (!item->delete_me)
1277 evas_object_smart_callback_call(item->wd->self, SIG_SELECTED, item);
1279 item->wd->walking--;
1280 if ((item->wd->clear_me) && (!item->wd->walking))
1281 elm_gengrid_clear(item->base.widget);
1284 if ((!item->walking) && (item->delete_me))
1285 if (!item->relcount) _item_del(item);
1287 item->wd->last_selected_item = item;
1291 _item_unselect(Elm_Gengrid_Item *item)
1293 if ((item->delete_me) || (!item->hilighted)) return;
1294 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1295 item->hilighted = EINA_FALSE;
1298 item->selected = EINA_FALSE;
1299 item->wd->selected = eina_list_remove(item->wd->selected, item);
1300 evas_object_smart_callback_call(item->wd->self, SIG_UNSELECTED, item);
1305 _calc_job(void *data)
1307 Widget_Data *wd = data;
1308 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1311 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1312 if ((cvw != 0) || (cvh != 0))
1314 if ((wd->horizontal) && (wd->item_height > 0))
1315 nmax = cvh / wd->item_height;
1316 else if (wd->item_width > 0)
1317 nmax = cvw / wd->item_width;
1325 minw = ceil(count / (float)nmax) * wd->item_width;
1326 minh = nmax * wd->item_height;
1330 minw = nmax * wd->item_width;
1331 minh = ceil(count / (float)nmax) * wd->item_height;
1334 if ((minw != wd->minw) || (minh != wd->minh))
1338 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1342 wd->calc_job = NULL;
1343 evas_object_smart_changed(wd->pan_smart);
1348 _pan_add(Evas_Object *obj)
1351 Evas_Object_Smart_Clipped_Data *cd;
1354 cd = evas_object_smart_data_get(obj);
1357 sd->__clipped_data = *cd;
1359 evas_object_smart_data_set(obj, sd);
1363 _pan_del(Evas_Object *obj)
1365 Pan *sd = evas_object_smart_data_get(obj);
1372 _pan_set(Evas_Object *obj,
1376 Pan *sd = evas_object_smart_data_get(obj);
1377 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1380 evas_object_smart_changed(obj);
1384 _pan_get(Evas_Object *obj,
1388 Pan *sd = evas_object_smart_data_get(obj);
1389 if (x) *x = sd->wd->pan_x;
1390 if (y) *y = sd->wd->pan_y;
1394 _pan_child_size_get(Evas_Object *obj,
1398 Pan *sd = evas_object_smart_data_get(obj);
1399 if (w) *w = sd->wd->minw;
1400 if (h) *h = sd->wd->minh;
1404 _pan_max_get(Evas_Object *obj,
1408 Pan *sd = evas_object_smart_data_get(obj);
1412 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1414 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1416 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1420 _pan_min_get(Evas_Object *obj,
1424 Pan *sd = evas_object_smart_data_get(obj);
1428 _pan_max_get(obj, &mx, &my);
1430 *x = -mx * sd->wd->align_x;
1432 *y = -my * sd->wd->align_y;
1436 _pan_resize(Evas_Object *obj,
1440 Pan *sd = evas_object_smart_data_get(obj);
1443 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1444 if ((ow == w) && (oh == h)) return;
1445 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1446 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1450 _pan_calculate(Evas_Object *obj)
1452 Pan *sd = evas_object_smart_data_get(obj);
1453 Evas_Coord cx = 0, cy = 0;
1454 Elm_Gengrid_Item *item;
1457 if (!sd->wd->nmax) return;
1459 EINA_INLIST_FOREACH(sd->wd->items, item)
1461 _item_place(item, cx, cy);
1462 if (sd->wd->horizontal)
1464 cy = (cy + 1) % sd->wd->nmax;
1469 cx = (cx + 1) % sd->wd->nmax;
1473 evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
1477 _pan_move(Evas_Object *obj,
1478 Evas_Coord x __UNUSED__,
1479 Evas_Coord y __UNUSED__)
1481 Pan *sd = evas_object_smart_data_get(obj);
1483 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1484 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1488 _hold_on(void *data __UNUSED__,
1490 void *event_info __UNUSED__)
1492 Widget_Data *wd = elm_widget_data_get(obj);
1494 elm_smart_scroller_hold_set(wd->scr, 1);
1498 _hold_off(void *data __UNUSED__,
1500 void *event_info __UNUSED__)
1502 Widget_Data *wd = elm_widget_data_get(obj);
1504 elm_smart_scroller_hold_set(wd->scr, 0);
1508 _freeze_on(void *data __UNUSED__,
1510 void *event_info __UNUSED__)
1512 Widget_Data *wd = elm_widget_data_get(obj);
1514 elm_smart_scroller_freeze_set(wd->scr, 1);
1518 _freeze_off(void *data __UNUSED__,
1520 void *event_info __UNUSED__)
1522 Widget_Data *wd = elm_widget_data_get(obj);
1524 elm_smart_scroller_freeze_set(wd->scr, 0);
1528 _scr_drag_start(void *data,
1529 Evas_Object *obj __UNUSED__,
1530 void *event_info __UNUSED__)
1532 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1536 _scr_drag_stop(void *data,
1537 Evas_Object *obj __UNUSED__,
1538 void *event_info __UNUSED__)
1540 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1544 _scr_scroll(void *data,
1545 Evas_Object *obj __UNUSED__,
1546 void *event_info __UNUSED__)
1548 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1552 * Add a new Gengrid object.
1554 * @param parent The parent object.
1555 * @return The new object or NULL if it cannot be created.
1557 * @see elm_gengrid_item_size_set()
1558 * @see elm_gengrid_horizontal_set()
1559 * @see elm_gengrid_item_append()
1560 * @see elm_gengrid_item_del()
1561 * @see elm_gengrid_clear()
1566 elm_gengrid_add(Evas_Object *parent)
1571 static Evas_Smart *smart = NULL;
1572 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1574 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1576 ELM_SET_WIDTYPE(widtype, "gengrid");
1577 elm_widget_type_set(obj, "gengrid");
1578 elm_widget_sub_object_add(parent, obj);
1579 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1580 elm_widget_data_set(obj, wd);
1581 elm_widget_del_hook_set(obj, _del_hook);
1582 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1583 elm_widget_theme_hook_set(obj, _theme_hook);
1584 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1585 elm_widget_can_focus_set(obj, EINA_TRUE);
1586 elm_widget_event_hook_set(obj, _event_hook);
1588 wd->scr = elm_smart_scroller_add(e);
1589 elm_smart_scroller_widget_set(wd->scr, obj);
1590 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1592 elm_widget_resize_object_set(obj, wd->scr);
1594 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1595 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1596 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1598 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1603 wd->no_select = EINA_FALSE;
1605 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1606 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1607 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1608 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1610 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1614 static Evas_Smart_Class sc;
1616 evas_object_smart_clipped_smart_set(&_pan_sc);
1618 sc.name = "elm_gengrid_pan";
1619 sc.version = EVAS_SMART_CLASS_VERSION;
1622 sc.resize = _pan_resize;
1623 sc.move = _pan_move;
1624 sc.calculate = _pan_calculate;
1625 smart = evas_smart_class_new(&sc);
1629 wd->pan_smart = evas_object_smart_add(e, smart);
1630 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1634 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1635 _pan_set, _pan_get, _pan_max_get,
1636 _pan_min_get, _pan_child_size_get);
1638 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1643 * Set the size for the item of the Gengrid.
1645 * @param obj The Gengrid object.
1646 * @param w The item's width.
1647 * @param h The item's height;
1649 * @see elm_gengrid_item_size_get()
1654 elm_gengrid_item_size_set(Evas_Object *obj,
1658 ELM_CHECK_WIDTYPE(obj, widtype);
1659 Widget_Data *wd = elm_widget_data_get(obj);
1661 if ((wd->item_width == w) && (wd->item_height == h)) return;
1663 wd->item_height = h;
1664 if (wd->calc_job) ecore_job_del(wd->calc_job);
1665 wd->calc_job = ecore_job_add(_calc_job, wd);
1669 * Get the size of the item of the Gengrid.
1671 * @param obj The Gengrid object.
1672 * @param w Pointer to the item's width.
1673 * @param h Pointer to the item's height.
1675 * @see elm_gengrid_item_size_get()
1680 elm_gengrid_item_size_get(const Evas_Object *obj,
1684 ELM_CHECK_WIDTYPE(obj, widtype);
1685 Widget_Data *wd = elm_widget_data_get(obj);
1687 if (w) *w = wd->item_width;
1688 if (h) *h = wd->item_height;
1692 * Set item's alignment within the scroller.
1694 * @param obj The Gengrid object.
1695 * @param align_x The x alignment (0 <= x <= 1).
1696 * @param align_y The y alignment (0 <= y <= 1).
1698 * @see elm_gengrid_align_get()
1703 elm_gengrid_align_set(Evas_Object *obj,
1707 ELM_CHECK_WIDTYPE(obj, widtype);
1708 Widget_Data *wd = elm_widget_data_get(obj);
1712 else if (align_x < 0.0)
1714 wd->align_x = align_x;
1718 else if (align_y < 0.0)
1720 wd->align_y = align_y;
1724 * Get the alignenment set for the Gengrid object.
1726 * @param obj The Gengrid object.
1727 * @param align_x Pointer to x alignenment.
1728 * @param align_y Pointer to y alignenment.
1730 * @see elm_gengrid_align_set()
1735 elm_gengrid_align_get(const Evas_Object *obj,
1739 ELM_CHECK_WIDTYPE(obj, widtype);
1740 Widget_Data *wd = elm_widget_data_get(obj);
1741 if (align_x) *align_x = wd->align_x;
1742 if (align_y) *align_y = wd->align_y;
1746 * Add item to the end of the Gengrid.
1748 * @param obj The Gengrid object.
1749 * @param gic The item class for the item.
1750 * @param data The item data.
1751 * @param func Convenience function called when item is selected.
1752 * @param func_data Data passed to @p func above.
1753 * @return A handle to the item added or NULL if not possible.
1755 * @see elm_gengrid_item_prepend()
1756 * @see elm_gengrid_item_insert_before()
1757 * @see elm_gengrid_item_insert_after()
1758 * @see elm_gengrid_item_del()
1762 EAPI Elm_Gengrid_Item *
1763 elm_gengrid_item_append(Evas_Object *obj,
1764 const Elm_Gengrid_Item_Class *gic,
1767 const void *func_data)
1769 Elm_Gengrid_Item *item;
1770 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1771 Widget_Data *wd = elm_widget_data_get(obj);
1772 if (!wd) return NULL;
1774 item = _item_create(wd, gic, data, func, func_data);
1775 if (!item) return NULL;
1776 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
1778 if (wd->calc_job) ecore_job_del(wd->calc_job);
1779 wd->calc_job = ecore_job_add(_calc_job, wd);
1785 * Add item at start of the Gengrid.
1787 * This adds an item to the beginning of the grid.
1789 * @param obj The Gengrid object.
1790 * @param gic The item class for the item.
1791 * @param data The item data.
1792 * @param func Convenience function called when item is selected.
1793 * @param func_data Data passed to @p func above.
1794 * @return A handle to the item added or NULL if not possible.
1796 * @see elm_gengrid_item_append()
1797 * @see elm_gengrid_item_insert_before()
1798 * @see elm_gengrid_item_insert_after()
1799 * @see elm_gengrid_item_del()
1803 EAPI Elm_Gengrid_Item *
1804 elm_gengrid_item_prepend(Evas_Object *obj,
1805 const Elm_Gengrid_Item_Class *gic,
1808 const void *func_data)
1810 Elm_Gengrid_Item *item;
1811 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1812 Widget_Data *wd = elm_widget_data_get(obj);
1813 if (!wd) return NULL;
1815 item = _item_create(wd, gic, data, func, func_data);
1816 if (!item) return NULL;
1817 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
1819 if (wd->calc_job) ecore_job_del(wd->calc_job);
1820 wd->calc_job = ecore_job_add(_calc_job, wd);
1826 * Insert and item before another in the Gengrid.
1828 * This inserts an item before another in the grid.
1830 * @param obj The Gengrid object.
1831 * @param gic The item class for the item.
1832 * @param data The item data.
1833 * @param relative The item to which insert before.
1834 * @param func Convenience function called when item is selected.
1835 * @param func_data Data passed to @p func above.
1836 * @return A handle to the item added or NULL if not possible.
1838 * @see elm_gengrid_item_append()
1839 * @see elm_gengrid_item_prepend()
1840 * @see elm_gengrid_item_insert_after()
1841 * @see elm_gengrid_item_del()
1845 EAPI Elm_Gengrid_Item *
1846 elm_gengrid_item_insert_before(Evas_Object *obj,
1847 const Elm_Gengrid_Item_Class *gic,
1849 Elm_Gengrid_Item *relative,
1851 const void *func_data)
1853 Elm_Gengrid_Item *item;
1854 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1855 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1856 Widget_Data *wd = elm_widget_data_get(obj);
1857 if (!wd) return NULL;
1859 item = _item_create(wd, gic, data, func, func_data);
1860 if (!item) return NULL;
1861 wd->items = eina_inlist_prepend_relative
1862 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1864 if (wd->calc_job) ecore_job_del(wd->calc_job);
1865 wd->calc_job = ecore_job_add(_calc_job, wd);
1871 * Insert and item after another in the Gengrid.
1873 * This inserts an item after another in the grid.
1875 * @param obj The Gengrid object.
1876 * @param gic The item class for the item.
1877 * @param data The item data.
1878 * @param relative The item to which insert after.
1879 * @param func Convenience function called when item is selected.
1880 * @param func_data Data passed to @p func above.
1881 * @return A handle to the item added or NULL if not possible.
1883 * @see elm_gengrid_item_append()
1884 * @see elm_gengrid_item_prepend()
1885 * @see elm_gengrid_item_insert_before()
1886 * @see elm_gengrid_item_del()
1890 EAPI Elm_Gengrid_Item *
1891 elm_gengrid_item_insert_after(Evas_Object *obj,
1892 const Elm_Gengrid_Item_Class *gic,
1894 Elm_Gengrid_Item *relative,
1896 const void *func_data)
1898 Elm_Gengrid_Item *item;
1899 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1900 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1901 Widget_Data *wd = elm_widget_data_get(obj);
1902 if (!wd) return NULL;
1904 item = _item_create(wd, gic, data, func, func_data);
1905 if (!item) return NULL;
1906 wd->items = eina_inlist_append_relative
1907 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1909 if (wd->calc_job) ecore_job_del(wd->calc_job);
1910 wd->calc_job = ecore_job_add(_calc_job, wd);
1916 * Remove an item from the Gengrid.
1918 * @param item The item to be removed.
1919 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise.
1921 * @see elm_gengrid_clear() to remove all items of the Gengrid.
1926 elm_gengrid_item_del(Elm_Gengrid_Item *item)
1928 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1929 if ((item->relcount > 0) || (item->walking > 0))
1931 item->delete_me = EINA_TRUE;
1932 elm_widget_item_pre_notify_del(item);
1934 item->wd->selected = eina_list_remove(item->wd->selected, item);
1935 if (item->gic->func.del)
1936 item->gic->func.del((void *)item->base.data, item->wd->self);
1944 * Set for what direction the Gengrid will expand.
1946 * @param obj The Gengrid object.
1947 * @param setting If @c EINA_TRUE the Gengrid will expand horizontally
1948 * or vertically if @c EINA_FALSE.
1953 elm_gengrid_horizontal_set(Evas_Object *obj,
1956 ELM_CHECK_WIDTYPE(obj, widtype);
1957 Widget_Data *wd = elm_widget_data_get(obj);
1959 if (setting == wd->horizontal) return;
1960 wd->horizontal = setting;
1962 /* Update the items to conform to the new layout */
1963 if (wd->calc_job) ecore_job_del(wd->calc_job);
1964 wd->calc_job = ecore_job_add(_calc_job, wd);
1968 * Get for what direction the Gengrid is expanded.
1970 * @param obj The Gengrid object.
1971 * @return If the Gengrid is expanded horizontally return @c EINA_TRUE
1972 * else @c EINA_FALSE.
1977 elm_gengrid_horizontal_get(const Evas_Object *obj)
1979 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1980 Widget_Data *wd = elm_widget_data_get(obj);
1981 if (!wd) return EINA_FALSE;
1982 return wd->horizontal;
1988 * This clears all items in the Gengrid, leaving it empty.
1990 * @param obj The Gengrid object.
1992 * @see elm_gengrid_item_del() to remove just one item.
1997 elm_gengrid_clear(Evas_Object *obj)
1999 ELM_CHECK_WIDTYPE(obj, widtype);
2000 Widget_Data *wd = elm_widget_data_get(obj);
2005 ecore_job_del(wd->calc_job);
2006 wd->calc_job = NULL;
2009 if (wd->walking > 0)
2011 Elm_Gengrid_Item *item;
2013 EINA_INLIST_FOREACH(wd->items, item)
2014 item->delete_me = 1;
2020 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2022 wd->items = eina_inlist_remove(wd->items, wd->items);
2023 elm_widget_item_pre_notify_del(item);
2024 if (item->realized) _item_unrealize(item);
2025 if (item->gic->func.del)
2026 item->gic->func.del((void *)item->base.data, wd->self);
2027 if (item->long_timer) ecore_timer_del(item->long_timer);
2028 elm_widget_item_del(item);
2033 eina_list_free(wd->selected);
2034 wd->selected = NULL;
2042 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2043 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2047 * Get the real evas object of the Gengrid item
2049 * This returns the actual evas object used for the specified Gengrid
2050 * item. This may be NULL as it may not be created, and may be
2051 * deleted at any time by Gengrid. Do not modify this object (move,
2052 * resize, show, hide etc.) as Gengrid is controlling it. This
2053 * function is for querying, emitting custom signals or hooking lower
2054 * level callbacks for events. Do not delete this object under any
2057 * @param item The Gengrid item.
2058 * @return the evas object associated to this item.
2060 * @see elm_gengrid_item_data_get()
2064 EAPI const Evas_Object *
2065 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
2067 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2068 return item->base.view;
2072 * Update the contents of an item
2074 * This updates an item by calling all the item class functions again
2075 * to get the icons, labels and states. Use this when the original
2076 * item data has changed and the changes are desired to be reflected.
2078 * @param item The item
2083 elm_gengrid_item_update(Elm_Gengrid_Item *item)
2085 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2086 if (!item->realized) return;
2087 if (item->want_unrealize) return;
2088 _item_unrealize(item);
2089 _item_realize(item);
2090 _item_place(item, item->x, item->y);
2094 * Returns the data associated to an item
2096 * This returns the data value passed on the elm_gengrid_item_append()
2097 * and related item addition calls.
2099 * @param item The Gengrid item.
2100 * @return the data associated to this item.
2102 * @see elm_gengrid_item_append()
2103 * @see elm_gengrid_item_object_get()
2108 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2110 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2111 return elm_widget_item_data_get(item);
2115 * Set the datan item from the gengrid item
2117 * This set the data value passed on the elm_gengrid_item_append() and
2118 * related item addition calls. This function will also call
2119 * elm_gengrid_item_update() so the item will be updated to reflect
2122 * @param item The item
2123 * @param data The new data pointer to set
2128 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2131 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2132 elm_widget_item_data_set(item, data);
2133 elm_gengrid_item_update(item);
2137 * Get the item's coordinates.
2139 * This returns the logical position of the item whithin the Gengrid.
2141 * @param item The Gengrid item.
2142 * @param x The x-axis coordinate pointer.
2143 * @param y The y-axis coordinate pointer.
2148 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2152 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2153 if (x) *x = item->x;
2154 if (y) *y = item->y;
2158 * Enable or disable multi-select in the Gengrid.
2160 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
2161 * the Gengrid. This allows more than 1 item to be selected.
2163 * @param obj The Gengrid object.
2164 * @param multi Multi-select enabled/disabled
2169 elm_gengrid_multi_select_set(Evas_Object *obj,
2172 ELM_CHECK_WIDTYPE(obj, widtype);
2173 Widget_Data *wd = elm_widget_data_get(obj);
2179 * Get if multi-select in Gengrid is enabled or disabled
2181 * @param obj The Gengrid object
2182 * @return Multi-select enable/disable
2183 * (EINA_TRUE = enabled / EINA_FALSE = disabled)
2188 elm_gengrid_multi_select_get(const Evas_Object *obj)
2190 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2191 Widget_Data *wd = elm_widget_data_get(obj);
2192 if (!wd) return EINA_FALSE;
2197 * Get the selected item in the Gengrid
2199 * This gets the selected item in the Gengrid (if multi-select is
2200 * enabled only the first item in the list is selected - which is not
2201 * very useful, so see elm_gengrid_selected_items_get() for when
2202 * multi-select is used).
2204 * If no item is selected, NULL is returned.
2206 * @param obj The Gengrid object.
2207 * @return The selected item, or NULL if none.
2211 EAPI Elm_Gengrid_Item *
2212 elm_gengrid_selected_item_get(const Evas_Object *obj)
2214 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2215 Widget_Data *wd = elm_widget_data_get(obj);
2216 if (!wd) return NULL;
2217 if (wd->selected) return wd->selected->data;
2222 * Get a list of selected items in the Gengrid.
2224 * This returns a list of the selected items. This list pointer is
2225 * only valid so long as no items are selected or unselected (or
2226 * unselected implictly by deletion). The list contains
2227 * Elm_Gengrid_Item pointers.
2229 * @param obj The Gengrid object.
2230 * @return The list of selected items, or NULL if none are selected.
2234 EAPI const Eina_List *
2235 elm_gengrid_selected_items_get(const Evas_Object *obj)
2237 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2238 Widget_Data *wd = elm_widget_data_get(obj);
2239 if (!wd) return NULL;
2240 return wd->selected;
2244 * Set the selected state of an item.
2246 * This sets the selected state of an item. If multi-select is not
2247 * enabled and selected is EINA_TRUE, previously selected items are
2250 * @param item The item
2251 * @param selected The selected state.
2256 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2259 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2260 Widget_Data *wd = item->wd;
2262 if (item->delete_me) return;
2263 selected = !!selected;
2264 if (item->selected == selected) return;
2270 while (wd->selected)
2271 _item_unselect(wd->selected->data);
2273 _item_hilight(item);
2277 _item_unselect(item);
2281 * Get the selected state of an item.
2283 * This gets the selected state of an item (1 selected, 0 not selected).
2285 * @param item The item
2286 * @return The selected state
2291 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2293 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2294 return item->selected;
2298 * Sets the disabled state of an item.
2300 * A disabled item cannot be selected or unselected. It will also
2301 * change appearance to disabled. This sets the disabled state (1
2302 * disabled, 0 not disabled).
2304 * @param item The item
2305 * @param disabled The disabled state
2310 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2313 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2314 if (item->disabled == disabled) return;
2315 if (item->delete_me) return;
2316 item->disabled = !!disabled;
2320 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2322 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2327 * Get the disabled state of an item.
2329 * This gets the disabled state of the given item.
2331 * @param item The item
2332 * @return The disabled state
2337 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2339 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2340 if (item->delete_me) return EINA_FALSE;
2341 return item->disabled;
2344 static Evas_Object *
2345 _elm_gengrid_item_label_create(void *data,
2347 void *item __UNUSED__)
2349 Evas_Object *label = elm_label_add(obj);
2352 elm_object_style_set(label, "tooltip");
2353 elm_label_label_set(label, data);
2358 _elm_gengrid_item_label_del_cb(void *data,
2359 Evas_Object *obj __UNUSED__,
2360 void *event_info __UNUSED__)
2362 eina_stringshare_del(data);
2366 * Set the text to be shown in the gengrid item.
2368 * @param item Target item
2369 * @param text The text to set in the content
2371 * Setup the text as tooltip to object. The item can have only one
2372 * tooltip, so any previous tooltip data is removed.
2377 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2380 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2381 text = eina_stringshare_add(text);
2382 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2384 _elm_gengrid_item_label_del_cb);
2388 * Set the content to be shown in the tooltip item
2390 * Setup the tooltip to item. The item can have only one tooltip, so
2391 * any previous tooltip data is removed. @p func(with @p data) will be
2392 * called every time that need show the tooltip and it should return a
2393 * valid Evas_Object. This object is then managed fully by tooltip
2394 * system and is deleted when the tooltip is gone.
2396 * @param item the gengrid item being attached a tooltip.
2397 * @param func the function used to create the tooltip contents.
2398 * @param data what to provide to @a func as callback data/context.
2399 * @param del_cb called when data is not needed anymore, either when
2400 * another callback replaces @func, the tooltip is unset with
2401 * elm_gengrid_item_tooltip_unset() or the owner @an item
2402 * dies. This callback receives as the first parameter the
2403 * given @a data, and @c event_info is the item.
2408 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2409 Elm_Tooltip_Item_Content_Cb func,
2411 Evas_Smart_Cb del_cb)
2413 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2415 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2418 if (item->tooltip.del_cb)
2419 item->tooltip.del_cb((void *)item->tooltip.data,
2420 item->base.widget, item);
2421 item->tooltip.content_cb = func;
2422 item->tooltip.data = data;
2423 item->tooltip.del_cb = del_cb;
2424 if (item->base.view)
2426 elm_widget_item_tooltip_content_cb_set(item,
2427 item->tooltip.content_cb,
2428 item->tooltip.data, NULL);
2429 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2435 if (del_cb) del_cb((void *)data, NULL, NULL);
2439 * Unset tooltip from item
2441 * @param item gengrid item to remove previously set tooltip.
2443 * Remove tooltip from item. The callback provided as del_cb to
2444 * elm_gengrid_item_tooltip_content_cb_set() will be called to notify
2445 * it is not used anymore.
2447 * @see elm_gengrid_item_tooltip_content_cb_set()
2452 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2454 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2455 if ((item->base.view) && (item->tooltip.content_cb))
2456 elm_widget_item_tooltip_unset(item);
2458 if (item->tooltip.del_cb)
2459 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2460 item->tooltip.del_cb = NULL;
2461 item->tooltip.content_cb = NULL;
2462 item->tooltip.data = NULL;
2463 if (item->tooltip.style)
2464 elm_gengrid_item_tooltip_style_set(item, NULL);
2468 * Sets a different style for this item tooltip.
2470 * @note before you set a style you should define a tooltip with
2471 * elm_gengrid_item_tooltip_content_cb_set() or
2472 * elm_gengrid_item_tooltip_text_set()
2474 * @param item gengrid item with tooltip already set.
2475 * @param style the theme style to use (default, transparent, ...)
2480 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2483 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2484 eina_stringshare_replace(&item->tooltip.style, style);
2485 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2489 * Get the style for this item tooltip.
2491 * @param item gengrid item with tooltip already set.
2492 * @return style the theme style in use, defaults to "default". If the
2493 * object does not have a tooltip set, then NULL is returned.
2498 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2500 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2501 return item->tooltip.style;
2505 * Set the cursor to be shown when mouse is over the gengrid item
2507 * @param item Target item
2508 * @param cursor the cursor name to be used.
2510 * @see elm_object_cursor_set()
2514 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2517 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2518 eina_stringshare_replace(&item->mouse_cursor, cursor);
2519 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2523 * Get the cursor to be shown when mouse is over the gengrid item
2525 * @param item gengrid item with cursor already set.
2526 * @return the cursor name.
2531 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2533 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2534 return elm_widget_item_cursor_get(item);
2538 * Unset the cursor to be shown when mouse is over the gengrid item
2540 * @param item Target item
2542 * @see elm_object_cursor_unset()
2546 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2548 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2549 if (!item->mouse_cursor)
2552 if (item->base.view)
2553 elm_widget_item_cursor_unset(item);
2555 eina_stringshare_del(item->mouse_cursor);
2556 item->mouse_cursor = NULL;
2560 * Sets a different style for this item cursor.
2562 * @note before you set a style you should define a cursor with
2563 * elm_gengrid_item_cursor_set()
2565 * @param item gengrid item with cursor already set.
2566 * @param style the theme style to use (default, transparent, ...)
2571 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2574 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2575 elm_widget_item_cursor_style_set(item, style);
2579 * Get the style for this item cursor.
2581 * @param item gengrid item with cursor already set.
2582 * @return style the theme style in use, defaults to "default". If the
2583 * object does not have a cursor set, then NULL is returned.
2588 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2590 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2591 return elm_widget_item_cursor_style_get(item);
2595 * Set if the cursor set should be searched on the theme or should use
2596 * the provided by the engine, only.
2598 * @note before you set if should look on theme you should define a
2599 * cursor with elm_object_cursor_set(). By default it will only look
2600 * for cursors provided by the engine.
2602 * @param item widget item with cursor already set.
2603 * @param engine_only boolean to define it cursors should be looked
2604 * only between the provided by the engine or searched on widget's
2610 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2611 Eina_Bool engine_only)
2613 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2614 elm_widget_item_cursor_engine_only_set(item, engine_only);
2618 * Get the cursor engine only usage for this item cursor.
2620 * @param item widget item with cursor already set.
2621 * @return engine_only boolean to define it cursors should be looked
2622 * only between the provided by the engine or searched on widget's
2623 * theme as well. If the object does not have a cursor set, then
2624 * EINA_FALSE is returned.
2629 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2631 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2632 return elm_widget_item_cursor_engine_only_get(item);
2636 * Set the always select mode.
2638 * Cells will only call their selection func and callback when first
2639 * becoming selected. Any further clicks will do nothing, unless you
2640 * enable always select with
2641 * elm_gengrid_always_select_mode_set(). This means even if selected,
2642 * every click will make the selected callbacks be called.
2644 * @param obj The Gengrid object
2645 * @param always_select The always select mode (EINA_TRUE = on,
2651 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2652 Eina_Bool always_select)
2654 ELM_CHECK_WIDTYPE(obj, widtype);
2655 Widget_Data *wd = elm_widget_data_get(obj);
2657 wd->always_select = always_select;
2661 * Get the always select mode.
2663 * @param obj The Gengrid object.
2664 * @return The always select mode (EINA_TRUE = on, EINA_FALSE = off)
2669 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2671 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2672 Widget_Data *wd = elm_widget_data_get(obj);
2673 if (!wd) return EINA_FALSE;
2674 return wd->always_select;
2678 * Set no select mode.
2680 * This will turn off the ability to select items entirely and they
2681 * will neither appear selected nor call selected callback functions.
2683 * @param obj The Gengrid object
2684 * @param no_select The no select mode (EINA_TRUE = on, EINA_FALSE = off)
2689 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2690 Eina_Bool no_select)
2692 ELM_CHECK_WIDTYPE(obj, widtype);
2693 Widget_Data *wd = elm_widget_data_get(obj);
2695 wd->no_select = no_select;
2699 * Gets no select mode.
2701 * @param obj The Gengrid object
2702 * @return The no select mode (EINA_TRUE = on, EINA_FALSE = off)
2707 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2709 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2710 Widget_Data *wd = elm_widget_data_get(obj);
2711 if (!wd) return EINA_FALSE;
2712 return wd->no_select;
2718 * This will enable or disable the scroller bounce mode for the
2719 * Gengrid. See elm_scroller_bounce_set() for details.
2721 * @param obj The Gengrid object
2722 * @param h_bounce Allow bounce horizontally
2723 * @param v_bounce Allow bounce vertically
2728 elm_gengrid_bounce_set(Evas_Object *obj,
2732 ELM_CHECK_WIDTYPE(obj, widtype);
2733 Widget_Data *wd = elm_widget_data_get(obj);
2735 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2739 * Get the bounce mode
2741 * @param obj The Gengrid object
2742 * @param h_bounce Allow bounce horizontally
2743 * @param v_bounce Allow bounce vertically
2748 elm_gengrid_bounce_get(const Evas_Object *obj,
2749 Eina_Bool *h_bounce,
2750 Eina_Bool *v_bounce)
2752 ELM_CHECK_WIDTYPE(obj, widtype);
2753 Widget_Data *wd = elm_widget_data_get(obj);
2755 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
2759 * Get all items in the Gengrid.
2761 * This returns a list of the Gengrid items. The list contains
2762 * Elm_Gengrid_Item pointers.
2764 * @param obj The Gengrid object.
2765 * @return The list of items, or NULL if none.
2771 * Set gengrid scroll page size relative to viewport size.
2773 * The gengrid scroller is capable of limiting scrolling by the user
2774 * to "pages" That is to jump by and only show a "whole page" at a
2775 * time as if the continuous area of the scroller content is split
2776 * into page sized pieces. This sets the size of a page relative to
2777 * the viewport of the scroller. 1.0 is "1 viewport" is size
2778 * (horizontally or vertically). 0.0 turns it off in that axis. This
2779 * is mutually exclusive with page size (see
2780 * elm_gengrid_page_size_set() for more information). Likewise 0.5 is
2781 * "half a viewport". Sane usable valus are normally between 0.0 and
2782 * 1.0 including 1.0. If you only want 1 axis to be page "limited",
2783 * use 0.0 for the other axis.
2785 * @param obj The gengrid object
2786 * @param h_pagerel The horizontal page relative size
2787 * @param v_pagerel The vertical page relative size
2792 elm_gengrid_page_relative_set(Evas_Object *obj,
2796 Evas_Coord pagesize_h;
2797 Evas_Coord pagesize_v;
2799 ELM_CHECK_WIDTYPE(obj, widtype);
2800 Widget_Data *wd = elm_widget_data_get(obj);
2803 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
2804 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
2809 * Get gengrid scroll page size relative to viewport size.
2811 * The gengrid scroller is capable of limiting scrolling by the user
2812 * to "pages" That is to jump by and only show a "whole page" at a
2813 * time as if the continuous area of the scroller content is split
2814 * into page sized pieces. This sets the size of a page relative to
2815 * the viewport of the scroller. 1.0 is "1 viewport" is size
2816 * (horizontally or vertically). 0.0 turns it off in that axis. This
2817 * is mutually exclusive with page size (see
2818 * elm_gengrid_page_size_set() for more information). Likewise 0.5 is
2819 * "half a viewport". Sane usable valus are normally between 0.0 and
2820 * 1.0 including 1.0. If you only want 1 axis to be page "limited",
2821 * use 0.0 for the other axis.
2823 * @param obj The gengrid object
2824 * @param h_pagerel The horizontal page relative size
2825 * @param v_pagerel The vertical page relative size
2830 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2832 ELM_CHECK_WIDTYPE(obj, widtype);
2833 Widget_Data *wd = elm_widget_data_get(obj);
2836 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
2840 * Set gengrid scroll page size.
2842 * See also elm_gengrid_page_relative_set(). This, instead of a page
2843 * size being relative to the viewport, sets it to an absolute fixed
2844 * value, with 0 turning it off for that axis.
2846 * @param obj The gengrid object
2847 * @param h_pagesize The horizontal page size
2848 * @param v_pagesize The vertical page size
2853 elm_gengrid_page_size_set(Evas_Object *obj,
2854 Evas_Coord h_pagesize,
2855 Evas_Coord v_pagesize)
2860 ELM_CHECK_WIDTYPE(obj, widtype);
2861 Widget_Data *wd = elm_widget_data_get(obj);
2863 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
2864 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
2869 * Get the first item in the gengrid
2871 * This returns the first item in the list.
2873 * @param obj The gengrid object
2874 * @return The first item, or NULL if none
2878 EAPI Elm_Gengrid_Item *
2879 elm_gengrid_first_item_get(const Evas_Object *obj)
2881 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2882 Widget_Data *wd = elm_widget_data_get(obj);
2883 if (!wd) return NULL;
2884 if (!wd->items) return NULL;
2885 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2886 while ((item) && (item->delete_me))
2887 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2892 * Get the last item in the gengrid
2894 * This returns the last item in the list.
2896 * @return The last item, or NULL if none
2900 EAPI Elm_Gengrid_Item *
2901 elm_gengrid_last_item_get(const Evas_Object *obj)
2903 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2904 Widget_Data *wd = elm_widget_data_get(obj);
2905 if (!wd) return NULL;
2906 if (!wd->items) return NULL;
2907 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
2908 while ((item) && (item->delete_me))
2909 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2914 * Get the next item in the gengrid
2916 * This returns the item after the item @p item.
2918 * @param item The item
2919 * @return The item after @p item, or NULL if none
2923 EAPI Elm_Gengrid_Item *
2924 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
2926 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2929 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2930 if ((item) && (!item->delete_me)) break;
2932 return (Elm_Gengrid_Item *)item;
2936 * Get the previous item in the gengrid
2938 * This returns the item before the item @p item.
2940 * @param item The item
2941 * @return The item before @p item, or NULL if none
2945 EAPI Elm_Gengrid_Item *
2946 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
2948 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2951 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2952 if ((item) && (!item->delete_me)) break;
2954 return (Elm_Gengrid_Item *)item;
2958 * Get the gengrid object from an item
2960 * This returns the gengrid object itself that an item belongs to.
2962 * @param item The item
2963 * @return The gengrid object
2968 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
2970 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2971 return item->base.widget;
2975 * Show the given item
2977 * This causes gengrid to jump to the given item @p item and show it
2978 * (by scrolling), if it is not fully visible.
2980 * @param item The item
2985 elm_gengrid_item_show(Elm_Gengrid_Item *item)
2987 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2988 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2989 Evas_Coord minx = 0, miny = 0;
2992 if ((!item) || (item->delete_me)) return;
2993 _pan_min_get(wd->pan_smart, &minx, &miny);
2995 elm_smart_scroller_child_region_show(item->wd->scr,
2996 item->x * wd->item_width + minx,
2997 item->y * wd->item_height + miny,
2998 item->wd->item_width,
2999 item->wd->item_height);
3003 * Bring in the given item
3005 * This causes gengrig to jump to the given item @p item and show it
3006 * (by scrolling), if it is not fully visible. This may use animation
3007 * to do so and take a period of time
3009 * @param item The item
3014 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
3016 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
3017 if (item->delete_me) return;
3019 Evas_Coord minx = 0, miny = 0;
3020 Widget_Data *wd = elm_widget_data_get(item->wd->self);
3022 _pan_min_get(wd->pan_smart, &minx, &miny);
3024 elm_smart_scroller_region_bring_in(item->wd->scr,
3025 item->x * wd->item_width + minx,
3026 item->y * wd->item_height + miny,
3027 item->wd->item_width,
3028 item->wd->item_height);