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;
42 Eina_Inlist_Sorted_State *state;
43 Evas_Object *obj; /* the gengrid object */
44 Evas_Object *scr; /* a smart scroller object which is used internally in genlist */
45 Evas_Object *pan_smart; /* "elm_genlist_pan" evas smart object. this is an extern pan of smart scroller(scr). */
47 Eina_List *group_items; /* list of groups index items */
48 Eina_Inlist *items; /* inlist of all items */
49 Elm_Gen_Item *reorder_it; /* item currently being repositioned */
50 Elm_Gen_Item *last_selected_item;
51 Pan *pan; /* pan_smart object's smart data */
54 int item_width, item_height;
55 int group_item_width, group_item_height;
58 Evas_Coord pan_x, pan_y;
59 Eina_Bool reorder_mode : 1;
60 Eina_Bool on_hold : 1;
62 Eina_Bool no_select : 1;
63 Eina_Bool wasselected : 1;
64 Eina_Bool always_select : 1;
65 Eina_Bool clear_me : 1;
66 Eina_Bool h_bounce : 1;
67 Eina_Bool v_bounce : 1;
68 Ecore_Cb del_cb, calc_cb, sizing_cb;
70 ////////////////////////////////////
71 double align_x, align_y;
73 Evas_Coord old_pan_x, old_pan_y;
74 Evas_Coord reorder_item_x, reorder_item_y;
80 Eina_Bool horizontal : 1;
81 Eina_Bool longpressed : 1;
82 Eina_Bool reorder_item_changed : 1;
83 Eina_Bool move_effect_enabled : 1;
87 static const char *widtype = NULL;
88 static void _item_highlight(Elm_Gen_Item *it);
89 static void _item_unrealize_cb(Elm_Gen_Item *it);
90 static void _item_unselect(Elm_Gen_Item *it);
91 static void _calc_job(void *data);
92 static void _on_focus_hook(void *data,
94 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
95 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
96 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
97 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
98 static Eina_Bool _item_single_select_up(Widget_Data *wd);
99 static Eina_Bool _item_single_select_down(Widget_Data *wd);
100 static Eina_Bool _item_single_select_left(Widget_Data *wd);
101 static Eina_Bool _item_single_select_right(Widget_Data *wd);
102 static Eina_Bool _event_hook(Evas_Object *obj,
104 Evas_Callback_Type type,
106 static Eina_Bool _deselect_all_items(Widget_Data *wd);
108 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
109 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
111 static const char SIG_ACTIVATED[] = "activated";
112 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
113 static const char SIG_LONGPRESSED[] = "longpressed";
114 static const char SIG_SELECTED[] = "selected";
115 static const char SIG_UNSELECTED[] = "unselected";
116 static const char SIG_REALIZED[] = "realized";
117 static const char SIG_UNREALIZED[] = "unrealized";
118 static const char SIG_CHANGED[] = "changed";
119 static const char SIG_DRAG_START_UP[] = "drag,start,up";
120 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
121 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
122 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
123 static const char SIG_DRAG_STOP[] = "drag,stop";
124 static const char SIG_DRAG[] = "drag";
125 static const char SIG_SCROLL[] = "scroll";
126 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
127 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
128 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
129 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
130 static const char SIG_EDGE_TOP[] = "edge,top";
131 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
132 static const char SIG_EDGE_LEFT[] = "edge,left";
133 static const char SIG_EDGE_RIGHT[] = "edge,right";
134 static const char SIG_MOVED[] = "moved";
136 static const Evas_Smart_Cb_Description _signals[] = {
138 {SIG_CLICKED_DOUBLE, ""},
139 {SIG_LONGPRESSED, ""},
141 {SIG_UNSELECTED, ""},
143 {SIG_UNREALIZED, ""},
145 {SIG_DRAG_START_UP, ""},
146 {SIG_DRAG_START_DOWN, ""},
147 {SIG_DRAG_START_LEFT, ""},
148 {SIG_DRAG_START_RIGHT, ""},
152 {SIG_SCROLL_ANIM_START, ""},
153 {SIG_SCROLL_ANIM_STOP, ""},
154 {SIG_SCROLL_DRAG_START, ""},
155 {SIG_SCROLL_DRAG_STOP, ""},
157 {SIG_EDGE_BOTTOM, ""},
159 {SIG_EDGE_RIGHT, ""},
165 _event_hook(Evas_Object *obj,
166 Evas_Object *src __UNUSED__,
167 Evas_Callback_Type type,
170 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
171 Evas_Event_Key_Down *ev = event_info;
172 Widget_Data *wd = elm_widget_data_get(obj);
173 if (!wd) return EINA_FALSE;
174 if (!wd->items) return EINA_FALSE;
175 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
176 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
178 Elm_Object_Item *it = NULL;
181 Evas_Coord step_x = 0;
182 Evas_Coord step_y = 0;
185 Evas_Coord page_x = 0;
186 Evas_Coord page_y = 0;
188 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
189 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
190 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
191 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
193 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
195 if ((wd->horizontal) &&
196 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
197 (_item_multi_select_up(wd)))
198 || (_item_single_select_up(wd))))
200 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
203 else if ((!wd->horizontal) &&
204 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
205 (_item_multi_select_left(wd)))
206 || (_item_single_select_left(wd))))
208 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
214 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
216 if ((wd->horizontal) &&
217 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
218 (_item_multi_select_down(wd)))
219 || (_item_single_select_down(wd))))
221 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
224 else if ((!wd->horizontal) &&
225 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
226 (_item_multi_select_right(wd)))
227 || (_item_single_select_right(wd))))
229 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
235 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
237 if ((wd->horizontal) &&
238 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
239 (_item_multi_select_left(wd)))
240 || (_item_single_select_left(wd))))
242 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
245 else if ((!wd->horizontal) &&
246 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
247 (_item_multi_select_up(wd)))
248 || (_item_single_select_up(wd))))
250 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
256 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
258 if ((wd->horizontal) &&
259 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
260 (_item_multi_select_right(wd)))
261 || (_item_single_select_right(wd))))
263 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
266 else if ((!wd->horizontal) &&
267 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
268 (_item_multi_select_down(wd)))
269 || (_item_single_select_down(wd))))
271 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
277 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
279 it = elm_gengrid_first_item_get(obj);
280 elm_gengrid_item_bring_in(it);
281 elm_gengrid_item_selected_set(it, EINA_TRUE);
282 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
285 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
287 it = elm_gengrid_last_item_get(obj);
288 elm_gengrid_item_bring_in(it);
289 elm_gengrid_item_selected_set(it, EINA_TRUE);
290 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
293 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
298 x -= -(page_x * v_w) / 100;
305 y -= -(page_y * v_h) / 100;
310 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
315 x += -(page_x * v_w) / 100;
322 y += -(page_y * v_h) / 100;
327 else if (!strcmp(ev->keyname, "Escape"))
329 if (!_deselect_all_items(wd)) return EINA_FALSE;
330 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
333 else if (((!strcmp(ev->keyname, "Return")) ||
334 (!strcmp(ev->keyname, "KP_Enter")) ||
335 (!strcmp(ev->keyname, "space")))
336 && (!wd->multi) && (wd->selected))
338 it = elm_gengrid_selected_item_get(obj);
339 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
341 else return EINA_FALSE;
343 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
344 elm_smart_scroller_child_pos_set(wd->scr, x, y);
349 _deselect_all_items(Widget_Data *wd)
351 if (!wd->selected) return EINA_FALSE;
353 elm_gengrid_item_selected_set((Elm_Object_Item *) wd->selected->data,
360 _item_multi_select_left(Widget_Data *wd)
362 if (!wd->selected) return EINA_FALSE;
364 Elm_Object_Item *prev =
365 elm_gengrid_item_prev_get(wd->last_selected_item);
366 if (!prev) return EINA_TRUE;
367 if (elm_gengrid_item_selected_get(prev))
369 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
370 wd->last_selected_item = prev;
371 elm_gengrid_item_show(wd->last_selected_item);
375 elm_gengrid_item_selected_set(prev, EINA_TRUE);
376 elm_gengrid_item_show(prev);
383 _item_multi_select_right(Widget_Data *wd)
385 if (!wd->selected) return EINA_FALSE;
387 Elm_Object_Item *next =
388 elm_gengrid_item_next_get(wd->last_selected_item);
389 if (!next) return EINA_TRUE;
390 if (elm_gengrid_item_selected_get(next))
392 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
393 wd->last_selected_item = next;
394 elm_gengrid_item_show(wd->last_selected_item);
398 elm_gengrid_item_selected_set(next, EINA_TRUE);
399 elm_gengrid_item_show(next);
406 _item_multi_select_up(Widget_Data *wd)
409 Eina_Bool r = EINA_TRUE;
411 if (!wd->selected) return EINA_FALSE;
413 for (i = 0; (r) && (i < wd->nmax); i++)
414 r &= _item_multi_select_left(wd);
420 _item_multi_select_down(Widget_Data *wd)
423 Eina_Bool r = EINA_TRUE;
425 if (!wd->selected) return EINA_FALSE;
427 for (i = 0; (r) && (i < wd->nmax); i++)
428 r &= _item_multi_select_right(wd);
434 _item_single_select_up(Widget_Data *wd)
442 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
443 while ((prev) && (prev->generation < wd->generation))
444 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
445 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
446 elm_gengrid_item_show((Elm_Object_Item *) prev);
450 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
452 if (!prev) return EINA_FALSE;
454 for (i = 1; i < wd->nmax; i++)
456 Elm_Object_Item *tmp =
457 elm_gengrid_item_prev_get((Elm_Object_Item *) prev);
458 if (!tmp) return EINA_FALSE;
459 prev = (Elm_Gen_Item *) tmp;
462 _deselect_all_items(wd);
464 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
465 elm_gengrid_item_show((Elm_Object_Item *) prev);
470 _item_single_select_down(Widget_Data *wd)
478 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
479 while ((next) && (next->generation < wd->generation))
480 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
481 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
482 elm_gengrid_item_show((Elm_Object_Item *) next);
486 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
488 if (!next) return EINA_FALSE;
490 for (i = 1; i < wd->nmax; i++)
492 Elm_Object_Item *tmp =
493 elm_gengrid_item_next_get((Elm_Object_Item *) next);
494 if (!tmp) return EINA_FALSE;
495 next = (Elm_Gen_Item *) tmp;
498 _deselect_all_items(wd);
500 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
501 elm_gengrid_item_show((Elm_Object_Item *) next);
506 _item_single_select_left(Widget_Data *wd)
511 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
512 while ((prev) && (prev->generation < wd->generation))
513 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
516 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
518 if (!prev) return EINA_FALSE;
520 _deselect_all_items(wd);
522 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
523 elm_gengrid_item_show((Elm_Object_Item *) prev);
528 _item_single_select_right(Widget_Data *wd)
533 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
534 while ((next) && (next->generation < wd->generation))
535 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
538 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
540 if (!next) return EINA_FALSE;
542 _deselect_all_items(wd);
544 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
545 elm_gengrid_item_show((Elm_Object_Item *) next);
550 _on_focus_hook(void *data __UNUSED__,
553 Widget_Data *wd = elm_widget_data_get(obj);
555 if (elm_widget_focus_get(obj))
557 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
558 evas_object_focus_set(wd->obj, EINA_TRUE);
559 if ((wd->selected) && (!wd->last_selected_item))
560 wd->last_selected_item = eina_list_data_get(wd->selected);
564 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
565 evas_object_focus_set(wd->obj, EINA_FALSE);
570 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
572 Widget_Data *wd = elm_widget_data_get(obj);
575 elm_smart_scroller_mirrored_set(wd->scr, rtl);
576 if (!wd->items) return;
577 it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
581 edje_object_mirrored_set(VIEW(it), rtl);
582 elm_gengrid_item_update((Elm_Object_Item *) it);
583 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
588 _theme_hook(Evas_Object *obj)
590 Widget_Data *wd = elm_widget_data_get(obj);
592 _elm_widget_mirrored_reload(obj);
593 _mirrored_set(obj, elm_widget_mirrored_get(obj));
594 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
595 elm_widget_style_get(obj));
599 _del_pre_hook(Evas_Object *obj)
601 Widget_Data *wd = elm_widget_data_get(obj);
603 elm_gengrid_clear(obj);
604 evas_object_del(wd->pan_smart);
605 wd->pan_smart = NULL;
609 _del_hook(Evas_Object *obj)
611 Widget_Data *wd = elm_widget_data_get(obj);
612 if (wd->calc_job) ecore_job_del(wd->calc_job);
617 _signal_emit_hook(Evas_Object *obj,
618 const char *emission,
621 Widget_Data *wd = elm_widget_data_get(obj);
623 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
628 _signal_callback_add_hook(Evas_Object *obj,
629 const char *emission,
631 Edje_Signal_Cb func_cb,
634 Widget_Data *wd = elm_widget_data_get(obj);
636 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
637 emission, source, func_cb, data);
641 _signal_callback_del_hook(Evas_Object *obj,
642 const char *emission,
644 Edje_Signal_Cb func_cb,
647 Widget_Data *wd = elm_widget_data_get(obj);
649 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scr),
650 emission, source, func_cb, data);
654 _mouse_move(void *data,
655 Evas *evas __UNUSED__,
659 Elm_Gen_Item *it = data;
660 Evas_Event_Mouse_Move *ev = event_info;
661 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
662 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
664 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
666 if (!it->wd->on_hold)
668 it->wd->on_hold = EINA_TRUE;
669 if (!it->wd->wasselected)
673 if ((it->dragging) && (it->down))
677 ecore_timer_del(it->long_timer);
678 it->long_timer = NULL;
680 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
683 if ((!it->down) || (it->wd->longpressed))
687 ecore_timer_del(it->long_timer);
688 it->long_timer = NULL;
690 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
692 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
694 it_scrl_x = ev->cur.canvas.x - it->wd->reorder_it->dx;
695 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
697 if (it_scrl_x < ox) it->wd->reorder_item_x = ox;
698 else if (it_scrl_x + it->wd->item_width > ox + ow)
699 it->wd->reorder_item_x = ox + ow - it->wd->item_width;
700 else it->wd->reorder_item_x = it_scrl_x;
702 if (it_scrl_y < oy) it->wd->reorder_item_y = oy;
703 else if (it_scrl_y + it->wd->item_height > oy + oh)
704 it->wd->reorder_item_y = oy + oh - it->wd->item_height;
705 else it->wd->reorder_item_y = it_scrl_y;
707 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
708 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
712 if (!it->display_only)
713 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
714 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
715 x = ev->cur.canvas.x - x;
716 y = ev->cur.canvas.y - y;
719 if (adx < 0) adx = -dx;
722 if (ady < 0) ady = -dy;
725 if ((adx > minw) || (ady > minh))
727 const char *left_drag, *right_drag;
728 if (!elm_widget_mirrored_get(WIDGET(it)))
730 left_drag = SIG_DRAG_START_LEFT;
731 right_drag = SIG_DRAG_START_RIGHT;
735 left_drag = SIG_DRAG_START_RIGHT;
736 right_drag = SIG_DRAG_START_LEFT;
742 ecore_timer_del(it->long_timer);
743 it->long_timer = NULL;
745 if (!it->wd->wasselected)
750 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_START_UP,
755 evas_object_smart_callback_call(WIDGET(it),
762 evas_object_smart_callback_call(WIDGET(it),
763 SIG_DRAG_START_DOWN, it);
767 evas_object_smart_callback_call(WIDGET(it),
770 evas_object_smart_callback_call(WIDGET(it),
778 _long_press(void *data)
780 Elm_Gen_Item *it = data;
782 it->long_timer = NULL;
783 if (elm_widget_item_disabled_get(it)|| (it->dragging))
784 return ECORE_CALLBACK_CANCEL;
785 it->wd->longpressed = EINA_TRUE;
786 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
787 if (it->wd->reorder_mode)
789 it->wd->reorder_it = it;
790 evas_object_raise(VIEW(it));
791 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
792 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
793 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
795 return ECORE_CALLBACK_CANCEL;
799 _mouse_down(void *data,
800 Evas *evas __UNUSED__,
804 Elm_Gen_Item *it = data;
805 Evas_Event_Mouse_Down *ev = event_info;
808 if (ev->button != 1) return;
811 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
812 it->dx = ev->canvas.x - x;
813 it->dy = ev->canvas.y - y;
814 it->wd->longpressed = EINA_FALSE;
815 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
816 else it->wd->on_hold = EINA_FALSE;
817 if (it->wd->on_hold) return;
818 it->wd->wasselected = it->selected;
820 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
822 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
823 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
825 if (it->long_timer) ecore_timer_del(it->long_timer);
827 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
830 it->long_timer = NULL;
834 _mouse_up(void *data,
835 Evas *evas __UNUSED__,
836 Evas_Object *obj __UNUSED__,
839 Elm_Gen_Item *it = data;
840 Evas_Event_Mouse_Up *ev = event_info;
841 Eina_Bool dragged = EINA_FALSE;
843 if (ev->button != 1) return;
844 it->down = EINA_FALSE;
845 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
846 else it->wd->on_hold = EINA_FALSE;
849 ecore_timer_del(it->long_timer);
850 it->long_timer = NULL;
854 it->dragging = EINA_FALSE;
855 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
860 it->wd->longpressed = EINA_FALSE;
861 it->wd->on_hold = EINA_FALSE;
864 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
866 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it->wd->reorder_it);
867 it->wd->reorder_it = NULL;
868 it->wd->move_effect_enabled = EINA_FALSE;
869 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
870 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
872 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
873 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
874 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
876 if (it->wd->longpressed)
878 it->wd->longpressed = EINA_FALSE;
879 if (!it->wd->wasselected) _item_unselect(it);
880 it->wd->wasselected = EINA_FALSE;
885 if (it->want_unrealize)
886 _elm_genlist_item_unrealize(it, EINA_FALSE);
888 if (elm_widget_item_disabled_get(it) || (dragged)) return;
896 else _item_unselect(it);
902 while (it->wd->selected)
903 _item_unselect(it->wd->selected->data);
907 const Eina_List *l, *l_next;
910 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, item2)
911 if (item2 != it) _item_unselect(item2);
919 _item_highlight(Elm_Gen_Item *it)
921 if ((it->wd->no_select) || (it->generation < it->wd->generation) || (it->highlighted)) return;
922 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
923 it->highlighted = EINA_TRUE;
927 _item_realize(Elm_Gen_Item *it)
932 if ((it->realized) || (it->generation < it->wd->generation)) return;
933 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
934 edje_object_scale_set(VIEW(it), elm_widget_scale_get(WIDGET(it)) *
936 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
937 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
938 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
939 snprintf(style, sizeof(style), "item/%s",
940 it->itc->item_style ? it->itc->item_style : "default");
941 _elm_theme_object_set(WIDGET(it), VIEW(it), "gengrid", style,
942 elm_widget_style_get(WIDGET(it)));
944 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
945 evas_object_color_set(it->spacer, 0, 0, 0, 0);
946 elm_widget_sub_object_add(WIDGET(it), it->spacer);
947 evas_object_size_hint_min_set(it->spacer, 2 * _elm_config->scale, 1);
948 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
950 if (it->itc->func.text_get)
956 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
958 EINA_LIST_FOREACH(it->texts, l, key)
960 char *s = it->itc->func.text_get
961 ((void *)it->base.data, WIDGET(it), key);
964 edje_object_part_text_set(VIEW(it), key, s);
970 if (it->itc->func.content_get)
974 Evas_Object *ic = NULL;
977 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
979 EINA_LIST_FOREACH(it->contents, l, key)
981 if (it->itc->func.content_get)
982 ic = it->itc->func.content_get
983 ((void *)it->base.data, WIDGET(it), key);
986 it->content_objs = eina_list_append(it->content_objs, ic);
987 edje_object_part_swallow(VIEW(it), key, ic);
988 evas_object_show(ic);
989 elm_widget_sub_object_add(WIDGET(it), ic);
994 if (it->itc->func.state_get)
1000 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
1002 EINA_LIST_FOREACH(it->states, l, key)
1004 Eina_Bool on = it->itc->func.state_get
1005 ((void *)it->base.data, WIDGET(it), l->data);
1008 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1009 edje_object_signal_emit(VIEW(it), buf, "elm");
1016 if ((!it->wd->group_item_width) && (!it->wd->group_item_height))
1018 edje_object_size_min_restricted_calc(VIEW(it),
1019 &it->wd->group_item_width,
1020 &it->wd->group_item_height,
1021 it->wd->group_item_width,
1022 it->wd->group_item_height);
1027 if ((!it->wd->item_width) && (!it->wd->item_height))
1029 edje_object_size_min_restricted_calc(VIEW(it),
1030 &it->wd->item_width,
1031 &it->wd->item_height,
1033 it->wd->item_height);
1034 elm_coords_finger_size_adjust(1, &it->wd->item_width,
1035 1, &it->wd->item_height);
1038 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1040 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1042 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1046 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1047 if (elm_widget_item_disabled_get(it))
1048 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1050 evas_object_show(VIEW(it));
1052 if (it->tooltip.content_cb)
1054 elm_widget_item_tooltip_content_cb_set(it,
1055 it->tooltip.content_cb,
1056 it->tooltip.data, NULL);
1057 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1058 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
1061 if (it->mouse_cursor)
1062 elm_widget_item_cursor_set(it, it->mouse_cursor);
1064 it->realized = EINA_TRUE;
1065 it->want_unrealize = EINA_FALSE;
1069 _item_unrealize_cb(Elm_Gen_Item *it)
1071 evas_object_del(VIEW(it));
1073 evas_object_del(it->spacer);
1078 _reorder_item_moving_effect_timer_cb(void *data)
1080 Elm_Gen_Item *it = data;
1084 tt = REORDER_EFFECT_TIME;
1085 t = ((0.0 > (t = ecore_loop_time_get()-it->item->moving_effect_start_time)) ? 0.0 : t);
1086 dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
1087 dy = ((it->item->ty - it->item->oy) / 10) * _elm_config->scale;
1091 it->item->rx += (1 * sin((t / tt) * (M_PI / 2)) * dx);
1092 it->item->ry += (1 * sin((t / tt) * (M_PI / 2)) * dy);
1100 if ((((dx > 0) && (it->item->rx >= it->item->tx)) || ((dx <= 0) && (it->item->rx <= it->item->tx))) &&
1101 (((dy > 0) && (it->item->ry >= it->item->ty)) || ((dy <= 0) && (it->item->ry <= it->item->ty))))
1103 evas_object_move(VIEW(it), it->item->tx, it->item->ty);
1107 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1108 if (it->wd->horizontal)
1109 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1111 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1114 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1115 it->item->moving = EINA_FALSE;
1116 it->item->item_moving_effect_timer = NULL;
1117 return ECORE_CALLBACK_CANCEL;
1120 evas_object_move(VIEW(it), it->item->rx, it->item->ry);
1124 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1125 if (it->wd->horizontal)
1126 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1128 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1131 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1133 return ECORE_CALLBACK_RENEW;
1137 _group_item_place(Pan *sd)
1139 Evas_Coord iw, ih, vw, vh;
1141 Eina_Bool was_realized;
1143 evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1144 if (sd->wd->horizontal)
1146 iw = sd->wd->group_item_width;
1152 ih = sd->wd->group_item_height;
1154 EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1156 was_realized = it->realized;
1157 if (it->item->group_realized)
1161 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1162 evas_object_move(VIEW(it), it->item->gx, it->item->gy);
1163 evas_object_resize(VIEW(it), iw, ih);
1164 evas_object_raise(VIEW(it));
1167 _elm_genlist_item_unrealize(it, EINA_FALSE);
1173 _item_place(Elm_Gen_Item *it,
1177 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1178 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1179 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1183 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &vw, &vh);
1185 /* Preload rows/columns at each side of the Gengrid */
1186 cvx = ox - PRELOAD * it->wd->item_width;
1187 cvy = oy - PRELOAD * it->wd->item_height;
1188 cvw = vw + 2 * PRELOAD * it->wd->item_width;
1189 cvh = vh + 2 * PRELOAD * it->wd->item_height;
1194 items_count = it->wd->item_count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
1195 if (it->wd->horizontal)
1197 int columns, items_visible = 0, items_row;
1199 if (it->wd->item_height > 0)
1200 items_visible = vh / it->wd->item_height;
1201 if (items_visible < 1)
1204 columns = items_count / items_visible;
1205 if (items_count % items_visible)
1208 tcw = (it->wd->item_width * columns) + (it->wd->group_item_width * eina_list_count(it->wd->group_items));
1209 alignw = (vw - tcw) * it->wd->align_x;
1211 items_row = items_visible;
1212 if ((unsigned int)items_row > it->wd->item_count)
1213 items_row = it->wd->item_count;
1215 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1216 tch = it->wd->nmax * it->wd->item_height;
1218 tch = items_row * it->wd->item_height;
1219 alignh = (vh - tch) * it->wd->align_y;
1223 unsigned int rows, items_visible = 0, items_col;
1225 if (it->wd->item_width > 0)
1226 items_visible = vw / it->wd->item_width;
1227 if (items_visible < 1)
1230 rows = items_count / items_visible;
1231 if (items_count % items_visible)
1234 tch = (it->wd->item_height * rows) + (it->wd->group_item_height * eina_list_count(it->wd->group_items));
1235 alignh = (vh - tch) * it->wd->align_y;
1237 items_col = items_visible;
1238 if (items_col > it->wd->item_count)
1239 items_col = it->wd->item_count;
1241 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1242 tcw = it->wd->nmax * it->wd->item_width;
1244 tcw = items_col * it->wd->item_width;
1245 alignw = (vw - tcw) * it->wd->align_x;
1250 if (it->wd->horizontal)
1252 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;
1254 iw = it->wd->group_item_width;
1260 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;
1262 ih = it->wd->group_item_height;
1269 if (it->wd->horizontal)
1271 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;
1272 y = (cy * it->wd->item_height) - it->wd->pan_y + oy + alignh;
1276 x = (cx * it->wd->item_width) - it->wd->pan_x + ox + alignw;
1277 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;
1279 if (elm_widget_mirrored_get(WIDGET(it)))
1280 { /* Switch items side and componsate for pan_x when in RTL mode */
1281 evas_object_geometry_get(WIDGET(it), NULL, NULL, &ww, NULL);
1282 x = ww - x - it->wd->item_width - it->wd->pan_x - it->wd->pan_x;
1284 iw = it->wd->item_width;
1285 ih = it->wd->item_height;
1288 Eina_Bool was_realized = it->realized;
1289 if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1293 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1296 if (it->wd->horizontal)
1298 if (it->parent->item->gx < ox)
1300 it->parent->item->gx = x + it->wd->item_width - it->wd->group_item_width;
1301 if (it->parent->item->gx > ox)
1302 it->parent->item->gx = ox;
1304 it->parent->item->group_realized = EINA_TRUE;
1308 if (it->parent->item->gy < oy)
1310 it->parent->item->gy = y + it->wd->item_height - it->wd->group_item_height;
1311 if (it->parent->item->gy > oy)
1312 it->parent->item->gy = oy;
1314 it->parent->item->group_realized = EINA_TRUE;
1317 if (it->wd->reorder_mode)
1319 if (it->wd->reorder_it)
1321 if (it->item->moving) return;
1323 if (!it->wd->move_effect_enabled)
1328 if (it->wd->reorder_it == it)
1330 evas_object_move(VIEW(it),
1331 it->wd->reorder_item_x, it->wd->reorder_item_y);
1332 evas_object_resize(VIEW(it), iw, ih);
1337 if (it->wd->move_effect_enabled)
1339 if ((it->item->ox != x) || (it->item->oy != y))
1341 if (((it->wd->old_pan_x == it->wd->pan_x) && (it->wd->old_pan_y == it->wd->pan_y)) ||
1342 ((it->wd->old_pan_x != it->wd->pan_x) && !(it->item->ox - it->wd->pan_x + it->wd->old_pan_x == x)) ||
1343 ((it->wd->old_pan_y != it->wd->pan_y) && !(it->item->oy - it->wd->pan_y + it->wd->old_pan_y == y)))
1347 it->item->rx = it->item->ox;
1348 it->item->ry = it->item->oy;
1349 it->item->moving = EINA_TRUE;
1350 it->item->moving_effect_start_time = ecore_loop_time_get();
1351 it->item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
1358 Evas_Coord nx, ny, nw, nh;
1361 if (it->wd->horizontal)
1363 nx = x + (it->wd->group_item_width / 2);
1371 ny = y + (it->wd->group_item_height / 2);
1378 nx = x + (it->wd->item_width / 2);
1379 ny = y + (it->wd->item_height / 2);
1384 if ( ELM_RECTS_INTERSECT(it->wd->reorder_item_x, it->wd->reorder_item_y,
1385 it->wd->item_width, it->wd->item_height,
1388 if (it->wd->horizontal)
1390 if ((it->wd->nmax * it->wd->reorder_it->x + it->wd->reorder_it->y) >
1391 (it->wd->nmax * it->x + it->y))
1392 reorder_item_move_forward = EINA_TRUE;
1396 if ((it->wd->nmax * it->wd->reorder_it->y + it->wd->reorder_it->x) >
1397 (it->wd->nmax * it->y + it->x))
1398 reorder_item_move_forward = EINA_TRUE;
1401 it->wd->items = eina_inlist_remove(it->wd->items,
1402 EINA_INLIST_GET(it->wd->reorder_it));
1403 if (reorder_item_move_forward)
1404 it->wd->items = eina_inlist_prepend_relative(it->wd->items,
1405 EINA_INLIST_GET(it->wd->reorder_it),
1406 EINA_INLIST_GET(it));
1408 it->wd->items = eina_inlist_append_relative(it->wd->items,
1409 EINA_INLIST_GET(it->wd->reorder_it),
1410 EINA_INLIST_GET(it));
1412 it->wd->reorder_item_changed = EINA_TRUE;
1413 it->wd->move_effect_enabled = EINA_TRUE;
1414 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1415 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1421 else if (it->item->item_moving_effect_timer)
1423 ecore_animator_del(it->item->item_moving_effect_timer);
1424 it->item->item_moving_effect_timer = NULL;
1425 it->item->moving = EINA_FALSE;
1430 evas_object_move(VIEW(it), x, y);
1431 evas_object_resize(VIEW(it), iw, ih);
1434 it->item->group_realized = EINA_TRUE;
1439 _elm_genlist_item_unrealize(it, EINA_FALSE);
1441 it->item->group_realized = EINA_FALSE;
1446 _item_del(Elm_Gen_Item *it)
1448 Evas_Object *obj = WIDGET(it);
1450 evas_event_freeze(evas_object_evas_get(obj));
1451 it->wd->selected = eina_list_remove(it->wd->selected, it);
1452 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
1453 it->wd->item_count--;
1454 _elm_genlist_item_del_serious(it);
1455 elm_gengrid_item_class_unref((Elm_Gengrid_Item_Class *)it->itc);
1456 evas_event_thaw(evas_object_evas_get(obj));
1457 evas_event_thaw_eval(evas_object_evas_get(obj));
1461 _item_unselect(Elm_Gen_Item *it)
1463 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
1464 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
1465 it->highlighted = EINA_FALSE;
1468 it->selected = EINA_FALSE;
1469 it->wd->selected = eina_list_remove(it->wd->selected, it);
1470 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
1475 _calc_job(void *data)
1477 Widget_Data *wd = data;
1478 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1479 Elm_Gen_Item *it, *group_item = NULL;
1480 int count_group = 0;
1484 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1485 if ((cvw != 0) || (cvh != 0))
1487 if ((wd->horizontal) && (wd->item_height > 0))
1488 nmax = cvh / wd->item_height;
1489 else if (wd->item_width > 0)
1490 nmax = cvw / wd->item_width;
1495 EINA_INLIST_FOREACH(wd->items, it)
1497 if (it->item->prev_group != count_group)
1498 it->item->prev_group = count_group;
1501 count = count % nmax;
1503 wd->items_lost += nmax - count;
1504 //printf("%d items and I lost %d\n", count, wd->items_lost);
1506 if (count) count = 0;
1511 if (it->parent != group_item)
1512 it->parent = group_item;
1516 count = wd->item_count + wd->items_lost - count_group;
1519 minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width);
1520 minh = nmax * wd->item_height;
1524 minw = nmax * wd->item_width;
1525 minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1528 if ((minw != wd->minw) || (minh != wd->minh))
1532 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1536 evas_object_smart_changed(wd->pan_smart);
1538 wd->calc_job = NULL;
1542 _pan_add(Evas_Object *obj)
1545 Evas_Object_Smart_Clipped_Data *cd;
1548 cd = evas_object_smart_data_get(obj);
1551 sd->__clipped_data = *cd;
1553 evas_object_smart_data_set(obj, sd);
1557 _pan_del(Evas_Object *obj)
1559 Pan *sd = evas_object_smart_data_get(obj);
1566 _pan_set(Evas_Object *obj,
1570 Pan *sd = evas_object_smart_data_get(obj);
1571 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1574 evas_object_smart_changed(obj);
1578 _pan_get(Evas_Object *obj,
1582 Pan *sd = evas_object_smart_data_get(obj);
1583 if (x) *x = sd->wd->pan_x;
1584 if (y) *y = sd->wd->pan_y;
1588 _pan_child_size_get(Evas_Object *obj,
1592 Pan *sd = evas_object_smart_data_get(obj);
1593 if (w) *w = sd->wd->minw;
1594 if (h) *h = sd->wd->minh;
1598 _pan_max_get(Evas_Object *obj,
1602 Pan *sd = evas_object_smart_data_get(obj);
1606 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1608 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1610 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1614 _pan_min_get(Evas_Object *obj,
1618 Pan *sd = evas_object_smart_data_get(obj);
1619 Evas_Coord mx = 0, my = 0;
1622 _pan_max_get(obj, &mx, &my);
1624 *x = -mx * sd->wd->align_x;
1626 *y = -my * sd->wd->align_y;
1630 _pan_resize(Evas_Object *obj,
1634 Pan *sd = evas_object_smart_data_get(obj);
1637 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1638 if ((ow == w) && (oh == h)) return;
1639 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1640 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1644 _pan_calculate(Evas_Object *obj)
1646 Pan *sd = evas_object_smart_data_get(obj);
1647 Evas_Coord cx = 0, cy = 0;
1651 if (!sd->wd->nmax) return;
1653 sd->wd->reorder_item_changed = EINA_FALSE;
1655 EINA_INLIST_FOREACH(sd->wd->items, it)
1659 if (sd->wd->horizontal)
1676 _item_place(it, cx, cy);
1677 if (sd->wd->reorder_item_changed) return;
1680 if (sd->wd->horizontal)
1693 if (sd->wd->horizontal)
1695 cy = (cy + 1) % sd->wd->nmax;
1700 cx = (cx + 1) % sd->wd->nmax;
1705 _group_item_place(sd);
1708 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
1710 if (!sd->wd->reorder_item_changed)
1712 sd->wd->old_pan_x = sd->wd->pan_x;
1713 sd->wd->old_pan_y = sd->wd->pan_y;
1715 sd->wd->move_effect_enabled = EINA_FALSE;
1717 evas_object_smart_callback_call(sd->wd->obj, SIG_CHANGED, NULL);
1721 _pan_move(Evas_Object *obj,
1722 Evas_Coord x __UNUSED__,
1723 Evas_Coord y __UNUSED__)
1725 Pan *sd = evas_object_smart_data_get(obj);
1727 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1728 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1732 _hold_on(void *data __UNUSED__,
1734 void *event_info __UNUSED__)
1736 Widget_Data *wd = elm_widget_data_get(obj);
1738 elm_smart_scroller_hold_set(wd->scr, 1);
1742 _hold_off(void *data __UNUSED__,
1744 void *event_info __UNUSED__)
1746 Widget_Data *wd = elm_widget_data_get(obj);
1748 elm_smart_scroller_hold_set(wd->scr, 0);
1752 _freeze_on(void *data __UNUSED__,
1754 void *event_info __UNUSED__)
1756 Widget_Data *wd = elm_widget_data_get(obj);
1758 elm_smart_scroller_freeze_set(wd->scr, 1);
1762 _freeze_off(void *data __UNUSED__,
1764 void *event_info __UNUSED__)
1766 Widget_Data *wd = elm_widget_data_get(obj);
1768 elm_smart_scroller_freeze_set(wd->scr, 0);
1772 _scr_anim_start(void *data,
1773 Evas_Object *obj __UNUSED__,
1774 void *event_info __UNUSED__)
1776 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1780 _scr_anim_stop(void *data,
1781 Evas_Object *obj __UNUSED__,
1782 void *event_info __UNUSED__)
1784 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1788 _scr_drag_start(void *data,
1789 Evas_Object *obj __UNUSED__,
1790 void *event_info __UNUSED__)
1792 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1796 _scr_drag_stop(void *data,
1797 Evas_Object *obj __UNUSED__,
1798 void *event_info __UNUSED__)
1800 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1804 _edge_left(void *data,
1805 Evas_Object *scr __UNUSED__,
1806 void *event_info __UNUSED__)
1808 evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
1812 _edge_right(void *data,
1813 Evas_Object *scr __UNUSED__,
1814 void *event_info __UNUSED__)
1816 evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
1820 _edge_top(void *data,
1821 Evas_Object *scr __UNUSED__,
1822 void *event_info __UNUSED__)
1824 evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
1828 _edge_bottom(void *data,
1829 Evas_Object *scr __UNUSED__,
1830 void *event_info __UNUSED__)
1832 evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
1836 _scr_scroll(void *data,
1837 Evas_Object *obj __UNUSED__,
1838 void *event_info __UNUSED__)
1840 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1844 _elm_gengrid_item_compare(const void *data, const void *data1)
1846 Elm_Gen_Item *it, *item1;
1847 it = ELM_GEN_ITEM_FROM_INLIST(data);
1848 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
1849 return it->wd->item_compare_cb(it, item1);
1853 _item_disable_hook(Elm_Object_Item *it)
1855 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
1857 if (_it->generation < _it->wd->generation) return;
1861 if (elm_widget_item_disabled_get(_it))
1862 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
1864 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
1869 _item_del_pre_hook(Elm_Object_Item *it)
1871 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
1872 if ((_it->relcount > 0) || (_it->walking > 0))
1874 _elm_genlist_item_del_notserious(_it);
1881 static Elm_Gen_Item *
1882 _item_new(Widget_Data *wd,
1883 const Elm_Gengrid_Item_Class *itc,
1886 const void *func_data)
1890 it = _elm_genlist_item_new(wd, itc, data, NULL, func, func_data);
1891 if (!it) return NULL;
1892 elm_widget_item_disable_hook_set(it, _item_disable_hook);
1893 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
1894 elm_gengrid_item_class_ref((Elm_Gengrid_Item_Class *)itc);
1895 it->item = ELM_NEW(Elm_Gen_Item_Type);
1897 it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
1898 ELM_GEN_ITEM_SETUP(it);
1904 elm_gengrid_add(Evas_Object *parent)
1909 static Evas_Smart *smart = NULL;
1910 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1914 static Evas_Smart_Class sc;
1916 evas_object_smart_clipped_smart_set(&_pan_sc);
1918 sc.name = "elm_gengrid_pan";
1919 sc.version = EVAS_SMART_CLASS_VERSION;
1922 sc.resize = _pan_resize;
1923 sc.move = _pan_move;
1924 sc.calculate = _pan_calculate;
1925 if (!(smart = evas_smart_class_new(&sc))) return NULL;
1928 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1930 ELM_SET_WIDTYPE(widtype, "gengrid");
1932 elm_widget_type_set(obj, "gengrid");
1933 elm_widget_sub_object_add(parent, obj);
1934 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1935 elm_widget_data_set(obj, wd);
1936 elm_widget_del_hook_set(obj, _del_hook);
1937 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1938 elm_widget_theme_hook_set(obj, _theme_hook);
1939 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1940 elm_widget_can_focus_set(obj, EINA_TRUE);
1941 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1942 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1943 elm_widget_event_hook_set(obj, _event_hook);
1946 wd->scr = elm_smart_scroller_add(e);
1947 elm_smart_scroller_widget_set(wd->scr, obj);
1948 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1950 elm_smart_scroller_bounce_allow_set(wd->scr, bounce,
1951 _elm_config->thumbscroll_bounce_enable);
1952 elm_widget_resize_object_set(obj, wd->scr);
1954 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1955 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1956 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1957 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1958 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1959 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1960 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1961 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom,
1963 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1968 wd->h_bounce = bounce;
1969 wd->v_bounce = bounce;
1971 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1972 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1973 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1974 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1976 wd->pan_smart = evas_object_smart_add(e, smart);
1977 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1980 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1981 _pan_set, _pan_get, _pan_max_get,
1982 _pan_min_get, _pan_child_size_get);
1984 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1986 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1991 elm_gengrid_item_size_set(Evas_Object *obj,
1995 ELM_CHECK_WIDTYPE(obj, widtype);
1996 Widget_Data *wd = elm_widget_data_get(obj);
1998 if ((wd->item_width == w) && (wd->item_height == h)) return;
2000 wd->item_height = h;
2001 if (wd->calc_job) ecore_job_del(wd->calc_job);
2002 wd->calc_job = ecore_job_add(_calc_job, wd);
2006 elm_gengrid_item_size_get(const Evas_Object *obj,
2010 ELM_CHECK_WIDTYPE(obj, widtype);
2011 Widget_Data *wd = elm_widget_data_get(obj);
2013 if (w) *w = wd->item_width;
2014 if (h) *h = wd->item_height;
2018 elm_gengrid_group_item_size_set(Evas_Object *obj,
2022 ELM_CHECK_WIDTYPE(obj, widtype);
2023 Widget_Data *wd = elm_widget_data_get(obj);
2025 if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
2026 wd->group_item_width = w;
2027 wd->group_item_height = h;
2028 if (wd->calc_job) ecore_job_del(wd->calc_job);
2029 wd->calc_job = ecore_job_add(_calc_job, wd);
2033 elm_gengrid_group_item_size_get(const Evas_Object *obj,
2037 ELM_CHECK_WIDTYPE(obj, widtype);
2038 Widget_Data *wd = elm_widget_data_get(obj);
2040 if (w) *w = wd->group_item_width;
2041 if (h) *h = wd->group_item_height;
2045 elm_gengrid_align_set(Evas_Object *obj,
2049 ELM_CHECK_WIDTYPE(obj, widtype);
2051 Widget_Data *wd = elm_widget_data_get(obj);
2052 double old_h = wd->align_x, old_y = wd->align_y;
2056 else if (align_x < 0.0)
2058 wd->align_x = align_x;
2062 else if (align_y < 0.0)
2064 wd->align_y = align_y;
2066 if ((old_h != wd->align_x) || (old_y != wd->align_y))
2067 evas_object_smart_calculate(wd->pan_smart);
2071 elm_gengrid_align_get(const Evas_Object *obj,
2075 ELM_CHECK_WIDTYPE(obj, widtype);
2076 Widget_Data *wd = elm_widget_data_get(obj);
2077 if (align_x) *align_x = wd->align_x;
2078 if (align_y) *align_y = wd->align_y;
2081 EAPI Elm_Object_Item *
2082 elm_gengrid_item_append(Evas_Object *obj,
2083 const Elm_Gengrid_Item_Class *itc,
2086 const void *func_data)
2089 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2090 Widget_Data *wd = elm_widget_data_get(obj);
2091 if (!wd) return NULL;
2093 it = _item_new(wd, itc, data, func, func_data);
2094 if (!it) return NULL;
2095 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2098 wd->group_items = eina_list_prepend(wd->group_items, it);
2100 if (wd->calc_job) ecore_job_del(wd->calc_job);
2101 wd->calc_job = ecore_job_add(_calc_job, wd);
2103 return (Elm_Object_Item *) it;
2106 EAPI Elm_Object_Item *
2107 elm_gengrid_item_prepend(Evas_Object *obj,
2108 const Elm_Gengrid_Item_Class *itc,
2111 const void *func_data)
2114 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2115 Widget_Data *wd = elm_widget_data_get(obj);
2116 if (!wd) return NULL;
2118 it = _item_new(wd, itc, data, func, func_data);
2119 if (!it) return NULL;
2120 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2122 wd->group_items = eina_list_append(wd->group_items, it);
2124 if (wd->calc_job) ecore_job_del(wd->calc_job);
2125 wd->calc_job = ecore_job_add(_calc_job, wd);
2127 return (Elm_Object_Item *) it;
2130 EAPI Elm_Object_Item *
2131 elm_gengrid_item_insert_before(Evas_Object *obj,
2132 const Elm_Gengrid_Item_Class *itc,
2134 Elm_Object_Item *relative,
2136 const void *func_data)
2139 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2140 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2141 Widget_Data *wd = elm_widget_data_get(obj);
2142 if (!wd) return NULL;
2144 it = _item_new(wd, itc, data, func, func_data);
2145 if (!it) return NULL;
2146 wd->items = eina_inlist_prepend_relative
2147 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2149 wd->group_items = eina_list_append_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2151 if (wd->calc_job) ecore_job_del(wd->calc_job);
2152 wd->calc_job = ecore_job_add(_calc_job, wd);
2154 return (Elm_Object_Item *) it;
2157 EAPI Elm_Object_Item *
2158 elm_gengrid_item_insert_after(Evas_Object *obj,
2159 const Elm_Gengrid_Item_Class *itc,
2161 Elm_Object_Item *relative,
2163 const void *func_data)
2166 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2167 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2168 Widget_Data *wd = elm_widget_data_get(obj);
2169 if (!wd) return NULL;
2171 it = _item_new(wd, itc, data, func, func_data);
2172 if (!it) return NULL;
2173 wd->items = eina_inlist_append_relative
2174 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2176 wd->group_items = eina_list_prepend_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2178 if (wd->calc_job) ecore_job_del(wd->calc_job);
2179 wd->calc_job = ecore_job_add(_calc_job, wd);
2181 return (Elm_Object_Item *) it;
2184 EAPI Elm_Object_Item *
2185 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2186 const Elm_Gengrid_Item_Class *itc,
2188 Eina_Compare_Cb comp,
2190 const void *func_data)
2193 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2194 Widget_Data *wd = elm_widget_data_get(obj);
2195 if (!wd) return NULL;
2197 it = _item_new(wd, itc, data, func, func_data);
2198 if (!it) return NULL;
2201 wd->state = eina_inlist_sorted_state_new();
2203 wd->item_compare_cb = comp;
2204 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
2205 _elm_gengrid_item_compare, wd->state);
2206 if (wd->calc_job) ecore_job_del(wd->calc_job);
2207 wd->calc_job = ecore_job_add(_calc_job, wd);
2209 return (Elm_Object_Item *) it;
2212 EINA_DEPRECATED Elm_Object_Item *
2213 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
2214 const Elm_Gengrid_Item_Class *itc,
2216 Eina_Compare_Cb comp,
2218 const void *func_data)
2220 return elm_gengrid_item_sorted_insert(obj, itc, data, comp, func, func_data);
2224 elm_gengrid_item_del(Elm_Object_Item *it)
2226 elm_object_item_del(it);
2230 elm_gengrid_horizontal_set(Evas_Object *obj,
2231 Eina_Bool horizontal)
2233 ELM_CHECK_WIDTYPE(obj, widtype);
2234 Widget_Data *wd = elm_widget_data_get(obj);
2236 horizontal = !!horizontal;
2237 if (horizontal == wd->horizontal) return;
2238 wd->horizontal = horizontal;
2240 /* Update the items to conform to the new layout */
2241 if (wd->calc_job) ecore_job_del(wd->calc_job);
2242 wd->calc_job = ecore_job_add(_calc_job, wd);
2246 elm_gengrid_horizontal_get(const Evas_Object *obj)
2248 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2249 Widget_Data *wd = elm_widget_data_get(obj);
2250 if (!wd) return EINA_FALSE;
2251 return wd->horizontal;
2255 elm_gengrid_clear(Evas_Object *obj)
2257 elm_genlist_clear(obj);
2260 EINA_DEPRECATED EAPI const Evas_Object *
2261 elm_gengrid_item_object_get(const Elm_Object_Item *it)
2263 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2268 elm_gengrid_item_update(Elm_Object_Item *it)
2270 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2271 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2272 if (!_it->realized) return;
2273 if (_it->want_unrealize) return;
2274 _elm_genlist_item_unrealize(_it, EINA_FALSE);
2276 _item_place(_it, _it->x, _it->y);
2280 elm_gengrid_item_data_get(const Elm_Object_Item *it)
2282 return elm_object_item_data_get(it);
2286 elm_gengrid_item_data_set(Elm_Object_Item *it,
2289 elm_object_item_data_set(it, (void *) data);
2292 EAPI const Elm_Gengrid_Item_Class *
2293 elm_gengrid_item_item_class_get(const Elm_Object_Item *it)
2295 return (Elm_Gengrid_Item_Class *) elm_genlist_item_item_class_get(it);
2298 EINA_DEPRECATED EAPI void
2299 elm_gengrid_item_item_class_set(Elm_Object_Item *it,
2300 const Elm_Gengrid_Item_Class *itc)
2302 elm_gengrid_item_item_class_update(it, itc);
2306 elm_gengrid_item_item_class_update(Elm_Object_Item *it,
2307 const Elm_Gengrid_Item_Class *itc)
2309 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2310 EINA_SAFETY_ON_NULL_RETURN(itc);
2311 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2312 if (_it->generation < _it->wd->generation) return;
2314 elm_gengrid_item_update(it);
2318 elm_gengrid_item_pos_get(const Elm_Object_Item *it,
2322 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2323 if (x) *x = ((Elm_Gen_Item *) it)->x;
2324 if (y) *y = ((Elm_Gen_Item *) it)->y;
2328 elm_gengrid_multi_select_set(Evas_Object *obj,
2331 ELM_CHECK_WIDTYPE(obj, widtype);
2332 Widget_Data *wd = elm_widget_data_get(obj);
2334 wd->multi = !!multi;
2338 elm_gengrid_multi_select_get(const Evas_Object *obj)
2340 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2341 Widget_Data *wd = elm_widget_data_get(obj);
2342 if (!wd) return EINA_FALSE;
2346 EAPI Elm_Object_Item *
2347 elm_gengrid_selected_item_get(const Evas_Object *obj)
2349 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2350 Widget_Data *wd = elm_widget_data_get(obj);
2351 if (!wd) return NULL;
2352 if (wd->selected) return wd->selected->data;
2356 EAPI const Eina_List *
2357 elm_gengrid_selected_items_get(const Evas_Object *obj)
2359 return elm_genlist_selected_items_get(obj);
2363 elm_gengrid_item_selected_set(Elm_Object_Item *it,
2366 elm_genlist_item_selected_set(it, selected);
2370 elm_gengrid_item_selected_get(const Elm_Object_Item *it)
2372 return elm_genlist_item_selected_get(it);
2376 elm_gengrid_item_disabled_set(Elm_Object_Item *it,
2379 elm_object_item_disabled_set(it, disabled);
2383 elm_gengrid_item_disabled_get(const Elm_Object_Item *it)
2385 return elm_object_item_disabled_get(it);
2388 static Evas_Object *
2389 _elm_gengrid_item_label_create(void *data,
2390 Evas_Object *obj __UNUSED__,
2391 Evas_Object *tooltip,
2392 void *it __UNUSED__)
2394 Evas_Object *label = elm_label_add(tooltip);
2397 elm_object_style_set(label, "tooltip");
2398 elm_object_text_set(label, data);
2403 _elm_gengrid_item_label_del_cb(void *data,
2404 Evas_Object *obj __UNUSED__,
2405 void *event_info __UNUSED__)
2407 eina_stringshare_del(data);
2411 elm_gengrid_item_tooltip_text_set(Elm_Object_Item *it,
2414 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2415 text = eina_stringshare_add(text);
2416 elm_gengrid_item_tooltip_content_cb_set(it, _elm_gengrid_item_label_create,
2418 _elm_gengrid_item_label_del_cb);
2422 elm_gengrid_item_tooltip_content_cb_set(Elm_Object_Item *it,
2423 Elm_Tooltip_Item_Content_Cb func,
2425 Evas_Smart_Cb del_cb)
2427 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
2428 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2430 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
2433 if (_it->tooltip.del_cb)
2434 _it->tooltip.del_cb((void *)_it->tooltip.data, WIDGET(_it), _it);
2435 _it->tooltip.content_cb = func;
2436 _it->tooltip.data = data;
2437 _it->tooltip.del_cb = del_cb;
2440 elm_widget_item_tooltip_content_cb_set(_it,
2441 _it->tooltip.content_cb,
2442 _it->tooltip.data, NULL);
2443 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
2444 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
2450 if (del_cb) del_cb((void *)data, NULL, NULL);
2454 elm_gengrid_item_tooltip_unset(Elm_Object_Item *it)
2456 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2457 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2459 if ((VIEW(_it)) && (_it->tooltip.content_cb))
2460 elm_widget_item_tooltip_unset(_it);
2462 if (_it->tooltip.del_cb)
2463 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
2464 _it->tooltip.del_cb = NULL;
2465 _it->tooltip.content_cb = NULL;
2466 _it->tooltip.data = NULL;
2467 _it->tooltip.free_size = EINA_FALSE;
2468 if (_it->tooltip.style)
2469 elm_gengrid_item_tooltip_style_set(it, NULL);
2473 elm_gengrid_item_tooltip_style_set(Elm_Object_Item *it,
2476 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2477 eina_stringshare_replace(&((Elm_Gen_Item *) it)->tooltip.style, style);
2478 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
2482 elm_gengrid_item_tooltip_style_get(const Elm_Object_Item *it)
2484 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2485 return ((Elm_Gen_Item *) it)->tooltip.style;
2489 elm_gengrid_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
2491 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2492 ((Elm_Gen_Item *) it)->tooltip.free_size = disable;
2493 if (VIEW(it)) return elm_widget_item_tooltip_window_mode_set(it, disable);
2498 elm_gengrid_item_tooltip_window_mode_get(const Elm_Object_Item *it)
2500 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2501 return ((Elm_Gen_Item *) it)->tooltip.free_size;
2505 elm_gengrid_item_cursor_set(Elm_Object_Item *it,
2508 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2509 eina_stringshare_replace(&((Elm_Gen_Item *) it)->mouse_cursor, cursor);
2510 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
2514 elm_gengrid_item_cursor_get(const Elm_Object_Item *it)
2516 return elm_widget_item_cursor_get(it);
2520 elm_gengrid_item_cursor_unset(Elm_Object_Item *it)
2522 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2523 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2524 if (!_it->mouse_cursor)
2528 elm_widget_item_cursor_unset(_it);
2530 eina_stringshare_del(_it->mouse_cursor);
2531 _it->mouse_cursor = NULL;
2535 elm_gengrid_item_cursor_style_set(Elm_Object_Item *it,
2538 elm_widget_item_cursor_style_set(it, style);
2542 elm_gengrid_item_cursor_style_get(const Elm_Object_Item *it)
2544 return elm_widget_item_cursor_style_get(it);
2548 elm_gengrid_item_cursor_engine_only_set(Elm_Object_Item *it,
2549 Eina_Bool engine_only)
2551 elm_widget_item_cursor_engine_only_set(it, engine_only);
2555 elm_gengrid_item_cursor_engine_only_get(const Elm_Object_Item *it)
2557 return elm_widget_item_cursor_engine_only_get(it);
2561 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2562 Eina_Bool reorder_mode)
2564 ELM_CHECK_WIDTYPE(obj, widtype);
2565 Widget_Data *wd = elm_widget_data_get(obj);
2567 wd->reorder_mode = !!reorder_mode;
2571 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2573 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2574 Widget_Data *wd = elm_widget_data_get(obj);
2575 if (!wd) return EINA_FALSE;
2576 return wd->reorder_mode;
2580 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2581 Eina_Bool always_select)
2583 elm_genlist_always_select_mode_set(obj, always_select);
2587 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2589 return elm_genlist_always_select_mode_get(obj);
2593 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2594 Eina_Bool no_select)
2596 elm_genlist_no_select_mode_set(obj, no_select);
2600 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2602 return elm_genlist_no_select_mode_get(obj);
2606 elm_gengrid_bounce_set(Evas_Object *obj,
2610 elm_genlist_bounce_set(obj, h_bounce, v_bounce);
2614 elm_gengrid_bounce_get(const Evas_Object *obj,
2615 Eina_Bool *h_bounce,
2616 Eina_Bool *v_bounce)
2618 elm_genlist_bounce_get(obj, h_bounce, v_bounce);
2622 elm_gengrid_page_relative_set(Evas_Object *obj,
2626 _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
2630 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2632 _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
2636 elm_gengrid_page_size_set(Evas_Object *obj,
2637 Evas_Coord h_pagesize,
2638 Evas_Coord v_pagesize)
2640 _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
2644 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2646 _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
2650 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2652 _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
2656 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2658 _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
2662 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2664 _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
2667 EAPI Elm_Object_Item *
2668 elm_gengrid_first_item_get(const Evas_Object *obj)
2670 return elm_genlist_first_item_get(obj);
2673 EAPI Elm_Object_Item *
2674 elm_gengrid_last_item_get(const Evas_Object *obj)
2676 return elm_genlist_last_item_get(obj);
2679 EAPI Elm_Object_Item *
2680 elm_gengrid_item_next_get(const Elm_Object_Item *it)
2682 return elm_genlist_item_next_get(it);
2685 EAPI Elm_Object_Item *
2686 elm_gengrid_item_prev_get(const Elm_Object_Item *it)
2688 return elm_genlist_item_prev_get(it);
2692 elm_gengrid_item_gengrid_get(const Elm_Object_Item *it)
2694 return elm_object_item_widget_get(it);
2698 elm_gengrid_item_show(Elm_Object_Item *it)
2700 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2701 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2702 Widget_Data *wd = _it->wd;
2703 Evas_Coord minx = 0, miny = 0;
2705 if ((_it->generation < _it->wd->generation)) return;
2706 _pan_min_get(wd->pan_smart, &minx, &miny);
2709 elm_smart_scroller_region_bring_in(_it->wd->scr,
2710 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2711 _it->y * wd->item_height + miny,
2712 _it->wd->item_width,
2713 _it->wd->item_height);
2715 elm_smart_scroller_region_bring_in(_it->wd->scr,
2716 _it->x * wd->item_width + minx,
2717 ((_it->y - _it->item->prev_group) * wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2718 _it->wd->item_width,
2719 _it->wd->item_height);
2723 elm_gengrid_item_bring_in(Elm_Object_Item *it)
2725 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2726 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2728 if (_it->generation < _it->wd->generation) return;
2730 Evas_Coord minx = 0, miny = 0;
2731 Widget_Data *wd = _it->wd;
2732 _pan_min_get(wd->pan_smart, &minx, &miny);
2735 elm_smart_scroller_region_bring_in(_it->wd->scr,
2736 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2737 _it->y * wd->item_height + miny,
2738 _it->wd->item_width,
2739 _it->wd->item_height);
2741 elm_smart_scroller_region_bring_in(_it->wd->scr,
2742 _it->x * wd->item_width + minx,
2743 ((_it->y - _it->item->prev_group)* wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2744 _it->wd->item_width,
2745 _it->wd->item_height);
2749 elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill)
2751 ELM_CHECK_WIDTYPE(obj, widtype);
2752 Widget_Data *wd = elm_widget_data_get(obj);
2755 if (wd->filled != fill)
2760 elm_gengrid_filled_get(const Evas_Object *obj)
2762 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2763 Widget_Data *wd = elm_widget_data_get(obj);
2764 if (!wd) return EINA_FALSE;
2768 EAPI Elm_Gengrid_Item_Class *
2769 elm_gengrid_item_class_new(void)
2771 Elm_Gengrid_Item_Class *itc;
2773 itc = calloc(1, sizeof(Elm_Gengrid_Item_Class));
2776 itc->version = CLASS_ALLOCATED;
2778 itc->delete_me = EINA_FALSE;
2784 elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
2786 if (itc && (itc->version == CLASS_ALLOCATED))
2788 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
2789 if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
2799 elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
2801 if (itc && (itc->version == CLASS_ALLOCATED))
2804 if (itc->refcount == 0) itc->refcount--;
2809 elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
2811 if (itc && (itc->version == CLASS_ALLOCATED))
2813 if (itc->refcount > 0) itc->refcount--;
2814 if (itc->delete_me && (!itc->refcount))
2815 elm_gengrid_item_class_free(itc);