1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 #include "els_scroller.h"
5 #include "elm_gen_common.h"
7 // internally allocated
8 #define CLASS_ALLOCATED 0x3a70f00f
12 * Handle non-homogeneous objects too.
16 #define REORDER_EFFECT_TIME 0.5
18 #define ELM_GEN_SETUP(wd) \
19 (wd)->calc_cb = (Ecore_Cb)_calc_job
21 #define ELM_GEN_ITEM_SETUP(it) \
22 (it)->del_cb = (Ecore_Cb)_item_del; \
23 (it)->highlight_cb = (Ecore_Cb)_item_highlight; \
24 (it)->unsel_cb = (Ecore_Cb)_item_unselect; \
25 (it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
27 struct Elm_Gen_Item_Type
30 Ecore_Animator *item_reorder_move_animator;
31 Evas_Coord gx, gy, ox, oy, tx, ty, rx, ry;
32 unsigned int moving_effect_start_time;
35 Eina_Bool group_realized : 1;
39 static const char *widtype = NULL;
40 static void _item_highlight(Elm_Gen_Item *it);
41 static void _item_unrealize_cb(Elm_Gen_Item *it);
42 static void _item_unselect(Elm_Gen_Item *it);
43 static void _calc_job(void *data);
44 static void _on_focus_hook(void *data,
46 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
47 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
48 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
49 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
50 static Eina_Bool _item_single_select_up(Widget_Data *wd);
51 static Eina_Bool _item_single_select_down(Widget_Data *wd);
52 static Eina_Bool _item_single_select_left(Widget_Data *wd);
53 static Eina_Bool _item_single_select_right(Widget_Data *wd);
54 static Eina_Bool _event_hook(Evas_Object *obj,
56 Evas_Callback_Type type,
58 static Eina_Bool _deselect_all_items(Widget_Data *wd);
60 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
61 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
63 static const char SIG_ACTIVATED[] = "activated";
64 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
65 static const char SIG_LONGPRESSED[] = "longpressed";
66 static const char SIG_SELECTED[] = "selected";
67 static const char SIG_UNSELECTED[] = "unselected";
68 static const char SIG_REALIZED[] = "realized";
69 static const char SIG_UNREALIZED[] = "unrealized";
70 static const char SIG_CHANGED[] = "changed";
71 static const char SIG_DRAG_START_UP[] = "drag,start,up";
72 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
73 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
74 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
75 static const char SIG_DRAG_STOP[] = "drag,stop";
76 static const char SIG_DRAG[] = "drag";
77 static const char SIG_SCROLL[] = "scroll";
78 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
79 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
80 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
81 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
82 static const char SIG_EDGE_TOP[] = "edge,top";
83 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
84 static const char SIG_EDGE_LEFT[] = "edge,left";
85 static const char SIG_EDGE_RIGHT[] = "edge,right";
86 static const char SIG_MOVED[] = "moved";
87 static const char SIG_INDEX_UPDATE[] = "index,update";
89 static const Evas_Smart_Cb_Description _signals[] = {
91 {SIG_CLICKED_DOUBLE, ""},
92 {SIG_LONGPRESSED, ""},
98 {SIG_DRAG_START_UP, ""},
99 {SIG_DRAG_START_DOWN, ""},
100 {SIG_DRAG_START_LEFT, ""},
101 {SIG_DRAG_START_RIGHT, ""},
105 {SIG_SCROLL_ANIM_START, ""},
106 {SIG_SCROLL_ANIM_STOP, ""},
107 {SIG_SCROLL_DRAG_START, ""},
108 {SIG_SCROLL_DRAG_STOP, ""},
110 {SIG_EDGE_BOTTOM, ""},
112 {SIG_EDGE_RIGHT, ""},
118 _event_hook(Evas_Object *obj,
119 Evas_Object *src __UNUSED__,
120 Evas_Callback_Type type,
123 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
124 Evas_Event_Key_Down *ev = event_info;
125 Widget_Data *wd = elm_widget_data_get(obj);
126 if (!wd) return EINA_FALSE;
127 if (!wd->items) return EINA_FALSE;
128 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
129 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
131 Elm_Object_Item *it = NULL;
134 Evas_Coord step_x = 0;
135 Evas_Coord step_y = 0;
138 Evas_Coord page_x = 0;
139 Evas_Coord page_y = 0;
141 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
142 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
143 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
144 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
146 if ((!strcmp(ev->keyname, "Left")) ||
147 ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string)))
149 if ((wd->horizontal) &&
150 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
151 (_item_multi_select_up(wd)))
152 || (_item_single_select_up(wd))))
154 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
157 else if ((!wd->horizontal) &&
158 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
159 (_item_multi_select_left(wd)))
160 || (_item_single_select_left(wd))))
162 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
168 else if ((!strcmp(ev->keyname, "Right")) ||
169 ((!strcmp(ev->keyname, "KP_Right")) && (!ev->string)))
171 if ((wd->horizontal) &&
172 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
173 (_item_multi_select_down(wd)))
174 || (_item_single_select_down(wd))))
176 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
179 else if ((!wd->horizontal) &&
180 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
181 (_item_multi_select_right(wd)))
182 || (_item_single_select_right(wd))))
184 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
190 else if ((!strcmp(ev->keyname, "Up")) ||
191 ((!strcmp(ev->keyname, "KP_Up")) && (!ev->string)))
193 if ((wd->horizontal) &&
194 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
195 (_item_multi_select_left(wd)))
196 || (_item_single_select_left(wd))))
198 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
201 else if ((!wd->horizontal) &&
202 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
203 (_item_multi_select_up(wd)))
204 || (_item_single_select_up(wd))))
206 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
212 else if ((!strcmp(ev->keyname, "Down")) ||
213 ((!strcmp(ev->keyname, "KP_Down")) && (!ev->string)))
215 if ((wd->horizontal) &&
216 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
217 (_item_multi_select_right(wd)))
218 || (_item_single_select_right(wd))))
220 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
223 else if ((!wd->horizontal) &&
224 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
225 (_item_multi_select_down(wd)))
226 || (_item_single_select_down(wd))))
228 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
234 else if ((!strcmp(ev->keyname, "Home")) ||
235 ((!strcmp(ev->keyname, "KP_Home")) && (!ev->string)))
237 it = elm_gengrid_first_item_get(obj);
238 elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN);
239 elm_gengrid_item_selected_set(it, EINA_TRUE);
240 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
243 else if ((!strcmp(ev->keyname, "End")) ||
244 ((!strcmp(ev->keyname, "KP_End")) && (!ev->string)))
246 it = elm_gengrid_last_item_get(obj);
247 elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN);
248 elm_gengrid_item_selected_set(it, EINA_TRUE);
249 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
252 else if ((!strcmp(ev->keyname, "Prior")) ||
253 ((!strcmp(ev->keyname, "KP_Prior")) && (!ev->string)))
258 x -= -(page_x * v_w) / 100;
265 y -= -(page_y * v_h) / 100;
270 else if ((!strcmp(ev->keyname, "Next")) ||
271 ((!strcmp(ev->keyname, "KP_Next")) && (!ev->string)))
276 x += -(page_x * v_w) / 100;
283 y += -(page_y * v_h) / 100;
288 else if (!strcmp(ev->keyname, "Escape"))
290 if (!_deselect_all_items(wd)) return EINA_FALSE;
291 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
294 else if (((!strcmp(ev->keyname, "Return")) ||
295 (!strcmp(ev->keyname, "KP_Enter")) ||
296 (!strcmp(ev->keyname, "space")))
297 && (!wd->multi) && (wd->selected))
299 it = elm_gengrid_selected_item_get(obj);
300 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
302 else return EINA_FALSE;
304 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
305 elm_smart_scroller_child_pos_set(wd->scr, x, y);
310 _deselect_all_items(Widget_Data *wd)
312 if (!wd->selected) return EINA_FALSE;
314 elm_gengrid_item_selected_set((Elm_Object_Item *) wd->selected->data,
321 _item_multi_select_left(Widget_Data *wd)
323 if (!wd->selected) return EINA_FALSE;
325 Elm_Object_Item *prev =
326 elm_gengrid_item_prev_get(wd->last_selected_item);
327 if (!prev) return EINA_TRUE;
328 if (elm_gengrid_item_selected_get(prev))
330 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
331 wd->last_selected_item = prev;
332 elm_gengrid_item_show(wd->last_selected_item, ELM_GENGRID_ITEM_SCROLLTO_IN);
336 elm_gengrid_item_selected_set(prev, EINA_TRUE);
337 elm_gengrid_item_show(prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
344 _item_multi_select_right(Widget_Data *wd)
346 if (!wd->selected) return EINA_FALSE;
348 Elm_Object_Item *next =
349 elm_gengrid_item_next_get(wd->last_selected_item);
350 if (!next) return EINA_TRUE;
351 if (elm_gengrid_item_selected_get(next))
353 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
354 wd->last_selected_item = next;
355 elm_gengrid_item_show(wd->last_selected_item, ELM_GENGRID_ITEM_SCROLLTO_IN);
359 elm_gengrid_item_selected_set(next, EINA_TRUE);
360 elm_gengrid_item_show(next, ELM_GENGRID_ITEM_SCROLLTO_IN);
367 _item_multi_select_up(Widget_Data *wd)
370 Eina_Bool r = EINA_TRUE;
372 if (!wd->selected) return EINA_FALSE;
374 for (i = 0; (r) && (i < wd->nmax); i++)
375 r &= _item_multi_select_left(wd);
381 _item_multi_select_down(Widget_Data *wd)
384 Eina_Bool r = EINA_TRUE;
386 if (!wd->selected) return EINA_FALSE;
388 for (i = 0; (r) && (i < wd->nmax); i++)
389 r &= _item_multi_select_right(wd);
395 _item_single_select_up(Widget_Data *wd)
403 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
404 while ((prev) && (prev->generation < wd->generation))
405 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
406 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
407 elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
411 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
413 if (!prev) return EINA_FALSE;
415 for (i = 1; i < wd->nmax; i++)
417 Elm_Object_Item *tmp =
418 elm_gengrid_item_prev_get((Elm_Object_Item *) prev);
419 if (!tmp) return EINA_FALSE;
420 prev = (Elm_Gen_Item *) tmp;
423 _deselect_all_items(wd);
425 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
426 elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
431 _item_single_select_down(Widget_Data *wd)
439 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
440 while ((next) && (next->generation < wd->generation))
441 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
442 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
443 elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN);
447 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
449 if (!next) return EINA_FALSE;
451 for (i = 1; i < wd->nmax; i++)
453 Elm_Object_Item *tmp =
454 elm_gengrid_item_next_get((Elm_Object_Item *) next);
455 if (!tmp) return EINA_FALSE;
456 next = (Elm_Gen_Item *) tmp;
459 _deselect_all_items(wd);
461 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
462 elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN);
467 _item_single_select_left(Widget_Data *wd)
472 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
473 while ((prev) && (prev->generation < wd->generation))
474 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
477 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
479 if (!prev) return EINA_FALSE;
481 _deselect_all_items(wd);
483 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
484 elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
489 _item_single_select_right(Widget_Data *wd)
494 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
495 while ((next) && (next->generation < wd->generation))
496 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
499 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
501 if (!next) return EINA_FALSE;
503 _deselect_all_items(wd);
505 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
506 elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN);
511 _on_focus_hook(void *data __UNUSED__,
514 Widget_Data *wd = elm_widget_data_get(obj);
516 if (elm_widget_focus_get(obj))
518 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
519 evas_object_focus_set(wd->obj, EINA_TRUE);
520 if ((wd->selected) && (!wd->last_selected_item))
521 wd->last_selected_item = eina_list_data_get(wd->selected);
525 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
526 evas_object_focus_set(wd->obj, EINA_FALSE);
531 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
533 Widget_Data *wd = elm_widget_data_get(obj);
536 elm_smart_scroller_mirrored_set(wd->scr, rtl);
537 if (!wd->items) return;
538 it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
542 edje_object_mirrored_set(VIEW(it), rtl);
543 elm_gengrid_item_update((Elm_Object_Item *)it);
544 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
549 _theme_hook(Evas_Object *obj)
551 Widget_Data *wd = elm_widget_data_get(obj);
553 _elm_widget_mirrored_reload(obj);
554 _mirrored_set(obj, elm_widget_mirrored_get(obj));
555 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
556 elm_widget_style_get(obj));
560 _del_pre_hook(Evas_Object *obj)
562 Widget_Data *wd = elm_widget_data_get(obj);
564 elm_gengrid_clear(obj);
565 evas_object_del(wd->pan_smart);
566 wd->pan_smart = NULL;
570 _del_hook(Evas_Object *obj)
572 Widget_Data *wd = elm_widget_data_get(obj);
573 if (wd->calc_job) ecore_job_del(wd->calc_job);
578 _signal_emit_hook(Evas_Object *obj,
579 const char *emission,
582 Widget_Data *wd = elm_widget_data_get(obj);
584 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
589 _signal_callback_add_hook(Evas_Object *obj,
590 const char *emission,
592 Edje_Signal_Cb func_cb,
595 Widget_Data *wd = elm_widget_data_get(obj);
597 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
598 emission, source, func_cb, data);
602 _signal_callback_del_hook(Evas_Object *obj,
603 const char *emission,
605 Edje_Signal_Cb func_cb,
608 Widget_Data *wd = elm_widget_data_get(obj);
610 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scr),
611 emission, source, func_cb, data);
615 _mouse_move(void *data,
616 Evas *evas __UNUSED__,
620 Elm_Gen_Item *it = data;
621 Evas_Event_Mouse_Move *ev = event_info;
622 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
623 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
625 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
627 if (!it->wd->on_hold)
629 it->wd->on_hold = EINA_TRUE;
630 if (!it->wd->wasselected)
634 if ((it->dragging) && (it->down))
638 ecore_timer_del(it->long_timer);
639 it->long_timer = NULL;
641 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
644 if ((!it->down) || (it->wd->longpressed))
648 ecore_timer_del(it->long_timer);
649 it->long_timer = NULL;
651 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
653 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
655 it_scrl_x = ev->cur.canvas.x - it->wd->reorder_it->dx;
656 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
658 if (it_scrl_x < ox) it->wd->reorder_item_x = ox;
659 else if (it_scrl_x + it->wd->item_width > ox + ow)
660 it->wd->reorder_item_x = ox + ow - it->wd->item_width;
661 else it->wd->reorder_item_x = it_scrl_x;
663 if (it_scrl_y < oy) it->wd->reorder_item_y = oy;
664 else if (it_scrl_y + it->wd->item_height > oy + oh)
665 it->wd->reorder_item_y = oy + oh - it->wd->item_height;
666 else it->wd->reorder_item_y = it_scrl_y;
668 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
669 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
673 if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
674 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
675 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
676 x = ev->cur.canvas.x - x;
677 y = ev->cur.canvas.y - y;
680 if (adx < 0) adx = -dx;
683 if (ady < 0) ady = -dy;
686 if ((adx > minw) || (ady > minh))
688 const char *left_drag, *right_drag;
689 if (!elm_widget_mirrored_get(WIDGET(it)))
691 left_drag = SIG_DRAG_START_LEFT;
692 right_drag = SIG_DRAG_START_RIGHT;
696 left_drag = SIG_DRAG_START_RIGHT;
697 right_drag = SIG_DRAG_START_LEFT;
703 ecore_timer_del(it->long_timer);
704 it->long_timer = NULL;
706 if (!it->wd->wasselected)
711 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_START_UP,
716 evas_object_smart_callback_call(WIDGET(it),
723 evas_object_smart_callback_call(WIDGET(it),
724 SIG_DRAG_START_DOWN, it);
728 evas_object_smart_callback_call(WIDGET(it),
731 evas_object_smart_callback_call(WIDGET(it),
739 _long_press(void *data)
741 Elm_Gen_Item *it = data;
743 it->long_timer = NULL;
744 if (elm_widget_item_disabled_get(it)|| (it->dragging))
745 return ECORE_CALLBACK_CANCEL;
746 it->wd->longpressed = EINA_TRUE;
747 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
748 if (it->wd->reorder_mode)
750 it->wd->reorder_it = it;
751 evas_object_raise(VIEW(it));
752 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
753 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
754 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
756 return ECORE_CALLBACK_CANCEL;
760 _mouse_down(void *data,
761 Evas *evas __UNUSED__,
765 Elm_Gen_Item *it = data;
766 Evas_Event_Mouse_Down *ev = event_info;
769 if (ev->button != 1) return;
772 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
773 it->dx = ev->canvas.x - x;
774 it->dy = ev->canvas.y - y;
775 it->wd->longpressed = EINA_FALSE;
776 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
777 else it->wd->on_hold = EINA_FALSE;
778 if (it->wd->on_hold) return;
779 it->wd->wasselected = it->selected;
781 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
783 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
784 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
786 if (it->long_timer) ecore_timer_del(it->long_timer);
788 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
791 it->long_timer = NULL;
795 _mouse_up(void *data,
796 Evas *evas __UNUSED__,
797 Evas_Object *obj __UNUSED__,
800 Elm_Gen_Item *it = data;
801 Evas_Event_Mouse_Up *ev = event_info;
802 Eina_Bool dragged = EINA_FALSE;
804 if (ev->button != 1) return;
805 it->down = EINA_FALSE;
806 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
807 else it->wd->on_hold = EINA_FALSE;
810 ecore_timer_del(it->long_timer);
811 it->long_timer = NULL;
815 it->dragging = EINA_FALSE;
816 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
821 it->wd->longpressed = EINA_FALSE;
822 it->wd->on_hold = EINA_FALSE;
825 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
827 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it->wd->reorder_it);
828 it->wd->reorder_it = NULL;
829 it->wd->move_effect_enabled = EINA_FALSE;
830 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
831 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
833 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
834 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
835 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
837 if (it->wd->longpressed)
839 it->wd->longpressed = EINA_FALSE;
840 if (!it->wd->wasselected) _item_unselect(it);
841 it->wd->wasselected = EINA_FALSE;
846 if (it->want_unrealize)
847 _elm_genlist_item_unrealize(it, EINA_FALSE);
849 if (elm_widget_item_disabled_get(it) || (dragged)) return;
857 else _item_unselect(it);
863 while (it->wd->selected)
864 _item_unselect(it->wd->selected->data);
868 const Eina_List *l, *l_next;
871 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, item2)
872 if (item2 != it) _item_unselect(item2);
880 _item_highlight(Elm_Gen_Item *it)
882 if ((it->wd->select_mode == ELM_OBJECT_SELECT_MODE_NONE) ||
883 (!it->wd->highlight) || (it->highlighted) ||
884 (it->generation < it->wd->generation)) return;
885 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
886 it->highlighted = EINA_TRUE;
890 _elm_gengrid_item_index_update(Elm_Gen_Item *it)
892 if (it->position_update)
894 evas_object_smart_callback_call(WIDGET(it), SIG_INDEX_UPDATE, it);
895 it->position_update = EINA_FALSE;
900 _item_realize(Elm_Gen_Item *it)
905 if ((it->realized) || (it->generation < it->wd->generation)) return;
906 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
907 edje_object_scale_set(VIEW(it), elm_widget_scale_get(WIDGET(it)) *
909 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
910 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
911 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
912 snprintf(style, sizeof(style), "item/%s",
913 it->itc->item_style ? it->itc->item_style : "default");
914 _elm_theme_object_set(WIDGET(it), VIEW(it), "gengrid", style,
915 elm_widget_style_get(WIDGET(it)));
917 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
918 evas_object_color_set(it->spacer, 0, 0, 0, 0);
919 elm_widget_sub_object_add(WIDGET(it), it->spacer);
920 evas_object_size_hint_min_set(it->spacer, 2 * _elm_config->scale, 1);
921 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
923 if (it->itc->func.text_get)
929 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
931 EINA_LIST_FOREACH(it->texts, l, key)
933 char *s = it->itc->func.text_get
934 ((void *)it->base.data, WIDGET(it), key);
937 edje_object_part_text_set(VIEW(it), key, s);
943 if (it->itc->func.content_get)
947 Evas_Object *ic = NULL;
950 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
952 EINA_LIST_FOREACH(it->contents, l, key)
954 if (it->itc->func.content_get)
955 ic = it->itc->func.content_get
956 ((void *)it->base.data, WIDGET(it), key);
959 it->content_objs = eina_list_append(it->content_objs, ic);
960 edje_object_part_swallow(VIEW(it), key, ic);
961 evas_object_show(ic);
962 elm_widget_sub_object_add(WIDGET(it), ic);
967 if (it->itc->func.state_get)
973 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
975 EINA_LIST_FOREACH(it->states, l, key)
977 Eina_Bool on = it->itc->func.state_get
978 ((void *)it->base.data, WIDGET(it), l->data);
981 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
982 edje_object_signal_emit(VIEW(it), buf, "elm");
989 if ((!it->wd->group_item_width) && (!it->wd->group_item_height))
991 edje_object_size_min_restricted_calc(VIEW(it),
992 &it->wd->group_item_width,
993 &it->wd->group_item_height,
994 it->wd->group_item_width,
995 it->wd->group_item_height);
1000 if ((!it->wd->item_width) && (!it->wd->item_height))
1002 edje_object_size_min_restricted_calc(VIEW(it),
1003 &it->wd->item_width,
1004 &it->wd->item_height,
1006 it->wd->item_height);
1007 elm_coords_finger_size_adjust(1, &it->wd->item_width,
1008 1, &it->wd->item_height);
1011 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1013 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1015 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1018 _elm_gengrid_item_index_update(it);
1021 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1022 if (elm_widget_item_disabled_get(it))
1023 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1025 evas_object_show(VIEW(it));
1027 if (it->tooltip.content_cb)
1029 elm_widget_item_tooltip_content_cb_set(it,
1030 it->tooltip.content_cb,
1031 it->tooltip.data, NULL);
1032 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1033 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
1036 if (it->mouse_cursor)
1037 elm_widget_item_cursor_set(it, it->mouse_cursor);
1039 it->realized = EINA_TRUE;
1040 it->want_unrealize = EINA_FALSE;
1044 _item_unrealize_cb(Elm_Gen_Item *it)
1046 evas_object_del(VIEW(it));
1048 evas_object_del(it->spacer);
1053 _reorder_item_move_animator_cb(void *data)
1055 Elm_Gen_Item *it = data;
1059 tt = REORDER_EFFECT_TIME;
1060 t = ((0.0 > (t = ecore_loop_time_get()-it->item->moving_effect_start_time)) ? 0.0 : t);
1061 dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
1062 dy = ((it->item->ty - it->item->oy) / 10) * _elm_config->scale;
1066 it->item->rx += (1 * sin((t / tt) * (M_PI / 2)) * dx);
1067 it->item->ry += (1 * sin((t / tt) * (M_PI / 2)) * dy);
1075 if ((((dx > 0) && (it->item->rx >= it->item->tx)) || ((dx <= 0) && (it->item->rx <= it->item->tx))) &&
1076 (((dy > 0) && (it->item->ry >= it->item->ty)) || ((dy <= 0) && (it->item->ry <= it->item->ty))))
1078 evas_object_move(VIEW(it), it->item->tx, it->item->ty);
1082 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1083 if (it->wd->horizontal)
1084 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1086 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1089 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1090 it->item->moving = EINA_FALSE;
1091 it->item->item_reorder_move_animator = NULL;
1092 return ECORE_CALLBACK_CANCEL;
1095 evas_object_move(VIEW(it), it->item->rx, it->item->ry);
1099 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1100 if (it->wd->horizontal)
1101 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1103 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1106 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1108 return ECORE_CALLBACK_RENEW;
1112 _group_item_place(Pan *sd)
1114 Evas_Coord iw, ih, vw, vh;
1116 Eina_Bool was_realized;
1118 evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1119 if (sd->wd->horizontal)
1121 iw = sd->wd->group_item_width;
1127 ih = sd->wd->group_item_height;
1129 EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1131 was_realized = it->realized;
1132 if (it->item->group_realized)
1136 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1137 evas_object_move(VIEW(it), it->item->gx, it->item->gy);
1138 evas_object_resize(VIEW(it), iw, ih);
1139 evas_object_raise(VIEW(it));
1142 _elm_genlist_item_unrealize(it, EINA_FALSE);
1148 _item_place(Elm_Gen_Item *it,
1152 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1153 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1154 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1158 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &vw, &vh);
1160 /* Preload rows/columns at each side of the Gengrid */
1161 cvx = ox - PRELOAD * it->wd->item_width;
1162 cvy = oy - PRELOAD * it->wd->item_height;
1163 cvw = vw + 2 * PRELOAD * it->wd->item_width;
1164 cvh = vh + 2 * PRELOAD * it->wd->item_height;
1169 items_count = it->wd->item_count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
1170 if (it->wd->horizontal)
1172 int columns, items_visible = 0, items_row;
1174 if (it->wd->item_height > 0)
1175 items_visible = vh / it->wd->item_height;
1176 if (items_visible < 1)
1179 columns = items_count / items_visible;
1180 if (items_count % items_visible)
1183 tcw = (it->wd->item_width * columns) + (it->wd->group_item_width * eina_list_count(it->wd->group_items));
1184 alignw = (vw - tcw) * it->wd->align_x;
1186 items_row = items_visible;
1187 if ((unsigned int)items_row > it->wd->item_count)
1188 items_row = it->wd->item_count;
1190 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1191 tch = it->wd->nmax * it->wd->item_height;
1193 tch = items_row * it->wd->item_height;
1194 alignh = (vh - tch) * it->wd->align_y;
1198 unsigned int rows, items_visible = 0, items_col;
1200 if (it->wd->item_width > 0)
1201 items_visible = vw / it->wd->item_width;
1202 if (items_visible < 1)
1205 rows = items_count / items_visible;
1206 if (items_count % items_visible)
1209 tch = (it->wd->item_height * rows) + (it->wd->group_item_height * eina_list_count(it->wd->group_items));
1210 alignh = (vh - tch) * it->wd->align_y;
1212 items_col = items_visible;
1213 if (items_col > it->wd->item_count)
1214 items_col = it->wd->item_count;
1216 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1217 tcw = it->wd->nmax * it->wd->item_width;
1219 tcw = items_col * it->wd->item_width;
1220 alignw = (vw - tcw) * it->wd->align_x;
1225 if (it->wd->horizontal)
1227 x = (((cx - it->item->prev_group) * it->wd->item_width) + (it->item->prev_group * it->wd->group_item_width)) - it->wd->pan_x + ox + alignw;
1229 iw = it->wd->group_item_width;
1235 y = (((cy - it->item->prev_group) * it->wd->item_height) + (it->item->prev_group * it->wd->group_item_height)) - it->wd->pan_y + oy + alignh;
1237 ih = it->wd->group_item_height;
1244 if (it->wd->horizontal)
1246 x = (((cx - it->item->prev_group) * it->wd->item_width) + (it->item->prev_group * it->wd->group_item_width)) - it->wd->pan_x + ox + alignw;
1247 y = (cy * it->wd->item_height) - it->wd->pan_y + oy + alignh;
1251 x = (cx * it->wd->item_width) - it->wd->pan_x + ox + alignw;
1252 y = (((cy - it->item->prev_group) * it->wd->item_height) + (it->item->prev_group * it->wd->group_item_height)) - it->wd->pan_y + oy + alignh;
1254 if (elm_widget_mirrored_get(WIDGET(it)))
1255 { /* Switch items side and componsate for pan_x when in RTL mode */
1256 evas_object_geometry_get(WIDGET(it), NULL, NULL, &ww, NULL);
1257 x = ww - x - it->wd->item_width - it->wd->pan_x - it->wd->pan_x;
1259 iw = it->wd->item_width;
1260 ih = it->wd->item_height;
1263 Eina_Bool was_realized = it->realized;
1264 if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1268 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1271 if (it->wd->horizontal)
1273 if (it->parent->item->gx < ox)
1275 it->parent->item->gx = x + it->wd->item_width - it->wd->group_item_width;
1276 if (it->parent->item->gx > ox)
1277 it->parent->item->gx = ox;
1279 it->parent->item->group_realized = EINA_TRUE;
1283 if (it->parent->item->gy < oy)
1285 it->parent->item->gy = y + it->wd->item_height - it->wd->group_item_height;
1286 if (it->parent->item->gy > oy)
1287 it->parent->item->gy = oy;
1289 it->parent->item->group_realized = EINA_TRUE;
1292 if (it->wd->reorder_mode)
1294 if (it->wd->reorder_it)
1296 if (it->item->moving) return;
1298 if (!it->wd->move_effect_enabled)
1303 if (it->wd->reorder_it == it)
1305 evas_object_move(VIEW(it),
1306 it->wd->reorder_item_x, it->wd->reorder_item_y);
1307 evas_object_resize(VIEW(it), iw, ih);
1312 if (it->wd->move_effect_enabled)
1314 if ((it->item->ox != x) || (it->item->oy != y))
1316 if (((it->wd->old_pan_x == it->wd->pan_x) && (it->wd->old_pan_y == it->wd->pan_y)) ||
1317 ((it->wd->old_pan_x != it->wd->pan_x) && !(it->item->ox - it->wd->pan_x + it->wd->old_pan_x == x)) ||
1318 ((it->wd->old_pan_y != it->wd->pan_y) && !(it->item->oy - it->wd->pan_y + it->wd->old_pan_y == y)))
1322 it->item->rx = it->item->ox;
1323 it->item->ry = it->item->oy;
1324 it->item->moving = EINA_TRUE;
1325 it->item->moving_effect_start_time = ecore_loop_time_get();
1326 it->item->item_reorder_move_animator = ecore_animator_add(_reorder_item_move_animator_cb, it);
1333 Evas_Coord nx, ny, nw, nh;
1336 if (it->wd->horizontal)
1338 nx = x + (it->wd->group_item_width / 2);
1346 ny = y + (it->wd->group_item_height / 2);
1353 nx = x + (it->wd->item_width / 2);
1354 ny = y + (it->wd->item_height / 2);
1359 if ( ELM_RECTS_INTERSECT(it->wd->reorder_item_x, it->wd->reorder_item_y,
1360 it->wd->item_width, it->wd->item_height,
1363 if (it->wd->horizontal)
1365 if ((it->wd->nmax * it->wd->reorder_it->x + it->wd->reorder_it->y) >
1366 (it->wd->nmax * it->x + it->y))
1367 reorder_item_move_forward = EINA_TRUE;
1371 if ((it->wd->nmax * it->wd->reorder_it->y + it->wd->reorder_it->x) >
1372 (it->wd->nmax * it->y + it->x))
1373 reorder_item_move_forward = EINA_TRUE;
1376 it->wd->items = eina_inlist_remove(it->wd->items,
1377 EINA_INLIST_GET(it->wd->reorder_it));
1378 if (reorder_item_move_forward)
1379 it->wd->items = eina_inlist_prepend_relative(it->wd->items,
1380 EINA_INLIST_GET(it->wd->reorder_it),
1381 EINA_INLIST_GET(it));
1383 it->wd->items = eina_inlist_append_relative(it->wd->items,
1384 EINA_INLIST_GET(it->wd->reorder_it),
1385 EINA_INLIST_GET(it));
1387 it->wd->reorder_item_changed = EINA_TRUE;
1388 it->wd->move_effect_enabled = EINA_TRUE;
1389 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1390 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1396 else if (it->item->item_reorder_move_animator)
1398 ecore_animator_del(it->item->item_reorder_move_animator);
1399 it->item->item_reorder_move_animator = NULL;
1400 it->item->moving = EINA_FALSE;
1405 evas_object_move(VIEW(it), x, y);
1406 evas_object_resize(VIEW(it), iw, ih);
1409 it->item->group_realized = EINA_TRUE;
1414 _elm_genlist_item_unrealize(it, EINA_FALSE);
1416 it->item->group_realized = EINA_FALSE;
1421 _item_position_update(Eina_Inlist *list, int idx)
1425 EINA_INLIST_FOREACH(list, it)
1427 it->position = idx++;
1428 it->position_update = EINA_TRUE;
1433 _item_del(Elm_Gen_Item *it)
1435 Evas_Object *obj = WIDGET(it);
1437 evas_event_freeze(evas_object_evas_get(obj));
1438 it->wd->selected = eina_list_remove(it->wd->selected, it);
1439 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
1440 _elm_genlist_item_del_serious(it);
1441 elm_gengrid_item_class_unref((Elm_Gengrid_Item_Class *)it->itc);
1442 evas_event_thaw(evas_object_evas_get(obj));
1443 evas_event_thaw_eval(evas_object_evas_get(obj));
1447 _item_unselect(Elm_Gen_Item *it)
1449 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
1450 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
1451 it->highlighted = EINA_FALSE;
1454 it->selected = EINA_FALSE;
1455 it->wd->selected = eina_list_remove(it->wd->selected, it);
1456 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
1461 _calc_job(void *data)
1463 Widget_Data *wd = data;
1464 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1465 Elm_Gen_Item *it, *group_item = NULL;
1466 int count_group = 0;
1470 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1471 if ((cvw != 0) || (cvh != 0))
1473 if ((wd->horizontal) && (wd->item_height > 0))
1474 nmax = cvh / wd->item_height;
1475 else if (wd->item_width > 0)
1476 nmax = cvw / wd->item_width;
1481 EINA_INLIST_FOREACH(wd->items, it)
1483 if (it->item->prev_group != count_group)
1484 it->item->prev_group = count_group;
1487 count = count % nmax;
1489 wd->items_lost += nmax - count;
1490 //printf("%d items and I lost %d\n", count, wd->items_lost);
1492 if (count) count = 0;
1497 if (it->parent != group_item)
1498 it->parent = group_item;
1502 count = wd->item_count + wd->items_lost - count_group;
1505 minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width);
1506 minh = nmax * wd->item_height;
1510 minw = nmax * wd->item_width;
1511 minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1514 if ((minw != wd->minw) || (minh != wd->minh))
1518 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1522 evas_object_smart_changed(wd->pan_smart);
1524 wd->calc_job = NULL;
1528 _pan_add(Evas_Object *obj)
1531 Evas_Object_Smart_Clipped_Data *cd;
1534 cd = evas_object_smart_data_get(obj);
1537 sd->__clipped_data = *cd;
1539 evas_object_smart_data_set(obj, sd);
1543 _pan_del(Evas_Object *obj)
1545 Pan *sd = evas_object_smart_data_get(obj);
1552 _pan_set(Evas_Object *obj,
1556 Pan *sd = evas_object_smart_data_get(obj);
1557 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1560 evas_object_smart_changed(obj);
1564 _pan_get(Evas_Object *obj,
1568 Pan *sd = evas_object_smart_data_get(obj);
1569 if (x) *x = sd->wd->pan_x;
1570 if (y) *y = sd->wd->pan_y;
1574 _pan_child_size_get(Evas_Object *obj,
1578 Pan *sd = evas_object_smart_data_get(obj);
1579 if (w) *w = sd->wd->minw;
1580 if (h) *h = sd->wd->minh;
1584 _pan_max_get(Evas_Object *obj,
1588 Pan *sd = evas_object_smart_data_get(obj);
1592 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1594 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1596 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1600 _pan_min_get(Evas_Object *obj,
1604 Pan *sd = evas_object_smart_data_get(obj);
1605 Evas_Coord mx = 0, my = 0;
1608 _pan_max_get(obj, &mx, &my);
1610 *x = -mx * sd->wd->align_x;
1612 *y = -my * sd->wd->align_y;
1616 _pan_resize(Evas_Object *obj,
1620 Pan *sd = evas_object_smart_data_get(obj);
1623 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1624 if ((ow == w) && (oh == h)) return;
1625 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1626 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1630 _pan_calculate(Evas_Object *obj)
1632 Pan *sd = evas_object_smart_data_get(obj);
1633 Evas_Coord cx = 0, cy = 0;
1637 if (!sd->wd->nmax) return;
1639 sd->wd->reorder_item_changed = EINA_FALSE;
1641 EINA_INLIST_FOREACH(sd->wd->items, it)
1645 if (sd->wd->horizontal)
1662 _item_place(it, cx, cy);
1663 if (sd->wd->reorder_item_changed) return;
1666 if (sd->wd->horizontal)
1679 if (sd->wd->horizontal)
1681 cy = (cy + 1) % sd->wd->nmax;
1686 cx = (cx + 1) % sd->wd->nmax;
1691 _group_item_place(sd);
1694 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
1696 if (!sd->wd->reorder_item_changed)
1698 sd->wd->old_pan_x = sd->wd->pan_x;
1699 sd->wd->old_pan_y = sd->wd->pan_y;
1701 sd->wd->move_effect_enabled = EINA_FALSE;
1703 evas_object_smart_callback_call(sd->wd->obj, SIG_CHANGED, NULL);
1707 _pan_move(Evas_Object *obj,
1708 Evas_Coord x __UNUSED__,
1709 Evas_Coord y __UNUSED__)
1711 Pan *sd = evas_object_smart_data_get(obj);
1713 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1714 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1718 _hold_on(void *data __UNUSED__,
1720 void *event_info __UNUSED__)
1722 Widget_Data *wd = elm_widget_data_get(obj);
1724 elm_smart_scroller_hold_set(wd->scr, 1);
1728 _hold_off(void *data __UNUSED__,
1730 void *event_info __UNUSED__)
1732 Widget_Data *wd = elm_widget_data_get(obj);
1734 elm_smart_scroller_hold_set(wd->scr, 0);
1738 _freeze_on(void *data __UNUSED__,
1740 void *event_info __UNUSED__)
1742 Widget_Data *wd = elm_widget_data_get(obj);
1744 elm_smart_scroller_freeze_set(wd->scr, 1);
1748 _freeze_off(void *data __UNUSED__,
1750 void *event_info __UNUSED__)
1752 Widget_Data *wd = elm_widget_data_get(obj);
1754 elm_smart_scroller_freeze_set(wd->scr, 0);
1758 _scr_anim_start(void *data,
1759 Evas_Object *obj __UNUSED__,
1760 void *event_info __UNUSED__)
1762 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1766 _scr_anim_stop(void *data,
1767 Evas_Object *obj __UNUSED__,
1768 void *event_info __UNUSED__)
1770 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1774 _scr_drag_start(void *data,
1775 Evas_Object *obj __UNUSED__,
1776 void *event_info __UNUSED__)
1778 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1782 _scr_drag_stop(void *data,
1783 Evas_Object *obj __UNUSED__,
1784 void *event_info __UNUSED__)
1786 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1790 _edge_left(void *data,
1791 Evas_Object *scr __UNUSED__,
1792 void *event_info __UNUSED__)
1794 evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
1798 _edge_right(void *data,
1799 Evas_Object *scr __UNUSED__,
1800 void *event_info __UNUSED__)
1802 evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
1806 _edge_top(void *data,
1807 Evas_Object *scr __UNUSED__,
1808 void *event_info __UNUSED__)
1810 evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
1814 _edge_bottom(void *data,
1815 Evas_Object *scr __UNUSED__,
1816 void *event_info __UNUSED__)
1818 evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
1822 _scr_scroll(void *data,
1823 Evas_Object *obj __UNUSED__,
1824 void *event_info __UNUSED__)
1826 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1830 _elm_gengrid_item_compare(const void *data, const void *data1)
1832 Elm_Gen_Item *it, *item1;
1833 it = ELM_GEN_ITEM_FROM_INLIST(data);
1834 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
1835 return it->wd->item_compare_cb(it, item1);
1839 _item_disable_hook(Elm_Object_Item *it)
1841 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
1843 if (_it->generation < _it->wd->generation) return;
1847 if (elm_widget_item_disabled_get(_it))
1848 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
1850 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
1855 _item_del_pre_hook(Elm_Object_Item *it)
1857 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
1858 if ((_it->relcount > 0) || (_it->walking > 0))
1860 _elm_genlist_item_del_notserious(_it);
1867 static Elm_Gen_Item *
1868 _item_new(Widget_Data *wd,
1869 const Elm_Gengrid_Item_Class *itc,
1872 const void *func_data)
1876 it = _elm_genlist_item_new(wd, itc, data, NULL, func, func_data);
1877 if (!it) return NULL;
1878 elm_widget_item_disable_hook_set(it, _item_disable_hook);
1879 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
1880 elm_gengrid_item_class_ref((Elm_Gengrid_Item_Class *)itc);
1881 it->item = ELM_NEW(Elm_Gen_Item_Type);
1883 it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
1884 ELM_GEN_ITEM_SETUP(it);
1890 elm_gengrid_add(Evas_Object *parent)
1895 static Evas_Smart *smart = NULL;
1896 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1900 static Evas_Smart_Class sc;
1902 evas_object_smart_clipped_smart_set(&_pan_sc);
1904 sc.name = "elm_gengrid_pan";
1905 sc.version = EVAS_SMART_CLASS_VERSION;
1908 sc.resize = _pan_resize;
1909 sc.move = _pan_move;
1910 sc.calculate = _pan_calculate;
1911 if (!(smart = evas_smart_class_new(&sc))) return NULL;
1914 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1916 ELM_SET_WIDTYPE(widtype, "gengrid");
1918 elm_widget_type_set(obj, "gengrid");
1919 elm_widget_sub_object_add(parent, obj);
1920 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1921 elm_widget_data_set(obj, wd);
1922 elm_widget_del_hook_set(obj, _del_hook);
1923 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1924 elm_widget_theme_hook_set(obj, _theme_hook);
1925 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1926 elm_widget_can_focus_set(obj, EINA_TRUE);
1927 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1928 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1929 elm_widget_event_hook_set(obj, _event_hook);
1932 wd->scr = elm_smart_scroller_add(e);
1933 elm_smart_scroller_widget_set(wd->scr, obj);
1934 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1936 elm_smart_scroller_bounce_allow_set(wd->scr, bounce,
1937 _elm_config->thumbscroll_bounce_enable);
1938 elm_widget_resize_object_set(obj, wd->scr);
1940 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1941 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1942 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1943 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1944 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1945 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1946 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1947 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom,
1949 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1954 wd->h_bounce = bounce;
1955 wd->v_bounce = bounce;
1956 wd->highlight = EINA_TRUE;
1958 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1959 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1960 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1961 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1963 wd->pan_smart = evas_object_smart_add(e, smart);
1964 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1967 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1968 _pan_set, _pan_get, _pan_max_get,
1969 _pan_min_get, _pan_child_size_get);
1971 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1973 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1978 elm_gengrid_item_size_set(Evas_Object *obj,
1982 ELM_CHECK_WIDTYPE(obj, widtype);
1983 Widget_Data *wd = elm_widget_data_get(obj);
1985 if ((wd->item_width == w) && (wd->item_height == h)) return;
1987 wd->item_height = h;
1988 if (wd->calc_job) ecore_job_del(wd->calc_job);
1989 wd->calc_job = ecore_job_add(_calc_job, wd);
1993 elm_gengrid_item_size_get(const Evas_Object *obj,
1997 ELM_CHECK_WIDTYPE(obj, widtype);
1998 Widget_Data *wd = elm_widget_data_get(obj);
2000 if (w) *w = wd->item_width;
2001 if (h) *h = wd->item_height;
2005 elm_gengrid_group_item_size_set(Evas_Object *obj,
2009 ELM_CHECK_WIDTYPE(obj, widtype);
2010 Widget_Data *wd = elm_widget_data_get(obj);
2012 if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
2013 wd->group_item_width = w;
2014 wd->group_item_height = h;
2015 if (wd->calc_job) ecore_job_del(wd->calc_job);
2016 wd->calc_job = ecore_job_add(_calc_job, wd);
2020 elm_gengrid_group_item_size_get(const Evas_Object *obj,
2024 ELM_CHECK_WIDTYPE(obj, widtype);
2025 Widget_Data *wd = elm_widget_data_get(obj);
2027 if (w) *w = wd->group_item_width;
2028 if (h) *h = wd->group_item_height;
2032 elm_gengrid_align_set(Evas_Object *obj,
2036 ELM_CHECK_WIDTYPE(obj, widtype);
2038 Widget_Data *wd = elm_widget_data_get(obj);
2039 double old_h = wd->align_x, old_y = wd->align_y;
2043 else if (align_x < 0.0)
2045 wd->align_x = align_x;
2049 else if (align_y < 0.0)
2051 wd->align_y = align_y;
2053 if ((old_h != wd->align_x) || (old_y != wd->align_y))
2054 evas_object_smart_calculate(wd->pan_smart);
2058 elm_gengrid_align_get(const Evas_Object *obj,
2062 ELM_CHECK_WIDTYPE(obj, widtype);
2063 Widget_Data *wd = elm_widget_data_get(obj);
2064 if (align_x) *align_x = wd->align_x;
2065 if (align_y) *align_y = wd->align_y;
2068 EAPI Elm_Object_Item *
2069 elm_gengrid_item_append(Evas_Object *obj,
2070 const Elm_Gengrid_Item_Class *itc,
2073 const void *func_data)
2076 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2077 Widget_Data *wd = elm_widget_data_get(obj);
2078 if (!wd) return NULL;
2080 it = _item_new(wd, itc, data, func, func_data);
2081 if (!it) return NULL;
2082 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2083 it->position = eina_inlist_count(wd->items);
2084 it->position_update = EINA_TRUE;
2087 wd->group_items = eina_list_prepend(wd->group_items, it);
2089 if (wd->calc_job) ecore_job_del(wd->calc_job);
2090 wd->calc_job = ecore_job_add(_calc_job, wd);
2092 return (Elm_Object_Item *)it;
2095 EAPI Elm_Object_Item *
2096 elm_gengrid_item_prepend(Evas_Object *obj,
2097 const Elm_Gengrid_Item_Class *itc,
2100 const void *func_data)
2103 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2104 Widget_Data *wd = elm_widget_data_get(obj);
2105 if (!wd) return NULL;
2107 it = _item_new(wd, itc, data, func, func_data);
2108 if (!it) return NULL;
2109 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2110 _item_position_update(wd->items, 0);
2113 wd->group_items = eina_list_append(wd->group_items, it);
2115 if (wd->calc_job) ecore_job_del(wd->calc_job);
2116 wd->calc_job = ecore_job_add(_calc_job, wd);
2118 return (Elm_Object_Item *)it;
2121 EAPI Elm_Object_Item *
2122 elm_gengrid_item_insert_before(Evas_Object *obj,
2123 const Elm_Gengrid_Item_Class *itc,
2125 Elm_Object_Item *relative,
2127 const void *func_data)
2130 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2131 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2132 Widget_Data *wd = elm_widget_data_get(obj);
2133 if (!wd) return NULL;
2135 it = _item_new(wd, itc, data, func, func_data);
2136 if (!it) return NULL;
2137 wd->items = eina_inlist_prepend_relative
2138 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2139 Eina_Inlist *tmp = eina_inlist_find(wd->items, EINA_INLIST_GET(it));
2140 _item_position_update(tmp, ((Elm_Gen_Item *)relative)->position);
2143 wd->group_items = eina_list_append_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2145 if (wd->calc_job) ecore_job_del(wd->calc_job);
2146 wd->calc_job = ecore_job_add(_calc_job, wd);
2148 return (Elm_Object_Item *)it;
2151 EAPI Elm_Object_Item *
2152 elm_gengrid_item_insert_after(Evas_Object *obj,
2153 const Elm_Gengrid_Item_Class *itc,
2155 Elm_Object_Item *relative,
2157 const void *func_data)
2160 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2161 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2162 Widget_Data *wd = elm_widget_data_get(obj);
2163 if (!wd) return NULL;
2165 it = _item_new(wd, itc, data, func, func_data);
2166 if (!it) return NULL;
2167 wd->items = eina_inlist_append_relative
2168 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2169 Eina_Inlist *tmp = eina_inlist_find(wd->items, EINA_INLIST_GET(it));
2170 _item_position_update(tmp, ((Elm_Gen_Item *)relative)->position+1);
2173 wd->group_items = eina_list_prepend_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2175 if (wd->calc_job) ecore_job_del(wd->calc_job);
2176 wd->calc_job = ecore_job_add(_calc_job, wd);
2178 return (Elm_Object_Item *)it;
2181 EAPI Elm_Object_Item *
2182 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2183 const Elm_Gengrid_Item_Class *itc,
2185 Eina_Compare_Cb comp,
2187 const void *func_data)
2190 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2191 Widget_Data *wd = elm_widget_data_get(obj);
2192 if (!wd) return NULL;
2194 it = _item_new(wd, itc, data, func, func_data);
2195 if (!it) return NULL;
2198 wd->state = eina_inlist_sorted_state_new();
2200 wd->item_compare_cb = comp;
2201 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
2202 _elm_gengrid_item_compare, wd->state);
2203 _item_position_update(wd->items, 0);
2205 if (wd->calc_job) ecore_job_del(wd->calc_job);
2206 wd->calc_job = ecore_job_add(_calc_job, wd);
2208 return (Elm_Object_Item *)it;
2212 elm_gengrid_horizontal_set(Evas_Object *obj,
2213 Eina_Bool horizontal)
2215 ELM_CHECK_WIDTYPE(obj, widtype);
2216 Widget_Data *wd = elm_widget_data_get(obj);
2218 horizontal = !!horizontal;
2219 if (horizontal == wd->horizontal) return;
2220 wd->horizontal = horizontal;
2222 /* Update the items to conform to the new layout */
2223 if (wd->calc_job) ecore_job_del(wd->calc_job);
2224 wd->calc_job = ecore_job_add(_calc_job, wd);
2228 elm_gengrid_horizontal_get(const Evas_Object *obj)
2230 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2231 Widget_Data *wd = elm_widget_data_get(obj);
2232 if (!wd) return EINA_FALSE;
2233 return wd->horizontal;
2237 elm_gengrid_clear(Evas_Object *obj)
2239 elm_genlist_clear(obj);
2242 EINA_DEPRECATED EAPI const Evas_Object *
2243 elm_gengrid_item_object_get(const Elm_Object_Item *it)
2245 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2250 elm_gengrid_item_update(Elm_Object_Item *it)
2252 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2253 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2254 if (!_it->realized) return;
2255 if (_it->want_unrealize) return;
2256 _elm_genlist_item_unrealize(_it, EINA_FALSE);
2258 _item_place(_it, _it->x, _it->y);
2261 EAPI const Elm_Gengrid_Item_Class *
2262 elm_gengrid_item_item_class_get(const Elm_Object_Item *it)
2264 return (Elm_Gengrid_Item_Class *)elm_genlist_item_item_class_get(it);
2268 elm_gengrid_item_item_class_update(Elm_Object_Item *it,
2269 const Elm_Gengrid_Item_Class *itc)
2271 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2272 EINA_SAFETY_ON_NULL_RETURN(itc);
2273 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2274 if (_it->generation < _it->wd->generation) return;
2276 elm_gengrid_item_update(it);
2280 elm_gengrid_item_pos_get(const Elm_Object_Item *it,
2284 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2285 if (x) *x = ((Elm_Gen_Item *)it)->x;
2286 if (y) *y = ((Elm_Gen_Item *)it)->y;
2290 elm_gengrid_multi_select_set(Evas_Object *obj,
2293 ELM_CHECK_WIDTYPE(obj, widtype);
2294 Widget_Data *wd = elm_widget_data_get(obj);
2296 wd->multi = !!multi;
2300 elm_gengrid_multi_select_get(const Evas_Object *obj)
2302 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2303 Widget_Data *wd = elm_widget_data_get(obj);
2304 if (!wd) return EINA_FALSE;
2308 EAPI Elm_Object_Item *
2309 elm_gengrid_selected_item_get(const Evas_Object *obj)
2311 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2312 Widget_Data *wd = elm_widget_data_get(obj);
2313 if (!wd) return NULL;
2314 if (wd->selected) return wd->selected->data;
2318 EAPI const Eina_List *
2319 elm_gengrid_selected_items_get(const Evas_Object *obj)
2321 return elm_genlist_selected_items_get(obj);
2325 elm_gengrid_item_selected_set(Elm_Object_Item *it,
2328 elm_genlist_item_selected_set(it, selected);
2332 elm_gengrid_item_selected_get(const Elm_Object_Item *it)
2334 return elm_genlist_item_selected_get(it);
2338 elm_gengrid_realized_items_get(const Evas_Object *obj)
2340 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2341 Widget_Data *wd = elm_widget_data_get(obj);
2342 Eina_List *list = NULL;
2345 EINA_INLIST_FOREACH(wd->items, it)
2347 if (it->realized) list = eina_list_append(list, (Elm_Object_Item *)it);
2353 elm_gengrid_realized_items_update(Evas_Object *obj)
2355 ELM_CHECK_WIDTYPE(obj, widtype);
2357 Eina_List *list, *l;
2358 Elm_Object_Item *it;
2360 list = elm_gengrid_realized_items_get(obj);
2361 EINA_LIST_FOREACH(list, l, it)
2362 elm_gengrid_item_update(it);
2365 static Evas_Object *
2366 _elm_gengrid_item_label_create(void *data,
2367 Evas_Object *obj __UNUSED__,
2368 Evas_Object *tooltip,
2369 void *it __UNUSED__)
2371 Evas_Object *label = elm_label_add(tooltip);
2374 elm_object_style_set(label, "tooltip");
2375 elm_object_text_set(label, data);
2380 _elm_gengrid_item_label_del_cb(void *data,
2381 Evas_Object *obj __UNUSED__,
2382 void *event_info __UNUSED__)
2384 eina_stringshare_del(data);
2388 elm_gengrid_item_tooltip_text_set(Elm_Object_Item *it,
2391 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2392 text = eina_stringshare_add(text);
2393 elm_gengrid_item_tooltip_content_cb_set(it, _elm_gengrid_item_label_create,
2395 _elm_gengrid_item_label_del_cb);
2399 elm_gengrid_item_tooltip_content_cb_set(Elm_Object_Item *it,
2400 Elm_Tooltip_Item_Content_Cb func,
2402 Evas_Smart_Cb del_cb)
2404 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
2405 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2407 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
2410 if (_it->tooltip.del_cb)
2411 _it->tooltip.del_cb((void *)_it->tooltip.data, WIDGET(_it), _it);
2412 _it->tooltip.content_cb = func;
2413 _it->tooltip.data = data;
2414 _it->tooltip.del_cb = del_cb;
2417 elm_widget_item_tooltip_content_cb_set(_it,
2418 _it->tooltip.content_cb,
2419 _it->tooltip.data, NULL);
2420 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
2421 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
2427 if (del_cb) del_cb((void *)data, NULL, NULL);
2431 elm_gengrid_item_tooltip_unset(Elm_Object_Item *it)
2433 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2434 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2436 if ((VIEW(_it)) && (_it->tooltip.content_cb))
2437 elm_widget_item_tooltip_unset(_it);
2439 if (_it->tooltip.del_cb)
2440 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
2441 _it->tooltip.del_cb = NULL;
2442 _it->tooltip.content_cb = NULL;
2443 _it->tooltip.data = NULL;
2444 _it->tooltip.free_size = EINA_FALSE;
2445 if (_it->tooltip.style)
2446 elm_gengrid_item_tooltip_style_set(it, NULL);
2450 elm_gengrid_item_tooltip_style_set(Elm_Object_Item *it,
2453 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2454 eina_stringshare_replace(&((Elm_Gen_Item *)it)->tooltip.style, style);
2455 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
2459 elm_gengrid_item_tooltip_style_get(const Elm_Object_Item *it)
2461 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2462 return ((Elm_Gen_Item *)it)->tooltip.style;
2466 elm_gengrid_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
2468 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2469 ((Elm_Gen_Item *)it)->tooltip.free_size = disable;
2470 if (VIEW(it)) return elm_widget_item_tooltip_window_mode_set(it, disable);
2475 elm_gengrid_item_tooltip_window_mode_get(const Elm_Object_Item *it)
2477 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2478 return ((Elm_Gen_Item *)it)->tooltip.free_size;
2482 elm_gengrid_item_cursor_set(Elm_Object_Item *it,
2485 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2486 eina_stringshare_replace(&((Elm_Gen_Item *)it)->mouse_cursor, cursor);
2487 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
2491 elm_gengrid_item_cursor_get(const Elm_Object_Item *it)
2493 return elm_widget_item_cursor_get(it);
2497 elm_gengrid_item_cursor_unset(Elm_Object_Item *it)
2499 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2500 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2501 if (!_it->mouse_cursor)
2505 elm_widget_item_cursor_unset(_it);
2507 eina_stringshare_del(_it->mouse_cursor);
2508 _it->mouse_cursor = NULL;
2512 elm_gengrid_item_cursor_style_set(Elm_Object_Item *it,
2515 elm_widget_item_cursor_style_set(it, style);
2519 elm_gengrid_item_cursor_style_get(const Elm_Object_Item *it)
2521 return elm_widget_item_cursor_style_get(it);
2525 elm_gengrid_item_cursor_engine_only_set(Elm_Object_Item *it,
2526 Eina_Bool engine_only)
2528 elm_widget_item_cursor_engine_only_set(it, engine_only);
2532 elm_gengrid_item_cursor_engine_only_get(const Elm_Object_Item *it)
2534 return elm_widget_item_cursor_engine_only_get(it);
2538 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2539 Eina_Bool reorder_mode)
2541 ELM_CHECK_WIDTYPE(obj, widtype);
2542 Widget_Data *wd = elm_widget_data_get(obj);
2544 wd->reorder_mode = !!reorder_mode;
2548 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2550 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2551 Widget_Data *wd = elm_widget_data_get(obj);
2552 if (!wd) return EINA_FALSE;
2553 return wd->reorder_mode;
2557 elm_gengrid_bounce_set(Evas_Object *obj,
2561 elm_genlist_bounce_set(obj, h_bounce, v_bounce);
2565 elm_gengrid_bounce_get(const Evas_Object *obj,
2566 Eina_Bool *h_bounce,
2567 Eina_Bool *v_bounce)
2569 elm_genlist_bounce_get(obj, h_bounce, v_bounce);
2573 elm_gengrid_page_relative_set(Evas_Object *obj,
2577 _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
2581 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2583 _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
2587 elm_gengrid_page_size_set(Evas_Object *obj,
2588 Evas_Coord h_pagesize,
2589 Evas_Coord v_pagesize)
2591 _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
2595 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2597 _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
2601 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2603 _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
2607 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2609 _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
2613 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2615 _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
2619 elm_gengrid_scroller_policy_set(Evas_Object *obj,
2620 Elm_Scroller_Policy policy_h,
2621 Elm_Scroller_Policy policy_v)
2623 ELM_CHECK_WIDTYPE(obj, widtype);
2624 Widget_Data *wd = elm_widget_data_get(obj);
2625 if ((!wd) || (!wd->scr)) return;
2626 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
2627 (policy_v >= ELM_SCROLLER_POLICY_LAST))
2629 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
2633 elm_gengrid_scroller_policy_get(const Evas_Object *obj,
2634 Elm_Scroller_Policy *policy_h,
2635 Elm_Scroller_Policy *policy_v)
2637 ELM_CHECK_WIDTYPE(obj, widtype);
2638 Widget_Data *wd = elm_widget_data_get(obj);
2639 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
2640 if ((!wd) || (!wd->scr)) return;
2641 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
2642 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
2643 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
2646 EAPI Elm_Object_Item *
2647 elm_gengrid_first_item_get(const Evas_Object *obj)
2649 return elm_genlist_first_item_get(obj);
2652 EAPI Elm_Object_Item *
2653 elm_gengrid_last_item_get(const Evas_Object *obj)
2655 return elm_genlist_last_item_get(obj);
2658 EAPI Elm_Object_Item *
2659 elm_gengrid_item_next_get(const Elm_Object_Item *it)
2661 return elm_genlist_item_next_get(it);
2664 EAPI Elm_Object_Item *
2665 elm_gengrid_item_prev_get(const Elm_Object_Item *it)
2667 return elm_genlist_item_prev_get(it);
2671 elm_gengrid_item_show(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
2673 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2674 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2675 Widget_Data *wd = _it->wd;
2676 Evas_Coord minx = 0, miny = 0;
2678 if ((_it->generation < _it->wd->generation)) return;
2679 _pan_min_get(wd->pan_smart, &minx, &miny);
2681 if (type==ELM_GENGRID_ITEM_SCROLLTO_IN)
2683 //TODO : type based handling like genlist
2687 elm_smart_scroller_region_bring_in(_it->wd->scr,
2688 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2689 _it->y * wd->item_height + miny,
2690 _it->wd->item_width,
2691 _it->wd->item_height);
2693 elm_smart_scroller_region_bring_in(_it->wd->scr,
2694 _it->x * wd->item_width + minx,
2695 ((_it->y - _it->item->prev_group) * wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2696 _it->wd->item_width,
2697 _it->wd->item_height);
2701 elm_gengrid_item_bring_in(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
2703 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2704 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2706 if (_it->generation < _it->wd->generation) return;
2708 Evas_Coord minx = 0, miny = 0;
2709 Widget_Data *wd = _it->wd;
2710 _pan_min_get(wd->pan_smart, &minx, &miny);
2712 if (type==ELM_GENGRID_ITEM_SCROLLTO_IN)
2714 //TODO : type based handling like genlist
2718 elm_smart_scroller_region_bring_in(_it->wd->scr,
2719 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2720 _it->y * wd->item_height + miny,
2721 _it->wd->item_width,
2722 _it->wd->item_height);
2724 elm_smart_scroller_region_bring_in(_it->wd->scr,
2725 _it->x * wd->item_width + minx,
2726 ((_it->y - _it->item->prev_group)* wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2727 _it->wd->item_width,
2728 _it->wd->item_height);
2732 elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill)
2734 ELM_CHECK_WIDTYPE(obj, widtype);
2735 Widget_Data *wd = elm_widget_data_get(obj);
2738 if (wd->filled != fill)
2743 elm_gengrid_filled_get(const Evas_Object *obj)
2745 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2746 Widget_Data *wd = elm_widget_data_get(obj);
2747 if (!wd) return EINA_FALSE;
2752 elm_gengrid_items_count(const Evas_Object *obj)
2754 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2755 Widget_Data *wd = elm_widget_data_get(obj);
2757 return wd->item_count;
2760 EAPI Elm_Gengrid_Item_Class *
2761 elm_gengrid_item_class_new(void)
2763 Elm_Gengrid_Item_Class *itc;
2765 itc = calloc(1, sizeof(Elm_Gengrid_Item_Class));
2768 itc->version = CLASS_ALLOCATED;
2770 itc->delete_me = EINA_FALSE;
2776 elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
2778 if (itc && (itc->version == CLASS_ALLOCATED))
2780 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
2781 if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
2791 elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
2793 if (itc && (itc->version == CLASS_ALLOCATED))
2796 if (itc->refcount == 0) itc->refcount--;
2801 elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
2803 if (itc && (itc->version == CLASS_ALLOCATED))
2805 if (itc->refcount > 0) itc->refcount--;
2806 if (itc->delete_me && (!itc->refcount))
2807 elm_gengrid_item_class_free(itc);
2812 elm_gengrid_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode mode)
2814 elm_genlist_select_mode_set(obj, mode);
2817 EAPI Elm_Object_Select_Mode
2818 elm_gengrid_select_mode_get(const Evas_Object *obj)
2820 return elm_genlist_select_mode_get(obj);
2824 elm_gengrid_highlight_mode_set(Evas_Object *obj,
2825 Eina_Bool highlight)
2827 elm_genlist_highlight_mode_set(obj, highlight);
2831 elm_gengrid_highlight_mode_get(const Evas_Object *obj)
2833 return elm_genlist_highlight_mode_get(obj);
2837 elm_gengrid_item_index_get(const Elm_Object_Item *it)
2839 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, -1);
2840 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2842 return _it->position;
2846 elm_gengrid_item_select_mode_set(Elm_Object_Item *it,
2847 Elm_Object_Select_Mode mode)
2849 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2850 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2852 if (_it->generation < _it->wd->generation) return;
2853 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
2855 if (_it->select_mode != mode)
2856 _it->select_mode = mode;
2858 if (_it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
2859 elm_gengrid_item_update(it);
2862 EAPI Elm_Object_Select_Mode
2863 elm_gengrid_item_select_mode_get(const Elm_Object_Item *it)
2865 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ELM_OBJECT_SELECT_MODE_MAX);
2866 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2867 if (!_it) return ELM_OBJECT_SELECT_MODE_MAX;
2868 return _it->select_mode;