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 Elm_Gengrid_Item *parent_group_item;
23 Ecore_Timer *long_timer;
24 Ecore_Animator *item_moving_effect_timer;
26 Eina_List *labels, *icons, *states, *icon_objs;
33 Evas_Coord x, y, gx, gy, dx, dy, ox, oy, tx, ty, rx, ry;
34 unsigned int moving_effect_start_time;
42 Elm_Tooltip_Item_Content_Cb content_cb;
45 Eina_Bool free_size : 1;
48 const char *mouse_cursor;
50 Eina_Bool is_group : 1;
51 Eina_Bool want_unrealize : 1;
52 Eina_Bool group_realized : 1;
53 Eina_Bool realized : 1;
54 Eina_Bool dragging : 1;
56 Eina_Bool delete_me : 1;
57 Eina_Bool display_only : 1;
58 Eina_Bool disabled : 1;
59 Eina_Bool selected : 1;
60 Eina_Bool highlighted : 1;
66 Eina_Inlist_Sorted_State *state;
67 Evas_Object *self, *scr;
68 Evas_Object *pan_smart;
71 Eina_List *group_items;
74 Elm_Gengrid_Item *last_selected_item, *reorder_item;
75 double align_x, align_y;
77 Evas_Coord pan_x, pan_y, old_pan_x, old_pan_y;
78 Evas_Coord item_width, item_height; /* Each item size */
79 Evas_Coord group_item_width, group_item_height; /* Each group item size */
80 Evas_Coord minw, minh; /* Total obj size */
81 Evas_Coord reorder_item_x, reorder_item_y;
87 Eina_Bool horizontal : 1;
88 Eina_Bool on_hold : 1;
89 Eina_Bool longpressed : 1;
91 Eina_Bool no_select : 1;
92 Eina_Bool wasselected : 1;
93 Eina_Bool always_select : 1;
94 Eina_Bool clear_me : 1;
95 Eina_Bool h_bounce : 1;
96 Eina_Bool v_bounce : 1;
97 Eina_Bool reorder_mode : 1;
98 Eina_Bool reorder_item_changed : 1;
99 Eina_Bool move_effect_enabled : 1;
102 #define ELM_GENGRID_ITEM_FROM_INLIST(item) \
103 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
107 Evas_Object_Smart_Clipped_Data __clipped_data;
111 static const char *widtype = NULL;
112 static void _item_highlight(Elm_Gengrid_Item *item);
113 static void _item_unrealize(Elm_Gengrid_Item *item);
114 static void _item_select(Elm_Gengrid_Item *item);
115 static void _item_unselect(Elm_Gengrid_Item *item);
116 static void _calc_job(void *data);
117 static void _on_focus_hook(void *data,
119 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
120 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
121 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
122 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
123 static Eina_Bool _item_single_select_up(Widget_Data *wd);
124 static Eina_Bool _item_single_select_down(Widget_Data *wd);
125 static Eina_Bool _item_single_select_left(Widget_Data *wd);
126 static Eina_Bool _item_single_select_right(Widget_Data *wd);
127 static Eina_Bool _event_hook(Evas_Object *obj,
129 Evas_Callback_Type type,
131 static Eina_Bool _deselect_all_items(Widget_Data *wd);
133 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
134 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
136 static const char SIG_ACTIVATED[] = "activated";
137 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
138 static const char SIG_LONGPRESSED[] = "longpressed";
139 static const char SIG_SELECTED[] = "selected";
140 static const char SIG_UNSELECTED[] = "unselected";
141 static const char SIG_REALIZED[] = "realized";
142 static const char SIG_UNREALIZED[] = "unrealized";
143 static const char SIG_CHANGED[] = "changed";
144 static const char SIG_DRAG_START_UP[] = "drag,start,up";
145 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
146 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
147 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
148 static const char SIG_DRAG_STOP[] = "drag,stop";
149 static const char SIG_DRAG[] = "drag";
150 static const char SIG_SCROLL[] = "scroll";
151 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
152 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
153 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
154 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
155 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
156 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
157 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
158 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
159 static const char SIG_MOVED[] = "moved";
161 static const Evas_Smart_Cb_Description _signals[] = {
163 {SIG_CLICKED_DOUBLE, ""},
164 {SIG_LONGPRESSED, ""},
166 {SIG_UNSELECTED, ""},
168 {SIG_UNREALIZED, ""},
170 {SIG_DRAG_START_UP, ""},
171 {SIG_DRAG_START_DOWN, ""},
172 {SIG_DRAG_START_LEFT, ""},
173 {SIG_DRAG_START_RIGHT, ""},
177 {SIG_SCROLL_ANIM_START, ""},
178 {SIG_SCROLL_ANIM_STOP, ""},
179 {SIG_SCROLL_DRAG_START, ""},
180 {SIG_SCROLL_DRAG_STOP, ""},
181 {SIG_SCROLL_EDGE_TOP, ""},
182 {SIG_SCROLL_EDGE_BOTTOM, ""},
183 {SIG_SCROLL_EDGE_LEFT, ""},
184 {SIG_SCROLL_EDGE_RIGHT, ""},
189 static Eina_Compare_Cb _elm_gengrid_item_compare_cb;
190 static Eina_Compare_Cb _elm_gengrid_item_compare_data_cb;
193 _event_hook(Evas_Object *obj,
194 Evas_Object *src __UNUSED__,
195 Evas_Callback_Type type,
198 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
199 Evas_Event_Key_Down *ev = event_info;
200 Widget_Data *wd = elm_widget_data_get(obj);
201 if (!wd) return EINA_FALSE;
202 if (!wd->items) return EINA_FALSE;
203 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
204 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
206 Elm_Gengrid_Item *item = NULL;
209 Evas_Coord step_x = 0;
210 Evas_Coord step_y = 0;
213 Evas_Coord page_x = 0;
214 Evas_Coord page_y = 0;
216 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
217 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
218 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
219 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
221 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
223 if ((wd->horizontal) &&
224 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
225 (_item_multi_select_up(wd)))
226 || (_item_single_select_up(wd))))
228 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
231 else if ((!wd->horizontal) &&
232 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
233 (_item_multi_select_left(wd)))
234 || (_item_single_select_left(wd))))
236 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
242 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
244 if ((wd->horizontal) &&
245 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
246 (_item_multi_select_down(wd)))
247 || (_item_single_select_down(wd))))
249 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
252 else if ((!wd->horizontal) &&
253 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
254 (_item_multi_select_right(wd)))
255 || (_item_single_select_right(wd))))
257 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
263 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
265 if ((wd->horizontal) &&
266 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
267 (_item_multi_select_left(wd)))
268 || (_item_single_select_left(wd))))
270 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
273 else if ((!wd->horizontal) &&
274 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
275 (_item_multi_select_up(wd)))
276 || (_item_single_select_up(wd))))
278 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
284 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
286 if ((wd->horizontal) &&
287 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
288 (_item_multi_select_right(wd)))
289 || (_item_single_select_right(wd))))
291 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
294 else if ((!wd->horizontal) &&
295 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
296 (_item_multi_select_down(wd)))
297 || (_item_single_select_down(wd))))
299 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
305 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
307 item = elm_gengrid_first_item_get(obj);
308 elm_gengrid_item_bring_in(item);
309 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
312 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
314 item = elm_gengrid_last_item_get(obj);
315 elm_gengrid_item_bring_in(item);
316 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
319 else if ((!strcmp(ev->keyname, "Prior")) ||
320 (!strcmp(ev->keyname, "KP_Prior")))
325 x -= -(page_x * v_w) / 100;
332 y -= -(page_y * v_h) / 100;
337 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
342 x += -(page_x * v_w) / 100;
349 y += -(page_y * v_h) / 100;
354 else if (!strcmp(ev->keyname, "Escape"))
356 if (!_deselect_all_items(wd)) return EINA_FALSE;
357 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
360 else if ((!strcmp(ev->keyname, "Return")) ||
361 (!strcmp(ev->keyname, "KP_Enter")) ||
362 (!strcmp(ev->keyname, "space")))
364 item = elm_gengrid_selected_item_get(obj);
365 evas_object_smart_callback_call(item->wd->self, SIG_ACTIVATED, item);
367 else return EINA_FALSE;
369 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
370 elm_smart_scroller_child_pos_set(wd->scr, x, y);
375 _deselect_all_items(Widget_Data *wd)
377 if (!wd->selected) return EINA_FALSE;
379 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
385 _item_multi_select_left(Widget_Data *wd)
387 if (!wd->selected) return EINA_FALSE;
389 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
390 if (!prev) return EINA_TRUE;
391 if (elm_gengrid_item_selected_get(prev))
393 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
394 wd->last_selected_item = prev;
395 elm_gengrid_item_show(wd->last_selected_item);
399 elm_gengrid_item_selected_set(prev, EINA_TRUE);
400 elm_gengrid_item_show(prev);
407 _item_multi_select_right(Widget_Data *wd)
409 if (!wd->selected) return EINA_FALSE;
411 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
412 if (!next) return EINA_TRUE;
413 if (elm_gengrid_item_selected_get(next))
415 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
416 wd->last_selected_item = next;
417 elm_gengrid_item_show(wd->last_selected_item);
421 elm_gengrid_item_selected_set(next, EINA_TRUE);
422 elm_gengrid_item_show(next);
429 _item_multi_select_up(Widget_Data *wd)
432 Eina_Bool r = EINA_TRUE;
434 if (!wd->selected) return EINA_FALSE;
436 for (i = 0; (r) && (i < wd->nmax); i++)
437 r &= _item_multi_select_left(wd);
443 _item_multi_select_down(Widget_Data *wd)
446 Eina_Bool r = EINA_TRUE;
448 if (!wd->selected) return EINA_FALSE;
450 for (i = 0; (r) && (i < wd->nmax); i++)
451 r &= _item_multi_select_right(wd);
457 _item_single_select_up(Widget_Data *wd)
461 Elm_Gengrid_Item *prev;
465 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
466 while ((prev) && (prev->delete_me))
467 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
468 elm_gengrid_item_selected_set(prev, EINA_TRUE);
469 elm_gengrid_item_show(prev);
472 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
474 if (!prev) return EINA_FALSE;
476 for (i = 1; i < wd->nmax; i++)
478 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
479 if (!tmp) return EINA_FALSE;
483 _deselect_all_items(wd);
485 elm_gengrid_item_selected_set(prev, EINA_TRUE);
486 elm_gengrid_item_show(prev);
491 _item_single_select_down(Widget_Data *wd)
495 Elm_Gengrid_Item *next;
499 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
500 while ((next) && (next->delete_me))
501 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
502 elm_gengrid_item_selected_set(next, EINA_TRUE);
503 elm_gengrid_item_show(next);
506 else next = elm_gengrid_item_next_get(wd->last_selected_item);
508 if (!next) return EINA_FALSE;
510 for (i = 1; i < wd->nmax; i++)
512 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
513 if (!tmp) return EINA_FALSE;
517 _deselect_all_items(wd);
519 elm_gengrid_item_selected_set(next, EINA_TRUE);
520 elm_gengrid_item_show(next);
525 _item_single_select_left(Widget_Data *wd)
527 Elm_Gengrid_Item *prev;
530 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
531 while ((prev) && (prev->delete_me))
532 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
534 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
536 if (!prev) return EINA_FALSE;
538 _deselect_all_items(wd);
540 elm_gengrid_item_selected_set(prev, EINA_TRUE);
541 elm_gengrid_item_show(prev);
546 _item_single_select_right(Widget_Data *wd)
548 Elm_Gengrid_Item *next;
551 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
552 while ((next) && (next->delete_me))
553 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
555 else next = elm_gengrid_item_next_get(wd->last_selected_item);
557 if (!next) return EINA_FALSE;
559 _deselect_all_items(wd);
561 elm_gengrid_item_selected_set(next, EINA_TRUE);
562 elm_gengrid_item_show(next);
567 _on_focus_hook(void *data __UNUSED__,
570 Widget_Data *wd = elm_widget_data_get(obj);
572 if (elm_widget_focus_get(obj))
574 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
575 evas_object_focus_set(wd->self, EINA_TRUE);
576 if ((wd->selected) && (!wd->last_selected_item))
577 wd->last_selected_item = eina_list_data_get(wd->selected);
581 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
582 evas_object_focus_set(wd->self, EINA_FALSE);
587 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
589 Widget_Data *wd = elm_widget_data_get(obj);
590 Elm_Gengrid_Item *item;
592 elm_smart_scroller_mirrored_set(wd->scr, rtl);
593 if (!wd->items) return;
594 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
598 edje_object_mirrored_set(item->base.view, rtl);
599 elm_gengrid_item_update(item);
600 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
605 _theme_hook(Evas_Object *obj)
607 Widget_Data *wd = elm_widget_data_get(obj);
609 _elm_widget_mirrored_reload(obj);
610 _mirrored_set(obj, elm_widget_mirrored_get(obj));
611 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
612 elm_widget_style_get(obj));
616 _del_pre_hook(Evas_Object *obj)
618 Widget_Data *wd = elm_widget_data_get(obj);
620 elm_gengrid_clear(obj);
621 evas_object_del(wd->pan_smart);
622 wd->pan_smart = NULL;
626 _del_hook(Evas_Object *obj)
628 Widget_Data *wd = elm_widget_data_get(obj);
633 _signal_emit_hook(Evas_Object *obj,
634 const char *emission,
637 Widget_Data *wd = elm_widget_data_get(obj);
639 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
644 _mouse_move(void *data,
645 Evas *evas __UNUSED__,
649 Elm_Gengrid_Item *item = data;
650 Evas_Event_Mouse_Move *ev = event_info;
651 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
652 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
654 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
656 if (!item->wd->on_hold)
658 item->wd->on_hold = EINA_TRUE;
659 if (!item->wd->wasselected)
660 _item_unselect(item);
663 if ((item->dragging) && (item->down))
665 if (item->long_timer)
667 ecore_timer_del(item->long_timer);
668 item->long_timer = NULL;
670 evas_object_smart_callback_call(item->wd->self, SIG_DRAG, item);
673 if ((!item->down) || (item->wd->longpressed))
675 if (item->long_timer)
677 ecore_timer_del(item->long_timer);
678 item->long_timer = NULL;
680 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
682 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &ow, &oh);
684 it_scrl_x = ev->cur.canvas.x - item->wd->reorder_item->dx;
685 it_scrl_y = ev->cur.canvas.y - item->wd->reorder_item->dy;
687 if (it_scrl_x < ox) item->wd->reorder_item_x = ox;
688 else if (it_scrl_x + item->wd->item_width > ox + ow)
689 item->wd->reorder_item_x = ox + ow - item->wd->item_width;
690 else item->wd->reorder_item_x = it_scrl_x;
692 if (it_scrl_y < oy) item->wd->reorder_item_y = oy;
693 else if (it_scrl_y + item->wd->item_height > oy + oh)
694 item->wd->reorder_item_y = oy + oh - item->wd->item_height;
695 else item->wd->reorder_item_y = it_scrl_y;
697 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
698 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
702 if (!item->display_only)
703 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
704 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
705 x = ev->cur.canvas.x - x;
706 y = ev->cur.canvas.y - y;
709 if (adx < 0) adx = -dx;
712 if (ady < 0) ady = -dy;
715 if ((adx > minw) || (ady > minh))
717 const char *left_drag, *right_drag;
718 if (!elm_widget_mirrored_get(item->wd->self))
720 left_drag = SIG_DRAG_START_LEFT;
721 right_drag = SIG_DRAG_START_RIGHT;
725 left_drag = SIG_DRAG_START_RIGHT;
726 right_drag = SIG_DRAG_START_LEFT;
730 if (item->long_timer)
732 ecore_timer_del(item->long_timer);
733 item->long_timer = NULL;
735 if (!item->wd->wasselected)
736 _item_unselect(item);
740 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_START_UP,
745 evas_object_smart_callback_call(item->wd->self,
752 evas_object_smart_callback_call(item->wd->self,
753 SIG_DRAG_START_DOWN, item);
757 evas_object_smart_callback_call(item->wd->self,
760 evas_object_smart_callback_call(item->wd->self,
768 _long_press(void *data)
770 Elm_Gengrid_Item *item = data;
772 item->long_timer = NULL;
773 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
774 item->wd->longpressed = EINA_TRUE;
775 evas_object_smart_callback_call(item->wd->self, SIG_LONGPRESSED, item);
776 if (item->wd->reorder_mode)
778 item->wd->reorder_item = item;
779 evas_object_raise(item->base.view);
780 elm_smart_scroller_hold_set(item->wd->scr, EINA_TRUE);
781 elm_smart_scroller_bounce_allow_set(item->wd->scr, EINA_FALSE, EINA_FALSE);
782 edje_object_signal_emit(item->base.view, "elm,state,reorder,enabled", "elm");
784 return ECORE_CALLBACK_CANCEL;
788 _mouse_down(void *data,
789 Evas *evas __UNUSED__,
793 Elm_Gengrid_Item *item = data;
794 Evas_Event_Mouse_Down *ev = event_info;
797 if (ev->button != 1) return;
800 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
801 item->dx = ev->canvas.x - x;
802 item->dy = ev->canvas.y - y;
803 item->wd->longpressed = EINA_FALSE;
804 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
805 else item->wd->on_hold = EINA_FALSE;
806 item->wd->wasselected = item->selected;
807 _item_highlight(item);
808 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
810 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
811 evas_object_smart_callback_call(item->wd->self, SIG_ACTIVATED, item);
813 if (item->long_timer) ecore_timer_del(item->long_timer);
815 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
818 item->long_timer = NULL;
822 _mouse_up(void *data,
823 Evas *evas __UNUSED__,
824 Evas_Object *obj __UNUSED__,
827 Elm_Gengrid_Item *item = data;
828 Evas_Event_Mouse_Up *ev = event_info;
829 Eina_Bool dragged = EINA_FALSE;
831 if (ev->button != 1) return;
832 item->down = EINA_FALSE;
833 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
834 else item->wd->on_hold = EINA_FALSE;
835 if (item->long_timer)
837 ecore_timer_del(item->long_timer);
838 item->long_timer = NULL;
842 item->dragging = EINA_FALSE;
843 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_STOP, item);
846 if (item->wd->on_hold)
848 item->wd->longpressed = EINA_FALSE;
849 item->wd->on_hold = EINA_FALSE;
852 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
854 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
855 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
857 evas_object_smart_callback_call(item->wd->self, SIG_MOVED, item->wd->reorder_item);
858 item->wd->reorder_item = NULL;
859 elm_smart_scroller_hold_set(item->wd->scr, EINA_FALSE);
860 elm_smart_scroller_bounce_allow_set(item->wd->scr, item->wd->h_bounce, item->wd->v_bounce);
861 edje_object_signal_emit(item->base.view, "elm,state,reorder,disabled", "elm");
863 if (item->wd->longpressed)
865 item->wd->longpressed = EINA_FALSE;
866 if (!item->wd->wasselected) _item_unselect(item);
867 item->wd->wasselected = EINA_FALSE;
872 if (item->want_unrealize) _item_unrealize(item);
874 if ((item->disabled) || (dragged)) return;
879 _item_highlight(item);
882 else _item_unselect(item);
888 while (item->wd->selected)
889 _item_unselect(item->wd->selected->data);
893 const Eina_List *l, *l_next;
894 Elm_Gengrid_Item *item2;
896 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
897 if (item2 != item) _item_unselect(item2);
899 _item_highlight(item);
905 _item_highlight(Elm_Gengrid_Item *item)
907 if ((item->wd->no_select) || (item->delete_me) || (item->highlighted)) return;
908 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
909 item->highlighted = EINA_TRUE;
913 _item_realize(Elm_Gengrid_Item *item)
918 if ((item->realized) || (item->delete_me)) return;
919 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
920 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
922 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
923 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
924 elm_widget_sub_object_add(item->wd->self, item->base.view);
925 snprintf(style, sizeof(style), "item/%s",
926 item->gic->item_style ? item->gic->item_style : "default");
927 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
928 elm_widget_style_get(item->wd->self));
930 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
931 evas_object_color_set(item->spacer, 0, 0, 0, 0);
932 elm_widget_sub_object_add(item->wd->self, item->spacer);
933 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
934 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
936 if (item->gic->func.label_get)
942 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
944 EINA_LIST_FOREACH(item->labels, l, key)
946 char *s = item->gic->func.label_get
947 ((void *)item->base.data, item->wd->self, l->data);
950 edje_object_part_text_set(item->base.view, l->data, s);
956 if (item->gic->func.icon_get)
962 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
964 EINA_LIST_FOREACH(item->icons, l, key)
966 Evas_Object *ic = item->gic->func.icon_get
967 ((void *)item->base.data, item->wd->self, l->data);
970 item->icon_objs = eina_list_append(item->icon_objs, ic);
971 edje_object_part_swallow(item->base.view, key, ic);
972 evas_object_show(ic);
973 elm_widget_sub_object_add(item->wd->self, ic);
978 if (item->gic->func.state_get)
984 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
986 EINA_LIST_FOREACH(item->states, l, key)
988 Eina_Bool on = item->gic->func.state_get
989 ((void *)item->base.data, item->wd->self, l->data);
992 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
993 edje_object_signal_emit(item->base.view, buf, "elm");
1000 if ((!item->wd->group_item_width) && (!item->wd->group_item_height))
1002 edje_object_size_min_restricted_calc(item->base.view,
1003 &item->wd->group_item_width,
1004 &item->wd->group_item_height,
1005 item->wd->group_item_width,
1006 item->wd->group_item_height);
1011 if ((!item->wd->item_width) && (!item->wd->item_height))
1013 edje_object_size_min_restricted_calc(item->base.view,
1014 &item->wd->item_width,
1015 &item->wd->item_height,
1016 item->wd->item_width,
1017 item->wd->item_height);
1018 elm_coords_finger_size_adjust(1, &item->wd->item_width,
1019 1, &item->wd->item_height);
1022 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1024 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
1026 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1030 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
1032 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
1034 evas_object_show(item->base.view);
1036 if (item->tooltip.content_cb)
1038 elm_widget_item_tooltip_content_cb_set(item,
1039 item->tooltip.content_cb,
1040 item->tooltip.data, NULL);
1041 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1042 elm_widget_item_tooltip_size_restrict_disable(item, item->tooltip.free_size);
1045 if (item->mouse_cursor)
1046 elm_widget_item_cursor_set(item, item->mouse_cursor);
1048 item->realized = EINA_TRUE;
1049 item->want_unrealize = EINA_FALSE;
1053 _item_unrealize(Elm_Gengrid_Item *item)
1057 if (!item->realized) return;
1058 if (item->long_timer)
1060 ecore_timer_del(item->long_timer);
1061 item->long_timer = NULL;
1063 evas_object_del(item->base.view);
1064 item->base.view = NULL;
1065 evas_object_del(item->spacer);
1066 item->spacer = NULL;
1067 elm_widget_stringlist_free(item->labels);
1068 item->labels = NULL;
1069 elm_widget_stringlist_free(item->icons);
1071 elm_widget_stringlist_free(item->states);
1072 item->states = NULL;
1074 EINA_LIST_FREE(item->icon_objs, icon)
1075 evas_object_del(icon);
1077 item->realized = EINA_FALSE;
1078 item->want_unrealize = EINA_FALSE;
1082 _reorder_item_moving_effect_timer_cb(void *data)
1084 Elm_Gengrid_Item *item = data;
1088 time = REORDER_EFFECT_TIME;
1089 t = ((0.0 > (t = ecore_loop_time_get()-item->moving_effect_start_time)) ? 0.0 : t);
1090 dx = ((item->tx - item->ox) / 10) * _elm_config->scale;
1091 dy = ((item->ty - item->oy) / 10) * _elm_config->scale;
1095 item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
1096 item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
1104 if ((((dx > 0) && (item->rx >= item->tx)) || ((dx <= 0) && (item->rx <= item->tx))) &&
1105 (((dy > 0) && (item->ry >= item->ty)) || ((dy <= 0) && (item->ry <= item->ty))))
1107 evas_object_move(item->base.view, item->tx, item->ty);
1111 evas_object_geometry_get(item->wd->pan_smart, NULL, NULL, &vw, &vh);
1112 if (item->wd->horizontal)
1113 evas_object_resize(item->base.view, item->wd->group_item_width, vh);
1115 evas_object_resize(item->base.view, vw, item->wd->group_item_height);
1118 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1119 item->moving = EINA_FALSE;
1120 item->item_moving_effect_timer = NULL;
1121 return ECORE_CALLBACK_CANCEL;
1124 evas_object_move(item->base.view, item->rx, item->ry);
1128 evas_object_geometry_get(item->wd->pan_smart, NULL, NULL, &vw, &vh);
1129 if (item->wd->horizontal)
1130 evas_object_resize(item->base.view, item->wd->group_item_width, vh);
1132 evas_object_resize(item->base.view, vw, item->wd->group_item_height);
1135 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1137 return ECORE_CALLBACK_RENEW;
1141 _group_item_place(Pan *sd)
1143 Evas_Coord iw, ih, vw, vh;
1145 Eina_Bool was_realized;
1146 Elm_Gengrid_Item *it;
1147 evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1148 if (sd->wd->horizontal)
1150 iw = sd->wd->group_item_width;
1156 ih = sd->wd->group_item_height;
1158 EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1160 was_realized = it->realized;
1161 if (it->group_realized)
1165 evas_object_smart_callback_call(it->wd->self, SIG_REALIZED, it);
1166 evas_object_move(it->base.view, it->gx, it->gy);
1167 evas_object_resize(it->base.view, iw, ih);
1168 evas_object_raise(it->base.view);
1172 _item_unrealize(it);
1174 evas_object_smart_callback_call(it->wd->self, SIG_UNREALIZED, it);
1181 _item_place(Elm_Gengrid_Item *item,
1185 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1186 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1187 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1191 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1193 /* Preload rows/columns at each side of the Gengrid */
1194 cvx = ox - PRELOAD * item->wd->item_width;
1195 cvy = oy - PRELOAD * item->wd->item_height;
1196 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1197 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1202 items_count = item->wd->count - eina_list_count(item->wd->group_items) + item->wd->items_lost;
1203 if (item->wd->horizontal)
1205 int columns, items_visible = 0, items_row;
1207 if (item->wd->item_height > 0)
1208 items_visible = vh / item->wd->item_height;
1209 if (items_visible < 1)
1212 columns = items_count / items_visible;
1213 if (items_count % items_visible)
1216 tcw = (item->wd->item_width * columns) + (item->wd->group_item_width * eina_list_count(item->wd->group_items));
1217 alignw = (vw - tcw) * item->wd->align_x;
1219 items_row = items_visible;
1220 if (items_row > item->wd->count)
1221 items_row = item->wd->count;
1222 tch = items_row * item->wd->item_height;
1223 alignh = (vh - tch) * item->wd->align_y;
1227 int rows, items_visible = 0, items_col;
1229 if (item->wd->item_width > 0)
1230 items_visible = vw / item->wd->item_width;
1231 if (items_visible < 1)
1234 rows = items_count / items_visible;
1235 if (items_count % items_visible)
1238 tch = (item->wd->item_height * rows) + (item->wd->group_item_height * eina_list_count(item->wd->group_items));
1239 alignh = (vh - tch) * item->wd->align_y;
1241 items_col = items_visible;
1242 if (items_col > item->wd->count)
1243 items_col = item->wd->count;
1244 tcw = items_col * item->wd->item_width;
1245 alignw = (vw - tcw) * item->wd->align_x;
1250 if (item->wd->horizontal)
1252 x = (((cx - item->prev_group) * item->wd->item_width) + (item->prev_group * item->wd->group_item_width)) - item->wd->pan_x + ox + alignw;
1254 iw = item->wd->group_item_width;
1260 y = (((cy - item->prev_group) * item->wd->item_height) + (item->prev_group * item->wd->group_item_height)) - item->wd->pan_y + oy + alignh;
1262 ih = item->wd->group_item_height;
1269 if (item->wd->horizontal)
1271 x = (((cx - item->prev_group) * item->wd->item_width) + (item->prev_group * item->wd->group_item_width)) - item->wd->pan_x + ox + alignw;
1272 y = (cy * item->wd->item_height) - item->wd->pan_y + oy + alignh;
1276 x = (cx * item->wd->item_height) - item->wd->pan_x + ox + alignw;
1277 y = (((cy - item->prev_group) * item->wd->item_height) + (item->prev_group * item->wd->group_item_height)) - item->wd->pan_y + oy + alignh;
1279 if (elm_widget_mirrored_get(item->wd->self))
1280 { /* Switch items side and componsate for pan_x when in RTL mode */
1281 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1282 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1284 iw = item->wd->item_width;
1285 ih = item->wd->item_height;
1288 Eina_Bool was_realized = item->realized;
1289 if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1291 _item_realize(item);
1293 evas_object_smart_callback_call(item->wd->self, SIG_REALIZED, item);
1294 if (item->parent_group_item)
1296 if (item->wd->horizontal)
1298 if (item->parent_group_item->gx < 0)
1300 item->parent_group_item->gx = x + item->wd->item_width - item->wd->group_item_width;
1301 if (item->parent_group_item->gx > 0)
1302 item->parent_group_item->gx = 0;
1307 if (item->parent_group_item->gy < 0)
1309 item->parent_group_item->gy = y + item->wd->item_height - item->wd->group_item_height;
1310 if (item->parent_group_item->gy > 0)
1311 item->parent_group_item->gy = 0;
1313 item->parent_group_item->group_realized = EINA_TRUE;
1316 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
1318 if (item->moving) return;
1320 if (!item->wd->move_effect_enabled)
1325 if (item->wd->reorder_item == item)
1327 evas_object_move(item->base.view,
1328 item->wd->reorder_item_x, item->wd->reorder_item_y);
1329 evas_object_resize(item->base.view, iw, ih);
1334 if (item->wd->move_effect_enabled)
1336 if ((item->ox != x) || (item->oy != y))
1338 if (((item->wd->old_pan_x == item->wd->pan_x) && (item->wd->old_pan_y == item->wd->pan_y)) ||
1339 ((item->wd->old_pan_x != item->wd->pan_x) && !(item->ox - item->wd->pan_x + item->wd->old_pan_x == x)) ||
1340 ((item->wd->old_pan_y != item->wd->pan_y) && !(item->oy - item->wd->pan_y + item->wd->old_pan_y == y)))
1344 item->rx = item->ox;
1345 item->ry = item->oy;
1346 item->moving = EINA_TRUE;
1347 item->moving_effect_start_time = ecore_loop_time_get();
1348 item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, item);
1355 Evas_Coord nx, ny, nw, nh;
1358 if (item->wd->horizontal)
1360 nx = x + (item->wd->group_item_width / 2);
1368 ny = y + (item->wd->group_item_height / 2);
1375 nx = x + (item->wd->item_width / 2);
1376 ny = y + (item->wd->item_height / 2);
1381 if ( ELM_RECTS_INTERSECT(item->wd->reorder_item_x, item->wd->reorder_item_y,
1382 item->wd->item_width, item->wd->item_height,
1385 if (item->wd->horizontal)
1387 if ((item->wd->nmax * item->wd->reorder_item->x + item->wd->reorder_item->y) >
1388 (item->wd->nmax * item->x + item->y))
1389 reorder_item_move_forward = EINA_TRUE;
1393 if ((item->wd->nmax * item->wd->reorder_item->y + item->wd->reorder_item->x) >
1394 (item->wd->nmax * item->y + item->x))
1395 reorder_item_move_forward = EINA_TRUE;
1398 item->wd->items = eina_inlist_remove(item->wd->items,
1399 EINA_INLIST_GET(item->wd->reorder_item));
1400 if (reorder_item_move_forward)
1401 item->wd->items = eina_inlist_prepend_relative(item->wd->items,
1402 EINA_INLIST_GET(item->wd->reorder_item),
1403 EINA_INLIST_GET(item));
1405 item->wd->items = eina_inlist_append_relative(item->wd->items,
1406 EINA_INLIST_GET(item->wd->reorder_item),
1407 EINA_INLIST_GET(item));
1409 item->wd->reorder_item_changed = EINA_TRUE;
1410 item->wd->move_effect_enabled = EINA_TRUE;
1411 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1412 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1418 if (!item->is_group)
1420 evas_object_move(item->base.view, x, y);
1421 evas_object_resize(item->base.view, iw, ih);
1424 item->group_realized = EINA_TRUE;
1428 if (!item->is_group)
1430 _item_unrealize(item);
1432 evas_object_smart_callback_call(item->wd->self, SIG_UNREALIZED, item);
1435 item->group_realized = EINA_FALSE;
1440 _item_label_hook(Elm_Gengrid_Item *it, const char *part)
1442 if (!it->gic->func.label_get) return NULL;
1443 return edje_object_part_text_get(it->base.view, part);
1446 static Elm_Gengrid_Item *
1447 _item_create(Widget_Data *wd,
1448 const Elm_Gengrid_Item_Class *gic,
1451 const void *func_data)
1453 Elm_Gengrid_Item *item;
1455 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1456 if (!item) return NULL;
1460 item->base.data = data;
1461 item->func.func = func;
1462 item->func.data = func_data;
1463 item->mouse_cursor = NULL;
1464 item->is_group = !strcmp(item->gic->item_style, "group_index");
1465 elm_widget_item_text_get_hook_set(item, _item_label_hook);
1471 _item_del(Elm_Gengrid_Item *item)
1473 elm_widget_item_pre_notify_del(item);
1475 item->wd->selected = eina_list_remove(item->wd->selected, item);
1476 if (item->realized) _item_unrealize(item);
1477 if ((!item->delete_me) && (item->gic->func.del))
1478 item->gic->func.del((void *)item->base.data, item->wd->self);
1479 item->delete_me = EINA_TRUE;
1480 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1481 if (item->long_timer) ecore_timer_del(item->long_timer);
1482 if (item->tooltip.del_cb)
1483 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1484 item->wd->walking -= item->walking;
1487 item->wd->group_items = eina_list_remove(item->wd->group_items, item);
1488 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1489 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1490 elm_widget_item_del(item);
1494 _item_select(Elm_Gengrid_Item *item)
1496 if ((item->wd->no_select) || (item->delete_me)) return;
1499 if (item->wd->always_select) goto call;
1502 item->selected = EINA_TRUE;
1503 item->wd->selected = eina_list_append(item->wd->selected, item);
1506 item->wd->walking++;
1507 if (item->func.func)
1508 item->func.func((void *)item->func.data, item->wd->self, item);
1509 if (!item->delete_me)
1510 evas_object_smart_callback_call(item->wd->self, SIG_SELECTED, item);
1512 item->wd->walking--;
1513 item->wd->last_selected_item = item;
1514 if ((item->wd->clear_me) && (!item->wd->walking))
1515 elm_gengrid_clear(item->base.widget);
1518 if ((!item->walking) && (item->delete_me))
1519 if (!item->relcount) _item_del(item);
1524 _item_unselect(Elm_Gengrid_Item *item)
1526 if ((item->delete_me) || (!item->highlighted)) return;
1527 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1528 item->highlighted = EINA_FALSE;
1531 item->selected = EINA_FALSE;
1532 item->wd->selected = eina_list_remove(item->wd->selected, item);
1533 evas_object_smart_callback_call(item->wd->self, SIG_UNSELECTED, item);
1538 _calc_job(void *data)
1540 Widget_Data *wd = data;
1541 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1542 Elm_Gengrid_Item *item, *group_item = NULL;
1543 int count_group = 0;
1547 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1548 if ((cvw != 0) || (cvh != 0))
1550 if ((wd->horizontal) && (wd->item_height > 0))
1551 nmax = cvh / wd->item_height;
1552 else if (wd->item_width > 0)
1553 nmax = cvw / wd->item_width;
1558 EINA_INLIST_FOREACH(wd->items, item)
1560 if (item->prev_group != count_group)
1561 item->prev_group = count_group;
1564 count = count % nmax;
1566 wd->items_lost += nmax - count;
1567 //printf("%d items and I lost %d\n", count, wd->items_lost);
1569 if (count) count = 0;
1574 if (item->parent_group_item != group_item)
1575 item->parent_group_item = group_item;
1579 count = wd->count + wd->items_lost - count_group;
1582 minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_height);
1583 minh = nmax * wd->item_height;
1587 minw = nmax * wd->item_width;
1588 minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1591 if ((minw != wd->minw) || (minh != wd->minh))
1595 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1599 evas_object_smart_changed(wd->pan_smart);
1601 wd->calc_job = NULL;
1605 _pan_add(Evas_Object *obj)
1608 Evas_Object_Smart_Clipped_Data *cd;
1611 cd = evas_object_smart_data_get(obj);
1614 sd->__clipped_data = *cd;
1616 evas_object_smart_data_set(obj, sd);
1620 _pan_del(Evas_Object *obj)
1622 Pan *sd = evas_object_smart_data_get(obj);
1629 _pan_set(Evas_Object *obj,
1633 Pan *sd = evas_object_smart_data_get(obj);
1634 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1637 evas_object_smart_changed(obj);
1641 _pan_get(Evas_Object *obj,
1645 Pan *sd = evas_object_smart_data_get(obj);
1646 if (x) *x = sd->wd->pan_x;
1647 if (y) *y = sd->wd->pan_y;
1651 _pan_child_size_get(Evas_Object *obj,
1655 Pan *sd = evas_object_smart_data_get(obj);
1656 if (w) *w = sd->wd->minw;
1657 if (h) *h = sd->wd->minh;
1661 _pan_max_get(Evas_Object *obj,
1665 Pan *sd = evas_object_smart_data_get(obj);
1669 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1671 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1673 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1677 _pan_min_get(Evas_Object *obj,
1681 Pan *sd = evas_object_smart_data_get(obj);
1685 _pan_max_get(obj, &mx, &my);
1687 *x = -mx * sd->wd->align_x;
1689 *y = -my * sd->wd->align_y;
1693 _pan_resize(Evas_Object *obj,
1697 Pan *sd = evas_object_smart_data_get(obj);
1700 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1701 if ((ow == w) && (oh == h)) return;
1702 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1703 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1707 _pan_calculate(Evas_Object *obj)
1709 Pan *sd = evas_object_smart_data_get(obj);
1710 Evas_Coord cx = 0, cy = 0;
1711 Elm_Gengrid_Item *item;
1714 if (!sd->wd->nmax) return;
1716 sd->wd->reorder_item_changed = EINA_FALSE;
1718 EINA_INLIST_FOREACH(sd->wd->items, item)
1722 if (sd->wd->horizontal)
1739 _item_place(item, cx, cy);
1740 if (sd->wd->reorder_item_changed) return;
1743 if (sd->wd->horizontal)
1756 if (sd->wd->horizontal)
1758 cy = (cy + 1) % sd->wd->nmax;
1763 cx = (cx + 1) % sd->wd->nmax;
1768 _group_item_place(sd);
1771 if ((sd->wd->reorder_mode) && (sd->wd->reorder_item))
1773 if (!sd->wd->reorder_item_changed)
1775 sd->wd->old_pan_x = sd->wd->pan_x;
1776 sd->wd->old_pan_y = sd->wd->pan_y;
1778 sd->wd->move_effect_enabled = EINA_FALSE;
1780 evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
1784 _pan_move(Evas_Object *obj,
1785 Evas_Coord x __UNUSED__,
1786 Evas_Coord y __UNUSED__)
1788 Pan *sd = evas_object_smart_data_get(obj);
1790 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1791 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1795 _hold_on(void *data __UNUSED__,
1797 void *event_info __UNUSED__)
1799 Widget_Data *wd = elm_widget_data_get(obj);
1801 elm_smart_scroller_hold_set(wd->scr, 1);
1805 _hold_off(void *data __UNUSED__,
1807 void *event_info __UNUSED__)
1809 Widget_Data *wd = elm_widget_data_get(obj);
1811 elm_smart_scroller_hold_set(wd->scr, 0);
1815 _freeze_on(void *data __UNUSED__,
1817 void *event_info __UNUSED__)
1819 Widget_Data *wd = elm_widget_data_get(obj);
1821 elm_smart_scroller_freeze_set(wd->scr, 1);
1825 _freeze_off(void *data __UNUSED__,
1827 void *event_info __UNUSED__)
1829 Widget_Data *wd = elm_widget_data_get(obj);
1831 elm_smart_scroller_freeze_set(wd->scr, 0);
1835 _scr_anim_start(void *data,
1836 Evas_Object *obj __UNUSED__,
1837 void *event_info __UNUSED__)
1839 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1843 _scr_anim_stop(void *data,
1844 Evas_Object *obj __UNUSED__,
1845 void *event_info __UNUSED__)
1847 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1851 _scr_drag_start(void *data,
1852 Evas_Object *obj __UNUSED__,
1853 void *event_info __UNUSED__)
1855 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1859 _scr_drag_stop(void *data,
1860 Evas_Object *obj __UNUSED__,
1861 void *event_info __UNUSED__)
1863 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1867 _scr_edge_left(void *data,
1868 Evas_Object *scr __UNUSED__,
1869 void *event_info __UNUSED__)
1871 evas_object_smart_callback_call(data, SIG_SCROLL_EDGE_LEFT, NULL);
1875 _scr_edge_right(void *data,
1876 Evas_Object *scr __UNUSED__,
1877 void *event_info __UNUSED__)
1879 evas_object_smart_callback_call(data, SIG_SCROLL_EDGE_RIGHT, NULL);
1883 _scr_edge_top(void *data,
1884 Evas_Object *scr __UNUSED__,
1885 void *event_info __UNUSED__)
1887 evas_object_smart_callback_call(data, SIG_SCROLL_EDGE_TOP, NULL);
1891 _scr_edge_bottom(void *data,
1892 Evas_Object *scr __UNUSED__,
1893 void *event_info __UNUSED__)
1895 evas_object_smart_callback_call(data, SIG_SCROLL_EDGE_BOTTOM, NULL);
1899 _scr_scroll(void *data,
1900 Evas_Object *obj __UNUSED__,
1901 void *event_info __UNUSED__)
1903 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1907 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1909 const Elm_Gengrid_Item *item = data;
1910 const Elm_Gengrid_Item *item1 = data1;
1912 return _elm_gengrid_item_compare_data_cb(item->base.data, item1->base.data);
1916 _elm_gengrid_item_compare(const void *data, const void *data1)
1918 Elm_Gengrid_Item *item, *item1;
1919 item = ELM_GENGRID_ITEM_FROM_INLIST(data);
1920 item1 = ELM_GENGRID_ITEM_FROM_INLIST(data1);
1921 return _elm_gengrid_item_compare_cb(item, item1);
1925 elm_gengrid_add(Evas_Object *parent)
1930 static Evas_Smart *smart = NULL;
1931 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1933 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1935 ELM_SET_WIDTYPE(widtype, "gengrid");
1936 elm_widget_type_set(obj, "gengrid");
1937 elm_widget_sub_object_add(parent, obj);
1938 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1939 elm_widget_data_set(obj, wd);
1940 elm_widget_del_hook_set(obj, _del_hook);
1941 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1942 elm_widget_theme_hook_set(obj, _theme_hook);
1943 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1944 elm_widget_can_focus_set(obj, EINA_TRUE);
1945 elm_widget_event_hook_set(obj, _event_hook);
1947 wd->scr = elm_smart_scroller_add(e);
1948 elm_smart_scroller_widget_set(wd->scr, obj);
1949 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1951 elm_widget_resize_object_set(obj, wd->scr);
1953 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1954 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1955 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1956 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1957 evas_object_smart_callback_add(wd->scr, "edge,left", _scr_edge_left, obj);
1958 evas_object_smart_callback_add(wd->scr, "edge,right", _scr_edge_right, obj);
1959 evas_object_smart_callback_add(wd->scr, "edge,top", _scr_edge_top, obj);
1960 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scr_edge_bottom,
1962 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1964 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1969 wd->h_bounce = bounce;
1970 wd->v_bounce = bounce;
1971 wd->no_select = EINA_FALSE;
1973 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1974 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1975 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1976 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1978 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1982 static Evas_Smart_Class sc;
1984 evas_object_smart_clipped_smart_set(&_pan_sc);
1986 sc.name = "elm_gengrid_pan";
1987 sc.version = EVAS_SMART_CLASS_VERSION;
1990 sc.resize = _pan_resize;
1991 sc.move = _pan_move;
1992 sc.calculate = _pan_calculate;
1993 smart = evas_smart_class_new(&sc);
1997 wd->pan_smart = evas_object_smart_add(e, smart);
1998 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2002 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2003 _pan_set, _pan_get, _pan_max_get,
2004 _pan_min_get, _pan_child_size_get);
2006 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2011 elm_gengrid_item_size_set(Evas_Object *obj,
2015 ELM_CHECK_WIDTYPE(obj, widtype);
2016 Widget_Data *wd = elm_widget_data_get(obj);
2018 if ((wd->item_width == w) && (wd->item_height == h)) return;
2020 wd->item_height = h;
2021 if (wd->calc_job) ecore_job_del(wd->calc_job);
2022 wd->calc_job = ecore_job_add(_calc_job, wd);
2026 elm_gengrid_item_size_get(const Evas_Object *obj,
2030 ELM_CHECK_WIDTYPE(obj, widtype);
2031 Widget_Data *wd = elm_widget_data_get(obj);
2033 if (w) *w = wd->item_width;
2034 if (h) *h = wd->item_height;
2038 elm_gengrid_group_item_size_set(Evas_Object *obj,
2042 ELM_CHECK_WIDTYPE(obj, widtype);
2043 Widget_Data *wd = elm_widget_data_get(obj);
2045 if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
2046 wd->group_item_width = w;
2047 wd->group_item_height = h;
2048 if (wd->calc_job) ecore_job_del(wd->calc_job);
2049 wd->calc_job = ecore_job_add(_calc_job, wd);
2053 elm_gengrid_group_item_size_get(const Evas_Object *obj,
2057 ELM_CHECK_WIDTYPE(obj, widtype);
2058 Widget_Data *wd = elm_widget_data_get(obj);
2060 if (w) *w = wd->group_item_width;
2061 if (h) *h = wd->group_item_height;
2065 elm_gengrid_align_set(Evas_Object *obj,
2069 ELM_CHECK_WIDTYPE(obj, widtype);
2071 Widget_Data *wd = elm_widget_data_get(obj);
2072 double old_h = wd->align_x, old_y = wd->align_y;
2076 else if (align_x < 0.0)
2078 wd->align_x = align_x;
2082 else if (align_y < 0.0)
2084 wd->align_y = align_y;
2086 if ((old_h != wd->align_x) || (old_y != wd->align_y))
2087 evas_object_smart_calculate(wd->pan_smart);
2091 elm_gengrid_align_get(const Evas_Object *obj,
2095 ELM_CHECK_WIDTYPE(obj, widtype);
2096 Widget_Data *wd = elm_widget_data_get(obj);
2097 if (align_x) *align_x = wd->align_x;
2098 if (align_y) *align_y = wd->align_y;
2101 EAPI Elm_Gengrid_Item *
2102 elm_gengrid_item_append(Evas_Object *obj,
2103 const Elm_Gengrid_Item_Class *gic,
2106 const void *func_data)
2108 Elm_Gengrid_Item *item;
2109 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2110 Widget_Data *wd = elm_widget_data_get(obj);
2111 if (!wd) return NULL;
2113 item = _item_create(wd, gic, data, func, func_data);
2114 if (!item) return NULL;
2115 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
2118 wd->group_items = eina_list_prepend(wd->group_items, item);
2120 if (wd->calc_job) ecore_job_del(wd->calc_job);
2121 wd->calc_job = ecore_job_add(_calc_job, wd);
2126 EAPI Elm_Gengrid_Item *
2127 elm_gengrid_item_prepend(Evas_Object *obj,
2128 const Elm_Gengrid_Item_Class *gic,
2131 const void *func_data)
2133 Elm_Gengrid_Item *item;
2134 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2135 Widget_Data *wd = elm_widget_data_get(obj);
2136 if (!wd) return NULL;
2138 item = _item_create(wd, gic, data, func, func_data);
2139 if (!item) return NULL;
2140 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
2142 wd->group_items = eina_list_append(wd->group_items, item);
2144 if (wd->calc_job) ecore_job_del(wd->calc_job);
2145 wd->calc_job = ecore_job_add(_calc_job, wd);
2150 EAPI Elm_Gengrid_Item *
2151 elm_gengrid_item_insert_before(Evas_Object *obj,
2152 const Elm_Gengrid_Item_Class *gic,
2154 Elm_Gengrid_Item *relative,
2156 const void *func_data)
2158 Elm_Gengrid_Item *item;
2159 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2160 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2161 Widget_Data *wd = elm_widget_data_get(obj);
2162 if (!wd) return NULL;
2164 item = _item_create(wd, gic, data, func, func_data);
2165 if (!item) return NULL;
2166 wd->items = eina_inlist_prepend_relative
2167 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
2169 wd->group_items = eina_list_append_relative(wd->group_items, item, relative->parent_group_item);
2171 if (wd->calc_job) ecore_job_del(wd->calc_job);
2172 wd->calc_job = ecore_job_add(_calc_job, wd);
2177 EAPI Elm_Gengrid_Item *
2178 elm_gengrid_item_insert_after(Evas_Object *obj,
2179 const Elm_Gengrid_Item_Class *gic,
2181 Elm_Gengrid_Item *relative,
2183 const void *func_data)
2185 Elm_Gengrid_Item *item;
2186 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2187 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2188 Widget_Data *wd = elm_widget_data_get(obj);
2189 if (!wd) return NULL;
2191 item = _item_create(wd, gic, data, func, func_data);
2192 if (!item) return NULL;
2193 wd->items = eina_inlist_append_relative
2194 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
2196 wd->group_items = eina_list_prepend_relative(wd->group_items, item, relative->parent_group_item);
2198 if (wd->calc_job) ecore_job_del(wd->calc_job);
2199 wd->calc_job = ecore_job_add(_calc_job, wd);
2204 EAPI Elm_Gengrid_Item *
2205 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
2206 const Elm_Gengrid_Item_Class *gic,
2208 Eina_Compare_Cb comp,
2210 const void *func_data)
2212 Elm_Gengrid_Item *item;
2213 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2214 Widget_Data *wd = elm_widget_data_get(obj);
2215 if (!wd) return NULL;
2217 item = _item_create(wd, gic, data, func, func_data);
2218 if (!item) return NULL;
2221 wd->state = eina_inlist_sorted_state_new();
2223 _elm_gengrid_item_compare_cb = comp;
2224 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(item),
2225 _elm_gengrid_item_compare, wd->state);
2226 if (wd->calc_job) ecore_job_del(wd->calc_job);
2227 wd->calc_job = ecore_job_add(_calc_job, wd);
2232 EAPI Elm_Gengrid_Item *
2233 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2234 const Elm_Gengrid_Item_Class *gic,
2236 Eina_Compare_Cb comp,
2238 const void *func_data)
2240 _elm_gengrid_item_compare_data_cb = comp;
2242 return elm_gengrid_item_direct_sorted_insert(obj, gic, data, _elm_gengrid_item_compare_data, func, func_data);
2246 elm_gengrid_item_del(Elm_Gengrid_Item *item)
2248 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2249 if ((item->relcount > 0) || (item->walking > 0))
2251 item->delete_me = EINA_TRUE;
2252 elm_widget_item_pre_notify_del(item);
2254 item->wd->selected = eina_list_remove(item->wd->selected, item);
2255 if (item->gic->func.del)
2256 item->gic->func.del((void *)item->base.data, item->wd->self);
2264 elm_gengrid_horizontal_set(Evas_Object *obj,
2267 ELM_CHECK_WIDTYPE(obj, widtype);
2268 Widget_Data *wd = elm_widget_data_get(obj);
2270 if (setting == wd->horizontal) return;
2271 wd->horizontal = setting;
2273 /* Update the items to conform to the new layout */
2274 if (wd->calc_job) ecore_job_del(wd->calc_job);
2275 wd->calc_job = ecore_job_add(_calc_job, wd);
2279 elm_gengrid_horizontal_get(const Evas_Object *obj)
2281 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2282 Widget_Data *wd = elm_widget_data_get(obj);
2283 if (!wd) return EINA_FALSE;
2284 return wd->horizontal;
2288 elm_gengrid_clear(Evas_Object *obj)
2290 ELM_CHECK_WIDTYPE(obj, widtype);
2291 Widget_Data *wd = elm_widget_data_get(obj);
2296 eina_inlist_sorted_state_free(wd->state);
2301 ecore_job_del(wd->calc_job);
2302 wd->calc_job = NULL;
2305 if (wd->walking > 0)
2307 Elm_Gengrid_Item *item;
2309 EINA_INLIST_FOREACH(wd->items, item)
2310 item->delete_me = 1;
2316 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2318 wd->items = eina_inlist_remove(wd->items, wd->items);
2319 elm_widget_item_pre_notify_del(item);
2320 if (item->realized) _item_unrealize(item);
2321 if (item->gic->func.del)
2322 item->gic->func.del((void *)item->base.data, wd->self);
2323 if (item->long_timer) ecore_timer_del(item->long_timer);
2324 elm_widget_item_del(item);
2329 eina_list_free(wd->selected);
2330 wd->selected = NULL;
2338 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2339 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2342 EAPI const Evas_Object *
2343 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
2345 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2346 return item->base.view;
2350 elm_gengrid_item_update(Elm_Gengrid_Item *item)
2352 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2353 if (!item->realized) return;
2354 if (item->want_unrealize) return;
2355 _item_unrealize(item);
2356 _item_realize(item);
2357 _item_place(item, item->x, item->y);
2361 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2363 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2364 return elm_widget_item_data_get(item);
2368 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2371 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2372 elm_widget_item_data_set(item, data);
2375 EAPI const Elm_Gengrid_Item_Class *
2376 elm_gengrid_item_item_class_get(const Elm_Gengrid_Item *item)
2378 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2379 if (item->delete_me) return NULL;
2384 elm_gengrid_item_item_class_set(Elm_Gengrid_Item *item,
2385 const Elm_Gengrid_Item_Class *gic)
2387 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2388 EINA_SAFETY_ON_NULL_RETURN(gic);
2389 if (item->delete_me) return;
2391 elm_gengrid_item_update(item);
2395 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2399 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2400 if (x) *x = item->x;
2401 if (y) *y = item->y;
2405 elm_gengrid_multi_select_set(Evas_Object *obj,
2408 ELM_CHECK_WIDTYPE(obj, widtype);
2409 Widget_Data *wd = elm_widget_data_get(obj);
2415 elm_gengrid_multi_select_get(const Evas_Object *obj)
2417 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2418 Widget_Data *wd = elm_widget_data_get(obj);
2419 if (!wd) return EINA_FALSE;
2423 EAPI Elm_Gengrid_Item *
2424 elm_gengrid_selected_item_get(const Evas_Object *obj)
2426 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2427 Widget_Data *wd = elm_widget_data_get(obj);
2428 if (!wd) return NULL;
2429 if (wd->selected) return wd->selected->data;
2433 EAPI const Eina_List *
2434 elm_gengrid_selected_items_get(const Evas_Object *obj)
2436 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2437 Widget_Data *wd = elm_widget_data_get(obj);
2438 if (!wd) return NULL;
2439 return wd->selected;
2443 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2446 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2447 Widget_Data *wd = item->wd;
2449 if (item->delete_me) return;
2450 selected = !!selected;
2451 if (item->selected == selected) return;
2457 while (wd->selected)
2458 _item_unselect(wd->selected->data);
2460 _item_highlight(item);
2464 _item_unselect(item);
2468 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2470 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2471 return item->selected;
2475 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2478 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2479 if (item->disabled == disabled) return;
2480 if (item->delete_me) return;
2481 item->disabled = !!disabled;
2485 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2487 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2492 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2494 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2495 if (item->delete_me) return EINA_FALSE;
2496 return item->disabled;
2499 static Evas_Object *
2500 _elm_gengrid_item_label_create(void *data,
2501 Evas_Object *obj __UNUSED__,
2502 Evas_Object *tooltip,
2503 void *item __UNUSED__)
2505 Evas_Object *label = elm_label_add(tooltip);
2508 elm_object_style_set(label, "tooltip");
2509 elm_object_text_set(label, data);
2514 _elm_gengrid_item_label_del_cb(void *data,
2515 Evas_Object *obj __UNUSED__,
2516 void *event_info __UNUSED__)
2518 eina_stringshare_del(data);
2522 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2525 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2526 text = eina_stringshare_add(text);
2527 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2529 _elm_gengrid_item_label_del_cb);
2533 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2534 Elm_Tooltip_Item_Content_Cb func,
2536 Evas_Smart_Cb del_cb)
2538 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2540 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2543 if (item->tooltip.del_cb)
2544 item->tooltip.del_cb((void *)item->tooltip.data,
2545 item->base.widget, item);
2546 item->tooltip.content_cb = func;
2547 item->tooltip.data = data;
2548 item->tooltip.del_cb = del_cb;
2549 if (item->base.view)
2551 elm_widget_item_tooltip_content_cb_set(item,
2552 item->tooltip.content_cb,
2553 item->tooltip.data, NULL);
2554 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2555 elm_widget_item_tooltip_size_restrict_disable(item, item->tooltip.free_size);
2561 if (del_cb) del_cb((void *)data, NULL, NULL);
2565 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2567 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2568 if ((item->base.view) && (item->tooltip.content_cb))
2569 elm_widget_item_tooltip_unset(item);
2571 if (item->tooltip.del_cb)
2572 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2573 item->tooltip.del_cb = NULL;
2574 item->tooltip.content_cb = NULL;
2575 item->tooltip.data = NULL;
2576 item->tooltip.free_size = EINA_FALSE;
2577 if (item->tooltip.style)
2578 elm_gengrid_item_tooltip_style_set(item, NULL);
2582 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2585 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2586 eina_stringshare_replace(&item->tooltip.style, style);
2587 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2591 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2593 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2594 return item->tooltip.style;
2598 elm_gengrid_item_tooltip_size_restrict_disable(Elm_Gengrid_Item *item, Eina_Bool disable)
2600 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2601 item->tooltip.free_size = disable;
2602 if (item->base.view) return elm_widget_item_tooltip_size_restrict_disable(item, disable);
2607 elm_gengrid_item_tooltip_size_restrict_disabled_get(const Elm_Gengrid_Item *item)
2609 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2610 return item->tooltip.free_size;
2614 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2617 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2618 eina_stringshare_replace(&item->mouse_cursor, cursor);
2619 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2623 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2625 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2626 return elm_widget_item_cursor_get(item);
2630 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2632 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2633 if (!item->mouse_cursor)
2636 if (item->base.view)
2637 elm_widget_item_cursor_unset(item);
2639 eina_stringshare_del(item->mouse_cursor);
2640 item->mouse_cursor = NULL;
2644 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2647 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2648 elm_widget_item_cursor_style_set(item, style);
2652 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2654 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2655 return elm_widget_item_cursor_style_get(item);
2659 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2660 Eina_Bool engine_only)
2662 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2663 elm_widget_item_cursor_engine_only_set(item, engine_only);
2667 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2669 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2670 return elm_widget_item_cursor_engine_only_get(item);
2674 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2675 Eina_Bool reorder_mode)
2677 ELM_CHECK_WIDTYPE(obj, widtype);
2678 Widget_Data *wd = elm_widget_data_get(obj);
2680 wd->reorder_mode = reorder_mode;
2684 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2686 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2687 Widget_Data *wd = elm_widget_data_get(obj);
2688 if (!wd) return EINA_FALSE;
2689 return wd->reorder_mode;
2693 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2694 Eina_Bool always_select)
2696 ELM_CHECK_WIDTYPE(obj, widtype);
2697 Widget_Data *wd = elm_widget_data_get(obj);
2699 wd->always_select = always_select;
2703 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2705 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2706 Widget_Data *wd = elm_widget_data_get(obj);
2707 if (!wd) return EINA_FALSE;
2708 return wd->always_select;
2712 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2713 Eina_Bool no_select)
2715 ELM_CHECK_WIDTYPE(obj, widtype);
2716 Widget_Data *wd = elm_widget_data_get(obj);
2718 wd->no_select = no_select;
2722 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2724 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2725 Widget_Data *wd = elm_widget_data_get(obj);
2726 if (!wd) return EINA_FALSE;
2727 return wd->no_select;
2731 elm_gengrid_bounce_set(Evas_Object *obj,
2735 ELM_CHECK_WIDTYPE(obj, widtype);
2736 Widget_Data *wd = elm_widget_data_get(obj);
2738 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2739 wd->h_bounce = h_bounce;
2740 wd->v_bounce = v_bounce;
2744 elm_gengrid_bounce_get(const Evas_Object *obj,
2745 Eina_Bool *h_bounce,
2746 Eina_Bool *v_bounce)
2748 ELM_CHECK_WIDTYPE(obj, widtype);
2749 Widget_Data *wd = elm_widget_data_get(obj);
2751 if (h_bounce) *h_bounce = wd->h_bounce;
2752 if (v_bounce) *v_bounce = wd->v_bounce;
2756 elm_gengrid_page_relative_set(Evas_Object *obj,
2760 Evas_Coord pagesize_h;
2761 Evas_Coord pagesize_v;
2763 ELM_CHECK_WIDTYPE(obj, widtype);
2764 Widget_Data *wd = elm_widget_data_get(obj);
2767 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
2768 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
2773 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2775 ELM_CHECK_WIDTYPE(obj, widtype);
2776 Widget_Data *wd = elm_widget_data_get(obj);
2779 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
2783 elm_gengrid_page_size_set(Evas_Object *obj,
2784 Evas_Coord h_pagesize,
2785 Evas_Coord v_pagesize)
2790 ELM_CHECK_WIDTYPE(obj, widtype);
2791 Widget_Data *wd = elm_widget_data_get(obj);
2793 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
2794 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
2799 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2801 ELM_CHECK_WIDTYPE(obj, widtype);
2802 Widget_Data *wd = elm_widget_data_get(obj);
2805 elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber);
2809 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2811 ELM_CHECK_WIDTYPE(obj, widtype);
2812 Widget_Data *wd = elm_widget_data_get(obj);
2815 elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber);
2819 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2821 ELM_CHECK_WIDTYPE(obj, widtype);
2822 Widget_Data *wd = elm_widget_data_get(obj);
2825 elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber);
2829 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2831 ELM_CHECK_WIDTYPE(obj, widtype);
2832 Widget_Data *wd = elm_widget_data_get(obj);
2835 elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber);
2838 EAPI Elm_Gengrid_Item *
2839 elm_gengrid_first_item_get(const Evas_Object *obj)
2841 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2842 Widget_Data *wd = elm_widget_data_get(obj);
2843 if (!wd) return NULL;
2844 if (!wd->items) return NULL;
2845 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2846 while ((item) && (item->delete_me))
2847 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2851 EAPI Elm_Gengrid_Item *
2852 elm_gengrid_last_item_get(const Evas_Object *obj)
2854 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2855 Widget_Data *wd = elm_widget_data_get(obj);
2856 if (!wd) return NULL;
2857 if (!wd->items) return NULL;
2858 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
2859 while ((item) && (item->delete_me))
2860 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2864 EAPI Elm_Gengrid_Item *
2865 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
2867 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2870 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2871 if ((item) && (!item->delete_me)) break;
2873 return (Elm_Gengrid_Item *)item;
2876 EAPI Elm_Gengrid_Item *
2877 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
2879 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2882 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2883 if ((item) && (!item->delete_me)) break;
2885 return (Elm_Gengrid_Item *)item;
2889 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
2891 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2892 return item->base.widget;
2896 elm_gengrid_item_show(Elm_Gengrid_Item *item)
2898 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2899 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2900 Evas_Coord minx = 0, miny = 0;
2903 if ((!item) || (item->delete_me)) return;
2904 _pan_min_get(wd->pan_smart, &minx, &miny);
2907 elm_smart_scroller_region_bring_in(item->wd->scr,
2908 ((item->x - item->prev_group) * wd->item_width) + (item->prev_group * item->wd->group_item_width) + minx,
2909 item->y * wd->item_height + miny,
2910 item->wd->item_width,
2911 item->wd->item_height);
2913 elm_smart_scroller_region_bring_in(item->wd->scr,
2914 item->x * wd->item_width + minx,
2915 ((item->y - item->prev_group)* wd->item_height) + (item->prev_group * item->wd->group_item_height) + miny,
2916 item->wd->item_width,
2917 item->wd->item_height);
2921 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
2923 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2924 if (item->delete_me) return;
2926 Evas_Coord minx = 0, miny = 0;
2927 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2929 _pan_min_get(wd->pan_smart, &minx, &miny);
2932 elm_smart_scroller_region_bring_in(item->wd->scr,
2933 ((item->x - item->prev_group) * wd->item_width) + (item->prev_group * item->wd->group_item_width) + minx,
2934 item->y * wd->item_height + miny,
2935 item->wd->item_width,
2936 item->wd->item_height);
2938 elm_smart_scroller_region_bring_in(item->wd->scr,
2939 item->x * wd->item_width + minx,
2940 ((item->y - item->prev_group)* wd->item_height) + (item->prev_group * item->wd->group_item_height) + miny,
2941 item->wd->item_width,
2942 item->wd->item_height);