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 highlighted : 1;
62 Eina_Inlist_Sorted_State *state;
63 Evas_Object *self, *scr;
64 Evas_Object *pan_smart;
69 Elm_Gengrid_Item *last_selected_item, *reorder_item;
70 double align_x, align_y;
72 Evas_Coord pan_x, pan_y, old_pan_x, old_pan_y;
73 Evas_Coord item_width, item_height; /* Each item size */
74 Evas_Coord minw, minh; /* Total obj size */
75 Evas_Coord reorder_item_x, reorder_item_y;
80 Eina_Bool horizontal : 1;
81 Eina_Bool on_hold : 1;
82 Eina_Bool longpressed : 1;
84 Eina_Bool no_select : 1;
85 Eina_Bool wasselected : 1;
86 Eina_Bool always_select : 1;
87 Eina_Bool clear_me : 1;
88 Eina_Bool h_bounce : 1;
89 Eina_Bool v_bounce : 1;
90 Eina_Bool reorder_mode : 1;
91 Eina_Bool reorder_item_changed : 1;
92 Eina_Bool move_effect_enabled : 1;
95 #define ELM_GENGRID_ITEM_FROM_INLIST(item) \
96 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
100 Evas_Object_Smart_Clipped_Data __clipped_data;
104 static const char *widtype = NULL;
105 static void _item_highlight(Elm_Gengrid_Item *item);
106 static void _item_unrealize(Elm_Gengrid_Item *item);
107 static void _item_select(Elm_Gengrid_Item *item);
108 static void _item_unselect(Elm_Gengrid_Item *item);
109 static void _calc_job(void *data);
110 static void _on_focus_hook(void *data,
112 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
113 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
114 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
115 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
116 static Eina_Bool _item_single_select_up(Widget_Data *wd);
117 static Eina_Bool _item_single_select_down(Widget_Data *wd);
118 static Eina_Bool _item_single_select_left(Widget_Data *wd);
119 static Eina_Bool _item_single_select_right(Widget_Data *wd);
120 static Eina_Bool _event_hook(Evas_Object *obj,
122 Evas_Callback_Type type,
124 static Eina_Bool _deselect_all_items(Widget_Data *wd);
126 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
127 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
129 static const char SIG_ACTIVATED[] = "activated";
130 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
131 static const char SIG_SELECTED[] = "selected";
132 static const char SIG_UNSELECTED[] = "unselected";
133 static const char SIG_REALIZED[] = "realized";
134 static const char SIG_UNREALIZED[] = "unrealized";
135 static const char SIG_CHANGED[] = "changed";
136 static const char SIG_DRAG_START_UP[] = "drag,start,up";
137 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
138 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
139 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
140 static const char SIG_DRAG_STOP[] = "drag,stop";
141 static const char SIG_DRAG[] = "drag";
142 static const char SIG_SCROLL[] = "scroll";
143 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
144 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
145 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
146 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
147 static const char SIG_MOVED[] = "moved";
149 static const Evas_Smart_Cb_Description _signals[] = {
151 {SIG_CLICKED_DOUBLE, ""},
153 {SIG_UNSELECTED, ""},
155 {SIG_UNREALIZED, ""},
157 {SIG_DRAG_START_UP, ""},
158 {SIG_DRAG_START_DOWN, ""},
159 {SIG_DRAG_START_LEFT, ""},
160 {SIG_DRAG_START_RIGHT, ""},
164 {SIG_SCROLL_ANIM_START, ""},
165 {SIG_SCROLL_ANIM_STOP, ""},
166 {SIG_SCROLL_DRAG_START, ""},
167 {SIG_SCROLL_DRAG_STOP, ""},
172 static Eina_Compare_Cb _elm_gengrid_item_compare_cb;
173 static Eina_Compare_Cb _elm_gengrid_item_compare_data_cb;
176 _event_hook(Evas_Object *obj,
177 Evas_Object *src __UNUSED__,
178 Evas_Callback_Type type,
181 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
182 Evas_Event_Key_Down *ev = event_info;
183 Widget_Data *wd = elm_widget_data_get(obj);
184 if (!wd) return EINA_FALSE;
185 if (!wd->items) return EINA_FALSE;
186 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
187 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
189 Elm_Gengrid_Item *item = NULL;
192 Evas_Coord step_x = 0;
193 Evas_Coord step_y = 0;
196 Evas_Coord page_x = 0;
197 Evas_Coord page_y = 0;
199 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
200 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
201 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
202 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
204 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
206 if ((wd->horizontal) &&
207 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
208 (_item_multi_select_up(wd)))
209 || (_item_single_select_up(wd))))
211 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
214 else if ((!wd->horizontal) &&
215 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
216 (_item_multi_select_left(wd)))
217 || (_item_single_select_left(wd))))
219 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
225 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
227 if ((wd->horizontal) &&
228 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
229 (_item_multi_select_down(wd)))
230 || (_item_single_select_down(wd))))
232 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
235 else if ((!wd->horizontal) &&
236 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
237 (_item_multi_select_right(wd)))
238 || (_item_single_select_right(wd))))
240 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
246 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
248 if ((wd->horizontal) &&
249 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
250 (_item_multi_select_left(wd)))
251 || (_item_single_select_left(wd))))
253 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
256 else if ((!wd->horizontal) &&
257 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
258 (_item_multi_select_up(wd)))
259 || (_item_single_select_up(wd))))
261 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
267 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
269 if ((wd->horizontal) &&
270 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
271 (_item_multi_select_right(wd)))
272 || (_item_single_select_right(wd))))
274 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
277 else if ((!wd->horizontal) &&
278 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
279 (_item_multi_select_down(wd)))
280 || (_item_single_select_down(wd))))
282 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
288 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
290 item = elm_gengrid_first_item_get(obj);
291 elm_gengrid_item_bring_in(item);
292 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
295 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
297 item = elm_gengrid_last_item_get(obj);
298 elm_gengrid_item_bring_in(item);
299 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
302 else if ((!strcmp(ev->keyname, "Prior")) ||
303 (!strcmp(ev->keyname, "KP_Prior")))
308 x -= -(page_x * v_w) / 100;
315 y -= -(page_y * v_h) / 100;
320 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
325 x += -(page_x * v_w) / 100;
332 y += -(page_y * v_h) / 100;
337 else if (!strcmp(ev->keyname, "Escape"))
339 if (!_deselect_all_items(wd)) return EINA_FALSE;
340 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
343 else if ((!strcmp(ev->keyname, "Return")) ||
344 (!strcmp(ev->keyname, "KP_Enter")) ||
345 (!strcmp(ev->keyname, "space")))
347 item = elm_gengrid_selected_item_get(obj);
348 evas_object_smart_callback_call(item->wd->self, SIG_ACTIVATED, item);
350 else return EINA_FALSE;
352 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
353 elm_smart_scroller_child_pos_set(wd->scr, x, y);
358 _deselect_all_items(Widget_Data *wd)
360 if (!wd->selected) return EINA_FALSE;
362 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
368 _item_multi_select_left(Widget_Data *wd)
370 if (!wd->selected) return EINA_FALSE;
372 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
373 if (!prev) return EINA_TRUE;
374 if (elm_gengrid_item_selected_get(prev))
376 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
377 wd->last_selected_item = prev;
378 elm_gengrid_item_show(wd->last_selected_item);
382 elm_gengrid_item_selected_set(prev, EINA_TRUE);
383 elm_gengrid_item_show(prev);
390 _item_multi_select_right(Widget_Data *wd)
392 if (!wd->selected) return EINA_FALSE;
394 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
395 if (!next) return EINA_TRUE;
396 if (elm_gengrid_item_selected_get(next))
398 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
399 wd->last_selected_item = next;
400 elm_gengrid_item_show(wd->last_selected_item);
404 elm_gengrid_item_selected_set(next, EINA_TRUE);
405 elm_gengrid_item_show(next);
412 _item_multi_select_up(Widget_Data *wd)
415 Eina_Bool r = EINA_TRUE;
417 if (!wd->selected) return EINA_FALSE;
419 for (i = 0; (r) && (i < wd->nmax); i++)
420 r &= _item_multi_select_left(wd);
426 _item_multi_select_down(Widget_Data *wd)
429 Eina_Bool r = EINA_TRUE;
431 if (!wd->selected) return EINA_FALSE;
433 for (i = 0; (r) && (i < wd->nmax); i++)
434 r &= _item_multi_select_right(wd);
440 _item_single_select_up(Widget_Data *wd)
444 Elm_Gengrid_Item *prev;
448 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
449 while ((prev) && (prev->delete_me))
450 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
451 elm_gengrid_item_selected_set(prev, EINA_TRUE);
452 elm_gengrid_item_show(prev);
455 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
457 if (!prev) return EINA_FALSE;
459 for (i = 1; i < wd->nmax; i++)
461 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
462 if (!tmp) return EINA_FALSE;
466 _deselect_all_items(wd);
468 elm_gengrid_item_selected_set(prev, EINA_TRUE);
469 elm_gengrid_item_show(prev);
474 _item_single_select_down(Widget_Data *wd)
478 Elm_Gengrid_Item *next;
482 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
483 while ((next) && (next->delete_me))
484 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
485 elm_gengrid_item_selected_set(next, EINA_TRUE);
486 elm_gengrid_item_show(next);
489 else next = elm_gengrid_item_next_get(wd->last_selected_item);
491 if (!next) return EINA_FALSE;
493 for (i = 1; i < wd->nmax; i++)
495 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
496 if (!tmp) return EINA_FALSE;
500 _deselect_all_items(wd);
502 elm_gengrid_item_selected_set(next, EINA_TRUE);
503 elm_gengrid_item_show(next);
508 _item_single_select_left(Widget_Data *wd)
510 Elm_Gengrid_Item *prev;
513 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
514 while ((prev) && (prev->delete_me))
515 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
517 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
519 if (!prev) return EINA_FALSE;
521 _deselect_all_items(wd);
523 elm_gengrid_item_selected_set(prev, EINA_TRUE);
524 elm_gengrid_item_show(prev);
529 _item_single_select_right(Widget_Data *wd)
531 Elm_Gengrid_Item *next;
534 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
535 while ((next) && (next->delete_me))
536 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
538 else next = elm_gengrid_item_next_get(wd->last_selected_item);
540 if (!next) return EINA_FALSE;
542 _deselect_all_items(wd);
544 elm_gengrid_item_selected_set(next, EINA_TRUE);
545 elm_gengrid_item_show(next);
550 _on_focus_hook(void *data __UNUSED__,
553 Widget_Data *wd = elm_widget_data_get(obj);
555 if (elm_widget_focus_get(obj))
557 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
558 evas_object_focus_set(wd->self, EINA_TRUE);
559 if ((wd->selected) && (!wd->last_selected_item))
560 wd->last_selected_item = eina_list_data_get(wd->selected);
564 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
565 evas_object_focus_set(wd->self, EINA_FALSE);
570 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
572 Widget_Data *wd = elm_widget_data_get(obj);
573 Elm_Gengrid_Item *item;
575 elm_smart_scroller_mirrored_set(wd->scr, rtl);
576 if (!wd->items) return;
577 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
581 edje_object_mirrored_set(item->base.view, rtl);
582 elm_gengrid_item_update(item);
583 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
588 _theme_hook(Evas_Object *obj)
590 Widget_Data *wd = elm_widget_data_get(obj);
592 _elm_widget_mirrored_reload(obj);
593 _mirrored_set(obj, elm_widget_mirrored_get(obj));
594 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
595 elm_widget_style_get(obj));
599 _del_pre_hook(Evas_Object *obj)
601 Widget_Data *wd = elm_widget_data_get(obj);
603 elm_gengrid_clear(obj);
604 evas_object_del(wd->pan_smart);
605 wd->pan_smart = NULL;
609 _del_hook(Evas_Object *obj)
611 Widget_Data *wd = elm_widget_data_get(obj);
616 _signal_emit_hook(Evas_Object *obj,
617 const char *emission,
620 Widget_Data *wd = elm_widget_data_get(obj);
622 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
627 _mouse_move(void *data,
628 Evas *evas __UNUSED__,
632 Elm_Gengrid_Item *item = data;
633 Evas_Event_Mouse_Move *ev = event_info;
634 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
635 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
637 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
639 if (!item->wd->on_hold)
641 item->wd->on_hold = EINA_TRUE;
642 if (!item->wd->wasselected)
643 _item_unselect(item);
646 if ((item->dragging) && (item->down))
648 if (item->long_timer)
650 ecore_timer_del(item->long_timer);
651 item->long_timer = NULL;
653 evas_object_smart_callback_call(item->wd->self, SIG_DRAG, item);
656 if ((!item->down) || (item->wd->longpressed))
658 if (item->long_timer)
660 ecore_timer_del(item->long_timer);
661 item->long_timer = NULL;
663 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
665 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &ow, &oh);
667 it_scrl_x = ev->cur.canvas.x - item->wd->reorder_item->dx;
668 it_scrl_y = ev->cur.canvas.y - item->wd->reorder_item->dy;
670 if (it_scrl_x < ox) item->wd->reorder_item_x = ox;
671 else if (it_scrl_x + item->wd->item_width > ox + ow)
672 item->wd->reorder_item_x = ox + ow - item->wd->item_width;
673 else item->wd->reorder_item_x = it_scrl_x;
675 if (it_scrl_y < oy) item->wd->reorder_item_y = oy;
676 else if (it_scrl_y + item->wd->item_height > oy + oh)
677 item->wd->reorder_item_y = oy + oh - item->wd->item_height;
678 else item->wd->reorder_item_y = it_scrl_y;
680 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
681 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
685 if (!item->display_only)
686 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
687 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
688 x = ev->cur.canvas.x - x;
689 y = ev->cur.canvas.y - y;
692 if (adx < 0) adx = -dx;
695 if (ady < 0) ady = -dy;
698 if ((adx > minw) || (ady > minh))
700 const char *left_drag, *right_drag;
701 if (!elm_widget_mirrored_get(item->wd->self))
703 left_drag = SIG_DRAG_START_LEFT;
704 right_drag = SIG_DRAG_START_RIGHT;
708 left_drag = SIG_DRAG_START_RIGHT;
709 right_drag = SIG_DRAG_START_LEFT;
713 if (item->long_timer)
715 ecore_timer_del(item->long_timer);
716 item->long_timer = NULL;
718 if (!item->wd->wasselected)
719 _item_unselect(item);
723 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_START_UP,
728 evas_object_smart_callback_call(item->wd->self,
735 evas_object_smart_callback_call(item->wd->self,
736 SIG_DRAG_START_DOWN, item);
740 evas_object_smart_callback_call(item->wd->self,
743 evas_object_smart_callback_call(item->wd->self,
751 _long_press(void *data)
753 Elm_Gengrid_Item *item = data;
755 item->long_timer = NULL;
756 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
757 item->wd->longpressed = EINA_TRUE;
758 evas_object_smart_callback_call(item->wd->self, "longpressed", item);
759 if (item->wd->reorder_mode)
761 item->wd->reorder_item = item;
762 evas_object_raise(item->base.view);
763 elm_smart_scroller_hold_set(item->wd->scr, EINA_TRUE);
764 elm_smart_scroller_bounce_allow_set(item->wd->scr, EINA_FALSE, EINA_FALSE);
765 edje_object_signal_emit(item->base.view, "elm,state,reorder,enabled", "elm");
767 return ECORE_CALLBACK_CANCEL;
771 _mouse_down(void *data,
772 Evas *evas __UNUSED__,
776 Elm_Gengrid_Item *item = data;
777 Evas_Event_Mouse_Down *ev = event_info;
780 if (ev->button != 1) return;
783 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
784 item->dx = ev->canvas.x - x;
785 item->dy = ev->canvas.y - y;
786 item->wd->longpressed = EINA_FALSE;
787 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
788 else item->wd->on_hold = EINA_FALSE;
789 item->wd->wasselected = item->selected;
790 _item_highlight(item);
791 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
793 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
794 evas_object_smart_callback_call(item->wd->self, SIG_ACTIVATED, item);
796 if (item->long_timer) ecore_timer_del(item->long_timer);
798 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
801 item->long_timer = NULL;
805 _mouse_up(void *data,
806 Evas *evas __UNUSED__,
807 Evas_Object *obj __UNUSED__,
810 Elm_Gengrid_Item *item = data;
811 Evas_Event_Mouse_Up *ev = event_info;
812 Eina_Bool dragged = EINA_FALSE;
814 if (ev->button != 1) return;
815 item->down = EINA_FALSE;
816 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
817 else item->wd->on_hold = EINA_FALSE;
818 if (item->long_timer)
820 ecore_timer_del(item->long_timer);
821 item->long_timer = NULL;
825 item->dragging = EINA_FALSE;
826 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_STOP, item);
829 if (item->wd->on_hold)
831 item->wd->longpressed = EINA_FALSE;
832 item->wd->on_hold = EINA_FALSE;
835 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
837 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
838 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
840 evas_object_smart_callback_call(item->wd->self, SIG_MOVED, item->wd->reorder_item);
841 item->wd->reorder_item = NULL;
842 elm_smart_scroller_hold_set(item->wd->scr, EINA_FALSE);
843 elm_smart_scroller_bounce_allow_set(item->wd->scr, item->wd->h_bounce, item->wd->v_bounce);
844 edje_object_signal_emit(item->base.view, "elm,state,reorder,disabled", "elm");
846 if (item->wd->longpressed)
848 item->wd->longpressed = EINA_FALSE;
849 if (!item->wd->wasselected) _item_unselect(item);
850 item->wd->wasselected = EINA_FALSE;
855 if (item->want_unrealize) _item_unrealize(item);
857 if ((item->disabled) || (dragged)) return;
862 _item_highlight(item);
865 else _item_unselect(item);
871 while (item->wd->selected)
872 _item_unselect(item->wd->selected->data);
876 const Eina_List *l, *l_next;
877 Elm_Gengrid_Item *item2;
879 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
880 if (item2 != item) _item_unselect(item2);
882 _item_highlight(item);
888 _item_highlight(Elm_Gengrid_Item *item)
890 if ((item->wd->no_select) || (item->delete_me) || (item->highlighted)) return;
891 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
892 item->highlighted = EINA_TRUE;
896 _item_realize(Elm_Gengrid_Item *item)
901 if ((item->realized) || (item->delete_me)) return;
902 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
903 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
905 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
906 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
907 elm_widget_sub_object_add(item->wd->self, item->base.view);
908 snprintf(style, sizeof(style), "item/%s",
909 item->gic->item_style ? item->gic->item_style : "default");
910 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
911 elm_widget_style_get(item->wd->self));
913 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
914 evas_object_color_set(item->spacer, 0, 0, 0, 0);
915 elm_widget_sub_object_add(item->wd->self, item->spacer);
916 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
917 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
919 if (item->gic->func.label_get)
925 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
927 EINA_LIST_FOREACH(item->labels, l, key)
929 char *s = item->gic->func.label_get
930 ((void *)item->base.data, item->wd->self, l->data);
933 edje_object_part_text_set(item->base.view, l->data, s);
939 if (item->gic->func.icon_get)
945 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
947 EINA_LIST_FOREACH(item->icons, l, key)
949 Evas_Object *ic = item->gic->func.icon_get
950 ((void *)item->base.data, item->wd->self, l->data);
953 item->icon_objs = eina_list_append(item->icon_objs, ic);
954 edje_object_part_swallow(item->base.view, key, ic);
955 evas_object_show(ic);
956 elm_widget_sub_object_add(item->wd->self, ic);
961 if (item->gic->func.state_get)
967 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
969 EINA_LIST_FOREACH(item->states, l, key)
971 Eina_Bool on = item->gic->func.state_get
972 ((void *)item->base.data, item->wd->self, l->data);
975 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
976 edje_object_signal_emit(item->base.view, buf, "elm");
981 if ((!item->wd->item_width) && (!item->wd->item_height))
983 edje_object_size_min_restricted_calc(item->base.view,
984 &item->wd->item_width,
985 &item->wd->item_height,
986 item->wd->item_width,
987 item->wd->item_height);
988 elm_coords_finger_size_adjust(1, &item->wd->item_width,
989 1, &item->wd->item_height);
992 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
994 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
996 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1000 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
1002 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
1004 evas_object_show(item->base.view);
1006 if (item->tooltip.content_cb)
1008 elm_widget_item_tooltip_content_cb_set(item,
1009 item->tooltip.content_cb,
1010 item->tooltip.data, NULL);
1011 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1012 elm_widget_item_tooltip_size_restrict_disable(item, item->tooltip.free_size);
1015 if (item->mouse_cursor)
1016 elm_widget_item_cursor_set(item, item->mouse_cursor);
1018 item->realized = EINA_TRUE;
1019 item->want_unrealize = EINA_FALSE;
1023 _item_unrealize(Elm_Gengrid_Item *item)
1027 if (!item->realized) return;
1028 if (item->long_timer)
1030 ecore_timer_del(item->long_timer);
1031 item->long_timer = NULL;
1033 evas_object_del(item->base.view);
1034 item->base.view = NULL;
1035 evas_object_del(item->spacer);
1036 item->spacer = NULL;
1037 elm_widget_stringlist_free(item->labels);
1038 item->labels = NULL;
1039 elm_widget_stringlist_free(item->icons);
1041 elm_widget_stringlist_free(item->states);
1042 item->states = NULL;
1044 EINA_LIST_FREE(item->icon_objs, icon)
1045 evas_object_del(icon);
1047 item->realized = EINA_FALSE;
1048 item->want_unrealize = EINA_FALSE;
1052 _reorder_item_moving_effect_timer_cb(void *data)
1054 Elm_Gengrid_Item *item = data;
1058 time = REORDER_EFFECT_TIME;
1059 t = ((0.0 > (t = ecore_loop_time_get()-item->moving_effect_start_time)) ? 0.0 : t);
1060 dx = ((item->tx - item->ox) / 10) * _elm_config->scale;
1061 dy = ((item->ty - item->oy) / 10) * _elm_config->scale;
1065 item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
1066 item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
1074 if ((((dx > 0) && (item->rx >= item->tx)) || ((dx <= 0) && (item->rx <= item->tx))) &&
1075 (((dy > 0) && (item->ry >= item->ty)) || ((dy <= 0) && (item->ry <= item->ty))))
1077 evas_object_move(item->base.view, item->tx, item->ty);
1078 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1079 item->moving = EINA_FALSE;
1080 item->item_moving_effect_timer = NULL;
1081 return ECORE_CALLBACK_CANCEL;
1084 evas_object_move(item->base.view, item->rx, item->ry);
1085 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1087 return ECORE_CALLBACK_RENEW;
1091 _item_place(Elm_Gengrid_Item *item,
1095 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh;
1096 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1097 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1100 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1102 /* Preload rows/columns at each side of the Gengrid */
1103 cvx = ox - PRELOAD * item->wd->item_width;
1104 cvy = oy - PRELOAD * item->wd->item_height;
1105 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1106 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1111 if (item->wd->horizontal)
1113 int columns, items_visible = 0, items_row;
1115 if (item->wd->item_height > 0)
1116 items_visible = vh / item->wd->item_height;
1117 if (items_visible < 1)
1120 columns = item->wd->count / items_visible;
1121 if (item->wd->count % items_visible)
1124 tcw = item->wd->item_width * columns;
1125 alignw = (vw - tcw) * item->wd->align_x;
1127 items_row = items_visible;
1128 if (items_row > item->wd->count)
1129 items_row = item->wd->count;
1130 tch = items_row * item->wd->item_height;
1131 alignh = (vh - tch) * item->wd->align_y;
1135 int rows, items_visible = 0, items_col;
1137 if (item->wd->item_width > 0)
1138 items_visible = vw / item->wd->item_width;
1139 if (items_visible < 1)
1142 rows = item->wd->count / items_visible;
1143 if (item->wd->count % items_visible)
1146 tch = item->wd->item_height * rows;
1147 alignh = (vh - tch) * item->wd->align_y;
1149 items_col = items_visible;
1150 if (items_col > item->wd->count)
1151 items_col = item->wd->count;
1152 tcw = items_col * item->wd->item_width;
1153 alignw = (vw - tcw) * item->wd->align_x;
1156 x = cx * item->wd->item_width - item->wd->pan_x + ox + alignw;
1157 if (elm_widget_mirrored_get(item->wd->self))
1158 { /* Switch items side and componsate for pan_x when in RTL mode */
1160 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1161 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1164 y = cy * item->wd->item_height - item->wd->pan_y + oy + alignh;
1166 Eina_Bool was_realized = item->realized;
1167 if (ELM_RECTS_INTERSECT(x, y, item->wd->item_width, item->wd->item_height,
1168 cvx, cvy, cvw, cvh))
1170 _item_realize(item);
1172 evas_object_smart_callback_call(item->wd->self, SIG_REALIZED, item);
1173 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
1175 if (item->moving) return;
1177 if (!item->wd->move_effect_enabled)
1182 if (item->wd->reorder_item == item)
1184 evas_object_move(item->base.view,
1185 item->wd->reorder_item_x, item->wd->reorder_item_y);
1186 evas_object_resize(item->base.view,
1187 item->wd->item_width, item->wd->item_height);
1192 if (item->wd->move_effect_enabled)
1194 if ((item->ox != x) || (item->oy != y))
1196 if (((item->wd->old_pan_x == item->wd->pan_x) && (item->wd->old_pan_y == item->wd->pan_y)) ||
1197 ((item->wd->old_pan_x != item->wd->pan_x) && !(item->ox - item->wd->pan_x + item->wd->old_pan_x == x)) ||
1198 ((item->wd->old_pan_y != item->wd->pan_y) && !(item->oy - item->wd->pan_y + item->wd->old_pan_y == y)))
1202 item->rx = item->ox;
1203 item->ry = item->oy;
1204 item->moving = EINA_TRUE;
1205 item->moving_effect_start_time = ecore_loop_time_get();
1206 item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, item);
1212 if (ELM_RECTS_INTERSECT(item->wd->reorder_item_x, item->wd->reorder_item_y,
1213 item->wd->item_width, item->wd->item_height,
1214 x+(item->wd->item_width/2), y+(item->wd->item_height/2),
1217 if (item->wd->horizontal)
1219 if ((item->wd->nmax * item->wd->reorder_item->x + item->wd->reorder_item->y) >
1220 (item->wd->nmax * item->x + item->y))
1221 reorder_item_move_forward = EINA_TRUE;
1225 if ((item->wd->nmax * item->wd->reorder_item->y + item->wd->reorder_item->x) >
1226 (item->wd->nmax * item->y + item->x))
1227 reorder_item_move_forward = EINA_TRUE;
1230 item->wd->items = eina_inlist_remove(item->wd->items,
1231 EINA_INLIST_GET(item->wd->reorder_item));
1232 if (reorder_item_move_forward)
1233 item->wd->items = eina_inlist_prepend_relative(item->wd->items,
1234 EINA_INLIST_GET(item->wd->reorder_item),
1235 EINA_INLIST_GET(item));
1237 item->wd->items = eina_inlist_append_relative(item->wd->items,
1238 EINA_INLIST_GET(item->wd->reorder_item),
1239 EINA_INLIST_GET(item));
1241 item->wd->reorder_item_changed = EINA_TRUE;
1242 item->wd->move_effect_enabled = EINA_TRUE;
1243 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1244 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1250 evas_object_move(item->base.view, x, y);
1251 evas_object_resize(item->base.view, item->wd->item_width,
1252 item->wd->item_height);
1256 _item_unrealize(item);
1258 evas_object_smart_callback_call(item->wd->self, SIG_UNREALIZED, item);
1263 _item_label_hook(Elm_Gengrid_Item *it, const char *part)
1265 if (!it->gic->func.label_get) return NULL;
1266 return edje_object_part_text_get(it->base.view, part);
1269 static Elm_Gengrid_Item *
1270 _item_create(Widget_Data *wd,
1271 const Elm_Gengrid_Item_Class *gic,
1274 const void *func_data)
1276 Elm_Gengrid_Item *item;
1278 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1279 if (!item) return NULL;
1283 item->base.data = data;
1284 item->func.func = func;
1285 item->func.data = func_data;
1286 item->mouse_cursor = NULL;
1287 elm_widget_item_text_get_hook_set(item, _item_label_hook);
1292 _item_del(Elm_Gengrid_Item *item)
1294 elm_widget_item_pre_notify_del(item);
1296 item->wd->selected = eina_list_remove(item->wd->selected, item);
1297 if (item->realized) _item_unrealize(item);
1298 if ((!item->delete_me) && (item->gic->func.del))
1299 item->gic->func.del((void *)item->base.data, item->wd->self);
1300 item->delete_me = EINA_TRUE;
1301 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1302 if (item->long_timer) ecore_timer_del(item->long_timer);
1303 if (item->tooltip.del_cb)
1304 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1305 item->wd->walking -= item->walking;
1307 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1308 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1309 elm_widget_item_del(item);
1313 _item_select(Elm_Gengrid_Item *item)
1315 if ((item->wd->no_select) || (item->delete_me)) return;
1318 if (item->wd->always_select) goto call;
1321 item->selected = EINA_TRUE;
1322 item->wd->selected = eina_list_append(item->wd->selected, item);
1325 item->wd->walking++;
1326 if (item->func.func)
1327 item->func.func((void *)item->func.data, item->wd->self, item);
1328 if (!item->delete_me)
1329 evas_object_smart_callback_call(item->wd->self, SIG_SELECTED, item);
1331 item->wd->walking--;
1332 item->wd->last_selected_item = item;
1333 if ((item->wd->clear_me) && (!item->wd->walking))
1334 elm_gengrid_clear(item->base.widget);
1337 if ((!item->walking) && (item->delete_me))
1338 if (!item->relcount) _item_del(item);
1343 _item_unselect(Elm_Gengrid_Item *item)
1345 if ((item->delete_me) || (!item->highlighted)) return;
1346 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1347 item->highlighted = EINA_FALSE;
1350 item->selected = EINA_FALSE;
1351 item->wd->selected = eina_list_remove(item->wd->selected, item);
1352 evas_object_smart_callback_call(item->wd->self, SIG_UNSELECTED, item);
1357 _calc_job(void *data)
1359 Widget_Data *wd = data;
1360 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1363 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1364 if ((cvw != 0) || (cvh != 0))
1366 if ((wd->horizontal) && (wd->item_height > 0))
1367 nmax = cvh / wd->item_height;
1368 else if (wd->item_width > 0)
1369 nmax = cvw / wd->item_width;
1377 minw = ceil(count / (float)nmax) * wd->item_width;
1378 minh = nmax * wd->item_height;
1382 minw = nmax * wd->item_width;
1383 minh = ceil(count / (float)nmax) * wd->item_height;
1386 if ((minw != wd->minw) || (minh != wd->minh))
1390 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1394 evas_object_smart_changed(wd->pan_smart);
1396 wd->calc_job = NULL;
1400 _pan_add(Evas_Object *obj)
1403 Evas_Object_Smart_Clipped_Data *cd;
1406 cd = evas_object_smart_data_get(obj);
1409 sd->__clipped_data = *cd;
1411 evas_object_smart_data_set(obj, sd);
1415 _pan_del(Evas_Object *obj)
1417 Pan *sd = evas_object_smart_data_get(obj);
1424 _pan_set(Evas_Object *obj,
1428 Pan *sd = evas_object_smart_data_get(obj);
1429 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1432 evas_object_smart_changed(obj);
1436 _pan_get(Evas_Object *obj,
1440 Pan *sd = evas_object_smart_data_get(obj);
1441 if (x) *x = sd->wd->pan_x;
1442 if (y) *y = sd->wd->pan_y;
1446 _pan_child_size_get(Evas_Object *obj,
1450 Pan *sd = evas_object_smart_data_get(obj);
1451 if (w) *w = sd->wd->minw;
1452 if (h) *h = sd->wd->minh;
1456 _pan_max_get(Evas_Object *obj,
1460 Pan *sd = evas_object_smart_data_get(obj);
1464 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1466 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1468 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1472 _pan_min_get(Evas_Object *obj,
1476 Pan *sd = evas_object_smart_data_get(obj);
1480 _pan_max_get(obj, &mx, &my);
1482 *x = -mx * sd->wd->align_x;
1484 *y = -my * sd->wd->align_y;
1488 _pan_resize(Evas_Object *obj,
1492 Pan *sd = evas_object_smart_data_get(obj);
1495 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1496 if ((ow == w) && (oh == h)) return;
1497 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1498 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1502 _pan_calculate(Evas_Object *obj)
1504 Pan *sd = evas_object_smart_data_get(obj);
1505 Evas_Coord cx = 0, cy = 0;
1506 Elm_Gengrid_Item *item;
1509 if (!sd->wd->nmax) return;
1511 sd->wd->reorder_item_changed = EINA_FALSE;
1513 EINA_INLIST_FOREACH(sd->wd->items, item)
1515 _item_place(item, cx, cy);
1516 if (sd->wd->reorder_item_changed) return;
1517 if (sd->wd->horizontal)
1519 cy = (cy + 1) % sd->wd->nmax;
1524 cx = (cx + 1) % sd->wd->nmax;
1529 if ((sd->wd->reorder_mode) && (sd->wd->reorder_item))
1531 if (!sd->wd->reorder_item_changed)
1533 sd->wd->old_pan_x = sd->wd->pan_x;
1534 sd->wd->old_pan_y = sd->wd->pan_y;
1536 sd->wd->move_effect_enabled = EINA_FALSE;
1538 evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
1542 _pan_move(Evas_Object *obj,
1543 Evas_Coord x __UNUSED__,
1544 Evas_Coord y __UNUSED__)
1546 Pan *sd = evas_object_smart_data_get(obj);
1548 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1549 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1553 _hold_on(void *data __UNUSED__,
1555 void *event_info __UNUSED__)
1557 Widget_Data *wd = elm_widget_data_get(obj);
1559 elm_smart_scroller_hold_set(wd->scr, 1);
1563 _hold_off(void *data __UNUSED__,
1565 void *event_info __UNUSED__)
1567 Widget_Data *wd = elm_widget_data_get(obj);
1569 elm_smart_scroller_hold_set(wd->scr, 0);
1573 _freeze_on(void *data __UNUSED__,
1575 void *event_info __UNUSED__)
1577 Widget_Data *wd = elm_widget_data_get(obj);
1579 elm_smart_scroller_freeze_set(wd->scr, 1);
1583 _freeze_off(void *data __UNUSED__,
1585 void *event_info __UNUSED__)
1587 Widget_Data *wd = elm_widget_data_get(obj);
1589 elm_smart_scroller_freeze_set(wd->scr, 0);
1593 _scr_anim_start(void *data,
1594 Evas_Object *obj __UNUSED__,
1595 void *event_info __UNUSED__)
1597 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1601 _scr_anim_stop(void *data,
1602 Evas_Object *obj __UNUSED__,
1603 void *event_info __UNUSED__)
1605 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1609 _scr_drag_start(void *data,
1610 Evas_Object *obj __UNUSED__,
1611 void *event_info __UNUSED__)
1613 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1617 _scr_drag_stop(void *data,
1618 Evas_Object *obj __UNUSED__,
1619 void *event_info __UNUSED__)
1621 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1625 _scr_scroll(void *data,
1626 Evas_Object *obj __UNUSED__,
1627 void *event_info __UNUSED__)
1629 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1633 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1635 const Elm_Gengrid_Item *item = data;
1636 const Elm_Gengrid_Item *item1 = data1;
1638 return _elm_gengrid_item_compare_data_cb(item->base.data, item1->base.data);
1642 _elm_gengrid_item_compare(const void *data, const void *data1)
1644 Elm_Gengrid_Item *item, *item1;
1645 item = ELM_GENGRID_ITEM_FROM_INLIST(data);
1646 item1 = ELM_GENGRID_ITEM_FROM_INLIST(data1);
1647 return _elm_gengrid_item_compare_cb(item, item1);
1651 elm_gengrid_add(Evas_Object *parent)
1656 static Evas_Smart *smart = NULL;
1657 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1659 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1661 ELM_SET_WIDTYPE(widtype, "gengrid");
1662 elm_widget_type_set(obj, "gengrid");
1663 elm_widget_sub_object_add(parent, obj);
1664 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1665 elm_widget_data_set(obj, wd);
1666 elm_widget_del_hook_set(obj, _del_hook);
1667 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1668 elm_widget_theme_hook_set(obj, _theme_hook);
1669 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1670 elm_widget_can_focus_set(obj, EINA_TRUE);
1671 elm_widget_event_hook_set(obj, _event_hook);
1673 wd->scr = elm_smart_scroller_add(e);
1674 elm_smart_scroller_widget_set(wd->scr, obj);
1675 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1677 elm_widget_resize_object_set(obj, wd->scr);
1679 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1680 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1681 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1682 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1683 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1685 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1690 wd->h_bounce = bounce;
1691 wd->v_bounce = bounce;
1692 wd->no_select = EINA_FALSE;
1694 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1695 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1696 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1697 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1699 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1703 static Evas_Smart_Class sc;
1705 evas_object_smart_clipped_smart_set(&_pan_sc);
1707 sc.name = "elm_gengrid_pan";
1708 sc.version = EVAS_SMART_CLASS_VERSION;
1711 sc.resize = _pan_resize;
1712 sc.move = _pan_move;
1713 sc.calculate = _pan_calculate;
1714 smart = evas_smart_class_new(&sc);
1718 wd->pan_smart = evas_object_smart_add(e, smart);
1719 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1723 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1724 _pan_set, _pan_get, _pan_max_get,
1725 _pan_min_get, _pan_child_size_get);
1727 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1732 elm_gengrid_item_size_set(Evas_Object *obj,
1736 ELM_CHECK_WIDTYPE(obj, widtype);
1737 Widget_Data *wd = elm_widget_data_get(obj);
1739 if ((wd->item_width == w) && (wd->item_height == h)) return;
1741 wd->item_height = h;
1742 if (wd->calc_job) ecore_job_del(wd->calc_job);
1743 wd->calc_job = ecore_job_add(_calc_job, wd);
1747 elm_gengrid_item_size_get(const Evas_Object *obj,
1751 ELM_CHECK_WIDTYPE(obj, widtype);
1752 Widget_Data *wd = elm_widget_data_get(obj);
1754 if (w) *w = wd->item_width;
1755 if (h) *h = wd->item_height;
1759 elm_gengrid_align_set(Evas_Object *obj,
1763 ELM_CHECK_WIDTYPE(obj, widtype);
1765 Widget_Data *wd = elm_widget_data_get(obj);
1766 double old_h = wd->align_x, old_y = wd->align_y;
1770 else if (align_x < 0.0)
1772 wd->align_x = align_x;
1776 else if (align_y < 0.0)
1778 wd->align_y = align_y;
1780 if ((old_h != wd->align_x) || (old_y != wd->align_y))
1781 evas_object_smart_calculate(wd->pan_smart);
1785 elm_gengrid_align_get(const Evas_Object *obj,
1789 ELM_CHECK_WIDTYPE(obj, widtype);
1790 Widget_Data *wd = elm_widget_data_get(obj);
1791 if (align_x) *align_x = wd->align_x;
1792 if (align_y) *align_y = wd->align_y;
1795 EAPI Elm_Gengrid_Item *
1796 elm_gengrid_item_append(Evas_Object *obj,
1797 const Elm_Gengrid_Item_Class *gic,
1800 const void *func_data)
1802 Elm_Gengrid_Item *item;
1803 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1804 Widget_Data *wd = elm_widget_data_get(obj);
1805 if (!wd) return NULL;
1807 item = _item_create(wd, gic, data, func, func_data);
1808 if (!item) return NULL;
1809 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
1811 if (wd->calc_job) ecore_job_del(wd->calc_job);
1812 wd->calc_job = ecore_job_add(_calc_job, wd);
1817 EAPI Elm_Gengrid_Item *
1818 elm_gengrid_item_prepend(Evas_Object *obj,
1819 const Elm_Gengrid_Item_Class *gic,
1822 const void *func_data)
1824 Elm_Gengrid_Item *item;
1825 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1826 Widget_Data *wd = elm_widget_data_get(obj);
1827 if (!wd) return NULL;
1829 item = _item_create(wd, gic, data, func, func_data);
1830 if (!item) return NULL;
1831 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
1833 if (wd->calc_job) ecore_job_del(wd->calc_job);
1834 wd->calc_job = ecore_job_add(_calc_job, wd);
1839 EAPI Elm_Gengrid_Item *
1840 elm_gengrid_item_insert_before(Evas_Object *obj,
1841 const Elm_Gengrid_Item_Class *gic,
1843 Elm_Gengrid_Item *relative,
1845 const void *func_data)
1847 Elm_Gengrid_Item *item;
1848 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1849 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1850 Widget_Data *wd = elm_widget_data_get(obj);
1851 if (!wd) return NULL;
1853 item = _item_create(wd, gic, data, func, func_data);
1854 if (!item) return NULL;
1855 wd->items = eina_inlist_prepend_relative
1856 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1858 if (wd->calc_job) ecore_job_del(wd->calc_job);
1859 wd->calc_job = ecore_job_add(_calc_job, wd);
1864 EAPI Elm_Gengrid_Item *
1865 elm_gengrid_item_insert_after(Evas_Object *obj,
1866 const Elm_Gengrid_Item_Class *gic,
1868 Elm_Gengrid_Item *relative,
1870 const void *func_data)
1872 Elm_Gengrid_Item *item;
1873 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1874 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
1875 Widget_Data *wd = elm_widget_data_get(obj);
1876 if (!wd) return NULL;
1878 item = _item_create(wd, gic, data, func, func_data);
1879 if (!item) return NULL;
1880 wd->items = eina_inlist_append_relative
1881 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
1883 if (wd->calc_job) ecore_job_del(wd->calc_job);
1884 wd->calc_job = ecore_job_add(_calc_job, wd);
1889 EAPI Elm_Gengrid_Item *
1890 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
1891 const Elm_Gengrid_Item_Class *gic,
1893 Eina_Compare_Cb comp,
1895 const void *func_data)
1897 Elm_Gengrid_Item *item;
1898 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1899 Widget_Data *wd = elm_widget_data_get(obj);
1900 if (!wd) return NULL;
1902 item = _item_create(wd, gic, data, func, func_data);
1903 if (!item) return NULL;
1906 wd->state = eina_inlist_sorted_state_new();
1908 _elm_gengrid_item_compare_cb = comp;
1909 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(item),
1910 _elm_gengrid_item_compare, wd->state);
1911 if (wd->calc_job) ecore_job_del(wd->calc_job);
1912 wd->calc_job = ecore_job_add(_calc_job, wd);
1917 EAPI Elm_Gengrid_Item *
1918 elm_gengrid_item_sorted_insert(Evas_Object *obj,
1919 const Elm_Gengrid_Item_Class *gic,
1921 Eina_Compare_Cb comp,
1923 const void *func_data)
1925 _elm_gengrid_item_compare_data_cb = comp;
1927 return elm_gengrid_item_direct_sorted_insert(obj, gic, data, _elm_gengrid_item_compare_data, func, func_data);
1931 elm_gengrid_item_del(Elm_Gengrid_Item *item)
1933 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1934 if ((item->relcount > 0) || (item->walking > 0))
1936 item->delete_me = EINA_TRUE;
1937 elm_widget_item_pre_notify_del(item);
1939 item->wd->selected = eina_list_remove(item->wd->selected, item);
1940 if (item->gic->func.del)
1941 item->gic->func.del((void *)item->base.data, item->wd->self);
1949 elm_gengrid_horizontal_set(Evas_Object *obj,
1952 ELM_CHECK_WIDTYPE(obj, widtype);
1953 Widget_Data *wd = elm_widget_data_get(obj);
1955 if (setting == wd->horizontal) return;
1956 wd->horizontal = setting;
1958 /* Update the items to conform to the new layout */
1959 if (wd->calc_job) ecore_job_del(wd->calc_job);
1960 wd->calc_job = ecore_job_add(_calc_job, wd);
1964 elm_gengrid_horizontal_get(const Evas_Object *obj)
1966 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1967 Widget_Data *wd = elm_widget_data_get(obj);
1968 if (!wd) return EINA_FALSE;
1969 return wd->horizontal;
1973 elm_gengrid_clear(Evas_Object *obj)
1975 ELM_CHECK_WIDTYPE(obj, widtype);
1976 Widget_Data *wd = elm_widget_data_get(obj);
1981 eina_inlist_sorted_state_free(wd->state);
1986 ecore_job_del(wd->calc_job);
1987 wd->calc_job = NULL;
1990 if (wd->walking > 0)
1992 Elm_Gengrid_Item *item;
1994 EINA_INLIST_FOREACH(wd->items, item)
1995 item->delete_me = 1;
2001 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2003 wd->items = eina_inlist_remove(wd->items, wd->items);
2004 elm_widget_item_pre_notify_del(item);
2005 if (item->realized) _item_unrealize(item);
2006 if (item->gic->func.del)
2007 item->gic->func.del((void *)item->base.data, wd->self);
2008 if (item->long_timer) ecore_timer_del(item->long_timer);
2009 elm_widget_item_del(item);
2014 eina_list_free(wd->selected);
2015 wd->selected = NULL;
2023 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2024 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2027 EAPI const Evas_Object *
2028 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
2030 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2031 return item->base.view;
2035 elm_gengrid_item_update(Elm_Gengrid_Item *item)
2037 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2038 if (!item->realized) return;
2039 if (item->want_unrealize) return;
2040 _item_unrealize(item);
2041 _item_realize(item);
2042 _item_place(item, item->x, item->y);
2046 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2048 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2049 return elm_widget_item_data_get(item);
2053 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2056 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2057 elm_widget_item_data_set(item, data);
2060 EAPI const Elm_Gengrid_Item_Class *
2061 elm_gengrid_item_item_class_get(const Elm_Gengrid_Item *item)
2063 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2064 if (item->delete_me) return NULL;
2069 elm_gengrid_item_item_class_set(Elm_Gengrid_Item *item,
2070 const Elm_Gengrid_Item_Class *gic)
2072 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2073 EINA_SAFETY_ON_NULL_RETURN(gic);
2074 if (item->delete_me) return;
2076 elm_gengrid_item_update(item);
2080 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2084 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2085 if (x) *x = item->x;
2086 if (y) *y = item->y;
2090 elm_gengrid_multi_select_set(Evas_Object *obj,
2093 ELM_CHECK_WIDTYPE(obj, widtype);
2094 Widget_Data *wd = elm_widget_data_get(obj);
2100 elm_gengrid_multi_select_get(const Evas_Object *obj)
2102 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2103 Widget_Data *wd = elm_widget_data_get(obj);
2104 if (!wd) return EINA_FALSE;
2108 EAPI Elm_Gengrid_Item *
2109 elm_gengrid_selected_item_get(const Evas_Object *obj)
2111 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2112 Widget_Data *wd = elm_widget_data_get(obj);
2113 if (!wd) return NULL;
2114 if (wd->selected) return wd->selected->data;
2118 EAPI const Eina_List *
2119 elm_gengrid_selected_items_get(const Evas_Object *obj)
2121 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2122 Widget_Data *wd = elm_widget_data_get(obj);
2123 if (!wd) return NULL;
2124 return wd->selected;
2128 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2131 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2132 Widget_Data *wd = item->wd;
2134 if (item->delete_me) return;
2135 selected = !!selected;
2136 if (item->selected == selected) return;
2142 while (wd->selected)
2143 _item_unselect(wd->selected->data);
2145 _item_highlight(item);
2149 _item_unselect(item);
2153 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2155 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2156 return item->selected;
2160 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2163 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2164 if (item->disabled == disabled) return;
2165 if (item->delete_me) return;
2166 item->disabled = !!disabled;
2170 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2172 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2177 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2179 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2180 if (item->delete_me) return EINA_FALSE;
2181 return item->disabled;
2184 static Evas_Object *
2185 _elm_gengrid_item_label_create(void *data,
2186 Evas_Object *obj __UNUSED__,
2187 Evas_Object *tooltip,
2188 void *item __UNUSED__)
2190 Evas_Object *label = elm_label_add(tooltip);
2193 elm_object_style_set(label, "tooltip");
2194 elm_object_text_set(label, data);
2199 _elm_gengrid_item_label_del_cb(void *data,
2200 Evas_Object *obj __UNUSED__,
2201 void *event_info __UNUSED__)
2203 eina_stringshare_del(data);
2207 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2210 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2211 text = eina_stringshare_add(text);
2212 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2214 _elm_gengrid_item_label_del_cb);
2218 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2219 Elm_Tooltip_Item_Content_Cb func,
2221 Evas_Smart_Cb del_cb)
2223 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2225 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2228 if (item->tooltip.del_cb)
2229 item->tooltip.del_cb((void *)item->tooltip.data,
2230 item->base.widget, item);
2231 item->tooltip.content_cb = func;
2232 item->tooltip.data = data;
2233 item->tooltip.del_cb = del_cb;
2234 if (item->base.view)
2236 elm_widget_item_tooltip_content_cb_set(item,
2237 item->tooltip.content_cb,
2238 item->tooltip.data, NULL);
2239 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2240 elm_widget_item_tooltip_size_restrict_disable(item, item->tooltip.free_size);
2246 if (del_cb) del_cb((void *)data, NULL, NULL);
2250 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2252 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2253 if ((item->base.view) && (item->tooltip.content_cb))
2254 elm_widget_item_tooltip_unset(item);
2256 if (item->tooltip.del_cb)
2257 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2258 item->tooltip.del_cb = NULL;
2259 item->tooltip.content_cb = NULL;
2260 item->tooltip.data = NULL;
2261 item->tooltip.free_size = EINA_FALSE;
2262 if (item->tooltip.style)
2263 elm_gengrid_item_tooltip_style_set(item, NULL);
2267 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2270 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2271 eina_stringshare_replace(&item->tooltip.style, style);
2272 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2276 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2278 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2279 return item->tooltip.style;
2283 elm_gengrid_item_tooltip_size_restrict_disable(Elm_Gengrid_Item *item, Eina_Bool disable)
2285 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2286 item->tooltip.free_size = disable;
2287 if (item->base.view) return elm_widget_item_tooltip_size_restrict_disable(item, disable);
2292 elm_gengrid_item_tooltip_size_restrict_disabled_get(const Elm_Gengrid_Item *item)
2294 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2295 return item->tooltip.free_size;
2299 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2302 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2303 eina_stringshare_replace(&item->mouse_cursor, cursor);
2304 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2308 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2310 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2311 return elm_widget_item_cursor_get(item);
2315 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2317 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2318 if (!item->mouse_cursor)
2321 if (item->base.view)
2322 elm_widget_item_cursor_unset(item);
2324 eina_stringshare_del(item->mouse_cursor);
2325 item->mouse_cursor = NULL;
2329 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2332 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2333 elm_widget_item_cursor_style_set(item, style);
2337 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2339 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2340 return elm_widget_item_cursor_style_get(item);
2344 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2345 Eina_Bool engine_only)
2347 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2348 elm_widget_item_cursor_engine_only_set(item, engine_only);
2352 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2354 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2355 return elm_widget_item_cursor_engine_only_get(item);
2359 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2360 Eina_Bool reorder_mode)
2362 ELM_CHECK_WIDTYPE(obj, widtype);
2363 Widget_Data *wd = elm_widget_data_get(obj);
2365 wd->reorder_mode = reorder_mode;
2369 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2371 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2372 Widget_Data *wd = elm_widget_data_get(obj);
2373 if (!wd) return EINA_FALSE;
2374 return wd->reorder_mode;
2378 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2379 Eina_Bool always_select)
2381 ELM_CHECK_WIDTYPE(obj, widtype);
2382 Widget_Data *wd = elm_widget_data_get(obj);
2384 wd->always_select = always_select;
2388 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2390 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2391 Widget_Data *wd = elm_widget_data_get(obj);
2392 if (!wd) return EINA_FALSE;
2393 return wd->always_select;
2397 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2398 Eina_Bool no_select)
2400 ELM_CHECK_WIDTYPE(obj, widtype);
2401 Widget_Data *wd = elm_widget_data_get(obj);
2403 wd->no_select = no_select;
2407 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2409 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2410 Widget_Data *wd = elm_widget_data_get(obj);
2411 if (!wd) return EINA_FALSE;
2412 return wd->no_select;
2416 elm_gengrid_bounce_set(Evas_Object *obj,
2420 ELM_CHECK_WIDTYPE(obj, widtype);
2421 Widget_Data *wd = elm_widget_data_get(obj);
2423 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2424 wd->h_bounce = h_bounce;
2425 wd->v_bounce = v_bounce;
2429 elm_gengrid_bounce_get(const Evas_Object *obj,
2430 Eina_Bool *h_bounce,
2431 Eina_Bool *v_bounce)
2433 ELM_CHECK_WIDTYPE(obj, widtype);
2434 Widget_Data *wd = elm_widget_data_get(obj);
2436 if (h_bounce) *h_bounce = wd->h_bounce;
2437 if (v_bounce) *v_bounce = wd->v_bounce;
2441 elm_gengrid_page_relative_set(Evas_Object *obj,
2445 Evas_Coord pagesize_h;
2446 Evas_Coord pagesize_v;
2448 ELM_CHECK_WIDTYPE(obj, widtype);
2449 Widget_Data *wd = elm_widget_data_get(obj);
2452 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
2453 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
2458 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2460 ELM_CHECK_WIDTYPE(obj, widtype);
2461 Widget_Data *wd = elm_widget_data_get(obj);
2464 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
2468 elm_gengrid_page_size_set(Evas_Object *obj,
2469 Evas_Coord h_pagesize,
2470 Evas_Coord v_pagesize)
2475 ELM_CHECK_WIDTYPE(obj, widtype);
2476 Widget_Data *wd = elm_widget_data_get(obj);
2478 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
2479 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
2483 EAPI Elm_Gengrid_Item *
2484 elm_gengrid_first_item_get(const Evas_Object *obj)
2486 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2487 Widget_Data *wd = elm_widget_data_get(obj);
2488 if (!wd) return NULL;
2489 if (!wd->items) return NULL;
2490 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2491 while ((item) && (item->delete_me))
2492 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2496 EAPI Elm_Gengrid_Item *
2497 elm_gengrid_last_item_get(const Evas_Object *obj)
2499 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2500 Widget_Data *wd = elm_widget_data_get(obj);
2501 if (!wd) return NULL;
2502 if (!wd->items) return NULL;
2503 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
2504 while ((item) && (item->delete_me))
2505 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2509 EAPI Elm_Gengrid_Item *
2510 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
2512 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2515 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2516 if ((item) && (!item->delete_me)) break;
2518 return (Elm_Gengrid_Item *)item;
2521 EAPI Elm_Gengrid_Item *
2522 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
2524 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2527 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2528 if ((item) && (!item->delete_me)) break;
2530 return (Elm_Gengrid_Item *)item;
2534 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
2536 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2537 return item->base.widget;
2541 elm_gengrid_item_show(Elm_Gengrid_Item *item)
2543 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2544 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2545 Evas_Coord minx = 0, miny = 0;
2548 if ((!item) || (item->delete_me)) return;
2549 _pan_min_get(wd->pan_smart, &minx, &miny);
2551 elm_smart_scroller_child_region_show(item->wd->scr,
2552 item->x * wd->item_width + minx,
2553 item->y * wd->item_height + miny,
2554 item->wd->item_width,
2555 item->wd->item_height);
2559 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
2561 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2562 if (item->delete_me) return;
2564 Evas_Coord minx = 0, miny = 0;
2565 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2567 _pan_min_get(wd->pan_smart, &minx, &miny);
2569 elm_smart_scroller_region_bring_in(item->wd->scr,
2570 item->x * wd->item_width + minx,
2571 item->y * wd->item_height + miny,
2572 item->wd->item_width,
2573 item->wd->item_height);