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(const void *data, const void *data1)
1843 Elm_Gen_Item *it, *item1;
1844 it = ELM_GEN_ITEM_FROM_INLIST(data);
1845 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
1846 return it->wd->item_compare_cb(it, item1);
1850 _item_disable_hook(Elm_Object_Item *it)
1852 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
1854 if (_it->generation < _it->wd->generation) return;
1858 if (elm_widget_item_disabled_get(_it))
1859 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
1861 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
1866 _item_del_pre_hook(Elm_Object_Item *it)
1868 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
1869 if ((_it->relcount > 0) || (_it->walking > 0))
1871 _elm_genlist_item_del_notserious(_it);
1878 static Elm_Gen_Item *
1879 _item_new(Widget_Data *wd,
1880 const Elm_Gengrid_Item_Class *itc,
1883 const void *func_data)
1887 it = _elm_genlist_item_new(wd, itc, data, NULL, func, func_data);
1888 if (!it) return NULL;
1889 elm_widget_item_disable_hook_set(it, _item_disable_hook);
1890 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
1891 elm_gengrid_item_class_ref((Elm_Gengrid_Item_Class *)itc);
1892 it->item = ELM_NEW(Elm_Gen_Item_Type);
1894 it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
1895 ELM_GEN_ITEM_SETUP(it);
1901 elm_gengrid_add(Evas_Object *parent)
1906 static Evas_Smart *smart = NULL;
1907 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1911 static Evas_Smart_Class sc;
1913 evas_object_smart_clipped_smart_set(&_pan_sc);
1915 sc.name = "elm_gengrid_pan";
1916 sc.version = EVAS_SMART_CLASS_VERSION;
1919 sc.resize = _pan_resize;
1920 sc.move = _pan_move;
1921 sc.calculate = _pan_calculate;
1922 if (!(smart = evas_smart_class_new(&sc))) return NULL;
1925 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1927 ELM_SET_WIDTYPE(widtype, "gengrid");
1929 elm_widget_type_set(obj, "gengrid");
1930 elm_widget_sub_object_add(parent, obj);
1931 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1932 elm_widget_data_set(obj, wd);
1933 elm_widget_del_hook_set(obj, _del_hook);
1934 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1935 elm_widget_theme_hook_set(obj, _theme_hook);
1936 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1937 elm_widget_can_focus_set(obj, EINA_TRUE);
1938 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1939 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1940 elm_widget_event_hook_set(obj, _event_hook);
1943 wd->scr = elm_smart_scroller_add(e);
1944 elm_smart_scroller_widget_set(wd->scr, obj);
1945 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1947 elm_smart_scroller_bounce_allow_set(wd->scr, bounce,
1948 _elm_config->thumbscroll_bounce_enable);
1949 elm_widget_resize_object_set(obj, wd->scr);
1951 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1952 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1953 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1954 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1955 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1956 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1957 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1958 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom,
1960 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1965 wd->h_bounce = bounce;
1966 wd->v_bounce = bounce;
1968 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1969 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1970 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1971 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1973 wd->pan_smart = evas_object_smart_add(e, smart);
1974 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1977 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1978 _pan_set, _pan_get, _pan_max_get,
1979 _pan_min_get, _pan_child_size_get);
1981 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1983 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1988 elm_gengrid_item_size_set(Evas_Object *obj,
1992 ELM_CHECK_WIDTYPE(obj, widtype);
1993 Widget_Data *wd = elm_widget_data_get(obj);
1995 if ((wd->item_width == w) && (wd->item_height == h)) return;
1997 wd->item_height = h;
1998 if (wd->calc_job) ecore_job_del(wd->calc_job);
1999 wd->calc_job = ecore_job_add(_calc_job, wd);
2003 elm_gengrid_item_size_get(const Evas_Object *obj,
2007 ELM_CHECK_WIDTYPE(obj, widtype);
2008 Widget_Data *wd = elm_widget_data_get(obj);
2010 if (w) *w = wd->item_width;
2011 if (h) *h = wd->item_height;
2015 elm_gengrid_group_item_size_set(Evas_Object *obj,
2019 ELM_CHECK_WIDTYPE(obj, widtype);
2020 Widget_Data *wd = elm_widget_data_get(obj);
2022 if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
2023 wd->group_item_width = w;
2024 wd->group_item_height = h;
2025 if (wd->calc_job) ecore_job_del(wd->calc_job);
2026 wd->calc_job = ecore_job_add(_calc_job, wd);
2030 elm_gengrid_group_item_size_get(const Evas_Object *obj,
2034 ELM_CHECK_WIDTYPE(obj, widtype);
2035 Widget_Data *wd = elm_widget_data_get(obj);
2037 if (w) *w = wd->group_item_width;
2038 if (h) *h = wd->group_item_height;
2042 elm_gengrid_align_set(Evas_Object *obj,
2046 ELM_CHECK_WIDTYPE(obj, widtype);
2048 Widget_Data *wd = elm_widget_data_get(obj);
2049 double old_h = wd->align_x, old_y = wd->align_y;
2053 else if (align_x < 0.0)
2055 wd->align_x = align_x;
2059 else if (align_y < 0.0)
2061 wd->align_y = align_y;
2063 if ((old_h != wd->align_x) || (old_y != wd->align_y))
2064 evas_object_smart_calculate(wd->pan_smart);
2068 elm_gengrid_align_get(const Evas_Object *obj,
2072 ELM_CHECK_WIDTYPE(obj, widtype);
2073 Widget_Data *wd = elm_widget_data_get(obj);
2074 if (align_x) *align_x = wd->align_x;
2075 if (align_y) *align_y = wd->align_y;
2078 EAPI Elm_Object_Item *
2079 elm_gengrid_item_append(Evas_Object *obj,
2080 const Elm_Gengrid_Item_Class *itc,
2083 const void *func_data)
2086 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2087 Widget_Data *wd = elm_widget_data_get(obj);
2088 if (!wd) return NULL;
2090 it = _item_new(wd, itc, data, func, func_data);
2091 if (!it) return NULL;
2092 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2095 wd->group_items = eina_list_prepend(wd->group_items, it);
2097 if (wd->calc_job) ecore_job_del(wd->calc_job);
2098 wd->calc_job = ecore_job_add(_calc_job, wd);
2100 return (Elm_Object_Item *) it;
2103 EAPI Elm_Object_Item *
2104 elm_gengrid_item_prepend(Evas_Object *obj,
2105 const Elm_Gengrid_Item_Class *itc,
2108 const void *func_data)
2111 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2112 Widget_Data *wd = elm_widget_data_get(obj);
2113 if (!wd) return NULL;
2115 it = _item_new(wd, itc, data, func, func_data);
2116 if (!it) return NULL;
2117 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2119 wd->group_items = eina_list_append(wd->group_items, it);
2121 if (wd->calc_job) ecore_job_del(wd->calc_job);
2122 wd->calc_job = ecore_job_add(_calc_job, wd);
2124 return (Elm_Object_Item *) it;
2127 EAPI Elm_Object_Item *
2128 elm_gengrid_item_insert_before(Evas_Object *obj,
2129 const Elm_Gengrid_Item_Class *itc,
2131 Elm_Object_Item *relative,
2133 const void *func_data)
2136 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2137 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2138 Widget_Data *wd = elm_widget_data_get(obj);
2139 if (!wd) return NULL;
2141 it = _item_new(wd, itc, data, func, func_data);
2142 if (!it) return NULL;
2143 wd->items = eina_inlist_prepend_relative
2144 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2146 wd->group_items = eina_list_append_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2148 if (wd->calc_job) ecore_job_del(wd->calc_job);
2149 wd->calc_job = ecore_job_add(_calc_job, wd);
2151 return (Elm_Object_Item *) it;
2154 EAPI Elm_Object_Item *
2155 elm_gengrid_item_insert_after(Evas_Object *obj,
2156 const Elm_Gengrid_Item_Class *itc,
2158 Elm_Object_Item *relative,
2160 const void *func_data)
2163 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2164 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2165 Widget_Data *wd = elm_widget_data_get(obj);
2166 if (!wd) return NULL;
2168 it = _item_new(wd, itc, data, func, func_data);
2169 if (!it) return NULL;
2170 wd->items = eina_inlist_append_relative
2171 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2173 wd->group_items = eina_list_prepend_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2175 if (wd->calc_job) ecore_job_del(wd->calc_job);
2176 wd->calc_job = ecore_job_add(_calc_job, wd);
2178 return (Elm_Object_Item *) it;
2181 EAPI Elm_Object_Item *
2182 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2183 const Elm_Gengrid_Item_Class *itc,
2185 Eina_Compare_Cb comp,
2187 const void *func_data)
2190 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2191 Widget_Data *wd = elm_widget_data_get(obj);
2192 if (!wd) return NULL;
2194 it = _item_new(wd, itc, data, func, func_data);
2195 if (!it) return NULL;
2198 wd->state = eina_inlist_sorted_state_new();
2200 wd->item_compare_cb = comp;
2201 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
2202 _elm_gengrid_item_compare, wd->state);
2203 if (wd->calc_job) ecore_job_del(wd->calc_job);
2204 wd->calc_job = ecore_job_add(_calc_job, wd);
2206 return (Elm_Object_Item *) it;
2209 EINA_DEPRECATED Elm_Object_Item *
2210 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
2211 const Elm_Gengrid_Item_Class *itc,
2213 Eina_Compare_Cb comp,
2215 const void *func_data)
2217 return elm_gengrid_item_sorted_insert(obj, itc, data, comp, func, func_data);
2221 elm_gengrid_item_del(Elm_Object_Item *it)
2223 elm_object_item_del(it);
2227 elm_gengrid_horizontal_set(Evas_Object *obj,
2228 Eina_Bool horizontal)
2230 ELM_CHECK_WIDTYPE(obj, widtype);
2231 Widget_Data *wd = elm_widget_data_get(obj);
2233 horizontal = !!horizontal;
2234 if (horizontal == wd->horizontal) return;
2235 wd->horizontal = horizontal;
2237 /* Update the items to conform to the new layout */
2238 if (wd->calc_job) ecore_job_del(wd->calc_job);
2239 wd->calc_job = ecore_job_add(_calc_job, wd);
2243 elm_gengrid_horizontal_get(const Evas_Object *obj)
2245 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2246 Widget_Data *wd = elm_widget_data_get(obj);
2247 if (!wd) return EINA_FALSE;
2248 return wd->horizontal;
2252 elm_gengrid_clear(Evas_Object *obj)
2254 elm_genlist_clear(obj);
2257 EINA_DEPRECATED EAPI const Evas_Object *
2258 elm_gengrid_item_object_get(const Elm_Object_Item *it)
2260 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2265 elm_gengrid_item_update(Elm_Object_Item *it)
2267 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2268 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2269 if (!_it->realized) return;
2270 if (_it->want_unrealize) return;
2271 _elm_genlist_item_unrealize(_it, EINA_FALSE);
2273 _item_place(_it, _it->x, _it->y);
2277 elm_gengrid_item_data_get(const Elm_Object_Item *it)
2279 return elm_object_item_data_get(it);
2283 elm_gengrid_item_data_set(Elm_Object_Item *it,
2286 elm_object_item_data_set(it, (void *) data);
2289 EAPI const Elm_Gengrid_Item_Class *
2290 elm_gengrid_item_item_class_get(const Elm_Object_Item *it)
2292 return (Elm_Gengrid_Item_Class *) elm_genlist_item_item_class_get(it);
2295 EINA_DEPRECATED EAPI void
2296 elm_gengrid_item_item_class_set(Elm_Object_Item *it,
2297 const Elm_Gengrid_Item_Class *itc)
2299 elm_gengrid_item_item_class_update(it, itc);
2303 elm_gengrid_item_item_class_update(Elm_Object_Item *it,
2304 const Elm_Gengrid_Item_Class *itc)
2306 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2307 EINA_SAFETY_ON_NULL_RETURN(itc);
2308 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2309 if (_it->generation < _it->wd->generation) return;
2311 elm_gengrid_item_update(it);
2315 elm_gengrid_item_pos_get(const Elm_Object_Item *it,
2319 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2320 if (x) *x = ((Elm_Gen_Item *) it)->x;
2321 if (y) *y = ((Elm_Gen_Item *) it)->y;
2325 elm_gengrid_multi_select_set(Evas_Object *obj,
2328 ELM_CHECK_WIDTYPE(obj, widtype);
2329 Widget_Data *wd = elm_widget_data_get(obj);
2331 wd->multi = !!multi;
2335 elm_gengrid_multi_select_get(const Evas_Object *obj)
2337 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2338 Widget_Data *wd = elm_widget_data_get(obj);
2339 if (!wd) return EINA_FALSE;
2343 EAPI Elm_Object_Item *
2344 elm_gengrid_selected_item_get(const Evas_Object *obj)
2346 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2347 Widget_Data *wd = elm_widget_data_get(obj);
2348 if (!wd) return NULL;
2349 if (wd->selected) return wd->selected->data;
2353 EAPI const Eina_List *
2354 elm_gengrid_selected_items_get(const Evas_Object *obj)
2356 return elm_genlist_selected_items_get(obj);
2360 elm_gengrid_item_selected_set(Elm_Object_Item *it,
2363 elm_genlist_item_selected_set(it, selected);
2367 elm_gengrid_item_selected_get(const Elm_Object_Item *it)
2369 return elm_genlist_item_selected_get(it);
2373 elm_gengrid_item_disabled_set(Elm_Object_Item *it,
2376 elm_object_item_disabled_set(it, disabled);
2380 elm_gengrid_item_disabled_get(const Elm_Object_Item *it)
2382 return elm_object_item_disabled_get(it);
2385 static Evas_Object *
2386 _elm_gengrid_item_label_create(void *data,
2387 Evas_Object *obj __UNUSED__,
2388 Evas_Object *tooltip,
2389 void *it __UNUSED__)
2391 Evas_Object *label = elm_label_add(tooltip);
2394 elm_object_style_set(label, "tooltip");
2395 elm_object_text_set(label, data);
2400 _elm_gengrid_item_label_del_cb(void *data,
2401 Evas_Object *obj __UNUSED__,
2402 void *event_info __UNUSED__)
2404 eina_stringshare_del(data);
2408 elm_gengrid_item_tooltip_text_set(Elm_Object_Item *it,
2411 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2412 text = eina_stringshare_add(text);
2413 elm_gengrid_item_tooltip_content_cb_set(it, _elm_gengrid_item_label_create,
2415 _elm_gengrid_item_label_del_cb);
2419 elm_gengrid_item_tooltip_content_cb_set(Elm_Object_Item *it,
2420 Elm_Tooltip_Item_Content_Cb func,
2422 Evas_Smart_Cb del_cb)
2424 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
2425 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2427 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
2430 if (_it->tooltip.del_cb)
2431 _it->tooltip.del_cb((void *)_it->tooltip.data, WIDGET(_it), _it);
2432 _it->tooltip.content_cb = func;
2433 _it->tooltip.data = data;
2434 _it->tooltip.del_cb = del_cb;
2437 elm_widget_item_tooltip_content_cb_set(_it,
2438 _it->tooltip.content_cb,
2439 _it->tooltip.data, NULL);
2440 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
2441 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
2447 if (del_cb) del_cb((void *)data, NULL, NULL);
2451 elm_gengrid_item_tooltip_unset(Elm_Object_Item *it)
2453 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2454 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2456 if ((VIEW(_it)) && (_it->tooltip.content_cb))
2457 elm_widget_item_tooltip_unset(_it);
2459 if (_it->tooltip.del_cb)
2460 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
2461 _it->tooltip.del_cb = NULL;
2462 _it->tooltip.content_cb = NULL;
2463 _it->tooltip.data = NULL;
2464 _it->tooltip.free_size = EINA_FALSE;
2465 if (_it->tooltip.style)
2466 elm_gengrid_item_tooltip_style_set(it, NULL);
2470 elm_gengrid_item_tooltip_style_set(Elm_Object_Item *it,
2473 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2474 eina_stringshare_replace(&((Elm_Gen_Item *) it)->tooltip.style, style);
2475 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
2479 elm_gengrid_item_tooltip_style_get(const Elm_Object_Item *it)
2481 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2482 return ((Elm_Gen_Item *) it)->tooltip.style;
2486 elm_gengrid_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
2488 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2489 ((Elm_Gen_Item *) it)->tooltip.free_size = disable;
2490 if (VIEW(it)) return elm_widget_item_tooltip_window_mode_set(it, disable);
2495 elm_gengrid_item_tooltip_window_mode_get(const Elm_Object_Item *it)
2497 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2498 return ((Elm_Gen_Item *) it)->tooltip.free_size;
2502 elm_gengrid_item_cursor_set(Elm_Object_Item *it,
2505 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2506 eina_stringshare_replace(&((Elm_Gen_Item *) it)->mouse_cursor, cursor);
2507 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
2511 elm_gengrid_item_cursor_get(const Elm_Object_Item *it)
2513 return elm_widget_item_cursor_get(it);
2517 elm_gengrid_item_cursor_unset(Elm_Object_Item *it)
2519 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2520 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2521 if (!_it->mouse_cursor)
2525 elm_widget_item_cursor_unset(_it);
2527 eina_stringshare_del(_it->mouse_cursor);
2528 _it->mouse_cursor = NULL;
2532 elm_gengrid_item_cursor_style_set(Elm_Object_Item *it,
2535 elm_widget_item_cursor_style_set(it, style);
2539 elm_gengrid_item_cursor_style_get(const Elm_Object_Item *it)
2541 return elm_widget_item_cursor_style_get(it);
2545 elm_gengrid_item_cursor_engine_only_set(Elm_Object_Item *it,
2546 Eina_Bool engine_only)
2548 elm_widget_item_cursor_engine_only_set(it, engine_only);
2552 elm_gengrid_item_cursor_engine_only_get(const Elm_Object_Item *it)
2554 return elm_widget_item_cursor_engine_only_get(it);
2558 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2559 Eina_Bool reorder_mode)
2561 ELM_CHECK_WIDTYPE(obj, widtype);
2562 Widget_Data *wd = elm_widget_data_get(obj);
2564 wd->reorder_mode = !!reorder_mode;
2568 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2570 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2571 Widget_Data *wd = elm_widget_data_get(obj);
2572 if (!wd) return EINA_FALSE;
2573 return wd->reorder_mode;
2577 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2578 Eina_Bool always_select)
2580 elm_genlist_always_select_mode_set(obj, always_select);
2584 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2586 return elm_genlist_always_select_mode_get(obj);
2590 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2591 Eina_Bool no_select)
2593 elm_genlist_no_select_mode_set(obj, no_select);
2597 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2599 return elm_genlist_no_select_mode_get(obj);
2603 elm_gengrid_bounce_set(Evas_Object *obj,
2607 elm_genlist_bounce_set(obj, h_bounce, v_bounce);
2611 elm_gengrid_bounce_get(const Evas_Object *obj,
2612 Eina_Bool *h_bounce,
2613 Eina_Bool *v_bounce)
2615 elm_genlist_bounce_get(obj, h_bounce, v_bounce);
2619 elm_gengrid_page_relative_set(Evas_Object *obj,
2623 _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
2627 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2629 _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
2633 elm_gengrid_page_size_set(Evas_Object *obj,
2634 Evas_Coord h_pagesize,
2635 Evas_Coord v_pagesize)
2637 _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
2641 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2643 _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
2647 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2649 _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
2653 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2655 _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
2659 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2661 _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
2664 EAPI Elm_Object_Item *
2665 elm_gengrid_first_item_get(const Evas_Object *obj)
2667 return elm_genlist_first_item_get(obj);
2670 EAPI Elm_Object_Item *
2671 elm_gengrid_last_item_get(const Evas_Object *obj)
2673 return elm_genlist_last_item_get(obj);
2676 EAPI Elm_Object_Item *
2677 elm_gengrid_item_next_get(const Elm_Object_Item *it)
2679 return elm_genlist_item_next_get(it);
2682 EAPI Elm_Object_Item *
2683 elm_gengrid_item_prev_get(const Elm_Object_Item *it)
2685 return elm_genlist_item_prev_get(it);
2689 elm_gengrid_item_gengrid_get(const Elm_Object_Item *it)
2691 return elm_object_item_widget_get(it);
2695 elm_gengrid_item_show(Elm_Object_Item *it)
2697 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2698 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2699 Widget_Data *wd = _it->wd;
2700 Evas_Coord minx = 0, miny = 0;
2702 if ((_it->generation < _it->wd->generation)) return;
2703 _pan_min_get(wd->pan_smart, &minx, &miny);
2706 elm_smart_scroller_region_bring_in(_it->wd->scr,
2707 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2708 _it->y * wd->item_height + miny,
2709 _it->wd->item_width,
2710 _it->wd->item_height);
2712 elm_smart_scroller_region_bring_in(_it->wd->scr,
2713 _it->x * wd->item_width + minx,
2714 ((_it->y - _it->item->prev_group) * wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2715 _it->wd->item_width,
2716 _it->wd->item_height);
2720 elm_gengrid_item_bring_in(Elm_Object_Item *it)
2722 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2723 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2725 if (_it->generation < _it->wd->generation) return;
2727 Evas_Coord minx = 0, miny = 0;
2728 Widget_Data *wd = _it->wd;
2729 _pan_min_get(wd->pan_smart, &minx, &miny);
2732 elm_smart_scroller_region_bring_in(_it->wd->scr,
2733 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2734 _it->y * wd->item_height + miny,
2735 _it->wd->item_width,
2736 _it->wd->item_height);
2738 elm_smart_scroller_region_bring_in(_it->wd->scr,
2739 _it->x * wd->item_width + minx,
2740 ((_it->y - _it->item->prev_group)* wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2741 _it->wd->item_width,
2742 _it->wd->item_height);
2746 elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill)
2748 ELM_CHECK_WIDTYPE(obj, widtype);
2749 Widget_Data *wd = elm_widget_data_get(obj);
2752 if (wd->filled != fill)
2757 elm_gengrid_filled_get(const Evas_Object *obj)
2759 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2760 Widget_Data *wd = elm_widget_data_get(obj);
2761 if (!wd) return EINA_FALSE;
2765 EAPI Elm_Gengrid_Item_Class *
2766 elm_gengrid_item_class_new(void)
2768 Elm_Gengrid_Item_Class *itc;
2770 itc = calloc(1, sizeof(Elm_Gengrid_Item_Class));
2773 itc->version = ELM_GENGRID_ITEM_CLASS_VERSION;
2775 itc->delete_me = EINA_FALSE;
2781 elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
2783 if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
2785 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
2786 if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
2796 elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
2798 if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
2801 if (itc->refcount == 0) itc->refcount--;
2806 elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
2808 if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
2810 if (itc->refcount > 0) itc->refcount--;
2811 if (itc->delete_me && (!itc->refcount))
2812 elm_gengrid_item_class_free(itc);