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);
1258 _item_label_hook(Elm_Gengrid_Item *it, const char *part)
1260 if (!it->gic->func.label_get) return NULL;
1261 return edje_object_part_text_get(it->base.view, part);
1264 static Elm_Gengrid_Item *
1265 _item_create(Widget_Data *wd,
1266 const Elm_Gengrid_Item_Class *gic,
1269 const void *func_data)
1271 Elm_Gengrid_Item *item;
1273 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1274 if (!item) return NULL;
1278 item->base.data = data;
1279 item->func.func = func;
1280 item->func.data = func_data;
1281 item->mouse_cursor = NULL;
1282 elm_widget_item_text_get_hook_set(item, _item_label_hook);
1287 _item_del(Elm_Gengrid_Item *item)
1289 elm_widget_item_pre_notify_del(item);
1291 item->wd->selected = eina_list_remove(item->wd->selected, item);
1292 if (item->realized) _item_unrealize(item);
1293 if ((!item->delete_me) && (item->gic->func.del))
1294 item->gic->func.del((void *)item->base.data, item->wd->self);
1295 item->delete_me = EINA_TRUE;
1296 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1297 if (item->long_timer) ecore_timer_del(item->long_timer);
1298 if (item->tooltip.del_cb)
1299 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1300 item->wd->walking -= item->walking;
1302 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1303 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1304 elm_widget_item_del(item);
1308 _item_select(Elm_Gengrid_Item *item)
1310 if ((item->wd->no_select) || (item->delete_me)) return;
1313 if (item->wd->always_select) goto call;
1316 item->selected = EINA_TRUE;
1317 item->wd->selected = eina_list_append(item->wd->selected, item);
1320 item->wd->walking++;
1321 if (item->func.func)
1322 item->func.func((void *)item->func.data, item->wd->self, item);
1323 if (!item->delete_me)
1324 evas_object_smart_callback_call(item->wd->self, SIG_SELECTED, item);
1326 item->wd->walking--;
1327 item->wd->last_selected_item = item;
1328 if ((item->wd->clear_me) && (!item->wd->walking))
1329 elm_gengrid_clear(item->base.widget);
1332 if ((!item->walking) && (item->delete_me))
1333 if (!item->relcount) _item_del(item);
1338 _item_unselect(Elm_Gengrid_Item *item)
1340 if ((item->delete_me) || (!item->hilighted)) return;
1341 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1342 item->hilighted = EINA_FALSE;
1345 item->selected = EINA_FALSE;
1346 item->wd->selected = eina_list_remove(item->wd->selected, item);
1347 evas_object_smart_callback_call(item->wd->self, SIG_UNSELECTED, item);
1352 _calc_job(void *data)
1354 Widget_Data *wd = data;
1355 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1358 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1359 if ((cvw != 0) || (cvh != 0))
1361 if ((wd->horizontal) && (wd->item_height > 0))
1362 nmax = cvh / wd->item_height;
1363 else if (wd->item_width > 0)
1364 nmax = cvw / wd->item_width;
1372 minw = ceil(count / (float)nmax) * wd->item_width;
1373 minh = nmax * wd->item_height;
1377 minw = nmax * wd->item_width;
1378 minh = ceil(count / (float)nmax) * wd->item_height;
1381 if ((minw != wd->minw) || (minh != wd->minh))
1385 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1389 evas_object_smart_changed(wd->pan_smart);
1391 wd->calc_job = NULL;
1395 _pan_add(Evas_Object *obj)
1398 Evas_Object_Smart_Clipped_Data *cd;
1401 cd = evas_object_smart_data_get(obj);
1404 sd->__clipped_data = *cd;
1406 evas_object_smart_data_set(obj, sd);
1410 _pan_del(Evas_Object *obj)
1412 Pan *sd = evas_object_smart_data_get(obj);
1419 _pan_set(Evas_Object *obj,
1423 Pan *sd = evas_object_smart_data_get(obj);
1424 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1427 evas_object_smart_changed(obj);
1431 _pan_get(Evas_Object *obj,
1435 Pan *sd = evas_object_smart_data_get(obj);
1436 if (x) *x = sd->wd->pan_x;
1437 if (y) *y = sd->wd->pan_y;
1441 _pan_child_size_get(Evas_Object *obj,
1445 Pan *sd = evas_object_smart_data_get(obj);
1446 if (w) *w = sd->wd->minw;
1447 if (h) *h = sd->wd->minh;
1451 _pan_max_get(Evas_Object *obj,
1455 Pan *sd = evas_object_smart_data_get(obj);
1459 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1461 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1463 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1467 _pan_min_get(Evas_Object *obj,
1471 Pan *sd = evas_object_smart_data_get(obj);
1475 _pan_max_get(obj, &mx, &my);
1477 *x = -mx * sd->wd->align_x;
1479 *y = -my * sd->wd->align_y;
1483 _pan_resize(Evas_Object *obj,
1487 Pan *sd = evas_object_smart_data_get(obj);
1490 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1491 if ((ow == w) && (oh == h)) return;
1492 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1493 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1497 _pan_calculate(Evas_Object *obj)
1499 Pan *sd = evas_object_smart_data_get(obj);
1500 Evas_Coord cx = 0, cy = 0;
1501 Elm_Gengrid_Item *item;
1504 if (!sd->wd->nmax) return;
1506 sd->wd->reorder_item_changed = EINA_FALSE;
1508 EINA_INLIST_FOREACH(sd->wd->items, item)
1510 _item_place(item, cx, cy);
1511 if (sd->wd->reorder_item_changed) return;
1512 if (sd->wd->horizontal)
1514 cy = (cy + 1) % sd->wd->nmax;
1519 cx = (cx + 1) % sd->wd->nmax;
1524 if ((sd->wd->reorder_mode) && (sd->wd->reorder_item))
1526 if (!sd->wd->reorder_item_changed)
1528 sd->wd->old_pan_x = sd->wd->pan_x;
1529 sd->wd->old_pan_y = sd->wd->pan_y;
1531 sd->wd->move_effect_enabled = EINA_FALSE;
1533 evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
1537 _pan_move(Evas_Object *obj,
1538 Evas_Coord x __UNUSED__,
1539 Evas_Coord y __UNUSED__)
1541 Pan *sd = evas_object_smart_data_get(obj);
1543 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1544 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1548 _hold_on(void *data __UNUSED__,
1550 void *event_info __UNUSED__)
1552 Widget_Data *wd = elm_widget_data_get(obj);
1554 elm_smart_scroller_hold_set(wd->scr, 1);
1558 _hold_off(void *data __UNUSED__,
1560 void *event_info __UNUSED__)
1562 Widget_Data *wd = elm_widget_data_get(obj);
1564 elm_smart_scroller_hold_set(wd->scr, 0);
1568 _freeze_on(void *data __UNUSED__,
1570 void *event_info __UNUSED__)
1572 Widget_Data *wd = elm_widget_data_get(obj);
1574 elm_smart_scroller_freeze_set(wd->scr, 1);
1578 _freeze_off(void *data __UNUSED__,
1580 void *event_info __UNUSED__)
1582 Widget_Data *wd = elm_widget_data_get(obj);
1584 elm_smart_scroller_freeze_set(wd->scr, 0);
1588 _scr_drag_start(void *data,
1589 Evas_Object *obj __UNUSED__,
1590 void *event_info __UNUSED__)
1592 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1596 _scr_drag_stop(void *data,
1597 Evas_Object *obj __UNUSED__,
1598 void *event_info __UNUSED__)
1600 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1604 _scr_scroll(void *data,
1605 Evas_Object *obj __UNUSED__,
1606 void *event_info __UNUSED__)
1608 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1612 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1614 const Elm_Gengrid_Item *item = data;
1615 const Elm_Gengrid_Item *item1 = data1;
1617 return _elm_gengrid_item_compare_data_cb(item->base.data, item1->base.data);
1621 _elm_gengrid_item_compare(const void *data, const void *data1)
1623 Elm_Gengrid_Item *item, *item1;
1624 item = ELM_GENGRID_ITEM_FROM_INLIST(data);
1625 item1 = ELM_GENGRID_ITEM_FROM_INLIST(data1);
1626 return _elm_gengrid_item_compare_cb(item, item1);
1630 elm_gengrid_add(Evas_Object *parent)
1635 static Evas_Smart *smart = NULL;
1636 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1638 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1640 ELM_SET_WIDTYPE(widtype, "gengrid");
1641 elm_widget_type_set(obj, "gengrid");
1642 elm_widget_sub_object_add(parent, obj);
1643 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1644 elm_widget_data_set(obj, wd);
1645 elm_widget_del_hook_set(obj, _del_hook);
1646 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1647 elm_widget_theme_hook_set(obj, _theme_hook);
1648 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1649 elm_widget_can_focus_set(obj, EINA_TRUE);
1650 elm_widget_event_hook_set(obj, _event_hook);
1652 wd->scr = elm_smart_scroller_add(e);
1653 elm_smart_scroller_widget_set(wd->scr, obj);
1654 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1656 elm_widget_resize_object_set(obj, wd->scr);
1658 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1659 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1660 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1662 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1667 wd->h_bounce = bounce;
1668 wd->v_bounce = bounce;
1669 wd->no_select = EINA_FALSE;
1671 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1672 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1673 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1674 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1676 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1680 static Evas_Smart_Class sc;
1682 evas_object_smart_clipped_smart_set(&_pan_sc);
1684 sc.name = "elm_gengrid_pan";
1685 sc.version = EVAS_SMART_CLASS_VERSION;
1688 sc.resize = _pan_resize;
1689 sc.move = _pan_move;
1690 sc.calculate = _pan_calculate;
1691 smart = evas_smart_class_new(&sc);
1695 wd->pan_smart = evas_object_smart_add(e, smart);
1696 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1700 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1701 _pan_set, _pan_get, _pan_max_get,
1702 _pan_min_get, _pan_child_size_get);
1704 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1709 elm_gengrid_item_size_set(Evas_Object *obj,
1713 ELM_CHECK_WIDTYPE(obj, widtype);
1714 Widget_Data *wd = elm_widget_data_get(obj);
1716 if ((wd->item_width == w) && (wd->item_height == h)) return;
1718 wd->item_height = h;
1719 if (wd->calc_job) ecore_job_del(wd->calc_job);
1720 wd->calc_job = ecore_job_add(_calc_job, wd);
1724 elm_gengrid_item_size_get(const Evas_Object *obj,
1728 ELM_CHECK_WIDTYPE(obj, widtype);
1729 Widget_Data *wd = elm_widget_data_get(obj);
1731 if (w) *w = wd->item_width;
1732 if (h) *h = wd->item_height;
1736 elm_gengrid_align_set(Evas_Object *obj,
1740 ELM_CHECK_WIDTYPE(obj, widtype);
1742 Widget_Data *wd = elm_widget_data_get(obj);
1743 double old_h = wd->align_x, old_y = wd->align_y;
1747 else if (align_x < 0.0)
1749 wd->align_x = align_x;
1753 else if (align_y < 0.0)
1755 wd->align_y = align_y;
1757 if ((old_h != wd->align_x) || (old_y != wd->align_y))
1758 evas_object_smart_calculate(wd->pan_smart);
1762 elm_gengrid_align_get(const Evas_Object *obj,
1766 ELM_CHECK_WIDTYPE(obj, widtype);
1767 Widget_Data *wd = elm_widget_data_get(obj);
1768 if (align_x) *align_x = wd->align_x;
1769 if (align_y) *align_y = wd->align_y;
1772 EAPI Elm_Gengrid_Item *
1773 elm_gengrid_item_append(Evas_Object *obj,
1774 const Elm_Gengrid_Item_Class *gic,
1777 const void *func_data)
1779 Elm_Gengrid_Item *item;
1780 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1781 Widget_Data *wd = elm_widget_data_get(obj);
1782 if (!wd) return NULL;
1784 item = _item_create(wd, gic, data, func, func_data);
1785 if (!item) return NULL;
1786 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
1788 if (wd->calc_job) ecore_job_del(wd->calc_job);
1789 wd->calc_job = ecore_job_add(_calc_job, wd);
1794 EAPI Elm_Gengrid_Item *
1795 elm_gengrid_item_prepend(Evas_Object *obj,
1796 const Elm_Gengrid_Item_Class *gic,
1799 const void *func_data)
1801 Elm_Gengrid_Item *item;
1802 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1803 Widget_Data *wd = elm_widget_data_get(obj);
1804 if (!wd) return NULL;
1806 item = _item_create(wd, gic, data, func, func_data);
1807 if (!item) return NULL;
1808 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
1810 if (wd->calc_job) ecore_job_del(wd->calc_job);
1811 wd->calc_job = ecore_job_add(_calc_job, wd);
1816 EAPI Elm_Gengrid_Item *
1817 elm_gengrid_item_insert_before(Evas_Object *obj,
1818 const Elm_Gengrid_Item_Class *gic,
1820 Elm_Gengrid_Item *relative,
1822 const void *func_data)
1824 Elm_Gengrid_Item *item;
1825 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1826 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1827 Widget_Data *wd = elm_widget_data_get(obj);
1828 if (!wd) return NULL;
1830 item = _item_create(wd, gic, data, func, func_data);
1831 if (!item) return NULL;
1832 wd->items = eina_inlist_prepend_relative
1833 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1835 if (wd->calc_job) ecore_job_del(wd->calc_job);
1836 wd->calc_job = ecore_job_add(_calc_job, wd);
1841 EAPI Elm_Gengrid_Item *
1842 elm_gengrid_item_insert_after(Evas_Object *obj,
1843 const Elm_Gengrid_Item_Class *gic,
1845 Elm_Gengrid_Item *relative,
1847 const void *func_data)
1849 Elm_Gengrid_Item *item;
1850 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1851 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1852 Widget_Data *wd = elm_widget_data_get(obj);
1853 if (!wd) return NULL;
1855 item = _item_create(wd, gic, data, func, func_data);
1856 if (!item) return NULL;
1857 wd->items = eina_inlist_append_relative
1858 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1860 if (wd->calc_job) ecore_job_del(wd->calc_job);
1861 wd->calc_job = ecore_job_add(_calc_job, wd);
1866 EAPI Elm_Gengrid_Item *
1867 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
1868 const Elm_Gengrid_Item_Class *gic,
1870 Eina_Compare_Cb comp,
1872 const void *func_data)
1874 Elm_Gengrid_Item *item;
1875 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1876 Widget_Data *wd = elm_widget_data_get(obj);
1877 if (!wd) return NULL;
1879 item = _item_create(wd, gic, data, func, func_data);
1880 if (!item) return NULL;
1882 _elm_gengrid_item_compare_cb = comp;
1883 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(item),
1884 _elm_gengrid_item_compare);
1885 if (wd->calc_job) ecore_job_del(wd->calc_job);
1886 wd->calc_job = ecore_job_add(_calc_job, wd);
1891 EAPI Elm_Gengrid_Item *
1892 elm_gengrid_item_sorted_insert(Evas_Object *obj,
1893 const Elm_Gengrid_Item_Class *gic,
1895 Eina_Compare_Cb comp,
1897 const void *func_data)
1899 _elm_gengrid_item_compare_data_cb = comp;
1901 return elm_gengrid_item_direct_sorted_insert(obj, gic, data, _elm_gengrid_item_compare_data, func, func_data);
1905 elm_gengrid_item_del(Elm_Gengrid_Item *item)
1907 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1908 if ((item->relcount > 0) || (item->walking > 0))
1910 item->delete_me = EINA_TRUE;
1911 elm_widget_item_pre_notify_del(item);
1913 item->wd->selected = eina_list_remove(item->wd->selected, item);
1914 if (item->gic->func.del)
1915 item->gic->func.del((void *)item->base.data, item->wd->self);
1923 elm_gengrid_horizontal_set(Evas_Object *obj,
1926 ELM_CHECK_WIDTYPE(obj, widtype);
1927 Widget_Data *wd = elm_widget_data_get(obj);
1929 if (setting == wd->horizontal) return;
1930 wd->horizontal = setting;
1932 /* Update the items to conform to the new layout */
1933 if (wd->calc_job) ecore_job_del(wd->calc_job);
1934 wd->calc_job = ecore_job_add(_calc_job, wd);
1938 elm_gengrid_horizontal_get(const Evas_Object *obj)
1940 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1941 Widget_Data *wd = elm_widget_data_get(obj);
1942 if (!wd) return EINA_FALSE;
1943 return wd->horizontal;
1947 elm_gengrid_clear(Evas_Object *obj)
1949 ELM_CHECK_WIDTYPE(obj, widtype);
1950 Widget_Data *wd = elm_widget_data_get(obj);
1955 ecore_job_del(wd->calc_job);
1956 wd->calc_job = NULL;
1959 if (wd->walking > 0)
1961 Elm_Gengrid_Item *item;
1963 EINA_INLIST_FOREACH(wd->items, item)
1964 item->delete_me = 1;
1970 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
1972 wd->items = eina_inlist_remove(wd->items, wd->items);
1973 elm_widget_item_pre_notify_del(item);
1974 if (item->realized) _item_unrealize(item);
1975 if (item->gic->func.del)
1976 item->gic->func.del((void *)item->base.data, wd->self);
1977 if (item->long_timer) ecore_timer_del(item->long_timer);
1978 elm_widget_item_del(item);
1983 eina_list_free(wd->selected);
1984 wd->selected = NULL;
1992 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
1993 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1996 EAPI const Evas_Object *
1997 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
1999 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2000 return item->base.view;
2004 elm_gengrid_item_update(Elm_Gengrid_Item *item)
2006 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2007 if (!item->realized) return;
2008 if (item->want_unrealize) return;
2009 _item_unrealize(item);
2010 _item_realize(item);
2011 _item_place(item, item->x, item->y);
2015 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2017 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2018 return elm_widget_item_data_get(item);
2022 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2025 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2026 elm_widget_item_data_set(item, data);
2029 EAPI const Elm_Gengrid_Item_Class *
2030 elm_gengrid_item_item_class_get(const Elm_Gengrid_Item *item)
2032 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2033 if (item->delete_me) return NULL;
2038 elm_gengrid_item_item_class_set(Elm_Gengrid_Item *item,
2039 const Elm_Gengrid_Item_Class *gic)
2041 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2042 EINA_SAFETY_ON_NULL_RETURN(gic);
2043 if (item->delete_me) return;
2045 elm_gengrid_item_update(item);
2049 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2053 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2054 if (x) *x = item->x;
2055 if (y) *y = item->y;
2059 elm_gengrid_multi_select_set(Evas_Object *obj,
2062 ELM_CHECK_WIDTYPE(obj, widtype);
2063 Widget_Data *wd = elm_widget_data_get(obj);
2069 elm_gengrid_multi_select_get(const Evas_Object *obj)
2071 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2072 Widget_Data *wd = elm_widget_data_get(obj);
2073 if (!wd) return EINA_FALSE;
2077 EAPI Elm_Gengrid_Item *
2078 elm_gengrid_selected_item_get(const Evas_Object *obj)
2080 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2081 Widget_Data *wd = elm_widget_data_get(obj);
2082 if (!wd) return NULL;
2083 if (wd->selected) return wd->selected->data;
2087 EAPI const Eina_List *
2088 elm_gengrid_selected_items_get(const Evas_Object *obj)
2090 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2091 Widget_Data *wd = elm_widget_data_get(obj);
2092 if (!wd) return NULL;
2093 return wd->selected;
2097 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2100 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2101 Widget_Data *wd = item->wd;
2103 if (item->delete_me) return;
2104 selected = !!selected;
2105 if (item->selected == selected) return;
2111 while (wd->selected)
2112 _item_unselect(wd->selected->data);
2114 _item_hilight(item);
2118 _item_unselect(item);
2122 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2124 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2125 return item->selected;
2129 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2132 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2133 if (item->disabled == disabled) return;
2134 if (item->delete_me) return;
2135 item->disabled = !!disabled;
2139 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2141 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2146 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2148 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2149 if (item->delete_me) return EINA_FALSE;
2150 return item->disabled;
2153 static Evas_Object *
2154 _elm_gengrid_item_label_create(void *data,
2155 Evas_Object *obj __UNUSED__,
2156 Evas_Object *tooltip,
2157 void *item __UNUSED__)
2159 Evas_Object *label = elm_label_add(tooltip);
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);
2209 elm_widget_item_tooltip_size_restrict_disable(item, item->tooltip.free_size);
2215 if (del_cb) del_cb((void *)data, NULL, NULL);
2219 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2221 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2222 if ((item->base.view) && (item->tooltip.content_cb))
2223 elm_widget_item_tooltip_unset(item);
2225 if (item->tooltip.del_cb)
2226 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2227 item->tooltip.del_cb = NULL;
2228 item->tooltip.content_cb = NULL;
2229 item->tooltip.data = NULL;
2230 item->tooltip.free_size = EINA_FALSE;
2231 if (item->tooltip.style)
2232 elm_gengrid_item_tooltip_style_set(item, NULL);
2236 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2239 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2240 eina_stringshare_replace(&item->tooltip.style, style);
2241 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2245 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2247 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2248 return item->tooltip.style;
2252 elm_gengrid_item_tooltip_size_restrict_disable(Elm_Gengrid_Item *item, Eina_Bool disable)
2254 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2255 item->tooltip.free_size = disable;
2256 if (item->base.view) return elm_widget_item_tooltip_size_restrict_disable(item, disable);
2261 elm_gengrid_item_tooltip_size_restrict_disabled_get(const Elm_Gengrid_Item *item)
2263 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2264 return item->tooltip.free_size;
2268 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2271 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2272 eina_stringshare_replace(&item->mouse_cursor, cursor);
2273 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2277 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2279 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2280 return elm_widget_item_cursor_get(item);
2284 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2286 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2287 if (!item->mouse_cursor)
2290 if (item->base.view)
2291 elm_widget_item_cursor_unset(item);
2293 eina_stringshare_del(item->mouse_cursor);
2294 item->mouse_cursor = NULL;
2298 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2301 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2302 elm_widget_item_cursor_style_set(item, style);
2306 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2308 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2309 return elm_widget_item_cursor_style_get(item);
2313 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2314 Eina_Bool engine_only)
2316 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2317 elm_widget_item_cursor_engine_only_set(item, engine_only);
2321 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2323 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2324 return elm_widget_item_cursor_engine_only_get(item);
2328 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2329 Eina_Bool reorder_mode)
2331 ELM_CHECK_WIDTYPE(obj, widtype);
2332 Widget_Data *wd = elm_widget_data_get(obj);
2334 wd->reorder_mode = reorder_mode;
2338 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2340 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2341 Widget_Data *wd = elm_widget_data_get(obj);
2342 if (!wd) return EINA_FALSE;
2343 return wd->reorder_mode;
2347 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2348 Eina_Bool always_select)
2350 ELM_CHECK_WIDTYPE(obj, widtype);
2351 Widget_Data *wd = elm_widget_data_get(obj);
2353 wd->always_select = always_select;
2357 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2359 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2360 Widget_Data *wd = elm_widget_data_get(obj);
2361 if (!wd) return EINA_FALSE;
2362 return wd->always_select;
2366 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2367 Eina_Bool no_select)
2369 ELM_CHECK_WIDTYPE(obj, widtype);
2370 Widget_Data *wd = elm_widget_data_get(obj);
2372 wd->no_select = no_select;
2376 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2378 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2379 Widget_Data *wd = elm_widget_data_get(obj);
2380 if (!wd) return EINA_FALSE;
2381 return wd->no_select;
2385 elm_gengrid_bounce_set(Evas_Object *obj,
2389 ELM_CHECK_WIDTYPE(obj, widtype);
2390 Widget_Data *wd = elm_widget_data_get(obj);
2392 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2393 wd->h_bounce = h_bounce;
2394 wd->v_bounce = v_bounce;
2398 elm_gengrid_bounce_get(const Evas_Object *obj,
2399 Eina_Bool *h_bounce,
2400 Eina_Bool *v_bounce)
2402 ELM_CHECK_WIDTYPE(obj, widtype);
2403 Widget_Data *wd = elm_widget_data_get(obj);
2405 if (h_bounce) *h_bounce = wd->h_bounce;
2406 if (v_bounce) *v_bounce = wd->v_bounce;
2410 elm_gengrid_page_relative_set(Evas_Object *obj,
2414 Evas_Coord pagesize_h;
2415 Evas_Coord pagesize_v;
2417 ELM_CHECK_WIDTYPE(obj, widtype);
2418 Widget_Data *wd = elm_widget_data_get(obj);
2421 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
2422 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
2427 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2429 ELM_CHECK_WIDTYPE(obj, widtype);
2430 Widget_Data *wd = elm_widget_data_get(obj);
2433 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
2437 elm_gengrid_page_size_set(Evas_Object *obj,
2438 Evas_Coord h_pagesize,
2439 Evas_Coord v_pagesize)
2444 ELM_CHECK_WIDTYPE(obj, widtype);
2445 Widget_Data *wd = elm_widget_data_get(obj);
2447 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
2448 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
2452 EAPI Elm_Gengrid_Item *
2453 elm_gengrid_first_item_get(const Evas_Object *obj)
2455 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2456 Widget_Data *wd = elm_widget_data_get(obj);
2457 if (!wd) return NULL;
2458 if (!wd->items) return NULL;
2459 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2460 while ((item) && (item->delete_me))
2461 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2465 EAPI Elm_Gengrid_Item *
2466 elm_gengrid_last_item_get(const Evas_Object *obj)
2468 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2469 Widget_Data *wd = elm_widget_data_get(obj);
2470 if (!wd) return NULL;
2471 if (!wd->items) return NULL;
2472 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
2473 while ((item) && (item->delete_me))
2474 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2478 EAPI Elm_Gengrid_Item *
2479 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
2481 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2484 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2485 if ((item) && (!item->delete_me)) break;
2487 return (Elm_Gengrid_Item *)item;
2490 EAPI Elm_Gengrid_Item *
2491 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
2493 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2496 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2497 if ((item) && (!item->delete_me)) break;
2499 return (Elm_Gengrid_Item *)item;
2503 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
2505 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2506 return item->base.widget;
2510 elm_gengrid_item_show(Elm_Gengrid_Item *item)
2512 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2513 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2514 Evas_Coord minx = 0, miny = 0;
2517 if ((!item) || (item->delete_me)) return;
2518 _pan_min_get(wd->pan_smart, &minx, &miny);
2520 elm_smart_scroller_child_region_show(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);
2528 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
2530 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2531 if (item->delete_me) return;
2533 Evas_Coord minx = 0, miny = 0;
2534 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2536 _pan_min_get(wd->pan_smart, &minx, &miny);
2538 elm_smart_scroller_region_bring_in(item->wd->scr,
2539 item->x * wd->item_width + minx,
2540 item->y * wd->item_height + miny,
2541 item->wd->item_width,
2542 item->wd->item_height);