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_escaped_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 if (!it || !it->item) return ECORE_CALLBACK_CANCEL;
1061 tt = REORDER_EFFECT_TIME;
1062 t = ((0.0 > (t = ecore_loop_time_get()-it->item->moving_effect_start_time)) ? 0.0 : t);
1063 dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
1064 dy = ((it->item->ty - it->item->oy) / 10) * _elm_config->scale;
1068 it->item->rx += (1 * sin((t / tt) * (M_PI / 2)) * dx);
1069 it->item->ry += (1 * sin((t / tt) * (M_PI / 2)) * dy);
1077 if ((((dx > 0) && (it->item->rx >= it->item->tx)) || ((dx <= 0) && (it->item->rx <= it->item->tx))) &&
1078 (((dy > 0) && (it->item->ry >= it->item->ty)) || ((dy <= 0) && (it->item->ry <= it->item->ty))))
1080 evas_object_move(VIEW(it), it->item->tx, it->item->ty);
1084 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1085 if (it->wd->horizontal)
1086 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1088 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1091 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1092 it->item->moving = EINA_FALSE;
1093 it->item->item_reorder_move_animator = NULL;
1094 return ECORE_CALLBACK_CANCEL;
1097 evas_object_move(VIEW(it), it->item->rx, it->item->ry);
1101 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1102 if (it->wd->horizontal)
1103 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1105 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1108 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1110 return ECORE_CALLBACK_RENEW;
1114 _group_item_place(Pan *sd)
1116 Evas_Coord iw, ih, vw, vh;
1118 Eina_Bool was_realized;
1120 evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1121 if (sd->wd->horizontal)
1123 iw = sd->wd->group_item_width;
1129 ih = sd->wd->group_item_height;
1131 EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1133 was_realized = it->realized;
1134 if (it->item->group_realized)
1138 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1139 evas_object_move(VIEW(it), it->item->gx, it->item->gy);
1140 evas_object_resize(VIEW(it), iw, ih);
1141 evas_object_raise(VIEW(it));
1144 _elm_genlist_item_unrealize(it, EINA_FALSE);
1150 _item_place(Elm_Gen_Item *it,
1154 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1155 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1156 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1160 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &vw, &vh);
1162 /* Preload rows/columns at each side of the Gengrid */
1163 cvx = ox - PRELOAD * it->wd->item_width;
1164 cvy = oy - PRELOAD * it->wd->item_height;
1165 cvw = vw + 2 * PRELOAD * it->wd->item_width;
1166 cvh = vh + 2 * PRELOAD * it->wd->item_height;
1171 items_count = it->wd->item_count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
1172 if (it->wd->horizontal)
1174 int columns, items_visible = 0, items_row;
1176 if (it->wd->item_height > 0)
1177 items_visible = vh / it->wd->item_height;
1178 if (items_visible < 1)
1181 columns = items_count / items_visible;
1182 if (items_count % items_visible)
1185 tcw = (it->wd->item_width * columns) + (it->wd->group_item_width * eina_list_count(it->wd->group_items));
1186 alignw = (vw - tcw) * it->wd->align_x;
1188 items_row = items_visible;
1189 if ((unsigned int)items_row > it->wd->item_count)
1190 items_row = it->wd->item_count;
1192 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1193 tch = it->wd->nmax * it->wd->item_height;
1195 tch = items_row * it->wd->item_height;
1196 alignh = (vh - tch) * it->wd->align_y;
1200 unsigned int rows, items_visible = 0, items_col;
1202 if (it->wd->item_width > 0)
1203 items_visible = vw / it->wd->item_width;
1204 if (items_visible < 1)
1207 rows = items_count / items_visible;
1208 if (items_count % items_visible)
1211 tch = (it->wd->item_height * rows) + (it->wd->group_item_height * eina_list_count(it->wd->group_items));
1212 alignh = (vh - tch) * it->wd->align_y;
1214 items_col = items_visible;
1215 if (items_col > it->wd->item_count)
1216 items_col = it->wd->item_count;
1218 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1219 tcw = it->wd->nmax * it->wd->item_width;
1221 tcw = items_col * it->wd->item_width;
1222 alignw = (vw - tcw) * it->wd->align_x;
1227 if (it->wd->horizontal)
1229 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;
1231 iw = it->wd->group_item_width;
1237 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;
1239 ih = it->wd->group_item_height;
1246 if (it->wd->horizontal)
1248 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;
1249 y = (cy * it->wd->item_height) - it->wd->pan_y + oy + alignh;
1253 x = (cx * it->wd->item_width) - it->wd->pan_x + ox + alignw;
1254 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;
1256 if (elm_widget_mirrored_get(WIDGET(it)))
1257 { /* Switch items side and componsate for pan_x when in RTL mode */
1258 evas_object_geometry_get(WIDGET(it), NULL, NULL, &ww, NULL);
1259 x = ww - x - it->wd->item_width - it->wd->pan_x - it->wd->pan_x;
1261 iw = it->wd->item_width;
1262 ih = it->wd->item_height;
1265 Eina_Bool was_realized = it->realized;
1266 if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1270 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1273 if (it->wd->horizontal)
1275 if (it->parent->item->gx < ox)
1277 it->parent->item->gx = x + it->wd->item_width - it->wd->group_item_width;
1278 if (it->parent->item->gx > ox)
1279 it->parent->item->gx = ox;
1281 it->parent->item->group_realized = EINA_TRUE;
1285 if (it->parent->item->gy < oy)
1287 it->parent->item->gy = y + it->wd->item_height - it->wd->group_item_height;
1288 if (it->parent->item->gy > oy)
1289 it->parent->item->gy = oy;
1291 it->parent->item->group_realized = EINA_TRUE;
1294 if (it->wd->reorder_mode)
1296 if (it->wd->reorder_it)
1298 if (it->item->moving) return;
1300 if (!it->wd->move_effect_enabled)
1305 if (it->wd->reorder_it == it)
1307 evas_object_move(VIEW(it),
1308 it->wd->reorder_item_x, it->wd->reorder_item_y);
1309 evas_object_resize(VIEW(it), iw, ih);
1314 if (it->wd->move_effect_enabled)
1316 if ((it->item->ox != x) || (it->item->oy != y))
1318 if (((it->wd->old_pan_x == it->wd->pan_x) && (it->wd->old_pan_y == it->wd->pan_y)) ||
1319 ((it->wd->old_pan_x != it->wd->pan_x) && !(it->item->ox - it->wd->pan_x + it->wd->old_pan_x == x)) ||
1320 ((it->wd->old_pan_y != it->wd->pan_y) && !(it->item->oy - it->wd->pan_y + it->wd->old_pan_y == y)))
1324 it->item->rx = it->item->ox;
1325 it->item->ry = it->item->oy;
1326 it->item->moving = EINA_TRUE;
1327 it->item->moving_effect_start_time = ecore_loop_time_get();
1328 it->item->item_reorder_move_animator = ecore_animator_add(_reorder_item_move_animator_cb, it);
1335 Evas_Coord nx, ny, nw, nh;
1338 if (it->wd->horizontal)
1340 nx = x + (it->wd->group_item_width / 2);
1348 ny = y + (it->wd->group_item_height / 2);
1355 nx = x + (it->wd->item_width / 2);
1356 ny = y + (it->wd->item_height / 2);
1361 if ( ELM_RECTS_INTERSECT(it->wd->reorder_item_x, it->wd->reorder_item_y,
1362 it->wd->item_width, it->wd->item_height,
1365 if (it->wd->horizontal)
1367 if ((it->wd->nmax * it->wd->reorder_it->x + it->wd->reorder_it->y) >
1368 (it->wd->nmax * it->x + it->y))
1369 reorder_item_move_forward = EINA_TRUE;
1373 if ((it->wd->nmax * it->wd->reorder_it->y + it->wd->reorder_it->x) >
1374 (it->wd->nmax * it->y + it->x))
1375 reorder_item_move_forward = EINA_TRUE;
1378 it->wd->items = eina_inlist_remove(it->wd->items,
1379 EINA_INLIST_GET(it->wd->reorder_it));
1380 if (reorder_item_move_forward)
1381 it->wd->items = eina_inlist_prepend_relative(it->wd->items,
1382 EINA_INLIST_GET(it->wd->reorder_it),
1383 EINA_INLIST_GET(it));
1385 it->wd->items = eina_inlist_append_relative(it->wd->items,
1386 EINA_INLIST_GET(it->wd->reorder_it),
1387 EINA_INLIST_GET(it));
1389 it->wd->reorder_item_changed = EINA_TRUE;
1390 it->wd->move_effect_enabled = EINA_TRUE;
1391 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1392 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1398 else if (it->item->item_reorder_move_animator)
1400 ecore_animator_del(it->item->item_reorder_move_animator);
1401 it->item->item_reorder_move_animator = NULL;
1402 it->item->moving = EINA_FALSE;
1407 evas_object_move(VIEW(it), x, y);
1408 evas_object_resize(VIEW(it), iw, ih);
1411 it->item->group_realized = EINA_TRUE;
1416 _elm_genlist_item_unrealize(it, EINA_FALSE);
1418 it->item->group_realized = EINA_FALSE;
1423 _item_position_update(Eina_Inlist *list, int idx)
1427 EINA_INLIST_FOREACH(list, it)
1429 it->position = idx++;
1430 it->position_update = EINA_TRUE;
1435 _item_del(Elm_Gen_Item *it)
1437 Evas_Object *obj = WIDGET(it);
1439 evas_event_freeze(evas_object_evas_get(obj));
1440 it->wd->selected = eina_list_remove(it->wd->selected, it);
1441 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
1442 _elm_genlist_item_del_serious(it);
1443 elm_gengrid_item_class_unref((Elm_Gengrid_Item_Class *)it->itc);
1444 evas_event_thaw(evas_object_evas_get(obj));
1445 evas_event_thaw_eval(evas_object_evas_get(obj));
1449 _item_unselect(Elm_Gen_Item *it)
1451 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
1452 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
1453 it->highlighted = EINA_FALSE;
1456 it->selected = EINA_FALSE;
1457 it->wd->selected = eina_list_remove(it->wd->selected, it);
1458 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
1463 _calc_job(void *data)
1465 Widget_Data *wd = data;
1466 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1467 Elm_Gen_Item *it, *group_item = NULL;
1468 int count_group = 0;
1472 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1473 if ((cvw != 0) || (cvh != 0))
1475 if ((wd->horizontal) && (wd->item_height > 0))
1476 nmax = cvh / wd->item_height;
1477 else if (wd->item_width > 0)
1478 nmax = cvw / wd->item_width;
1483 EINA_INLIST_FOREACH(wd->items, it)
1485 if (it->item->prev_group != count_group)
1486 it->item->prev_group = count_group;
1489 count = count % nmax;
1491 wd->items_lost += nmax - count;
1492 //printf("%d items and I lost %d\n", count, wd->items_lost);
1494 if (count) count = 0;
1499 if (it->parent != group_item)
1500 it->parent = group_item;
1504 count = wd->item_count + wd->items_lost - count_group;
1507 minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width);
1508 minh = nmax * wd->item_height;
1512 minw = nmax * wd->item_width;
1513 minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1516 if ((minw != wd->minw) || (minh != wd->minh))
1520 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1524 evas_object_smart_changed(wd->pan_smart);
1526 wd->calc_job = NULL;
1530 _pan_add(Evas_Object *obj)
1533 Evas_Object_Smart_Clipped_Data *cd;
1536 cd = evas_object_smart_data_get(obj);
1539 sd->__clipped_data = *cd;
1541 evas_object_smart_data_set(obj, sd);
1545 _pan_del(Evas_Object *obj)
1547 Pan *sd = evas_object_smart_data_get(obj);
1554 _pan_set(Evas_Object *obj,
1558 Pan *sd = evas_object_smart_data_get(obj);
1559 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1562 evas_object_smart_changed(obj);
1566 _pan_get(Evas_Object *obj,
1570 Pan *sd = evas_object_smart_data_get(obj);
1571 if (x) *x = sd->wd->pan_x;
1572 if (y) *y = sd->wd->pan_y;
1576 _pan_child_size_get(Evas_Object *obj,
1580 Pan *sd = evas_object_smart_data_get(obj);
1581 if (w) *w = sd->wd->minw;
1582 if (h) *h = sd->wd->minh;
1586 _pan_max_get(Evas_Object *obj,
1590 Pan *sd = evas_object_smart_data_get(obj);
1594 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1596 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1598 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1602 _pan_min_get(Evas_Object *obj,
1606 Pan *sd = evas_object_smart_data_get(obj);
1607 Evas_Coord mx = 0, my = 0;
1610 _pan_max_get(obj, &mx, &my);
1612 *x = -mx * sd->wd->align_x;
1614 *y = -my * sd->wd->align_y;
1618 _pan_resize(Evas_Object *obj,
1622 Pan *sd = evas_object_smart_data_get(obj);
1625 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1626 if ((ow == w) && (oh == h)) return;
1627 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1628 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1632 _pan_calculate(Evas_Object *obj)
1634 Pan *sd = evas_object_smart_data_get(obj);
1635 Evas_Coord cx = 0, cy = 0;
1639 if (!sd->wd->nmax) return;
1641 sd->wd->reorder_item_changed = EINA_FALSE;
1643 EINA_INLIST_FOREACH(sd->wd->items, it)
1647 if (sd->wd->horizontal)
1664 _item_place(it, cx, cy);
1665 if (sd->wd->reorder_item_changed) return;
1668 if (sd->wd->horizontal)
1681 if (sd->wd->horizontal)
1683 cy = (cy + 1) % sd->wd->nmax;
1688 cx = (cx + 1) % sd->wd->nmax;
1693 _group_item_place(sd);
1696 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
1698 if (!sd->wd->reorder_item_changed)
1700 sd->wd->old_pan_x = sd->wd->pan_x;
1701 sd->wd->old_pan_y = sd->wd->pan_y;
1703 sd->wd->move_effect_enabled = EINA_FALSE;
1705 evas_object_smart_callback_call(sd->wd->obj, SIG_CHANGED, NULL);
1709 _pan_move(Evas_Object *obj,
1710 Evas_Coord x __UNUSED__,
1711 Evas_Coord y __UNUSED__)
1713 Pan *sd = evas_object_smart_data_get(obj);
1715 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1716 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1720 _hold_on(void *data __UNUSED__,
1722 void *event_info __UNUSED__)
1724 Widget_Data *wd = elm_widget_data_get(obj);
1726 elm_smart_scroller_hold_set(wd->scr, 1);
1730 _hold_off(void *data __UNUSED__,
1732 void *event_info __UNUSED__)
1734 Widget_Data *wd = elm_widget_data_get(obj);
1736 elm_smart_scroller_hold_set(wd->scr, 0);
1740 _freeze_on(void *data __UNUSED__,
1742 void *event_info __UNUSED__)
1744 Widget_Data *wd = elm_widget_data_get(obj);
1746 elm_smart_scroller_freeze_set(wd->scr, 1);
1750 _freeze_off(void *data __UNUSED__,
1752 void *event_info __UNUSED__)
1754 Widget_Data *wd = elm_widget_data_get(obj);
1756 elm_smart_scroller_freeze_set(wd->scr, 0);
1760 _scr_anim_start(void *data,
1761 Evas_Object *obj __UNUSED__,
1762 void *event_info __UNUSED__)
1764 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1768 _scr_anim_stop(void *data,
1769 Evas_Object *obj __UNUSED__,
1770 void *event_info __UNUSED__)
1772 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1776 _scr_drag_start(void *data,
1777 Evas_Object *obj __UNUSED__,
1778 void *event_info __UNUSED__)
1780 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1784 _scr_drag_stop(void *data,
1785 Evas_Object *obj __UNUSED__,
1786 void *event_info __UNUSED__)
1788 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1792 _edge_left(void *data,
1793 Evas_Object *scr __UNUSED__,
1794 void *event_info __UNUSED__)
1796 evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
1800 _edge_right(void *data,
1801 Evas_Object *scr __UNUSED__,
1802 void *event_info __UNUSED__)
1804 evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
1808 _edge_top(void *data,
1809 Evas_Object *scr __UNUSED__,
1810 void *event_info __UNUSED__)
1812 evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
1816 _edge_bottom(void *data,
1817 Evas_Object *scr __UNUSED__,
1818 void *event_info __UNUSED__)
1820 evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
1824 _scr_scroll(void *data,
1825 Evas_Object *obj __UNUSED__,
1826 void *event_info __UNUSED__)
1828 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1832 _elm_gengrid_item_compare(const void *data, const void *data1)
1834 Elm_Gen_Item *it, *item1;
1835 it = ELM_GEN_ITEM_FROM_INLIST(data);
1836 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
1837 return it->wd->item_compare_cb(it, item1);
1841 _item_disable_hook(Elm_Object_Item *it)
1843 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
1845 if (_it->generation < _it->wd->generation) return;
1849 if (elm_widget_item_disabled_get(_it))
1850 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
1852 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
1857 _item_del_pre_hook(Elm_Object_Item *it)
1859 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
1860 if ((_it->relcount > 0) || (_it->walking > 0))
1862 _elm_genlist_item_del_notserious(_it);
1869 static Elm_Gen_Item *
1870 _item_new(Widget_Data *wd,
1871 const Elm_Gengrid_Item_Class *itc,
1874 const void *func_data)
1878 it = _elm_genlist_item_new(wd, itc, data, NULL, func, func_data);
1879 if (!it) return NULL;
1880 elm_widget_item_disable_hook_set(it, _item_disable_hook);
1881 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
1882 elm_gengrid_item_class_ref((Elm_Gengrid_Item_Class *)itc);
1883 it->item = ELM_NEW(Elm_Gen_Item_Type);
1885 it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
1886 ELM_GEN_ITEM_SETUP(it);
1892 elm_gengrid_add(Evas_Object *parent)
1897 static Evas_Smart *smart = NULL;
1898 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1902 static Evas_Smart_Class sc;
1904 evas_object_smart_clipped_smart_set(&_pan_sc);
1906 sc.name = "elm_gengrid_pan";
1907 sc.version = EVAS_SMART_CLASS_VERSION;
1910 sc.resize = _pan_resize;
1911 sc.move = _pan_move;
1912 sc.calculate = _pan_calculate;
1913 if (!(smart = evas_smart_class_new(&sc))) return NULL;
1916 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1918 ELM_SET_WIDTYPE(widtype, "gengrid");
1920 elm_widget_type_set(obj, "gengrid");
1921 elm_widget_sub_object_add(parent, obj);
1922 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1923 elm_widget_data_set(obj, wd);
1924 elm_widget_del_hook_set(obj, _del_hook);
1925 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1926 elm_widget_theme_hook_set(obj, _theme_hook);
1927 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1928 elm_widget_can_focus_set(obj, EINA_TRUE);
1929 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1930 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1931 elm_widget_event_hook_set(obj, _event_hook);
1934 wd->scr = elm_smart_scroller_add(e);
1935 elm_smart_scroller_widget_set(wd->scr, obj);
1936 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1938 elm_smart_scroller_bounce_allow_set(wd->scr, bounce,
1939 _elm_config->thumbscroll_bounce_enable);
1940 elm_widget_resize_object_set(obj, wd->scr);
1942 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1943 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1944 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1945 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1946 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1947 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1948 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1949 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom,
1951 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1956 wd->h_bounce = bounce;
1957 wd->v_bounce = bounce;
1958 wd->highlight = EINA_TRUE;
1960 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1961 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1962 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1963 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1965 wd->pan_smart = evas_object_smart_add(e, smart);
1966 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1969 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1970 _pan_set, _pan_get, _pan_max_get,
1971 _pan_min_get, _pan_child_size_get);
1973 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1975 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1980 elm_gengrid_item_size_set(Evas_Object *obj,
1984 ELM_CHECK_WIDTYPE(obj, widtype);
1985 Widget_Data *wd = elm_widget_data_get(obj);
1987 if ((wd->item_width == w) && (wd->item_height == h)) return;
1989 wd->item_height = h;
1990 if (wd->calc_job) ecore_job_del(wd->calc_job);
1991 wd->calc_job = ecore_job_add(_calc_job, wd);
1995 elm_gengrid_item_size_get(const Evas_Object *obj,
1999 ELM_CHECK_WIDTYPE(obj, widtype);
2000 Widget_Data *wd = elm_widget_data_get(obj);
2002 if (w) *w = wd->item_width;
2003 if (h) *h = wd->item_height;
2007 elm_gengrid_group_item_size_set(Evas_Object *obj,
2011 ELM_CHECK_WIDTYPE(obj, widtype);
2012 Widget_Data *wd = elm_widget_data_get(obj);
2014 if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
2015 wd->group_item_width = w;
2016 wd->group_item_height = h;
2017 if (wd->calc_job) ecore_job_del(wd->calc_job);
2018 wd->calc_job = ecore_job_add(_calc_job, wd);
2022 elm_gengrid_group_item_size_get(const Evas_Object *obj,
2026 ELM_CHECK_WIDTYPE(obj, widtype);
2027 Widget_Data *wd = elm_widget_data_get(obj);
2029 if (w) *w = wd->group_item_width;
2030 if (h) *h = wd->group_item_height;
2034 elm_gengrid_align_set(Evas_Object *obj,
2038 ELM_CHECK_WIDTYPE(obj, widtype);
2040 Widget_Data *wd = elm_widget_data_get(obj);
2041 double old_h = wd->align_x, old_y = wd->align_y;
2045 else if (align_x < 0.0)
2047 wd->align_x = align_x;
2051 else if (align_y < 0.0)
2053 wd->align_y = align_y;
2055 if ((old_h != wd->align_x) || (old_y != wd->align_y))
2056 evas_object_smart_calculate(wd->pan_smart);
2060 elm_gengrid_align_get(const Evas_Object *obj,
2064 ELM_CHECK_WIDTYPE(obj, widtype);
2065 Widget_Data *wd = elm_widget_data_get(obj);
2066 if (align_x) *align_x = wd->align_x;
2067 if (align_y) *align_y = wd->align_y;
2070 EAPI Elm_Object_Item *
2071 elm_gengrid_item_append(Evas_Object *obj,
2072 const Elm_Gengrid_Item_Class *itc,
2075 const void *func_data)
2078 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2079 Widget_Data *wd = elm_widget_data_get(obj);
2080 if (!wd) return NULL;
2082 it = _item_new(wd, itc, data, func, func_data);
2083 if (!it) return NULL;
2084 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2085 it->position = eina_inlist_count(wd->items);
2086 it->position_update = EINA_TRUE;
2089 wd->group_items = eina_list_prepend(wd->group_items, it);
2091 if (wd->calc_job) ecore_job_del(wd->calc_job);
2092 wd->calc_job = ecore_job_add(_calc_job, wd);
2094 return (Elm_Object_Item *)it;
2097 EAPI Elm_Object_Item *
2098 elm_gengrid_item_prepend(Evas_Object *obj,
2099 const Elm_Gengrid_Item_Class *itc,
2102 const void *func_data)
2105 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2106 Widget_Data *wd = elm_widget_data_get(obj);
2107 if (!wd) return NULL;
2109 it = _item_new(wd, itc, data, func, func_data);
2110 if (!it) return NULL;
2111 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2112 _item_position_update(wd->items, 0);
2115 wd->group_items = eina_list_append(wd->group_items, it);
2117 if (wd->calc_job) ecore_job_del(wd->calc_job);
2118 wd->calc_job = ecore_job_add(_calc_job, wd);
2120 return (Elm_Object_Item *)it;
2123 EAPI Elm_Object_Item *
2124 elm_gengrid_item_insert_before(Evas_Object *obj,
2125 const Elm_Gengrid_Item_Class *itc,
2127 Elm_Object_Item *relative,
2129 const void *func_data)
2132 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2133 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2134 Widget_Data *wd = elm_widget_data_get(obj);
2135 if (!wd) return NULL;
2137 it = _item_new(wd, itc, data, func, func_data);
2138 if (!it) return NULL;
2139 wd->items = eina_inlist_prepend_relative
2140 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2141 Eina_Inlist *tmp = eina_inlist_find(wd->items, EINA_INLIST_GET(it));
2142 _item_position_update(tmp, ((Elm_Gen_Item *)relative)->position);
2145 wd->group_items = eina_list_append_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2147 if (wd->calc_job) ecore_job_del(wd->calc_job);
2148 wd->calc_job = ecore_job_add(_calc_job, wd);
2150 return (Elm_Object_Item *)it;
2153 EAPI Elm_Object_Item *
2154 elm_gengrid_item_insert_after(Evas_Object *obj,
2155 const Elm_Gengrid_Item_Class *itc,
2157 Elm_Object_Item *relative,
2159 const void *func_data)
2162 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2163 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2164 Widget_Data *wd = elm_widget_data_get(obj);
2165 if (!wd) return NULL;
2167 it = _item_new(wd, itc, data, func, func_data);
2168 if (!it) return NULL;
2169 wd->items = eina_inlist_append_relative
2170 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2171 Eina_Inlist *tmp = eina_inlist_find(wd->items, EINA_INLIST_GET(it));
2172 _item_position_update(tmp, ((Elm_Gen_Item *)relative)->position+1);
2175 wd->group_items = eina_list_prepend_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2177 if (wd->calc_job) ecore_job_del(wd->calc_job);
2178 wd->calc_job = ecore_job_add(_calc_job, wd);
2180 return (Elm_Object_Item *)it;
2183 EAPI Elm_Object_Item *
2184 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2185 const Elm_Gengrid_Item_Class *itc,
2187 Eina_Compare_Cb comp,
2189 const void *func_data)
2192 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2193 Widget_Data *wd = elm_widget_data_get(obj);
2194 if (!wd) return NULL;
2196 it = _item_new(wd, itc, data, func, func_data);
2197 if (!it) return NULL;
2200 wd->state = eina_inlist_sorted_state_new();
2202 wd->item_compare_cb = comp;
2203 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
2204 _elm_gengrid_item_compare, wd->state);
2205 _item_position_update(wd->items, 0);
2207 if (wd->calc_job) ecore_job_del(wd->calc_job);
2208 wd->calc_job = ecore_job_add(_calc_job, wd);
2210 return (Elm_Object_Item *)it;
2214 elm_gengrid_horizontal_set(Evas_Object *obj,
2215 Eina_Bool horizontal)
2217 ELM_CHECK_WIDTYPE(obj, widtype);
2218 Widget_Data *wd = elm_widget_data_get(obj);
2220 horizontal = !!horizontal;
2221 if (horizontal == wd->horizontal) return;
2222 wd->horizontal = horizontal;
2224 /* Update the items to conform to the new layout */
2225 if (wd->calc_job) ecore_job_del(wd->calc_job);
2226 wd->calc_job = ecore_job_add(_calc_job, wd);
2230 elm_gengrid_horizontal_get(const Evas_Object *obj)
2232 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2233 Widget_Data *wd = elm_widget_data_get(obj);
2234 if (!wd) return EINA_FALSE;
2235 return wd->horizontal;
2239 elm_gengrid_clear(Evas_Object *obj)
2241 elm_genlist_clear(obj);
2244 EINA_DEPRECATED EAPI const Evas_Object *
2245 elm_gengrid_item_object_get(const Elm_Object_Item *it)
2247 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2252 elm_gengrid_item_update(Elm_Object_Item *it)
2254 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2255 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2256 if (!_it->realized) return;
2257 if (_it->want_unrealize) return;
2258 _elm_genlist_item_unrealize(_it, EINA_FALSE);
2260 _item_place(_it, _it->x, _it->y);
2263 EAPI const Elm_Gengrid_Item_Class *
2264 elm_gengrid_item_item_class_get(const Elm_Object_Item *it)
2266 return (Elm_Gengrid_Item_Class *)elm_genlist_item_item_class_get(it);
2270 elm_gengrid_item_item_class_update(Elm_Object_Item *it,
2271 const Elm_Gengrid_Item_Class *itc)
2273 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2274 EINA_SAFETY_ON_NULL_RETURN(itc);
2275 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2276 if (_it->generation < _it->wd->generation) return;
2278 elm_gengrid_item_update(it);
2282 elm_gengrid_item_pos_get(const Elm_Object_Item *it,
2286 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2287 if (x) *x = ((Elm_Gen_Item *)it)->x;
2288 if (y) *y = ((Elm_Gen_Item *)it)->y;
2292 elm_gengrid_multi_select_set(Evas_Object *obj,
2295 ELM_CHECK_WIDTYPE(obj, widtype);
2296 Widget_Data *wd = elm_widget_data_get(obj);
2298 wd->multi = !!multi;
2302 elm_gengrid_multi_select_get(const Evas_Object *obj)
2304 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2305 Widget_Data *wd = elm_widget_data_get(obj);
2306 if (!wd) return EINA_FALSE;
2310 EAPI Elm_Object_Item *
2311 elm_gengrid_selected_item_get(const Evas_Object *obj)
2313 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2314 Widget_Data *wd = elm_widget_data_get(obj);
2315 if (!wd) return NULL;
2316 if (wd->selected) return wd->selected->data;
2320 EAPI const Eina_List *
2321 elm_gengrid_selected_items_get(const Evas_Object *obj)
2323 return elm_genlist_selected_items_get(obj);
2327 elm_gengrid_item_selected_set(Elm_Object_Item *it,
2330 elm_genlist_item_selected_set(it, selected);
2334 elm_gengrid_item_selected_get(const Elm_Object_Item *it)
2336 return elm_genlist_item_selected_get(it);
2340 elm_gengrid_realized_items_get(const Evas_Object *obj)
2342 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2343 Widget_Data *wd = elm_widget_data_get(obj);
2344 Eina_List *list = NULL;
2347 EINA_INLIST_FOREACH(wd->items, it)
2349 if (it->realized) list = eina_list_append(list, (Elm_Object_Item *)it);
2355 elm_gengrid_realized_items_update(Evas_Object *obj)
2357 ELM_CHECK_WIDTYPE(obj, widtype);
2359 Eina_List *list, *l;
2360 Elm_Object_Item *it;
2362 list = elm_gengrid_realized_items_get(obj);
2363 EINA_LIST_FOREACH(list, l, it)
2364 elm_gengrid_item_update(it);
2367 static Evas_Object *
2368 _elm_gengrid_item_label_create(void *data,
2369 Evas_Object *obj __UNUSED__,
2370 Evas_Object *tooltip,
2371 void *it __UNUSED__)
2373 Evas_Object *label = elm_label_add(tooltip);
2376 elm_object_style_set(label, "tooltip");
2377 elm_object_text_set(label, data);
2382 _elm_gengrid_item_label_del_cb(void *data,
2383 Evas_Object *obj __UNUSED__,
2384 void *event_info __UNUSED__)
2386 eina_stringshare_del(data);
2390 elm_gengrid_item_tooltip_text_set(Elm_Object_Item *it,
2393 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2394 text = eina_stringshare_add(text);
2395 elm_gengrid_item_tooltip_content_cb_set(it, _elm_gengrid_item_label_create,
2397 _elm_gengrid_item_label_del_cb);
2401 elm_gengrid_item_tooltip_content_cb_set(Elm_Object_Item *it,
2402 Elm_Tooltip_Item_Content_Cb func,
2404 Evas_Smart_Cb del_cb)
2406 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
2407 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2409 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
2412 if (_it->tooltip.del_cb)
2413 _it->tooltip.del_cb((void *)_it->tooltip.data, WIDGET(_it), _it);
2414 _it->tooltip.content_cb = func;
2415 _it->tooltip.data = data;
2416 _it->tooltip.del_cb = del_cb;
2419 elm_widget_item_tooltip_content_cb_set(_it,
2420 _it->tooltip.content_cb,
2421 _it->tooltip.data, NULL);
2422 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
2423 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
2429 if (del_cb) del_cb((void *)data, NULL, NULL);
2433 elm_gengrid_item_tooltip_unset(Elm_Object_Item *it)
2435 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2436 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2438 if ((VIEW(_it)) && (_it->tooltip.content_cb))
2439 elm_widget_item_tooltip_unset(_it);
2441 if (_it->tooltip.del_cb)
2442 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
2443 _it->tooltip.del_cb = NULL;
2444 _it->tooltip.content_cb = NULL;
2445 _it->tooltip.data = NULL;
2446 _it->tooltip.free_size = EINA_FALSE;
2447 if (_it->tooltip.style)
2448 elm_gengrid_item_tooltip_style_set(it, NULL);
2452 elm_gengrid_item_tooltip_style_set(Elm_Object_Item *it,
2455 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2456 eina_stringshare_replace(&((Elm_Gen_Item *)it)->tooltip.style, style);
2457 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
2461 elm_gengrid_item_tooltip_style_get(const Elm_Object_Item *it)
2463 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2464 return ((Elm_Gen_Item *)it)->tooltip.style;
2468 elm_gengrid_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
2470 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2471 ((Elm_Gen_Item *)it)->tooltip.free_size = disable;
2472 if (VIEW(it)) return elm_widget_item_tooltip_window_mode_set(it, disable);
2477 elm_gengrid_item_tooltip_window_mode_get(const Elm_Object_Item *it)
2479 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2480 return ((Elm_Gen_Item *)it)->tooltip.free_size;
2484 elm_gengrid_item_cursor_set(Elm_Object_Item *it,
2487 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2488 eina_stringshare_replace(&((Elm_Gen_Item *)it)->mouse_cursor, cursor);
2489 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
2493 elm_gengrid_item_cursor_get(const Elm_Object_Item *it)
2495 return elm_widget_item_cursor_get(it);
2499 elm_gengrid_item_cursor_unset(Elm_Object_Item *it)
2501 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2502 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2503 if (!_it->mouse_cursor)
2507 elm_widget_item_cursor_unset(_it);
2509 eina_stringshare_del(_it->mouse_cursor);
2510 _it->mouse_cursor = NULL;
2514 elm_gengrid_item_cursor_style_set(Elm_Object_Item *it,
2517 elm_widget_item_cursor_style_set(it, style);
2521 elm_gengrid_item_cursor_style_get(const Elm_Object_Item *it)
2523 return elm_widget_item_cursor_style_get(it);
2527 elm_gengrid_item_cursor_engine_only_set(Elm_Object_Item *it,
2528 Eina_Bool engine_only)
2530 elm_widget_item_cursor_engine_only_set(it, engine_only);
2534 elm_gengrid_item_cursor_engine_only_get(const Elm_Object_Item *it)
2536 return elm_widget_item_cursor_engine_only_get(it);
2540 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2541 Eina_Bool reorder_mode)
2543 ELM_CHECK_WIDTYPE(obj, widtype);
2544 Widget_Data *wd = elm_widget_data_get(obj);
2546 wd->reorder_mode = !!reorder_mode;
2550 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2552 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2553 Widget_Data *wd = elm_widget_data_get(obj);
2554 if (!wd) return EINA_FALSE;
2555 return wd->reorder_mode;
2559 elm_gengrid_bounce_set(Evas_Object *obj,
2563 elm_genlist_bounce_set(obj, h_bounce, v_bounce);
2567 elm_gengrid_bounce_get(const Evas_Object *obj,
2568 Eina_Bool *h_bounce,
2569 Eina_Bool *v_bounce)
2571 elm_genlist_bounce_get(obj, h_bounce, v_bounce);
2575 elm_gengrid_page_relative_set(Evas_Object *obj,
2579 _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
2583 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2585 _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
2589 elm_gengrid_page_size_set(Evas_Object *obj,
2590 Evas_Coord h_pagesize,
2591 Evas_Coord v_pagesize)
2593 _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
2597 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2599 _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
2603 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2605 _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
2609 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2611 _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
2615 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2617 _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
2621 elm_gengrid_scroller_policy_set(Evas_Object *obj,
2622 Elm_Scroller_Policy policy_h,
2623 Elm_Scroller_Policy policy_v)
2625 ELM_CHECK_WIDTYPE(obj, widtype);
2626 Widget_Data *wd = elm_widget_data_get(obj);
2627 if ((!wd) || (!wd->scr)) return;
2628 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
2629 (policy_v >= ELM_SCROLLER_POLICY_LAST))
2631 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
2635 elm_gengrid_scroller_policy_get(const Evas_Object *obj,
2636 Elm_Scroller_Policy *policy_h,
2637 Elm_Scroller_Policy *policy_v)
2639 ELM_CHECK_WIDTYPE(obj, widtype);
2640 Widget_Data *wd = elm_widget_data_get(obj);
2641 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
2642 if ((!wd) || (!wd->scr)) return;
2643 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
2644 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
2645 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
2648 EAPI Elm_Object_Item *
2649 elm_gengrid_first_item_get(const Evas_Object *obj)
2651 return elm_genlist_first_item_get(obj);
2654 EAPI Elm_Object_Item *
2655 elm_gengrid_last_item_get(const Evas_Object *obj)
2657 return elm_genlist_last_item_get(obj);
2660 EAPI Elm_Object_Item *
2661 elm_gengrid_item_next_get(const Elm_Object_Item *it)
2663 return elm_genlist_item_next_get(it);
2666 EAPI Elm_Object_Item *
2667 elm_gengrid_item_prev_get(const Elm_Object_Item *it)
2669 return elm_genlist_item_prev_get(it);
2673 elm_gengrid_item_show(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
2675 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2676 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2677 Widget_Data *wd = _it->wd;
2678 Evas_Coord minx = 0, miny = 0;
2680 if ((_it->generation < _it->wd->generation)) return;
2681 _pan_min_get(wd->pan_smart, &minx, &miny);
2683 if (type==ELM_GENGRID_ITEM_SCROLLTO_IN)
2685 //TODO : type based handling like genlist
2689 elm_smart_scroller_child_region_show(_it->wd->scr,
2690 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2691 _it->y * wd->item_height + miny,
2692 _it->wd->item_width,
2693 _it->wd->item_height);
2695 elm_smart_scroller_child_region_show(_it->wd->scr,
2696 _it->x * wd->item_width + minx,
2697 ((_it->y - _it->item->prev_group) * wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2698 _it->wd->item_width,
2699 _it->wd->item_height);
2703 elm_gengrid_item_bring_in(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
2705 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2706 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2708 if (_it->generation < _it->wd->generation) return;
2710 Evas_Coord minx = 0, miny = 0;
2711 Widget_Data *wd = _it->wd;
2712 _pan_min_get(wd->pan_smart, &minx, &miny);
2714 if (type==ELM_GENGRID_ITEM_SCROLLTO_IN)
2716 //TODO : type based handling like genlist
2720 elm_smart_scroller_region_bring_in(_it->wd->scr,
2721 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2722 _it->y * wd->item_height + miny,
2723 _it->wd->item_width,
2724 _it->wd->item_height);
2726 elm_smart_scroller_region_bring_in(_it->wd->scr,
2727 _it->x * wd->item_width + minx,
2728 ((_it->y - _it->item->prev_group)* wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2729 _it->wd->item_width,
2730 _it->wd->item_height);
2734 elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill)
2736 ELM_CHECK_WIDTYPE(obj, widtype);
2737 Widget_Data *wd = elm_widget_data_get(obj);
2740 if (wd->filled != fill)
2745 elm_gengrid_filled_get(const Evas_Object *obj)
2747 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2748 Widget_Data *wd = elm_widget_data_get(obj);
2749 if (!wd) return EINA_FALSE;
2754 elm_gengrid_items_count(const Evas_Object *obj)
2756 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2757 Widget_Data *wd = elm_widget_data_get(obj);
2759 return wd->item_count;
2762 EAPI Elm_Gengrid_Item_Class *
2763 elm_gengrid_item_class_new(void)
2765 Elm_Gengrid_Item_Class *itc;
2767 itc = calloc(1, sizeof(Elm_Gengrid_Item_Class));
2770 itc->version = CLASS_ALLOCATED;
2772 itc->delete_me = EINA_FALSE;
2778 elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
2780 if (itc && (itc->version == CLASS_ALLOCATED))
2782 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
2783 if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
2793 elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
2795 if (itc && (itc->version == CLASS_ALLOCATED))
2798 if (itc->refcount == 0) itc->refcount--;
2803 elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
2805 if (itc && (itc->version == CLASS_ALLOCATED))
2807 if (itc->refcount > 0) itc->refcount--;
2808 if (itc->delete_me && (!itc->refcount))
2809 elm_gengrid_item_class_free(itc);
2814 elm_gengrid_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode mode)
2816 elm_genlist_select_mode_set(obj, mode);
2819 EAPI Elm_Object_Select_Mode
2820 elm_gengrid_select_mode_get(const Evas_Object *obj)
2822 return elm_genlist_select_mode_get(obj);
2826 elm_gengrid_highlight_mode_set(Evas_Object *obj,
2827 Eina_Bool highlight)
2829 elm_genlist_highlight_mode_set(obj, highlight);
2833 elm_gengrid_highlight_mode_get(const Evas_Object *obj)
2835 return elm_genlist_highlight_mode_get(obj);
2839 elm_gengrid_item_index_get(const Elm_Object_Item *it)
2841 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, -1);
2842 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2844 return _it->position;
2848 elm_gengrid_item_select_mode_set(Elm_Object_Item *it,
2849 Elm_Object_Select_Mode mode)
2851 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2852 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2854 if (_it->generation < _it->wd->generation) return;
2855 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
2857 if (_it->select_mode != mode)
2858 _it->select_mode = mode;
2860 if (_it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
2861 elm_gengrid_item_update(it);
2864 EAPI Elm_Object_Select_Mode
2865 elm_gengrid_item_select_mode_get(const Elm_Object_Item *it)
2867 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ELM_OBJECT_SELECT_MODE_MAX);
2868 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2869 if (!_it) return ELM_OBJECT_SELECT_MODE_MAX;
2870 return _it->select_mode;