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 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
281 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
283 it = elm_gengrid_last_item_get(obj);
284 elm_gengrid_item_bring_in(it);
285 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
288 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
293 x -= -(page_x * v_w) / 100;
300 y -= -(page_y * v_h) / 100;
305 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
310 x += -(page_x * v_w) / 100;
317 y += -(page_y * v_h) / 100;
322 else if (!strcmp(ev->keyname, "Escape"))
324 if (!_deselect_all_items(wd)) return EINA_FALSE;
325 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
328 else if (((!strcmp(ev->keyname, "Return")) ||
329 (!strcmp(ev->keyname, "KP_Enter")) ||
330 (!strcmp(ev->keyname, "space")))
331 && (!wd->multi) && (wd->selected))
333 it = elm_gengrid_selected_item_get(obj);
334 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
336 else return EINA_FALSE;
338 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
339 elm_smart_scroller_child_pos_set(wd->scr, x, y);
344 _deselect_all_items(Widget_Data *wd)
346 if (!wd->selected) return EINA_FALSE;
348 elm_gengrid_item_selected_set((Elm_Object_Item *) wd->selected->data,
355 _item_multi_select_left(Widget_Data *wd)
357 if (!wd->selected) return EINA_FALSE;
359 Elm_Object_Item *prev =
360 elm_gengrid_item_prev_get(wd->last_selected_item);
361 if (!prev) return EINA_TRUE;
362 if (elm_gengrid_item_selected_get(prev))
364 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
365 wd->last_selected_item = prev;
366 elm_gengrid_item_show(wd->last_selected_item);
370 elm_gengrid_item_selected_set(prev, EINA_TRUE);
371 elm_gengrid_item_show(prev);
378 _item_multi_select_right(Widget_Data *wd)
380 if (!wd->selected) return EINA_FALSE;
382 Elm_Object_Item *next =
383 elm_gengrid_item_next_get(wd->last_selected_item);
384 if (!next) return EINA_TRUE;
385 if (elm_gengrid_item_selected_get(next))
387 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
388 wd->last_selected_item = next;
389 elm_gengrid_item_show(wd->last_selected_item);
393 elm_gengrid_item_selected_set(next, EINA_TRUE);
394 elm_gengrid_item_show(next);
401 _item_multi_select_up(Widget_Data *wd)
404 Eina_Bool r = EINA_TRUE;
406 if (!wd->selected) return EINA_FALSE;
408 for (i = 0; (r) && (i < wd->nmax); i++)
409 r &= _item_multi_select_left(wd);
415 _item_multi_select_down(Widget_Data *wd)
418 Eina_Bool r = EINA_TRUE;
420 if (!wd->selected) return EINA_FALSE;
422 for (i = 0; (r) && (i < wd->nmax); i++)
423 r &= _item_multi_select_right(wd);
429 _item_single_select_up(Widget_Data *wd)
437 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
438 while ((prev) && (prev->generation < wd->generation))
439 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
440 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
441 elm_gengrid_item_show((Elm_Object_Item *) prev);
445 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
447 if (!prev) return EINA_FALSE;
449 for (i = 1; i < wd->nmax; i++)
451 Elm_Object_Item *tmp =
452 elm_gengrid_item_prev_get((Elm_Object_Item *) prev);
453 if (!tmp) return EINA_FALSE;
454 prev = (Elm_Gen_Item *) tmp;
457 _deselect_all_items(wd);
459 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
460 elm_gengrid_item_show((Elm_Object_Item *) prev);
465 _item_single_select_down(Widget_Data *wd)
473 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
474 while ((next) && (next->generation < wd->generation))
475 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
476 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
477 elm_gengrid_item_show((Elm_Object_Item *) next);
481 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
483 if (!next) return EINA_FALSE;
485 for (i = 1; i < wd->nmax; i++)
487 Elm_Object_Item *tmp =
488 elm_gengrid_item_next_get((Elm_Object_Item *) next);
489 if (!tmp) return EINA_FALSE;
490 next = (Elm_Gen_Item *) tmp;
493 _deselect_all_items(wd);
495 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
496 elm_gengrid_item_show((Elm_Object_Item *) next);
501 _item_single_select_left(Widget_Data *wd)
506 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
507 while ((prev) && (prev->generation < wd->generation))
508 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
511 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
513 if (!prev) return EINA_FALSE;
515 _deselect_all_items(wd);
517 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
518 elm_gengrid_item_show((Elm_Object_Item *) prev);
523 _item_single_select_right(Widget_Data *wd)
528 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
529 while ((next) && (next->generation < wd->generation))
530 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
533 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
535 if (!next) return EINA_FALSE;
537 _deselect_all_items(wd);
539 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
540 elm_gengrid_item_show((Elm_Object_Item *) next);
545 _on_focus_hook(void *data __UNUSED__,
548 Widget_Data *wd = elm_widget_data_get(obj);
550 if (elm_widget_focus_get(obj))
552 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
553 evas_object_focus_set(wd->obj, EINA_TRUE);
554 if ((wd->selected) && (!wd->last_selected_item))
555 wd->last_selected_item = eina_list_data_get(wd->selected);
559 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
560 evas_object_focus_set(wd->obj, EINA_FALSE);
565 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
567 Widget_Data *wd = elm_widget_data_get(obj);
570 elm_smart_scroller_mirrored_set(wd->scr, rtl);
571 if (!wd->items) return;
572 it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
576 edje_object_mirrored_set(VIEW(it), rtl);
577 elm_gengrid_item_update((Elm_Object_Item *) it);
578 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
583 _theme_hook(Evas_Object *obj)
585 Widget_Data *wd = elm_widget_data_get(obj);
587 _elm_widget_mirrored_reload(obj);
588 _mirrored_set(obj, elm_widget_mirrored_get(obj));
589 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
590 elm_widget_style_get(obj));
594 _del_pre_hook(Evas_Object *obj)
596 Widget_Data *wd = elm_widget_data_get(obj);
598 elm_gengrid_clear(obj);
599 evas_object_del(wd->pan_smart);
600 wd->pan_smart = NULL;
604 _del_hook(Evas_Object *obj)
606 Widget_Data *wd = elm_widget_data_get(obj);
607 if (wd->calc_job) ecore_job_del(wd->calc_job);
612 _signal_emit_hook(Evas_Object *obj,
613 const char *emission,
616 Widget_Data *wd = elm_widget_data_get(obj);
618 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
623 _signal_callback_add_hook(Evas_Object *obj,
624 const char *emission,
626 Edje_Signal_Cb func_cb,
629 Widget_Data *wd = elm_widget_data_get(obj);
631 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
632 emission, source, func_cb, data);
636 _signal_callback_del_hook(Evas_Object *obj,
637 const char *emission,
639 Edje_Signal_Cb func_cb,
642 Widget_Data *wd = elm_widget_data_get(obj);
644 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scr),
645 emission, source, func_cb, data);
649 _mouse_move(void *data,
650 Evas *evas __UNUSED__,
654 Elm_Gen_Item *it = data;
655 Evas_Event_Mouse_Move *ev = event_info;
656 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
657 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
659 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
661 if (!it->wd->on_hold)
663 it->wd->on_hold = EINA_TRUE;
664 if (!it->wd->wasselected)
668 if ((it->dragging) && (it->down))
672 ecore_timer_del(it->long_timer);
673 it->long_timer = NULL;
675 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
678 if ((!it->down) || (it->wd->longpressed))
682 ecore_timer_del(it->long_timer);
683 it->long_timer = NULL;
685 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
687 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
689 it_scrl_x = ev->cur.canvas.x - it->wd->reorder_it->dx;
690 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
692 if (it_scrl_x < ox) it->wd->reorder_item_x = ox;
693 else if (it_scrl_x + it->wd->item_width > ox + ow)
694 it->wd->reorder_item_x = ox + ow - it->wd->item_width;
695 else it->wd->reorder_item_x = it_scrl_x;
697 if (it_scrl_y < oy) it->wd->reorder_item_y = oy;
698 else if (it_scrl_y + it->wd->item_height > oy + oh)
699 it->wd->reorder_item_y = oy + oh - it->wd->item_height;
700 else it->wd->reorder_item_y = it_scrl_y;
702 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
703 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
707 if (!it->display_only)
708 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
709 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
710 x = ev->cur.canvas.x - x;
711 y = ev->cur.canvas.y - y;
714 if (adx < 0) adx = -dx;
717 if (ady < 0) ady = -dy;
720 if ((adx > minw) || (ady > minh))
722 const char *left_drag, *right_drag;
723 if (!elm_widget_mirrored_get(WIDGET(it)))
725 left_drag = SIG_DRAG_START_LEFT;
726 right_drag = SIG_DRAG_START_RIGHT;
730 left_drag = SIG_DRAG_START_RIGHT;
731 right_drag = SIG_DRAG_START_LEFT;
737 ecore_timer_del(it->long_timer);
738 it->long_timer = NULL;
740 if (!it->wd->wasselected)
745 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_START_UP,
750 evas_object_smart_callback_call(WIDGET(it),
757 evas_object_smart_callback_call(WIDGET(it),
758 SIG_DRAG_START_DOWN, it);
762 evas_object_smart_callback_call(WIDGET(it),
765 evas_object_smart_callback_call(WIDGET(it),
773 _long_press(void *data)
775 Elm_Gen_Item *it = data;
777 it->long_timer = NULL;
778 if (elm_widget_item_disabled_get(it)|| (it->dragging))
779 return ECORE_CALLBACK_CANCEL;
780 it->wd->longpressed = EINA_TRUE;
781 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
782 if (it->wd->reorder_mode)
784 it->wd->reorder_it = it;
785 evas_object_raise(VIEW(it));
786 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
787 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
788 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
790 return ECORE_CALLBACK_CANCEL;
794 _mouse_down(void *data,
795 Evas *evas __UNUSED__,
799 Elm_Gen_Item *it = data;
800 Evas_Event_Mouse_Down *ev = event_info;
803 if (ev->button != 1) return;
806 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
807 it->dx = ev->canvas.x - x;
808 it->dy = ev->canvas.y - y;
809 it->wd->longpressed = EINA_FALSE;
810 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
811 else it->wd->on_hold = EINA_FALSE;
812 if (it->wd->on_hold) return;
813 it->wd->wasselected = it->selected;
815 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
817 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
818 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
820 if (it->long_timer) ecore_timer_del(it->long_timer);
822 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
825 it->long_timer = NULL;
829 _mouse_up(void *data,
830 Evas *evas __UNUSED__,
831 Evas_Object *obj __UNUSED__,
834 Elm_Gen_Item *it = data;
835 Evas_Event_Mouse_Up *ev = event_info;
836 Eina_Bool dragged = EINA_FALSE;
838 if (ev->button != 1) return;
839 it->down = EINA_FALSE;
840 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
841 else it->wd->on_hold = EINA_FALSE;
844 ecore_timer_del(it->long_timer);
845 it->long_timer = NULL;
849 it->dragging = EINA_FALSE;
850 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
855 it->wd->longpressed = EINA_FALSE;
856 it->wd->on_hold = EINA_FALSE;
859 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
861 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it->wd->reorder_it);
862 it->wd->reorder_it = NULL;
863 it->wd->move_effect_enabled = EINA_FALSE;
864 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
865 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
867 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
868 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
869 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
871 if (it->wd->longpressed)
873 it->wd->longpressed = EINA_FALSE;
874 if (!it->wd->wasselected) _item_unselect(it);
875 it->wd->wasselected = EINA_FALSE;
880 if (it->want_unrealize)
881 _elm_genlist_item_unrealize(it, EINA_FALSE);
883 if (elm_widget_item_disabled_get(it) || (dragged)) return;
891 else _item_unselect(it);
897 while (it->wd->selected)
898 _item_unselect(it->wd->selected->data);
902 const Eina_List *l, *l_next;
905 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, item2)
906 if (item2 != it) _item_unselect(item2);
914 _item_highlight(Elm_Gen_Item *it)
916 if ((it->wd->no_select) || (it->generation < it->wd->generation) || (it->highlighted)) return;
917 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
918 it->highlighted = EINA_TRUE;
922 _item_realize(Elm_Gen_Item *it)
927 if ((it->realized) || (it->generation < it->wd->generation)) return;
928 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
929 edje_object_scale_set(VIEW(it), elm_widget_scale_get(WIDGET(it)) *
931 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
932 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
933 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
934 snprintf(style, sizeof(style), "item/%s",
935 it->itc->item_style ? it->itc->item_style : "default");
936 _elm_theme_object_set(WIDGET(it), VIEW(it), "gengrid", style,
937 elm_widget_style_get(WIDGET(it)));
939 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
940 evas_object_color_set(it->spacer, 0, 0, 0, 0);
941 elm_widget_sub_object_add(WIDGET(it), it->spacer);
942 evas_object_size_hint_min_set(it->spacer, 2 * _elm_config->scale, 1);
943 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
945 if (it->itc->func.text_get)
951 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
953 EINA_LIST_FOREACH(it->texts, l, key)
955 char *s = it->itc->func.text_get
956 ((void *)it->base.data, WIDGET(it), key);
959 edje_object_part_text_set(VIEW(it), key, s);
965 if (it->itc->func.content_get)
969 Evas_Object *ic = NULL;
972 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
974 EINA_LIST_FOREACH(it->contents, l, key)
976 if (it->itc->func.content_get)
977 ic = it->itc->func.content_get
978 ((void *)it->base.data, WIDGET(it), key);
981 it->content_objs = eina_list_append(it->content_objs, ic);
982 edje_object_part_swallow(VIEW(it), key, ic);
983 evas_object_show(ic);
984 elm_widget_sub_object_add(WIDGET(it), ic);
989 if (it->itc->func.state_get)
995 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
997 EINA_LIST_FOREACH(it->states, l, key)
999 Eina_Bool on = it->itc->func.state_get
1000 ((void *)it->base.data, WIDGET(it), l->data);
1003 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1004 edje_object_signal_emit(VIEW(it), buf, "elm");
1011 if ((!it->wd->group_item_width) && (!it->wd->group_item_height))
1013 edje_object_size_min_restricted_calc(VIEW(it),
1014 &it->wd->group_item_width,
1015 &it->wd->group_item_height,
1016 it->wd->group_item_width,
1017 it->wd->group_item_height);
1022 if ((!it->wd->item_width) && (!it->wd->item_height))
1024 edje_object_size_min_restricted_calc(VIEW(it),
1025 &it->wd->item_width,
1026 &it->wd->item_height,
1028 it->wd->item_height);
1029 elm_coords_finger_size_adjust(1, &it->wd->item_width,
1030 1, &it->wd->item_height);
1033 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1035 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1037 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1041 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1042 if (elm_widget_item_disabled_get(it))
1043 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1045 evas_object_show(VIEW(it));
1047 if (it->tooltip.content_cb)
1049 elm_widget_item_tooltip_content_cb_set(it,
1050 it->tooltip.content_cb,
1051 it->tooltip.data, NULL);
1052 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1053 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
1056 if (it->mouse_cursor)
1057 elm_widget_item_cursor_set(it, it->mouse_cursor);
1059 it->realized = EINA_TRUE;
1060 it->want_unrealize = EINA_FALSE;
1064 _item_unrealize_cb(Elm_Gen_Item *it)
1066 evas_object_del(VIEW(it));
1068 evas_object_del(it->spacer);
1073 _reorder_item_moving_effect_timer_cb(void *data)
1075 Elm_Gen_Item *it = data;
1079 tt = REORDER_EFFECT_TIME;
1080 t = ((0.0 > (t = ecore_loop_time_get()-it->item->moving_effect_start_time)) ? 0.0 : t);
1081 dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
1082 dy = ((it->item->ty - it->item->oy) / 10) * _elm_config->scale;
1086 it->item->rx += (1 * sin((t / tt) * (M_PI / 2)) * dx);
1087 it->item->ry += (1 * sin((t / tt) * (M_PI / 2)) * dy);
1095 if ((((dx > 0) && (it->item->rx >= it->item->tx)) || ((dx <= 0) && (it->item->rx <= it->item->tx))) &&
1096 (((dy > 0) && (it->item->ry >= it->item->ty)) || ((dy <= 0) && (it->item->ry <= it->item->ty))))
1098 evas_object_move(VIEW(it), it->item->tx, it->item->ty);
1102 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1103 if (it->wd->horizontal)
1104 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1106 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1109 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1110 it->item->moving = EINA_FALSE;
1111 it->item->item_moving_effect_timer = NULL;
1112 return ECORE_CALLBACK_CANCEL;
1115 evas_object_move(VIEW(it), it->item->rx, it->item->ry);
1119 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1120 if (it->wd->horizontal)
1121 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1123 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1126 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1128 return ECORE_CALLBACK_RENEW;
1132 _group_item_place(Pan *sd)
1134 Evas_Coord iw, ih, vw, vh;
1136 Eina_Bool was_realized;
1138 evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1139 if (sd->wd->horizontal)
1141 iw = sd->wd->group_item_width;
1147 ih = sd->wd->group_item_height;
1149 EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1151 was_realized = it->realized;
1152 if (it->item->group_realized)
1156 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1157 evas_object_move(VIEW(it), it->item->gx, it->item->gy);
1158 evas_object_resize(VIEW(it), iw, ih);
1159 evas_object_raise(VIEW(it));
1162 _elm_genlist_item_unrealize(it, EINA_FALSE);
1168 _item_place(Elm_Gen_Item *it,
1172 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1173 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1174 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1178 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &vw, &vh);
1180 /* Preload rows/columns at each side of the Gengrid */
1181 cvx = ox - PRELOAD * it->wd->item_width;
1182 cvy = oy - PRELOAD * it->wd->item_height;
1183 cvw = vw + 2 * PRELOAD * it->wd->item_width;
1184 cvh = vh + 2 * PRELOAD * it->wd->item_height;
1189 items_count = it->wd->item_count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
1190 if (it->wd->horizontal)
1192 int columns, items_visible = 0, items_row;
1194 if (it->wd->item_height > 0)
1195 items_visible = vh / it->wd->item_height;
1196 if (items_visible < 1)
1199 columns = items_count / items_visible;
1200 if (items_count % items_visible)
1203 tcw = (it->wd->item_width * columns) + (it->wd->group_item_width * eina_list_count(it->wd->group_items));
1204 alignw = (vw - tcw) * it->wd->align_x;
1206 items_row = items_visible;
1207 if ((unsigned int)items_row > it->wd->item_count)
1208 items_row = it->wd->item_count;
1210 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1211 tch = it->wd->nmax * it->wd->item_height;
1213 tch = items_row * it->wd->item_height;
1214 alignh = (vh - tch) * it->wd->align_y;
1218 unsigned int rows, items_visible = 0, items_col;
1220 if (it->wd->item_width > 0)
1221 items_visible = vw / it->wd->item_width;
1222 if (items_visible < 1)
1225 rows = items_count / items_visible;
1226 if (items_count % items_visible)
1229 tch = (it->wd->item_height * rows) + (it->wd->group_item_height * eina_list_count(it->wd->group_items));
1230 alignh = (vh - tch) * it->wd->align_y;
1232 items_col = items_visible;
1233 if (items_col > it->wd->item_count)
1234 items_col = it->wd->item_count;
1236 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1237 tcw = it->wd->nmax * it->wd->item_width;
1239 tcw = items_col * it->wd->item_width;
1240 alignw = (vw - tcw) * it->wd->align_x;
1245 if (it->wd->horizontal)
1247 x = (((cx - it->item->prev_group) * it->wd->item_width) + (it->item->prev_group * it->wd->group_item_width)) - it->wd->pan_x + ox + alignw;
1249 iw = it->wd->group_item_width;
1255 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;
1257 ih = it->wd->group_item_height;
1264 if (it->wd->horizontal)
1266 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;
1267 y = (cy * it->wd->item_height) - it->wd->pan_y + oy + alignh;
1271 x = (cx * it->wd->item_width) - it->wd->pan_x + ox + alignw;
1272 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;
1274 if (elm_widget_mirrored_get(WIDGET(it)))
1275 { /* Switch items side and componsate for pan_x when in RTL mode */
1276 evas_object_geometry_get(WIDGET(it), NULL, NULL, &ww, NULL);
1277 x = ww - x - it->wd->item_width - it->wd->pan_x - it->wd->pan_x;
1279 iw = it->wd->item_width;
1280 ih = it->wd->item_height;
1283 Eina_Bool was_realized = it->realized;
1284 if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1288 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1291 if (it->wd->horizontal)
1293 if (it->parent->item->gx < ox)
1295 it->parent->item->gx = x + it->wd->item_width - it->wd->group_item_width;
1296 if (it->parent->item->gx > ox)
1297 it->parent->item->gx = ox;
1299 it->parent->item->group_realized = EINA_TRUE;
1303 if (it->parent->item->gy < oy)
1305 it->parent->item->gy = y + it->wd->item_height - it->wd->group_item_height;
1306 if (it->parent->item->gy > oy)
1307 it->parent->item->gy = oy;
1309 it->parent->item->group_realized = EINA_TRUE;
1312 if (it->wd->reorder_mode)
1314 if (it->wd->reorder_it)
1316 if (it->item->moving) return;
1318 if (!it->wd->move_effect_enabled)
1323 if (it->wd->reorder_it == it)
1325 evas_object_move(VIEW(it),
1326 it->wd->reorder_item_x, it->wd->reorder_item_y);
1327 evas_object_resize(VIEW(it), iw, ih);
1332 if (it->wd->move_effect_enabled)
1334 if ((it->item->ox != x) || (it->item->oy != y))
1336 if (((it->wd->old_pan_x == it->wd->pan_x) && (it->wd->old_pan_y == it->wd->pan_y)) ||
1337 ((it->wd->old_pan_x != it->wd->pan_x) && !(it->item->ox - it->wd->pan_x + it->wd->old_pan_x == x)) ||
1338 ((it->wd->old_pan_y != it->wd->pan_y) && !(it->item->oy - it->wd->pan_y + it->wd->old_pan_y == y)))
1342 it->item->rx = it->item->ox;
1343 it->item->ry = it->item->oy;
1344 it->item->moving = EINA_TRUE;
1345 it->item->moving_effect_start_time = ecore_loop_time_get();
1346 it->item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
1353 Evas_Coord nx, ny, nw, nh;
1356 if (it->wd->horizontal)
1358 nx = x + (it->wd->group_item_width / 2);
1366 ny = y + (it->wd->group_item_height / 2);
1373 nx = x + (it->wd->item_width / 2);
1374 ny = y + (it->wd->item_height / 2);
1379 if ( ELM_RECTS_INTERSECT(it->wd->reorder_item_x, it->wd->reorder_item_y,
1380 it->wd->item_width, it->wd->item_height,
1383 if (it->wd->horizontal)
1385 if ((it->wd->nmax * it->wd->reorder_it->x + it->wd->reorder_it->y) >
1386 (it->wd->nmax * it->x + it->y))
1387 reorder_item_move_forward = EINA_TRUE;
1391 if ((it->wd->nmax * it->wd->reorder_it->y + it->wd->reorder_it->x) >
1392 (it->wd->nmax * it->y + it->x))
1393 reorder_item_move_forward = EINA_TRUE;
1396 it->wd->items = eina_inlist_remove(it->wd->items,
1397 EINA_INLIST_GET(it->wd->reorder_it));
1398 if (reorder_item_move_forward)
1399 it->wd->items = eina_inlist_prepend_relative(it->wd->items,
1400 EINA_INLIST_GET(it->wd->reorder_it),
1401 EINA_INLIST_GET(it));
1403 it->wd->items = eina_inlist_append_relative(it->wd->items,
1404 EINA_INLIST_GET(it->wd->reorder_it),
1405 EINA_INLIST_GET(it));
1407 it->wd->reorder_item_changed = EINA_TRUE;
1408 it->wd->move_effect_enabled = EINA_TRUE;
1409 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1410 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1416 else if (it->item->item_moving_effect_timer)
1418 ecore_animator_del(it->item->item_moving_effect_timer);
1419 it->item->item_moving_effect_timer = NULL;
1420 it->item->moving = EINA_FALSE;
1425 evas_object_move(VIEW(it), x, y);
1426 evas_object_resize(VIEW(it), iw, ih);
1429 it->item->group_realized = EINA_TRUE;
1434 _elm_genlist_item_unrealize(it, EINA_FALSE);
1436 it->item->group_realized = EINA_FALSE;
1441 _item_del(Elm_Gen_Item *it)
1443 Evas_Object *obj = WIDGET(it);
1445 evas_event_freeze(evas_object_evas_get(obj));
1446 it->wd->selected = eina_list_remove(it->wd->selected, it);
1447 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
1448 it->wd->item_count--;
1449 _elm_genlist_item_del_serious(it);
1450 elm_gengrid_item_class_unref((Elm_Gengrid_Item_Class *)it->itc);
1451 evas_event_thaw(evas_object_evas_get(obj));
1452 evas_event_thaw_eval(evas_object_evas_get(obj));
1456 _item_unselect(Elm_Gen_Item *it)
1458 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
1459 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
1460 it->highlighted = EINA_FALSE;
1463 it->selected = EINA_FALSE;
1464 it->wd->selected = eina_list_remove(it->wd->selected, it);
1465 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
1470 _calc_job(void *data)
1472 Widget_Data *wd = data;
1473 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1474 Elm_Gen_Item *it, *group_item = NULL;
1475 int count_group = 0;
1479 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1480 if ((cvw != 0) || (cvh != 0))
1482 if ((wd->horizontal) && (wd->item_height > 0))
1483 nmax = cvh / wd->item_height;
1484 else if (wd->item_width > 0)
1485 nmax = cvw / wd->item_width;
1490 EINA_INLIST_FOREACH(wd->items, it)
1492 if (it->item->prev_group != count_group)
1493 it->item->prev_group = count_group;
1496 count = count % nmax;
1498 wd->items_lost += nmax - count;
1499 //printf("%d items and I lost %d\n", count, wd->items_lost);
1501 if (count) count = 0;
1506 if (it->parent != group_item)
1507 it->parent = group_item;
1511 count = wd->item_count + wd->items_lost - count_group;
1514 minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width);
1515 minh = nmax * wd->item_height;
1519 minw = nmax * wd->item_width;
1520 minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1523 if ((minw != wd->minw) || (minh != wd->minh))
1527 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1531 evas_object_smart_changed(wd->pan_smart);
1533 wd->calc_job = NULL;
1537 _pan_add(Evas_Object *obj)
1540 Evas_Object_Smart_Clipped_Data *cd;
1543 cd = evas_object_smart_data_get(obj);
1546 sd->__clipped_data = *cd;
1548 evas_object_smart_data_set(obj, sd);
1552 _pan_del(Evas_Object *obj)
1554 Pan *sd = evas_object_smart_data_get(obj);
1561 _pan_set(Evas_Object *obj,
1565 Pan *sd = evas_object_smart_data_get(obj);
1566 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1569 evas_object_smart_changed(obj);
1573 _pan_get(Evas_Object *obj,
1577 Pan *sd = evas_object_smart_data_get(obj);
1578 if (x) *x = sd->wd->pan_x;
1579 if (y) *y = sd->wd->pan_y;
1583 _pan_child_size_get(Evas_Object *obj,
1587 Pan *sd = evas_object_smart_data_get(obj);
1588 if (w) *w = sd->wd->minw;
1589 if (h) *h = sd->wd->minh;
1593 _pan_max_get(Evas_Object *obj,
1597 Pan *sd = evas_object_smart_data_get(obj);
1601 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1603 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1605 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1609 _pan_min_get(Evas_Object *obj,
1613 Pan *sd = evas_object_smart_data_get(obj);
1614 Evas_Coord mx = 0, my = 0;
1617 _pan_max_get(obj, &mx, &my);
1619 *x = -mx * sd->wd->align_x;
1621 *y = -my * sd->wd->align_y;
1625 _pan_resize(Evas_Object *obj,
1629 Pan *sd = evas_object_smart_data_get(obj);
1632 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1633 if ((ow == w) && (oh == h)) return;
1634 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1635 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1639 _pan_calculate(Evas_Object *obj)
1641 Pan *sd = evas_object_smart_data_get(obj);
1642 Evas_Coord cx = 0, cy = 0;
1646 if (!sd->wd->nmax) return;
1648 sd->wd->reorder_item_changed = EINA_FALSE;
1650 EINA_INLIST_FOREACH(sd->wd->items, it)
1654 if (sd->wd->horizontal)
1671 _item_place(it, cx, cy);
1672 if (sd->wd->reorder_item_changed) return;
1675 if (sd->wd->horizontal)
1688 if (sd->wd->horizontal)
1690 cy = (cy + 1) % sd->wd->nmax;
1695 cx = (cx + 1) % sd->wd->nmax;
1700 _group_item_place(sd);
1703 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
1705 if (!sd->wd->reorder_item_changed)
1707 sd->wd->old_pan_x = sd->wd->pan_x;
1708 sd->wd->old_pan_y = sd->wd->pan_y;
1710 sd->wd->move_effect_enabled = EINA_FALSE;
1712 evas_object_smart_callback_call(sd->wd->obj, SIG_CHANGED, NULL);
1716 _pan_move(Evas_Object *obj,
1717 Evas_Coord x __UNUSED__,
1718 Evas_Coord y __UNUSED__)
1720 Pan *sd = evas_object_smart_data_get(obj);
1722 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1723 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1727 _hold_on(void *data __UNUSED__,
1729 void *event_info __UNUSED__)
1731 Widget_Data *wd = elm_widget_data_get(obj);
1733 elm_smart_scroller_hold_set(wd->scr, 1);
1737 _hold_off(void *data __UNUSED__,
1739 void *event_info __UNUSED__)
1741 Widget_Data *wd = elm_widget_data_get(obj);
1743 elm_smart_scroller_hold_set(wd->scr, 0);
1747 _freeze_on(void *data __UNUSED__,
1749 void *event_info __UNUSED__)
1751 Widget_Data *wd = elm_widget_data_get(obj);
1753 elm_smart_scroller_freeze_set(wd->scr, 1);
1757 _freeze_off(void *data __UNUSED__,
1759 void *event_info __UNUSED__)
1761 Widget_Data *wd = elm_widget_data_get(obj);
1763 elm_smart_scroller_freeze_set(wd->scr, 0);
1767 _scr_anim_start(void *data,
1768 Evas_Object *obj __UNUSED__,
1769 void *event_info __UNUSED__)
1771 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1775 _scr_anim_stop(void *data,
1776 Evas_Object *obj __UNUSED__,
1777 void *event_info __UNUSED__)
1779 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1783 _scr_drag_start(void *data,
1784 Evas_Object *obj __UNUSED__,
1785 void *event_info __UNUSED__)
1787 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1791 _scr_drag_stop(void *data,
1792 Evas_Object *obj __UNUSED__,
1793 void *event_info __UNUSED__)
1795 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1799 _edge_left(void *data,
1800 Evas_Object *scr __UNUSED__,
1801 void *event_info __UNUSED__)
1803 evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
1807 _edge_right(void *data,
1808 Evas_Object *scr __UNUSED__,
1809 void *event_info __UNUSED__)
1811 evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
1815 _edge_top(void *data,
1816 Evas_Object *scr __UNUSED__,
1817 void *event_info __UNUSED__)
1819 evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
1823 _edge_bottom(void *data,
1824 Evas_Object *scr __UNUSED__,
1825 void *event_info __UNUSED__)
1827 evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
1831 _scr_scroll(void *data,
1832 Evas_Object *obj __UNUSED__,
1833 void *event_info __UNUSED__)
1835 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1839 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1841 const Elm_Gen_Item *it = data;
1842 const Elm_Gen_Item *item1 = data1;
1844 return it->wd->item_compare_data_cb(it->base.data, item1->base.data);
1848 _elm_gengrid_item_compare(const void *data, const void *data1)
1850 Elm_Gen_Item *it, *item1;
1851 it = ELM_GEN_ITEM_FROM_INLIST(data);
1852 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
1853 return it->wd->item_compare_cb(it, item1);
1857 _item_disable_hook(Elm_Object_Item *it)
1859 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1860 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
1862 if (_it->generation < _it->wd->generation) return;
1866 if (elm_widget_item_disabled_get(_it))
1867 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
1869 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
1874 _item_del_pre_hook(Elm_Object_Item *it)
1876 ELM_OBJ_ITEM_CHECK_OR_RETURN(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,
2242 ELM_CHECK_WIDTYPE(obj, widtype);
2243 Widget_Data *wd = elm_widget_data_get(obj);
2245 if (setting == wd->horizontal) return;
2246 wd->horizontal = setting;
2248 /* Update the items to conform to the new layout */
2249 if (wd->calc_job) ecore_job_del(wd->calc_job);
2250 wd->calc_job = ecore_job_add(_calc_job, wd);
2254 elm_gengrid_horizontal_get(const Evas_Object *obj)
2256 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2257 Widget_Data *wd = elm_widget_data_get(obj);
2258 if (!wd) return EINA_FALSE;
2259 return wd->horizontal;
2263 elm_gengrid_clear(Evas_Object *obj)
2265 elm_genlist_clear(obj);
2268 EAPI const Evas_Object *
2269 elm_gengrid_item_object_get(const Elm_Object_Item *it)
2271 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2276 elm_gengrid_item_update(Elm_Object_Item *it)
2278 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2279 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2280 if (!_it->realized) return;
2281 if (_it->want_unrealize) return;
2282 _elm_genlist_item_unrealize(_it, EINA_FALSE);
2284 _item_place(_it, _it->x, _it->y);
2288 elm_gengrid_item_data_get(const Elm_Object_Item *it)
2290 return elm_object_item_data_get(it);
2294 elm_gengrid_item_data_set(Elm_Object_Item *it,
2297 elm_object_item_data_set(it, (void *) data);
2300 EAPI const Elm_Gengrid_Item_Class *
2301 elm_gengrid_item_item_class_get(const Elm_Object_Item *it)
2303 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2304 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2305 if (_it->generation < _it->wd->generation) return NULL;
2310 elm_gengrid_item_item_class_set(Elm_Object_Item *it,
2311 const Elm_Gengrid_Item_Class *itc)
2313 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2314 EINA_SAFETY_ON_NULL_RETURN(itc);
2315 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2316 if (_it->generation < _it->wd->generation) return;
2318 elm_gengrid_item_update(it);
2322 elm_gengrid_item_pos_get(const Elm_Object_Item *it,
2326 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2327 if (x) *x = ((Elm_Gen_Item *) it)->x;
2328 if (y) *y = ((Elm_Gen_Item *) it)->y;
2332 elm_gengrid_multi_select_set(Evas_Object *obj,
2335 ELM_CHECK_WIDTYPE(obj, widtype);
2336 Widget_Data *wd = elm_widget_data_get(obj);
2342 elm_gengrid_multi_select_get(const Evas_Object *obj)
2344 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2345 Widget_Data *wd = elm_widget_data_get(obj);
2346 if (!wd) return EINA_FALSE;
2350 EAPI Elm_Object_Item *
2351 elm_gengrid_selected_item_get(const Evas_Object *obj)
2353 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2354 Widget_Data *wd = elm_widget_data_get(obj);
2355 if (!wd) return NULL;
2356 if (wd->selected) return wd->selected->data;
2360 EAPI const Eina_List *
2361 elm_gengrid_selected_items_get(const Evas_Object *obj)
2363 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2364 Widget_Data *wd = elm_widget_data_get(obj);
2365 if (!wd) return NULL;
2366 return wd->selected;
2370 elm_gengrid_item_selected_set(Elm_Object_Item *it,
2373 elm_genlist_item_selected_set(it, selected);
2377 elm_gengrid_item_selected_get(const Elm_Object_Item *it)
2379 return elm_genlist_item_selected_get(it);
2383 elm_gengrid_item_disabled_set(Elm_Object_Item *it,
2386 elm_object_item_disabled_set(it, disabled);
2390 elm_gengrid_item_disabled_get(const Elm_Object_Item *it)
2392 return elm_object_item_disabled_get(it);
2395 static Evas_Object *
2396 _elm_gengrid_item_label_create(void *data,
2397 Evas_Object *obj __UNUSED__,
2398 Evas_Object *tooltip,
2399 void *it __UNUSED__)
2401 Evas_Object *label = elm_label_add(tooltip);
2404 elm_object_style_set(label, "tooltip");
2405 elm_object_text_set(label, data);
2410 _elm_gengrid_item_label_del_cb(void *data,
2411 Evas_Object *obj __UNUSED__,
2412 void *event_info __UNUSED__)
2414 eina_stringshare_del(data);
2418 elm_gengrid_item_tooltip_text_set(Elm_Object_Item *it,
2421 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2422 text = eina_stringshare_add(text);
2423 elm_gengrid_item_tooltip_content_cb_set(it, _elm_gengrid_item_label_create,
2425 _elm_gengrid_item_label_del_cb);
2429 elm_gengrid_item_tooltip_content_cb_set(Elm_Object_Item *it,
2430 Elm_Tooltip_Item_Content_Cb func,
2432 Evas_Smart_Cb del_cb)
2434 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
2435 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2437 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
2440 if (_it->tooltip.del_cb)
2441 _it->tooltip.del_cb((void *)_it->tooltip.data, WIDGET(_it), _it);
2442 _it->tooltip.content_cb = func;
2443 _it->tooltip.data = data;
2444 _it->tooltip.del_cb = del_cb;
2447 elm_widget_item_tooltip_content_cb_set(_it,
2448 _it->tooltip.content_cb,
2449 _it->tooltip.data, NULL);
2450 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
2451 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
2457 if (del_cb) del_cb((void *)data, NULL, NULL);
2461 elm_gengrid_item_tooltip_unset(Elm_Object_Item *it)
2463 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2464 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2466 if ((VIEW(_it)) && (_it->tooltip.content_cb))
2467 elm_widget_item_tooltip_unset(_it);
2469 if (_it->tooltip.del_cb)
2470 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
2471 _it->tooltip.del_cb = NULL;
2472 _it->tooltip.content_cb = NULL;
2473 _it->tooltip.data = NULL;
2474 _it->tooltip.free_size = EINA_FALSE;
2475 if (_it->tooltip.style)
2476 elm_gengrid_item_tooltip_style_set(it, NULL);
2480 elm_gengrid_item_tooltip_style_set(Elm_Object_Item *it,
2483 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2484 eina_stringshare_replace(&((Elm_Gen_Item *) it)->tooltip.style, style);
2485 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
2489 elm_gengrid_item_tooltip_style_get(const Elm_Object_Item *it)
2491 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2492 return ((Elm_Gen_Item *) it)->tooltip.style;
2496 elm_gengrid_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
2498 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2499 ((Elm_Gen_Item *) it)->tooltip.free_size = disable;
2500 if (VIEW(it)) return elm_widget_item_tooltip_window_mode_set(it, disable);
2505 elm_gengrid_item_tooltip_window_mode_get(const Elm_Object_Item *it)
2507 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2508 return ((Elm_Gen_Item *) it)->tooltip.free_size;
2512 elm_gengrid_item_cursor_set(Elm_Object_Item *it,
2515 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2516 eina_stringshare_replace(&((Elm_Gen_Item *) it)->mouse_cursor, cursor);
2517 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
2521 elm_gengrid_item_cursor_get(const Elm_Object_Item *it)
2523 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2524 return elm_widget_item_cursor_get(it);
2528 elm_gengrid_item_cursor_unset(Elm_Object_Item *it)
2530 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2531 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2532 if (!_it->mouse_cursor)
2536 elm_widget_item_cursor_unset(_it);
2538 eina_stringshare_del(_it->mouse_cursor);
2539 _it->mouse_cursor = NULL;
2543 elm_gengrid_item_cursor_style_set(Elm_Object_Item *it,
2546 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2547 elm_widget_item_cursor_style_set(it, style);
2551 elm_gengrid_item_cursor_style_get(const Elm_Object_Item *it)
2553 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2554 return elm_widget_item_cursor_style_get(it);
2558 elm_gengrid_item_cursor_engine_only_set(Elm_Object_Item *it,
2559 Eina_Bool engine_only)
2561 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2562 elm_widget_item_cursor_engine_only_set(it, engine_only);
2566 elm_gengrid_item_cursor_engine_only_get(const Elm_Object_Item *it)
2568 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2569 return elm_widget_item_cursor_engine_only_get(it);
2573 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2574 Eina_Bool reorder_mode)
2576 ELM_CHECK_WIDTYPE(obj, widtype);
2577 Widget_Data *wd = elm_widget_data_get(obj);
2579 wd->reorder_mode = reorder_mode;
2583 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2585 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2586 Widget_Data *wd = elm_widget_data_get(obj);
2587 if (!wd) return EINA_FALSE;
2588 return wd->reorder_mode;
2592 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2593 Eina_Bool always_select)
2595 elm_genlist_always_select_mode_set(obj, always_select);
2599 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2601 return elm_genlist_always_select_mode_get(obj);
2605 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2606 Eina_Bool no_select)
2608 elm_genlist_no_select_mode_set(obj, no_select);
2612 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2614 return elm_genlist_no_select_mode_get(obj);
2618 elm_gengrid_bounce_set(Evas_Object *obj,
2622 elm_genlist_bounce_set(obj, h_bounce, v_bounce);
2626 elm_gengrid_bounce_get(const Evas_Object *obj,
2627 Eina_Bool *h_bounce,
2628 Eina_Bool *v_bounce)
2630 elm_genlist_bounce_get(obj, h_bounce, v_bounce);
2634 elm_gengrid_page_relative_set(Evas_Object *obj,
2638 _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
2642 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2644 _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
2648 elm_gengrid_page_size_set(Evas_Object *obj,
2649 Evas_Coord h_pagesize,
2650 Evas_Coord v_pagesize)
2652 _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
2656 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2658 _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
2662 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2664 _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
2668 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2670 _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
2674 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2676 _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
2679 EAPI Elm_Object_Item *
2680 elm_gengrid_first_item_get(const Evas_Object *obj)
2682 return elm_genlist_first_item_get(obj);
2685 EAPI Elm_Object_Item *
2686 elm_gengrid_last_item_get(const Evas_Object *obj)
2688 return elm_genlist_last_item_get(obj);
2691 EAPI Elm_Object_Item *
2692 elm_gengrid_item_next_get(const Elm_Object_Item *it)
2694 return elm_genlist_item_next_get(it);
2697 EAPI Elm_Object_Item *
2698 elm_gengrid_item_prev_get(const Elm_Object_Item *it)
2700 return elm_genlist_item_prev_get(it);
2704 elm_gengrid_item_gengrid_get(const Elm_Object_Item *it)
2706 return elm_object_item_widget_get(it);
2710 elm_gengrid_item_show(Elm_Object_Item *it)
2712 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2713 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2714 Widget_Data *wd = _it->wd;
2715 Evas_Coord minx = 0, miny = 0;
2717 if ((_it->generation < _it->wd->generation)) return;
2718 _pan_min_get(wd->pan_smart, &minx, &miny);
2721 elm_smart_scroller_region_bring_in(_it->wd->scr,
2722 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2723 _it->y * wd->item_height + miny,
2724 _it->wd->item_width,
2725 _it->wd->item_height);
2727 elm_smart_scroller_region_bring_in(_it->wd->scr,
2728 _it->x * wd->item_width + minx,
2729 ((_it->y - _it->item->prev_group) * wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2730 _it->wd->item_width,
2731 _it->wd->item_height);
2735 elm_gengrid_item_bring_in(Elm_Object_Item *it)
2737 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2738 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2740 if (_it->generation < _it->wd->generation) return;
2742 Evas_Coord minx = 0, miny = 0;
2743 Widget_Data *wd = _it->wd;
2744 _pan_min_get(wd->pan_smart, &minx, &miny);
2747 elm_smart_scroller_region_bring_in(_it->wd->scr,
2748 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2749 _it->y * wd->item_height + miny,
2750 _it->wd->item_width,
2751 _it->wd->item_height);
2753 elm_smart_scroller_region_bring_in(_it->wd->scr,
2754 _it->x * wd->item_width + minx,
2755 ((_it->y - _it->item->prev_group)* wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2756 _it->wd->item_width,
2757 _it->wd->item_height);
2761 elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill)
2763 ELM_CHECK_WIDTYPE(obj, widtype);
2764 Widget_Data *wd = elm_widget_data_get(obj);
2767 if (wd->filled != fill)
2772 elm_gengrid_filled_get(const Evas_Object *obj)
2774 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2775 Widget_Data *wd = elm_widget_data_get(obj);
2776 if (!wd) return EINA_FALSE;
2780 EAPI Elm_Gengrid_Item_Class *
2781 elm_gengrid_item_class_new(void)
2783 Elm_Gengrid_Item_Class *itc;
2785 itc = calloc(1, sizeof(Elm_Gengrid_Item_Class));
2788 itc->version = ELM_GENGRID_ITEM_CLASS_VERSION;
2790 itc->delete_me = EINA_FALSE;
2796 elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
2798 if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
2800 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
2801 if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
2811 elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
2813 if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
2816 if (itc->refcount == 0) itc->refcount--;
2821 elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
2823 if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
2825 if (itc->refcount > 0) itc->refcount--;
2826 if (itc->delete_me && (!itc->refcount))
2827 elm_gengrid_item_class_free(itc);