1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
7 * Handle non-homogeneous objects too.
10 typedef struct _Widget_Data Widget_Data;
11 typedef struct _Pan Pan;
14 #define REORDER_EFFECT_TIME 0.5
16 struct _Elm_Gengrid_Item
21 const Elm_Gengrid_Item_Class *gic;
22 Ecore_Timer *long_timer;
23 Ecore_Animator *item_moving_effect_timer;
25 Eina_List *labels, *icons, *states, *icon_objs;
32 Evas_Coord x, y, dx, dy, ox, oy, tx, ty, rx, ry;
33 unsigned int moving_effect_start_time;
40 Elm_Tooltip_Item_Content_Cb content_cb;
45 const char *mouse_cursor;
47 Eina_Bool want_unrealize : 1;
48 Eina_Bool realized : 1;
49 Eina_Bool dragging : 1;
51 Eina_Bool delete_me : 1;
52 Eina_Bool display_only : 1;
53 Eina_Bool disabled : 1;
54 Eina_Bool selected : 1;
55 Eina_Bool hilighted : 1;
61 Evas_Object *self, *scr;
62 Evas_Object *pan_smart;
67 Elm_Gengrid_Item *last_selected_item, *reorder_item;
68 double align_x, align_y;
70 Evas_Coord pan_x, pan_y, old_pan_x, old_pan_y;
71 Evas_Coord item_width, item_height; /* Each item size */
72 Evas_Coord minw, minh; /* Total obj size */
73 Evas_Coord reorder_item_x, reorder_item_y;
78 Eina_Bool horizontal : 1;
79 Eina_Bool on_hold : 1;
80 Eina_Bool longpressed : 1;
82 Eina_Bool no_select : 1;
83 Eina_Bool wasselected : 1;
84 Eina_Bool always_select : 1;
85 Eina_Bool clear_me : 1;
86 Eina_Bool h_bounce : 1;
87 Eina_Bool v_bounce : 1;
88 Eina_Bool reorder_mode : 1;
89 Eina_Bool reorder_item_changed : 1;
90 Eina_Bool move_effect_enabled : 1;
93 #define ELM_GENGRID_ITEM_FROM_INLIST(item) \
94 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
98 Evas_Object_Smart_Clipped_Data __clipped_data;
102 static const char *widtype = NULL;
103 static void _item_hilight(Elm_Gengrid_Item *item);
104 static void _item_unrealize(Elm_Gengrid_Item *item);
105 static void _item_select(Elm_Gengrid_Item *item);
106 static void _item_unselect(Elm_Gengrid_Item *item);
107 static void _calc_job(void *data);
108 static void _on_focus_hook(void *data,
110 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
111 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
112 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
113 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
114 static Eina_Bool _item_single_select_up(Widget_Data *wd);
115 static Eina_Bool _item_single_select_down(Widget_Data *wd);
116 static Eina_Bool _item_single_select_left(Widget_Data *wd);
117 static Eina_Bool _item_single_select_right(Widget_Data *wd);
118 static Eina_Bool _event_hook(Evas_Object *obj,
120 Evas_Callback_Type type,
122 static Eina_Bool _deselect_all_items(Widget_Data *wd);
124 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
125 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
127 static const char SIG_ACTIVATED[] = "activated";
128 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
129 static const char SIG_SELECTED[] = "selected";
130 static const char SIG_UNSELECTED[] = "unselected";
131 static const char SIG_REALIZED[] = "realized";
132 static const char SIG_UNREALIZED[] = "unrealized";
133 static const char SIG_CHANGED[] = "changed";
134 static const char SIG_DRAG_START_UP[] = "drag,start,up";
135 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
136 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
137 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
138 static const char SIG_DRAG_STOP[] = "drag,stop";
139 static const char SIG_DRAG[] = "drag";
140 static const char SIG_SCROLL[] = "scroll";
141 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
142 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
143 static const char SIG_MOVED[] = "moved";
145 static const Evas_Smart_Cb_Description _signals[] = {
147 {SIG_CLICKED_DOUBLE, ""},
149 {SIG_UNSELECTED, ""},
151 {SIG_UNREALIZED, ""},
153 {SIG_DRAG_START_UP, ""},
154 {SIG_DRAG_START_DOWN, ""},
155 {SIG_DRAG_START_LEFT, ""},
156 {SIG_DRAG_START_RIGHT, ""},
160 {SIG_SCROLL_DRAG_START, ""},
161 {SIG_SCROLL_DRAG_STOP, ""},
166 static Eina_Compare_Cb _elm_gengrid_item_compare_cb;
167 static Eina_Compare_Cb _elm_gengrid_item_compare_data_cb;
170 _event_hook(Evas_Object *obj,
171 Evas_Object *src __UNUSED__,
172 Evas_Callback_Type type,
175 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
176 Evas_Event_Key_Down *ev = event_info;
177 Widget_Data *wd = elm_widget_data_get(obj);
178 if (!wd) return EINA_FALSE;
179 if (!wd->items) return EINA_FALSE;
180 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
181 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
183 Elm_Gengrid_Item *item = NULL;
186 Evas_Coord step_x = 0;
187 Evas_Coord step_y = 0;
190 Evas_Coord page_x = 0;
191 Evas_Coord page_y = 0;
193 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
194 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
195 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
196 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
198 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
200 if ((wd->horizontal) &&
201 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
202 (_item_multi_select_up(wd)))
203 || (_item_single_select_up(wd))))
205 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
208 else if ((!wd->horizontal) &&
209 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
210 (_item_multi_select_left(wd)))
211 || (_item_single_select_left(wd))))
213 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
219 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
221 if ((wd->horizontal) &&
222 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
223 (_item_multi_select_down(wd)))
224 || (_item_single_select_down(wd))))
226 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
229 else if ((!wd->horizontal) &&
230 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
231 (_item_multi_select_right(wd)))
232 || (_item_single_select_right(wd))))
234 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
240 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
242 if ((wd->horizontal) &&
243 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
244 (_item_multi_select_left(wd)))
245 || (_item_single_select_left(wd))))
247 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
250 else if ((!wd->horizontal) &&
251 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
252 (_item_multi_select_up(wd)))
253 || (_item_single_select_up(wd))))
255 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
261 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
263 if ((wd->horizontal) &&
264 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
265 (_item_multi_select_right(wd)))
266 || (_item_single_select_right(wd))))
268 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
271 else if ((!wd->horizontal) &&
272 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
273 (_item_multi_select_down(wd)))
274 || (_item_single_select_down(wd))))
276 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
282 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
284 item = elm_gengrid_first_item_get(obj);
285 elm_gengrid_item_bring_in(item);
286 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
289 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
291 item = elm_gengrid_last_item_get(obj);
292 elm_gengrid_item_bring_in(item);
293 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
296 else if ((!strcmp(ev->keyname, "Prior")) ||
297 (!strcmp(ev->keyname, "KP_Prior")))
302 x -= -(page_x * v_w) / 100;
309 y -= -(page_y * v_h) / 100;
314 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
319 x += -(page_x * v_w) / 100;
326 y += -(page_y * v_h) / 100;
331 else if (!strcmp(ev->keyname, "Escape"))
333 if (!_deselect_all_items(wd)) return EINA_FALSE;
334 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
337 else if ((!strcmp(ev->keyname, "Return")) ||
338 (!strcmp(ev->keyname, "KP_Enter")) ||
339 (!strcmp(ev->keyname, "space")))
341 item = elm_gengrid_selected_item_get(obj);
342 evas_object_smart_callback_call(item->wd->self, SIG_ACTIVATED, item);
344 else return EINA_FALSE;
346 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
347 elm_smart_scroller_child_pos_set(wd->scr, x, y);
352 _deselect_all_items(Widget_Data *wd)
354 if (!wd->selected) return EINA_FALSE;
356 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
362 _item_multi_select_left(Widget_Data *wd)
364 if (!wd->selected) return EINA_FALSE;
366 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
367 if (!prev) return EINA_TRUE;
368 if (elm_gengrid_item_selected_get(prev))
370 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
371 wd->last_selected_item = prev;
372 elm_gengrid_item_show(wd->last_selected_item);
376 elm_gengrid_item_selected_set(prev, EINA_TRUE);
377 elm_gengrid_item_show(prev);
384 _item_multi_select_right(Widget_Data *wd)
386 if (!wd->selected) return EINA_FALSE;
388 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
389 if (!next) return EINA_TRUE;
390 if (elm_gengrid_item_selected_get(next))
392 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
393 wd->last_selected_item = next;
394 elm_gengrid_item_show(wd->last_selected_item);
398 elm_gengrid_item_selected_set(next, EINA_TRUE);
399 elm_gengrid_item_show(next);
406 _item_multi_select_up(Widget_Data *wd)
409 Eina_Bool r = EINA_TRUE;
411 if (!wd->selected) return EINA_FALSE;
413 for (i = 0; (r) && (i < wd->nmax); i++)
414 r &= _item_multi_select_left(wd);
420 _item_multi_select_down(Widget_Data *wd)
423 Eina_Bool r = EINA_TRUE;
425 if (!wd->selected) return EINA_FALSE;
427 for (i = 0; (r) && (i < wd->nmax); i++)
428 r &= _item_multi_select_right(wd);
434 _item_single_select_up(Widget_Data *wd)
438 Elm_Gengrid_Item *prev;
442 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
443 while ((prev) && (prev->delete_me))
444 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
445 elm_gengrid_item_selected_set(prev, EINA_TRUE);
446 elm_gengrid_item_show(prev);
449 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
451 if (!prev) return EINA_FALSE;
453 for (i = 1; i < wd->nmax; i++)
455 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
456 if (!tmp) return EINA_FALSE;
460 _deselect_all_items(wd);
462 elm_gengrid_item_selected_set(prev, EINA_TRUE);
463 elm_gengrid_item_show(prev);
468 _item_single_select_down(Widget_Data *wd)
472 Elm_Gengrid_Item *next;
476 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
477 while ((next) && (next->delete_me))
478 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
479 elm_gengrid_item_selected_set(next, EINA_TRUE);
480 elm_gengrid_item_show(next);
483 else next = elm_gengrid_item_next_get(wd->last_selected_item);
485 if (!next) return EINA_FALSE;
487 for (i = 1; i < wd->nmax; i++)
489 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
490 if (!tmp) return EINA_FALSE;
494 _deselect_all_items(wd);
496 elm_gengrid_item_selected_set(next, EINA_TRUE);
497 elm_gengrid_item_show(next);
502 _item_single_select_left(Widget_Data *wd)
504 Elm_Gengrid_Item *prev;
507 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
508 while ((prev) && (prev->delete_me))
509 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
511 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
513 if (!prev) return EINA_FALSE;
515 _deselect_all_items(wd);
517 elm_gengrid_item_selected_set(prev, EINA_TRUE);
518 elm_gengrid_item_show(prev);
523 _item_single_select_right(Widget_Data *wd)
525 Elm_Gengrid_Item *next;
528 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
529 while ((next) && (next->delete_me))
530 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
532 else next = elm_gengrid_item_next_get(wd->last_selected_item);
534 if (!next) return EINA_FALSE;
536 _deselect_all_items(wd);
538 elm_gengrid_item_selected_set(next, EINA_TRUE);
539 elm_gengrid_item_show(next);
544 _on_focus_hook(void *data __UNUSED__,
547 Widget_Data *wd = elm_widget_data_get(obj);
549 if (elm_widget_focus_get(obj))
551 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
552 evas_object_focus_set(wd->self, EINA_TRUE);
553 if ((wd->selected) && (!wd->last_selected_item))
554 wd->last_selected_item = eina_list_data_get(wd->selected);
558 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
559 evas_object_focus_set(wd->self, EINA_FALSE);
564 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
566 Widget_Data *wd = elm_widget_data_get(obj);
567 Elm_Gengrid_Item *item;
569 elm_smart_scroller_mirrored_set(wd->scr, rtl);
570 if (!wd->items) return;
571 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
575 edje_object_mirrored_set(item->base.view, rtl);
576 elm_gengrid_item_update(item);
577 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
582 _theme_hook(Evas_Object *obj)
584 Widget_Data *wd = elm_widget_data_get(obj);
586 _elm_widget_mirrored_reload(obj);
587 _mirrored_set(obj, elm_widget_mirrored_get(obj));
588 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
589 elm_widget_style_get(obj));
593 _del_pre_hook(Evas_Object *obj)
595 Widget_Data *wd = elm_widget_data_get(obj);
597 elm_gengrid_clear(obj);
598 evas_object_del(wd->pan_smart);
599 wd->pan_smart = NULL;
603 _del_hook(Evas_Object *obj)
605 Widget_Data *wd = elm_widget_data_get(obj);
610 _signal_emit_hook(Evas_Object *obj,
611 const char *emission,
614 Widget_Data *wd = elm_widget_data_get(obj);
616 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
621 _mouse_move(void *data,
622 Evas *evas __UNUSED__,
626 Elm_Gengrid_Item *item = data;
627 Evas_Event_Mouse_Move *ev = event_info;
628 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
629 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
631 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
633 if (!item->wd->on_hold)
635 item->wd->on_hold = EINA_TRUE;
636 if (!item->wd->wasselected)
637 _item_unselect(item);
640 if ((item->dragging) && (item->down))
642 if (item->long_timer)
644 ecore_timer_del(item->long_timer);
645 item->long_timer = NULL;
647 evas_object_smart_callback_call(item->wd->self, SIG_DRAG, item);
650 if ((!item->down) || (item->wd->longpressed))
652 if (item->long_timer)
654 ecore_timer_del(item->long_timer);
655 item->long_timer = NULL;
657 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
659 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &ow, &oh);
661 it_scrl_x = ev->cur.canvas.x - item->wd->reorder_item->dx;
662 it_scrl_y = ev->cur.canvas.y - item->wd->reorder_item->dy;
664 if (it_scrl_x < ox) item->wd->reorder_item_x = ox;
665 else if (it_scrl_x + item->wd->item_width > ox + ow)
666 item->wd->reorder_item_x = ox + ow - item->wd->item_width;
667 else item->wd->reorder_item_x = it_scrl_x;
669 if (it_scrl_y < oy) item->wd->reorder_item_y = oy;
670 else if (it_scrl_y + item->wd->item_height > oy + oh)
671 item->wd->reorder_item_y = oy + oh - item->wd->item_height;
672 else item->wd->reorder_item_y = it_scrl_y;
674 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
675 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
679 if (!item->display_only)
680 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
681 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
682 x = ev->cur.canvas.x - x;
683 y = ev->cur.canvas.y - y;
686 if (adx < 0) adx = -dx;
689 if (ady < 0) ady = -dy;
692 if ((adx > minw) || (ady > minh))
694 const char *left_drag, *right_drag;
695 if (!elm_widget_mirrored_get(item->wd->self))
697 left_drag = SIG_DRAG_START_LEFT;
698 right_drag = SIG_DRAG_START_RIGHT;
702 left_drag = SIG_DRAG_START_RIGHT;
703 right_drag = SIG_DRAG_START_LEFT;
707 if (item->long_timer)
709 ecore_timer_del(item->long_timer);
710 item->long_timer = NULL;
712 if (!item->wd->wasselected)
713 _item_unselect(item);
717 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_START_UP,
722 evas_object_smart_callback_call(item->wd->self,
729 evas_object_smart_callback_call(item->wd->self,
730 SIG_DRAG_START_DOWN, item);
734 evas_object_smart_callback_call(item->wd->self,
737 evas_object_smart_callback_call(item->wd->self,
745 _long_press(void *data)
747 Elm_Gengrid_Item *item = data;
749 item->long_timer = NULL;
750 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
751 item->wd->longpressed = EINA_TRUE;
752 evas_object_smart_callback_call(item->wd->self, "longpressed", item);
753 if (item->wd->reorder_mode)
755 item->wd->reorder_item = item;
756 evas_object_raise(item->base.view);
757 elm_smart_scroller_hold_set(item->wd->scr, EINA_TRUE);
758 elm_smart_scroller_bounce_allow_set(item->wd->scr, EINA_FALSE, EINA_FALSE);
759 edje_object_signal_emit(item->base.view, "elm,state,reorder,enabled", "elm");
761 return ECORE_CALLBACK_CANCEL;
765 _mouse_down(void *data,
766 Evas *evas __UNUSED__,
770 Elm_Gengrid_Item *item = data;
771 Evas_Event_Mouse_Down *ev = event_info;
774 if (ev->button != 1) return;
777 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
778 item->dx = ev->canvas.x - x;
779 item->dy = ev->canvas.y - y;
780 item->wd->longpressed = EINA_FALSE;
781 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
782 else item->wd->on_hold = EINA_FALSE;
783 item->wd->wasselected = item->selected;
785 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
787 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
788 evas_object_smart_callback_call(item->wd->self, SIG_ACTIVATED, item);
790 if (item->long_timer) ecore_timer_del(item->long_timer);
792 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
795 item->long_timer = NULL;
799 _mouse_up(void *data,
800 Evas *evas __UNUSED__,
801 Evas_Object *obj __UNUSED__,
804 Elm_Gengrid_Item *item = data;
805 Evas_Event_Mouse_Up *ev = event_info;
806 Eina_Bool dragged = EINA_FALSE;
808 if (ev->button != 1) return;
809 item->down = EINA_FALSE;
810 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
811 else item->wd->on_hold = EINA_FALSE;
812 if (item->long_timer)
814 ecore_timer_del(item->long_timer);
815 item->long_timer = NULL;
819 item->dragging = EINA_FALSE;
820 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_STOP, item);
823 if (item->wd->on_hold)
825 item->wd->longpressed = EINA_FALSE;
826 item->wd->on_hold = EINA_FALSE;
829 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
831 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
832 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
834 evas_object_smart_callback_call(item->wd->self, SIG_MOVED, item->wd->reorder_item);
835 item->wd->reorder_item = NULL;
836 elm_smart_scroller_hold_set(item->wd->scr, EINA_FALSE);
837 elm_smart_scroller_bounce_allow_set(item->wd->scr, item->wd->h_bounce, item->wd->v_bounce);
838 edje_object_signal_emit(item->base.view, "elm,state,reorder,disabled", "elm");
840 if (item->wd->longpressed)
842 item->wd->longpressed = EINA_FALSE;
843 if (!item->wd->wasselected) _item_unselect(item);
844 item->wd->wasselected = EINA_FALSE;
849 if (item->want_unrealize) _item_unrealize(item);
851 if ((item->disabled) || (dragged)) return;
859 else _item_unselect(item);
865 while (item->wd->selected)
866 _item_unselect(item->wd->selected->data);
870 const Eina_List *l, *l_next;
871 Elm_Gengrid_Item *item2;
873 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
874 if (item2 != item) _item_unselect(item2);
882 _item_hilight(Elm_Gengrid_Item *item)
884 if ((item->wd->no_select) || (item->delete_me) || (item->hilighted)) return;
885 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
886 item->hilighted = EINA_TRUE;
890 _item_realize(Elm_Gengrid_Item *item)
895 if ((item->realized) || (item->delete_me)) return;
896 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
897 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
899 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
900 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
901 elm_widget_sub_object_add(item->wd->self, item->base.view);
902 snprintf(style, sizeof(style), "item/%s",
903 item->gic->item_style ? item->gic->item_style : "default");
904 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
905 elm_widget_style_get(item->wd->self));
907 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
908 evas_object_color_set(item->spacer, 0, 0, 0, 0);
909 elm_widget_sub_object_add(item->wd->self, item->spacer);
910 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
911 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
913 if (item->gic->func.label_get)
919 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
921 EINA_LIST_FOREACH(item->labels, l, key)
923 char *s = item->gic->func.label_get
924 ((void *)item->base.data, item->wd->self, l->data);
927 edje_object_part_text_set(item->base.view, l->data, s);
933 if (item->gic->func.icon_get)
939 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
941 EINA_LIST_FOREACH(item->icons, l, key)
943 Evas_Object *ic = item->gic->func.icon_get
944 ((void *)item->base.data, item->wd->self, l->data);
947 item->icon_objs = eina_list_append(item->icon_objs, ic);
948 edje_object_part_swallow(item->base.view, key, ic);
949 evas_object_show(ic);
950 elm_widget_sub_object_add(item->wd->self, ic);
955 if (item->gic->func.state_get)
961 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
963 EINA_LIST_FOREACH(item->states, l, key)
965 Eina_Bool on = item->gic->func.state_get
966 ((void *)item->base.data, item->wd->self, l->data);
969 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
970 edje_object_signal_emit(item->base.view, buf, "elm");
975 if ((!item->wd->item_width) && (!item->wd->item_height))
977 edje_object_size_min_restricted_calc(item->base.view,
978 &item->wd->item_width,
979 &item->wd->item_height,
980 item->wd->item_width,
981 item->wd->item_height);
982 elm_coords_finger_size_adjust(1, &item->wd->item_width,
983 1, &item->wd->item_height);
986 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
988 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
990 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
994 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
996 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
998 evas_object_show(item->base.view);
1000 if (item->tooltip.content_cb)
1002 elm_widget_item_tooltip_content_cb_set(item,
1003 item->tooltip.content_cb,
1004 item->tooltip.data, NULL);
1005 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1008 if (item->mouse_cursor)
1009 elm_widget_item_cursor_set(item, item->mouse_cursor);
1011 item->realized = EINA_TRUE;
1012 item->want_unrealize = EINA_FALSE;
1016 _item_unrealize(Elm_Gengrid_Item *item)
1020 if (!item->realized) return;
1021 if (item->long_timer)
1023 ecore_timer_del(item->long_timer);
1024 item->long_timer = NULL;
1026 evas_object_del(item->base.view);
1027 item->base.view = NULL;
1028 evas_object_del(item->spacer);
1029 item->spacer = NULL;
1030 elm_widget_stringlist_free(item->labels);
1031 item->labels = NULL;
1032 elm_widget_stringlist_free(item->icons);
1034 elm_widget_stringlist_free(item->states);
1035 item->states = NULL;
1037 EINA_LIST_FREE(item->icon_objs, icon)
1038 evas_object_del(icon);
1040 item->realized = EINA_FALSE;
1041 item->want_unrealize = EINA_FALSE;
1045 _reorder_item_moving_effect_timer_cb(void *data)
1047 Elm_Gengrid_Item *item = data;
1051 time = REORDER_EFFECT_TIME;
1052 t = ((0.0 > (t = ecore_loop_time_get()-item->moving_effect_start_time)) ? 0.0 : t);
1053 dx = ((item->tx - item->ox) / 10) * _elm_config->scale;
1054 dy = ((item->ty - item->oy) / 10) * _elm_config->scale;
1058 item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
1059 item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
1067 if ((((dx > 0) && (item->rx >= item->tx)) || ((dx <= 0) && (item->rx <= item->tx))) &&
1068 (((dy > 0) && (item->ry >= item->ty)) || ((dy <= 0) && (item->ry <= item->ty))))
1070 evas_object_move(item->base.view, item->tx, item->ty);
1071 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1072 item->moving = EINA_FALSE;
1073 item->item_moving_effect_timer = NULL;
1074 return ECORE_CALLBACK_CANCEL;
1077 evas_object_move(item->base.view, item->rx, item->ry);
1078 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1080 return ECORE_CALLBACK_RENEW;
1084 _item_place(Elm_Gengrid_Item *item,
1088 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh;
1089 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1090 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1093 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1095 /* Preload rows/columns at each side of the Gengrid */
1096 cvx = ox - PRELOAD * item->wd->item_width;
1097 cvy = oy - PRELOAD * item->wd->item_height;
1098 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1099 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1104 if (item->wd->horizontal)
1106 int columns, items_visible = 0, items_row;
1108 if (item->wd->item_height > 0)
1109 items_visible = vh / item->wd->item_height;
1110 if (items_visible < 1)
1113 columns = item->wd->count / items_visible;
1114 if (item->wd->count % items_visible)
1117 tcw = item->wd->item_width * columns;
1118 alignw = (vw - tcw) * item->wd->align_x;
1120 items_row = items_visible;
1121 if (items_row > item->wd->count)
1122 items_row = item->wd->count;
1123 tch = items_row * item->wd->item_height;
1124 alignh = (vh - tch) * item->wd->align_y;
1128 int rows, items_visible = 0, items_col;
1130 if (item->wd->item_width > 0)
1131 items_visible = vw / item->wd->item_width;
1132 if (items_visible < 1)
1135 rows = item->wd->count / items_visible;
1136 if (item->wd->count % items_visible)
1139 tch = item->wd->item_height * rows;
1140 alignh = (vh - tch) * item->wd->align_y;
1142 items_col = items_visible;
1143 if (items_col > item->wd->count)
1144 items_col = item->wd->count;
1145 tcw = items_col * item->wd->item_width;
1146 alignw = (vw - tcw) * item->wd->align_x;
1149 x = cx * item->wd->item_width - item->wd->pan_x + ox + alignw;
1150 if (elm_widget_mirrored_get(item->wd->self))
1151 { /* Switch items side and componsate for pan_x when in RTL mode */
1153 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1154 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1157 y = cy * item->wd->item_height - item->wd->pan_y + oy + alignh;
1159 Eina_Bool was_realized = item->realized;
1160 if (ELM_RECTS_INTERSECT(x, y, item->wd->item_width, item->wd->item_height,
1161 cvx, cvy, cvw, cvh))
1163 _item_realize(item);
1165 evas_object_smart_callback_call(item->wd->self, SIG_REALIZED, item);
1166 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
1168 if (item->moving) return;
1170 if (!item->wd->move_effect_enabled)
1175 if (item->wd->reorder_item == item)
1177 evas_object_move(item->base.view,
1178 item->wd->reorder_item_x, item->wd->reorder_item_y);
1179 evas_object_resize(item->base.view,
1180 item->wd->item_width, item->wd->item_height);
1185 if (item->wd->move_effect_enabled)
1187 if ((item->ox != x) || (item->oy != y))
1189 if (((item->wd->old_pan_x == item->wd->pan_x) && (item->wd->old_pan_y == item->wd->pan_y)) ||
1190 ((item->wd->old_pan_x != item->wd->pan_x) && !(item->ox - item->wd->pan_x + item->wd->old_pan_x == x)) ||
1191 ((item->wd->old_pan_y != item->wd->pan_y) && !(item->oy - item->wd->pan_y + item->wd->old_pan_y == y)))
1195 item->rx = item->ox;
1196 item->ry = item->oy;
1197 item->moving = EINA_TRUE;
1198 item->moving_effect_start_time = ecore_loop_time_get();
1199 item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, item);
1205 if (ELM_RECTS_INTERSECT(item->wd->reorder_item_x, item->wd->reorder_item_y,
1206 item->wd->item_width, item->wd->item_height,
1207 x+(item->wd->item_width/2), y+(item->wd->item_height/2),
1210 if (item->wd->horizontal)
1212 if ((item->wd->nmax * item->wd->reorder_item->x + item->wd->reorder_item->y) >
1213 (item->wd->nmax * item->x + item->y))
1214 reorder_item_move_forward = EINA_TRUE;
1218 if ((item->wd->nmax * item->wd->reorder_item->y + item->wd->reorder_item->x) >
1219 (item->wd->nmax * item->y + item->x))
1220 reorder_item_move_forward = EINA_TRUE;
1223 item->wd->items = eina_inlist_remove(item->wd->items,
1224 EINA_INLIST_GET(item->wd->reorder_item));
1225 if (reorder_item_move_forward)
1226 item->wd->items = eina_inlist_prepend_relative(item->wd->items,
1227 EINA_INLIST_GET(item->wd->reorder_item),
1228 EINA_INLIST_GET(item));
1230 item->wd->items = eina_inlist_append_relative(item->wd->items,
1231 EINA_INLIST_GET(item->wd->reorder_item),
1232 EINA_INLIST_GET(item));
1234 item->wd->reorder_item_changed = EINA_TRUE;
1235 item->wd->move_effect_enabled = EINA_TRUE;
1236 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1237 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1243 evas_object_move(item->base.view, x, y);
1244 evas_object_resize(item->base.view, item->wd->item_width,
1245 item->wd->item_height);
1249 _item_unrealize(item);
1251 evas_object_smart_callback_call(item->wd->self, SIG_UNREALIZED, item);
1255 static Elm_Gengrid_Item *
1256 _item_create(Widget_Data *wd,
1257 const Elm_Gengrid_Item_Class *gic,
1260 const void *func_data)
1262 Elm_Gengrid_Item *item;
1264 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1265 if (!item) return NULL;
1269 item->base.data = data;
1270 item->func.func = func;
1271 item->func.data = func_data;
1272 item->mouse_cursor = NULL;
1277 _item_del(Elm_Gengrid_Item *item)
1279 elm_widget_item_pre_notify_del(item);
1281 item->wd->selected = eina_list_remove(item->wd->selected, item);
1282 if (item->realized) _item_unrealize(item);
1283 if ((!item->delete_me) && (item->gic->func.del))
1284 item->gic->func.del((void *)item->base.data, item->wd->self);
1285 item->delete_me = EINA_TRUE;
1286 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1287 if (item->long_timer) ecore_timer_del(item->long_timer);
1288 if (item->tooltip.del_cb)
1289 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1290 item->wd->walking -= item->walking;
1292 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1293 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1294 elm_widget_item_del(item);
1298 _item_select(Elm_Gengrid_Item *item)
1300 if ((item->wd->no_select) || (item->delete_me)) return;
1303 if (item->wd->always_select) goto call;
1306 item->selected = EINA_TRUE;
1307 item->wd->selected = eina_list_append(item->wd->selected, item);
1310 item->wd->walking++;
1311 if (item->func.func)
1312 item->func.func((void *)item->func.data, item->wd->self, item);
1313 if (!item->delete_me)
1314 evas_object_smart_callback_call(item->wd->self, SIG_SELECTED, item);
1316 item->wd->walking--;
1317 item->wd->last_selected_item = item;
1318 if ((item->wd->clear_me) && (!item->wd->walking))
1319 elm_gengrid_clear(item->base.widget);
1322 if ((!item->walking) && (item->delete_me))
1323 if (!item->relcount) _item_del(item);
1328 _item_unselect(Elm_Gengrid_Item *item)
1330 if ((item->delete_me) || (!item->hilighted)) return;
1331 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1332 item->hilighted = EINA_FALSE;
1335 item->selected = EINA_FALSE;
1336 item->wd->selected = eina_list_remove(item->wd->selected, item);
1337 evas_object_smart_callback_call(item->wd->self, SIG_UNSELECTED, item);
1342 _calc_job(void *data)
1344 Widget_Data *wd = data;
1345 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1348 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1349 if ((cvw != 0) || (cvh != 0))
1351 if ((wd->horizontal) && (wd->item_height > 0))
1352 nmax = cvh / wd->item_height;
1353 else if (wd->item_width > 0)
1354 nmax = cvw / wd->item_width;
1362 minw = ceil(count / (float)nmax) * wd->item_width;
1363 minh = nmax * wd->item_height;
1367 minw = nmax * wd->item_width;
1368 minh = ceil(count / (float)nmax) * wd->item_height;
1371 if ((minw != wd->minw) || (minh != wd->minh))
1375 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1379 evas_object_smart_changed(wd->pan_smart);
1381 wd->calc_job = NULL;
1385 _pan_add(Evas_Object *obj)
1388 Evas_Object_Smart_Clipped_Data *cd;
1391 cd = evas_object_smart_data_get(obj);
1394 sd->__clipped_data = *cd;
1396 evas_object_smart_data_set(obj, sd);
1400 _pan_del(Evas_Object *obj)
1402 Pan *sd = evas_object_smart_data_get(obj);
1409 _pan_set(Evas_Object *obj,
1413 Pan *sd = evas_object_smart_data_get(obj);
1414 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1417 evas_object_smart_changed(obj);
1421 _pan_get(Evas_Object *obj,
1425 Pan *sd = evas_object_smart_data_get(obj);
1426 if (x) *x = sd->wd->pan_x;
1427 if (y) *y = sd->wd->pan_y;
1431 _pan_child_size_get(Evas_Object *obj,
1435 Pan *sd = evas_object_smart_data_get(obj);
1436 if (w) *w = sd->wd->minw;
1437 if (h) *h = sd->wd->minh;
1441 _pan_max_get(Evas_Object *obj,
1445 Pan *sd = evas_object_smart_data_get(obj);
1449 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1451 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1453 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1457 _pan_min_get(Evas_Object *obj,
1461 Pan *sd = evas_object_smart_data_get(obj);
1465 _pan_max_get(obj, &mx, &my);
1467 *x = -mx * sd->wd->align_x;
1469 *y = -my * sd->wd->align_y;
1473 _pan_resize(Evas_Object *obj,
1477 Pan *sd = evas_object_smart_data_get(obj);
1480 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1481 if ((ow == w) && (oh == h)) return;
1482 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1483 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1487 _pan_calculate(Evas_Object *obj)
1489 Pan *sd = evas_object_smart_data_get(obj);
1490 Evas_Coord cx = 0, cy = 0;
1491 Elm_Gengrid_Item *item;
1494 if (!sd->wd->nmax) return;
1496 sd->wd->reorder_item_changed = EINA_FALSE;
1498 EINA_INLIST_FOREACH(sd->wd->items, item)
1500 _item_place(item, cx, cy);
1501 if (sd->wd->reorder_item_changed) return;
1502 if (sd->wd->horizontal)
1504 cy = (cy + 1) % sd->wd->nmax;
1509 cx = (cx + 1) % sd->wd->nmax;
1514 if ((sd->wd->reorder_mode) && (sd->wd->reorder_item))
1516 if (!sd->wd->reorder_item_changed)
1518 sd->wd->old_pan_x = sd->wd->pan_x;
1519 sd->wd->old_pan_y = sd->wd->pan_y;
1521 sd->wd->move_effect_enabled = EINA_FALSE;
1523 evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
1527 _pan_move(Evas_Object *obj,
1528 Evas_Coord x __UNUSED__,
1529 Evas_Coord y __UNUSED__)
1531 Pan *sd = evas_object_smart_data_get(obj);
1533 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1534 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1538 _hold_on(void *data __UNUSED__,
1540 void *event_info __UNUSED__)
1542 Widget_Data *wd = elm_widget_data_get(obj);
1544 elm_smart_scroller_hold_set(wd->scr, 1);
1548 _hold_off(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, 0);
1558 _freeze_on(void *data __UNUSED__,
1560 void *event_info __UNUSED__)
1562 Widget_Data *wd = elm_widget_data_get(obj);
1564 elm_smart_scroller_freeze_set(wd->scr, 1);
1568 _freeze_off(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, 0);
1578 _scr_drag_start(void *data,
1579 Evas_Object *obj __UNUSED__,
1580 void *event_info __UNUSED__)
1582 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1586 _scr_drag_stop(void *data,
1587 Evas_Object *obj __UNUSED__,
1588 void *event_info __UNUSED__)
1590 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1594 _scr_scroll(void *data,
1595 Evas_Object *obj __UNUSED__,
1596 void *event_info __UNUSED__)
1598 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1602 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1604 const Elm_Gengrid_Item *item = data;
1605 const Elm_Gengrid_Item *item1 = data1;
1607 return _elm_gengrid_item_compare_data_cb(item->base.data, item1->base.data);
1611 _elm_gengrid_item_compare(const void *data, const void *data1)
1613 Elm_Gengrid_Item *item, *item1;
1614 item = ELM_GENGRID_ITEM_FROM_INLIST(data);
1615 item1 = ELM_GENGRID_ITEM_FROM_INLIST(data1);
1616 return _elm_gengrid_item_compare_cb(item, item1);
1620 elm_gengrid_add(Evas_Object *parent)
1625 static Evas_Smart *smart = NULL;
1626 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1628 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1630 ELM_SET_WIDTYPE(widtype, "gengrid");
1631 elm_widget_type_set(obj, "gengrid");
1632 elm_widget_sub_object_add(parent, obj);
1633 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1634 elm_widget_data_set(obj, wd);
1635 elm_widget_del_hook_set(obj, _del_hook);
1636 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1637 elm_widget_theme_hook_set(obj, _theme_hook);
1638 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1639 elm_widget_can_focus_set(obj, EINA_TRUE);
1640 elm_widget_event_hook_set(obj, _event_hook);
1642 wd->scr = elm_smart_scroller_add(e);
1643 elm_smart_scroller_widget_set(wd->scr, obj);
1644 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1646 elm_widget_resize_object_set(obj, wd->scr);
1648 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1649 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1650 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1652 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1657 wd->h_bounce = bounce;
1658 wd->v_bounce = bounce;
1659 wd->no_select = EINA_FALSE;
1661 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1662 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1663 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1664 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1666 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1670 static Evas_Smart_Class sc;
1672 evas_object_smart_clipped_smart_set(&_pan_sc);
1674 sc.name = "elm_gengrid_pan";
1675 sc.version = EVAS_SMART_CLASS_VERSION;
1678 sc.resize = _pan_resize;
1679 sc.move = _pan_move;
1680 sc.calculate = _pan_calculate;
1681 smart = evas_smart_class_new(&sc);
1685 wd->pan_smart = evas_object_smart_add(e, smart);
1686 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1690 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1691 _pan_set, _pan_get, _pan_max_get,
1692 _pan_min_get, _pan_child_size_get);
1694 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1699 elm_gengrid_item_size_set(Evas_Object *obj,
1703 ELM_CHECK_WIDTYPE(obj, widtype);
1704 Widget_Data *wd = elm_widget_data_get(obj);
1706 if ((wd->item_width == w) && (wd->item_height == h)) return;
1708 wd->item_height = h;
1709 if (wd->calc_job) ecore_job_del(wd->calc_job);
1710 wd->calc_job = ecore_job_add(_calc_job, wd);
1714 elm_gengrid_item_size_get(const Evas_Object *obj,
1718 ELM_CHECK_WIDTYPE(obj, widtype);
1719 Widget_Data *wd = elm_widget_data_get(obj);
1721 if (w) *w = wd->item_width;
1722 if (h) *h = wd->item_height;
1726 elm_gengrid_align_set(Evas_Object *obj,
1730 ELM_CHECK_WIDTYPE(obj, widtype);
1732 Widget_Data *wd = elm_widget_data_get(obj);
1733 double old_h = wd->align_x, old_y = wd->align_y;
1737 else if (align_x < 0.0)
1739 wd->align_x = align_x;
1743 else if (align_y < 0.0)
1745 wd->align_y = align_y;
1747 if ((old_h != wd->align_x) || (old_y != wd->align_y))
1748 evas_object_smart_calculate(wd->pan_smart);
1752 elm_gengrid_align_get(const Evas_Object *obj,
1756 ELM_CHECK_WIDTYPE(obj, widtype);
1757 Widget_Data *wd = elm_widget_data_get(obj);
1758 if (align_x) *align_x = wd->align_x;
1759 if (align_y) *align_y = wd->align_y;
1762 EAPI Elm_Gengrid_Item *
1763 elm_gengrid_item_append(Evas_Object *obj,
1764 const Elm_Gengrid_Item_Class *gic,
1767 const void *func_data)
1769 Elm_Gengrid_Item *item;
1770 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1771 Widget_Data *wd = elm_widget_data_get(obj);
1772 if (!wd) return NULL;
1774 item = _item_create(wd, gic, data, func, func_data);
1775 if (!item) return NULL;
1776 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
1778 if (wd->calc_job) ecore_job_del(wd->calc_job);
1779 wd->calc_job = ecore_job_add(_calc_job, wd);
1784 EAPI Elm_Gengrid_Item *
1785 elm_gengrid_item_prepend(Evas_Object *obj,
1786 const Elm_Gengrid_Item_Class *gic,
1789 const void *func_data)
1791 Elm_Gengrid_Item *item;
1792 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1793 Widget_Data *wd = elm_widget_data_get(obj);
1794 if (!wd) return NULL;
1796 item = _item_create(wd, gic, data, func, func_data);
1797 if (!item) return NULL;
1798 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
1800 if (wd->calc_job) ecore_job_del(wd->calc_job);
1801 wd->calc_job = ecore_job_add(_calc_job, wd);
1806 EAPI Elm_Gengrid_Item *
1807 elm_gengrid_item_insert_before(Evas_Object *obj,
1808 const Elm_Gengrid_Item_Class *gic,
1810 Elm_Gengrid_Item *relative,
1812 const void *func_data)
1814 Elm_Gengrid_Item *item;
1815 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1816 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1817 Widget_Data *wd = elm_widget_data_get(obj);
1818 if (!wd) return NULL;
1820 item = _item_create(wd, gic, data, func, func_data);
1821 if (!item) return NULL;
1822 wd->items = eina_inlist_prepend_relative
1823 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1825 if (wd->calc_job) ecore_job_del(wd->calc_job);
1826 wd->calc_job = ecore_job_add(_calc_job, wd);
1831 EAPI Elm_Gengrid_Item *
1832 elm_gengrid_item_insert_after(Evas_Object *obj,
1833 const Elm_Gengrid_Item_Class *gic,
1835 Elm_Gengrid_Item *relative,
1837 const void *func_data)
1839 Elm_Gengrid_Item *item;
1840 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1841 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1842 Widget_Data *wd = elm_widget_data_get(obj);
1843 if (!wd) return NULL;
1845 item = _item_create(wd, gic, data, func, func_data);
1846 if (!item) return NULL;
1847 wd->items = eina_inlist_append_relative
1848 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1850 if (wd->calc_job) ecore_job_del(wd->calc_job);
1851 wd->calc_job = ecore_job_add(_calc_job, wd);
1856 EAPI Elm_Gengrid_Item *
1857 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
1858 const Elm_Gengrid_Item_Class *gic,
1860 Eina_Compare_Cb comp,
1862 const void *func_data)
1864 Elm_Gengrid_Item *item;
1865 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1866 Widget_Data *wd = elm_widget_data_get(obj);
1867 if (!wd) return NULL;
1869 item = _item_create(wd, gic, data, func, func_data);
1870 if (!item) return NULL;
1872 _elm_gengrid_item_compare_cb = comp;
1873 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(item),
1874 _elm_gengrid_item_compare);
1875 if (wd->calc_job) ecore_job_del(wd->calc_job);
1876 wd->calc_job = ecore_job_add(_calc_job, wd);
1881 EAPI Elm_Gengrid_Item *
1882 elm_gengrid_item_sorted_insert(Evas_Object *obj,
1883 const Elm_Gengrid_Item_Class *gic,
1885 Eina_Compare_Cb comp,
1887 const void *func_data)
1889 _elm_gengrid_item_compare_data_cb = comp;
1891 return elm_gengrid_item_direct_sorted_insert(obj, gic, data, _elm_gengrid_item_compare_data, func, func_data);
1895 elm_gengrid_item_del(Elm_Gengrid_Item *item)
1897 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1898 if ((item->relcount > 0) || (item->walking > 0))
1900 item->delete_me = EINA_TRUE;
1901 elm_widget_item_pre_notify_del(item);
1903 item->wd->selected = eina_list_remove(item->wd->selected, item);
1904 if (item->gic->func.del)
1905 item->gic->func.del((void *)item->base.data, item->wd->self);
1913 elm_gengrid_horizontal_set(Evas_Object *obj,
1916 ELM_CHECK_WIDTYPE(obj, widtype);
1917 Widget_Data *wd = elm_widget_data_get(obj);
1919 if (setting == wd->horizontal) return;
1920 wd->horizontal = setting;
1922 /* Update the items to conform to the new layout */
1923 if (wd->calc_job) ecore_job_del(wd->calc_job);
1924 wd->calc_job = ecore_job_add(_calc_job, wd);
1928 elm_gengrid_horizontal_get(const Evas_Object *obj)
1930 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1931 Widget_Data *wd = elm_widget_data_get(obj);
1932 if (!wd) return EINA_FALSE;
1933 return wd->horizontal;
1937 elm_gengrid_clear(Evas_Object *obj)
1939 ELM_CHECK_WIDTYPE(obj, widtype);
1940 Widget_Data *wd = elm_widget_data_get(obj);
1945 ecore_job_del(wd->calc_job);
1946 wd->calc_job = NULL;
1949 if (wd->walking > 0)
1951 Elm_Gengrid_Item *item;
1953 EINA_INLIST_FOREACH(wd->items, item)
1954 item->delete_me = 1;
1960 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
1962 wd->items = eina_inlist_remove(wd->items, wd->items);
1963 elm_widget_item_pre_notify_del(item);
1964 if (item->realized) _item_unrealize(item);
1965 if (item->gic->func.del)
1966 item->gic->func.del((void *)item->base.data, wd->self);
1967 if (item->long_timer) ecore_timer_del(item->long_timer);
1968 elm_widget_item_del(item);
1973 eina_list_free(wd->selected);
1974 wd->selected = NULL;
1982 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
1983 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1986 EAPI const Evas_Object *
1987 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
1989 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1990 return item->base.view;
1994 elm_gengrid_item_update(Elm_Gengrid_Item *item)
1996 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1997 if (!item->realized) return;
1998 if (item->want_unrealize) return;
1999 _item_unrealize(item);
2000 _item_realize(item);
2001 _item_place(item, item->x, item->y);
2005 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2007 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2008 return elm_widget_item_data_get(item);
2012 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2015 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2016 elm_widget_item_data_set(item, data);
2019 EAPI const Elm_Gengrid_Item_Class *
2020 elm_gengrid_item_item_class_get(const Elm_Gengrid_Item *item)
2022 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2023 if (item->delete_me) return NULL;
2028 elm_gengrid_item_item_class_set(Elm_Gengrid_Item *item,
2029 const Elm_Gengrid_Item_Class *gic)
2031 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2032 EINA_SAFETY_ON_NULL_RETURN(gic);
2033 if (item->delete_me) return;
2035 elm_gengrid_item_update(item);
2039 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2043 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2044 if (x) *x = item->x;
2045 if (y) *y = item->y;
2049 elm_gengrid_multi_select_set(Evas_Object *obj,
2052 ELM_CHECK_WIDTYPE(obj, widtype);
2053 Widget_Data *wd = elm_widget_data_get(obj);
2059 elm_gengrid_multi_select_get(const Evas_Object *obj)
2061 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2062 Widget_Data *wd = elm_widget_data_get(obj);
2063 if (!wd) return EINA_FALSE;
2067 EAPI Elm_Gengrid_Item *
2068 elm_gengrid_selected_item_get(const Evas_Object *obj)
2070 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2071 Widget_Data *wd = elm_widget_data_get(obj);
2072 if (!wd) return NULL;
2073 if (wd->selected) return wd->selected->data;
2077 EAPI const Eina_List *
2078 elm_gengrid_selected_items_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 return wd->selected;
2087 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2090 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2091 Widget_Data *wd = item->wd;
2093 if (item->delete_me) return;
2094 selected = !!selected;
2095 if (item->selected == selected) return;
2101 while (wd->selected)
2102 _item_unselect(wd->selected->data);
2104 _item_hilight(item);
2108 _item_unselect(item);
2112 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2114 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2115 return item->selected;
2119 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2122 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2123 if (item->disabled == disabled) return;
2124 if (item->delete_me) return;
2125 item->disabled = !!disabled;
2129 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2131 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2136 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2138 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2139 if (item->delete_me) return EINA_FALSE;
2140 return item->disabled;
2143 static Evas_Object *
2144 _elm_gengrid_item_label_create(void *data,
2145 Evas_Object *obj __UNUSED__,
2146 Evas_Object *tooltip,
2147 void *item __UNUSED__)
2149 Evas_Object *label = elm_label_add(tooltip);
2152 elm_object_style_set(label, "tooltip");
2153 elm_object_text_set(label, data);
2158 _elm_gengrid_item_label_del_cb(void *data,
2159 Evas_Object *obj __UNUSED__,
2160 void *event_info __UNUSED__)
2162 eina_stringshare_del(data);
2166 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2169 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2170 text = eina_stringshare_add(text);
2171 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2173 _elm_gengrid_item_label_del_cb);
2177 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2178 Elm_Tooltip_Item_Content_Cb func,
2180 Evas_Smart_Cb del_cb)
2182 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2184 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2187 if (item->tooltip.del_cb)
2188 item->tooltip.del_cb((void *)item->tooltip.data,
2189 item->base.widget, item);
2190 item->tooltip.content_cb = func;
2191 item->tooltip.data = data;
2192 item->tooltip.del_cb = del_cb;
2193 if (item->base.view)
2195 elm_widget_item_tooltip_content_cb_set(item,
2196 item->tooltip.content_cb,
2197 item->tooltip.data, NULL);
2198 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2204 if (del_cb) del_cb((void *)data, NULL, NULL);
2208 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2210 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2211 if ((item->base.view) && (item->tooltip.content_cb))
2212 elm_widget_item_tooltip_unset(item);
2214 if (item->tooltip.del_cb)
2215 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2216 item->tooltip.del_cb = NULL;
2217 item->tooltip.content_cb = NULL;
2218 item->tooltip.data = NULL;
2219 if (item->tooltip.style)
2220 elm_gengrid_item_tooltip_style_set(item, NULL);
2224 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2227 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2228 eina_stringshare_replace(&item->tooltip.style, style);
2229 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2233 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2235 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2236 return item->tooltip.style;
2240 elm_gengrid_item_tooltip_size_restrict_disable(Elm_Gengrid_Item *item, Eina_Bool disable)
2242 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2243 return elm_widget_item_tooltip_size_restrict_disable(item, disable);
2247 elm_gengrid_item_tooltip_size_restrict_disabled_get(const Elm_Gengrid_Item *item)
2249 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2250 return elm_widget_item_tooltip_size_restrict_disabled_get(item);
2254 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2257 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2258 eina_stringshare_replace(&item->mouse_cursor, cursor);
2259 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2263 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2265 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2266 return elm_widget_item_cursor_get(item);
2270 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2272 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2273 if (!item->mouse_cursor)
2276 if (item->base.view)
2277 elm_widget_item_cursor_unset(item);
2279 eina_stringshare_del(item->mouse_cursor);
2280 item->mouse_cursor = NULL;
2284 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2287 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2288 elm_widget_item_cursor_style_set(item, style);
2292 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2294 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2295 return elm_widget_item_cursor_style_get(item);
2299 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2300 Eina_Bool engine_only)
2302 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2303 elm_widget_item_cursor_engine_only_set(item, engine_only);
2307 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2309 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2310 return elm_widget_item_cursor_engine_only_get(item);
2314 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2315 Eina_Bool reorder_mode)
2317 ELM_CHECK_WIDTYPE(obj, widtype);
2318 Widget_Data *wd = elm_widget_data_get(obj);
2320 wd->reorder_mode = reorder_mode;
2324 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2326 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2327 Widget_Data *wd = elm_widget_data_get(obj);
2328 if (!wd) return EINA_FALSE;
2329 return wd->reorder_mode;
2333 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2334 Eina_Bool always_select)
2336 ELM_CHECK_WIDTYPE(obj, widtype);
2337 Widget_Data *wd = elm_widget_data_get(obj);
2339 wd->always_select = always_select;
2343 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2345 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2346 Widget_Data *wd = elm_widget_data_get(obj);
2347 if (!wd) return EINA_FALSE;
2348 return wd->always_select;
2352 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2353 Eina_Bool no_select)
2355 ELM_CHECK_WIDTYPE(obj, widtype);
2356 Widget_Data *wd = elm_widget_data_get(obj);
2358 wd->no_select = no_select;
2362 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2364 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2365 Widget_Data *wd = elm_widget_data_get(obj);
2366 if (!wd) return EINA_FALSE;
2367 return wd->no_select;
2371 elm_gengrid_bounce_set(Evas_Object *obj,
2375 ELM_CHECK_WIDTYPE(obj, widtype);
2376 Widget_Data *wd = elm_widget_data_get(obj);
2378 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2379 wd->h_bounce = h_bounce;
2380 wd->v_bounce = v_bounce;
2384 elm_gengrid_bounce_get(const Evas_Object *obj,
2385 Eina_Bool *h_bounce,
2386 Eina_Bool *v_bounce)
2388 ELM_CHECK_WIDTYPE(obj, widtype);
2389 Widget_Data *wd = elm_widget_data_get(obj);
2391 if (h_bounce) *h_bounce = wd->h_bounce;
2392 if (v_bounce) *v_bounce = wd->v_bounce;
2396 elm_gengrid_page_relative_set(Evas_Object *obj,
2400 Evas_Coord pagesize_h;
2401 Evas_Coord pagesize_v;
2403 ELM_CHECK_WIDTYPE(obj, widtype);
2404 Widget_Data *wd = elm_widget_data_get(obj);
2407 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
2408 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
2413 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2415 ELM_CHECK_WIDTYPE(obj, widtype);
2416 Widget_Data *wd = elm_widget_data_get(obj);
2419 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
2423 elm_gengrid_page_size_set(Evas_Object *obj,
2424 Evas_Coord h_pagesize,
2425 Evas_Coord v_pagesize)
2430 ELM_CHECK_WIDTYPE(obj, widtype);
2431 Widget_Data *wd = elm_widget_data_get(obj);
2433 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
2434 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
2438 EAPI Elm_Gengrid_Item *
2439 elm_gengrid_first_item_get(const Evas_Object *obj)
2441 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2442 Widget_Data *wd = elm_widget_data_get(obj);
2443 if (!wd) return NULL;
2444 if (!wd->items) return NULL;
2445 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2446 while ((item) && (item->delete_me))
2447 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2451 EAPI Elm_Gengrid_Item *
2452 elm_gengrid_last_item_get(const Evas_Object *obj)
2454 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2455 Widget_Data *wd = elm_widget_data_get(obj);
2456 if (!wd) return NULL;
2457 if (!wd->items) return NULL;
2458 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
2459 while ((item) && (item->delete_me))
2460 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2464 EAPI Elm_Gengrid_Item *
2465 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
2467 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2470 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2471 if ((item) && (!item->delete_me)) break;
2473 return (Elm_Gengrid_Item *)item;
2476 EAPI Elm_Gengrid_Item *
2477 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
2479 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2482 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2483 if ((item) && (!item->delete_me)) break;
2485 return (Elm_Gengrid_Item *)item;
2489 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
2491 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2492 return item->base.widget;
2496 elm_gengrid_item_show(Elm_Gengrid_Item *item)
2498 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2499 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2500 Evas_Coord minx = 0, miny = 0;
2503 if ((!item) || (item->delete_me)) return;
2504 _pan_min_get(wd->pan_smart, &minx, &miny);
2506 elm_smart_scroller_child_region_show(item->wd->scr,
2507 item->x * wd->item_width + minx,
2508 item->y * wd->item_height + miny,
2509 item->wd->item_width,
2510 item->wd->item_height);
2514 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
2516 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2517 if (item->delete_me) return;
2519 Evas_Coord minx = 0, miny = 0;
2520 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2522 _pan_min_get(wd->pan_smart, &minx, &miny);
2524 elm_smart_scroller_region_bring_in(item->wd->scr,
2525 item->x * wd->item_width + minx,
2526 item->y * wd->item_height + miny,
2527 item->wd->item_width,
2528 item->wd->item_height);