1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 #include "els_scroller.h"
5 #include "elm_gen_common.h"
7 // internally allocated
8 #define CLASS_ALLOCATED 0x3a70f00f
12 * Handle non-homogeneous objects too.
16 #define REORDER_EFFECT_TIME 0.5
18 #define ELM_GEN_SETUP(wd) \
19 (wd)->calc_cb = (Ecore_Cb)_calc_job
21 #define ELM_GEN_ITEM_SETUP(it) \
22 (it)->del_cb = (Ecore_Cb)_item_del; \
23 (it)->highlight_cb = (Ecore_Cb)_item_highlight; \
24 (it)->unsel_cb = (Ecore_Cb)_item_unselect; \
25 (it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
27 struct Elm_Gen_Item_Type
30 Ecore_Animator *item_moving_effect_timer;
31 Evas_Coord gx, gy, ox, oy, tx, ty, rx, ry;
32 unsigned int moving_effect_start_time;
35 Eina_Bool group_realized : 1;
39 static const char *widtype = NULL;
40 static void _item_highlight(Elm_Gen_Item *it);
41 static void _item_unrealize_cb(Elm_Gen_Item *it);
42 static void _item_unselect(Elm_Gen_Item *it);
43 static void _calc_job(void *data);
44 static void _on_focus_hook(void *data,
46 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
47 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
48 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
49 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
50 static Eina_Bool _item_single_select_up(Widget_Data *wd);
51 static Eina_Bool _item_single_select_down(Widget_Data *wd);
52 static Eina_Bool _item_single_select_left(Widget_Data *wd);
53 static Eina_Bool _item_single_select_right(Widget_Data *wd);
54 static Eina_Bool _event_hook(Evas_Object *obj,
56 Evas_Callback_Type type,
58 static Eina_Bool _deselect_all_items(Widget_Data *wd);
60 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
61 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
63 static const char SIG_ACTIVATED[] = "activated";
64 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
65 static const char SIG_LONGPRESSED[] = "longpressed";
66 static const char SIG_SELECTED[] = "selected";
67 static const char SIG_UNSELECTED[] = "unselected";
68 static const char SIG_REALIZED[] = "realized";
69 static const char SIG_UNREALIZED[] = "unrealized";
70 static const char SIG_CHANGED[] = "changed";
71 static const char SIG_DRAG_START_UP[] = "drag,start,up";
72 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
73 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
74 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
75 static const char SIG_DRAG_STOP[] = "drag,stop";
76 static const char SIG_DRAG[] = "drag";
77 static const char SIG_SCROLL[] = "scroll";
78 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
79 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
80 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
81 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
82 static const char SIG_EDGE_TOP[] = "edge,top";
83 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
84 static const char SIG_EDGE_LEFT[] = "edge,left";
85 static const char SIG_EDGE_RIGHT[] = "edge,right";
86 static const char SIG_MOVED[] = "moved";
87 static const char SIG_INDEX_UPDATE[] = "index,update";
89 static const Evas_Smart_Cb_Description _signals[] = {
91 {SIG_CLICKED_DOUBLE, ""},
92 {SIG_LONGPRESSED, ""},
98 {SIG_DRAG_START_UP, ""},
99 {SIG_DRAG_START_DOWN, ""},
100 {SIG_DRAG_START_LEFT, ""},
101 {SIG_DRAG_START_RIGHT, ""},
105 {SIG_SCROLL_ANIM_START, ""},
106 {SIG_SCROLL_ANIM_STOP, ""},
107 {SIG_SCROLL_DRAG_START, ""},
108 {SIG_SCROLL_DRAG_STOP, ""},
110 {SIG_EDGE_BOTTOM, ""},
112 {SIG_EDGE_RIGHT, ""},
118 _event_hook(Evas_Object *obj,
119 Evas_Object *src __UNUSED__,
120 Evas_Callback_Type type,
123 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
124 Evas_Event_Key_Down *ev = event_info;
125 Widget_Data *wd = elm_widget_data_get(obj);
126 if (!wd) return EINA_FALSE;
127 if (!wd->items) return EINA_FALSE;
128 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
129 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
131 Elm_Object_Item *it = NULL;
134 Evas_Coord step_x = 0;
135 Evas_Coord step_y = 0;
138 Evas_Coord page_x = 0;
139 Evas_Coord page_y = 0;
141 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
142 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
143 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
144 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
146 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
148 if ((wd->horizontal) &&
149 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
150 (_item_multi_select_up(wd)))
151 || (_item_single_select_up(wd))))
153 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
156 else if ((!wd->horizontal) &&
157 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
158 (_item_multi_select_left(wd)))
159 || (_item_single_select_left(wd))))
161 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
167 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
169 if ((wd->horizontal) &&
170 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
171 (_item_multi_select_down(wd)))
172 || (_item_single_select_down(wd))))
174 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
177 else if ((!wd->horizontal) &&
178 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
179 (_item_multi_select_right(wd)))
180 || (_item_single_select_right(wd))))
182 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
188 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
190 if ((wd->horizontal) &&
191 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
192 (_item_multi_select_left(wd)))
193 || (_item_single_select_left(wd))))
195 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
198 else if ((!wd->horizontal) &&
199 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
200 (_item_multi_select_up(wd)))
201 || (_item_single_select_up(wd))))
203 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
209 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
211 if ((wd->horizontal) &&
212 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
213 (_item_multi_select_right(wd)))
214 || (_item_single_select_right(wd))))
216 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
219 else if ((!wd->horizontal) &&
220 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
221 (_item_multi_select_down(wd)))
222 || (_item_single_select_down(wd))))
224 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
230 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
232 it = elm_gengrid_first_item_get(obj);
233 elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN);
234 elm_gengrid_item_selected_set(it, EINA_TRUE);
235 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
238 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
240 it = elm_gengrid_last_item_get(obj);
241 elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN);
242 elm_gengrid_item_selected_set(it, EINA_TRUE);
243 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
246 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
251 x -= -(page_x * v_w) / 100;
258 y -= -(page_y * v_h) / 100;
263 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
268 x += -(page_x * v_w) / 100;
275 y += -(page_y * v_h) / 100;
280 else if (!strcmp(ev->keyname, "Escape"))
282 if (!_deselect_all_items(wd)) return EINA_FALSE;
283 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
286 else if (((!strcmp(ev->keyname, "Return")) ||
287 (!strcmp(ev->keyname, "KP_Enter")) ||
288 (!strcmp(ev->keyname, "space")))
289 && (!wd->multi) && (wd->selected))
291 it = elm_gengrid_selected_item_get(obj);
292 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
294 else return EINA_FALSE;
296 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
297 elm_smart_scroller_child_pos_set(wd->scr, x, y);
302 _deselect_all_items(Widget_Data *wd)
304 if (!wd->selected) return EINA_FALSE;
306 elm_gengrid_item_selected_set((Elm_Object_Item *) wd->selected->data,
313 _item_multi_select_left(Widget_Data *wd)
315 if (!wd->selected) return EINA_FALSE;
317 Elm_Object_Item *prev =
318 elm_gengrid_item_prev_get(wd->last_selected_item);
319 if (!prev) return EINA_TRUE;
320 if (elm_gengrid_item_selected_get(prev))
322 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
323 wd->last_selected_item = prev;
324 elm_gengrid_item_show(wd->last_selected_item, ELM_GENGRID_ITEM_SCROLLTO_IN);
328 elm_gengrid_item_selected_set(prev, EINA_TRUE);
329 elm_gengrid_item_show(prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
336 _item_multi_select_right(Widget_Data *wd)
338 if (!wd->selected) return EINA_FALSE;
340 Elm_Object_Item *next =
341 elm_gengrid_item_next_get(wd->last_selected_item);
342 if (!next) return EINA_TRUE;
343 if (elm_gengrid_item_selected_get(next))
345 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
346 wd->last_selected_item = next;
347 elm_gengrid_item_show(wd->last_selected_item, ELM_GENGRID_ITEM_SCROLLTO_IN);
351 elm_gengrid_item_selected_set(next, EINA_TRUE);
352 elm_gengrid_item_show(next, ELM_GENGRID_ITEM_SCROLLTO_IN);
359 _item_multi_select_up(Widget_Data *wd)
362 Eina_Bool r = EINA_TRUE;
364 if (!wd->selected) return EINA_FALSE;
366 for (i = 0; (r) && (i < wd->nmax); i++)
367 r &= _item_multi_select_left(wd);
373 _item_multi_select_down(Widget_Data *wd)
376 Eina_Bool r = EINA_TRUE;
378 if (!wd->selected) return EINA_FALSE;
380 for (i = 0; (r) && (i < wd->nmax); i++)
381 r &= _item_multi_select_right(wd);
387 _item_single_select_up(Widget_Data *wd)
395 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
396 while ((prev) && (prev->generation < wd->generation))
397 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
398 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
399 elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
403 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
405 if (!prev) return EINA_FALSE;
407 for (i = 1; i < wd->nmax; i++)
409 Elm_Object_Item *tmp =
410 elm_gengrid_item_prev_get((Elm_Object_Item *) prev);
411 if (!tmp) return EINA_FALSE;
412 prev = (Elm_Gen_Item *) tmp;
415 _deselect_all_items(wd);
417 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
418 elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
423 _item_single_select_down(Widget_Data *wd)
431 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
432 while ((next) && (next->generation < wd->generation))
433 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
434 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
435 elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN);
439 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
441 if (!next) return EINA_FALSE;
443 for (i = 1; i < wd->nmax; i++)
445 Elm_Object_Item *tmp =
446 elm_gengrid_item_next_get((Elm_Object_Item *) next);
447 if (!tmp) return EINA_FALSE;
448 next = (Elm_Gen_Item *) tmp;
451 _deselect_all_items(wd);
453 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
454 elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN);
459 _item_single_select_left(Widget_Data *wd)
464 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
465 while ((prev) && (prev->generation < wd->generation))
466 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
469 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
471 if (!prev) return EINA_FALSE;
473 _deselect_all_items(wd);
475 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
476 elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
481 _item_single_select_right(Widget_Data *wd)
486 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
487 while ((next) && (next->generation < wd->generation))
488 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
491 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
493 if (!next) return EINA_FALSE;
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, ELM_GENGRID_ITEM_SCROLLTO_IN);
503 _on_focus_hook(void *data __UNUSED__,
506 Widget_Data *wd = elm_widget_data_get(obj);
508 if (elm_widget_focus_get(obj))
510 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
511 evas_object_focus_set(wd->obj, EINA_TRUE);
512 if ((wd->selected) && (!wd->last_selected_item))
513 wd->last_selected_item = eina_list_data_get(wd->selected);
517 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
518 evas_object_focus_set(wd->obj, EINA_FALSE);
523 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
525 Widget_Data *wd = elm_widget_data_get(obj);
528 elm_smart_scroller_mirrored_set(wd->scr, rtl);
529 if (!wd->items) return;
530 it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
534 edje_object_mirrored_set(VIEW(it), rtl);
535 elm_gengrid_item_update((Elm_Object_Item *)it);
536 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
541 _theme_hook(Evas_Object *obj)
543 Widget_Data *wd = elm_widget_data_get(obj);
545 _elm_widget_mirrored_reload(obj);
546 _mirrored_set(obj, elm_widget_mirrored_get(obj));
547 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
548 elm_widget_style_get(obj));
552 _del_pre_hook(Evas_Object *obj)
554 Widget_Data *wd = elm_widget_data_get(obj);
556 elm_gengrid_clear(obj);
557 evas_object_del(wd->pan_smart);
558 wd->pan_smart = NULL;
562 _del_hook(Evas_Object *obj)
564 Widget_Data *wd = elm_widget_data_get(obj);
565 if (wd->calc_job) ecore_job_del(wd->calc_job);
570 _signal_emit_hook(Evas_Object *obj,
571 const char *emission,
574 Widget_Data *wd = elm_widget_data_get(obj);
576 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
581 _signal_callback_add_hook(Evas_Object *obj,
582 const char *emission,
584 Edje_Signal_Cb func_cb,
587 Widget_Data *wd = elm_widget_data_get(obj);
589 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
590 emission, source, func_cb, data);
594 _signal_callback_del_hook(Evas_Object *obj,
595 const char *emission,
597 Edje_Signal_Cb func_cb,
600 Widget_Data *wd = elm_widget_data_get(obj);
602 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scr),
603 emission, source, func_cb, data);
607 _mouse_move(void *data,
608 Evas *evas __UNUSED__,
612 Elm_Gen_Item *it = data;
613 Evas_Event_Mouse_Move *ev = event_info;
614 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
615 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
617 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
619 if (!it->wd->on_hold)
621 it->wd->on_hold = EINA_TRUE;
622 if (!it->wd->wasselected)
626 if ((it->dragging) && (it->down))
630 ecore_timer_del(it->long_timer);
631 it->long_timer = NULL;
633 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
636 if ((!it->down) || (it->wd->longpressed))
640 ecore_timer_del(it->long_timer);
641 it->long_timer = NULL;
643 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
645 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
647 it_scrl_x = ev->cur.canvas.x - it->wd->reorder_it->dx;
648 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
650 if (it_scrl_x < ox) it->wd->reorder_item_x = ox;
651 else if (it_scrl_x + it->wd->item_width > ox + ow)
652 it->wd->reorder_item_x = ox + ow - it->wd->item_width;
653 else it->wd->reorder_item_x = it_scrl_x;
655 if (it_scrl_y < oy) it->wd->reorder_item_y = oy;
656 else if (it_scrl_y + it->wd->item_height > oy + oh)
657 it->wd->reorder_item_y = oy + oh - it->wd->item_height;
658 else it->wd->reorder_item_y = it_scrl_y;
660 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
661 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
665 if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
666 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
667 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
668 x = ev->cur.canvas.x - x;
669 y = ev->cur.canvas.y - y;
672 if (adx < 0) adx = -dx;
675 if (ady < 0) ady = -dy;
678 if ((adx > minw) || (ady > minh))
680 const char *left_drag, *right_drag;
681 if (!elm_widget_mirrored_get(WIDGET(it)))
683 left_drag = SIG_DRAG_START_LEFT;
684 right_drag = SIG_DRAG_START_RIGHT;
688 left_drag = SIG_DRAG_START_RIGHT;
689 right_drag = SIG_DRAG_START_LEFT;
695 ecore_timer_del(it->long_timer);
696 it->long_timer = NULL;
698 if (!it->wd->wasselected)
703 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_START_UP,
708 evas_object_smart_callback_call(WIDGET(it),
715 evas_object_smart_callback_call(WIDGET(it),
716 SIG_DRAG_START_DOWN, it);
720 evas_object_smart_callback_call(WIDGET(it),
723 evas_object_smart_callback_call(WIDGET(it),
731 _long_press(void *data)
733 Elm_Gen_Item *it = data;
735 it->long_timer = NULL;
736 if (elm_widget_item_disabled_get(it)|| (it->dragging))
737 return ECORE_CALLBACK_CANCEL;
738 it->wd->longpressed = EINA_TRUE;
739 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
740 if (it->wd->reorder_mode)
742 it->wd->reorder_it = it;
743 evas_object_raise(VIEW(it));
744 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
745 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
746 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
748 return ECORE_CALLBACK_CANCEL;
752 _mouse_down(void *data,
753 Evas *evas __UNUSED__,
757 Elm_Gen_Item *it = data;
758 Evas_Event_Mouse_Down *ev = event_info;
761 if (ev->button != 1) return;
764 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
765 it->dx = ev->canvas.x - x;
766 it->dy = ev->canvas.y - y;
767 it->wd->longpressed = EINA_FALSE;
768 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
769 else it->wd->on_hold = EINA_FALSE;
770 if (it->wd->on_hold) return;
771 it->wd->wasselected = it->selected;
773 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
775 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
776 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
778 if (it->long_timer) ecore_timer_del(it->long_timer);
780 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
783 it->long_timer = NULL;
787 _mouse_up(void *data,
788 Evas *evas __UNUSED__,
789 Evas_Object *obj __UNUSED__,
792 Elm_Gen_Item *it = data;
793 Evas_Event_Mouse_Up *ev = event_info;
794 Eina_Bool dragged = EINA_FALSE;
796 if (ev->button != 1) return;
797 it->down = EINA_FALSE;
798 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
799 else it->wd->on_hold = EINA_FALSE;
802 ecore_timer_del(it->long_timer);
803 it->long_timer = NULL;
807 it->dragging = EINA_FALSE;
808 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
813 it->wd->longpressed = EINA_FALSE;
814 it->wd->on_hold = EINA_FALSE;
817 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
819 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it->wd->reorder_it);
820 it->wd->reorder_it = NULL;
821 it->wd->move_effect_enabled = EINA_FALSE;
822 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
823 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
825 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
826 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
827 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
829 if (it->wd->longpressed)
831 it->wd->longpressed = EINA_FALSE;
832 if (!it->wd->wasselected) _item_unselect(it);
833 it->wd->wasselected = EINA_FALSE;
838 if (it->want_unrealize)
839 _elm_genlist_item_unrealize(it, EINA_FALSE);
841 if (elm_widget_item_disabled_get(it) || (dragged)) return;
849 else _item_unselect(it);
855 while (it->wd->selected)
856 _item_unselect(it->wd->selected->data);
860 const Eina_List *l, *l_next;
863 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, item2)
864 if (item2 != it) _item_unselect(item2);
872 _item_highlight(Elm_Gen_Item *it)
874 if ((it->wd->select_mode == ELM_OBJECT_SELECT_MODE_NONE) ||
875 (!it->wd->highlight) || (it->highlighted) ||
876 (it->generation < it->wd->generation)) return;
877 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
878 it->highlighted = EINA_TRUE;
882 _elm_gengrid_item_index_update(Elm_Gen_Item *it)
884 if (it->position_update)
886 evas_object_smart_callback_call(WIDGET(it), SIG_INDEX_UPDATE, it);
887 it->position_update = EINA_FALSE;
892 _item_realize(Elm_Gen_Item *it)
897 if ((it->realized) || (it->generation < it->wd->generation)) return;
898 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
899 edje_object_scale_set(VIEW(it), elm_widget_scale_get(WIDGET(it)) *
901 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
902 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
903 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
904 snprintf(style, sizeof(style), "item/%s",
905 it->itc->item_style ? it->itc->item_style : "default");
906 _elm_theme_object_set(WIDGET(it), VIEW(it), "gengrid", style,
907 elm_widget_style_get(WIDGET(it)));
909 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
910 evas_object_color_set(it->spacer, 0, 0, 0, 0);
911 elm_widget_sub_object_add(WIDGET(it), it->spacer);
912 evas_object_size_hint_min_set(it->spacer, 2 * _elm_config->scale, 1);
913 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
915 if (it->itc->func.text_get)
921 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
923 EINA_LIST_FOREACH(it->texts, l, key)
925 char *s = it->itc->func.text_get
926 ((void *)it->base.data, WIDGET(it), key);
929 edje_object_part_text_set(VIEW(it), key, s);
935 if (it->itc->func.content_get)
939 Evas_Object *ic = NULL;
942 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
944 EINA_LIST_FOREACH(it->contents, l, key)
946 if (it->itc->func.content_get)
947 ic = it->itc->func.content_get
948 ((void *)it->base.data, WIDGET(it), key);
951 it->content_objs = eina_list_append(it->content_objs, ic);
952 edje_object_part_swallow(VIEW(it), key, ic);
953 evas_object_show(ic);
954 elm_widget_sub_object_add(WIDGET(it), ic);
959 if (it->itc->func.state_get)
965 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
967 EINA_LIST_FOREACH(it->states, l, key)
969 Eina_Bool on = it->itc->func.state_get
970 ((void *)it->base.data, WIDGET(it), l->data);
973 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
974 edje_object_signal_emit(VIEW(it), buf, "elm");
981 if ((!it->wd->group_item_width) && (!it->wd->group_item_height))
983 edje_object_size_min_restricted_calc(VIEW(it),
984 &it->wd->group_item_width,
985 &it->wd->group_item_height,
986 it->wd->group_item_width,
987 it->wd->group_item_height);
992 if ((!it->wd->item_width) && (!it->wd->item_height))
994 edje_object_size_min_restricted_calc(VIEW(it),
996 &it->wd->item_height,
998 it->wd->item_height);
999 elm_coords_finger_size_adjust(1, &it->wd->item_width,
1000 1, &it->wd->item_height);
1003 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1005 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1007 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1010 _elm_gengrid_item_index_update(it);
1013 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1014 if (elm_widget_item_disabled_get(it))
1015 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1017 evas_object_show(VIEW(it));
1019 if (it->tooltip.content_cb)
1021 elm_widget_item_tooltip_content_cb_set(it,
1022 it->tooltip.content_cb,
1023 it->tooltip.data, NULL);
1024 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1025 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
1028 if (it->mouse_cursor)
1029 elm_widget_item_cursor_set(it, it->mouse_cursor);
1031 it->realized = EINA_TRUE;
1032 it->want_unrealize = EINA_FALSE;
1036 _item_unrealize_cb(Elm_Gen_Item *it)
1038 evas_object_del(VIEW(it));
1040 evas_object_del(it->spacer);
1045 _reorder_item_moving_effect_timer_cb(void *data)
1047 Elm_Gen_Item *it = data;
1051 tt = REORDER_EFFECT_TIME;
1052 t = ((0.0 > (t = ecore_loop_time_get()-it->item->moving_effect_start_time)) ? 0.0 : t);
1053 dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
1054 dy = ((it->item->ty - it->item->oy) / 10) * _elm_config->scale;
1058 it->item->rx += (1 * sin((t / tt) * (M_PI / 2)) * dx);
1059 it->item->ry += (1 * sin((t / tt) * (M_PI / 2)) * dy);
1067 if ((((dx > 0) && (it->item->rx >= it->item->tx)) || ((dx <= 0) && (it->item->rx <= it->item->tx))) &&
1068 (((dy > 0) && (it->item->ry >= it->item->ty)) || ((dy <= 0) && (it->item->ry <= it->item->ty))))
1070 evas_object_move(VIEW(it), it->item->tx, it->item->ty);
1074 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1075 if (it->wd->horizontal)
1076 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1078 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1081 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1082 it->item->moving = EINA_FALSE;
1083 it->item->item_moving_effect_timer = NULL;
1084 return ECORE_CALLBACK_CANCEL;
1087 evas_object_move(VIEW(it), it->item->rx, it->item->ry);
1091 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1092 if (it->wd->horizontal)
1093 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1095 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1098 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1100 return ECORE_CALLBACK_RENEW;
1104 _group_item_place(Pan *sd)
1106 Evas_Coord iw, ih, vw, vh;
1108 Eina_Bool was_realized;
1110 evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1111 if (sd->wd->horizontal)
1113 iw = sd->wd->group_item_width;
1119 ih = sd->wd->group_item_height;
1121 EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1123 was_realized = it->realized;
1124 if (it->item->group_realized)
1128 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1129 evas_object_move(VIEW(it), it->item->gx, it->item->gy);
1130 evas_object_resize(VIEW(it), iw, ih);
1131 evas_object_raise(VIEW(it));
1134 _elm_genlist_item_unrealize(it, EINA_FALSE);
1140 _item_place(Elm_Gen_Item *it,
1144 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1145 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1146 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1150 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &vw, &vh);
1152 /* Preload rows/columns at each side of the Gengrid */
1153 cvx = ox - PRELOAD * it->wd->item_width;
1154 cvy = oy - PRELOAD * it->wd->item_height;
1155 cvw = vw + 2 * PRELOAD * it->wd->item_width;
1156 cvh = vh + 2 * PRELOAD * it->wd->item_height;
1161 items_count = it->wd->item_count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
1162 if (it->wd->horizontal)
1164 int columns, items_visible = 0, items_row;
1166 if (it->wd->item_height > 0)
1167 items_visible = vh / it->wd->item_height;
1168 if (items_visible < 1)
1171 columns = items_count / items_visible;
1172 if (items_count % items_visible)
1175 tcw = (it->wd->item_width * columns) + (it->wd->group_item_width * eina_list_count(it->wd->group_items));
1176 alignw = (vw - tcw) * it->wd->align_x;
1178 items_row = items_visible;
1179 if ((unsigned int)items_row > it->wd->item_count)
1180 items_row = it->wd->item_count;
1182 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1183 tch = it->wd->nmax * it->wd->item_height;
1185 tch = items_row * it->wd->item_height;
1186 alignh = (vh - tch) * it->wd->align_y;
1190 unsigned int rows, items_visible = 0, items_col;
1192 if (it->wd->item_width > 0)
1193 items_visible = vw / it->wd->item_width;
1194 if (items_visible < 1)
1197 rows = items_count / items_visible;
1198 if (items_count % items_visible)
1201 tch = (it->wd->item_height * rows) + (it->wd->group_item_height * eina_list_count(it->wd->group_items));
1202 alignh = (vh - tch) * it->wd->align_y;
1204 items_col = items_visible;
1205 if (items_col > it->wd->item_count)
1206 items_col = it->wd->item_count;
1208 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1209 tcw = it->wd->nmax * it->wd->item_width;
1211 tcw = items_col * it->wd->item_width;
1212 alignw = (vw - tcw) * it->wd->align_x;
1217 if (it->wd->horizontal)
1219 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;
1221 iw = it->wd->group_item_width;
1227 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;
1229 ih = it->wd->group_item_height;
1236 if (it->wd->horizontal)
1238 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;
1239 y = (cy * it->wd->item_height) - it->wd->pan_y + oy + alignh;
1243 x = (cx * it->wd->item_width) - it->wd->pan_x + ox + alignw;
1244 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;
1246 if (elm_widget_mirrored_get(WIDGET(it)))
1247 { /* Switch items side and componsate for pan_x when in RTL mode */
1248 evas_object_geometry_get(WIDGET(it), NULL, NULL, &ww, NULL);
1249 x = ww - x - it->wd->item_width - it->wd->pan_x - it->wd->pan_x;
1251 iw = it->wd->item_width;
1252 ih = it->wd->item_height;
1255 Eina_Bool was_realized = it->realized;
1256 if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1260 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1263 if (it->wd->horizontal)
1265 if (it->parent->item->gx < ox)
1267 it->parent->item->gx = x + it->wd->item_width - it->wd->group_item_width;
1268 if (it->parent->item->gx > ox)
1269 it->parent->item->gx = ox;
1271 it->parent->item->group_realized = EINA_TRUE;
1275 if (it->parent->item->gy < oy)
1277 it->parent->item->gy = y + it->wd->item_height - it->wd->group_item_height;
1278 if (it->parent->item->gy > oy)
1279 it->parent->item->gy = oy;
1281 it->parent->item->group_realized = EINA_TRUE;
1284 if (it->wd->reorder_mode)
1286 if (it->wd->reorder_it)
1288 if (it->item->moving) return;
1290 if (!it->wd->move_effect_enabled)
1295 if (it->wd->reorder_it == it)
1297 evas_object_move(VIEW(it),
1298 it->wd->reorder_item_x, it->wd->reorder_item_y);
1299 evas_object_resize(VIEW(it), iw, ih);
1304 if (it->wd->move_effect_enabled)
1306 if ((it->item->ox != x) || (it->item->oy != y))
1308 if (((it->wd->old_pan_x == it->wd->pan_x) && (it->wd->old_pan_y == it->wd->pan_y)) ||
1309 ((it->wd->old_pan_x != it->wd->pan_x) && !(it->item->ox - it->wd->pan_x + it->wd->old_pan_x == x)) ||
1310 ((it->wd->old_pan_y != it->wd->pan_y) && !(it->item->oy - it->wd->pan_y + it->wd->old_pan_y == y)))
1314 it->item->rx = it->item->ox;
1315 it->item->ry = it->item->oy;
1316 it->item->moving = EINA_TRUE;
1317 it->item->moving_effect_start_time = ecore_loop_time_get();
1318 it->item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
1325 Evas_Coord nx, ny, nw, nh;
1328 if (it->wd->horizontal)
1330 nx = x + (it->wd->group_item_width / 2);
1338 ny = y + (it->wd->group_item_height / 2);
1345 nx = x + (it->wd->item_width / 2);
1346 ny = y + (it->wd->item_height / 2);
1351 if ( ELM_RECTS_INTERSECT(it->wd->reorder_item_x, it->wd->reorder_item_y,
1352 it->wd->item_width, it->wd->item_height,
1355 if (it->wd->horizontal)
1357 if ((it->wd->nmax * it->wd->reorder_it->x + it->wd->reorder_it->y) >
1358 (it->wd->nmax * it->x + it->y))
1359 reorder_item_move_forward = EINA_TRUE;
1363 if ((it->wd->nmax * it->wd->reorder_it->y + it->wd->reorder_it->x) >
1364 (it->wd->nmax * it->y + it->x))
1365 reorder_item_move_forward = EINA_TRUE;
1368 it->wd->items = eina_inlist_remove(it->wd->items,
1369 EINA_INLIST_GET(it->wd->reorder_it));
1370 if (reorder_item_move_forward)
1371 it->wd->items = eina_inlist_prepend_relative(it->wd->items,
1372 EINA_INLIST_GET(it->wd->reorder_it),
1373 EINA_INLIST_GET(it));
1375 it->wd->items = eina_inlist_append_relative(it->wd->items,
1376 EINA_INLIST_GET(it->wd->reorder_it),
1377 EINA_INLIST_GET(it));
1379 it->wd->reorder_item_changed = EINA_TRUE;
1380 it->wd->move_effect_enabled = EINA_TRUE;
1381 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1382 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1388 else if (it->item->item_moving_effect_timer)
1390 ecore_animator_del(it->item->item_moving_effect_timer);
1391 it->item->item_moving_effect_timer = NULL;
1392 it->item->moving = EINA_FALSE;
1397 evas_object_move(VIEW(it), x, y);
1398 evas_object_resize(VIEW(it), iw, ih);
1401 it->item->group_realized = EINA_TRUE;
1406 _elm_genlist_item_unrealize(it, EINA_FALSE);
1408 it->item->group_realized = EINA_FALSE;
1413 _item_position_update(Eina_Inlist *list, int idx)
1417 EINA_INLIST_FOREACH(list, it)
1419 it->position = idx++;
1420 it->position_update = EINA_TRUE;
1425 _item_del(Elm_Gen_Item *it)
1427 Evas_Object *obj = WIDGET(it);
1429 evas_event_freeze(evas_object_evas_get(obj));
1430 it->wd->selected = eina_list_remove(it->wd->selected, it);
1431 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
1432 it->wd->item_count--;
1433 _elm_genlist_item_del_serious(it);
1434 elm_gengrid_item_class_unref((Elm_Gengrid_Item_Class *)it->itc);
1435 evas_event_thaw(evas_object_evas_get(obj));
1436 evas_event_thaw_eval(evas_object_evas_get(obj));
1440 _item_unselect(Elm_Gen_Item *it)
1442 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
1443 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
1444 it->highlighted = EINA_FALSE;
1447 it->selected = EINA_FALSE;
1448 it->wd->selected = eina_list_remove(it->wd->selected, it);
1449 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
1454 _calc_job(void *data)
1456 Widget_Data *wd = data;
1457 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1458 Elm_Gen_Item *it, *group_item = NULL;
1459 int count_group = 0;
1463 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1464 if ((cvw != 0) || (cvh != 0))
1466 if ((wd->horizontal) && (wd->item_height > 0))
1467 nmax = cvh / wd->item_height;
1468 else if (wd->item_width > 0)
1469 nmax = cvw / wd->item_width;
1474 EINA_INLIST_FOREACH(wd->items, it)
1476 if (it->item->prev_group != count_group)
1477 it->item->prev_group = count_group;
1480 count = count % nmax;
1482 wd->items_lost += nmax - count;
1483 //printf("%d items and I lost %d\n", count, wd->items_lost);
1485 if (count) count = 0;
1490 if (it->parent != group_item)
1491 it->parent = group_item;
1495 count = wd->item_count + wd->items_lost - count_group;
1498 minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width);
1499 minh = nmax * wd->item_height;
1503 minw = nmax * wd->item_width;
1504 minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1507 if ((minw != wd->minw) || (minh != wd->minh))
1511 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1515 evas_object_smart_changed(wd->pan_smart);
1517 wd->calc_job = NULL;
1521 _pan_add(Evas_Object *obj)
1524 Evas_Object_Smart_Clipped_Data *cd;
1527 cd = evas_object_smart_data_get(obj);
1530 sd->__clipped_data = *cd;
1532 evas_object_smart_data_set(obj, sd);
1536 _pan_del(Evas_Object *obj)
1538 Pan *sd = evas_object_smart_data_get(obj);
1545 _pan_set(Evas_Object *obj,
1549 Pan *sd = evas_object_smart_data_get(obj);
1550 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1553 evas_object_smart_changed(obj);
1557 _pan_get(Evas_Object *obj,
1561 Pan *sd = evas_object_smart_data_get(obj);
1562 if (x) *x = sd->wd->pan_x;
1563 if (y) *y = sd->wd->pan_y;
1567 _pan_child_size_get(Evas_Object *obj,
1571 Pan *sd = evas_object_smart_data_get(obj);
1572 if (w) *w = sd->wd->minw;
1573 if (h) *h = sd->wd->minh;
1577 _pan_max_get(Evas_Object *obj,
1581 Pan *sd = evas_object_smart_data_get(obj);
1585 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1587 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1589 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1593 _pan_min_get(Evas_Object *obj,
1597 Pan *sd = evas_object_smart_data_get(obj);
1598 Evas_Coord mx = 0, my = 0;
1601 _pan_max_get(obj, &mx, &my);
1603 *x = -mx * sd->wd->align_x;
1605 *y = -my * sd->wd->align_y;
1609 _pan_resize(Evas_Object *obj,
1613 Pan *sd = evas_object_smart_data_get(obj);
1616 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1617 if ((ow == w) && (oh == h)) return;
1618 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1619 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1623 _pan_calculate(Evas_Object *obj)
1625 Pan *sd = evas_object_smart_data_get(obj);
1626 Evas_Coord cx = 0, cy = 0;
1630 if (!sd->wd->nmax) return;
1632 sd->wd->reorder_item_changed = EINA_FALSE;
1634 EINA_INLIST_FOREACH(sd->wd->items, it)
1638 if (sd->wd->horizontal)
1655 _item_place(it, cx, cy);
1656 if (sd->wd->reorder_item_changed) return;
1659 if (sd->wd->horizontal)
1672 if (sd->wd->horizontal)
1674 cy = (cy + 1) % sd->wd->nmax;
1679 cx = (cx + 1) % sd->wd->nmax;
1684 _group_item_place(sd);
1687 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
1689 if (!sd->wd->reorder_item_changed)
1691 sd->wd->old_pan_x = sd->wd->pan_x;
1692 sd->wd->old_pan_y = sd->wd->pan_y;
1694 sd->wd->move_effect_enabled = EINA_FALSE;
1696 evas_object_smart_callback_call(sd->wd->obj, SIG_CHANGED, NULL);
1700 _pan_move(Evas_Object *obj,
1701 Evas_Coord x __UNUSED__,
1702 Evas_Coord y __UNUSED__)
1704 Pan *sd = evas_object_smart_data_get(obj);
1706 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1707 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1711 _hold_on(void *data __UNUSED__,
1713 void *event_info __UNUSED__)
1715 Widget_Data *wd = elm_widget_data_get(obj);
1717 elm_smart_scroller_hold_set(wd->scr, 1);
1721 _hold_off(void *data __UNUSED__,
1723 void *event_info __UNUSED__)
1725 Widget_Data *wd = elm_widget_data_get(obj);
1727 elm_smart_scroller_hold_set(wd->scr, 0);
1731 _freeze_on(void *data __UNUSED__,
1733 void *event_info __UNUSED__)
1735 Widget_Data *wd = elm_widget_data_get(obj);
1737 elm_smart_scroller_freeze_set(wd->scr, 1);
1741 _freeze_off(void *data __UNUSED__,
1743 void *event_info __UNUSED__)
1745 Widget_Data *wd = elm_widget_data_get(obj);
1747 elm_smart_scroller_freeze_set(wd->scr, 0);
1751 _scr_anim_start(void *data,
1752 Evas_Object *obj __UNUSED__,
1753 void *event_info __UNUSED__)
1755 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1759 _scr_anim_stop(void *data,
1760 Evas_Object *obj __UNUSED__,
1761 void *event_info __UNUSED__)
1763 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1767 _scr_drag_start(void *data,
1768 Evas_Object *obj __UNUSED__,
1769 void *event_info __UNUSED__)
1771 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1775 _scr_drag_stop(void *data,
1776 Evas_Object *obj __UNUSED__,
1777 void *event_info __UNUSED__)
1779 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1783 _edge_left(void *data,
1784 Evas_Object *scr __UNUSED__,
1785 void *event_info __UNUSED__)
1787 evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
1791 _edge_right(void *data,
1792 Evas_Object *scr __UNUSED__,
1793 void *event_info __UNUSED__)
1795 evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
1799 _edge_top(void *data,
1800 Evas_Object *scr __UNUSED__,
1801 void *event_info __UNUSED__)
1803 evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
1807 _edge_bottom(void *data,
1808 Evas_Object *scr __UNUSED__,
1809 void *event_info __UNUSED__)
1811 evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
1815 _scr_scroll(void *data,
1816 Evas_Object *obj __UNUSED__,
1817 void *event_info __UNUSED__)
1819 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1823 _elm_gengrid_item_compare(const void *data, const void *data1)
1825 Elm_Gen_Item *it, *item1;
1826 it = ELM_GEN_ITEM_FROM_INLIST(data);
1827 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
1828 return it->wd->item_compare_cb(it, item1);
1832 _item_disable_hook(Elm_Object_Item *it)
1834 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
1836 if (_it->generation < _it->wd->generation) return;
1840 if (elm_widget_item_disabled_get(_it))
1841 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
1843 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
1848 _item_del_pre_hook(Elm_Object_Item *it)
1850 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
1851 if ((_it->relcount > 0) || (_it->walking > 0))
1853 _elm_genlist_item_del_notserious(_it);
1860 static Elm_Gen_Item *
1861 _item_new(Widget_Data *wd,
1862 const Elm_Gengrid_Item_Class *itc,
1865 const void *func_data)
1869 it = _elm_genlist_item_new(wd, itc, data, NULL, func, func_data);
1870 if (!it) return NULL;
1871 elm_widget_item_disable_hook_set(it, _item_disable_hook);
1872 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
1873 elm_gengrid_item_class_ref((Elm_Gengrid_Item_Class *)itc);
1874 it->item = ELM_NEW(Elm_Gen_Item_Type);
1876 it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
1877 ELM_GEN_ITEM_SETUP(it);
1883 elm_gengrid_add(Evas_Object *parent)
1888 static Evas_Smart *smart = NULL;
1889 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1893 static Evas_Smart_Class sc;
1895 evas_object_smart_clipped_smart_set(&_pan_sc);
1897 sc.name = "elm_gengrid_pan";
1898 sc.version = EVAS_SMART_CLASS_VERSION;
1901 sc.resize = _pan_resize;
1902 sc.move = _pan_move;
1903 sc.calculate = _pan_calculate;
1904 if (!(smart = evas_smart_class_new(&sc))) return NULL;
1907 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1909 ELM_SET_WIDTYPE(widtype, "gengrid");
1911 elm_widget_type_set(obj, "gengrid");
1912 elm_widget_sub_object_add(parent, obj);
1913 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1914 elm_widget_data_set(obj, wd);
1915 elm_widget_del_hook_set(obj, _del_hook);
1916 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1917 elm_widget_theme_hook_set(obj, _theme_hook);
1918 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1919 elm_widget_can_focus_set(obj, EINA_TRUE);
1920 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1921 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1922 elm_widget_event_hook_set(obj, _event_hook);
1925 wd->scr = elm_smart_scroller_add(e);
1926 elm_smart_scroller_widget_set(wd->scr, obj);
1927 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1929 elm_smart_scroller_bounce_allow_set(wd->scr, bounce,
1930 _elm_config->thumbscroll_bounce_enable);
1931 elm_widget_resize_object_set(obj, wd->scr);
1933 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1934 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1935 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1936 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1937 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1938 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1939 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1940 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom,
1942 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1947 wd->h_bounce = bounce;
1948 wd->v_bounce = bounce;
1949 wd->highlight = EINA_TRUE;
1951 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1952 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1953 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1954 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1956 wd->pan_smart = evas_object_smart_add(e, smart);
1957 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1960 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1961 _pan_set, _pan_get, _pan_max_get,
1962 _pan_min_get, _pan_child_size_get);
1964 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1966 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1971 elm_gengrid_item_size_set(Evas_Object *obj,
1975 ELM_CHECK_WIDTYPE(obj, widtype);
1976 Widget_Data *wd = elm_widget_data_get(obj);
1978 if ((wd->item_width == w) && (wd->item_height == h)) return;
1980 wd->item_height = h;
1981 if (wd->calc_job) ecore_job_del(wd->calc_job);
1982 wd->calc_job = ecore_job_add(_calc_job, wd);
1986 elm_gengrid_item_size_get(const Evas_Object *obj,
1990 ELM_CHECK_WIDTYPE(obj, widtype);
1991 Widget_Data *wd = elm_widget_data_get(obj);
1993 if (w) *w = wd->item_width;
1994 if (h) *h = wd->item_height;
1998 elm_gengrid_group_item_size_set(Evas_Object *obj,
2002 ELM_CHECK_WIDTYPE(obj, widtype);
2003 Widget_Data *wd = elm_widget_data_get(obj);
2005 if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
2006 wd->group_item_width = w;
2007 wd->group_item_height = h;
2008 if (wd->calc_job) ecore_job_del(wd->calc_job);
2009 wd->calc_job = ecore_job_add(_calc_job, wd);
2013 elm_gengrid_group_item_size_get(const Evas_Object *obj,
2017 ELM_CHECK_WIDTYPE(obj, widtype);
2018 Widget_Data *wd = elm_widget_data_get(obj);
2020 if (w) *w = wd->group_item_width;
2021 if (h) *h = wd->group_item_height;
2025 elm_gengrid_align_set(Evas_Object *obj,
2029 ELM_CHECK_WIDTYPE(obj, widtype);
2031 Widget_Data *wd = elm_widget_data_get(obj);
2032 double old_h = wd->align_x, old_y = wd->align_y;
2036 else if (align_x < 0.0)
2038 wd->align_x = align_x;
2042 else if (align_y < 0.0)
2044 wd->align_y = align_y;
2046 if ((old_h != wd->align_x) || (old_y != wd->align_y))
2047 evas_object_smart_calculate(wd->pan_smart);
2051 elm_gengrid_align_get(const Evas_Object *obj,
2055 ELM_CHECK_WIDTYPE(obj, widtype);
2056 Widget_Data *wd = elm_widget_data_get(obj);
2057 if (align_x) *align_x = wd->align_x;
2058 if (align_y) *align_y = wd->align_y;
2061 EAPI Elm_Object_Item *
2062 elm_gengrid_item_append(Evas_Object *obj,
2063 const Elm_Gengrid_Item_Class *itc,
2066 const void *func_data)
2069 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2070 Widget_Data *wd = elm_widget_data_get(obj);
2071 if (!wd) return NULL;
2073 it = _item_new(wd, itc, data, func, func_data);
2074 if (!it) return NULL;
2075 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2076 it->position = eina_inlist_count(wd->items);
2077 it->position_update = EINA_TRUE;
2080 wd->group_items = eina_list_prepend(wd->group_items, it);
2082 if (wd->calc_job) ecore_job_del(wd->calc_job);
2083 wd->calc_job = ecore_job_add(_calc_job, wd);
2085 return (Elm_Object_Item *)it;
2088 EAPI Elm_Object_Item *
2089 elm_gengrid_item_prepend(Evas_Object *obj,
2090 const Elm_Gengrid_Item_Class *itc,
2093 const void *func_data)
2096 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2097 Widget_Data *wd = elm_widget_data_get(obj);
2098 if (!wd) return NULL;
2100 it = _item_new(wd, itc, data, func, func_data);
2101 if (!it) return NULL;
2102 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2103 _item_position_update(wd->items, 0);
2106 wd->group_items = eina_list_append(wd->group_items, it);
2108 if (wd->calc_job) ecore_job_del(wd->calc_job);
2109 wd->calc_job = ecore_job_add(_calc_job, wd);
2111 return (Elm_Object_Item *)it;
2114 EAPI Elm_Object_Item *
2115 elm_gengrid_item_insert_before(Evas_Object *obj,
2116 const Elm_Gengrid_Item_Class *itc,
2118 Elm_Object_Item *relative,
2120 const void *func_data)
2123 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2124 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2125 Widget_Data *wd = elm_widget_data_get(obj);
2126 if (!wd) return NULL;
2128 it = _item_new(wd, itc, data, func, func_data);
2129 if (!it) return NULL;
2130 wd->items = eina_inlist_prepend_relative
2131 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2132 Eina_Inlist *tmp = eina_inlist_find(wd->items, EINA_INLIST_GET(it));
2133 _item_position_update(tmp, ((Elm_Gen_Item *)relative)->position);
2136 wd->group_items = eina_list_append_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2138 if (wd->calc_job) ecore_job_del(wd->calc_job);
2139 wd->calc_job = ecore_job_add(_calc_job, wd);
2141 return (Elm_Object_Item *)it;
2144 EAPI Elm_Object_Item *
2145 elm_gengrid_item_insert_after(Evas_Object *obj,
2146 const Elm_Gengrid_Item_Class *itc,
2148 Elm_Object_Item *relative,
2150 const void *func_data)
2153 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2154 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2155 Widget_Data *wd = elm_widget_data_get(obj);
2156 if (!wd) return NULL;
2158 it = _item_new(wd, itc, data, func, func_data);
2159 if (!it) return NULL;
2160 wd->items = eina_inlist_append_relative
2161 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2162 Eina_Inlist *tmp = eina_inlist_find(wd->items, EINA_INLIST_GET(it));
2163 _item_position_update(tmp, ((Elm_Gen_Item *)relative)->position+1);
2166 wd->group_items = eina_list_prepend_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2168 if (wd->calc_job) ecore_job_del(wd->calc_job);
2169 wd->calc_job = ecore_job_add(_calc_job, wd);
2171 return (Elm_Object_Item *)it;
2174 EAPI Elm_Object_Item *
2175 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2176 const Elm_Gengrid_Item_Class *itc,
2178 Eina_Compare_Cb comp,
2180 const void *func_data)
2183 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2184 Widget_Data *wd = elm_widget_data_get(obj);
2185 if (!wd) return NULL;
2187 it = _item_new(wd, itc, data, func, func_data);
2188 if (!it) return NULL;
2191 wd->state = eina_inlist_sorted_state_new();
2193 wd->item_compare_cb = comp;
2194 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
2195 _elm_gengrid_item_compare, wd->state);
2196 _item_position_update(wd->items, 0);
2198 if (wd->calc_job) ecore_job_del(wd->calc_job);
2199 wd->calc_job = ecore_job_add(_calc_job, wd);
2201 return (Elm_Object_Item *)it;
2205 elm_gengrid_horizontal_set(Evas_Object *obj,
2206 Eina_Bool horizontal)
2208 ELM_CHECK_WIDTYPE(obj, widtype);
2209 Widget_Data *wd = elm_widget_data_get(obj);
2211 horizontal = !!horizontal;
2212 if (horizontal == wd->horizontal) return;
2213 wd->horizontal = horizontal;
2215 /* Update the items to conform to the new layout */
2216 if (wd->calc_job) ecore_job_del(wd->calc_job);
2217 wd->calc_job = ecore_job_add(_calc_job, wd);
2221 elm_gengrid_horizontal_get(const Evas_Object *obj)
2223 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2224 Widget_Data *wd = elm_widget_data_get(obj);
2225 if (!wd) return EINA_FALSE;
2226 return wd->horizontal;
2230 elm_gengrid_clear(Evas_Object *obj)
2232 elm_genlist_clear(obj);
2235 EINA_DEPRECATED EAPI const Evas_Object *
2236 elm_gengrid_item_object_get(const Elm_Object_Item *it)
2238 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2243 elm_gengrid_item_update(Elm_Object_Item *it)
2245 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2246 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2247 if (!_it->realized) return;
2248 if (_it->want_unrealize) return;
2249 _elm_genlist_item_unrealize(_it, EINA_FALSE);
2251 _item_place(_it, _it->x, _it->y);
2254 EAPI const Elm_Gengrid_Item_Class *
2255 elm_gengrid_item_item_class_get(const Elm_Object_Item *it)
2257 return (Elm_Gengrid_Item_Class *)elm_genlist_item_item_class_get(it);
2261 elm_gengrid_item_item_class_update(Elm_Object_Item *it,
2262 const Elm_Gengrid_Item_Class *itc)
2264 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2265 EINA_SAFETY_ON_NULL_RETURN(itc);
2266 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2267 if (_it->generation < _it->wd->generation) return;
2269 elm_gengrid_item_update(it);
2273 elm_gengrid_item_pos_get(const Elm_Object_Item *it,
2277 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2278 if (x) *x = ((Elm_Gen_Item *)it)->x;
2279 if (y) *y = ((Elm_Gen_Item *)it)->y;
2283 elm_gengrid_multi_select_set(Evas_Object *obj,
2286 ELM_CHECK_WIDTYPE(obj, widtype);
2287 Widget_Data *wd = elm_widget_data_get(obj);
2289 wd->multi = !!multi;
2293 elm_gengrid_multi_select_get(const Evas_Object *obj)
2295 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2296 Widget_Data *wd = elm_widget_data_get(obj);
2297 if (!wd) return EINA_FALSE;
2301 EAPI Elm_Object_Item *
2302 elm_gengrid_selected_item_get(const Evas_Object *obj)
2304 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2305 Widget_Data *wd = elm_widget_data_get(obj);
2306 if (!wd) return NULL;
2307 if (wd->selected) return wd->selected->data;
2311 EAPI const Eina_List *
2312 elm_gengrid_selected_items_get(const Evas_Object *obj)
2314 return elm_genlist_selected_items_get(obj);
2318 elm_gengrid_item_selected_set(Elm_Object_Item *it,
2321 elm_genlist_item_selected_set(it, selected);
2325 elm_gengrid_item_selected_get(const Elm_Object_Item *it)
2327 return elm_genlist_item_selected_get(it);
2331 elm_gengrid_realized_items_get(const Evas_Object *obj)
2333 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2334 Widget_Data *wd = elm_widget_data_get(obj);
2335 Eina_List *list = NULL;
2338 EINA_INLIST_FOREACH(wd->items, it)
2340 if (it->realized) list = eina_list_append(list, (Elm_Object_Item *)it);
2346 elm_gengrid_realized_items_update(Evas_Object *obj)
2348 ELM_CHECK_WIDTYPE(obj, widtype);
2350 Eina_List *list, *l;
2351 Elm_Object_Item *it;
2353 list = elm_gengrid_realized_items_get(obj);
2354 EINA_LIST_FOREACH(list, l, it)
2355 elm_gengrid_item_update(it);
2358 static Evas_Object *
2359 _elm_gengrid_item_label_create(void *data,
2360 Evas_Object *obj __UNUSED__,
2361 Evas_Object *tooltip,
2362 void *it __UNUSED__)
2364 Evas_Object *label = elm_label_add(tooltip);
2367 elm_object_style_set(label, "tooltip");
2368 elm_object_text_set(label, data);
2373 _elm_gengrid_item_label_del_cb(void *data,
2374 Evas_Object *obj __UNUSED__,
2375 void *event_info __UNUSED__)
2377 eina_stringshare_del(data);
2381 elm_gengrid_item_tooltip_text_set(Elm_Object_Item *it,
2384 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2385 text = eina_stringshare_add(text);
2386 elm_gengrid_item_tooltip_content_cb_set(it, _elm_gengrid_item_label_create,
2388 _elm_gengrid_item_label_del_cb);
2392 elm_gengrid_item_tooltip_content_cb_set(Elm_Object_Item *it,
2393 Elm_Tooltip_Item_Content_Cb func,
2395 Evas_Smart_Cb del_cb)
2397 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
2398 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2400 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
2403 if (_it->tooltip.del_cb)
2404 _it->tooltip.del_cb((void *)_it->tooltip.data, WIDGET(_it), _it);
2405 _it->tooltip.content_cb = func;
2406 _it->tooltip.data = data;
2407 _it->tooltip.del_cb = del_cb;
2410 elm_widget_item_tooltip_content_cb_set(_it,
2411 _it->tooltip.content_cb,
2412 _it->tooltip.data, NULL);
2413 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
2414 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
2420 if (del_cb) del_cb((void *)data, NULL, NULL);
2424 elm_gengrid_item_tooltip_unset(Elm_Object_Item *it)
2426 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2427 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2429 if ((VIEW(_it)) && (_it->tooltip.content_cb))
2430 elm_widget_item_tooltip_unset(_it);
2432 if (_it->tooltip.del_cb)
2433 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
2434 _it->tooltip.del_cb = NULL;
2435 _it->tooltip.content_cb = NULL;
2436 _it->tooltip.data = NULL;
2437 _it->tooltip.free_size = EINA_FALSE;
2438 if (_it->tooltip.style)
2439 elm_gengrid_item_tooltip_style_set(it, NULL);
2443 elm_gengrid_item_tooltip_style_set(Elm_Object_Item *it,
2446 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2447 eina_stringshare_replace(&((Elm_Gen_Item *)it)->tooltip.style, style);
2448 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
2452 elm_gengrid_item_tooltip_style_get(const Elm_Object_Item *it)
2454 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2455 return ((Elm_Gen_Item *)it)->tooltip.style;
2459 elm_gengrid_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
2461 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2462 ((Elm_Gen_Item *)it)->tooltip.free_size = disable;
2463 if (VIEW(it)) return elm_widget_item_tooltip_window_mode_set(it, disable);
2468 elm_gengrid_item_tooltip_window_mode_get(const Elm_Object_Item *it)
2470 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2471 return ((Elm_Gen_Item *)it)->tooltip.free_size;
2475 elm_gengrid_item_cursor_set(Elm_Object_Item *it,
2478 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2479 eina_stringshare_replace(&((Elm_Gen_Item *)it)->mouse_cursor, cursor);
2480 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
2484 elm_gengrid_item_cursor_get(const Elm_Object_Item *it)
2486 return elm_widget_item_cursor_get(it);
2490 elm_gengrid_item_cursor_unset(Elm_Object_Item *it)
2492 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2493 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2494 if (!_it->mouse_cursor)
2498 elm_widget_item_cursor_unset(_it);
2500 eina_stringshare_del(_it->mouse_cursor);
2501 _it->mouse_cursor = NULL;
2505 elm_gengrid_item_cursor_style_set(Elm_Object_Item *it,
2508 elm_widget_item_cursor_style_set(it, style);
2512 elm_gengrid_item_cursor_style_get(const Elm_Object_Item *it)
2514 return elm_widget_item_cursor_style_get(it);
2518 elm_gengrid_item_cursor_engine_only_set(Elm_Object_Item *it,
2519 Eina_Bool engine_only)
2521 elm_widget_item_cursor_engine_only_set(it, engine_only);
2525 elm_gengrid_item_cursor_engine_only_get(const Elm_Object_Item *it)
2527 return elm_widget_item_cursor_engine_only_get(it);
2531 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2532 Eina_Bool reorder_mode)
2534 ELM_CHECK_WIDTYPE(obj, widtype);
2535 Widget_Data *wd = elm_widget_data_get(obj);
2537 wd->reorder_mode = !!reorder_mode;
2541 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2543 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2544 Widget_Data *wd = elm_widget_data_get(obj);
2545 if (!wd) return EINA_FALSE;
2546 return wd->reorder_mode;
2549 EINA_DEPRECATED EAPI void
2550 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2551 Eina_Bool always_select)
2554 elm_genlist_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_ALWAYS);
2557 Elm_Object_Select_Mode oldmode = elm_genlist_select_mode_get(obj);
2558 if (oldmode == ELM_OBJECT_SELECT_MODE_ALWAYS)
2559 elm_genlist_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_DEFAULT);
2563 EINA_DEPRECATED EAPI Eina_Bool
2564 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2566 Elm_Object_Select_Mode oldmode = elm_genlist_select_mode_get(obj);
2567 if (oldmode == ELM_OBJECT_SELECT_MODE_ALWAYS)
2573 EINA_DEPRECATED EAPI void
2574 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2575 Eina_Bool no_select)
2578 elm_genlist_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_NONE);
2581 Elm_Object_Select_Mode oldmode = elm_genlist_select_mode_get(obj);
2582 if (oldmode == ELM_OBJECT_SELECT_MODE_NONE)
2583 elm_genlist_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_DEFAULT);
2587 EINA_DEPRECATED EAPI Eina_Bool
2588 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2590 Elm_Object_Select_Mode oldmode = elm_genlist_select_mode_get(obj);
2591 if (oldmode == ELM_OBJECT_SELECT_MODE_NONE)
2598 elm_gengrid_bounce_set(Evas_Object *obj,
2602 elm_genlist_bounce_set(obj, h_bounce, v_bounce);
2606 elm_gengrid_bounce_get(const Evas_Object *obj,
2607 Eina_Bool *h_bounce,
2608 Eina_Bool *v_bounce)
2610 elm_genlist_bounce_get(obj, h_bounce, v_bounce);
2614 elm_gengrid_page_relative_set(Evas_Object *obj,
2618 _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
2622 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2624 _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
2628 elm_gengrid_page_size_set(Evas_Object *obj,
2629 Evas_Coord h_pagesize,
2630 Evas_Coord v_pagesize)
2632 _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
2636 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2638 _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
2642 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2644 _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
2648 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2650 _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
2654 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2656 _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
2660 elm_gengrid_scroller_policy_set(Evas_Object *obj,
2661 Elm_Scroller_Policy policy_h,
2662 Elm_Scroller_Policy policy_v)
2664 ELM_CHECK_WIDTYPE(obj, widtype);
2665 Widget_Data *wd = elm_widget_data_get(obj);
2666 if ((!wd) || (!wd->scr)) return;
2667 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
2668 (policy_v >= ELM_SCROLLER_POLICY_LAST))
2670 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
2674 elm_gengrid_scroller_policy_get(const Evas_Object *obj,
2675 Elm_Scroller_Policy *policy_h,
2676 Elm_Scroller_Policy *policy_v)
2678 ELM_CHECK_WIDTYPE(obj, widtype);
2679 Widget_Data *wd = elm_widget_data_get(obj);
2680 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
2681 if ((!wd) || (!wd->scr)) return;
2682 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
2683 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
2684 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
2687 EAPI Elm_Object_Item *
2688 elm_gengrid_first_item_get(const Evas_Object *obj)
2690 return elm_genlist_first_item_get(obj);
2693 EAPI Elm_Object_Item *
2694 elm_gengrid_last_item_get(const Evas_Object *obj)
2696 return elm_genlist_last_item_get(obj);
2699 EAPI Elm_Object_Item *
2700 elm_gengrid_item_next_get(const Elm_Object_Item *it)
2702 return elm_genlist_item_next_get(it);
2705 EAPI Elm_Object_Item *
2706 elm_gengrid_item_prev_get(const Elm_Object_Item *it)
2708 return elm_genlist_item_prev_get(it);
2712 elm_gengrid_item_show(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
2714 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2715 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2716 Widget_Data *wd = _it->wd;
2717 Evas_Coord minx = 0, miny = 0;
2719 if ((_it->generation < _it->wd->generation)) return;
2720 _pan_min_get(wd->pan_smart, &minx, &miny);
2722 if (type==ELM_GENGRID_ITEM_SCROLLTO_IN)
2724 //TODO : type based handling like genlist
2728 elm_smart_scroller_region_bring_in(_it->wd->scr,
2729 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2730 _it->y * wd->item_height + miny,
2731 _it->wd->item_width,
2732 _it->wd->item_height);
2734 elm_smart_scroller_region_bring_in(_it->wd->scr,
2735 _it->x * wd->item_width + minx,
2736 ((_it->y - _it->item->prev_group) * wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2737 _it->wd->item_width,
2738 _it->wd->item_height);
2742 elm_gengrid_item_bring_in(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
2744 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2745 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2747 if (_it->generation < _it->wd->generation) return;
2749 Evas_Coord minx = 0, miny = 0;
2750 Widget_Data *wd = _it->wd;
2751 _pan_min_get(wd->pan_smart, &minx, &miny);
2753 if (type==ELM_GENGRID_ITEM_SCROLLTO_IN)
2755 //TODO : type based handling like genlist
2759 elm_smart_scroller_region_bring_in(_it->wd->scr,
2760 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2761 _it->y * wd->item_height + miny,
2762 _it->wd->item_width,
2763 _it->wd->item_height);
2765 elm_smart_scroller_region_bring_in(_it->wd->scr,
2766 _it->x * wd->item_width + minx,
2767 ((_it->y - _it->item->prev_group)* wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2768 _it->wd->item_width,
2769 _it->wd->item_height);
2773 elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill)
2775 ELM_CHECK_WIDTYPE(obj, widtype);
2776 Widget_Data *wd = elm_widget_data_get(obj);
2779 if (wd->filled != fill)
2784 elm_gengrid_filled_get(const Evas_Object *obj)
2786 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2787 Widget_Data *wd = elm_widget_data_get(obj);
2788 if (!wd) return EINA_FALSE;
2793 elm_gengrid_items_count(const Evas_Object *obj)
2795 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2796 Widget_Data *wd = elm_widget_data_get(obj);
2798 return wd->item_count;
2801 EAPI Elm_Gengrid_Item_Class *
2802 elm_gengrid_item_class_new(void)
2804 Elm_Gengrid_Item_Class *itc;
2806 itc = calloc(1, sizeof(Elm_Gengrid_Item_Class));
2809 itc->version = CLASS_ALLOCATED;
2811 itc->delete_me = EINA_FALSE;
2817 elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
2819 if (itc && (itc->version == CLASS_ALLOCATED))
2821 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
2822 if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
2832 elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
2834 if (itc && (itc->version == CLASS_ALLOCATED))
2837 if (itc->refcount == 0) itc->refcount--;
2842 elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
2844 if (itc && (itc->version == CLASS_ALLOCATED))
2846 if (itc->refcount > 0) itc->refcount--;
2847 if (itc->delete_me && (!itc->refcount))
2848 elm_gengrid_item_class_free(itc);
2853 elm_gengrid_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode mode)
2855 elm_genlist_select_mode_set(obj, mode);
2858 EAPI Elm_Object_Select_Mode
2859 elm_gengrid_select_mode_get(const Evas_Object *obj)
2861 return elm_genlist_select_mode_get(obj);
2865 elm_gengrid_highlight_mode_set(Evas_Object *obj,
2866 Eina_Bool highlight)
2868 elm_genlist_highlight_mode_set(obj, highlight);
2872 elm_gengrid_highlight_mode_get(const Evas_Object *obj)
2874 return elm_genlist_highlight_mode_get(obj);
2878 elm_gengrid_item_index_get(const Elm_Object_Item *it)
2880 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, -1);
2881 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2883 return _it->position;
2887 elm_gengrid_item_select_mode_set(Elm_Object_Item *it,
2888 Elm_Object_Select_Mode mode)
2890 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2891 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2893 if (_it->generation < _it->wd->generation) return;
2894 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
2896 if (_it->select_mode != mode)
2897 _it->select_mode = mode;
2899 if (_it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
2900 elm_gengrid_item_update(it);
2903 EAPI Elm_Object_Select_Mode
2904 elm_gengrid_item_select_mode_get(const Elm_Object_Item *it)
2906 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ELM_OBJECT_SELECT_MODE_MAX);
2907 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2908 if (!_it) return ELM_OBJECT_SELECT_MODE_MAX;
2909 return _it->select_mode;