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;
43 Eina_Bool free_size : 1;
46 const char *mouse_cursor;
48 Eina_Bool want_unrealize : 1;
49 Eina_Bool realized : 1;
50 Eina_Bool dragging : 1;
52 Eina_Bool delete_me : 1;
53 Eina_Bool display_only : 1;
54 Eina_Bool disabled : 1;
55 Eina_Bool selected : 1;
56 Eina_Bool hilighted : 1;
62 Evas_Object *self, *scr;
63 Evas_Object *pan_smart;
68 Elm_Gengrid_Item *last_selected_item, *reorder_item;
69 double align_x, align_y;
71 Evas_Coord pan_x, pan_y, old_pan_x, old_pan_y;
72 Evas_Coord item_width, item_height; /* Each item size */
73 Evas_Coord minw, minh; /* Total obj size */
74 Evas_Coord reorder_item_x, reorder_item_y;
79 Eina_Bool horizontal : 1;
80 Eina_Bool on_hold : 1;
81 Eina_Bool longpressed : 1;
83 Eina_Bool no_select : 1;
84 Eina_Bool wasselected : 1;
85 Eina_Bool always_select : 1;
86 Eina_Bool clear_me : 1;
87 Eina_Bool h_bounce : 1;
88 Eina_Bool v_bounce : 1;
89 Eina_Bool reorder_mode : 1;
90 Eina_Bool reorder_item_changed : 1;
91 Eina_Bool move_effect_enabled : 1;
94 #define ELM_GENGRID_ITEM_FROM_INLIST(item) \
95 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
99 Evas_Object_Smart_Clipped_Data __clipped_data;
103 static const char *widtype = NULL;
104 static void _item_hilight(Elm_Gengrid_Item *item);
105 static void _item_unrealize(Elm_Gengrid_Item *item);
106 static void _item_select(Elm_Gengrid_Item *item);
107 static void _item_unselect(Elm_Gengrid_Item *item);
108 static void _calc_job(void *data);
109 static void _on_focus_hook(void *data,
111 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
112 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
113 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
114 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
115 static Eina_Bool _item_single_select_up(Widget_Data *wd);
116 static Eina_Bool _item_single_select_down(Widget_Data *wd);
117 static Eina_Bool _item_single_select_left(Widget_Data *wd);
118 static Eina_Bool _item_single_select_right(Widget_Data *wd);
119 static Eina_Bool _event_hook(Evas_Object *obj,
121 Evas_Callback_Type type,
123 static Eina_Bool _deselect_all_items(Widget_Data *wd);
125 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
126 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
128 static const char SIG_ACTIVATED[] = "activated";
129 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
130 static const char SIG_SELECTED[] = "selected";
131 static const char SIG_UNSELECTED[] = "unselected";
132 static const char SIG_REALIZED[] = "realized";
133 static const char SIG_UNREALIZED[] = "unrealized";
134 static const char SIG_CHANGED[] = "changed";
135 static const char SIG_DRAG_START_UP[] = "drag,start,up";
136 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
137 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
138 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
139 static const char SIG_DRAG_STOP[] = "drag,stop";
140 static const char SIG_DRAG[] = "drag";
141 static const char SIG_SCROLL[] = "scroll";
142 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
143 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
144 static const char SIG_MOVED[] = "moved";
146 static const Evas_Smart_Cb_Description _signals[] = {
148 {SIG_CLICKED_DOUBLE, ""},
150 {SIG_UNSELECTED, ""},
152 {SIG_UNREALIZED, ""},
154 {SIG_DRAG_START_UP, ""},
155 {SIG_DRAG_START_DOWN, ""},
156 {SIG_DRAG_START_LEFT, ""},
157 {SIG_DRAG_START_RIGHT, ""},
161 {SIG_SCROLL_DRAG_START, ""},
162 {SIG_SCROLL_DRAG_STOP, ""},
167 static Eina_Compare_Cb _elm_gengrid_item_compare_cb;
168 static Eina_Compare_Cb _elm_gengrid_item_compare_data_cb;
171 _event_hook(Evas_Object *obj,
172 Evas_Object *src __UNUSED__,
173 Evas_Callback_Type type,
176 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
177 Evas_Event_Key_Down *ev = event_info;
178 Widget_Data *wd = elm_widget_data_get(obj);
179 if (!wd) return EINA_FALSE;
180 if (!wd->items) return EINA_FALSE;
181 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
182 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
184 Elm_Gengrid_Item *item = NULL;
187 Evas_Coord step_x = 0;
188 Evas_Coord step_y = 0;
191 Evas_Coord page_x = 0;
192 Evas_Coord page_y = 0;
194 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
195 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
196 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
197 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
199 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
201 if ((wd->horizontal) &&
202 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
203 (_item_multi_select_up(wd)))
204 || (_item_single_select_up(wd))))
206 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
209 else if ((!wd->horizontal) &&
210 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
211 (_item_multi_select_left(wd)))
212 || (_item_single_select_left(wd))))
214 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
220 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
222 if ((wd->horizontal) &&
223 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
224 (_item_multi_select_down(wd)))
225 || (_item_single_select_down(wd))))
227 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
230 else if ((!wd->horizontal) &&
231 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
232 (_item_multi_select_right(wd)))
233 || (_item_single_select_right(wd))))
235 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
241 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
243 if ((wd->horizontal) &&
244 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
245 (_item_multi_select_left(wd)))
246 || (_item_single_select_left(wd))))
248 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
251 else if ((!wd->horizontal) &&
252 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
253 (_item_multi_select_up(wd)))
254 || (_item_single_select_up(wd))))
256 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
262 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
264 if ((wd->horizontal) &&
265 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
266 (_item_multi_select_right(wd)))
267 || (_item_single_select_right(wd))))
269 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
272 else if ((!wd->horizontal) &&
273 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
274 (_item_multi_select_down(wd)))
275 || (_item_single_select_down(wd))))
277 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
283 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
285 item = elm_gengrid_first_item_get(obj);
286 elm_gengrid_item_bring_in(item);
287 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
290 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
292 item = elm_gengrid_last_item_get(obj);
293 elm_gengrid_item_bring_in(item);
294 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
297 else if ((!strcmp(ev->keyname, "Prior")) ||
298 (!strcmp(ev->keyname, "KP_Prior")))
303 x -= -(page_x * v_w) / 100;
310 y -= -(page_y * v_h) / 100;
315 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
320 x += -(page_x * v_w) / 100;
327 y += -(page_y * v_h) / 100;
332 else if (!strcmp(ev->keyname, "Escape"))
334 if (!_deselect_all_items(wd)) return EINA_FALSE;
335 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
338 else if ((!strcmp(ev->keyname, "Return")) ||
339 (!strcmp(ev->keyname, "KP_Enter")) ||
340 (!strcmp(ev->keyname, "space")))
342 item = elm_gengrid_selected_item_get(obj);
343 evas_object_smart_callback_call(item->wd->self, SIG_ACTIVATED, item);
345 else return EINA_FALSE;
347 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
348 elm_smart_scroller_child_pos_set(wd->scr, x, y);
353 _deselect_all_items(Widget_Data *wd)
355 if (!wd->selected) return EINA_FALSE;
357 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
363 _item_multi_select_left(Widget_Data *wd)
365 if (!wd->selected) return EINA_FALSE;
367 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
368 if (!prev) return EINA_TRUE;
369 if (elm_gengrid_item_selected_get(prev))
371 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
372 wd->last_selected_item = prev;
373 elm_gengrid_item_show(wd->last_selected_item);
377 elm_gengrid_item_selected_set(prev, EINA_TRUE);
378 elm_gengrid_item_show(prev);
385 _item_multi_select_right(Widget_Data *wd)
387 if (!wd->selected) return EINA_FALSE;
389 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
390 if (!next) return EINA_TRUE;
391 if (elm_gengrid_item_selected_get(next))
393 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
394 wd->last_selected_item = next;
395 elm_gengrid_item_show(wd->last_selected_item);
399 elm_gengrid_item_selected_set(next, EINA_TRUE);
400 elm_gengrid_item_show(next);
407 _item_multi_select_up(Widget_Data *wd)
410 Eina_Bool r = EINA_TRUE;
412 if (!wd->selected) return EINA_FALSE;
414 for (i = 0; (r) && (i < wd->nmax); i++)
415 r &= _item_multi_select_left(wd);
421 _item_multi_select_down(Widget_Data *wd)
424 Eina_Bool r = EINA_TRUE;
426 if (!wd->selected) return EINA_FALSE;
428 for (i = 0; (r) && (i < wd->nmax); i++)
429 r &= _item_multi_select_right(wd);
435 _item_single_select_up(Widget_Data *wd)
439 Elm_Gengrid_Item *prev;
443 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
444 while ((prev) && (prev->delete_me))
445 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
446 elm_gengrid_item_selected_set(prev, EINA_TRUE);
447 elm_gengrid_item_show(prev);
450 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
452 if (!prev) return EINA_FALSE;
454 for (i = 1; i < wd->nmax; i++)
456 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
457 if (!tmp) return EINA_FALSE;
461 _deselect_all_items(wd);
463 elm_gengrid_item_selected_set(prev, EINA_TRUE);
464 elm_gengrid_item_show(prev);
469 _item_single_select_down(Widget_Data *wd)
473 Elm_Gengrid_Item *next;
477 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
478 while ((next) && (next->delete_me))
479 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
480 elm_gengrid_item_selected_set(next, EINA_TRUE);
481 elm_gengrid_item_show(next);
484 else next = elm_gengrid_item_next_get(wd->last_selected_item);
486 if (!next) return EINA_FALSE;
488 for (i = 1; i < wd->nmax; i++)
490 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
491 if (!tmp) return EINA_FALSE;
495 _deselect_all_items(wd);
497 elm_gengrid_item_selected_set(next, EINA_TRUE);
498 elm_gengrid_item_show(next);
503 _item_single_select_left(Widget_Data *wd)
505 Elm_Gengrid_Item *prev;
508 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
509 while ((prev) && (prev->delete_me))
510 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
512 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
514 if (!prev) return EINA_FALSE;
516 _deselect_all_items(wd);
518 elm_gengrid_item_selected_set(prev, EINA_TRUE);
519 elm_gengrid_item_show(prev);
524 _item_single_select_right(Widget_Data *wd)
526 Elm_Gengrid_Item *next;
529 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
530 while ((next) && (next->delete_me))
531 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
533 else next = elm_gengrid_item_next_get(wd->last_selected_item);
535 if (!next) return EINA_FALSE;
537 _deselect_all_items(wd);
539 elm_gengrid_item_selected_set(next, EINA_TRUE);
540 elm_gengrid_item_show(next);
545 _on_focus_hook(void *data __UNUSED__,
548 Widget_Data *wd = elm_widget_data_get(obj);
550 if (elm_widget_focus_get(obj))
552 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
553 evas_object_focus_set(wd->self, EINA_TRUE);
554 if ((wd->selected) && (!wd->last_selected_item))
555 wd->last_selected_item = eina_list_data_get(wd->selected);
559 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
560 evas_object_focus_set(wd->self, EINA_FALSE);
565 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
567 Widget_Data *wd = elm_widget_data_get(obj);
568 Elm_Gengrid_Item *item;
570 elm_smart_scroller_mirrored_set(wd->scr, rtl);
571 if (!wd->items) return;
572 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
576 edje_object_mirrored_set(item->base.view, rtl);
577 elm_gengrid_item_update(item);
578 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
583 _theme_hook(Evas_Object *obj)
585 Widget_Data *wd = elm_widget_data_get(obj);
587 _elm_widget_mirrored_reload(obj);
588 _mirrored_set(obj, elm_widget_mirrored_get(obj));
589 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
590 elm_widget_style_get(obj));
594 _del_pre_hook(Evas_Object *obj)
596 Widget_Data *wd = elm_widget_data_get(obj);
598 elm_gengrid_clear(obj);
599 evas_object_del(wd->pan_smart);
600 wd->pan_smart = NULL;
604 _del_hook(Evas_Object *obj)
606 Widget_Data *wd = elm_widget_data_get(obj);
611 _signal_emit_hook(Evas_Object *obj,
612 const char *emission,
615 Widget_Data *wd = elm_widget_data_get(obj);
617 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
622 _mouse_move(void *data,
623 Evas *evas __UNUSED__,
627 Elm_Gengrid_Item *item = data;
628 Evas_Event_Mouse_Move *ev = event_info;
629 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
630 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
632 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
634 if (!item->wd->on_hold)
636 item->wd->on_hold = EINA_TRUE;
637 if (!item->wd->wasselected)
638 _item_unselect(item);
641 if ((item->dragging) && (item->down))
643 if (item->long_timer)
645 ecore_timer_del(item->long_timer);
646 item->long_timer = NULL;
648 evas_object_smart_callback_call(item->wd->self, SIG_DRAG, item);
651 if ((!item->down) || (item->wd->longpressed))
653 if (item->long_timer)
655 ecore_timer_del(item->long_timer);
656 item->long_timer = NULL;
658 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
660 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &ow, &oh);
662 it_scrl_x = ev->cur.canvas.x - item->wd->reorder_item->dx;
663 it_scrl_y = ev->cur.canvas.y - item->wd->reorder_item->dy;
665 if (it_scrl_x < ox) item->wd->reorder_item_x = ox;
666 else if (it_scrl_x + item->wd->item_width > ox + ow)
667 item->wd->reorder_item_x = ox + ow - item->wd->item_width;
668 else item->wd->reorder_item_x = it_scrl_x;
670 if (it_scrl_y < oy) item->wd->reorder_item_y = oy;
671 else if (it_scrl_y + item->wd->item_height > oy + oh)
672 item->wd->reorder_item_y = oy + oh - item->wd->item_height;
673 else item->wd->reorder_item_y = it_scrl_y;
675 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
676 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
680 if (!item->display_only)
681 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
682 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
683 x = ev->cur.canvas.x - x;
684 y = ev->cur.canvas.y - y;
687 if (adx < 0) adx = -dx;
690 if (ady < 0) ady = -dy;
693 if ((adx > minw) || (ady > minh))
695 const char *left_drag, *right_drag;
696 if (!elm_widget_mirrored_get(item->wd->self))
698 left_drag = SIG_DRAG_START_LEFT;
699 right_drag = SIG_DRAG_START_RIGHT;
703 left_drag = SIG_DRAG_START_RIGHT;
704 right_drag = SIG_DRAG_START_LEFT;
708 if (item->long_timer)
710 ecore_timer_del(item->long_timer);
711 item->long_timer = NULL;
713 if (!item->wd->wasselected)
714 _item_unselect(item);
718 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_START_UP,
723 evas_object_smart_callback_call(item->wd->self,
730 evas_object_smart_callback_call(item->wd->self,
731 SIG_DRAG_START_DOWN, item);
735 evas_object_smart_callback_call(item->wd->self,
738 evas_object_smart_callback_call(item->wd->self,
746 _long_press(void *data)
748 Elm_Gengrid_Item *item = data;
750 item->long_timer = NULL;
751 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
752 item->wd->longpressed = EINA_TRUE;
753 evas_object_smart_callback_call(item->wd->self, "longpressed", item);
754 if (item->wd->reorder_mode)
756 item->wd->reorder_item = item;
757 evas_object_raise(item->base.view);
758 elm_smart_scroller_hold_set(item->wd->scr, EINA_TRUE);
759 elm_smart_scroller_bounce_allow_set(item->wd->scr, EINA_FALSE, EINA_FALSE);
760 edje_object_signal_emit(item->base.view, "elm,state,reorder,enabled", "elm");
762 return ECORE_CALLBACK_CANCEL;
766 _mouse_down(void *data,
767 Evas *evas __UNUSED__,
771 Elm_Gengrid_Item *item = data;
772 Evas_Event_Mouse_Down *ev = event_info;
775 if (ev->button != 1) return;
778 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
779 item->dx = ev->canvas.x - x;
780 item->dy = ev->canvas.y - y;
781 item->wd->longpressed = EINA_FALSE;
782 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
783 else item->wd->on_hold = EINA_FALSE;
784 item->wd->wasselected = item->selected;
786 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
788 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
789 evas_object_smart_callback_call(item->wd->self, SIG_ACTIVATED, item);
791 if (item->long_timer) ecore_timer_del(item->long_timer);
793 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
796 item->long_timer = NULL;
800 _mouse_up(void *data,
801 Evas *evas __UNUSED__,
802 Evas_Object *obj __UNUSED__,
805 Elm_Gengrid_Item *item = data;
806 Evas_Event_Mouse_Up *ev = event_info;
807 Eina_Bool dragged = EINA_FALSE;
809 if (ev->button != 1) return;
810 item->down = EINA_FALSE;
811 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
812 else item->wd->on_hold = EINA_FALSE;
813 if (item->long_timer)
815 ecore_timer_del(item->long_timer);
816 item->long_timer = NULL;
820 item->dragging = EINA_FALSE;
821 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_STOP, item);
824 if (item->wd->on_hold)
826 item->wd->longpressed = EINA_FALSE;
827 item->wd->on_hold = EINA_FALSE;
830 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
832 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
833 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
835 evas_object_smart_callback_call(item->wd->self, SIG_MOVED, item->wd->reorder_item);
836 item->wd->reorder_item = NULL;
837 elm_smart_scroller_hold_set(item->wd->scr, EINA_FALSE);
838 elm_smart_scroller_bounce_allow_set(item->wd->scr, item->wd->h_bounce, item->wd->v_bounce);
839 edje_object_signal_emit(item->base.view, "elm,state,reorder,disabled", "elm");
841 if (item->wd->longpressed)
843 item->wd->longpressed = EINA_FALSE;
844 if (!item->wd->wasselected) _item_unselect(item);
845 item->wd->wasselected = EINA_FALSE;
850 if (item->want_unrealize) _item_unrealize(item);
852 if ((item->disabled) || (dragged)) return;
860 else _item_unselect(item);
866 while (item->wd->selected)
867 _item_unselect(item->wd->selected->data);
871 const Eina_List *l, *l_next;
872 Elm_Gengrid_Item *item2;
874 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
875 if (item2 != item) _item_unselect(item2);
883 _item_hilight(Elm_Gengrid_Item *item)
885 if ((item->wd->no_select) || (item->delete_me) || (item->hilighted)) return;
886 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
887 item->hilighted = EINA_TRUE;
891 _item_realize(Elm_Gengrid_Item *item)
896 if ((item->realized) || (item->delete_me)) return;
897 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
898 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
900 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
901 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
902 elm_widget_sub_object_add(item->wd->self, item->base.view);
903 snprintf(style, sizeof(style), "item/%s",
904 item->gic->item_style ? item->gic->item_style : "default");
905 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
906 elm_widget_style_get(item->wd->self));
908 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
909 evas_object_color_set(item->spacer, 0, 0, 0, 0);
910 elm_widget_sub_object_add(item->wd->self, item->spacer);
911 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
912 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
914 if (item->gic->func.label_get)
920 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
922 EINA_LIST_FOREACH(item->labels, l, key)
924 char *s = item->gic->func.label_get
925 ((void *)item->base.data, item->wd->self, l->data);
928 edje_object_part_text_set(item->base.view, l->data, s);
934 if (item->gic->func.icon_get)
940 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
942 EINA_LIST_FOREACH(item->icons, l, key)
944 Evas_Object *ic = item->gic->func.icon_get
945 ((void *)item->base.data, item->wd->self, l->data);
948 item->icon_objs = eina_list_append(item->icon_objs, ic);
949 edje_object_part_swallow(item->base.view, key, ic);
950 evas_object_show(ic);
951 elm_widget_sub_object_add(item->wd->self, ic);
956 if (item->gic->func.state_get)
962 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
964 EINA_LIST_FOREACH(item->states, l, key)
966 Eina_Bool on = item->gic->func.state_get
967 ((void *)item->base.data, item->wd->self, l->data);
970 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
971 edje_object_signal_emit(item->base.view, buf, "elm");
976 if ((!item->wd->item_width) && (!item->wd->item_height))
978 edje_object_size_min_restricted_calc(item->base.view,
979 &item->wd->item_width,
980 &item->wd->item_height,
981 item->wd->item_width,
982 item->wd->item_height);
983 elm_coords_finger_size_adjust(1, &item->wd->item_width,
984 1, &item->wd->item_height);
987 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
989 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
991 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
995 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
997 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
999 evas_object_show(item->base.view);
1001 if (item->tooltip.content_cb)
1003 elm_widget_item_tooltip_content_cb_set(item,
1004 item->tooltip.content_cb,
1005 item->tooltip.data, NULL);
1006 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1007 elm_widget_item_tooltip_size_restrict_disable(item, item->tooltip.free_size);
1010 if (item->mouse_cursor)
1011 elm_widget_item_cursor_set(item, item->mouse_cursor);
1013 item->realized = EINA_TRUE;
1014 item->want_unrealize = EINA_FALSE;
1018 _item_unrealize(Elm_Gengrid_Item *item)
1022 if (!item->realized) return;
1023 if (item->long_timer)
1025 ecore_timer_del(item->long_timer);
1026 item->long_timer = NULL;
1028 evas_object_del(item->base.view);
1029 item->base.view = NULL;
1030 evas_object_del(item->spacer);
1031 item->spacer = NULL;
1032 elm_widget_stringlist_free(item->labels);
1033 item->labels = NULL;
1034 elm_widget_stringlist_free(item->icons);
1036 elm_widget_stringlist_free(item->states);
1037 item->states = NULL;
1039 EINA_LIST_FREE(item->icon_objs, icon)
1040 evas_object_del(icon);
1042 item->realized = EINA_FALSE;
1043 item->want_unrealize = EINA_FALSE;
1047 _reorder_item_moving_effect_timer_cb(void *data)
1049 Elm_Gengrid_Item *item = data;
1053 time = REORDER_EFFECT_TIME;
1054 t = ((0.0 > (t = ecore_loop_time_get()-item->moving_effect_start_time)) ? 0.0 : t);
1055 dx = ((item->tx - item->ox) / 10) * _elm_config->scale;
1056 dy = ((item->ty - item->oy) / 10) * _elm_config->scale;
1060 item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
1061 item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
1069 if ((((dx > 0) && (item->rx >= item->tx)) || ((dx <= 0) && (item->rx <= item->tx))) &&
1070 (((dy > 0) && (item->ry >= item->ty)) || ((dy <= 0) && (item->ry <= item->ty))))
1072 evas_object_move(item->base.view, item->tx, item->ty);
1073 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1074 item->moving = EINA_FALSE;
1075 item->item_moving_effect_timer = NULL;
1076 return ECORE_CALLBACK_CANCEL;
1079 evas_object_move(item->base.view, item->rx, item->ry);
1080 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1082 return ECORE_CALLBACK_RENEW;
1086 _item_place(Elm_Gengrid_Item *item,
1090 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh;
1091 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1092 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1095 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1097 /* Preload rows/columns at each side of the Gengrid */
1098 cvx = ox - PRELOAD * item->wd->item_width;
1099 cvy = oy - PRELOAD * item->wd->item_height;
1100 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1101 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1106 if (item->wd->horizontal)
1108 int columns, items_visible = 0, items_row;
1110 if (item->wd->item_height > 0)
1111 items_visible = vh / item->wd->item_height;
1112 if (items_visible < 1)
1115 columns = item->wd->count / items_visible;
1116 if (item->wd->count % items_visible)
1119 tcw = item->wd->item_width * columns;
1120 alignw = (vw - tcw) * item->wd->align_x;
1122 items_row = items_visible;
1123 if (items_row > item->wd->count)
1124 items_row = item->wd->count;
1125 tch = items_row * item->wd->item_height;
1126 alignh = (vh - tch) * item->wd->align_y;
1130 int rows, items_visible = 0, items_col;
1132 if (item->wd->item_width > 0)
1133 items_visible = vw / item->wd->item_width;
1134 if (items_visible < 1)
1137 rows = item->wd->count / items_visible;
1138 if (item->wd->count % items_visible)
1141 tch = item->wd->item_height * rows;
1142 alignh = (vh - tch) * item->wd->align_y;
1144 items_col = items_visible;
1145 if (items_col > item->wd->count)
1146 items_col = item->wd->count;
1147 tcw = items_col * item->wd->item_width;
1148 alignw = (vw - tcw) * item->wd->align_x;
1151 x = cx * item->wd->item_width - item->wd->pan_x + ox + alignw;
1152 if (elm_widget_mirrored_get(item->wd->self))
1153 { /* Switch items side and componsate for pan_x when in RTL mode */
1155 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1156 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1159 y = cy * item->wd->item_height - item->wd->pan_y + oy + alignh;
1161 Eina_Bool was_realized = item->realized;
1162 if (ELM_RECTS_INTERSECT(x, y, item->wd->item_width, item->wd->item_height,
1163 cvx, cvy, cvw, cvh))
1165 _item_realize(item);
1167 evas_object_smart_callback_call(item->wd->self, SIG_REALIZED, item);
1168 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
1170 if (item->moving) return;
1172 if (!item->wd->move_effect_enabled)
1177 if (item->wd->reorder_item == item)
1179 evas_object_move(item->base.view,
1180 item->wd->reorder_item_x, item->wd->reorder_item_y);
1181 evas_object_resize(item->base.view,
1182 item->wd->item_width, item->wd->item_height);
1187 if (item->wd->move_effect_enabled)
1189 if ((item->ox != x) || (item->oy != y))
1191 if (((item->wd->old_pan_x == item->wd->pan_x) && (item->wd->old_pan_y == item->wd->pan_y)) ||
1192 ((item->wd->old_pan_x != item->wd->pan_x) && !(item->ox - item->wd->pan_x + item->wd->old_pan_x == x)) ||
1193 ((item->wd->old_pan_y != item->wd->pan_y) && !(item->oy - item->wd->pan_y + item->wd->old_pan_y == y)))
1197 item->rx = item->ox;
1198 item->ry = item->oy;
1199 item->moving = EINA_TRUE;
1200 item->moving_effect_start_time = ecore_loop_time_get();
1201 item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, item);
1207 if (ELM_RECTS_INTERSECT(item->wd->reorder_item_x, item->wd->reorder_item_y,
1208 item->wd->item_width, item->wd->item_height,
1209 x+(item->wd->item_width/2), y+(item->wd->item_height/2),
1212 if (item->wd->horizontal)
1214 if ((item->wd->nmax * item->wd->reorder_item->x + item->wd->reorder_item->y) >
1215 (item->wd->nmax * item->x + item->y))
1216 reorder_item_move_forward = EINA_TRUE;
1220 if ((item->wd->nmax * item->wd->reorder_item->y + item->wd->reorder_item->x) >
1221 (item->wd->nmax * item->y + item->x))
1222 reorder_item_move_forward = EINA_TRUE;
1225 item->wd->items = eina_inlist_remove(item->wd->items,
1226 EINA_INLIST_GET(item->wd->reorder_item));
1227 if (reorder_item_move_forward)
1228 item->wd->items = eina_inlist_prepend_relative(item->wd->items,
1229 EINA_INLIST_GET(item->wd->reorder_item),
1230 EINA_INLIST_GET(item));
1232 item->wd->items = eina_inlist_append_relative(item->wd->items,
1233 EINA_INLIST_GET(item->wd->reorder_item),
1234 EINA_INLIST_GET(item));
1236 item->wd->reorder_item_changed = EINA_TRUE;
1237 item->wd->move_effect_enabled = EINA_TRUE;
1238 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1239 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1245 evas_object_move(item->base.view, x, y);
1246 evas_object_resize(item->base.view, item->wd->item_width,
1247 item->wd->item_height);
1251 _item_unrealize(item);
1253 evas_object_smart_callback_call(item->wd->self, SIG_UNREALIZED, item);
1257 static Elm_Gengrid_Item *
1258 _item_create(Widget_Data *wd,
1259 const Elm_Gengrid_Item_Class *gic,
1262 const void *func_data)
1264 Elm_Gengrid_Item *item;
1266 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1267 if (!item) return NULL;
1271 item->base.data = data;
1272 item->func.func = func;
1273 item->func.data = func_data;
1274 item->mouse_cursor = NULL;
1279 _item_del(Elm_Gengrid_Item *item)
1281 elm_widget_item_pre_notify_del(item);
1283 item->wd->selected = eina_list_remove(item->wd->selected, item);
1284 if (item->realized) _item_unrealize(item);
1285 if ((!item->delete_me) && (item->gic->func.del))
1286 item->gic->func.del((void *)item->base.data, item->wd->self);
1287 item->delete_me = EINA_TRUE;
1288 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1289 if (item->long_timer) ecore_timer_del(item->long_timer);
1290 if (item->tooltip.del_cb)
1291 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1292 item->wd->walking -= item->walking;
1294 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1295 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1296 elm_widget_item_del(item);
1300 _item_select(Elm_Gengrid_Item *item)
1302 if ((item->wd->no_select) || (item->delete_me)) return;
1305 if (item->wd->always_select) goto call;
1308 item->selected = EINA_TRUE;
1309 item->wd->selected = eina_list_append(item->wd->selected, item);
1312 item->wd->walking++;
1313 if (item->func.func)
1314 item->func.func((void *)item->func.data, item->wd->self, item);
1315 if (!item->delete_me)
1316 evas_object_smart_callback_call(item->wd->self, SIG_SELECTED, item);
1318 item->wd->walking--;
1319 item->wd->last_selected_item = item;
1320 if ((item->wd->clear_me) && (!item->wd->walking))
1321 elm_gengrid_clear(item->base.widget);
1324 if ((!item->walking) && (item->delete_me))
1325 if (!item->relcount) _item_del(item);
1330 _item_unselect(Elm_Gengrid_Item *item)
1332 if ((item->delete_me) || (!item->hilighted)) return;
1333 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1334 item->hilighted = EINA_FALSE;
1337 item->selected = EINA_FALSE;
1338 item->wd->selected = eina_list_remove(item->wd->selected, item);
1339 evas_object_smart_callback_call(item->wd->self, SIG_UNSELECTED, item);
1344 _calc_job(void *data)
1346 Widget_Data *wd = data;
1347 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1350 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1351 if ((cvw != 0) || (cvh != 0))
1353 if ((wd->horizontal) && (wd->item_height > 0))
1354 nmax = cvh / wd->item_height;
1355 else if (wd->item_width > 0)
1356 nmax = cvw / wd->item_width;
1364 minw = ceil(count / (float)nmax) * wd->item_width;
1365 minh = nmax * wd->item_height;
1369 minw = nmax * wd->item_width;
1370 minh = ceil(count / (float)nmax) * wd->item_height;
1373 if ((minw != wd->minw) || (minh != wd->minh))
1377 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1381 evas_object_smart_changed(wd->pan_smart);
1383 wd->calc_job = NULL;
1387 _pan_add(Evas_Object *obj)
1390 Evas_Object_Smart_Clipped_Data *cd;
1393 cd = evas_object_smart_data_get(obj);
1396 sd->__clipped_data = *cd;
1398 evas_object_smart_data_set(obj, sd);
1402 _pan_del(Evas_Object *obj)
1404 Pan *sd = evas_object_smart_data_get(obj);
1411 _pan_set(Evas_Object *obj,
1415 Pan *sd = evas_object_smart_data_get(obj);
1416 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1419 evas_object_smart_changed(obj);
1423 _pan_get(Evas_Object *obj,
1427 Pan *sd = evas_object_smart_data_get(obj);
1428 if (x) *x = sd->wd->pan_x;
1429 if (y) *y = sd->wd->pan_y;
1433 _pan_child_size_get(Evas_Object *obj,
1437 Pan *sd = evas_object_smart_data_get(obj);
1438 if (w) *w = sd->wd->minw;
1439 if (h) *h = sd->wd->minh;
1443 _pan_max_get(Evas_Object *obj,
1447 Pan *sd = evas_object_smart_data_get(obj);
1451 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1453 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1455 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1459 _pan_min_get(Evas_Object *obj,
1463 Pan *sd = evas_object_smart_data_get(obj);
1467 _pan_max_get(obj, &mx, &my);
1469 *x = -mx * sd->wd->align_x;
1471 *y = -my * sd->wd->align_y;
1475 _pan_resize(Evas_Object *obj,
1479 Pan *sd = evas_object_smart_data_get(obj);
1482 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1483 if ((ow == w) && (oh == h)) return;
1484 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1485 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1489 _pan_calculate(Evas_Object *obj)
1491 Pan *sd = evas_object_smart_data_get(obj);
1492 Evas_Coord cx = 0, cy = 0;
1493 Elm_Gengrid_Item *item;
1496 if (!sd->wd->nmax) return;
1498 sd->wd->reorder_item_changed = EINA_FALSE;
1500 EINA_INLIST_FOREACH(sd->wd->items, item)
1502 _item_place(item, cx, cy);
1503 if (sd->wd->reorder_item_changed) return;
1504 if (sd->wd->horizontal)
1506 cy = (cy + 1) % sd->wd->nmax;
1511 cx = (cx + 1) % sd->wd->nmax;
1516 if ((sd->wd->reorder_mode) && (sd->wd->reorder_item))
1518 if (!sd->wd->reorder_item_changed)
1520 sd->wd->old_pan_x = sd->wd->pan_x;
1521 sd->wd->old_pan_y = sd->wd->pan_y;
1523 sd->wd->move_effect_enabled = EINA_FALSE;
1525 evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
1529 _pan_move(Evas_Object *obj,
1530 Evas_Coord x __UNUSED__,
1531 Evas_Coord y __UNUSED__)
1533 Pan *sd = evas_object_smart_data_get(obj);
1535 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1536 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1540 _hold_on(void *data __UNUSED__,
1542 void *event_info __UNUSED__)
1544 Widget_Data *wd = elm_widget_data_get(obj);
1546 elm_smart_scroller_hold_set(wd->scr, 1);
1550 _hold_off(void *data __UNUSED__,
1552 void *event_info __UNUSED__)
1554 Widget_Data *wd = elm_widget_data_get(obj);
1556 elm_smart_scroller_hold_set(wd->scr, 0);
1560 _freeze_on(void *data __UNUSED__,
1562 void *event_info __UNUSED__)
1564 Widget_Data *wd = elm_widget_data_get(obj);
1566 elm_smart_scroller_freeze_set(wd->scr, 1);
1570 _freeze_off(void *data __UNUSED__,
1572 void *event_info __UNUSED__)
1574 Widget_Data *wd = elm_widget_data_get(obj);
1576 elm_smart_scroller_freeze_set(wd->scr, 0);
1580 _scr_drag_start(void *data,
1581 Evas_Object *obj __UNUSED__,
1582 void *event_info __UNUSED__)
1584 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1588 _scr_drag_stop(void *data,
1589 Evas_Object *obj __UNUSED__,
1590 void *event_info __UNUSED__)
1592 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1596 _scr_scroll(void *data,
1597 Evas_Object *obj __UNUSED__,
1598 void *event_info __UNUSED__)
1600 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1604 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1606 const Elm_Gengrid_Item *item = data;
1607 const Elm_Gengrid_Item *item1 = data1;
1609 return _elm_gengrid_item_compare_data_cb(item->base.data, item1->base.data);
1613 _elm_gengrid_item_compare(const void *data, const void *data1)
1615 Elm_Gengrid_Item *item, *item1;
1616 item = ELM_GENGRID_ITEM_FROM_INLIST(data);
1617 item1 = ELM_GENGRID_ITEM_FROM_INLIST(data1);
1618 return _elm_gengrid_item_compare_cb(item, item1);
1622 elm_gengrid_add(Evas_Object *parent)
1627 static Evas_Smart *smart = NULL;
1628 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1630 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1632 ELM_SET_WIDTYPE(widtype, "gengrid");
1633 elm_widget_type_set(obj, "gengrid");
1634 elm_widget_sub_object_add(parent, obj);
1635 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1636 elm_widget_data_set(obj, wd);
1637 elm_widget_del_hook_set(obj, _del_hook);
1638 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1639 elm_widget_theme_hook_set(obj, _theme_hook);
1640 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1641 elm_widget_can_focus_set(obj, EINA_TRUE);
1642 elm_widget_event_hook_set(obj, _event_hook);
1644 wd->scr = elm_smart_scroller_add(e);
1645 elm_smart_scroller_widget_set(wd->scr, obj);
1646 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1648 elm_widget_resize_object_set(obj, wd->scr);
1650 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1651 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1652 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1654 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1659 wd->h_bounce = bounce;
1660 wd->v_bounce = bounce;
1661 wd->no_select = EINA_FALSE;
1663 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1664 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1665 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1666 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1668 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1672 static Evas_Smart_Class sc;
1674 evas_object_smart_clipped_smart_set(&_pan_sc);
1676 sc.name = "elm_gengrid_pan";
1677 sc.version = EVAS_SMART_CLASS_VERSION;
1680 sc.resize = _pan_resize;
1681 sc.move = _pan_move;
1682 sc.calculate = _pan_calculate;
1683 smart = evas_smart_class_new(&sc);
1687 wd->pan_smart = evas_object_smart_add(e, smart);
1688 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1692 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1693 _pan_set, _pan_get, _pan_max_get,
1694 _pan_min_get, _pan_child_size_get);
1696 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1701 elm_gengrid_item_size_set(Evas_Object *obj,
1705 ELM_CHECK_WIDTYPE(obj, widtype);
1706 Widget_Data *wd = elm_widget_data_get(obj);
1708 if ((wd->item_width == w) && (wd->item_height == h)) return;
1710 wd->item_height = h;
1711 if (wd->calc_job) ecore_job_del(wd->calc_job);
1712 wd->calc_job = ecore_job_add(_calc_job, wd);
1716 elm_gengrid_item_size_get(const Evas_Object *obj,
1720 ELM_CHECK_WIDTYPE(obj, widtype);
1721 Widget_Data *wd = elm_widget_data_get(obj);
1723 if (w) *w = wd->item_width;
1724 if (h) *h = wd->item_height;
1728 elm_gengrid_align_set(Evas_Object *obj,
1732 ELM_CHECK_WIDTYPE(obj, widtype);
1734 Widget_Data *wd = elm_widget_data_get(obj);
1735 double old_h = wd->align_x, old_y = wd->align_y;
1739 else if (align_x < 0.0)
1741 wd->align_x = align_x;
1745 else if (align_y < 0.0)
1747 wd->align_y = align_y;
1749 if ((old_h != wd->align_x) || (old_y != wd->align_y))
1750 evas_object_smart_calculate(wd->pan_smart);
1754 elm_gengrid_align_get(const Evas_Object *obj,
1758 ELM_CHECK_WIDTYPE(obj, widtype);
1759 Widget_Data *wd = elm_widget_data_get(obj);
1760 if (align_x) *align_x = wd->align_x;
1761 if (align_y) *align_y = wd->align_y;
1764 EAPI Elm_Gengrid_Item *
1765 elm_gengrid_item_append(Evas_Object *obj,
1766 const Elm_Gengrid_Item_Class *gic,
1769 const void *func_data)
1771 Elm_Gengrid_Item *item;
1772 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1773 Widget_Data *wd = elm_widget_data_get(obj);
1774 if (!wd) return NULL;
1776 item = _item_create(wd, gic, data, func, func_data);
1777 if (!item) return NULL;
1778 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
1780 if (wd->calc_job) ecore_job_del(wd->calc_job);
1781 wd->calc_job = ecore_job_add(_calc_job, wd);
1786 EAPI Elm_Gengrid_Item *
1787 elm_gengrid_item_prepend(Evas_Object *obj,
1788 const Elm_Gengrid_Item_Class *gic,
1791 const void *func_data)
1793 Elm_Gengrid_Item *item;
1794 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1795 Widget_Data *wd = elm_widget_data_get(obj);
1796 if (!wd) return NULL;
1798 item = _item_create(wd, gic, data, func, func_data);
1799 if (!item) return NULL;
1800 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
1802 if (wd->calc_job) ecore_job_del(wd->calc_job);
1803 wd->calc_job = ecore_job_add(_calc_job, wd);
1808 EAPI Elm_Gengrid_Item *
1809 elm_gengrid_item_insert_before(Evas_Object *obj,
1810 const Elm_Gengrid_Item_Class *gic,
1812 Elm_Gengrid_Item *relative,
1814 const void *func_data)
1816 Elm_Gengrid_Item *item;
1817 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1818 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1819 Widget_Data *wd = elm_widget_data_get(obj);
1820 if (!wd) return NULL;
1822 item = _item_create(wd, gic, data, func, func_data);
1823 if (!item) return NULL;
1824 wd->items = eina_inlist_prepend_relative
1825 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1827 if (wd->calc_job) ecore_job_del(wd->calc_job);
1828 wd->calc_job = ecore_job_add(_calc_job, wd);
1833 EAPI Elm_Gengrid_Item *
1834 elm_gengrid_item_insert_after(Evas_Object *obj,
1835 const Elm_Gengrid_Item_Class *gic,
1837 Elm_Gengrid_Item *relative,
1839 const void *func_data)
1841 Elm_Gengrid_Item *item;
1842 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1843 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1844 Widget_Data *wd = elm_widget_data_get(obj);
1845 if (!wd) return NULL;
1847 item = _item_create(wd, gic, data, func, func_data);
1848 if (!item) return NULL;
1849 wd->items = eina_inlist_append_relative
1850 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1852 if (wd->calc_job) ecore_job_del(wd->calc_job);
1853 wd->calc_job = ecore_job_add(_calc_job, wd);
1858 EAPI Elm_Gengrid_Item *
1859 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
1860 const Elm_Gengrid_Item_Class *gic,
1862 Eina_Compare_Cb comp,
1864 const void *func_data)
1866 Elm_Gengrid_Item *item;
1867 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1868 Widget_Data *wd = elm_widget_data_get(obj);
1869 if (!wd) return NULL;
1871 item = _item_create(wd, gic, data, func, func_data);
1872 if (!item) return NULL;
1874 _elm_gengrid_item_compare_cb = comp;
1875 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(item),
1876 _elm_gengrid_item_compare);
1877 if (wd->calc_job) ecore_job_del(wd->calc_job);
1878 wd->calc_job = ecore_job_add(_calc_job, wd);
1883 EAPI Elm_Gengrid_Item *
1884 elm_gengrid_item_sorted_insert(Evas_Object *obj,
1885 const Elm_Gengrid_Item_Class *gic,
1887 Eina_Compare_Cb comp,
1889 const void *func_data)
1891 _elm_gengrid_item_compare_data_cb = comp;
1893 return elm_gengrid_item_direct_sorted_insert(obj, gic, data, _elm_gengrid_item_compare_data, func, func_data);
1897 elm_gengrid_item_del(Elm_Gengrid_Item *item)
1899 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1900 if ((item->relcount > 0) || (item->walking > 0))
1902 item->delete_me = EINA_TRUE;
1903 elm_widget_item_pre_notify_del(item);
1905 item->wd->selected = eina_list_remove(item->wd->selected, item);
1906 if (item->gic->func.del)
1907 item->gic->func.del((void *)item->base.data, item->wd->self);
1915 elm_gengrid_horizontal_set(Evas_Object *obj,
1918 ELM_CHECK_WIDTYPE(obj, widtype);
1919 Widget_Data *wd = elm_widget_data_get(obj);
1921 if (setting == wd->horizontal) return;
1922 wd->horizontal = setting;
1924 /* Update the items to conform to the new layout */
1925 if (wd->calc_job) ecore_job_del(wd->calc_job);
1926 wd->calc_job = ecore_job_add(_calc_job, wd);
1930 elm_gengrid_horizontal_get(const Evas_Object *obj)
1932 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1933 Widget_Data *wd = elm_widget_data_get(obj);
1934 if (!wd) return EINA_FALSE;
1935 return wd->horizontal;
1939 elm_gengrid_clear(Evas_Object *obj)
1941 ELM_CHECK_WIDTYPE(obj, widtype);
1942 Widget_Data *wd = elm_widget_data_get(obj);
1947 ecore_job_del(wd->calc_job);
1948 wd->calc_job = NULL;
1951 if (wd->walking > 0)
1953 Elm_Gengrid_Item *item;
1955 EINA_INLIST_FOREACH(wd->items, item)
1956 item->delete_me = 1;
1962 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
1964 wd->items = eina_inlist_remove(wd->items, wd->items);
1965 elm_widget_item_pre_notify_del(item);
1966 if (item->realized) _item_unrealize(item);
1967 if (item->gic->func.del)
1968 item->gic->func.del((void *)item->base.data, wd->self);
1969 if (item->long_timer) ecore_timer_del(item->long_timer);
1970 elm_widget_item_del(item);
1975 eina_list_free(wd->selected);
1976 wd->selected = NULL;
1984 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
1985 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1988 EAPI const Evas_Object *
1989 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
1991 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1992 return item->base.view;
1996 elm_gengrid_item_update(Elm_Gengrid_Item *item)
1998 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1999 if (!item->realized) return;
2000 if (item->want_unrealize) return;
2001 _item_unrealize(item);
2002 _item_realize(item);
2003 _item_place(item, item->x, item->y);
2007 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2009 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2010 return elm_widget_item_data_get(item);
2014 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2017 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2018 elm_widget_item_data_set(item, data);
2021 EAPI const Elm_Gengrid_Item_Class *
2022 elm_gengrid_item_item_class_get(const Elm_Gengrid_Item *item)
2024 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2025 if (item->delete_me) return NULL;
2030 elm_gengrid_item_item_class_set(Elm_Gengrid_Item *item,
2031 const Elm_Gengrid_Item_Class *gic)
2033 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2034 EINA_SAFETY_ON_NULL_RETURN(gic);
2035 if (item->delete_me) return;
2037 elm_gengrid_item_update(item);
2041 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2045 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2046 if (x) *x = item->x;
2047 if (y) *y = item->y;
2051 elm_gengrid_multi_select_set(Evas_Object *obj,
2054 ELM_CHECK_WIDTYPE(obj, widtype);
2055 Widget_Data *wd = elm_widget_data_get(obj);
2061 elm_gengrid_multi_select_get(const Evas_Object *obj)
2063 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2064 Widget_Data *wd = elm_widget_data_get(obj);
2065 if (!wd) return EINA_FALSE;
2069 EAPI Elm_Gengrid_Item *
2070 elm_gengrid_selected_item_get(const Evas_Object *obj)
2072 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2073 Widget_Data *wd = elm_widget_data_get(obj);
2074 if (!wd) return NULL;
2075 if (wd->selected) return wd->selected->data;
2079 EAPI const Eina_List *
2080 elm_gengrid_selected_items_get(const Evas_Object *obj)
2082 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2083 Widget_Data *wd = elm_widget_data_get(obj);
2084 if (!wd) return NULL;
2085 return wd->selected;
2089 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2092 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2093 Widget_Data *wd = item->wd;
2095 if (item->delete_me) return;
2096 selected = !!selected;
2097 if (item->selected == selected) return;
2103 while (wd->selected)
2104 _item_unselect(wd->selected->data);
2106 _item_hilight(item);
2110 _item_unselect(item);
2114 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2116 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2117 return item->selected;
2121 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2124 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2125 if (item->disabled == disabled) return;
2126 if (item->delete_me) return;
2127 item->disabled = !!disabled;
2131 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2133 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2138 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2140 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2141 if (item->delete_me) return EINA_FALSE;
2142 return item->disabled;
2145 static Evas_Object *
2146 _elm_gengrid_item_label_create(void *data,
2147 Evas_Object *obj __UNUSED__,
2148 Evas_Object *tooltip,
2149 void *item __UNUSED__)
2151 Evas_Object *label = elm_label_add(tooltip);
2154 elm_object_style_set(label, "tooltip");
2155 elm_object_text_set(label, data);
2160 _elm_gengrid_item_label_del_cb(void *data,
2161 Evas_Object *obj __UNUSED__,
2162 void *event_info __UNUSED__)
2164 eina_stringshare_del(data);
2168 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2171 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2172 text = eina_stringshare_add(text);
2173 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2175 _elm_gengrid_item_label_del_cb);
2179 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2180 Elm_Tooltip_Item_Content_Cb func,
2182 Evas_Smart_Cb del_cb)
2184 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2186 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2189 if (item->tooltip.del_cb)
2190 item->tooltip.del_cb((void *)item->tooltip.data,
2191 item->base.widget, item);
2192 item->tooltip.content_cb = func;
2193 item->tooltip.data = data;
2194 item->tooltip.del_cb = del_cb;
2195 if (item->base.view)
2197 elm_widget_item_tooltip_content_cb_set(item,
2198 item->tooltip.content_cb,
2199 item->tooltip.data, NULL);
2200 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2201 elm_widget_item_tooltip_size_restrict_disable(item, item->tooltip.free_size);
2207 if (del_cb) del_cb((void *)data, NULL, NULL);
2211 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2213 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2214 if ((item->base.view) && (item->tooltip.content_cb))
2215 elm_widget_item_tooltip_unset(item);
2217 if (item->tooltip.del_cb)
2218 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2219 item->tooltip.del_cb = NULL;
2220 item->tooltip.content_cb = NULL;
2221 item->tooltip.data = NULL;
2222 item->tooltip.free_size = EINA_FALSE;
2223 if (item->tooltip.style)
2224 elm_gengrid_item_tooltip_style_set(item, NULL);
2228 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2231 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2232 eina_stringshare_replace(&item->tooltip.style, style);
2233 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2237 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2239 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2240 return item->tooltip.style;
2244 elm_gengrid_item_tooltip_size_restrict_disable(Elm_Gengrid_Item *item, Eina_Bool disable)
2246 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2247 item->tooltip.free_size = disable;
2248 if (item->base.view) return elm_widget_item_tooltip_size_restrict_disable(item, disable);
2253 elm_gengrid_item_tooltip_size_restrict_disabled_get(const Elm_Gengrid_Item *item)
2255 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2256 return item->tooltip.free_size;
2260 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2263 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2264 eina_stringshare_replace(&item->mouse_cursor, cursor);
2265 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2269 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2271 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2272 return elm_widget_item_cursor_get(item);
2276 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2278 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2279 if (!item->mouse_cursor)
2282 if (item->base.view)
2283 elm_widget_item_cursor_unset(item);
2285 eina_stringshare_del(item->mouse_cursor);
2286 item->mouse_cursor = NULL;
2290 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2293 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2294 elm_widget_item_cursor_style_set(item, style);
2298 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2300 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2301 return elm_widget_item_cursor_style_get(item);
2305 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2306 Eina_Bool engine_only)
2308 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2309 elm_widget_item_cursor_engine_only_set(item, engine_only);
2313 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2315 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2316 return elm_widget_item_cursor_engine_only_get(item);
2320 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2321 Eina_Bool reorder_mode)
2323 ELM_CHECK_WIDTYPE(obj, widtype);
2324 Widget_Data *wd = elm_widget_data_get(obj);
2326 wd->reorder_mode = reorder_mode;
2330 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2332 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2333 Widget_Data *wd = elm_widget_data_get(obj);
2334 if (!wd) return EINA_FALSE;
2335 return wd->reorder_mode;
2339 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2340 Eina_Bool always_select)
2342 ELM_CHECK_WIDTYPE(obj, widtype);
2343 Widget_Data *wd = elm_widget_data_get(obj);
2345 wd->always_select = always_select;
2349 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2351 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2352 Widget_Data *wd = elm_widget_data_get(obj);
2353 if (!wd) return EINA_FALSE;
2354 return wd->always_select;
2358 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2359 Eina_Bool no_select)
2361 ELM_CHECK_WIDTYPE(obj, widtype);
2362 Widget_Data *wd = elm_widget_data_get(obj);
2364 wd->no_select = no_select;
2368 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2370 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2371 Widget_Data *wd = elm_widget_data_get(obj);
2372 if (!wd) return EINA_FALSE;
2373 return wd->no_select;
2377 elm_gengrid_bounce_set(Evas_Object *obj,
2381 ELM_CHECK_WIDTYPE(obj, widtype);
2382 Widget_Data *wd = elm_widget_data_get(obj);
2384 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2385 wd->h_bounce = h_bounce;
2386 wd->v_bounce = v_bounce;
2390 elm_gengrid_bounce_get(const Evas_Object *obj,
2391 Eina_Bool *h_bounce,
2392 Eina_Bool *v_bounce)
2394 ELM_CHECK_WIDTYPE(obj, widtype);
2395 Widget_Data *wd = elm_widget_data_get(obj);
2397 if (h_bounce) *h_bounce = wd->h_bounce;
2398 if (v_bounce) *v_bounce = wd->v_bounce;
2402 elm_gengrid_page_relative_set(Evas_Object *obj,
2406 Evas_Coord pagesize_h;
2407 Evas_Coord pagesize_v;
2409 ELM_CHECK_WIDTYPE(obj, widtype);
2410 Widget_Data *wd = elm_widget_data_get(obj);
2413 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
2414 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
2419 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2421 ELM_CHECK_WIDTYPE(obj, widtype);
2422 Widget_Data *wd = elm_widget_data_get(obj);
2425 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
2429 elm_gengrid_page_size_set(Evas_Object *obj,
2430 Evas_Coord h_pagesize,
2431 Evas_Coord v_pagesize)
2436 ELM_CHECK_WIDTYPE(obj, widtype);
2437 Widget_Data *wd = elm_widget_data_get(obj);
2439 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
2440 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
2444 EAPI Elm_Gengrid_Item *
2445 elm_gengrid_first_item_get(const Evas_Object *obj)
2447 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2448 Widget_Data *wd = elm_widget_data_get(obj);
2449 if (!wd) return NULL;
2450 if (!wd->items) return NULL;
2451 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2452 while ((item) && (item->delete_me))
2453 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2457 EAPI Elm_Gengrid_Item *
2458 elm_gengrid_last_item_get(const Evas_Object *obj)
2460 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2461 Widget_Data *wd = elm_widget_data_get(obj);
2462 if (!wd) return NULL;
2463 if (!wd->items) return NULL;
2464 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
2465 while ((item) && (item->delete_me))
2466 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2470 EAPI Elm_Gengrid_Item *
2471 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
2473 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2476 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2477 if ((item) && (!item->delete_me)) break;
2479 return (Elm_Gengrid_Item *)item;
2482 EAPI Elm_Gengrid_Item *
2483 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
2485 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2488 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2489 if ((item) && (!item->delete_me)) break;
2491 return (Elm_Gengrid_Item *)item;
2495 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
2497 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2498 return item->base.widget;
2502 elm_gengrid_item_show(Elm_Gengrid_Item *item)
2504 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2505 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2506 Evas_Coord minx = 0, miny = 0;
2509 if ((!item) || (item->delete_me)) return;
2510 _pan_min_get(wd->pan_smart, &minx, &miny);
2512 elm_smart_scroller_child_region_show(item->wd->scr,
2513 item->x * wd->item_width + minx,
2514 item->y * wd->item_height + miny,
2515 item->wd->item_width,
2516 item->wd->item_height);
2520 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
2522 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2523 if (item->delete_me) return;
2525 Evas_Coord minx = 0, miny = 0;
2526 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2528 _pan_min_get(wd->pan_smart, &minx, &miny);
2530 elm_smart_scroller_region_bring_in(item->wd->scr,
2531 item->x * wd->item_width + minx,
2532 item->y * wd->item_height + miny,
2533 item->wd->item_width,
2534 item->wd->item_height);