1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
7 * Handle non-homogeneous objects too.
10 typedef struct _Widget_Data Widget_Data;
11 typedef struct _Pan Pan;
14 #define REORDER_EFFECT_TIME 0.5
16 struct _Elm_Gengrid_Item
21 const Elm_Gengrid_Item_Class *gic;
22 Ecore_Timer *long_timer;
23 Ecore_Animator *item_moving_effect_timer;
25 Eina_List *labels, *icons, *states, *icon_objs;
32 Evas_Coord x, y, dx, dy, ox, oy, tx, ty, rx, ry;
33 unsigned int moving_effect_start_time;
40 Elm_Tooltip_Item_Content_Cb content_cb;
45 const char *mouse_cursor;
47 Eina_Bool want_unrealize : 1;
48 Eina_Bool realized : 1;
49 Eina_Bool dragging : 1;
51 Eina_Bool delete_me : 1;
52 Eina_Bool display_only : 1;
53 Eina_Bool disabled : 1;
54 Eina_Bool selected : 1;
55 Eina_Bool hilighted : 1;
61 Evas_Object *self, *scr;
62 Evas_Object *pan_smart;
67 Elm_Gengrid_Item *last_selected_item, *reorder_item;
68 double align_x, align_y;
70 Evas_Coord pan_x, pan_y, old_pan_x, old_pan_y;
71 Evas_Coord item_width, item_height; /* Each item size */
72 Evas_Coord minw, minh; /* Total obj size */
73 Evas_Coord reorder_item_x, reorder_item_y;
78 Eina_Bool horizontal : 1;
79 Eina_Bool on_hold : 1;
80 Eina_Bool longpressed : 1;
82 Eina_Bool no_select : 1;
83 Eina_Bool wasselected : 1;
84 Eina_Bool always_select : 1;
85 Eina_Bool clear_me : 1;
86 Eina_Bool h_bounce : 1;
87 Eina_Bool v_bounce : 1;
88 Eina_Bool reorder_mode : 1;
89 Eina_Bool reorder_item_changed : 1;
90 Eina_Bool move_effect_enabled : 1;
93 #define ELM_GENGRID_ITEM_FROM_INLIST(item) \
94 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
98 Evas_Object_Smart_Clipped_Data __clipped_data;
102 static const char *widtype = NULL;
103 static void _item_hilight(Elm_Gengrid_Item *item);
104 static void _item_unrealize(Elm_Gengrid_Item *item);
105 static void _item_select(Elm_Gengrid_Item *item);
106 static void _item_unselect(Elm_Gengrid_Item *item);
107 static void _calc_job(void *data);
108 static void _on_focus_hook(void *data,
110 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
111 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
112 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
113 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
114 static Eina_Bool _item_single_select_up(Widget_Data *wd);
115 static Eina_Bool _item_single_select_down(Widget_Data *wd);
116 static Eina_Bool _item_single_select_left(Widget_Data *wd);
117 static Eina_Bool _item_single_select_right(Widget_Data *wd);
118 static Eina_Bool _event_hook(Evas_Object *obj,
120 Evas_Callback_Type type,
122 static Eina_Bool _deselect_all_items(Widget_Data *wd);
124 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
125 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
127 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
128 static const char SIG_SELECTED[] = "selected";
129 static const char SIG_UNSELECTED[] = "unselected";
130 static const char SIG_REALIZED[] = "realized";
131 static const char SIG_UNREALIZED[] = "unrealized";
132 static const char SIG_CHANGED[] = "changed";
133 static const char SIG_DRAG_START_UP[] = "drag,start,up";
134 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
135 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
136 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
137 static const char SIG_DRAG_STOP[] = "drag,stop";
138 static const char SIG_DRAG[] = "drag";
139 static const char SIG_SCROLL[] = "scroll";
140 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
141 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
142 static const char SIG_MOVED[] = "moved";
144 static const Evas_Smart_Cb_Description _signals[] = {
145 {SIG_CLICKED_DOUBLE, ""},
147 {SIG_UNSELECTED, ""},
149 {SIG_UNREALIZED, ""},
151 {SIG_DRAG_START_UP, ""},
152 {SIG_DRAG_START_DOWN, ""},
153 {SIG_DRAG_START_LEFT, ""},
154 {SIG_DRAG_START_RIGHT, ""},
158 {SIG_SCROLL_DRAG_START, ""},
159 {SIG_SCROLL_DRAG_STOP, ""},
164 static Eina_Compare_Cb _elm_gengrid_item_compare_cb;
165 static Eina_Compare_Cb _elm_gengrid_item_compare_data_cb;
168 _event_hook(Evas_Object *obj,
169 Evas_Object *src __UNUSED__,
170 Evas_Callback_Type type,
173 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
174 Evas_Event_Key_Down *ev = event_info;
175 Widget_Data *wd = elm_widget_data_get(obj);
176 if (!wd) return EINA_FALSE;
177 if (!wd->items) return EINA_FALSE;
178 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
179 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
181 Elm_Gengrid_Item *item = NULL;
184 Evas_Coord step_x = 0;
185 Evas_Coord step_y = 0;
188 Evas_Coord page_x = 0;
189 Evas_Coord page_y = 0;
191 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
192 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
193 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
194 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
196 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
198 if ((wd->horizontal) &&
199 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
200 (_item_multi_select_up(wd)))
201 || (_item_single_select_up(wd))))
203 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
206 else if ((!wd->horizontal) &&
207 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
208 (_item_multi_select_left(wd)))
209 || (_item_single_select_left(wd))))
211 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
217 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
219 if ((wd->horizontal) &&
220 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
221 (_item_multi_select_down(wd)))
222 || (_item_single_select_down(wd))))
224 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
227 else if ((!wd->horizontal) &&
228 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
229 (_item_multi_select_right(wd)))
230 || (_item_single_select_right(wd))))
232 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
238 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
240 if ((wd->horizontal) &&
241 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
242 (_item_multi_select_left(wd)))
243 || (_item_single_select_left(wd))))
245 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
248 else if ((!wd->horizontal) &&
249 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
250 (_item_multi_select_up(wd)))
251 || (_item_single_select_up(wd))))
253 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
259 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
261 if ((wd->horizontal) &&
262 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
263 (_item_multi_select_right(wd)))
264 || (_item_single_select_right(wd))))
266 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
269 else if ((!wd->horizontal) &&
270 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
271 (_item_multi_select_down(wd)))
272 || (_item_single_select_down(wd))))
274 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
280 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
282 item = elm_gengrid_first_item_get(obj);
283 elm_gengrid_item_bring_in(item);
284 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
287 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
289 item = elm_gengrid_last_item_get(obj);
290 elm_gengrid_item_bring_in(item);
291 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
294 else if ((!strcmp(ev->keyname, "Prior")) ||
295 (!strcmp(ev->keyname, "KP_Prior")))
300 x -= -(page_x * v_w) / 100;
307 y -= -(page_y * v_h) / 100;
312 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
317 x += -(page_x * v_w) / 100;
324 y += -(page_y * v_h) / 100;
329 else if (!strcmp(ev->keyname, "Escape"))
331 if (!_deselect_all_items(wd)) return EINA_FALSE;
332 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
335 else if ((!strcmp(ev->keyname, "Return")) ||
336 (!strcmp(ev->keyname, "KP_Enter")) ||
337 (!strcmp(ev->keyname, "space")))
339 item = elm_gengrid_selected_item_get(obj);
340 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
342 else return EINA_FALSE;
344 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
345 elm_smart_scroller_child_pos_set(wd->scr, x, y);
350 _deselect_all_items(Widget_Data *wd)
352 if (!wd->selected) return EINA_FALSE;
354 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
360 _item_multi_select_left(Widget_Data *wd)
362 if (!wd->selected) return EINA_FALSE;
364 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
365 if (!prev) return EINA_TRUE;
366 if (elm_gengrid_item_selected_get(prev))
368 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
369 wd->last_selected_item = prev;
370 elm_gengrid_item_show(wd->last_selected_item);
374 elm_gengrid_item_selected_set(prev, EINA_TRUE);
375 elm_gengrid_item_show(prev);
382 _item_multi_select_right(Widget_Data *wd)
384 if (!wd->selected) return EINA_FALSE;
386 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
387 if (!next) return EINA_TRUE;
388 if (elm_gengrid_item_selected_get(next))
390 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
391 wd->last_selected_item = next;
392 elm_gengrid_item_show(wd->last_selected_item);
396 elm_gengrid_item_selected_set(next, EINA_TRUE);
397 elm_gengrid_item_show(next);
404 _item_multi_select_up(Widget_Data *wd)
407 Eina_Bool r = EINA_TRUE;
409 if (!wd->selected) return EINA_FALSE;
411 for (i = 0; (r) && (i < wd->nmax); i++)
412 r &= _item_multi_select_left(wd);
418 _item_multi_select_down(Widget_Data *wd)
421 Eina_Bool r = EINA_TRUE;
423 if (!wd->selected) return EINA_FALSE;
425 for (i = 0; (r) && (i < wd->nmax); i++)
426 r &= _item_multi_select_right(wd);
432 _item_single_select_up(Widget_Data *wd)
436 Elm_Gengrid_Item *prev;
440 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
441 while ((prev) && (prev->delete_me))
442 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
443 elm_gengrid_item_selected_set(prev, EINA_TRUE);
444 elm_gengrid_item_show(prev);
447 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
449 if (!prev) return EINA_FALSE;
451 for (i = 1; i < wd->nmax; i++)
453 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
454 if (!tmp) return EINA_FALSE;
458 _deselect_all_items(wd);
460 elm_gengrid_item_selected_set(prev, EINA_TRUE);
461 elm_gengrid_item_show(prev);
466 _item_single_select_down(Widget_Data *wd)
470 Elm_Gengrid_Item *next;
474 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
475 while ((next) && (next->delete_me))
476 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
477 elm_gengrid_item_selected_set(next, EINA_TRUE);
478 elm_gengrid_item_show(next);
481 else next = elm_gengrid_item_next_get(wd->last_selected_item);
483 if (!next) return EINA_FALSE;
485 for (i = 1; i < wd->nmax; i++)
487 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
488 if (!tmp) return EINA_FALSE;
492 _deselect_all_items(wd);
494 elm_gengrid_item_selected_set(next, EINA_TRUE);
495 elm_gengrid_item_show(next);
500 _item_single_select_left(Widget_Data *wd)
502 Elm_Gengrid_Item *prev;
505 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
506 while ((prev) && (prev->delete_me))
507 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
509 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
511 if (!prev) return EINA_FALSE;
513 _deselect_all_items(wd);
515 elm_gengrid_item_selected_set(prev, EINA_TRUE);
516 elm_gengrid_item_show(prev);
521 _item_single_select_right(Widget_Data *wd)
523 Elm_Gengrid_Item *next;
526 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
527 while ((next) && (next->delete_me))
528 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
530 else next = elm_gengrid_item_next_get(wd->last_selected_item);
532 if (!next) return EINA_FALSE;
534 _deselect_all_items(wd);
536 elm_gengrid_item_selected_set(next, EINA_TRUE);
537 elm_gengrid_item_show(next);
542 _on_focus_hook(void *data __UNUSED__,
545 Widget_Data *wd = elm_widget_data_get(obj);
547 if (elm_widget_focus_get(obj))
549 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
550 evas_object_focus_set(wd->self, EINA_TRUE);
551 if ((wd->selected) && (!wd->last_selected_item))
552 wd->last_selected_item = eina_list_data_get(wd->selected);
556 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
557 evas_object_focus_set(wd->self, EINA_FALSE);
562 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
564 Widget_Data *wd = elm_widget_data_get(obj);
565 Elm_Gengrid_Item *item;
567 elm_smart_scroller_mirrored_set(wd->scr, rtl);
568 if (!wd->items) return;
569 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
573 edje_object_mirrored_set(item->base.view, rtl);
574 elm_gengrid_item_update(item);
575 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
580 _theme_hook(Evas_Object *obj)
582 Widget_Data *wd = elm_widget_data_get(obj);
584 _elm_widget_mirrored_reload(obj);
585 _mirrored_set(obj, elm_widget_mirrored_get(obj));
586 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
587 elm_widget_style_get(obj));
591 _del_pre_hook(Evas_Object *obj)
593 Widget_Data *wd = elm_widget_data_get(obj);
595 elm_gengrid_clear(obj);
596 evas_object_del(wd->pan_smart);
597 wd->pan_smart = NULL;
601 _del_hook(Evas_Object *obj)
603 Widget_Data *wd = elm_widget_data_get(obj);
608 _signal_emit_hook(Evas_Object *obj,
609 const char *emission,
612 Widget_Data *wd = elm_widget_data_get(obj);
614 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
619 _mouse_move(void *data,
620 Evas *evas __UNUSED__,
624 Elm_Gengrid_Item *item = data;
625 Evas_Event_Mouse_Move *ev = event_info;
626 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
627 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
629 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
631 if (!item->wd->on_hold)
633 item->wd->on_hold = EINA_TRUE;
634 if (!item->wd->wasselected)
635 _item_unselect(item);
638 if ((item->dragging) && (item->down))
640 if (item->long_timer)
642 ecore_timer_del(item->long_timer);
643 item->long_timer = NULL;
645 evas_object_smart_callback_call(item->wd->self, SIG_DRAG, item);
648 if ((!item->down) || (item->wd->longpressed))
650 if (item->long_timer)
652 ecore_timer_del(item->long_timer);
653 item->long_timer = NULL;
655 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
657 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &ow, &oh);
659 it_scrl_x = ev->cur.canvas.x - item->wd->reorder_item->dx;
660 it_scrl_y = ev->cur.canvas.y - item->wd->reorder_item->dy;
662 if (it_scrl_x < ox) item->wd->reorder_item_x = ox;
663 else if (it_scrl_x + item->wd->item_width > ox + ow)
664 item->wd->reorder_item_x = ox + ow - item->wd->item_width;
665 else item->wd->reorder_item_x = it_scrl_x;
667 if (it_scrl_y < oy) item->wd->reorder_item_y = oy;
668 else if (it_scrl_y + item->wd->item_height > oy + oh)
669 item->wd->reorder_item_y = oy + oh - item->wd->item_height;
670 else item->wd->reorder_item_y = it_scrl_y;
672 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
673 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
677 if (!item->display_only)
678 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
679 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
680 x = ev->cur.canvas.x - x;
681 y = ev->cur.canvas.y - y;
684 if (adx < 0) adx = -dx;
687 if (ady < 0) ady = -dy;
690 if ((adx > minw) || (ady > minh))
692 const char *left_drag, *right_drag;
693 if (!elm_widget_mirrored_get(item->wd->self))
695 left_drag = SIG_DRAG_START_LEFT;
696 right_drag = SIG_DRAG_START_RIGHT;
700 left_drag = SIG_DRAG_START_RIGHT;
701 right_drag = SIG_DRAG_START_LEFT;
705 if (item->long_timer)
707 ecore_timer_del(item->long_timer);
708 item->long_timer = NULL;
710 if (!item->wd->wasselected)
711 _item_unselect(item);
715 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_START_UP,
720 evas_object_smart_callback_call(item->wd->self,
727 evas_object_smart_callback_call(item->wd->self,
728 SIG_DRAG_START_DOWN, item);
732 evas_object_smart_callback_call(item->wd->self,
735 evas_object_smart_callback_call(item->wd->self,
743 _long_press(void *data)
745 Elm_Gengrid_Item *item = data;
747 item->long_timer = NULL;
748 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
749 item->wd->longpressed = EINA_TRUE;
750 evas_object_smart_callback_call(item->wd->self, "longpressed", item);
751 if (item->wd->reorder_mode)
753 item->wd->reorder_item = item;
754 evas_object_raise(item->base.view);
755 elm_smart_scroller_hold_set(item->wd->scr, EINA_TRUE);
756 elm_smart_scroller_bounce_allow_set(item->wd->scr, EINA_FALSE, EINA_FALSE);
757 edje_object_signal_emit(item->base.view, "elm,state,reorder,enabled", "elm");
759 return ECORE_CALLBACK_CANCEL;
763 _mouse_down(void *data,
764 Evas *evas __UNUSED__,
768 Elm_Gengrid_Item *item = data;
769 Evas_Event_Mouse_Down *ev = event_info;
772 if (ev->button != 1) return;
775 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
776 item->dx = ev->canvas.x - x;
777 item->dy = ev->canvas.y - y;
778 item->wd->longpressed = EINA_FALSE;
779 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
780 else item->wd->on_hold = EINA_FALSE;
781 item->wd->wasselected = item->selected;
783 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
785 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
786 evas_object_smart_callback_call(item->wd->self, "clicked", item); // will be removed
788 if (item->long_timer) ecore_timer_del(item->long_timer);
790 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
793 item->long_timer = NULL;
797 _mouse_up(void *data,
798 Evas *evas __UNUSED__,
799 Evas_Object *obj __UNUSED__,
802 Elm_Gengrid_Item *item = data;
803 Evas_Event_Mouse_Up *ev = event_info;
804 Eina_Bool dragged = EINA_FALSE;
806 if (ev->button != 1) return;
807 item->down = EINA_FALSE;
808 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
809 else item->wd->on_hold = EINA_FALSE;
810 if (item->long_timer)
812 ecore_timer_del(item->long_timer);
813 item->long_timer = NULL;
817 item->dragging = EINA_FALSE;
818 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_STOP, item);
821 if (item->wd->on_hold)
823 item->wd->longpressed = EINA_FALSE;
824 item->wd->on_hold = EINA_FALSE;
827 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
829 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
830 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
832 evas_object_smart_callback_call(item->wd->self, SIG_MOVED, item->wd->reorder_item);
833 item->wd->reorder_item = NULL;
834 elm_smart_scroller_hold_set(item->wd->scr, EINA_FALSE);
835 elm_smart_scroller_bounce_allow_set(item->wd->scr, item->wd->h_bounce, item->wd->v_bounce);
836 edje_object_signal_emit(item->base.view, "elm,state,reorder,disabled", "elm");
838 if (item->wd->longpressed)
840 item->wd->longpressed = EINA_FALSE;
841 if (!item->wd->wasselected) _item_unselect(item);
842 item->wd->wasselected = EINA_FALSE;
847 if (item->want_unrealize) _item_unrealize(item);
849 if ((item->disabled) || (dragged)) return;
857 else _item_unselect(item);
863 while (item->wd->selected)
864 _item_unselect(item->wd->selected->data);
868 const Eina_List *l, *l_next;
869 Elm_Gengrid_Item *item2;
871 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
872 if (item2 != item) _item_unselect(item2);
880 _item_hilight(Elm_Gengrid_Item *item)
882 if ((item->wd->no_select) || (item->delete_me) || (item->hilighted)) return;
883 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
884 item->hilighted = EINA_TRUE;
888 _item_realize(Elm_Gengrid_Item *item)
893 if ((item->realized) || (item->delete_me)) return;
894 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
895 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
897 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
898 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
899 elm_widget_sub_object_add(item->wd->self, item->base.view);
900 snprintf(style, sizeof(style), "item/%s",
901 item->gic->item_style ? item->gic->item_style : "default");
902 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
903 elm_widget_style_get(item->wd->self));
905 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
906 evas_object_color_set(item->spacer, 0, 0, 0, 0);
907 elm_widget_sub_object_add(item->wd->self, item->spacer);
908 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
909 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
911 if (item->gic->func.label_get)
917 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
919 EINA_LIST_FOREACH(item->labels, l, key)
921 char *s = item->gic->func.label_get
922 ((void *)item->base.data, item->wd->self, l->data);
925 edje_object_part_text_set(item->base.view, l->data, s);
931 if (item->gic->func.icon_get)
937 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
939 EINA_LIST_FOREACH(item->icons, l, key)
941 Evas_Object *ic = item->gic->func.icon_get
942 ((void *)item->base.data, item->wd->self, l->data);
945 item->icon_objs = eina_list_append(item->icon_objs, ic);
946 edje_object_part_swallow(item->base.view, key, ic);
947 evas_object_show(ic);
948 elm_widget_sub_object_add(item->wd->self, ic);
953 if (item->gic->func.state_get)
959 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
961 EINA_LIST_FOREACH(item->states, l, key)
963 Eina_Bool on = item->gic->func.state_get
964 ((void *)item->base.data, item->wd->self, l->data);
967 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
968 edje_object_signal_emit(item->base.view, buf, "elm");
973 if ((!item->wd->item_width) && (!item->wd->item_height))
975 edje_object_size_min_restricted_calc(item->base.view,
976 &item->wd->item_width,
977 &item->wd->item_height,
978 item->wd->item_width,
979 item->wd->item_height);
980 elm_coords_finger_size_adjust(1, &item->wd->item_width,
981 1, &item->wd->item_height);
984 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
986 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
988 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
992 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
994 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
996 evas_object_show(item->base.view);
998 if (item->tooltip.content_cb)
1000 elm_widget_item_tooltip_content_cb_set(item,
1001 item->tooltip.content_cb,
1002 item->tooltip.data, NULL);
1003 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1006 if (item->mouse_cursor)
1007 elm_widget_item_cursor_set(item, item->mouse_cursor);
1009 item->realized = EINA_TRUE;
1010 item->want_unrealize = EINA_FALSE;
1014 _item_unrealize(Elm_Gengrid_Item *item)
1018 if (!item->realized) return;
1019 if (item->long_timer)
1021 ecore_timer_del(item->long_timer);
1022 item->long_timer = NULL;
1024 evas_object_del(item->base.view);
1025 item->base.view = NULL;
1026 evas_object_del(item->spacer);
1027 item->spacer = NULL;
1028 elm_widget_stringlist_free(item->labels);
1029 item->labels = NULL;
1030 elm_widget_stringlist_free(item->icons);
1032 elm_widget_stringlist_free(item->states);
1033 item->states = NULL;
1035 EINA_LIST_FREE(item->icon_objs, icon)
1036 evas_object_del(icon);
1038 item->realized = EINA_FALSE;
1039 item->want_unrealize = EINA_FALSE;
1043 _reorder_item_moving_effect_timer_cb(void *data)
1045 Elm_Gengrid_Item *item = data;
1049 time = REORDER_EFFECT_TIME;
1050 t = ((0.0 > (t = ecore_loop_time_get()-item->moving_effect_start_time)) ? 0.0 : t);
1051 dx = ((item->tx - item->ox) / 10) * _elm_config->scale;
1052 dy = ((item->ty - item->oy) / 10) * _elm_config->scale;
1056 item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
1057 item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
1065 if ((((dx > 0) && (item->rx >= item->tx)) || ((dx <= 0) && (item->rx <= item->tx))) &&
1066 (((dy > 0) && (item->ry >= item->ty)) || ((dy <= 0) && (item->ry <= item->ty))))
1068 evas_object_move(item->base.view, item->tx, item->ty);
1069 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1070 item->moving = EINA_FALSE;
1071 item->item_moving_effect_timer = NULL;
1072 return ECORE_CALLBACK_CANCEL;
1075 evas_object_move(item->base.view, item->rx, item->ry);
1076 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1078 return ECORE_CALLBACK_RENEW;
1082 _item_place(Elm_Gengrid_Item *item,
1086 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh;
1087 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1088 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1091 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1093 /* Preload rows/columns at each side of the Gengrid */
1094 cvx = ox - PRELOAD * item->wd->item_width;
1095 cvy = oy - PRELOAD * item->wd->item_height;
1096 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1097 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1102 if (item->wd->horizontal)
1104 int columns, items_visible = 0, items_row;
1106 if (item->wd->item_height > 0)
1107 items_visible = vh / item->wd->item_height;
1108 if (items_visible < 1)
1111 columns = item->wd->count / items_visible;
1112 if (item->wd->count % items_visible)
1115 tcw = item->wd->item_width * columns;
1116 alignw = (vw - tcw) * item->wd->align_x;
1118 items_row = items_visible;
1119 if (items_row > item->wd->count)
1120 items_row = item->wd->count;
1121 tch = items_row * item->wd->item_height;
1122 alignh = (vh - tch) * item->wd->align_y;
1126 int rows, items_visible = 0, items_col;
1128 if (item->wd->item_width > 0)
1129 items_visible = vw / item->wd->item_width;
1130 if (items_visible < 1)
1133 rows = item->wd->count / items_visible;
1134 if (item->wd->count % items_visible)
1137 tch = item->wd->item_height * rows;
1138 alignh = (vh - tch) * item->wd->align_y;
1140 items_col = items_visible;
1141 if (items_col > item->wd->count)
1142 items_col = item->wd->count;
1143 tcw = items_col * item->wd->item_width;
1144 alignw = (vw - tcw) * item->wd->align_x;
1147 x = cx * item->wd->item_width - item->wd->pan_x + ox + alignw;
1148 if (elm_widget_mirrored_get(item->wd->self))
1149 { /* Switch items side and componsate for pan_x when in RTL mode */
1151 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1152 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1155 y = cy * item->wd->item_height - item->wd->pan_y + oy + alignh;
1157 Eina_Bool was_realized = item->realized;
1158 if (ELM_RECTS_INTERSECT(x, y, item->wd->item_width, item->wd->item_height,
1159 cvx, cvy, cvw, cvh))
1161 _item_realize(item);
1163 evas_object_smart_callback_call(item->wd->self, SIG_REALIZED, item);
1164 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
1166 if (item->moving) return;
1168 if (!item->wd->move_effect_enabled)
1173 if (item->wd->reorder_item == item)
1175 evas_object_move(item->base.view,
1176 item->wd->reorder_item_x, item->wd->reorder_item_y);
1177 evas_object_resize(item->base.view,
1178 item->wd->item_width, item->wd->item_height);
1183 if (item->wd->move_effect_enabled)
1185 if ((item->ox != x) || (item->oy != y))
1187 if (((item->wd->old_pan_x == item->wd->pan_x) && (item->wd->old_pan_y == item->wd->pan_y)) ||
1188 ((item->wd->old_pan_x != item->wd->pan_x) && !(item->ox - item->wd->pan_x + item->wd->old_pan_x == x)) ||
1189 ((item->wd->old_pan_y != item->wd->pan_y) && !(item->oy - item->wd->pan_y + item->wd->old_pan_y == y)))
1193 item->rx = item->ox;
1194 item->ry = item->oy;
1195 item->moving = EINA_TRUE;
1196 item->moving_effect_start_time = ecore_loop_time_get();
1197 item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, item);
1203 if (ELM_RECTS_INTERSECT(item->wd->reorder_item_x, item->wd->reorder_item_y,
1204 item->wd->item_width, item->wd->item_height,
1205 x+(item->wd->item_width/2), y+(item->wd->item_height/2),
1208 if (item->wd->horizontal)
1210 if ((item->wd->nmax * item->wd->reorder_item->x + item->wd->reorder_item->y) >
1211 (item->wd->nmax * item->x + item->y))
1212 reorder_item_move_forward = EINA_TRUE;
1216 if ((item->wd->nmax * item->wd->reorder_item->y + item->wd->reorder_item->x) >
1217 (item->wd->nmax * item->y + item->x))
1218 reorder_item_move_forward = EINA_TRUE;
1221 item->wd->items = eina_inlist_remove(item->wd->items,
1222 EINA_INLIST_GET(item->wd->reorder_item));
1223 if (reorder_item_move_forward)
1224 item->wd->items = eina_inlist_prepend_relative(item->wd->items,
1225 EINA_INLIST_GET(item->wd->reorder_item),
1226 EINA_INLIST_GET(item));
1228 item->wd->items = eina_inlist_append_relative(item->wd->items,
1229 EINA_INLIST_GET(item->wd->reorder_item),
1230 EINA_INLIST_GET(item));
1232 item->wd->reorder_item_changed = EINA_TRUE;
1233 item->wd->move_effect_enabled = EINA_TRUE;
1234 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1235 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1241 evas_object_move(item->base.view, x, y);
1242 evas_object_resize(item->base.view, item->wd->item_width,
1243 item->wd->item_height);
1247 _item_unrealize(item);
1249 evas_object_smart_callback_call(item->wd->self, SIG_UNREALIZED, item);
1253 static Elm_Gengrid_Item *
1254 _item_create(Widget_Data *wd,
1255 const Elm_Gengrid_Item_Class *gic,
1258 const void *func_data)
1260 Elm_Gengrid_Item *item;
1262 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1263 if (!item) return NULL;
1267 item->base.data = data;
1268 item->func.func = func;
1269 item->func.data = func_data;
1270 item->mouse_cursor = NULL;
1275 _item_del(Elm_Gengrid_Item *item)
1277 elm_widget_item_pre_notify_del(item);
1279 item->wd->selected = eina_list_remove(item->wd->selected, item);
1280 if (item->realized) _item_unrealize(item);
1281 if ((!item->delete_me) && (item->gic->func.del))
1282 item->gic->func.del((void *)item->base.data, item->wd->self);
1283 item->delete_me = EINA_TRUE;
1284 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1285 if (item->long_timer) ecore_timer_del(item->long_timer);
1286 if (item->tooltip.del_cb)
1287 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1288 item->wd->walking -= item->walking;
1290 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1291 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1292 elm_widget_item_del(item);
1296 _item_select(Elm_Gengrid_Item *item)
1298 if ((item->wd->no_select) || (item->delete_me)) return;
1301 if (item->wd->always_select) goto call;
1304 item->selected = EINA_TRUE;
1305 item->wd->selected = eina_list_append(item->wd->selected, item);
1308 item->wd->walking++;
1309 if (item->func.func)
1310 item->func.func((void *)item->func.data, item->wd->self, item);
1311 if (!item->delete_me)
1312 evas_object_smart_callback_call(item->wd->self, SIG_SELECTED, item);
1314 item->wd->walking--;
1315 item->wd->last_selected_item = item;
1316 if ((item->wd->clear_me) && (!item->wd->walking))
1317 elm_gengrid_clear(item->base.widget);
1320 if ((!item->walking) && (item->delete_me))
1321 if (!item->relcount) _item_del(item);
1326 _item_unselect(Elm_Gengrid_Item *item)
1328 if ((item->delete_me) || (!item->hilighted)) return;
1329 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1330 item->hilighted = EINA_FALSE;
1333 item->selected = EINA_FALSE;
1334 item->wd->selected = eina_list_remove(item->wd->selected, item);
1335 evas_object_smart_callback_call(item->wd->self, SIG_UNSELECTED, item);
1340 _calc_job(void *data)
1342 Widget_Data *wd = data;
1343 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1346 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1347 if ((cvw != 0) || (cvh != 0))
1349 if ((wd->horizontal) && (wd->item_height > 0))
1350 nmax = cvh / wd->item_height;
1351 else if (wd->item_width > 0)
1352 nmax = cvw / wd->item_width;
1360 minw = ceil(count / (float)nmax) * wd->item_width;
1361 minh = nmax * wd->item_height;
1365 minw = nmax * wd->item_width;
1366 minh = ceil(count / (float)nmax) * wd->item_height;
1369 if ((minw != wd->minw) || (minh != wd->minh))
1373 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1377 evas_object_smart_changed(wd->pan_smart);
1379 wd->calc_job = NULL;
1383 _pan_add(Evas_Object *obj)
1386 Evas_Object_Smart_Clipped_Data *cd;
1389 cd = evas_object_smart_data_get(obj);
1392 sd->__clipped_data = *cd;
1394 evas_object_smart_data_set(obj, sd);
1398 _pan_del(Evas_Object *obj)
1400 Pan *sd = evas_object_smart_data_get(obj);
1407 _pan_set(Evas_Object *obj,
1411 Pan *sd = evas_object_smart_data_get(obj);
1412 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1415 evas_object_smart_changed(obj);
1419 _pan_get(Evas_Object *obj,
1423 Pan *sd = evas_object_smart_data_get(obj);
1424 if (x) *x = sd->wd->pan_x;
1425 if (y) *y = sd->wd->pan_y;
1429 _pan_child_size_get(Evas_Object *obj,
1433 Pan *sd = evas_object_smart_data_get(obj);
1434 if (w) *w = sd->wd->minw;
1435 if (h) *h = sd->wd->minh;
1439 _pan_max_get(Evas_Object *obj,
1443 Pan *sd = evas_object_smart_data_get(obj);
1447 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1449 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1451 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1455 _pan_min_get(Evas_Object *obj,
1459 Pan *sd = evas_object_smart_data_get(obj);
1463 _pan_max_get(obj, &mx, &my);
1465 *x = -mx * sd->wd->align_x;
1467 *y = -my * sd->wd->align_y;
1471 _pan_resize(Evas_Object *obj,
1475 Pan *sd = evas_object_smart_data_get(obj);
1478 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1479 if ((ow == w) && (oh == h)) return;
1480 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1481 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1485 _pan_calculate(Evas_Object *obj)
1487 Pan *sd = evas_object_smart_data_get(obj);
1488 Evas_Coord cx = 0, cy = 0;
1489 Elm_Gengrid_Item *item;
1492 if (!sd->wd->nmax) return;
1494 sd->wd->reorder_item_changed = EINA_FALSE;
1496 EINA_INLIST_FOREACH(sd->wd->items, item)
1498 _item_place(item, cx, cy);
1499 if (sd->wd->reorder_item_changed) return;
1500 if (sd->wd->horizontal)
1502 cy = (cy + 1) % sd->wd->nmax;
1507 cx = (cx + 1) % sd->wd->nmax;
1512 if ((sd->wd->reorder_mode) && (sd->wd->reorder_item))
1514 if (!sd->wd->reorder_item_changed)
1516 sd->wd->old_pan_x = sd->wd->pan_x;
1517 sd->wd->old_pan_y = sd->wd->pan_y;
1519 sd->wd->move_effect_enabled = EINA_FALSE;
1521 evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
1525 _pan_move(Evas_Object *obj,
1526 Evas_Coord x __UNUSED__,
1527 Evas_Coord y __UNUSED__)
1529 Pan *sd = evas_object_smart_data_get(obj);
1531 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1532 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1536 _hold_on(void *data __UNUSED__,
1538 void *event_info __UNUSED__)
1540 Widget_Data *wd = elm_widget_data_get(obj);
1542 elm_smart_scroller_hold_set(wd->scr, 1);
1546 _hold_off(void *data __UNUSED__,
1548 void *event_info __UNUSED__)
1550 Widget_Data *wd = elm_widget_data_get(obj);
1552 elm_smart_scroller_hold_set(wd->scr, 0);
1556 _freeze_on(void *data __UNUSED__,
1558 void *event_info __UNUSED__)
1560 Widget_Data *wd = elm_widget_data_get(obj);
1562 elm_smart_scroller_freeze_set(wd->scr, 1);
1566 _freeze_off(void *data __UNUSED__,
1568 void *event_info __UNUSED__)
1570 Widget_Data *wd = elm_widget_data_get(obj);
1572 elm_smart_scroller_freeze_set(wd->scr, 0);
1576 _scr_drag_start(void *data,
1577 Evas_Object *obj __UNUSED__,
1578 void *event_info __UNUSED__)
1580 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1584 _scr_drag_stop(void *data,
1585 Evas_Object *obj __UNUSED__,
1586 void *event_info __UNUSED__)
1588 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1592 _scr_scroll(void *data,
1593 Evas_Object *obj __UNUSED__,
1594 void *event_info __UNUSED__)
1596 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1600 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1602 const Elm_Gengrid_Item *item = data;
1603 const Elm_Gengrid_Item *item1 = data1;
1605 return _elm_gengrid_item_compare_data_cb(item->base.data, item1->base.data);
1609 _elm_gengrid_item_compare(const void *data, const void *data1)
1611 Elm_Gengrid_Item *item, *item1;
1612 item = ELM_GENGRID_ITEM_FROM_INLIST(data);
1613 item1 = ELM_GENGRID_ITEM_FROM_INLIST(data1);
1614 return _elm_gengrid_item_compare_cb(item, item1);
1618 elm_gengrid_add(Evas_Object *parent)
1623 static Evas_Smart *smart = NULL;
1624 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1626 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1628 ELM_SET_WIDTYPE(widtype, "gengrid");
1629 elm_widget_type_set(obj, "gengrid");
1630 elm_widget_sub_object_add(parent, obj);
1631 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1632 elm_widget_data_set(obj, wd);
1633 elm_widget_del_hook_set(obj, _del_hook);
1634 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1635 elm_widget_theme_hook_set(obj, _theme_hook);
1636 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1637 elm_widget_can_focus_set(obj, EINA_TRUE);
1638 elm_widget_event_hook_set(obj, _event_hook);
1640 wd->scr = elm_smart_scroller_add(e);
1641 elm_smart_scroller_widget_set(wd->scr, obj);
1642 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1644 elm_widget_resize_object_set(obj, wd->scr);
1646 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1647 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1648 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1650 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1655 wd->h_bounce = bounce;
1656 wd->v_bounce = bounce;
1657 wd->no_select = EINA_FALSE;
1659 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1660 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1661 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1662 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1664 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1668 static Evas_Smart_Class sc;
1670 evas_object_smart_clipped_smart_set(&_pan_sc);
1672 sc.name = "elm_gengrid_pan";
1673 sc.version = EVAS_SMART_CLASS_VERSION;
1676 sc.resize = _pan_resize;
1677 sc.move = _pan_move;
1678 sc.calculate = _pan_calculate;
1679 smart = evas_smart_class_new(&sc);
1683 wd->pan_smart = evas_object_smart_add(e, smart);
1684 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1688 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1689 _pan_set, _pan_get, _pan_max_get,
1690 _pan_min_get, _pan_child_size_get);
1692 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1697 elm_gengrid_item_size_set(Evas_Object *obj,
1701 ELM_CHECK_WIDTYPE(obj, widtype);
1702 Widget_Data *wd = elm_widget_data_get(obj);
1704 if ((wd->item_width == w) && (wd->item_height == h)) return;
1706 wd->item_height = h;
1707 if (wd->calc_job) ecore_job_del(wd->calc_job);
1708 wd->calc_job = ecore_job_add(_calc_job, wd);
1712 elm_gengrid_item_size_get(const Evas_Object *obj,
1716 ELM_CHECK_WIDTYPE(obj, widtype);
1717 Widget_Data *wd = elm_widget_data_get(obj);
1719 if (w) *w = wd->item_width;
1720 if (h) *h = wd->item_height;
1724 elm_gengrid_align_set(Evas_Object *obj,
1728 ELM_CHECK_WIDTYPE(obj, widtype);
1730 Widget_Data *wd = elm_widget_data_get(obj);
1731 double old_h = wd->align_x, old_y = wd->align_y;
1735 else if (align_x < 0.0)
1737 wd->align_x = align_x;
1741 else if (align_y < 0.0)
1743 wd->align_y = align_y;
1745 if ((old_h != wd->align_x) || (old_y != wd->align_y))
1746 evas_object_smart_calculate(wd->pan_smart);
1750 elm_gengrid_align_get(const Evas_Object *obj,
1754 ELM_CHECK_WIDTYPE(obj, widtype);
1755 Widget_Data *wd = elm_widget_data_get(obj);
1756 if (align_x) *align_x = wd->align_x;
1757 if (align_y) *align_y = wd->align_y;
1760 EAPI Elm_Gengrid_Item *
1761 elm_gengrid_item_append(Evas_Object *obj,
1762 const Elm_Gengrid_Item_Class *gic,
1765 const void *func_data)
1767 Elm_Gengrid_Item *item;
1768 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1769 Widget_Data *wd = elm_widget_data_get(obj);
1770 if (!wd) return NULL;
1772 item = _item_create(wd, gic, data, func, func_data);
1773 if (!item) return NULL;
1774 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
1776 if (wd->calc_job) ecore_job_del(wd->calc_job);
1777 wd->calc_job = ecore_job_add(_calc_job, wd);
1782 EAPI Elm_Gengrid_Item *
1783 elm_gengrid_item_prepend(Evas_Object *obj,
1784 const Elm_Gengrid_Item_Class *gic,
1787 const void *func_data)
1789 Elm_Gengrid_Item *item;
1790 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1791 Widget_Data *wd = elm_widget_data_get(obj);
1792 if (!wd) return NULL;
1794 item = _item_create(wd, gic, data, func, func_data);
1795 if (!item) return NULL;
1796 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
1798 if (wd->calc_job) ecore_job_del(wd->calc_job);
1799 wd->calc_job = ecore_job_add(_calc_job, wd);
1804 EAPI Elm_Gengrid_Item *
1805 elm_gengrid_item_insert_before(Evas_Object *obj,
1806 const Elm_Gengrid_Item_Class *gic,
1808 Elm_Gengrid_Item *relative,
1810 const void *func_data)
1812 Elm_Gengrid_Item *item;
1813 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1814 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1815 Widget_Data *wd = elm_widget_data_get(obj);
1816 if (!wd) return NULL;
1818 item = _item_create(wd, gic, data, func, func_data);
1819 if (!item) return NULL;
1820 wd->items = eina_inlist_prepend_relative
1821 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1823 if (wd->calc_job) ecore_job_del(wd->calc_job);
1824 wd->calc_job = ecore_job_add(_calc_job, wd);
1829 EAPI Elm_Gengrid_Item *
1830 elm_gengrid_item_insert_after(Evas_Object *obj,
1831 const Elm_Gengrid_Item_Class *gic,
1833 Elm_Gengrid_Item *relative,
1835 const void *func_data)
1837 Elm_Gengrid_Item *item;
1838 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1839 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1840 Widget_Data *wd = elm_widget_data_get(obj);
1841 if (!wd) return NULL;
1843 item = _item_create(wd, gic, data, func, func_data);
1844 if (!item) return NULL;
1845 wd->items = eina_inlist_append_relative
1846 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1848 if (wd->calc_job) ecore_job_del(wd->calc_job);
1849 wd->calc_job = ecore_job_add(_calc_job, wd);
1854 EAPI Elm_Gengrid_Item *
1855 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
1856 const Elm_Gengrid_Item_Class *gic,
1858 Eina_Compare_Cb comp,
1860 const void *func_data)
1862 Elm_Gengrid_Item *item;
1863 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1864 Widget_Data *wd = elm_widget_data_get(obj);
1865 if (!wd) return NULL;
1867 item = _item_create(wd, gic, data, func, func_data);
1868 if (!item) return NULL;
1870 _elm_gengrid_item_compare_cb = comp;
1871 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(item),
1872 _elm_gengrid_item_compare);
1873 if (wd->calc_job) ecore_job_del(wd->calc_job);
1874 wd->calc_job = ecore_job_add(_calc_job, wd);
1879 EAPI Elm_Gengrid_Item *
1880 elm_gengrid_item_sorted_insert(Evas_Object *obj,
1881 const Elm_Gengrid_Item_Class *gic,
1883 Eina_Compare_Cb comp,
1885 const void *func_data)
1887 _elm_gengrid_item_compare_data_cb = comp;
1889 return elm_gengrid_item_direct_sorted_insert(obj, gic, data, _elm_gengrid_item_compare_data, func, func_data);
1893 elm_gengrid_item_del(Elm_Gengrid_Item *item)
1895 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1896 if ((item->relcount > 0) || (item->walking > 0))
1898 item->delete_me = EINA_TRUE;
1899 elm_widget_item_pre_notify_del(item);
1901 item->wd->selected = eina_list_remove(item->wd->selected, item);
1902 if (item->gic->func.del)
1903 item->gic->func.del((void *)item->base.data, item->wd->self);
1911 elm_gengrid_horizontal_set(Evas_Object *obj,
1914 ELM_CHECK_WIDTYPE(obj, widtype);
1915 Widget_Data *wd = elm_widget_data_get(obj);
1917 if (setting == wd->horizontal) return;
1918 wd->horizontal = setting;
1920 /* Update the items to conform to the new layout */
1921 if (wd->calc_job) ecore_job_del(wd->calc_job);
1922 wd->calc_job = ecore_job_add(_calc_job, wd);
1926 elm_gengrid_horizontal_get(const Evas_Object *obj)
1928 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1929 Widget_Data *wd = elm_widget_data_get(obj);
1930 if (!wd) return EINA_FALSE;
1931 return wd->horizontal;
1935 elm_gengrid_clear(Evas_Object *obj)
1937 ELM_CHECK_WIDTYPE(obj, widtype);
1938 Widget_Data *wd = elm_widget_data_get(obj);
1943 ecore_job_del(wd->calc_job);
1944 wd->calc_job = NULL;
1947 if (wd->walking > 0)
1949 Elm_Gengrid_Item *item;
1951 EINA_INLIST_FOREACH(wd->items, item)
1952 item->delete_me = 1;
1958 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
1960 wd->items = eina_inlist_remove(wd->items, wd->items);
1961 elm_widget_item_pre_notify_del(item);
1962 if (item->realized) _item_unrealize(item);
1963 if (item->gic->func.del)
1964 item->gic->func.del((void *)item->base.data, wd->self);
1965 if (item->long_timer) ecore_timer_del(item->long_timer);
1966 elm_widget_item_del(item);
1971 eina_list_free(wd->selected);
1972 wd->selected = NULL;
1980 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
1981 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1984 EAPI const Evas_Object *
1985 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
1987 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1988 return item->base.view;
1992 elm_gengrid_item_update(Elm_Gengrid_Item *item)
1994 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1995 if (!item->realized) return;
1996 if (item->want_unrealize) return;
1997 _item_unrealize(item);
1998 _item_realize(item);
1999 _item_place(item, item->x, item->y);
2003 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2005 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2006 return elm_widget_item_data_get(item);
2010 * Set the data item from the gengrid item
2012 * This sets the data value passed on the elm_gengrid_item_append() and
2013 * related item addition calls. This function will not call
2014 * elm_gengrid_item_update() anymore. So call elm_gengrid_item_update()
2015 * manually only when it's needed.
2017 * @param item The item
2018 * @param data The new data pointer to set
2023 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2026 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2027 elm_widget_item_data_set(item, data);
2030 EAPI const Elm_Gengrid_Item_Class *
2031 elm_gengrid_item_item_class_get(const Elm_Gengrid_Item *item)
2033 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2034 if (item->delete_me) return NULL;
2039 elm_gengrid_item_item_class_set(Elm_Gengrid_Item *item,
2040 const Elm_Gengrid_Item_Class *gic)
2042 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2043 EINA_SAFETY_ON_NULL_RETURN(gic);
2044 if (item->delete_me) return;
2046 elm_gengrid_item_update(item);
2050 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2054 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2055 if (x) *x = item->x;
2056 if (y) *y = item->y;
2060 elm_gengrid_multi_select_set(Evas_Object *obj,
2063 ELM_CHECK_WIDTYPE(obj, widtype);
2064 Widget_Data *wd = elm_widget_data_get(obj);
2070 elm_gengrid_multi_select_get(const Evas_Object *obj)
2072 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2073 Widget_Data *wd = elm_widget_data_get(obj);
2074 if (!wd) return EINA_FALSE;
2078 EAPI Elm_Gengrid_Item *
2079 elm_gengrid_selected_item_get(const Evas_Object *obj)
2081 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2082 Widget_Data *wd = elm_widget_data_get(obj);
2083 if (!wd) return NULL;
2084 if (wd->selected) return wd->selected->data;
2088 EAPI const Eina_List *
2089 elm_gengrid_selected_items_get(const Evas_Object *obj)
2091 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2092 Widget_Data *wd = elm_widget_data_get(obj);
2093 if (!wd) return NULL;
2094 return wd->selected;
2098 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2101 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2102 Widget_Data *wd = item->wd;
2104 if (item->delete_me) return;
2105 selected = !!selected;
2106 if (item->selected == selected) return;
2112 while (wd->selected)
2113 _item_unselect(wd->selected->data);
2115 _item_hilight(item);
2119 _item_unselect(item);
2123 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2125 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2126 return item->selected;
2130 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2133 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2134 if (item->disabled == disabled) return;
2135 if (item->delete_me) return;
2136 item->disabled = !!disabled;
2140 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2142 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2147 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2149 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2150 if (item->delete_me) return EINA_FALSE;
2151 return item->disabled;
2154 static Evas_Object *
2155 _elm_gengrid_item_label_create(void *data,
2157 void *item __UNUSED__)
2159 Evas_Object *label = elm_label_add(obj);
2162 elm_object_style_set(label, "tooltip");
2163 elm_object_text_set(label, data);
2168 _elm_gengrid_item_label_del_cb(void *data,
2169 Evas_Object *obj __UNUSED__,
2170 void *event_info __UNUSED__)
2172 eina_stringshare_del(data);
2176 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2179 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2180 text = eina_stringshare_add(text);
2181 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2183 _elm_gengrid_item_label_del_cb);
2187 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2188 Elm_Tooltip_Item_Content_Cb func,
2190 Evas_Smart_Cb del_cb)
2192 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2194 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2197 if (item->tooltip.del_cb)
2198 item->tooltip.del_cb((void *)item->tooltip.data,
2199 item->base.widget, item);
2200 item->tooltip.content_cb = func;
2201 item->tooltip.data = data;
2202 item->tooltip.del_cb = del_cb;
2203 if (item->base.view)
2205 elm_widget_item_tooltip_content_cb_set(item,
2206 item->tooltip.content_cb,
2207 item->tooltip.data, NULL);
2208 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2214 if (del_cb) del_cb((void *)data, NULL, NULL);
2218 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2220 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2221 if ((item->base.view) && (item->tooltip.content_cb))
2222 elm_widget_item_tooltip_unset(item);
2224 if (item->tooltip.del_cb)
2225 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2226 item->tooltip.del_cb = NULL;
2227 item->tooltip.content_cb = NULL;
2228 item->tooltip.data = NULL;
2229 if (item->tooltip.style)
2230 elm_gengrid_item_tooltip_style_set(item, NULL);
2234 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2237 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2238 eina_stringshare_replace(&item->tooltip.style, style);
2239 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2243 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2245 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2246 return item->tooltip.style;
2250 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2253 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2254 eina_stringshare_replace(&item->mouse_cursor, cursor);
2255 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2259 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2261 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2262 return elm_widget_item_cursor_get(item);
2266 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2268 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2269 if (!item->mouse_cursor)
2272 if (item->base.view)
2273 elm_widget_item_cursor_unset(item);
2275 eina_stringshare_del(item->mouse_cursor);
2276 item->mouse_cursor = NULL;
2280 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2283 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2284 elm_widget_item_cursor_style_set(item, style);
2288 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2290 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2291 return elm_widget_item_cursor_style_get(item);
2295 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2296 Eina_Bool engine_only)
2298 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2299 elm_widget_item_cursor_engine_only_set(item, engine_only);
2303 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2305 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2306 return elm_widget_item_cursor_engine_only_get(item);
2310 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2311 Eina_Bool reorder_mode)
2313 ELM_CHECK_WIDTYPE(obj, widtype);
2314 Widget_Data *wd = elm_widget_data_get(obj);
2316 wd->reorder_mode = reorder_mode;
2320 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2322 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2323 Widget_Data *wd = elm_widget_data_get(obj);
2324 if (!wd) return EINA_FALSE;
2325 return wd->reorder_mode;
2329 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2330 Eina_Bool always_select)
2332 ELM_CHECK_WIDTYPE(obj, widtype);
2333 Widget_Data *wd = elm_widget_data_get(obj);
2335 wd->always_select = always_select;
2339 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2341 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2342 Widget_Data *wd = elm_widget_data_get(obj);
2343 if (!wd) return EINA_FALSE;
2344 return wd->always_select;
2348 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2349 Eina_Bool no_select)
2351 ELM_CHECK_WIDTYPE(obj, widtype);
2352 Widget_Data *wd = elm_widget_data_get(obj);
2354 wd->no_select = no_select;
2358 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2360 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2361 Widget_Data *wd = elm_widget_data_get(obj);
2362 if (!wd) return EINA_FALSE;
2363 return wd->no_select;
2367 elm_gengrid_bounce_set(Evas_Object *obj,
2371 ELM_CHECK_WIDTYPE(obj, widtype);
2372 Widget_Data *wd = elm_widget_data_get(obj);
2374 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2375 wd->h_bounce = h_bounce;
2376 wd->v_bounce = v_bounce;
2380 elm_gengrid_bounce_get(const Evas_Object *obj,
2381 Eina_Bool *h_bounce,
2382 Eina_Bool *v_bounce)
2384 ELM_CHECK_WIDTYPE(obj, widtype);
2385 Widget_Data *wd = elm_widget_data_get(obj);
2387 if (h_bounce) *h_bounce = wd->h_bounce;
2388 if (v_bounce) *v_bounce = wd->v_bounce;
2392 elm_gengrid_page_relative_set(Evas_Object *obj,
2396 Evas_Coord pagesize_h;
2397 Evas_Coord pagesize_v;
2399 ELM_CHECK_WIDTYPE(obj, widtype);
2400 Widget_Data *wd = elm_widget_data_get(obj);
2403 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
2404 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
2409 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2411 ELM_CHECK_WIDTYPE(obj, widtype);
2412 Widget_Data *wd = elm_widget_data_get(obj);
2415 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
2419 elm_gengrid_page_size_set(Evas_Object *obj,
2420 Evas_Coord h_pagesize,
2421 Evas_Coord v_pagesize)
2426 ELM_CHECK_WIDTYPE(obj, widtype);
2427 Widget_Data *wd = elm_widget_data_get(obj);
2429 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
2430 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
2434 EAPI Elm_Gengrid_Item *
2435 elm_gengrid_first_item_get(const Evas_Object *obj)
2437 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2438 Widget_Data *wd = elm_widget_data_get(obj);
2439 if (!wd) return NULL;
2440 if (!wd->items) return NULL;
2441 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2442 while ((item) && (item->delete_me))
2443 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2447 EAPI Elm_Gengrid_Item *
2448 elm_gengrid_last_item_get(const Evas_Object *obj)
2450 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2451 Widget_Data *wd = elm_widget_data_get(obj);
2452 if (!wd) return NULL;
2453 if (!wd->items) return NULL;
2454 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
2455 while ((item) && (item->delete_me))
2456 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2460 EAPI Elm_Gengrid_Item *
2461 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
2463 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2466 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2467 if ((item) && (!item->delete_me)) break;
2469 return (Elm_Gengrid_Item *)item;
2472 EAPI Elm_Gengrid_Item *
2473 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
2475 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2478 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2479 if ((item) && (!item->delete_me)) break;
2481 return (Elm_Gengrid_Item *)item;
2485 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
2487 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2488 return item->base.widget;
2492 elm_gengrid_item_show(Elm_Gengrid_Item *item)
2494 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2495 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2496 Evas_Coord minx = 0, miny = 0;
2499 if ((!item) || (item->delete_me)) return;
2500 _pan_min_get(wd->pan_smart, &minx, &miny);
2502 elm_smart_scroller_child_region_show(item->wd->scr,
2503 item->x * wd->item_width + minx,
2504 item->y * wd->item_height + miny,
2505 item->wd->item_width,
2506 item->wd->item_height);
2510 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
2512 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2513 if (item->delete_me) return;
2515 Evas_Coord minx = 0, miny = 0;
2516 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2518 _pan_min_get(wd->pan_smart, &minx, &miny);
2520 elm_smart_scroller_region_bring_in(item->wd->scr,
2521 item->x * wd->item_width + minx,
2522 item->y * wd->item_height + miny,
2523 item->wd->item_width,
2524 item->wd->item_height);