1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 * @defgroup Gengrid Gengrid
8 * This widget aims to position objects in a grid layout while
9 * actually building only the visible ones, using the same idea as
10 * genlist: the user define a class for each item, specifying
11 * functions that will be called at object creation and deletion.
13 * A item in the Gengrid can have 0 or more text labels (they can be
14 * regular text or textblock - that's up to the style to determine), 0
15 * or more icons (which are simply objects swallowed into the Gengrid
16 * item) and 0 or more boolean states that can be used for check,
17 * radio or other indicators by the edje theme style. A item may be
18 * one of several styles (Elementary provides 1 by default -
19 * "default", but this can be extended by system or application custom
20 * themes/overlays/extensions).
22 * In order to implement the ability to add and delete items on the
23 * fly, Gengrid implements a class/callback system where the
24 * application provides a structure with information about that type
25 * of item (Gengrid may contain multiple different items with
26 * different classes, states and styles). Gengrid will call the
27 * functions in this struct (methods) when an item is "realized" (that
28 * is created dynamically while scrolling). All objects will simply be
29 * deleted when no longer needed with evas_object_del(). The
30 * Elm_GenGrid_Item_Class structure contains the following members:
32 * item_style - This is a constant string and simply defines the name
33 * of the item style. It must be specified and the default should be
36 * func.label_get - This function is called when an actual item object
37 * is created. The data parameter is the one passed to
38 * elm_gengrid_item_append() and related item creation functions. The
39 * obj parameter is the Gengrid object and the part parameter is the
40 * string name of the text part in the edje design that is listed as
41 * one of the possible labels that can be set. This function must
42 * return a strdup'()ed string as the caller will free() it when done.
44 * func.icon_get - This function is called when an actual item object
45 * is created. The data parameter is the one passed to
46 * elm_gengrid_item_append() and related item creation functions. The
47 * obj parameter is the Gengrid object and the part parameter is the
48 * string name of the icon part in the edje design that is listed as
49 * one of the possible icons that can be set. This must return NULL
50 * for no object or a valid object. The object will be deleted by
51 * Gengrid on shutdown or when the item is unrealized.
53 * func.state_get - This function is called when an actual item object
54 * is created. The data parameter is the one passed to
55 * elm_gengrid_item_append() and related item creation functions. The
56 * obj parameter is the Gengrid object and the part parameter is the
57 * string name of th state part in the edje design that is listed as
58 * one of the possible states that can be set. Return 0 for false and
59 * 1 for true. Gengrid will emit a signal to the edje object with
60 * "elm,state,XXX,active" "elm" when true (the default is false),
61 * where XXX is the name of the part.
63 * func.del - This is called when elm_gengrid_item_del() is called on
64 * an item or elm_gengrid_clear() is called on the Gengrid. This is
65 * intended for use when actual Gengrid items are deleted, so any
66 * backing data attached to the item (e.g. its data parameter on
67 * creation) can be deleted.
69 * If the application wants multiple items to be able to be selected,
70 * elm_gengrid_multi_select_set() can enable this. If the Gengrid is
71 * single-selection only (the default), then
72 * elm_gengrid_select_item_get() will return the selected item, if
73 * any, or NULL if none is selected. If the Gengrid is multi-select
74 * then elm_gengrid_selected_items_get() will return a list (that is
75 * only valid as long as no items are modified (added, deleted,
76 * selected or unselected).
78 * If an item changes (state of boolean changes, label or icons
79 * change), then use elm_gengrid_item_update() to have Gengrid update
80 * the item with the new state. Gengrid will re-realize the item thus
81 * call the functions in the _Elm_Gengrid_Item_Class for that item.
83 * To programmatically (un)select an item use
84 * elm_gengrid_item_selected_set(). To get its selected state use
85 * elm_gengrid_item_selected_get(). To make an item disabled (unable to
86 * be selected and appear differently) use
87 * elm_gengrid_item_disabled_set() to set this and
88 * elm_gengrid_item_disabled_get() to get the disabled state.
90 * Cells will only call their selection func and callback when first
91 * becoming selected. Any further clicks will do nothing, unless you
92 * enable always select with
93 * elm_gengrid_always_select_mode_set(). This means event if selected,
94 * every click will make the selected callbacks be called.
95 * elm_gengrid_no_select_mode_set() will turn off the ability to
96 * select items entirely and they will neither appear selected nor
97 * call selected callback function.
99 * Remember that you can create new styles and add your own theme
100 * augmentation per application with elm_theme_extension_add(). If you
101 * absolutely must have a specific style that overrides any theme the
102 * user or system sets up you can use elm_theme_overlay_add() to add
105 * Signals that you can add callbacks for are:
107 * "clicked,double" - The user has double-clicked or pressed enter on
108 * an item. The event_infoparameter is the Gengrid item
109 * that was double-clicked.
110 * "selected" - The user has made an item selected. The event_info
111 * parameter is the Gengrid item that was selected.
112 * "unselected" - The user has made an item unselected. The event_info
113 * parameter is the Gengrid item that was unselected.
114 * "realized" - This is called when the item in the Gengrid is created
115 * as a real evas object. event_info is the Gengrid item that was
116 * created. The object may be deleted at any time, so it is up to
117 * the caller to not use the object pointer from
118 * elm_gengrid_item_object_get() in a way where it may point to
120 * "unrealized" - This is called when the real evas object for this item
121 * is deleted. event_info is the Gengrid item that was created.
122 * "changed" - Called when an item is added, removed, resized or moved
123 * and when gengrid is resized or horizontal property changes.
124 * "drag,start,up" - Called when the item in the Gengrid has been
125 * dragged (not scrolled) up.
126 * "drag,start,down" - Called when the item in the Gengrid has been
127 * dragged (not scrolled) down.
128 * "drag,start,left" - Called when the item in the Gengrid has been
129 * dragged (not scrolled) left.
130 * "drag,start,right" - Called when the item in the Gengrid has been
131 * dragged (not scrolled) right.
132 * "drag,stop" - Called when the item in the Gengrid has stopped being
134 * "drag" - Called when the item in the Gengrid is being dragged.
135 * "scroll" - called when the content has been scrolled (moved).
136 * "scroll,drag,start" - called when dragging the content has started.
137 * "scroll,drag,stop" - called when dragging the content has stopped.
141 * Handle non-homogeneous objects too.
144 typedef struct _Widget_Data Widget_Data;
145 typedef struct _Pan Pan;
148 #define REORDER_EFFECT_TIME 0.5
150 struct _Elm_Gengrid_Item
152 Elm_Widget_Item base;
155 const Elm_Gengrid_Item_Class *gic;
156 Ecore_Timer *long_timer;
157 Ecore_Animator *item_moving_effect_timer;
159 Eina_List *labels, *icons, *states, *icon_objs;
166 Evas_Coord x, y, dx, dy, ox, oy, tx, ty, rx, ry;
167 unsigned int moving_effect_start_time;
174 Elm_Tooltip_Item_Content_Cb content_cb;
175 Evas_Smart_Cb del_cb;
179 const char *mouse_cursor;
181 Eina_Bool want_unrealize : 1;
182 Eina_Bool realized : 1;
183 Eina_Bool dragging : 1;
185 Eina_Bool delete_me : 1;
186 Eina_Bool display_only : 1;
187 Eina_Bool disabled : 1;
188 Eina_Bool selected : 1;
189 Eina_Bool hilighted : 1;
190 Eina_Bool moving : 1;
195 Evas_Object *self, *scr;
196 Evas_Object *pan_smart;
201 Elm_Gengrid_Item *last_selected_item, *reorder_item;
202 double align_x, align_y;
204 Evas_Coord pan_x, pan_y, old_pan_x, old_pan_y;
205 Evas_Coord item_width, item_height; /* Each item size */
206 Evas_Coord minw, minh; /* Total obj size */
207 Evas_Coord reorder_item_x, reorder_item_y;
212 Eina_Bool horizontal : 1;
213 Eina_Bool on_hold : 1;
214 Eina_Bool longpressed : 1;
216 Eina_Bool no_select : 1;
217 Eina_Bool wasselected : 1;
218 Eina_Bool always_select : 1;
219 Eina_Bool clear_me : 1;
220 Eina_Bool h_bounce : 1;
221 Eina_Bool v_bounce : 1;
222 Eina_Bool reorder_mode : 1;
223 Eina_Bool reorder_item_changed : 1;
224 Eina_Bool move_effect_enabled : 1;
227 #define ELM_GENGRID_ITEM_FROM_INLIST(item) \
228 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
232 Evas_Object_Smart_Clipped_Data __clipped_data;
236 static const char *widtype = NULL;
237 static void _item_hilight(Elm_Gengrid_Item *item);
238 static void _item_unrealize(Elm_Gengrid_Item *item);
239 static void _item_select(Elm_Gengrid_Item *item);
240 static void _item_unselect(Elm_Gengrid_Item *item);
241 static void _calc_job(void *data);
242 static void _on_focus_hook(void *data,
244 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
245 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
246 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
247 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
248 static Eina_Bool _item_single_select_up(Widget_Data *wd);
249 static Eina_Bool _item_single_select_down(Widget_Data *wd);
250 static Eina_Bool _item_single_select_left(Widget_Data *wd);
251 static Eina_Bool _item_single_select_right(Widget_Data *wd);
252 static Eina_Bool _event_hook(Evas_Object *obj,
254 Evas_Callback_Type type,
256 static Eina_Bool _deselect_all_items(Widget_Data *wd);
258 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
259 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
261 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
262 static const char SIG_SELECTED[] = "selected";
263 static const char SIG_UNSELECTED[] = "unselected";
264 static const char SIG_REALIZED[] = "realized";
265 static const char SIG_UNREALIZED[] = "unrealized";
266 static const char SIG_CHANGED[] = "changed";
267 static const char SIG_DRAG_START_UP[] = "drag,start,up";
268 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
269 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
270 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
271 static const char SIG_DRAG_STOP[] = "drag,stop";
272 static const char SIG_DRAG[] = "drag";
273 static const char SIG_SCROLL[] = "scroll";
274 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
275 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
276 static const char SIG_MOVED[] = "moved";
278 static const Evas_Smart_Cb_Description _signals[] = {
279 {SIG_CLICKED_DOUBLE, ""},
281 {SIG_UNSELECTED, ""},
283 {SIG_UNREALIZED, ""},
285 {SIG_DRAG_START_UP, ""},
286 {SIG_DRAG_START_DOWN, ""},
287 {SIG_DRAG_START_LEFT, ""},
288 {SIG_DRAG_START_RIGHT, ""},
292 {SIG_SCROLL_DRAG_START, ""},
293 {SIG_SCROLL_DRAG_STOP, ""},
298 static Eina_Compare_Cb _elm_gengrid_item_compare_cb;
299 static Eina_Compare_Cb _elm_gengrid_item_compare_data_cb;
302 _event_hook(Evas_Object *obj,
303 Evas_Object *src __UNUSED__,
304 Evas_Callback_Type type,
307 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
308 Evas_Event_Key_Down *ev = event_info;
309 Widget_Data *wd = elm_widget_data_get(obj);
310 if (!wd) return EINA_FALSE;
311 if (!wd->items) return EINA_FALSE;
312 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
313 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
315 Elm_Gengrid_Item *item = NULL;
318 Evas_Coord step_x = 0;
319 Evas_Coord step_y = 0;
322 Evas_Coord page_x = 0;
323 Evas_Coord page_y = 0;
325 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
326 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
327 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
328 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
330 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
332 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;
340 else if ((!wd->horizontal) &&
341 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
342 (_item_multi_select_left(wd)))
343 || (_item_single_select_left(wd))))
345 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
351 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
353 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;
361 else if ((!wd->horizontal) &&
362 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
363 (_item_multi_select_right(wd)))
364 || (_item_single_select_right(wd))))
366 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
372 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
374 if ((wd->horizontal) &&
375 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
376 (_item_multi_select_left(wd)))
377 || (_item_single_select_left(wd))))
379 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
382 else if ((!wd->horizontal) &&
383 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
384 (_item_multi_select_up(wd)))
385 || (_item_single_select_up(wd))))
387 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
393 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
395 if ((wd->horizontal) &&
396 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
397 (_item_multi_select_right(wd)))
398 || (_item_single_select_right(wd))))
400 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
403 else if ((!wd->horizontal) &&
404 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
405 (_item_multi_select_down(wd)))
406 || (_item_single_select_down(wd))))
408 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
414 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
416 item = elm_gengrid_first_item_get(obj);
417 elm_gengrid_item_bring_in(item);
418 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
421 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
423 item = elm_gengrid_last_item_get(obj);
424 elm_gengrid_item_bring_in(item);
425 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
428 else if ((!strcmp(ev->keyname, "Prior")) ||
429 (!strcmp(ev->keyname, "KP_Prior")))
434 x -= -(page_x * v_w) / 100;
441 y -= -(page_y * v_h) / 100;
446 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
451 x += -(page_x * v_w) / 100;
458 y += -(page_y * v_h) / 100;
463 else if (!strcmp(ev->keyname, "Escape"))
465 if (!_deselect_all_items(wd)) return EINA_FALSE;
466 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
469 else if ((!strcmp(ev->keyname, "Return")) ||
470 (!strcmp(ev->keyname, "KP_Enter")) ||
471 (!strcmp(ev->keyname, "space")))
473 item = elm_gengrid_selected_item_get(obj);
474 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
476 else return EINA_FALSE;
478 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
479 elm_smart_scroller_child_pos_set(wd->scr, x, y);
484 _deselect_all_items(Widget_Data *wd)
486 if (!wd->selected) return EINA_FALSE;
488 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
494 _item_multi_select_left(Widget_Data *wd)
496 if (!wd->selected) return EINA_FALSE;
498 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
499 if (!prev) return EINA_TRUE;
500 if (elm_gengrid_item_selected_get(prev))
502 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
503 wd->last_selected_item = prev;
504 elm_gengrid_item_show(wd->last_selected_item);
508 elm_gengrid_item_selected_set(prev, EINA_TRUE);
509 elm_gengrid_item_show(prev);
516 _item_multi_select_right(Widget_Data *wd)
518 if (!wd->selected) return EINA_FALSE;
520 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
521 if (!next) return EINA_TRUE;
522 if (elm_gengrid_item_selected_get(next))
524 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
525 wd->last_selected_item = next;
526 elm_gengrid_item_show(wd->last_selected_item);
530 elm_gengrid_item_selected_set(next, EINA_TRUE);
531 elm_gengrid_item_show(next);
538 _item_multi_select_up(Widget_Data *wd)
541 Eina_Bool r = EINA_TRUE;
543 if (!wd->selected) return EINA_FALSE;
545 for (i = 0; (r) && (i < wd->nmax); i++)
546 r &= _item_multi_select_left(wd);
552 _item_multi_select_down(Widget_Data *wd)
555 Eina_Bool r = EINA_TRUE;
557 if (!wd->selected) return EINA_FALSE;
559 for (i = 0; (r) && (i < wd->nmax); i++)
560 r &= _item_multi_select_right(wd);
566 _item_single_select_up(Widget_Data *wd)
570 Elm_Gengrid_Item *prev;
574 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
575 while ((prev) && (prev->delete_me))
576 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
577 elm_gengrid_item_selected_set(prev, EINA_TRUE);
578 elm_gengrid_item_show(prev);
581 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
583 if (!prev) return EINA_FALSE;
585 for (i = 1; i < wd->nmax; i++)
587 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
588 if (!tmp) return EINA_FALSE;
592 _deselect_all_items(wd);
594 elm_gengrid_item_selected_set(prev, EINA_TRUE);
595 elm_gengrid_item_show(prev);
600 _item_single_select_down(Widget_Data *wd)
604 Elm_Gengrid_Item *next;
608 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
609 while ((next) && (next->delete_me))
610 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
611 elm_gengrid_item_selected_set(next, EINA_TRUE);
612 elm_gengrid_item_show(next);
615 else next = elm_gengrid_item_next_get(wd->last_selected_item);
617 if (!next) return EINA_FALSE;
619 for (i = 1; i < wd->nmax; i++)
621 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
622 if (!tmp) return EINA_FALSE;
626 _deselect_all_items(wd);
628 elm_gengrid_item_selected_set(next, EINA_TRUE);
629 elm_gengrid_item_show(next);
634 _item_single_select_left(Widget_Data *wd)
636 Elm_Gengrid_Item *prev;
639 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
640 while ((prev) && (prev->delete_me))
641 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
643 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
645 if (!prev) return EINA_FALSE;
647 _deselect_all_items(wd);
649 elm_gengrid_item_selected_set(prev, EINA_TRUE);
650 elm_gengrid_item_show(prev);
655 _item_single_select_right(Widget_Data *wd)
657 Elm_Gengrid_Item *next;
660 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
661 while ((next) && (next->delete_me))
662 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
664 else next = elm_gengrid_item_next_get(wd->last_selected_item);
666 if (!next) return EINA_FALSE;
668 _deselect_all_items(wd);
670 elm_gengrid_item_selected_set(next, EINA_TRUE);
671 elm_gengrid_item_show(next);
676 _on_focus_hook(void *data __UNUSED__,
679 Widget_Data *wd = elm_widget_data_get(obj);
681 if (elm_widget_focus_get(obj))
683 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
684 evas_object_focus_set(wd->self, EINA_TRUE);
685 if ((wd->selected) && (!wd->last_selected_item))
686 wd->last_selected_item = eina_list_data_get(wd->selected);
690 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
691 evas_object_focus_set(wd->self, EINA_FALSE);
696 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
698 Widget_Data *wd = elm_widget_data_get(obj);
699 Elm_Gengrid_Item *item;
701 elm_smart_scroller_mirrored_set(wd->scr, rtl);
702 if (!wd->items) return;
703 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
707 edje_object_mirrored_set(item->base.view, rtl);
708 elm_gengrid_item_update(item);
709 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
714 _theme_hook(Evas_Object *obj)
716 Widget_Data *wd = elm_widget_data_get(obj);
718 _elm_widget_mirrored_reload(obj);
719 _mirrored_set(obj, elm_widget_mirrored_get(obj));
720 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
721 elm_widget_style_get(obj));
725 _del_pre_hook(Evas_Object *obj)
727 Widget_Data *wd = elm_widget_data_get(obj);
729 elm_gengrid_clear(obj);
730 evas_object_del(wd->pan_smart);
731 wd->pan_smart = NULL;
735 _del_hook(Evas_Object *obj)
737 Widget_Data *wd = elm_widget_data_get(obj);
742 _signal_emit_hook(Evas_Object *obj,
743 const char *emission,
746 Widget_Data *wd = elm_widget_data_get(obj);
748 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
753 _mouse_move(void *data,
754 Evas *evas __UNUSED__,
758 Elm_Gengrid_Item *item = data;
759 Evas_Event_Mouse_Move *ev = event_info;
760 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
761 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
763 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
765 if (!item->wd->on_hold)
767 item->wd->on_hold = EINA_TRUE;
768 if (!item->wd->wasselected)
769 _item_unselect(item);
772 if ((item->dragging) && (item->down))
774 if (item->long_timer)
776 ecore_timer_del(item->long_timer);
777 item->long_timer = NULL;
779 evas_object_smart_callback_call(item->wd->self, SIG_DRAG, item);
782 if ((!item->down) || (item->wd->longpressed))
784 if (item->long_timer)
786 ecore_timer_del(item->long_timer);
787 item->long_timer = NULL;
789 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
791 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &ow, &oh);
793 it_scrl_x = ev->cur.canvas.x - item->wd->reorder_item->dx;
794 it_scrl_y = ev->cur.canvas.y - item->wd->reorder_item->dy;
796 if (it_scrl_x < ox) item->wd->reorder_item_x = ox;
797 else if (it_scrl_x + item->wd->item_width > ox + ow)
798 item->wd->reorder_item_x = ox + ow - item->wd->item_width;
799 else item->wd->reorder_item_x = it_scrl_x;
801 if (it_scrl_y < oy) item->wd->reorder_item_y = oy;
802 else if (it_scrl_y + item->wd->item_height > oy + oh)
803 item->wd->reorder_item_y = oy + oh - item->wd->item_height;
804 else item->wd->reorder_item_y = it_scrl_y;
806 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
807 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
811 if (!item->display_only)
812 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
813 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
814 x = ev->cur.canvas.x - x;
815 y = ev->cur.canvas.y - y;
818 if (adx < 0) adx = -dx;
821 if (ady < 0) ady = -dy;
824 if ((adx > minw) || (ady > minh))
826 const char *left_drag, *right_drag;
827 if (!elm_widget_mirrored_get(item->wd->self))
829 left_drag = SIG_DRAG_START_LEFT;
830 right_drag = SIG_DRAG_START_RIGHT;
834 left_drag = SIG_DRAG_START_RIGHT;
835 right_drag = SIG_DRAG_START_LEFT;
839 if (item->long_timer)
841 ecore_timer_del(item->long_timer);
842 item->long_timer = NULL;
844 if (!item->wd->wasselected)
845 _item_unselect(item);
849 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_START_UP,
854 evas_object_smart_callback_call(item->wd->self,
861 evas_object_smart_callback_call(item->wd->self,
862 SIG_DRAG_START_DOWN, item);
866 evas_object_smart_callback_call(item->wd->self,
869 evas_object_smart_callback_call(item->wd->self,
877 _long_press(void *data)
879 Elm_Gengrid_Item *item = data;
881 item->long_timer = NULL;
882 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
883 item->wd->longpressed = EINA_TRUE;
884 evas_object_smart_callback_call(item->wd->self, "longpressed", item);
885 if (item->wd->reorder_mode)
887 item->wd->reorder_item = item;
888 evas_object_raise(item->base.view);
889 elm_smart_scroller_hold_set(item->wd->scr, EINA_TRUE);
890 elm_smart_scroller_bounce_allow_set(item->wd->scr, EINA_FALSE, EINA_FALSE);
891 edje_object_signal_emit(item->base.view, "elm,state,reorder,enabled", "elm");
893 return ECORE_CALLBACK_CANCEL;
897 _mouse_down(void *data,
898 Evas *evas __UNUSED__,
902 Elm_Gengrid_Item *item = data;
903 Evas_Event_Mouse_Down *ev = event_info;
906 if (ev->button != 1) return;
909 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
910 item->dx = ev->canvas.x - x;
911 item->dy = ev->canvas.y - y;
912 item->wd->longpressed = EINA_FALSE;
913 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
914 else item->wd->on_hold = EINA_FALSE;
915 item->wd->wasselected = item->selected;
917 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
918 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
919 if (item->long_timer) ecore_timer_del(item->long_timer);
921 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
924 item->long_timer = NULL;
928 _mouse_up(void *data,
929 Evas *evas __UNUSED__,
930 Evas_Object *obj __UNUSED__,
933 Elm_Gengrid_Item *item = data;
934 Evas_Event_Mouse_Up *ev = event_info;
935 Eina_Bool dragged = EINA_FALSE;
937 if (ev->button != 1) return;
938 item->down = EINA_FALSE;
939 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
940 else item->wd->on_hold = EINA_FALSE;
941 if (item->long_timer)
943 ecore_timer_del(item->long_timer);
944 item->long_timer = NULL;
948 item->dragging = EINA_FALSE;
949 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_STOP, item);
952 if (item->wd->on_hold)
954 item->wd->longpressed = EINA_FALSE;
955 item->wd->on_hold = EINA_FALSE;
958 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
960 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
961 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
963 evas_object_smart_callback_call(item->wd->self, SIG_MOVED, item->wd->reorder_item);
964 item->wd->reorder_item = NULL;
965 elm_smart_scroller_hold_set(item->wd->scr, EINA_FALSE);
966 elm_smart_scroller_bounce_allow_set(item->wd->scr, item->wd->h_bounce, item->wd->v_bounce);
967 edje_object_signal_emit(item->base.view, "elm,state,reorder,disabled", "elm");
969 if (item->wd->longpressed)
971 item->wd->longpressed = EINA_FALSE;
972 if (!item->wd->wasselected) _item_unselect(item);
973 item->wd->wasselected = EINA_FALSE;
978 if (item->want_unrealize) _item_unrealize(item);
980 if ((item->disabled) || (dragged)) return;
988 else _item_unselect(item);
994 while (item->wd->selected)
995 _item_unselect(item->wd->selected->data);
999 const Eina_List *l, *l_next;
1000 Elm_Gengrid_Item *item2;
1002 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
1003 if (item2 != item) _item_unselect(item2);
1005 _item_hilight(item);
1011 _item_hilight(Elm_Gengrid_Item *item)
1013 if ((item->wd->no_select) || (item->delete_me) || (item->hilighted)) return;
1014 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
1015 item->hilighted = EINA_TRUE;
1019 _item_realize(Elm_Gengrid_Item *item)
1024 if ((item->realized) || (item->delete_me)) return;
1025 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
1026 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
1027 _elm_config->scale);
1028 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
1029 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
1030 elm_widget_sub_object_add(item->wd->self, item->base.view);
1031 snprintf(style, sizeof(style), "item/%s",
1032 item->gic->item_style ? item->gic->item_style : "default");
1033 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
1034 elm_widget_style_get(item->wd->self));
1036 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
1037 evas_object_color_set(item->spacer, 0, 0, 0, 0);
1038 elm_widget_sub_object_add(item->wd->self, item->spacer);
1039 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
1040 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
1042 if (item->gic->func.label_get)
1048 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1050 EINA_LIST_FOREACH(item->labels, l, key)
1052 char *s = item->gic->func.label_get
1053 ((void *)item->base.data, item->wd->self, l->data);
1056 edje_object_part_text_set(item->base.view, l->data, s);
1062 if (item->gic->func.icon_get)
1068 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1070 EINA_LIST_FOREACH(item->icons, l, key)
1072 Evas_Object *ic = item->gic->func.icon_get
1073 ((void *)item->base.data, item->wd->self, l->data);
1076 item->icon_objs = eina_list_append(item->icon_objs, ic);
1077 edje_object_part_swallow(item->base.view, key, ic);
1078 evas_object_show(ic);
1079 elm_widget_sub_object_add(item->wd->self, ic);
1084 if (item->gic->func.state_get)
1090 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
1092 EINA_LIST_FOREACH(item->states, l, key)
1094 Eina_Bool on = item->gic->func.state_get
1095 ((void *)item->base.data, item->wd->self, l->data);
1098 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1099 edje_object_signal_emit(item->base.view, buf, "elm");
1104 if ((!item->wd->item_width) && (!item->wd->item_height))
1106 edje_object_size_min_restricted_calc(item->base.view,
1107 &item->wd->item_width,
1108 &item->wd->item_height,
1109 item->wd->item_width,
1110 item->wd->item_height);
1111 elm_coords_finger_size_adjust(1, &item->wd->item_width,
1112 1, &item->wd->item_height);
1115 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1117 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
1119 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1123 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
1125 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
1127 evas_object_show(item->base.view);
1129 if (item->tooltip.content_cb)
1131 elm_widget_item_tooltip_content_cb_set(item,
1132 item->tooltip.content_cb,
1133 item->tooltip.data, NULL);
1134 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1137 if (item->mouse_cursor)
1138 elm_widget_item_cursor_set(item, item->mouse_cursor);
1140 item->realized = EINA_TRUE;
1141 item->want_unrealize = EINA_FALSE;
1145 _item_unrealize(Elm_Gengrid_Item *item)
1149 if (!item->realized) return;
1150 if (item->long_timer)
1152 ecore_timer_del(item->long_timer);
1153 item->long_timer = NULL;
1155 evas_object_del(item->base.view);
1156 item->base.view = NULL;
1157 evas_object_del(item->spacer);
1158 item->spacer = NULL;
1159 elm_widget_stringlist_free(item->labels);
1160 item->labels = NULL;
1161 elm_widget_stringlist_free(item->icons);
1163 elm_widget_stringlist_free(item->states);
1164 item->states = NULL;
1166 EINA_LIST_FREE(item->icon_objs, icon)
1167 evas_object_del(icon);
1169 item->realized = EINA_FALSE;
1170 item->want_unrealize = EINA_FALSE;
1174 _reorder_item_moving_effect_timer_cb(void *data)
1176 Elm_Gengrid_Item *item = data;
1180 time = REORDER_EFFECT_TIME;
1181 t = ((0.0 > (t = ecore_loop_time_get()-item->moving_effect_start_time)) ? 0.0 : t);
1182 dx = ((item->tx - item->ox) / 10) * _elm_config->scale;
1183 dy = ((item->ty - item->oy) / 10) * _elm_config->scale;
1187 item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
1188 item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
1196 if ((((dx > 0) && (item->rx >= item->tx)) || ((dx <= 0) && (item->rx <= item->tx))) &&
1197 (((dy > 0) && (item->ry >= item->ty)) || ((dy <= 0) && (item->ry <= item->ty))))
1199 evas_object_move(item->base.view, item->tx, item->ty);
1200 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1201 item->moving = EINA_FALSE;
1202 item->item_moving_effect_timer = NULL;
1203 return ECORE_CALLBACK_CANCEL;
1206 evas_object_move(item->base.view, item->rx, item->ry);
1207 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1209 return ECORE_CALLBACK_RENEW;
1213 _item_place(Elm_Gengrid_Item *item,
1217 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh;
1218 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1219 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1222 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1224 /* Preload rows/columns at each side of the Gengrid */
1225 cvx = ox - PRELOAD * item->wd->item_width;
1226 cvy = oy - PRELOAD * item->wd->item_height;
1227 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1228 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1233 if (item->wd->horizontal)
1235 int columns, items_visible = 0, items_row;
1237 if (item->wd->item_height > 0)
1238 items_visible = vh / item->wd->item_height;
1239 if (items_visible < 1)
1242 columns = item->wd->count / items_visible;
1243 if (item->wd->count % items_visible)
1246 tcw = item->wd->item_width * columns;
1247 alignw = (vw - tcw) * item->wd->align_x;
1249 items_row = items_visible;
1250 if (items_row > item->wd->count)
1251 items_row = item->wd->count;
1252 tch = items_row * item->wd->item_height;
1253 alignh = (vh - tch) * item->wd->align_y;
1257 int rows, items_visible = 0, items_col;
1259 if (item->wd->item_width > 0)
1260 items_visible = vw / item->wd->item_width;
1261 if (items_visible < 1)
1264 rows = item->wd->count / items_visible;
1265 if (item->wd->count % items_visible)
1268 tch = item->wd->item_height * rows;
1269 alignh = (vh - tch) * item->wd->align_y;
1271 items_col = items_visible;
1272 if (items_col > item->wd->count)
1273 items_col = item->wd->count;
1274 tcw = items_col * item->wd->item_width;
1275 alignw = (vw - tcw) * item->wd->align_x;
1278 x = cx * item->wd->item_width - item->wd->pan_x + ox + alignw;
1279 if (elm_widget_mirrored_get(item->wd->self))
1280 { /* Switch items side and componsate for pan_x when in RTL mode */
1282 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1283 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1286 y = cy * item->wd->item_height - item->wd->pan_y + oy + alignh;
1288 Eina_Bool was_realized = item->realized;
1289 if (ELM_RECTS_INTERSECT(x, y, item->wd->item_width, item->wd->item_height,
1290 cvx, cvy, cvw, cvh))
1292 _item_realize(item);
1294 evas_object_smart_callback_call(item->wd->self, SIG_REALIZED, item);
1295 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
1297 if (item->moving) return;
1299 if (!item->wd->move_effect_enabled)
1304 if (item->wd->reorder_item == item)
1306 evas_object_move(item->base.view,
1307 item->wd->reorder_item_x, item->wd->reorder_item_y);
1308 evas_object_resize(item->base.view,
1309 item->wd->item_width, item->wd->item_height);
1314 if (item->wd->move_effect_enabled)
1316 if ((item->ox != x) || (item->oy != y))
1318 if (((item->wd->old_pan_x == item->wd->pan_x) && (item->wd->old_pan_y == item->wd->pan_y)) ||
1319 ((item->wd->old_pan_x != item->wd->pan_x) && !(item->ox - item->wd->pan_x + item->wd->old_pan_x == x)) ||
1320 ((item->wd->old_pan_y != item->wd->pan_y) && !(item->oy - item->wd->pan_y + item->wd->old_pan_y == y)))
1324 item->rx = item->ox;
1325 item->ry = item->oy;
1326 item->moving = EINA_TRUE;
1327 item->moving_effect_start_time = ecore_loop_time_get();
1328 item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, item);
1334 if (ELM_RECTS_INTERSECT(item->wd->reorder_item_x, item->wd->reorder_item_y,
1335 item->wd->item_width, item->wd->item_height,
1336 x+(item->wd->item_width/2), y+(item->wd->item_height/2),
1339 if (item->wd->horizontal)
1341 if ((item->wd->nmax * item->wd->reorder_item->x + item->wd->reorder_item->y) >
1342 (item->wd->nmax * item->x + item->y))
1343 reorder_item_move_forward = EINA_TRUE;
1347 if ((item->wd->nmax * item->wd->reorder_item->y + item->wd->reorder_item->x) >
1348 (item->wd->nmax * item->y + item->x))
1349 reorder_item_move_forward = EINA_TRUE;
1352 item->wd->items = eina_inlist_remove(item->wd->items,
1353 EINA_INLIST_GET(item->wd->reorder_item));
1354 if (reorder_item_move_forward)
1355 item->wd->items = eina_inlist_prepend_relative(item->wd->items,
1356 EINA_INLIST_GET(item->wd->reorder_item),
1357 EINA_INLIST_GET(item));
1359 item->wd->items = eina_inlist_append_relative(item->wd->items,
1360 EINA_INLIST_GET(item->wd->reorder_item),
1361 EINA_INLIST_GET(item));
1363 item->wd->reorder_item_changed = EINA_TRUE;
1364 item->wd->move_effect_enabled = EINA_TRUE;
1365 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1366 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1372 evas_object_move(item->base.view, x, y);
1373 evas_object_resize(item->base.view, item->wd->item_width,
1374 item->wd->item_height);
1378 _item_unrealize(item);
1380 evas_object_smart_callback_call(item->wd->self, SIG_UNREALIZED, item);
1384 static Elm_Gengrid_Item *
1385 _item_create(Widget_Data *wd,
1386 const Elm_Gengrid_Item_Class *gic,
1389 const void *func_data)
1391 Elm_Gengrid_Item *item;
1393 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1394 if (!item) return NULL;
1398 item->base.data = data;
1399 item->func.func = func;
1400 item->func.data = func_data;
1401 item->mouse_cursor = NULL;
1406 _item_del(Elm_Gengrid_Item *item)
1408 elm_widget_item_pre_notify_del(item);
1410 item->wd->selected = eina_list_remove(item->wd->selected, item);
1411 if (item->realized) _item_unrealize(item);
1412 if ((!item->delete_me) && (item->gic->func.del))
1413 item->gic->func.del((void *)item->base.data, item->wd->self);
1414 item->delete_me = EINA_TRUE;
1415 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1416 if (item->long_timer) ecore_timer_del(item->long_timer);
1417 if (item->tooltip.del_cb)
1418 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1419 item->wd->walking -= item->walking;
1421 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1422 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1423 elm_widget_item_del(item);
1427 _item_select(Elm_Gengrid_Item *item)
1429 if ((item->wd->no_select) || (item->delete_me)) return;
1432 if (item->wd->always_select) goto call;
1435 item->selected = EINA_TRUE;
1436 item->wd->selected = eina_list_append(item->wd->selected, item);
1439 item->wd->walking++;
1440 if (item->func.func)
1441 item->func.func((void *)item->func.data, item->wd->self, item);
1442 if (!item->delete_me)
1443 evas_object_smart_callback_call(item->wd->self, SIG_SELECTED, item);
1445 item->wd->walking--;
1446 item->wd->last_selected_item = item;
1447 if ((item->wd->clear_me) && (!item->wd->walking))
1448 elm_gengrid_clear(item->base.widget);
1451 if ((!item->walking) && (item->delete_me))
1452 if (!item->relcount) _item_del(item);
1457 _item_unselect(Elm_Gengrid_Item *item)
1459 if ((item->delete_me) || (!item->hilighted)) return;
1460 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1461 item->hilighted = EINA_FALSE;
1464 item->selected = EINA_FALSE;
1465 item->wd->selected = eina_list_remove(item->wd->selected, item);
1466 evas_object_smart_callback_call(item->wd->self, SIG_UNSELECTED, item);
1471 _calc_job(void *data)
1473 Widget_Data *wd = data;
1474 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1477 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1478 if ((cvw != 0) || (cvh != 0))
1480 if ((wd->horizontal) && (wd->item_height > 0))
1481 nmax = cvh / wd->item_height;
1482 else if (wd->item_width > 0)
1483 nmax = cvw / wd->item_width;
1491 minw = ceil(count / (float)nmax) * wd->item_width;
1492 minh = nmax * wd->item_height;
1496 minw = nmax * wd->item_width;
1497 minh = ceil(count / (float)nmax) * wd->item_height;
1500 if ((minw != wd->minw) || (minh != wd->minh))
1504 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1508 evas_object_smart_changed(wd->pan_smart);
1510 wd->calc_job = NULL;
1514 _pan_add(Evas_Object *obj)
1517 Evas_Object_Smart_Clipped_Data *cd;
1520 cd = evas_object_smart_data_get(obj);
1523 sd->__clipped_data = *cd;
1525 evas_object_smart_data_set(obj, sd);
1529 _pan_del(Evas_Object *obj)
1531 Pan *sd = evas_object_smart_data_get(obj);
1538 _pan_set(Evas_Object *obj,
1542 Pan *sd = evas_object_smart_data_get(obj);
1543 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1546 evas_object_smart_changed(obj);
1550 _pan_get(Evas_Object *obj,
1554 Pan *sd = evas_object_smart_data_get(obj);
1555 if (x) *x = sd->wd->pan_x;
1556 if (y) *y = sd->wd->pan_y;
1560 _pan_child_size_get(Evas_Object *obj,
1564 Pan *sd = evas_object_smart_data_get(obj);
1565 if (w) *w = sd->wd->minw;
1566 if (h) *h = sd->wd->minh;
1570 _pan_max_get(Evas_Object *obj,
1574 Pan *sd = evas_object_smart_data_get(obj);
1578 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1580 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1582 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1586 _pan_min_get(Evas_Object *obj,
1590 Pan *sd = evas_object_smart_data_get(obj);
1594 _pan_max_get(obj, &mx, &my);
1596 *x = -mx * sd->wd->align_x;
1598 *y = -my * sd->wd->align_y;
1602 _pan_resize(Evas_Object *obj,
1606 Pan *sd = evas_object_smart_data_get(obj);
1609 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1610 if ((ow == w) && (oh == h)) return;
1611 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1612 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1616 _pan_calculate(Evas_Object *obj)
1618 Pan *sd = evas_object_smart_data_get(obj);
1619 Evas_Coord cx = 0, cy = 0;
1620 Elm_Gengrid_Item *item;
1623 if (!sd->wd->nmax) return;
1625 sd->wd->reorder_item_changed = EINA_FALSE;
1627 EINA_INLIST_FOREACH(sd->wd->items, item)
1629 _item_place(item, cx, cy);
1630 if (sd->wd->reorder_item_changed) return;
1631 if (sd->wd->horizontal)
1633 cy = (cy + 1) % sd->wd->nmax;
1638 cx = (cx + 1) % sd->wd->nmax;
1643 if ((sd->wd->reorder_mode) && (sd->wd->reorder_item))
1645 if (!sd->wd->reorder_item_changed)
1647 sd->wd->old_pan_x = sd->wd->pan_x;
1648 sd->wd->old_pan_y = sd->wd->pan_y;
1650 sd->wd->move_effect_enabled = EINA_FALSE;
1652 evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
1656 _pan_move(Evas_Object *obj,
1657 Evas_Coord x __UNUSED__,
1658 Evas_Coord y __UNUSED__)
1660 Pan *sd = evas_object_smart_data_get(obj);
1662 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1663 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1667 _hold_on(void *data __UNUSED__,
1669 void *event_info __UNUSED__)
1671 Widget_Data *wd = elm_widget_data_get(obj);
1673 elm_smart_scroller_hold_set(wd->scr, 1);
1677 _hold_off(void *data __UNUSED__,
1679 void *event_info __UNUSED__)
1681 Widget_Data *wd = elm_widget_data_get(obj);
1683 elm_smart_scroller_hold_set(wd->scr, 0);
1687 _freeze_on(void *data __UNUSED__,
1689 void *event_info __UNUSED__)
1691 Widget_Data *wd = elm_widget_data_get(obj);
1693 elm_smart_scroller_freeze_set(wd->scr, 1);
1697 _freeze_off(void *data __UNUSED__,
1699 void *event_info __UNUSED__)
1701 Widget_Data *wd = elm_widget_data_get(obj);
1703 elm_smart_scroller_freeze_set(wd->scr, 0);
1707 _scr_drag_start(void *data,
1708 Evas_Object *obj __UNUSED__,
1709 void *event_info __UNUSED__)
1711 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1715 _scr_drag_stop(void *data,
1716 Evas_Object *obj __UNUSED__,
1717 void *event_info __UNUSED__)
1719 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1723 _scr_scroll(void *data,
1724 Evas_Object *obj __UNUSED__,
1725 void *event_info __UNUSED__)
1727 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1731 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1733 const Elm_Gengrid_Item *item = data;
1734 const Elm_Gengrid_Item *item1 = data1;
1736 return _elm_gengrid_item_compare_data_cb(item->base.data, item1->base.data);
1740 _elm_gengrid_item_compare(const void *data, const void *data1)
1742 Elm_Gengrid_Item *item, *item1;
1743 item = ELM_GENGRID_ITEM_FROM_INLIST(data);
1744 item1 = ELM_GENGRID_ITEM_FROM_INLIST(data1);
1745 return _elm_gengrid_item_compare_cb(item, item1);
1749 * Add a new Gengrid object.
1751 * @param parent The parent object.
1752 * @return The new object or NULL if it cannot be created.
1754 * @see elm_gengrid_item_size_set()
1755 * @see elm_gengrid_horizontal_set()
1756 * @see elm_gengrid_item_append()
1757 * @see elm_gengrid_item_del()
1758 * @see elm_gengrid_clear()
1763 elm_gengrid_add(Evas_Object *parent)
1768 static Evas_Smart *smart = NULL;
1769 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1771 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1773 ELM_SET_WIDTYPE(widtype, "gengrid");
1774 elm_widget_type_set(obj, "gengrid");
1775 elm_widget_sub_object_add(parent, obj);
1776 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1777 elm_widget_data_set(obj, wd);
1778 elm_widget_del_hook_set(obj, _del_hook);
1779 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1780 elm_widget_theme_hook_set(obj, _theme_hook);
1781 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1782 elm_widget_can_focus_set(obj, EINA_TRUE);
1783 elm_widget_event_hook_set(obj, _event_hook);
1785 wd->scr = elm_smart_scroller_add(e);
1786 elm_smart_scroller_widget_set(wd->scr, obj);
1787 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1789 elm_widget_resize_object_set(obj, wd->scr);
1791 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1792 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1793 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1795 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1800 wd->h_bounce = bounce;
1801 wd->v_bounce = bounce;
1802 wd->no_select = EINA_FALSE;
1804 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1805 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1806 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1807 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1809 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1813 static Evas_Smart_Class sc;
1815 evas_object_smart_clipped_smart_set(&_pan_sc);
1817 sc.name = "elm_gengrid_pan";
1818 sc.version = EVAS_SMART_CLASS_VERSION;
1821 sc.resize = _pan_resize;
1822 sc.move = _pan_move;
1823 sc.calculate = _pan_calculate;
1824 smart = evas_smart_class_new(&sc);
1828 wd->pan_smart = evas_object_smart_add(e, smart);
1829 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1833 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1834 _pan_set, _pan_get, _pan_max_get,
1835 _pan_min_get, _pan_child_size_get);
1837 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1842 * Set the size for the item of the Gengrid.
1844 * @param obj The Gengrid object.
1845 * @param w The item's width.
1846 * @param h The item's height;
1848 * @see elm_gengrid_item_size_get()
1853 elm_gengrid_item_size_set(Evas_Object *obj,
1857 ELM_CHECK_WIDTYPE(obj, widtype);
1858 Widget_Data *wd = elm_widget_data_get(obj);
1860 if ((wd->item_width == w) && (wd->item_height == h)) return;
1862 wd->item_height = h;
1863 if (wd->calc_job) ecore_job_del(wd->calc_job);
1864 wd->calc_job = ecore_job_add(_calc_job, wd);
1868 * Get the size of the item of the Gengrid.
1870 * @param obj The Gengrid object.
1871 * @param w Pointer to the item's width.
1872 * @param h Pointer to the item's height.
1874 * @see elm_gengrid_item_size_get()
1879 elm_gengrid_item_size_get(const Evas_Object *obj,
1883 ELM_CHECK_WIDTYPE(obj, widtype);
1884 Widget_Data *wd = elm_widget_data_get(obj);
1886 if (w) *w = wd->item_width;
1887 if (h) *h = wd->item_height;
1891 * Set item's alignment within the scroller.
1893 * @param obj The Gengrid object.
1894 * @param align_x The x alignment (0 <= x <= 1).
1895 * @param align_y The y alignment (0 <= y <= 1).
1897 * @see elm_gengrid_align_get()
1902 elm_gengrid_align_set(Evas_Object *obj,
1906 ELM_CHECK_WIDTYPE(obj, widtype);
1907 Widget_Data *wd = elm_widget_data_get(obj);
1911 else if (align_x < 0.0)
1913 wd->align_x = align_x;
1917 else if (align_y < 0.0)
1919 wd->align_y = align_y;
1923 * Get the alignenment set for the Gengrid object.
1925 * @param obj The Gengrid object.
1926 * @param align_x Pointer to x alignenment.
1927 * @param align_y Pointer to y alignenment.
1929 * @see elm_gengrid_align_set()
1934 elm_gengrid_align_get(const Evas_Object *obj,
1938 ELM_CHECK_WIDTYPE(obj, widtype);
1939 Widget_Data *wd = elm_widget_data_get(obj);
1940 if (align_x) *align_x = wd->align_x;
1941 if (align_y) *align_y = wd->align_y;
1945 * Add item to the end of the Gengrid.
1947 * @param obj The Gengrid object.
1948 * @param gic The item class for the item.
1949 * @param data The item data.
1950 * @param func Convenience function called when item is selected.
1951 * @param func_data Data passed to @p func above.
1952 * @return A handle to the item added or NULL if not possible.
1954 * @see elm_gengrid_item_prepend()
1955 * @see elm_gengrid_item_insert_before()
1956 * @see elm_gengrid_item_insert_after()
1957 * @see elm_gengrid_item_del()
1961 EAPI Elm_Gengrid_Item *
1962 elm_gengrid_item_append(Evas_Object *obj,
1963 const Elm_Gengrid_Item_Class *gic,
1966 const void *func_data)
1968 Elm_Gengrid_Item *item;
1969 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1970 Widget_Data *wd = elm_widget_data_get(obj);
1971 if (!wd) return NULL;
1973 item = _item_create(wd, gic, data, func, func_data);
1974 if (!item) return NULL;
1975 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
1977 if (wd->calc_job) ecore_job_del(wd->calc_job);
1978 wd->calc_job = ecore_job_add(_calc_job, wd);
1984 * Add item at start of the Gengrid.
1986 * This adds an item to the beginning of the grid.
1988 * @param obj The Gengrid object.
1989 * @param gic The item class for the item.
1990 * @param data The item data.
1991 * @param func Convenience function called when item is selected.
1992 * @param func_data Data passed to @p func above.
1993 * @return A handle to the item added or NULL if not possible.
1995 * @see elm_gengrid_item_append()
1996 * @see elm_gengrid_item_insert_before()
1997 * @see elm_gengrid_item_insert_after()
1998 * @see elm_gengrid_item_del()
2002 EAPI Elm_Gengrid_Item *
2003 elm_gengrid_item_prepend(Evas_Object *obj,
2004 const Elm_Gengrid_Item_Class *gic,
2007 const void *func_data)
2009 Elm_Gengrid_Item *item;
2010 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2011 Widget_Data *wd = elm_widget_data_get(obj);
2012 if (!wd) return NULL;
2014 item = _item_create(wd, gic, data, func, func_data);
2015 if (!item) return NULL;
2016 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
2018 if (wd->calc_job) ecore_job_del(wd->calc_job);
2019 wd->calc_job = ecore_job_add(_calc_job, wd);
2025 * Insert and item before another in the Gengrid.
2027 * This inserts an item before another in the grid.
2029 * @param obj The Gengrid object.
2030 * @param gic The item class for the item.
2031 * @param data The item data.
2032 * @param relative The item to which insert before.
2033 * @param func Convenience function called when item is selected.
2034 * @param func_data Data passed to @p func above.
2035 * @return A handle to the item added or NULL if not possible.
2037 * @see elm_gengrid_item_append()
2038 * @see elm_gengrid_item_prepend()
2039 * @see elm_gengrid_item_insert_after()
2040 * @see elm_gengrid_item_del()
2044 EAPI Elm_Gengrid_Item *
2045 elm_gengrid_item_insert_before(Evas_Object *obj,
2046 const Elm_Gengrid_Item_Class *gic,
2048 Elm_Gengrid_Item *relative,
2050 const void *func_data)
2052 Elm_Gengrid_Item *item;
2053 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2054 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2055 Widget_Data *wd = elm_widget_data_get(obj);
2056 if (!wd) return NULL;
2058 item = _item_create(wd, gic, data, func, func_data);
2059 if (!item) return NULL;
2060 wd->items = eina_inlist_prepend_relative
2061 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
2063 if (wd->calc_job) ecore_job_del(wd->calc_job);
2064 wd->calc_job = ecore_job_add(_calc_job, wd);
2070 * Insert and item after another in the Gengrid.
2072 * This inserts an item after another in the grid.
2074 * @param obj The Gengrid object.
2075 * @param gic The item class for the item.
2076 * @param data The item data.
2077 * @param relative The item to which insert after.
2078 * @param func Convenience function called when item is selected.
2079 * @param func_data Data passed to @p func above.
2080 * @return A handle to the item added or NULL if not possible.
2082 * @see elm_gengrid_item_append()
2083 * @see elm_gengrid_item_prepend()
2084 * @see elm_gengrid_item_insert_before()
2085 * @see elm_gengrid_item_del()
2089 EAPI Elm_Gengrid_Item *
2090 elm_gengrid_item_insert_after(Evas_Object *obj,
2091 const Elm_Gengrid_Item_Class *gic,
2093 Elm_Gengrid_Item *relative,
2095 const void *func_data)
2097 Elm_Gengrid_Item *item;
2098 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2099 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2100 Widget_Data *wd = elm_widget_data_get(obj);
2101 if (!wd) return NULL;
2103 item = _item_create(wd, gic, data, func, func_data);
2104 if (!item) return NULL;
2105 wd->items = eina_inlist_append_relative
2106 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
2108 if (wd->calc_job) ecore_job_del(wd->calc_job);
2109 wd->calc_job = ecore_job_add(_calc_job, wd);
2114 EAPI Elm_Gengrid_Item *
2115 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
2116 const Elm_Gengrid_Item_Class *gic,
2118 Eina_Compare_Cb comp,
2120 const void *func_data)
2122 Elm_Gengrid_Item *item;
2123 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2124 Widget_Data *wd = elm_widget_data_get(obj);
2125 if (!wd) return NULL;
2127 item = _item_create(wd, gic, data, func, func_data);
2128 if (!item) return NULL;
2130 _elm_gengrid_item_compare_cb = comp;
2131 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(item),
2132 _elm_gengrid_item_compare);
2133 if (wd->calc_job) ecore_job_del(wd->calc_job);
2134 wd->calc_job = ecore_job_add(_calc_job, wd);
2139 EAPI Elm_Gengrid_Item *
2140 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2141 const Elm_Gengrid_Item_Class *gic,
2143 Eina_Compare_Cb comp,
2145 const void *func_data)
2147 _elm_gengrid_item_compare_data_cb = comp;
2149 return elm_gengrid_item_direct_sorted_insert(obj, gic, data, _elm_gengrid_item_compare_data, func, func_data);
2153 * Remove an item from the Gengrid.
2155 * @param item The item to be removed.
2156 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise.
2158 * @see elm_gengrid_clear() to remove all items of the Gengrid.
2163 elm_gengrid_item_del(Elm_Gengrid_Item *item)
2165 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2166 if ((item->relcount > 0) || (item->walking > 0))
2168 item->delete_me = EINA_TRUE;
2169 elm_widget_item_pre_notify_del(item);
2171 item->wd->selected = eina_list_remove(item->wd->selected, item);
2172 if (item->gic->func.del)
2173 item->gic->func.del((void *)item->base.data, item->wd->self);
2181 * Set for what direction the Gengrid will expand.
2183 * @param obj The Gengrid object.
2184 * @param setting If @c EINA_TRUE the Gengrid will expand horizontally
2185 * or vertically if @c EINA_FALSE.
2190 elm_gengrid_horizontal_set(Evas_Object *obj,
2193 ELM_CHECK_WIDTYPE(obj, widtype);
2194 Widget_Data *wd = elm_widget_data_get(obj);
2196 if (setting == wd->horizontal) return;
2197 wd->horizontal = setting;
2199 /* Update the items to conform to the new layout */
2200 if (wd->calc_job) ecore_job_del(wd->calc_job);
2201 wd->calc_job = ecore_job_add(_calc_job, wd);
2205 * Get for what direction the Gengrid is expanded.
2207 * @param obj The Gengrid object.
2208 * @return If the Gengrid is expanded horizontally return @c EINA_TRUE
2209 * else @c EINA_FALSE.
2214 elm_gengrid_horizontal_get(const Evas_Object *obj)
2216 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2217 Widget_Data *wd = elm_widget_data_get(obj);
2218 if (!wd) return EINA_FALSE;
2219 return wd->horizontal;
2225 * This clears all items in the Gengrid, leaving it empty.
2227 * @param obj The Gengrid object.
2229 * @see elm_gengrid_item_del() to remove just one item.
2234 elm_gengrid_clear(Evas_Object *obj)
2236 ELM_CHECK_WIDTYPE(obj, widtype);
2237 Widget_Data *wd = elm_widget_data_get(obj);
2242 ecore_job_del(wd->calc_job);
2243 wd->calc_job = NULL;
2246 if (wd->walking > 0)
2248 Elm_Gengrid_Item *item;
2250 EINA_INLIST_FOREACH(wd->items, item)
2251 item->delete_me = 1;
2257 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2259 wd->items = eina_inlist_remove(wd->items, wd->items);
2260 elm_widget_item_pre_notify_del(item);
2261 if (item->realized) _item_unrealize(item);
2262 if (item->gic->func.del)
2263 item->gic->func.del((void *)item->base.data, wd->self);
2264 if (item->long_timer) ecore_timer_del(item->long_timer);
2265 elm_widget_item_del(item);
2270 eina_list_free(wd->selected);
2271 wd->selected = NULL;
2279 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2280 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2284 * Get the real evas object of the Gengrid item
2286 * This returns the actual evas object used for the specified Gengrid
2287 * item. This may be NULL as it may not be created, and may be
2288 * deleted at any time by Gengrid. Do not modify this object (move,
2289 * resize, show, hide etc.) as Gengrid is controlling it. This
2290 * function is for querying, emitting custom signals or hooking lower
2291 * level callbacks for events. Do not delete this object under any
2294 * @param item The Gengrid item.
2295 * @return the evas object associated to this item.
2297 * @see elm_gengrid_item_data_get()
2301 EAPI const Evas_Object *
2302 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
2304 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2305 return item->base.view;
2309 * Update the contents of an item
2311 * This updates an item by calling all the item class functions again
2312 * to get the icons, labels and states. Use this when the original
2313 * item data has changed and the changes are desired to be reflected.
2315 * @param item The item
2320 elm_gengrid_item_update(Elm_Gengrid_Item *item)
2322 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2323 if (!item->realized) return;
2324 if (item->want_unrealize) return;
2325 _item_unrealize(item);
2326 _item_realize(item);
2327 _item_place(item, item->x, item->y);
2331 * Returns the data associated to an item
2333 * This returns the data value passed on the elm_gengrid_item_append()
2334 * and related item addition calls.
2336 * @param item The Gengrid item.
2337 * @return the data associated to this item.
2339 * @see elm_gengrid_item_append()
2340 * @see elm_gengrid_item_object_get()
2345 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2347 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2348 return elm_widget_item_data_get(item);
2352 * Set the datan item from the gengrid item
2354 * This set the data value passed on the elm_gengrid_item_append() and
2355 * related item addition calls. This function will also call
2356 * elm_gengrid_item_update() so the item will be updated to reflect
2359 * @param item The item
2360 * @param data The new data pointer to set
2365 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2368 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2369 elm_widget_item_data_set(item, data);
2370 elm_gengrid_item_update(item);
2373 EAPI const Elm_Gengrid_Item_Class *
2374 elm_gengrid_item_item_class_get(const Elm_Gengrid_Item *item)
2376 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2377 if (item->delete_me) return NULL;
2382 elm_gengrid_item_item_class_set(Elm_Gengrid_Item *item,
2383 const Elm_Gengrid_Item_Class *gic)
2385 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2386 EINA_SAFETY_ON_NULL_RETURN(gic);
2387 if (item->delete_me) return;
2389 elm_gengrid_item_update(item);
2393 * Get the item's coordinates.
2395 * This returns the logical position of the item whithin the Gengrid.
2397 * @param item The Gengrid item.
2398 * @param x The x-axis coordinate pointer.
2399 * @param y The y-axis coordinate pointer.
2404 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2408 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2409 if (x) *x = item->x;
2410 if (y) *y = item->y;
2414 * Enable or disable multi-select in the Gengrid.
2416 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
2417 * the Gengrid. This allows more than 1 item to be selected.
2419 * @param obj The Gengrid object.
2420 * @param multi Multi-select enabled/disabled
2425 elm_gengrid_multi_select_set(Evas_Object *obj,
2428 ELM_CHECK_WIDTYPE(obj, widtype);
2429 Widget_Data *wd = elm_widget_data_get(obj);
2435 * Get if multi-select in Gengrid is enabled or disabled
2437 * @param obj The Gengrid object
2438 * @return Multi-select enable/disable
2439 * (EINA_TRUE = enabled / EINA_FALSE = disabled)
2444 elm_gengrid_multi_select_get(const Evas_Object *obj)
2446 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2447 Widget_Data *wd = elm_widget_data_get(obj);
2448 if (!wd) return EINA_FALSE;
2453 * Get the selected item in the Gengrid
2455 * This gets the selected item in the Gengrid (if multi-select is
2456 * enabled only the first item in the list is selected - which is not
2457 * very useful, so see elm_gengrid_selected_items_get() for when
2458 * multi-select is used).
2460 * If no item is selected, NULL is returned.
2462 * @param obj The Gengrid object.
2463 * @return The selected item, or NULL if none.
2467 EAPI Elm_Gengrid_Item *
2468 elm_gengrid_selected_item_get(const Evas_Object *obj)
2470 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2471 Widget_Data *wd = elm_widget_data_get(obj);
2472 if (!wd) return NULL;
2473 if (wd->selected) return wd->selected->data;
2478 * Get a list of selected items in the Gengrid.
2480 * This returns a list of the selected items. This list pointer is
2481 * only valid so long as no items are selected or unselected (or
2482 * unselected implictly by deletion). The list contains
2483 * Elm_Gengrid_Item pointers.
2485 * @param obj The Gengrid object.
2486 * @return The list of selected items, or NULL if none are selected.
2490 EAPI const Eina_List *
2491 elm_gengrid_selected_items_get(const Evas_Object *obj)
2493 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2494 Widget_Data *wd = elm_widget_data_get(obj);
2495 if (!wd) return NULL;
2496 return wd->selected;
2500 * Set the selected state of an item.
2502 * This sets the selected state of an item. If multi-select is not
2503 * enabled and selected is EINA_TRUE, previously selected items are
2506 * @param item The item
2507 * @param selected The selected state.
2512 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2515 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2516 Widget_Data *wd = item->wd;
2518 if (item->delete_me) return;
2519 selected = !!selected;
2520 if (item->selected == selected) return;
2526 while (wd->selected)
2527 _item_unselect(wd->selected->data);
2529 _item_hilight(item);
2533 _item_unselect(item);
2537 * Get the selected state of an item.
2539 * This gets the selected state of an item (1 selected, 0 not selected).
2541 * @param item The item
2542 * @return The selected state
2547 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2549 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2550 return item->selected;
2554 * Sets the disabled state of an item.
2556 * A disabled item cannot be selected or unselected. It will also
2557 * change appearance to disabled. This sets the disabled state (1
2558 * disabled, 0 not disabled).
2560 * @param item The item
2561 * @param disabled The disabled state
2566 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2569 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2570 if (item->disabled == disabled) return;
2571 if (item->delete_me) return;
2572 item->disabled = !!disabled;
2576 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2578 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2583 * Get the disabled state of an item.
2585 * This gets the disabled state of the given item.
2587 * @param item The item
2588 * @return The disabled state
2593 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2595 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2596 if (item->delete_me) return EINA_FALSE;
2597 return item->disabled;
2600 static Evas_Object *
2601 _elm_gengrid_item_label_create(void *data,
2603 void *item __UNUSED__)
2605 Evas_Object *label = elm_label_add(obj);
2608 elm_object_style_set(label, "tooltip");
2609 elm_object_text_set(label, data);
2614 _elm_gengrid_item_label_del_cb(void *data,
2615 Evas_Object *obj __UNUSED__,
2616 void *event_info __UNUSED__)
2618 eina_stringshare_del(data);
2622 * Set the text to be shown in the gengrid item.
2624 * @param item Target item
2625 * @param text The text to set in the content
2627 * Setup the text as tooltip to object. The item can have only one
2628 * tooltip, so any previous tooltip data is removed.
2633 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2636 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2637 text = eina_stringshare_add(text);
2638 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2640 _elm_gengrid_item_label_del_cb);
2644 * Set the content to be shown in the tooltip item
2646 * Setup the tooltip to item. The item can have only one tooltip, so
2647 * any previous tooltip data is removed. @p func(with @p data) will be
2648 * called every time that need show the tooltip and it should return a
2649 * valid Evas_Object. This object is then managed fully by tooltip
2650 * system and is deleted when the tooltip is gone.
2652 * @param item the gengrid item being attached a tooltip.
2653 * @param func the function used to create the tooltip contents.
2654 * @param data what to provide to @a func as callback data/context.
2655 * @param del_cb called when data is not needed anymore, either when
2656 * another callback replaces @func, the tooltip is unset with
2657 * elm_gengrid_item_tooltip_unset() or the owner @an item
2658 * dies. This callback receives as the first parameter the
2659 * given @a data, and @c event_info is the item.
2664 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2665 Elm_Tooltip_Item_Content_Cb func,
2667 Evas_Smart_Cb del_cb)
2669 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2671 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2674 if (item->tooltip.del_cb)
2675 item->tooltip.del_cb((void *)item->tooltip.data,
2676 item->base.widget, item);
2677 item->tooltip.content_cb = func;
2678 item->tooltip.data = data;
2679 item->tooltip.del_cb = del_cb;
2680 if (item->base.view)
2682 elm_widget_item_tooltip_content_cb_set(item,
2683 item->tooltip.content_cb,
2684 item->tooltip.data, NULL);
2685 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2691 if (del_cb) del_cb((void *)data, NULL, NULL);
2695 * Unset tooltip from item
2697 * @param item gengrid item to remove previously set tooltip.
2699 * Remove tooltip from item. The callback provided as del_cb to
2700 * elm_gengrid_item_tooltip_content_cb_set() will be called to notify
2701 * it is not used anymore.
2703 * @see elm_gengrid_item_tooltip_content_cb_set()
2708 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2710 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2711 if ((item->base.view) && (item->tooltip.content_cb))
2712 elm_widget_item_tooltip_unset(item);
2714 if (item->tooltip.del_cb)
2715 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2716 item->tooltip.del_cb = NULL;
2717 item->tooltip.content_cb = NULL;
2718 item->tooltip.data = NULL;
2719 if (item->tooltip.style)
2720 elm_gengrid_item_tooltip_style_set(item, NULL);
2724 * Sets a different style for this item tooltip.
2726 * @note before you set a style you should define a tooltip with
2727 * elm_gengrid_item_tooltip_content_cb_set() or
2728 * elm_gengrid_item_tooltip_text_set()
2730 * @param item gengrid item with tooltip already set.
2731 * @param style the theme style to use (default, transparent, ...)
2736 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2739 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2740 eina_stringshare_replace(&item->tooltip.style, style);
2741 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2745 * Get the style for this item tooltip.
2747 * @param item gengrid item with tooltip already set.
2748 * @return style the theme style in use, defaults to "default". If the
2749 * object does not have a tooltip set, then NULL is returned.
2754 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2756 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2757 return item->tooltip.style;
2761 * Set the cursor to be shown when mouse is over the gengrid item
2763 * @param item Target item
2764 * @param cursor the cursor name to be used.
2766 * @see elm_object_cursor_set()
2770 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2773 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2774 eina_stringshare_replace(&item->mouse_cursor, cursor);
2775 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2779 * Get the cursor to be shown when mouse is over the gengrid item
2781 * @param item gengrid item with cursor already set.
2782 * @return the cursor name.
2787 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2789 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2790 return elm_widget_item_cursor_get(item);
2794 * Unset the cursor to be shown when mouse is over the gengrid item
2796 * @param item Target item
2798 * @see elm_object_cursor_unset()
2802 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2804 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2805 if (!item->mouse_cursor)
2808 if (item->base.view)
2809 elm_widget_item_cursor_unset(item);
2811 eina_stringshare_del(item->mouse_cursor);
2812 item->mouse_cursor = NULL;
2816 * Sets a different style for this item cursor.
2818 * @note before you set a style you should define a cursor with
2819 * elm_gengrid_item_cursor_set()
2821 * @param item gengrid item with cursor already set.
2822 * @param style the theme style to use (default, transparent, ...)
2827 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2830 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2831 elm_widget_item_cursor_style_set(item, style);
2835 * Get the style for this item cursor.
2837 * @param item gengrid item with cursor already set.
2838 * @return style the theme style in use, defaults to "default". If the
2839 * object does not have a cursor set, then NULL is returned.
2844 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2846 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2847 return elm_widget_item_cursor_style_get(item);
2851 * Set if the cursor set should be searched on the theme or should use
2852 * the provided by the engine, only.
2854 * @note before you set if should look on theme you should define a
2855 * cursor with elm_object_cursor_set(). By default it will only look
2856 * for cursors provided by the engine.
2858 * @param item widget item with cursor already set.
2859 * @param engine_only boolean to define it cursors should be looked
2860 * only between the provided by the engine or searched on widget's
2866 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2867 Eina_Bool engine_only)
2869 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2870 elm_widget_item_cursor_engine_only_set(item, engine_only);
2874 * Get the cursor engine only usage for this item cursor.
2876 * @param item widget item with cursor already set.
2877 * @return engine_only boolean to define it cursors should be looked
2878 * only between the provided by the engine or searched on widget's
2879 * theme as well. If the object does not have a cursor set, then
2880 * EINA_FALSE is returned.
2885 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2887 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2888 return elm_widget_item_cursor_engine_only_get(item);
2892 * Set the reorder mode
2894 * @param obj The Gengrid object
2895 * @param reorder_mode The reorder mode
2896 * (EINA_TRUE = on, EINA_FALSE = off)
2901 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2902 Eina_Bool reorder_mode)
2904 ELM_CHECK_WIDTYPE(obj, widtype);
2905 Widget_Data *wd = elm_widget_data_get(obj);
2907 wd->reorder_mode = reorder_mode;
2911 * Get the reorder mode
2913 * @param obj The Gengrid object
2914 * @return The reorder mode
2915 * (EINA_TRUE = on, EINA_FALSE = off)
2920 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2922 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2923 Widget_Data *wd = elm_widget_data_get(obj);
2924 if (!wd) return EINA_FALSE;
2925 return wd->reorder_mode;
2929 * Set the always select mode.
2931 * Cells will only call their selection func and callback when first
2932 * becoming selected. Any further clicks will do nothing, unless you
2933 * enable always select with
2934 * elm_gengrid_always_select_mode_set(). This means even if selected,
2935 * every click will make the selected callbacks be called.
2937 * @param obj The Gengrid object
2938 * @param always_select The always select mode (EINA_TRUE = on,
2944 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2945 Eina_Bool always_select)
2947 ELM_CHECK_WIDTYPE(obj, widtype);
2948 Widget_Data *wd = elm_widget_data_get(obj);
2950 wd->always_select = always_select;
2954 * Get the always select mode.
2956 * @param obj The Gengrid object.
2957 * @return The always select mode (EINA_TRUE = on, EINA_FALSE = off)
2962 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2964 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2965 Widget_Data *wd = elm_widget_data_get(obj);
2966 if (!wd) return EINA_FALSE;
2967 return wd->always_select;
2971 * Set no select mode.
2973 * This will turn off the ability to select items entirely and they
2974 * will neither appear selected nor call selected callback functions.
2976 * @param obj The Gengrid object
2977 * @param no_select The no select mode (EINA_TRUE = on, EINA_FALSE = off)
2982 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2983 Eina_Bool no_select)
2985 ELM_CHECK_WIDTYPE(obj, widtype);
2986 Widget_Data *wd = elm_widget_data_get(obj);
2988 wd->no_select = no_select;
2992 * Gets no select mode.
2994 * @param obj The Gengrid object
2995 * @return The no select mode (EINA_TRUE = on, EINA_FALSE = off)
3000 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
3002 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3003 Widget_Data *wd = elm_widget_data_get(obj);
3004 if (!wd) return EINA_FALSE;
3005 return wd->no_select;
3011 * This will enable or disable the scroller bounce mode for the
3012 * Gengrid. See elm_scroller_bounce_set() for details.
3014 * @param obj The Gengrid object
3015 * @param h_bounce Allow bounce horizontally
3016 * @param v_bounce Allow bounce vertically
3021 elm_gengrid_bounce_set(Evas_Object *obj,
3025 ELM_CHECK_WIDTYPE(obj, widtype);
3026 Widget_Data *wd = elm_widget_data_get(obj);
3028 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
3029 wd->h_bounce = h_bounce;
3030 wd->v_bounce = v_bounce;
3034 * Get the bounce mode
3036 * @param obj The Gengrid object
3037 * @param h_bounce Allow bounce horizontally
3038 * @param v_bounce Allow bounce vertically
3043 elm_gengrid_bounce_get(const Evas_Object *obj,
3044 Eina_Bool *h_bounce,
3045 Eina_Bool *v_bounce)
3047 ELM_CHECK_WIDTYPE(obj, widtype);
3048 Widget_Data *wd = elm_widget_data_get(obj);
3050 *h_bounce = wd->h_bounce;
3051 *v_bounce = wd->v_bounce;
3055 * Get all items in the Gengrid.
3057 * This returns a list of the Gengrid items. The list contains
3058 * Elm_Gengrid_Item pointers.
3060 * @param obj The Gengrid object.
3061 * @return The list of items, or NULL if none.
3067 * Set gengrid scroll page size relative to viewport size.
3069 * The gengrid scroller is capable of limiting scrolling by the user
3070 * to "pages" That is to jump by and only show a "whole page" at a
3071 * time as if the continuous area of the scroller content is split
3072 * into page sized pieces. This sets the size of a page relative to
3073 * the viewport of the scroller. 1.0 is "1 viewport" is size
3074 * (horizontally or vertically). 0.0 turns it off in that axis. This
3075 * is mutually exclusive with page size (see
3076 * elm_gengrid_page_size_set() for more information). Likewise 0.5 is
3077 * "half a viewport". Sane usable valus are normally between 0.0 and
3078 * 1.0 including 1.0. If you only want 1 axis to be page "limited",
3079 * use 0.0 for the other axis.
3081 * @param obj The gengrid object
3082 * @param h_pagerel The horizontal page relative size
3083 * @param v_pagerel The vertical page relative size
3088 elm_gengrid_page_relative_set(Evas_Object *obj,
3092 Evas_Coord pagesize_h;
3093 Evas_Coord pagesize_v;
3095 ELM_CHECK_WIDTYPE(obj, widtype);
3096 Widget_Data *wd = elm_widget_data_get(obj);
3099 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
3100 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
3105 * Get gengrid scroll page size relative to viewport size.
3107 * The gengrid scroller is capable of limiting scrolling by the user
3108 * to "pages" That is to jump by and only show a "whole page" at a
3109 * time as if the continuous area of the scroller content is split
3110 * into page sized pieces. This sets the size of a page relative to
3111 * the viewport of the scroller. 1.0 is "1 viewport" is size
3112 * (horizontally or vertically). 0.0 turns it off in that axis. This
3113 * is mutually exclusive with page size (see
3114 * elm_gengrid_page_size_set() for more information). Likewise 0.5 is
3115 * "half a viewport". Sane usable valus are normally between 0.0 and
3116 * 1.0 including 1.0. If you only want 1 axis to be page "limited",
3117 * use 0.0 for the other axis.
3119 * @param obj The gengrid object
3120 * @param h_pagerel The horizontal page relative size
3121 * @param v_pagerel The vertical page relative size
3126 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
3128 ELM_CHECK_WIDTYPE(obj, widtype);
3129 Widget_Data *wd = elm_widget_data_get(obj);
3132 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
3136 * Set gengrid scroll page size.
3138 * See also elm_gengrid_page_relative_set(). This, instead of a page
3139 * size being relative to the viewport, sets it to an absolute fixed
3140 * value, with 0 turning it off for that axis.
3142 * @param obj The gengrid object
3143 * @param h_pagesize The horizontal page size
3144 * @param v_pagesize The vertical page size
3149 elm_gengrid_page_size_set(Evas_Object *obj,
3150 Evas_Coord h_pagesize,
3151 Evas_Coord v_pagesize)
3156 ELM_CHECK_WIDTYPE(obj, widtype);
3157 Widget_Data *wd = elm_widget_data_get(obj);
3159 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
3160 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
3165 * Get the first item in the gengrid
3167 * This returns the first item in the list.
3169 * @param obj The gengrid object
3170 * @return The first item, or NULL if none
3174 EAPI Elm_Gengrid_Item *
3175 elm_gengrid_first_item_get(const Evas_Object *obj)
3177 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3178 Widget_Data *wd = elm_widget_data_get(obj);
3179 if (!wd) return NULL;
3180 if (!wd->items) return NULL;
3181 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
3182 while ((item) && (item->delete_me))
3183 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
3188 * Get the last item in the gengrid
3190 * This returns the last item in the list.
3192 * @return The last item, or NULL if none
3196 EAPI Elm_Gengrid_Item *
3197 elm_gengrid_last_item_get(const Evas_Object *obj)
3199 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3200 Widget_Data *wd = elm_widget_data_get(obj);
3201 if (!wd) return NULL;
3202 if (!wd->items) return NULL;
3203 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
3204 while ((item) && (item->delete_me))
3205 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
3210 * Get the next item in the gengrid
3212 * This returns the item after the item @p item.
3214 * @param item The item
3215 * @return The item after @p item, or NULL if none
3219 EAPI Elm_Gengrid_Item *
3220 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
3222 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
3225 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
3226 if ((item) && (!item->delete_me)) break;
3228 return (Elm_Gengrid_Item *)item;
3232 * Get the previous item in the gengrid
3234 * This returns the item before the item @p item.
3236 * @param item The item
3237 * @return The item before @p item, or NULL if none
3241 EAPI Elm_Gengrid_Item *
3242 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
3244 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
3247 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
3248 if ((item) && (!item->delete_me)) break;
3250 return (Elm_Gengrid_Item *)item;
3254 * Get the gengrid object from an item
3256 * This returns the gengrid object itself that an item belongs to.
3258 * @param item The item
3259 * @return The gengrid object
3264 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
3266 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
3267 return item->base.widget;
3271 * Show the given item
3273 * This causes gengrid to jump to the given item @p item and show it
3274 * (by scrolling), if it is not fully visible.
3276 * @param item The item
3281 elm_gengrid_item_show(Elm_Gengrid_Item *item)
3283 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
3284 Widget_Data *wd = elm_widget_data_get(item->wd->self);
3285 Evas_Coord minx = 0, miny = 0;
3288 if ((!item) || (item->delete_me)) return;
3289 _pan_min_get(wd->pan_smart, &minx, &miny);
3291 elm_smart_scroller_child_region_show(item->wd->scr,
3292 item->x * wd->item_width + minx,
3293 item->y * wd->item_height + miny,
3294 item->wd->item_width,
3295 item->wd->item_height);
3299 * Bring in the given item
3301 * This causes gengrig to jump to the given item @p item and show it
3302 * (by scrolling), if it is not fully visible. This may use animation
3303 * to do so and take a period of time
3305 * @param item The item
3310 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
3312 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
3313 if (item->delete_me) return;
3315 Evas_Coord minx = 0, miny = 0;
3316 Widget_Data *wd = elm_widget_data_get(item->wd->self);
3318 _pan_min_get(wd->pan_smart, &minx, &miny);
3320 elm_smart_scroller_region_bring_in(item->wd->scr,
3321 item->x * wd->item_width + minx,
3322 item->y * wd->item_height + miny,
3323 item->wd->item_width,
3324 item->wd->item_height);