1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 #include "els_scroller.h"
5 #include "elm_gen_common.h"
9 * Handle non-homogeneous objects too.
13 #define REORDER_EFFECT_TIME 0.5
15 #define ELM_GEN_SETUP(wd) \
16 (wd)->calc_cb = (Ecore_Cb)_calc_job
18 #define ELM_GEN_ITEM_SETUP(it) \
19 (it)->del_cb = (Ecore_Cb)_item_del; \
20 (it)->highlight_cb = (Ecore_Cb)_item_highlight; \
21 (it)->unsel_cb = (Ecore_Cb)_item_unselect; \
22 (it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
24 struct Elm_Gen_Item_Type
27 Ecore_Animator *item_moving_effect_timer;
28 Evas_Coord gx, gy, ox, oy, tx, ty, rx, ry;
29 unsigned int moving_effect_start_time;
32 Eina_Bool group_realized : 1;
39 Eina_Inlist_Sorted_State *state;
40 Evas_Object *obj; /* the gengrid object */
41 Evas_Object *scr; /* a smart scroller object which is used internally in genlist */
42 Evas_Object *pan_smart; /* "elm_genlist_pan" evas smart object. this is an extern pan of smart scroller(scr). */
44 Eina_List *group_items; /* list of groups index items */
45 Eina_Inlist *items; /* inlist of all items */
46 Elm_Gen_Item *reorder_it; /* item currently being repositioned */
47 Elm_Gen_Item *last_selected_item;
48 Pan *pan; /* pan_smart object's smart data */
51 int item_width, item_height;
52 int group_item_width, group_item_height;
55 Evas_Coord pan_x, pan_y;
56 Eina_Bool reorder_mode : 1;
57 Eina_Bool on_hold : 1;
59 Eina_Bool no_select : 1;
60 Eina_Bool wasselected : 1;
61 Eina_Bool always_select : 1;
62 Eina_Bool clear_me : 1;
63 Eina_Bool h_bounce : 1;
64 Eina_Bool v_bounce : 1;
65 Ecore_Cb del_cb, calc_cb, sizing_cb;
67 ////////////////////////////////////
68 double align_x, align_y;
70 Evas_Coord old_pan_x, old_pan_y;
71 Evas_Coord reorder_item_x, reorder_item_y;
77 Eina_Bool horizontal : 1;
78 Eina_Bool longpressed : 1;
79 Eina_Bool reorder_item_changed : 1;
80 Eina_Bool move_effect_enabled : 1;
84 static const char *widtype = NULL;
85 static void _item_highlight(Elm_Gen_Item *it);
86 static void _item_unrealize_cb(Elm_Gen_Item *it);
87 static void _item_unselect(Elm_Gen_Item *it);
88 static void _calc_job(void *data);
89 static void _on_focus_hook(void *data,
91 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
92 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
93 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
94 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
95 static Eina_Bool _item_single_select_up(Widget_Data *wd);
96 static Eina_Bool _item_single_select_down(Widget_Data *wd);
97 static Eina_Bool _item_single_select_left(Widget_Data *wd);
98 static Eina_Bool _item_single_select_right(Widget_Data *wd);
99 static Eina_Bool _event_hook(Evas_Object *obj,
101 Evas_Callback_Type type,
103 static Eina_Bool _deselect_all_items(Widget_Data *wd);
105 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
106 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
108 static const char SIG_ACTIVATED[] = "activated";
109 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
110 static const char SIG_LONGPRESSED[] = "longpressed";
111 static const char SIG_SELECTED[] = "selected";
112 static const char SIG_UNSELECTED[] = "unselected";
113 static const char SIG_REALIZED[] = "realized";
114 static const char SIG_UNREALIZED[] = "unrealized";
115 static const char SIG_CHANGED[] = "changed";
116 static const char SIG_DRAG_START_UP[] = "drag,start,up";
117 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
118 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
119 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
120 static const char SIG_DRAG_STOP[] = "drag,stop";
121 static const char SIG_DRAG[] = "drag";
122 static const char SIG_SCROLL[] = "scroll";
123 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
124 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
125 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
126 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
127 static const char SIG_EDGE_TOP[] = "edge,top";
128 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
129 static const char SIG_EDGE_LEFT[] = "edge,left";
130 static const char SIG_EDGE_RIGHT[] = "edge,right";
131 static const char SIG_MOVED[] = "moved";
133 static const Evas_Smart_Cb_Description _signals[] = {
135 {SIG_CLICKED_DOUBLE, ""},
136 {SIG_LONGPRESSED, ""},
138 {SIG_UNSELECTED, ""},
140 {SIG_UNREALIZED, ""},
142 {SIG_DRAG_START_UP, ""},
143 {SIG_DRAG_START_DOWN, ""},
144 {SIG_DRAG_START_LEFT, ""},
145 {SIG_DRAG_START_RIGHT, ""},
149 {SIG_SCROLL_ANIM_START, ""},
150 {SIG_SCROLL_ANIM_STOP, ""},
151 {SIG_SCROLL_DRAG_START, ""},
152 {SIG_SCROLL_DRAG_STOP, ""},
154 {SIG_EDGE_BOTTOM, ""},
156 {SIG_EDGE_RIGHT, ""},
162 _event_hook(Evas_Object *obj,
163 Evas_Object *src __UNUSED__,
164 Evas_Callback_Type type,
167 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
168 Evas_Event_Key_Down *ev = event_info;
169 Widget_Data *wd = elm_widget_data_get(obj);
170 if (!wd) return EINA_FALSE;
171 if (!wd->items) return EINA_FALSE;
172 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
173 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
175 Elm_Object_Item *it = NULL;
178 Evas_Coord step_x = 0;
179 Evas_Coord step_y = 0;
182 Evas_Coord page_x = 0;
183 Evas_Coord page_y = 0;
185 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
186 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
187 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
188 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
190 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
192 if ((wd->horizontal) &&
193 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
194 (_item_multi_select_up(wd)))
195 || (_item_single_select_up(wd))))
197 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
200 else if ((!wd->horizontal) &&
201 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
202 (_item_multi_select_left(wd)))
203 || (_item_single_select_left(wd))))
205 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
211 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
213 if ((wd->horizontal) &&
214 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
215 (_item_multi_select_down(wd)))
216 || (_item_single_select_down(wd))))
218 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
221 else if ((!wd->horizontal) &&
222 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
223 (_item_multi_select_right(wd)))
224 || (_item_single_select_right(wd))))
226 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
232 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
234 if ((wd->horizontal) &&
235 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
236 (_item_multi_select_left(wd)))
237 || (_item_single_select_left(wd))))
239 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
242 else if ((!wd->horizontal) &&
243 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
244 (_item_multi_select_up(wd)))
245 || (_item_single_select_up(wd))))
247 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
253 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
255 if ((wd->horizontal) &&
256 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
257 (_item_multi_select_right(wd)))
258 || (_item_single_select_right(wd))))
260 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
263 else if ((!wd->horizontal) &&
264 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
265 (_item_multi_select_down(wd)))
266 || (_item_single_select_down(wd))))
268 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
274 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
276 it = elm_gengrid_first_item_get(obj);
277 elm_gengrid_item_bring_in(it);
278 elm_gengrid_item_selected_set(it, EINA_TRUE);
279 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
282 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
284 it = elm_gengrid_last_item_get(obj);
285 elm_gengrid_item_bring_in(it);
286 elm_gengrid_item_selected_set(it, EINA_TRUE);
287 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
290 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
295 x -= -(page_x * v_w) / 100;
302 y -= -(page_y * v_h) / 100;
307 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
312 x += -(page_x * v_w) / 100;
319 y += -(page_y * v_h) / 100;
324 else if (!strcmp(ev->keyname, "Escape"))
326 if (!_deselect_all_items(wd)) return EINA_FALSE;
327 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
330 else if (((!strcmp(ev->keyname, "Return")) ||
331 (!strcmp(ev->keyname, "KP_Enter")) ||
332 (!strcmp(ev->keyname, "space")))
333 && (!wd->multi) && (wd->selected))
335 it = elm_gengrid_selected_item_get(obj);
336 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
338 else return EINA_FALSE;
340 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
341 elm_smart_scroller_child_pos_set(wd->scr, x, y);
346 _deselect_all_items(Widget_Data *wd)
348 if (!wd->selected) return EINA_FALSE;
350 elm_gengrid_item_selected_set((Elm_Object_Item *) wd->selected->data,
357 _item_multi_select_left(Widget_Data *wd)
359 if (!wd->selected) return EINA_FALSE;
361 Elm_Object_Item *prev =
362 elm_gengrid_item_prev_get(wd->last_selected_item);
363 if (!prev) return EINA_TRUE;
364 if (elm_gengrid_item_selected_get(prev))
366 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
367 wd->last_selected_item = prev;
368 elm_gengrid_item_show(wd->last_selected_item);
372 elm_gengrid_item_selected_set(prev, EINA_TRUE);
373 elm_gengrid_item_show(prev);
380 _item_multi_select_right(Widget_Data *wd)
382 if (!wd->selected) return EINA_FALSE;
384 Elm_Object_Item *next =
385 elm_gengrid_item_next_get(wd->last_selected_item);
386 if (!next) return EINA_TRUE;
387 if (elm_gengrid_item_selected_get(next))
389 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
390 wd->last_selected_item = next;
391 elm_gengrid_item_show(wd->last_selected_item);
395 elm_gengrid_item_selected_set(next, EINA_TRUE);
396 elm_gengrid_item_show(next);
403 _item_multi_select_up(Widget_Data *wd)
406 Eina_Bool r = EINA_TRUE;
408 if (!wd->selected) return EINA_FALSE;
410 for (i = 0; (r) && (i < wd->nmax); i++)
411 r &= _item_multi_select_left(wd);
417 _item_multi_select_down(Widget_Data *wd)
420 Eina_Bool r = EINA_TRUE;
422 if (!wd->selected) return EINA_FALSE;
424 for (i = 0; (r) && (i < wd->nmax); i++)
425 r &= _item_multi_select_right(wd);
431 _item_single_select_up(Widget_Data *wd)
439 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
440 while ((prev) && (prev->generation < wd->generation))
441 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
442 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
443 elm_gengrid_item_show((Elm_Object_Item *) prev);
447 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
449 if (!prev) return EINA_FALSE;
451 for (i = 1; i < wd->nmax; i++)
453 Elm_Object_Item *tmp =
454 elm_gengrid_item_prev_get((Elm_Object_Item *) prev);
455 if (!tmp) return EINA_FALSE;
456 prev = (Elm_Gen_Item *) tmp;
459 _deselect_all_items(wd);
461 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
462 elm_gengrid_item_show((Elm_Object_Item *) prev);
467 _item_single_select_down(Widget_Data *wd)
475 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
476 while ((next) && (next->generation < wd->generation))
477 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
478 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
479 elm_gengrid_item_show((Elm_Object_Item *) next);
483 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
485 if (!next) return EINA_FALSE;
487 for (i = 1; i < wd->nmax; i++)
489 Elm_Object_Item *tmp =
490 elm_gengrid_item_next_get((Elm_Object_Item *) next);
491 if (!tmp) return EINA_FALSE;
492 next = (Elm_Gen_Item *) tmp;
495 _deselect_all_items(wd);
497 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
498 elm_gengrid_item_show((Elm_Object_Item *) next);
503 _item_single_select_left(Widget_Data *wd)
508 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
509 while ((prev) && (prev->generation < wd->generation))
510 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
513 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
515 if (!prev) return EINA_FALSE;
517 _deselect_all_items(wd);
519 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
520 elm_gengrid_item_show((Elm_Object_Item *) prev);
525 _item_single_select_right(Widget_Data *wd)
530 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
531 while ((next) && (next->generation < wd->generation))
532 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
535 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
537 if (!next) return EINA_FALSE;
539 _deselect_all_items(wd);
541 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
542 elm_gengrid_item_show((Elm_Object_Item *) next);
547 _on_focus_hook(void *data __UNUSED__,
550 Widget_Data *wd = elm_widget_data_get(obj);
552 if (elm_widget_focus_get(obj))
554 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
555 evas_object_focus_set(wd->obj, EINA_TRUE);
556 if ((wd->selected) && (!wd->last_selected_item))
557 wd->last_selected_item = eina_list_data_get(wd->selected);
561 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
562 evas_object_focus_set(wd->obj, EINA_FALSE);
567 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
569 Widget_Data *wd = elm_widget_data_get(obj);
572 elm_smart_scroller_mirrored_set(wd->scr, rtl);
573 if (!wd->items) return;
574 it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
578 edje_object_mirrored_set(VIEW(it), rtl);
579 elm_gengrid_item_update((Elm_Object_Item *) it);
580 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
585 _theme_hook(Evas_Object *obj)
587 Widget_Data *wd = elm_widget_data_get(obj);
589 _elm_widget_mirrored_reload(obj);
590 _mirrored_set(obj, elm_widget_mirrored_get(obj));
591 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
592 elm_widget_style_get(obj));
596 _del_pre_hook(Evas_Object *obj)
598 Widget_Data *wd = elm_widget_data_get(obj);
600 elm_gengrid_clear(obj);
601 evas_object_del(wd->pan_smart);
602 wd->pan_smart = NULL;
606 _del_hook(Evas_Object *obj)
608 Widget_Data *wd = elm_widget_data_get(obj);
609 if (wd->calc_job) ecore_job_del(wd->calc_job);
614 _signal_emit_hook(Evas_Object *obj,
615 const char *emission,
618 Widget_Data *wd = elm_widget_data_get(obj);
620 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
625 _signal_callback_add_hook(Evas_Object *obj,
626 const char *emission,
628 Edje_Signal_Cb func_cb,
631 Widget_Data *wd = elm_widget_data_get(obj);
633 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
634 emission, source, func_cb, data);
638 _signal_callback_del_hook(Evas_Object *obj,
639 const char *emission,
641 Edje_Signal_Cb func_cb,
644 Widget_Data *wd = elm_widget_data_get(obj);
646 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scr),
647 emission, source, func_cb, data);
651 _mouse_move(void *data,
652 Evas *evas __UNUSED__,
656 Elm_Gen_Item *it = data;
657 Evas_Event_Mouse_Move *ev = event_info;
658 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
659 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
661 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
663 if (!it->wd->on_hold)
665 it->wd->on_hold = EINA_TRUE;
666 if (!it->wd->wasselected)
670 if ((it->dragging) && (it->down))
674 ecore_timer_del(it->long_timer);
675 it->long_timer = NULL;
677 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
680 if ((!it->down) || (it->wd->longpressed))
684 ecore_timer_del(it->long_timer);
685 it->long_timer = NULL;
687 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
689 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
691 it_scrl_x = ev->cur.canvas.x - it->wd->reorder_it->dx;
692 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
694 if (it_scrl_x < ox) it->wd->reorder_item_x = ox;
695 else if (it_scrl_x + it->wd->item_width > ox + ow)
696 it->wd->reorder_item_x = ox + ow - it->wd->item_width;
697 else it->wd->reorder_item_x = it_scrl_x;
699 if (it_scrl_y < oy) it->wd->reorder_item_y = oy;
700 else if (it_scrl_y + it->wd->item_height > oy + oh)
701 it->wd->reorder_item_y = oy + oh - it->wd->item_height;
702 else it->wd->reorder_item_y = it_scrl_y;
704 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
705 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
709 if (!it->display_only)
710 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
711 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
712 x = ev->cur.canvas.x - x;
713 y = ev->cur.canvas.y - y;
716 if (adx < 0) adx = -dx;
719 if (ady < 0) ady = -dy;
722 if ((adx > minw) || (ady > minh))
724 const char *left_drag, *right_drag;
725 if (!elm_widget_mirrored_get(WIDGET(it)))
727 left_drag = SIG_DRAG_START_LEFT;
728 right_drag = SIG_DRAG_START_RIGHT;
732 left_drag = SIG_DRAG_START_RIGHT;
733 right_drag = SIG_DRAG_START_LEFT;
739 ecore_timer_del(it->long_timer);
740 it->long_timer = NULL;
742 if (!it->wd->wasselected)
747 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_START_UP,
752 evas_object_smart_callback_call(WIDGET(it),
759 evas_object_smart_callback_call(WIDGET(it),
760 SIG_DRAG_START_DOWN, it);
764 evas_object_smart_callback_call(WIDGET(it),
767 evas_object_smart_callback_call(WIDGET(it),
775 _long_press(void *data)
777 Elm_Gen_Item *it = data;
779 it->long_timer = NULL;
780 if (elm_widget_item_disabled_get(it)|| (it->dragging))
781 return ECORE_CALLBACK_CANCEL;
782 it->wd->longpressed = EINA_TRUE;
783 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
784 if (it->wd->reorder_mode)
786 it->wd->reorder_it = it;
787 evas_object_raise(VIEW(it));
788 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
789 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
790 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
792 return ECORE_CALLBACK_CANCEL;
796 _mouse_down(void *data,
797 Evas *evas __UNUSED__,
801 Elm_Gen_Item *it = data;
802 Evas_Event_Mouse_Down *ev = event_info;
805 if (ev->button != 1) return;
808 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
809 it->dx = ev->canvas.x - x;
810 it->dy = ev->canvas.y - y;
811 it->wd->longpressed = EINA_FALSE;
812 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
813 else it->wd->on_hold = EINA_FALSE;
814 if (it->wd->on_hold) return;
815 it->wd->wasselected = it->selected;
817 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
819 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
820 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
822 if (it->long_timer) ecore_timer_del(it->long_timer);
824 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
827 it->long_timer = NULL;
831 _mouse_up(void *data,
832 Evas *evas __UNUSED__,
833 Evas_Object *obj __UNUSED__,
836 Elm_Gen_Item *it = data;
837 Evas_Event_Mouse_Up *ev = event_info;
838 Eina_Bool dragged = EINA_FALSE;
840 if (ev->button != 1) return;
841 it->down = EINA_FALSE;
842 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
843 else it->wd->on_hold = EINA_FALSE;
846 ecore_timer_del(it->long_timer);
847 it->long_timer = NULL;
851 it->dragging = EINA_FALSE;
852 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
857 it->wd->longpressed = EINA_FALSE;
858 it->wd->on_hold = EINA_FALSE;
861 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
863 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it->wd->reorder_it);
864 it->wd->reorder_it = NULL;
865 it->wd->move_effect_enabled = EINA_FALSE;
866 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
867 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
869 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
870 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
871 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
873 if (it->wd->longpressed)
875 it->wd->longpressed = EINA_FALSE;
876 if (!it->wd->wasselected) _item_unselect(it);
877 it->wd->wasselected = EINA_FALSE;
882 if (it->want_unrealize)
883 _elm_genlist_item_unrealize(it, EINA_FALSE);
885 if (elm_widget_item_disabled_get(it) || (dragged)) return;
893 else _item_unselect(it);
899 while (it->wd->selected)
900 _item_unselect(it->wd->selected->data);
904 const Eina_List *l, *l_next;
907 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, item2)
908 if (item2 != it) _item_unselect(item2);
916 _item_highlight(Elm_Gen_Item *it)
918 if ((it->wd->no_select) || (it->generation < it->wd->generation) || (it->highlighted)) return;
919 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
920 it->highlighted = EINA_TRUE;
924 _item_realize(Elm_Gen_Item *it)
929 if ((it->realized) || (it->generation < it->wd->generation)) return;
930 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
931 edje_object_scale_set(VIEW(it), elm_widget_scale_get(WIDGET(it)) *
933 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
934 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
935 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
936 snprintf(style, sizeof(style), "item/%s",
937 it->itc->item_style ? it->itc->item_style : "default");
938 _elm_theme_object_set(WIDGET(it), VIEW(it), "gengrid", style,
939 elm_widget_style_get(WIDGET(it)));
941 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
942 evas_object_color_set(it->spacer, 0, 0, 0, 0);
943 elm_widget_sub_object_add(WIDGET(it), it->spacer);
944 evas_object_size_hint_min_set(it->spacer, 2 * _elm_config->scale, 1);
945 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
947 if (it->itc->func.text_get)
953 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
955 EINA_LIST_FOREACH(it->texts, l, key)
957 char *s = it->itc->func.text_get
958 ((void *)it->base.data, WIDGET(it), key);
961 edje_object_part_text_set(VIEW(it), key, s);
967 if (it->itc->func.content_get)
971 Evas_Object *ic = NULL;
974 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
976 EINA_LIST_FOREACH(it->contents, l, key)
978 if (it->itc->func.content_get)
979 ic = it->itc->func.content_get
980 ((void *)it->base.data, WIDGET(it), key);
983 it->content_objs = eina_list_append(it->content_objs, ic);
984 edje_object_part_swallow(VIEW(it), key, ic);
985 evas_object_show(ic);
986 elm_widget_sub_object_add(WIDGET(it), ic);
991 if (it->itc->func.state_get)
997 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
999 EINA_LIST_FOREACH(it->states, l, key)
1001 Eina_Bool on = it->itc->func.state_get
1002 ((void *)it->base.data, WIDGET(it), l->data);
1005 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1006 edje_object_signal_emit(VIEW(it), buf, "elm");
1013 if ((!it->wd->group_item_width) && (!it->wd->group_item_height))
1015 edje_object_size_min_restricted_calc(VIEW(it),
1016 &it->wd->group_item_width,
1017 &it->wd->group_item_height,
1018 it->wd->group_item_width,
1019 it->wd->group_item_height);
1024 if ((!it->wd->item_width) && (!it->wd->item_height))
1026 edje_object_size_min_restricted_calc(VIEW(it),
1027 &it->wd->item_width,
1028 &it->wd->item_height,
1030 it->wd->item_height);
1031 elm_coords_finger_size_adjust(1, &it->wd->item_width,
1032 1, &it->wd->item_height);
1035 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1037 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1039 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1043 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1044 if (elm_widget_item_disabled_get(it))
1045 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1047 evas_object_show(VIEW(it));
1049 if (it->tooltip.content_cb)
1051 elm_widget_item_tooltip_content_cb_set(it,
1052 it->tooltip.content_cb,
1053 it->tooltip.data, NULL);
1054 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1055 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
1058 if (it->mouse_cursor)
1059 elm_widget_item_cursor_set(it, it->mouse_cursor);
1061 it->realized = EINA_TRUE;
1062 it->want_unrealize = EINA_FALSE;
1066 _item_unrealize_cb(Elm_Gen_Item *it)
1068 evas_object_del(VIEW(it));
1070 evas_object_del(it->spacer);
1075 _reorder_item_moving_effect_timer_cb(void *data)
1077 Elm_Gen_Item *it = data;
1081 tt = REORDER_EFFECT_TIME;
1082 t = ((0.0 > (t = ecore_loop_time_get()-it->item->moving_effect_start_time)) ? 0.0 : t);
1083 dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
1084 dy = ((it->item->ty - it->item->oy) / 10) * _elm_config->scale;
1088 it->item->rx += (1 * sin((t / tt) * (M_PI / 2)) * dx);
1089 it->item->ry += (1 * sin((t / tt) * (M_PI / 2)) * dy);
1097 if ((((dx > 0) && (it->item->rx >= it->item->tx)) || ((dx <= 0) && (it->item->rx <= it->item->tx))) &&
1098 (((dy > 0) && (it->item->ry >= it->item->ty)) || ((dy <= 0) && (it->item->ry <= it->item->ty))))
1100 evas_object_move(VIEW(it), it->item->tx, it->item->ty);
1104 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1105 if (it->wd->horizontal)
1106 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1108 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1111 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1112 it->item->moving = EINA_FALSE;
1113 it->item->item_moving_effect_timer = NULL;
1114 return ECORE_CALLBACK_CANCEL;
1117 evas_object_move(VIEW(it), it->item->rx, it->item->ry);
1121 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1122 if (it->wd->horizontal)
1123 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1125 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1128 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1130 return ECORE_CALLBACK_RENEW;
1134 _group_item_place(Pan *sd)
1136 Evas_Coord iw, ih, vw, vh;
1138 Eina_Bool was_realized;
1140 evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1141 if (sd->wd->horizontal)
1143 iw = sd->wd->group_item_width;
1149 ih = sd->wd->group_item_height;
1151 EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1153 was_realized = it->realized;
1154 if (it->item->group_realized)
1158 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1159 evas_object_move(VIEW(it), it->item->gx, it->item->gy);
1160 evas_object_resize(VIEW(it), iw, ih);
1161 evas_object_raise(VIEW(it));
1164 _elm_genlist_item_unrealize(it, EINA_FALSE);
1170 _item_place(Elm_Gen_Item *it,
1174 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1175 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1176 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1180 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &vw, &vh);
1182 /* Preload rows/columns at each side of the Gengrid */
1183 cvx = ox - PRELOAD * it->wd->item_width;
1184 cvy = oy - PRELOAD * it->wd->item_height;
1185 cvw = vw + 2 * PRELOAD * it->wd->item_width;
1186 cvh = vh + 2 * PRELOAD * it->wd->item_height;
1191 items_count = it->wd->item_count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
1192 if (it->wd->horizontal)
1194 int columns, items_visible = 0, items_row;
1196 if (it->wd->item_height > 0)
1197 items_visible = vh / it->wd->item_height;
1198 if (items_visible < 1)
1201 columns = items_count / items_visible;
1202 if (items_count % items_visible)
1205 tcw = (it->wd->item_width * columns) + (it->wd->group_item_width * eina_list_count(it->wd->group_items));
1206 alignw = (vw - tcw) * it->wd->align_x;
1208 items_row = items_visible;
1209 if ((unsigned int)items_row > it->wd->item_count)
1210 items_row = it->wd->item_count;
1212 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1213 tch = it->wd->nmax * it->wd->item_height;
1215 tch = items_row * it->wd->item_height;
1216 alignh = (vh - tch) * it->wd->align_y;
1220 unsigned int rows, items_visible = 0, items_col;
1222 if (it->wd->item_width > 0)
1223 items_visible = vw / it->wd->item_width;
1224 if (items_visible < 1)
1227 rows = items_count / items_visible;
1228 if (items_count % items_visible)
1231 tch = (it->wd->item_height * rows) + (it->wd->group_item_height * eina_list_count(it->wd->group_items));
1232 alignh = (vh - tch) * it->wd->align_y;
1234 items_col = items_visible;
1235 if (items_col > it->wd->item_count)
1236 items_col = it->wd->item_count;
1238 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1239 tcw = it->wd->nmax * it->wd->item_width;
1241 tcw = items_col * it->wd->item_width;
1242 alignw = (vw - tcw) * it->wd->align_x;
1247 if (it->wd->horizontal)
1249 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;
1251 iw = it->wd->group_item_width;
1257 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;
1259 ih = it->wd->group_item_height;
1266 if (it->wd->horizontal)
1268 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;
1269 y = (cy * it->wd->item_height) - it->wd->pan_y + oy + alignh;
1273 x = (cx * it->wd->item_width) - it->wd->pan_x + ox + alignw;
1274 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;
1276 if (elm_widget_mirrored_get(WIDGET(it)))
1277 { /* Switch items side and componsate for pan_x when in RTL mode */
1278 evas_object_geometry_get(WIDGET(it), NULL, NULL, &ww, NULL);
1279 x = ww - x - it->wd->item_width - it->wd->pan_x - it->wd->pan_x;
1281 iw = it->wd->item_width;
1282 ih = it->wd->item_height;
1285 Eina_Bool was_realized = it->realized;
1286 if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1290 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1293 if (it->wd->horizontal)
1295 if (it->parent->item->gx < ox)
1297 it->parent->item->gx = x + it->wd->item_width - it->wd->group_item_width;
1298 if (it->parent->item->gx > ox)
1299 it->parent->item->gx = ox;
1301 it->parent->item->group_realized = EINA_TRUE;
1305 if (it->parent->item->gy < oy)
1307 it->parent->item->gy = y + it->wd->item_height - it->wd->group_item_height;
1308 if (it->parent->item->gy > oy)
1309 it->parent->item->gy = oy;
1311 it->parent->item->group_realized = EINA_TRUE;
1314 if (it->wd->reorder_mode)
1316 if (it->wd->reorder_it)
1318 if (it->item->moving) return;
1320 if (!it->wd->move_effect_enabled)
1325 if (it->wd->reorder_it == it)
1327 evas_object_move(VIEW(it),
1328 it->wd->reorder_item_x, it->wd->reorder_item_y);
1329 evas_object_resize(VIEW(it), iw, ih);
1334 if (it->wd->move_effect_enabled)
1336 if ((it->item->ox != x) || (it->item->oy != y))
1338 if (((it->wd->old_pan_x == it->wd->pan_x) && (it->wd->old_pan_y == it->wd->pan_y)) ||
1339 ((it->wd->old_pan_x != it->wd->pan_x) && !(it->item->ox - it->wd->pan_x + it->wd->old_pan_x == x)) ||
1340 ((it->wd->old_pan_y != it->wd->pan_y) && !(it->item->oy - it->wd->pan_y + it->wd->old_pan_y == y)))
1344 it->item->rx = it->item->ox;
1345 it->item->ry = it->item->oy;
1346 it->item->moving = EINA_TRUE;
1347 it->item->moving_effect_start_time = ecore_loop_time_get();
1348 it->item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
1355 Evas_Coord nx, ny, nw, nh;
1358 if (it->wd->horizontal)
1360 nx = x + (it->wd->group_item_width / 2);
1368 ny = y + (it->wd->group_item_height / 2);
1375 nx = x + (it->wd->item_width / 2);
1376 ny = y + (it->wd->item_height / 2);
1381 if ( ELM_RECTS_INTERSECT(it->wd->reorder_item_x, it->wd->reorder_item_y,
1382 it->wd->item_width, it->wd->item_height,
1385 if (it->wd->horizontal)
1387 if ((it->wd->nmax * it->wd->reorder_it->x + it->wd->reorder_it->y) >
1388 (it->wd->nmax * it->x + it->y))
1389 reorder_item_move_forward = EINA_TRUE;
1393 if ((it->wd->nmax * it->wd->reorder_it->y + it->wd->reorder_it->x) >
1394 (it->wd->nmax * it->y + it->x))
1395 reorder_item_move_forward = EINA_TRUE;
1398 it->wd->items = eina_inlist_remove(it->wd->items,
1399 EINA_INLIST_GET(it->wd->reorder_it));
1400 if (reorder_item_move_forward)
1401 it->wd->items = eina_inlist_prepend_relative(it->wd->items,
1402 EINA_INLIST_GET(it->wd->reorder_it),
1403 EINA_INLIST_GET(it));
1405 it->wd->items = eina_inlist_append_relative(it->wd->items,
1406 EINA_INLIST_GET(it->wd->reorder_it),
1407 EINA_INLIST_GET(it));
1409 it->wd->reorder_item_changed = EINA_TRUE;
1410 it->wd->move_effect_enabled = EINA_TRUE;
1411 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1412 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1418 else if (it->item->item_moving_effect_timer)
1420 ecore_animator_del(it->item->item_moving_effect_timer);
1421 it->item->item_moving_effect_timer = NULL;
1422 it->item->moving = EINA_FALSE;
1427 evas_object_move(VIEW(it), x, y);
1428 evas_object_resize(VIEW(it), iw, ih);
1431 it->item->group_realized = EINA_TRUE;
1436 _elm_genlist_item_unrealize(it, EINA_FALSE);
1438 it->item->group_realized = EINA_FALSE;
1443 _item_del(Elm_Gen_Item *it)
1445 Evas_Object *obj = WIDGET(it);
1447 evas_event_freeze(evas_object_evas_get(obj));
1448 it->wd->selected = eina_list_remove(it->wd->selected, it);
1449 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
1450 it->wd->item_count--;
1451 _elm_genlist_item_del_serious(it);
1452 elm_gengrid_item_class_unref((Elm_Gengrid_Item_Class *)it->itc);
1453 evas_event_thaw(evas_object_evas_get(obj));
1454 evas_event_thaw_eval(evas_object_evas_get(obj));
1458 _item_unselect(Elm_Gen_Item *it)
1460 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
1461 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
1462 it->highlighted = EINA_FALSE;
1465 it->selected = EINA_FALSE;
1466 it->wd->selected = eina_list_remove(it->wd->selected, it);
1467 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
1472 _calc_job(void *data)
1474 Widget_Data *wd = data;
1475 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1476 Elm_Gen_Item *it, *group_item = NULL;
1477 int count_group = 0;
1481 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1482 if ((cvw != 0) || (cvh != 0))
1484 if ((wd->horizontal) && (wd->item_height > 0))
1485 nmax = cvh / wd->item_height;
1486 else if (wd->item_width > 0)
1487 nmax = cvw / wd->item_width;
1492 EINA_INLIST_FOREACH(wd->items, it)
1494 if (it->item->prev_group != count_group)
1495 it->item->prev_group = count_group;
1498 count = count % nmax;
1500 wd->items_lost += nmax - count;
1501 //printf("%d items and I lost %d\n", count, wd->items_lost);
1503 if (count) count = 0;
1508 if (it->parent != group_item)
1509 it->parent = group_item;
1513 count = wd->item_count + wd->items_lost - count_group;
1516 minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width);
1517 minh = nmax * wd->item_height;
1521 minw = nmax * wd->item_width;
1522 minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1525 if ((minw != wd->minw) || (minh != wd->minh))
1529 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1533 evas_object_smart_changed(wd->pan_smart);
1535 wd->calc_job = NULL;
1539 _pan_add(Evas_Object *obj)
1542 Evas_Object_Smart_Clipped_Data *cd;
1545 cd = evas_object_smart_data_get(obj);
1548 sd->__clipped_data = *cd;
1550 evas_object_smart_data_set(obj, sd);
1554 _pan_del(Evas_Object *obj)
1556 Pan *sd = evas_object_smart_data_get(obj);
1563 _pan_set(Evas_Object *obj,
1567 Pan *sd = evas_object_smart_data_get(obj);
1568 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1571 evas_object_smart_changed(obj);
1575 _pan_get(Evas_Object *obj,
1579 Pan *sd = evas_object_smart_data_get(obj);
1580 if (x) *x = sd->wd->pan_x;
1581 if (y) *y = sd->wd->pan_y;
1585 _pan_child_size_get(Evas_Object *obj,
1589 Pan *sd = evas_object_smart_data_get(obj);
1590 if (w) *w = sd->wd->minw;
1591 if (h) *h = sd->wd->minh;
1595 _pan_max_get(Evas_Object *obj,
1599 Pan *sd = evas_object_smart_data_get(obj);
1603 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1605 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1607 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1611 _pan_min_get(Evas_Object *obj,
1615 Pan *sd = evas_object_smart_data_get(obj);
1616 Evas_Coord mx = 0, my = 0;
1619 _pan_max_get(obj, &mx, &my);
1621 *x = -mx * sd->wd->align_x;
1623 *y = -my * sd->wd->align_y;
1627 _pan_resize(Evas_Object *obj,
1631 Pan *sd = evas_object_smart_data_get(obj);
1634 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1635 if ((ow == w) && (oh == h)) return;
1636 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1637 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1641 _pan_calculate(Evas_Object *obj)
1643 Pan *sd = evas_object_smart_data_get(obj);
1644 Evas_Coord cx = 0, cy = 0;
1648 if (!sd->wd->nmax) return;
1650 sd->wd->reorder_item_changed = EINA_FALSE;
1652 EINA_INLIST_FOREACH(sd->wd->items, it)
1656 if (sd->wd->horizontal)
1673 _item_place(it, cx, cy);
1674 if (sd->wd->reorder_item_changed) return;
1677 if (sd->wd->horizontal)
1690 if (sd->wd->horizontal)
1692 cy = (cy + 1) % sd->wd->nmax;
1697 cx = (cx + 1) % sd->wd->nmax;
1702 _group_item_place(sd);
1705 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
1707 if (!sd->wd->reorder_item_changed)
1709 sd->wd->old_pan_x = sd->wd->pan_x;
1710 sd->wd->old_pan_y = sd->wd->pan_y;
1712 sd->wd->move_effect_enabled = EINA_FALSE;
1714 evas_object_smart_callback_call(sd->wd->obj, SIG_CHANGED, NULL);
1718 _pan_move(Evas_Object *obj,
1719 Evas_Coord x __UNUSED__,
1720 Evas_Coord y __UNUSED__)
1722 Pan *sd = evas_object_smart_data_get(obj);
1724 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1725 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1729 _hold_on(void *data __UNUSED__,
1731 void *event_info __UNUSED__)
1733 Widget_Data *wd = elm_widget_data_get(obj);
1735 elm_smart_scroller_hold_set(wd->scr, 1);
1739 _hold_off(void *data __UNUSED__,
1741 void *event_info __UNUSED__)
1743 Widget_Data *wd = elm_widget_data_get(obj);
1745 elm_smart_scroller_hold_set(wd->scr, 0);
1749 _freeze_on(void *data __UNUSED__,
1751 void *event_info __UNUSED__)
1753 Widget_Data *wd = elm_widget_data_get(obj);
1755 elm_smart_scroller_freeze_set(wd->scr, 1);
1759 _freeze_off(void *data __UNUSED__,
1761 void *event_info __UNUSED__)
1763 Widget_Data *wd = elm_widget_data_get(obj);
1765 elm_smart_scroller_freeze_set(wd->scr, 0);
1769 _scr_anim_start(void *data,
1770 Evas_Object *obj __UNUSED__,
1771 void *event_info __UNUSED__)
1773 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1777 _scr_anim_stop(void *data,
1778 Evas_Object *obj __UNUSED__,
1779 void *event_info __UNUSED__)
1781 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1785 _scr_drag_start(void *data,
1786 Evas_Object *obj __UNUSED__,
1787 void *event_info __UNUSED__)
1789 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1793 _scr_drag_stop(void *data,
1794 Evas_Object *obj __UNUSED__,
1795 void *event_info __UNUSED__)
1797 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1801 _edge_left(void *data,
1802 Evas_Object *scr __UNUSED__,
1803 void *event_info __UNUSED__)
1805 evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
1809 _edge_right(void *data,
1810 Evas_Object *scr __UNUSED__,
1811 void *event_info __UNUSED__)
1813 evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
1817 _edge_top(void *data,
1818 Evas_Object *scr __UNUSED__,
1819 void *event_info __UNUSED__)
1821 evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
1825 _edge_bottom(void *data,
1826 Evas_Object *scr __UNUSED__,
1827 void *event_info __UNUSED__)
1829 evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
1833 _scr_scroll(void *data,
1834 Evas_Object *obj __UNUSED__,
1835 void *event_info __UNUSED__)
1837 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1841 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1843 const Elm_Gen_Item *it = data;
1844 const Elm_Gen_Item *item1 = data1;
1846 return it->wd->item_compare_data_cb(it->base.data, item1->base.data);
1850 _elm_gengrid_item_compare(const void *data, const void *data1)
1852 Elm_Gen_Item *it, *item1;
1853 it = ELM_GEN_ITEM_FROM_INLIST(data);
1854 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
1855 return it->wd->item_compare_cb(it, item1);
1859 _item_disable_hook(Elm_Object_Item *it)
1861 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
1863 if (_it->generation < _it->wd->generation) return;
1867 if (elm_widget_item_disabled_get(_it))
1868 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
1870 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
1875 _item_del_pre_hook(Elm_Object_Item *it)
1877 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
1878 if ((_it->relcount > 0) || (_it->walking > 0))
1880 _elm_genlist_item_del_notserious(_it);
1887 static Elm_Gen_Item *
1888 _item_new(Widget_Data *wd,
1889 const Elm_Gengrid_Item_Class *itc,
1892 const void *func_data)
1896 it = _elm_genlist_item_new(wd, itc, data, NULL, func, func_data);
1897 if (!it) return NULL;
1898 elm_widget_item_disable_hook_set(it, _item_disable_hook);
1899 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
1900 elm_gengrid_item_class_ref((Elm_Gengrid_Item_Class *)itc);
1901 it->item = ELM_NEW(Elm_Gen_Item_Type);
1903 it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
1904 ELM_GEN_ITEM_SETUP(it);
1910 elm_gengrid_add(Evas_Object *parent)
1915 static Evas_Smart *smart = NULL;
1916 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1920 static Evas_Smart_Class sc;
1922 evas_object_smart_clipped_smart_set(&_pan_sc);
1924 sc.name = "elm_gengrid_pan";
1925 sc.version = EVAS_SMART_CLASS_VERSION;
1928 sc.resize = _pan_resize;
1929 sc.move = _pan_move;
1930 sc.calculate = _pan_calculate;
1931 if (!(smart = evas_smart_class_new(&sc))) return NULL;
1934 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1936 ELM_SET_WIDTYPE(widtype, "gengrid");
1938 elm_widget_type_set(obj, "gengrid");
1939 elm_widget_sub_object_add(parent, obj);
1940 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1941 elm_widget_data_set(obj, wd);
1942 elm_widget_del_hook_set(obj, _del_hook);
1943 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1944 elm_widget_theme_hook_set(obj, _theme_hook);
1945 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1946 elm_widget_can_focus_set(obj, EINA_TRUE);
1947 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1948 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1949 elm_widget_event_hook_set(obj, _event_hook);
1952 wd->scr = elm_smart_scroller_add(e);
1953 elm_smart_scroller_widget_set(wd->scr, obj);
1954 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1956 elm_smart_scroller_bounce_allow_set(wd->scr, bounce,
1957 _elm_config->thumbscroll_bounce_enable);
1958 elm_widget_resize_object_set(obj, wd->scr);
1960 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1961 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1962 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1963 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1964 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1965 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1966 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1967 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom,
1969 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1974 wd->h_bounce = bounce;
1975 wd->v_bounce = bounce;
1977 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1978 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1979 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1980 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1982 wd->pan_smart = evas_object_smart_add(e, smart);
1983 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1986 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1987 _pan_set, _pan_get, _pan_max_get,
1988 _pan_min_get, _pan_child_size_get);
1990 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1992 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1997 elm_gengrid_item_size_set(Evas_Object *obj,
2001 ELM_CHECK_WIDTYPE(obj, widtype);
2002 Widget_Data *wd = elm_widget_data_get(obj);
2004 if ((wd->item_width == w) && (wd->item_height == h)) return;
2006 wd->item_height = h;
2007 if (wd->calc_job) ecore_job_del(wd->calc_job);
2008 wd->calc_job = ecore_job_add(_calc_job, wd);
2012 elm_gengrid_item_size_get(const Evas_Object *obj,
2016 ELM_CHECK_WIDTYPE(obj, widtype);
2017 Widget_Data *wd = elm_widget_data_get(obj);
2019 if (w) *w = wd->item_width;
2020 if (h) *h = wd->item_height;
2024 elm_gengrid_group_item_size_set(Evas_Object *obj,
2028 ELM_CHECK_WIDTYPE(obj, widtype);
2029 Widget_Data *wd = elm_widget_data_get(obj);
2031 if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
2032 wd->group_item_width = w;
2033 wd->group_item_height = h;
2034 if (wd->calc_job) ecore_job_del(wd->calc_job);
2035 wd->calc_job = ecore_job_add(_calc_job, wd);
2039 elm_gengrid_group_item_size_get(const Evas_Object *obj,
2043 ELM_CHECK_WIDTYPE(obj, widtype);
2044 Widget_Data *wd = elm_widget_data_get(obj);
2046 if (w) *w = wd->group_item_width;
2047 if (h) *h = wd->group_item_height;
2051 elm_gengrid_align_set(Evas_Object *obj,
2055 ELM_CHECK_WIDTYPE(obj, widtype);
2057 Widget_Data *wd = elm_widget_data_get(obj);
2058 double old_h = wd->align_x, old_y = wd->align_y;
2062 else if (align_x < 0.0)
2064 wd->align_x = align_x;
2068 else if (align_y < 0.0)
2070 wd->align_y = align_y;
2072 if ((old_h != wd->align_x) || (old_y != wd->align_y))
2073 evas_object_smart_calculate(wd->pan_smart);
2077 elm_gengrid_align_get(const Evas_Object *obj,
2081 ELM_CHECK_WIDTYPE(obj, widtype);
2082 Widget_Data *wd = elm_widget_data_get(obj);
2083 if (align_x) *align_x = wd->align_x;
2084 if (align_y) *align_y = wd->align_y;
2087 EAPI Elm_Object_Item *
2088 elm_gengrid_item_append(Evas_Object *obj,
2089 const Elm_Gengrid_Item_Class *itc,
2092 const void *func_data)
2095 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2096 Widget_Data *wd = elm_widget_data_get(obj);
2097 if (!wd) return NULL;
2099 it = _item_new(wd, itc, data, func, func_data);
2100 if (!it) return NULL;
2101 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2104 wd->group_items = eina_list_prepend(wd->group_items, it);
2106 if (wd->calc_job) ecore_job_del(wd->calc_job);
2107 wd->calc_job = ecore_job_add(_calc_job, wd);
2109 return (Elm_Object_Item *) it;
2112 EAPI Elm_Object_Item *
2113 elm_gengrid_item_prepend(Evas_Object *obj,
2114 const Elm_Gengrid_Item_Class *itc,
2117 const void *func_data)
2120 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2121 Widget_Data *wd = elm_widget_data_get(obj);
2122 if (!wd) return NULL;
2124 it = _item_new(wd, itc, data, func, func_data);
2125 if (!it) return NULL;
2126 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2128 wd->group_items = eina_list_append(wd->group_items, it);
2130 if (wd->calc_job) ecore_job_del(wd->calc_job);
2131 wd->calc_job = ecore_job_add(_calc_job, wd);
2133 return (Elm_Object_Item *) it;
2136 EAPI Elm_Object_Item *
2137 elm_gengrid_item_insert_before(Evas_Object *obj,
2138 const Elm_Gengrid_Item_Class *itc,
2140 Elm_Object_Item *relative,
2142 const void *func_data)
2145 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2146 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2147 Widget_Data *wd = elm_widget_data_get(obj);
2148 if (!wd) return NULL;
2150 it = _item_new(wd, itc, data, func, func_data);
2151 if (!it) return NULL;
2152 wd->items = eina_inlist_prepend_relative
2153 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2155 wd->group_items = eina_list_append_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2157 if (wd->calc_job) ecore_job_del(wd->calc_job);
2158 wd->calc_job = ecore_job_add(_calc_job, wd);
2160 return (Elm_Object_Item *) it;
2163 EAPI Elm_Object_Item *
2164 elm_gengrid_item_insert_after(Evas_Object *obj,
2165 const Elm_Gengrid_Item_Class *itc,
2167 Elm_Object_Item *relative,
2169 const void *func_data)
2172 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2173 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2174 Widget_Data *wd = elm_widget_data_get(obj);
2175 if (!wd) return NULL;
2177 it = _item_new(wd, itc, data, func, func_data);
2178 if (!it) return NULL;
2179 wd->items = eina_inlist_append_relative
2180 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2182 wd->group_items = eina_list_prepend_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2184 if (wd->calc_job) ecore_job_del(wd->calc_job);
2185 wd->calc_job = ecore_job_add(_calc_job, wd);
2187 return (Elm_Object_Item *) it;
2190 EAPI Elm_Object_Item *
2191 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
2192 const Elm_Gengrid_Item_Class *itc,
2194 Eina_Compare_Cb comp,
2196 const void *func_data)
2199 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2200 Widget_Data *wd = elm_widget_data_get(obj);
2201 if (!wd) return NULL;
2203 it = _item_new(wd, itc, data, func, func_data);
2204 if (!it) return NULL;
2207 wd->state = eina_inlist_sorted_state_new();
2209 wd->item_compare_cb = comp;
2210 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
2211 _elm_gengrid_item_compare, wd->state);
2212 if (wd->calc_job) ecore_job_del(wd->calc_job);
2213 wd->calc_job = ecore_job_add(_calc_job, wd);
2215 return (Elm_Object_Item *) it;
2218 EAPI Elm_Object_Item *
2219 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2220 const Elm_Gengrid_Item_Class *itc,
2222 Eina_Compare_Cb comp,
2224 const void *func_data)
2226 Widget_Data *wd = elm_widget_data_get(obj);
2227 wd->item_compare_data_cb = comp;
2229 return elm_gengrid_item_direct_sorted_insert(obj, itc, data, _elm_gengrid_item_compare_data, func, func_data);
2233 elm_gengrid_item_del(Elm_Object_Item *it)
2235 elm_object_item_del(it);
2239 elm_gengrid_horizontal_set(Evas_Object *obj,
2240 Eina_Bool horizontal)
2242 ELM_CHECK_WIDTYPE(obj, widtype);
2243 Widget_Data *wd = elm_widget_data_get(obj);
2245 horizontal = !!horizontal;
2246 if (horizontal == wd->horizontal) return;
2247 wd->horizontal = horizontal;
2249 /* Update the items to conform to the new layout */
2250 if (wd->calc_job) ecore_job_del(wd->calc_job);
2251 wd->calc_job = ecore_job_add(_calc_job, wd);
2255 elm_gengrid_horizontal_get(const Evas_Object *obj)
2257 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2258 Widget_Data *wd = elm_widget_data_get(obj);
2259 if (!wd) return EINA_FALSE;
2260 return wd->horizontal;
2264 elm_gengrid_clear(Evas_Object *obj)
2266 elm_genlist_clear(obj);
2269 EINA_DEPRECATED EAPI const Evas_Object *
2270 elm_gengrid_item_object_get(const Elm_Object_Item *it)
2272 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2277 elm_gengrid_item_update(Elm_Object_Item *it)
2279 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2280 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2281 if (!_it->realized) return;
2282 if (_it->want_unrealize) return;
2283 _elm_genlist_item_unrealize(_it, EINA_FALSE);
2285 _item_place(_it, _it->x, _it->y);
2289 elm_gengrid_item_data_get(const Elm_Object_Item *it)
2291 return elm_object_item_data_get(it);
2295 elm_gengrid_item_data_set(Elm_Object_Item *it,
2298 elm_object_item_data_set(it, (void *) data);
2301 EAPI const Elm_Gengrid_Item_Class *
2302 elm_gengrid_item_item_class_get(const Elm_Object_Item *it)
2304 return (Elm_Gengrid_Item_Class *) elm_genlist_item_item_class_get(it);
2308 elm_gengrid_item_item_class_set(Elm_Object_Item *it,
2309 const Elm_Gengrid_Item_Class *itc)
2311 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2312 EINA_SAFETY_ON_NULL_RETURN(itc);
2313 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2314 if (_it->generation < _it->wd->generation) return;
2316 elm_gengrid_item_update(it);
2320 elm_gengrid_item_pos_get(const Elm_Object_Item *it,
2324 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2325 if (x) *x = ((Elm_Gen_Item *) it)->x;
2326 if (y) *y = ((Elm_Gen_Item *) it)->y;
2330 elm_gengrid_multi_select_set(Evas_Object *obj,
2333 ELM_CHECK_WIDTYPE(obj, widtype);
2334 Widget_Data *wd = elm_widget_data_get(obj);
2336 wd->multi = !!multi;
2340 elm_gengrid_multi_select_get(const Evas_Object *obj)
2342 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2343 Widget_Data *wd = elm_widget_data_get(obj);
2344 if (!wd) return EINA_FALSE;
2348 EAPI Elm_Object_Item *
2349 elm_gengrid_selected_item_get(const Evas_Object *obj)
2351 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2352 Widget_Data *wd = elm_widget_data_get(obj);
2353 if (!wd) return NULL;
2354 if (wd->selected) return wd->selected->data;
2358 EAPI const Eina_List *
2359 elm_gengrid_selected_items_get(const Evas_Object *obj)
2361 return elm_gengrid_selected_items_get(obj);
2365 elm_gengrid_item_selected_set(Elm_Object_Item *it,
2368 elm_genlist_item_selected_set(it, selected);
2372 elm_gengrid_item_selected_get(const Elm_Object_Item *it)
2374 return elm_genlist_item_selected_get(it);
2378 elm_gengrid_item_disabled_set(Elm_Object_Item *it,
2381 elm_object_item_disabled_set(it, disabled);
2385 elm_gengrid_item_disabled_get(const Elm_Object_Item *it)
2387 return elm_object_item_disabled_get(it);
2390 static Evas_Object *
2391 _elm_gengrid_item_label_create(void *data,
2392 Evas_Object *obj __UNUSED__,
2393 Evas_Object *tooltip,
2394 void *it __UNUSED__)
2396 Evas_Object *label = elm_label_add(tooltip);
2399 elm_object_style_set(label, "tooltip");
2400 elm_object_text_set(label, data);
2405 _elm_gengrid_item_label_del_cb(void *data,
2406 Evas_Object *obj __UNUSED__,
2407 void *event_info __UNUSED__)
2409 eina_stringshare_del(data);
2413 elm_gengrid_item_tooltip_text_set(Elm_Object_Item *it,
2416 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2417 text = eina_stringshare_add(text);
2418 elm_gengrid_item_tooltip_content_cb_set(it, _elm_gengrid_item_label_create,
2420 _elm_gengrid_item_label_del_cb);
2424 elm_gengrid_item_tooltip_content_cb_set(Elm_Object_Item *it,
2425 Elm_Tooltip_Item_Content_Cb func,
2427 Evas_Smart_Cb del_cb)
2429 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
2430 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2432 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
2435 if (_it->tooltip.del_cb)
2436 _it->tooltip.del_cb((void *)_it->tooltip.data, WIDGET(_it), _it);
2437 _it->tooltip.content_cb = func;
2438 _it->tooltip.data = data;
2439 _it->tooltip.del_cb = del_cb;
2442 elm_widget_item_tooltip_content_cb_set(_it,
2443 _it->tooltip.content_cb,
2444 _it->tooltip.data, NULL);
2445 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
2446 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
2452 if (del_cb) del_cb((void *)data, NULL, NULL);
2456 elm_gengrid_item_tooltip_unset(Elm_Object_Item *it)
2458 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2459 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2461 if ((VIEW(_it)) && (_it->tooltip.content_cb))
2462 elm_widget_item_tooltip_unset(_it);
2464 if (_it->tooltip.del_cb)
2465 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
2466 _it->tooltip.del_cb = NULL;
2467 _it->tooltip.content_cb = NULL;
2468 _it->tooltip.data = NULL;
2469 _it->tooltip.free_size = EINA_FALSE;
2470 if (_it->tooltip.style)
2471 elm_gengrid_item_tooltip_style_set(it, NULL);
2475 elm_gengrid_item_tooltip_style_set(Elm_Object_Item *it,
2478 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2479 eina_stringshare_replace(&((Elm_Gen_Item *) it)->tooltip.style, style);
2480 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
2484 elm_gengrid_item_tooltip_style_get(const Elm_Object_Item *it)
2486 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2487 return ((Elm_Gen_Item *) it)->tooltip.style;
2491 elm_gengrid_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
2493 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2494 ((Elm_Gen_Item *) it)->tooltip.free_size = disable;
2495 if (VIEW(it)) return elm_widget_item_tooltip_window_mode_set(it, disable);
2500 elm_gengrid_item_tooltip_window_mode_get(const Elm_Object_Item *it)
2502 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2503 return ((Elm_Gen_Item *) it)->tooltip.free_size;
2507 elm_gengrid_item_cursor_set(Elm_Object_Item *it,
2510 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2511 eina_stringshare_replace(&((Elm_Gen_Item *) it)->mouse_cursor, cursor);
2512 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
2516 elm_gengrid_item_cursor_get(const Elm_Object_Item *it)
2518 return elm_widget_item_cursor_get(it);
2522 elm_gengrid_item_cursor_unset(Elm_Object_Item *it)
2524 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2525 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2526 if (!_it->mouse_cursor)
2530 elm_widget_item_cursor_unset(_it);
2532 eina_stringshare_del(_it->mouse_cursor);
2533 _it->mouse_cursor = NULL;
2537 elm_gengrid_item_cursor_style_set(Elm_Object_Item *it,
2540 elm_widget_item_cursor_style_set(it, style);
2544 elm_gengrid_item_cursor_style_get(const Elm_Object_Item *it)
2546 return elm_widget_item_cursor_style_get(it);
2550 elm_gengrid_item_cursor_engine_only_set(Elm_Object_Item *it,
2551 Eina_Bool engine_only)
2553 elm_widget_item_cursor_engine_only_set(it, engine_only);
2557 elm_gengrid_item_cursor_engine_only_get(const Elm_Object_Item *it)
2559 return elm_widget_item_cursor_engine_only_get(it);
2563 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2564 Eina_Bool reorder_mode)
2566 ELM_CHECK_WIDTYPE(obj, widtype);
2567 Widget_Data *wd = elm_widget_data_get(obj);
2569 wd->reorder_mode = !!reorder_mode;
2573 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2575 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2576 Widget_Data *wd = elm_widget_data_get(obj);
2577 if (!wd) return EINA_FALSE;
2578 return wd->reorder_mode;
2582 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2583 Eina_Bool always_select)
2585 elm_genlist_always_select_mode_set(obj, always_select);
2589 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2591 return elm_genlist_always_select_mode_get(obj);
2595 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2596 Eina_Bool no_select)
2598 elm_genlist_no_select_mode_set(obj, no_select);
2602 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2604 return elm_genlist_no_select_mode_get(obj);
2608 elm_gengrid_bounce_set(Evas_Object *obj,
2612 elm_genlist_bounce_set(obj, h_bounce, v_bounce);
2616 elm_gengrid_bounce_get(const Evas_Object *obj,
2617 Eina_Bool *h_bounce,
2618 Eina_Bool *v_bounce)
2620 elm_genlist_bounce_get(obj, h_bounce, v_bounce);
2624 elm_gengrid_page_relative_set(Evas_Object *obj,
2628 _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
2632 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2634 _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
2638 elm_gengrid_page_size_set(Evas_Object *obj,
2639 Evas_Coord h_pagesize,
2640 Evas_Coord v_pagesize)
2642 _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
2646 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2648 _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
2652 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2654 _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
2658 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2660 _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
2664 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2666 _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
2669 EAPI Elm_Object_Item *
2670 elm_gengrid_first_item_get(const Evas_Object *obj)
2672 return elm_genlist_first_item_get(obj);
2675 EAPI Elm_Object_Item *
2676 elm_gengrid_last_item_get(const Evas_Object *obj)
2678 return elm_genlist_last_item_get(obj);
2681 EAPI Elm_Object_Item *
2682 elm_gengrid_item_next_get(const Elm_Object_Item *it)
2684 return elm_genlist_item_next_get(it);
2687 EAPI Elm_Object_Item *
2688 elm_gengrid_item_prev_get(const Elm_Object_Item *it)
2690 return elm_genlist_item_prev_get(it);
2694 elm_gengrid_item_gengrid_get(const Elm_Object_Item *it)
2696 return elm_object_item_widget_get(it);
2700 elm_gengrid_item_show(Elm_Object_Item *it)
2702 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2703 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2704 Widget_Data *wd = _it->wd;
2705 Evas_Coord minx = 0, miny = 0;
2707 if ((_it->generation < _it->wd->generation)) return;
2708 _pan_min_get(wd->pan_smart, &minx, &miny);
2711 elm_smart_scroller_region_bring_in(_it->wd->scr,
2712 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2713 _it->y * wd->item_height + miny,
2714 _it->wd->item_width,
2715 _it->wd->item_height);
2717 elm_smart_scroller_region_bring_in(_it->wd->scr,
2718 _it->x * wd->item_width + minx,
2719 ((_it->y - _it->item->prev_group) * wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2720 _it->wd->item_width,
2721 _it->wd->item_height);
2725 elm_gengrid_item_bring_in(Elm_Object_Item *it)
2727 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2728 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2730 if (_it->generation < _it->wd->generation) return;
2732 Evas_Coord minx = 0, miny = 0;
2733 Widget_Data *wd = _it->wd;
2734 _pan_min_get(wd->pan_smart, &minx, &miny);
2737 elm_smart_scroller_region_bring_in(_it->wd->scr,
2738 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2739 _it->y * wd->item_height + miny,
2740 _it->wd->item_width,
2741 _it->wd->item_height);
2743 elm_smart_scroller_region_bring_in(_it->wd->scr,
2744 _it->x * wd->item_width + minx,
2745 ((_it->y - _it->item->prev_group)* wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2746 _it->wd->item_width,
2747 _it->wd->item_height);
2751 elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill)
2753 ELM_CHECK_WIDTYPE(obj, widtype);
2754 Widget_Data *wd = elm_widget_data_get(obj);
2757 if (wd->filled != fill)
2762 elm_gengrid_filled_get(const Evas_Object *obj)
2764 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2765 Widget_Data *wd = elm_widget_data_get(obj);
2766 if (!wd) return EINA_FALSE;
2770 EAPI Elm_Gengrid_Item_Class *
2771 elm_gengrid_item_class_new(void)
2773 Elm_Gengrid_Item_Class *itc;
2775 itc = calloc(1, sizeof(Elm_Gengrid_Item_Class));
2778 itc->version = ELM_GENGRID_ITEM_CLASS_VERSION;
2780 itc->delete_me = EINA_FALSE;
2785 //XXX: notify class version to user if it is mismatched
2787 elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
2789 if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
2791 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
2792 if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
2801 //XXX: notify class version to user if it is mismatched
2803 elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
2805 if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
2808 if (itc->refcount == 0) itc->refcount--;
2812 //XXX: notify class version to user if it is mismatched
2814 elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
2816 if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
2818 if (itc->refcount > 0) itc->refcount--;
2819 if (itc->delete_me && (!itc->refcount))
2820 elm_gengrid_item_class_free(itc);