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 wasselected : 1;
63 Eina_Bool clear_me : 1;
64 Eina_Bool h_bounce : 1;
65 Eina_Bool v_bounce : 1;
66 Ecore_Cb del_cb, calc_cb, sizing_cb;
68 ////////////////////////////////////
69 double align_x, align_y;
71 Evas_Coord old_pan_x, old_pan_y;
72 Evas_Coord reorder_item_x, reorder_item_y;
78 Eina_Bool horizontal : 1;
79 Eina_Bool longpressed : 1;
80 Eina_Bool reorder_item_changed : 1;
81 Eina_Bool move_effect_enabled : 1;
85 static const char *widtype = NULL;
86 static void _item_highlight(Elm_Gen_Item *it);
87 static void _item_unrealize_cb(Elm_Gen_Item *it);
88 static void _item_unselect(Elm_Gen_Item *it);
89 static void _calc_job(void *data);
90 static void _on_focus_hook(void *data,
92 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
93 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
94 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
95 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
96 static Eina_Bool _item_single_select_up(Widget_Data *wd);
97 static Eina_Bool _item_single_select_down(Widget_Data *wd);
98 static Eina_Bool _item_single_select_left(Widget_Data *wd);
99 static Eina_Bool _item_single_select_right(Widget_Data *wd);
100 static Eina_Bool _event_hook(Evas_Object *obj,
102 Evas_Callback_Type type,
104 static Eina_Bool _deselect_all_items(Widget_Data *wd);
106 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
107 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
109 static const char SIG_ACTIVATED[] = "activated";
110 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
111 static const char SIG_LONGPRESSED[] = "longpressed";
112 static const char SIG_SELECTED[] = "selected";
113 static const char SIG_UNSELECTED[] = "unselected";
114 static const char SIG_REALIZED[] = "realized";
115 static const char SIG_UNREALIZED[] = "unrealized";
116 static const char SIG_CHANGED[] = "changed";
117 static const char SIG_DRAG_START_UP[] = "drag,start,up";
118 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
119 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
120 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
121 static const char SIG_DRAG_STOP[] = "drag,stop";
122 static const char SIG_DRAG[] = "drag";
123 static const char SIG_SCROLL[] = "scroll";
124 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
125 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
126 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
127 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
128 static const char SIG_EDGE_TOP[] = "edge,top";
129 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
130 static const char SIG_EDGE_LEFT[] = "edge,left";
131 static const char SIG_EDGE_RIGHT[] = "edge,right";
132 static const char SIG_MOVED[] = "moved";
134 static const Evas_Smart_Cb_Description _signals[] = {
136 {SIG_CLICKED_DOUBLE, ""},
137 {SIG_LONGPRESSED, ""},
139 {SIG_UNSELECTED, ""},
141 {SIG_UNREALIZED, ""},
143 {SIG_DRAG_START_UP, ""},
144 {SIG_DRAG_START_DOWN, ""},
145 {SIG_DRAG_START_LEFT, ""},
146 {SIG_DRAG_START_RIGHT, ""},
150 {SIG_SCROLL_ANIM_START, ""},
151 {SIG_SCROLL_ANIM_STOP, ""},
152 {SIG_SCROLL_DRAG_START, ""},
153 {SIG_SCROLL_DRAG_STOP, ""},
155 {SIG_EDGE_BOTTOM, ""},
157 {SIG_EDGE_RIGHT, ""},
163 _event_hook(Evas_Object *obj,
164 Evas_Object *src __UNUSED__,
165 Evas_Callback_Type type,
168 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
169 Evas_Event_Key_Down *ev = event_info;
170 Widget_Data *wd = elm_widget_data_get(obj);
171 if (!wd) return EINA_FALSE;
172 if (!wd->items) return EINA_FALSE;
173 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
174 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
176 Elm_Object_Item *it = NULL;
179 Evas_Coord step_x = 0;
180 Evas_Coord step_y = 0;
183 Evas_Coord page_x = 0;
184 Evas_Coord page_y = 0;
186 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
187 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
188 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
189 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
191 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
193 if ((wd->horizontal) &&
194 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
195 (_item_multi_select_up(wd)))
196 || (_item_single_select_up(wd))))
198 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
201 else if ((!wd->horizontal) &&
202 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
203 (_item_multi_select_left(wd)))
204 || (_item_single_select_left(wd))))
206 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
212 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
214 if ((wd->horizontal) &&
215 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
216 (_item_multi_select_down(wd)))
217 || (_item_single_select_down(wd))))
219 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
222 else if ((!wd->horizontal) &&
223 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
224 (_item_multi_select_right(wd)))
225 || (_item_single_select_right(wd))))
227 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
233 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
235 if ((wd->horizontal) &&
236 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
237 (_item_multi_select_left(wd)))
238 || (_item_single_select_left(wd))))
240 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
243 else if ((!wd->horizontal) &&
244 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
245 (_item_multi_select_up(wd)))
246 || (_item_single_select_up(wd))))
248 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
254 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
256 if ((wd->horizontal) &&
257 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
258 (_item_multi_select_right(wd)))
259 || (_item_single_select_right(wd))))
261 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
264 else if ((!wd->horizontal) &&
265 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
266 (_item_multi_select_down(wd)))
267 || (_item_single_select_down(wd))))
269 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
275 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
277 it = elm_gengrid_first_item_get(obj);
278 elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN);
279 elm_gengrid_item_selected_set(it, EINA_TRUE);
280 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
283 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
285 it = elm_gengrid_last_item_get(obj);
286 elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN);
287 elm_gengrid_item_selected_set(it, EINA_TRUE);
288 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
291 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
296 x -= -(page_x * v_w) / 100;
303 y -= -(page_y * v_h) / 100;
308 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
313 x += -(page_x * v_w) / 100;
320 y += -(page_y * v_h) / 100;
325 else if (!strcmp(ev->keyname, "Escape"))
327 if (!_deselect_all_items(wd)) return EINA_FALSE;
328 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
331 else if (((!strcmp(ev->keyname, "Return")) ||
332 (!strcmp(ev->keyname, "KP_Enter")) ||
333 (!strcmp(ev->keyname, "space")))
334 && (!wd->multi) && (wd->selected))
336 it = elm_gengrid_selected_item_get(obj);
337 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
339 else return EINA_FALSE;
341 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
342 elm_smart_scroller_child_pos_set(wd->scr, x, y);
347 _deselect_all_items(Widget_Data *wd)
349 if (!wd->selected) return EINA_FALSE;
351 elm_gengrid_item_selected_set((Elm_Object_Item *) wd->selected->data,
358 _item_multi_select_left(Widget_Data *wd)
360 if (!wd->selected) return EINA_FALSE;
362 Elm_Object_Item *prev =
363 elm_gengrid_item_prev_get(wd->last_selected_item);
364 if (!prev) return EINA_TRUE;
365 if (elm_gengrid_item_selected_get(prev))
367 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
368 wd->last_selected_item = prev;
369 elm_gengrid_item_show(wd->last_selected_item, ELM_GENGRID_ITEM_SCROLLTO_IN);
373 elm_gengrid_item_selected_set(prev, EINA_TRUE);
374 elm_gengrid_item_show(prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
381 _item_multi_select_right(Widget_Data *wd)
383 if (!wd->selected) return EINA_FALSE;
385 Elm_Object_Item *next =
386 elm_gengrid_item_next_get(wd->last_selected_item);
387 if (!next) return EINA_TRUE;
388 if (elm_gengrid_item_selected_get(next))
390 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
391 wd->last_selected_item = next;
392 elm_gengrid_item_show(wd->last_selected_item, ELM_GENGRID_ITEM_SCROLLTO_IN);
396 elm_gengrid_item_selected_set(next, EINA_TRUE);
397 elm_gengrid_item_show(next, ELM_GENGRID_ITEM_SCROLLTO_IN);
404 _item_multi_select_up(Widget_Data *wd)
407 Eina_Bool r = EINA_TRUE;
409 if (!wd->selected) return EINA_FALSE;
411 for (i = 0; (r) && (i < wd->nmax); i++)
412 r &= _item_multi_select_left(wd);
418 _item_multi_select_down(Widget_Data *wd)
421 Eina_Bool r = EINA_TRUE;
423 if (!wd->selected) return EINA_FALSE;
425 for (i = 0; (r) && (i < wd->nmax); i++)
426 r &= _item_multi_select_right(wd);
432 _item_single_select_up(Widget_Data *wd)
440 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
441 while ((prev) && (prev->generation < wd->generation))
442 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
443 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
444 elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
448 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
450 if (!prev) return EINA_FALSE;
452 for (i = 1; i < wd->nmax; i++)
454 Elm_Object_Item *tmp =
455 elm_gengrid_item_prev_get((Elm_Object_Item *) prev);
456 if (!tmp) return EINA_FALSE;
457 prev = (Elm_Gen_Item *) tmp;
460 _deselect_all_items(wd);
462 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
463 elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
468 _item_single_select_down(Widget_Data *wd)
476 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
477 while ((next) && (next->generation < wd->generation))
478 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
479 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
480 elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN);
484 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
486 if (!next) return EINA_FALSE;
488 for (i = 1; i < wd->nmax; i++)
490 Elm_Object_Item *tmp =
491 elm_gengrid_item_next_get((Elm_Object_Item *) next);
492 if (!tmp) return EINA_FALSE;
493 next = (Elm_Gen_Item *) tmp;
496 _deselect_all_items(wd);
498 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
499 elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN);
504 _item_single_select_left(Widget_Data *wd)
509 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
510 while ((prev) && (prev->generation < wd->generation))
511 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
514 prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
516 if (!prev) return EINA_FALSE;
518 _deselect_all_items(wd);
520 elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
521 elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
526 _item_single_select_right(Widget_Data *wd)
531 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
532 while ((next) && (next->generation < wd->generation))
533 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
536 next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
538 if (!next) return EINA_FALSE;
540 _deselect_all_items(wd);
542 elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
543 elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN);
548 _on_focus_hook(void *data __UNUSED__,
551 Widget_Data *wd = elm_widget_data_get(obj);
553 if (elm_widget_focus_get(obj))
555 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
556 evas_object_focus_set(wd->obj, EINA_TRUE);
557 if ((wd->selected) && (!wd->last_selected_item))
558 wd->last_selected_item = eina_list_data_get(wd->selected);
562 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
563 evas_object_focus_set(wd->obj, EINA_FALSE);
568 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
570 Widget_Data *wd = elm_widget_data_get(obj);
573 elm_smart_scroller_mirrored_set(wd->scr, rtl);
574 if (!wd->items) return;
575 it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
579 edje_object_mirrored_set(VIEW(it), rtl);
580 elm_gengrid_item_update((Elm_Object_Item *)it);
581 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
586 _theme_hook(Evas_Object *obj)
588 Widget_Data *wd = elm_widget_data_get(obj);
590 _elm_widget_mirrored_reload(obj);
591 _mirrored_set(obj, elm_widget_mirrored_get(obj));
592 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
593 elm_widget_style_get(obj));
597 _del_pre_hook(Evas_Object *obj)
599 Widget_Data *wd = elm_widget_data_get(obj);
601 elm_gengrid_clear(obj);
602 evas_object_del(wd->pan_smart);
603 wd->pan_smart = NULL;
607 _del_hook(Evas_Object *obj)
609 Widget_Data *wd = elm_widget_data_get(obj);
610 if (wd->calc_job) ecore_job_del(wd->calc_job);
615 _signal_emit_hook(Evas_Object *obj,
616 const char *emission,
619 Widget_Data *wd = elm_widget_data_get(obj);
621 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
626 _signal_callback_add_hook(Evas_Object *obj,
627 const char *emission,
629 Edje_Signal_Cb func_cb,
632 Widget_Data *wd = elm_widget_data_get(obj);
634 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
635 emission, source, func_cb, data);
639 _signal_callback_del_hook(Evas_Object *obj,
640 const char *emission,
642 Edje_Signal_Cb func_cb,
645 Widget_Data *wd = elm_widget_data_get(obj);
647 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scr),
648 emission, source, func_cb, data);
652 _mouse_move(void *data,
653 Evas *evas __UNUSED__,
657 Elm_Gen_Item *it = data;
658 Evas_Event_Mouse_Move *ev = event_info;
659 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
660 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
662 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
664 if (!it->wd->on_hold)
666 it->wd->on_hold = EINA_TRUE;
667 if (!it->wd->wasselected)
671 if ((it->dragging) && (it->down))
675 ecore_timer_del(it->long_timer);
676 it->long_timer = NULL;
678 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
681 if ((!it->down) || (it->wd->longpressed))
685 ecore_timer_del(it->long_timer);
686 it->long_timer = NULL;
688 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
690 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
692 it_scrl_x = ev->cur.canvas.x - it->wd->reorder_it->dx;
693 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
695 if (it_scrl_x < ox) it->wd->reorder_item_x = ox;
696 else if (it_scrl_x + it->wd->item_width > ox + ow)
697 it->wd->reorder_item_x = ox + ow - it->wd->item_width;
698 else it->wd->reorder_item_x = it_scrl_x;
700 if (it_scrl_y < oy) it->wd->reorder_item_y = oy;
701 else if (it_scrl_y + it->wd->item_height > oy + oh)
702 it->wd->reorder_item_y = oy + oh - it->wd->item_height;
703 else it->wd->reorder_item_y = it_scrl_y;
705 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
706 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
710 if (!it->display_only)
711 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
712 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
713 x = ev->cur.canvas.x - x;
714 y = ev->cur.canvas.y - y;
717 if (adx < 0) adx = -dx;
720 if (ady < 0) ady = -dy;
723 if ((adx > minw) || (ady > minh))
725 const char *left_drag, *right_drag;
726 if (!elm_widget_mirrored_get(WIDGET(it)))
728 left_drag = SIG_DRAG_START_LEFT;
729 right_drag = SIG_DRAG_START_RIGHT;
733 left_drag = SIG_DRAG_START_RIGHT;
734 right_drag = SIG_DRAG_START_LEFT;
740 ecore_timer_del(it->long_timer);
741 it->long_timer = NULL;
743 if (!it->wd->wasselected)
748 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_START_UP,
753 evas_object_smart_callback_call(WIDGET(it),
760 evas_object_smart_callback_call(WIDGET(it),
761 SIG_DRAG_START_DOWN, it);
765 evas_object_smart_callback_call(WIDGET(it),
768 evas_object_smart_callback_call(WIDGET(it),
776 _long_press(void *data)
778 Elm_Gen_Item *it = data;
780 it->long_timer = NULL;
781 if (elm_widget_item_disabled_get(it)|| (it->dragging))
782 return ECORE_CALLBACK_CANCEL;
783 it->wd->longpressed = EINA_TRUE;
784 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
785 if (it->wd->reorder_mode)
787 it->wd->reorder_it = it;
788 evas_object_raise(VIEW(it));
789 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
790 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
791 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
793 return ECORE_CALLBACK_CANCEL;
797 _mouse_down(void *data,
798 Evas *evas __UNUSED__,
802 Elm_Gen_Item *it = data;
803 Evas_Event_Mouse_Down *ev = event_info;
806 if (ev->button != 1) return;
809 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
810 it->dx = ev->canvas.x - x;
811 it->dy = ev->canvas.y - y;
812 it->wd->longpressed = EINA_FALSE;
813 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
814 else it->wd->on_hold = EINA_FALSE;
815 if (it->wd->on_hold) return;
816 it->wd->wasselected = it->selected;
818 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
820 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
821 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
823 if (it->long_timer) ecore_timer_del(it->long_timer);
825 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
828 it->long_timer = NULL;
832 _mouse_up(void *data,
833 Evas *evas __UNUSED__,
834 Evas_Object *obj __UNUSED__,
837 Elm_Gen_Item *it = data;
838 Evas_Event_Mouse_Up *ev = event_info;
839 Eina_Bool dragged = EINA_FALSE;
841 if (ev->button != 1) return;
842 it->down = EINA_FALSE;
843 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
844 else it->wd->on_hold = EINA_FALSE;
847 ecore_timer_del(it->long_timer);
848 it->long_timer = NULL;
852 it->dragging = EINA_FALSE;
853 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
858 it->wd->longpressed = EINA_FALSE;
859 it->wd->on_hold = EINA_FALSE;
862 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
864 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it->wd->reorder_it);
865 it->wd->reorder_it = NULL;
866 it->wd->move_effect_enabled = EINA_FALSE;
867 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
868 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
870 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
871 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
872 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
874 if (it->wd->longpressed)
876 it->wd->longpressed = EINA_FALSE;
877 if (!it->wd->wasselected) _item_unselect(it);
878 it->wd->wasselected = EINA_FALSE;
883 if (it->want_unrealize)
884 _elm_genlist_item_unrealize(it, EINA_FALSE);
886 if (elm_widget_item_disabled_get(it) || (dragged)) return;
894 else _item_unselect(it);
900 while (it->wd->selected)
901 _item_unselect(it->wd->selected->data);
905 const Eina_List *l, *l_next;
908 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, item2)
909 if (item2 != it) _item_unselect(item2);
917 _item_highlight(Elm_Gen_Item *it)
919 if ((it->wd->select_mode == ELM_OBJECT_NO_SELECT) || (it->generation < it->wd->generation) || (it->highlighted)) return;
920 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
921 it->highlighted = EINA_TRUE;
925 _item_realize(Elm_Gen_Item *it)
930 if ((it->realized) || (it->generation < it->wd->generation)) return;
931 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
932 edje_object_scale_set(VIEW(it), elm_widget_scale_get(WIDGET(it)) *
934 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
935 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
936 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
937 snprintf(style, sizeof(style), "item/%s",
938 it->itc->item_style ? it->itc->item_style : "default");
939 _elm_theme_object_set(WIDGET(it), VIEW(it), "gengrid", style,
940 elm_widget_style_get(WIDGET(it)));
942 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
943 evas_object_color_set(it->spacer, 0, 0, 0, 0);
944 elm_widget_sub_object_add(WIDGET(it), it->spacer);
945 evas_object_size_hint_min_set(it->spacer, 2 * _elm_config->scale, 1);
946 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
948 if (it->itc->func.text_get)
954 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
956 EINA_LIST_FOREACH(it->texts, l, key)
958 char *s = it->itc->func.text_get
959 ((void *)it->base.data, WIDGET(it), key);
962 edje_object_part_text_set(VIEW(it), key, s);
968 if (it->itc->func.content_get)
972 Evas_Object *ic = NULL;
975 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
977 EINA_LIST_FOREACH(it->contents, l, key)
979 if (it->itc->func.content_get)
980 ic = it->itc->func.content_get
981 ((void *)it->base.data, WIDGET(it), key);
984 it->content_objs = eina_list_append(it->content_objs, ic);
985 edje_object_part_swallow(VIEW(it), key, ic);
986 evas_object_show(ic);
987 elm_widget_sub_object_add(WIDGET(it), ic);
992 if (it->itc->func.state_get)
998 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
1000 EINA_LIST_FOREACH(it->states, l, key)
1002 Eina_Bool on = it->itc->func.state_get
1003 ((void *)it->base.data, WIDGET(it), l->data);
1006 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1007 edje_object_signal_emit(VIEW(it), buf, "elm");
1014 if ((!it->wd->group_item_width) && (!it->wd->group_item_height))
1016 edje_object_size_min_restricted_calc(VIEW(it),
1017 &it->wd->group_item_width,
1018 &it->wd->group_item_height,
1019 it->wd->group_item_width,
1020 it->wd->group_item_height);
1025 if ((!it->wd->item_width) && (!it->wd->item_height))
1027 edje_object_size_min_restricted_calc(VIEW(it),
1028 &it->wd->item_width,
1029 &it->wd->item_height,
1031 it->wd->item_height);
1032 elm_coords_finger_size_adjust(1, &it->wd->item_width,
1033 1, &it->wd->item_height);
1036 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1038 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1040 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1044 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1045 if (elm_widget_item_disabled_get(it))
1046 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1048 evas_object_show(VIEW(it));
1050 if (it->tooltip.content_cb)
1052 elm_widget_item_tooltip_content_cb_set(it,
1053 it->tooltip.content_cb,
1054 it->tooltip.data, NULL);
1055 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1056 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
1059 if (it->mouse_cursor)
1060 elm_widget_item_cursor_set(it, it->mouse_cursor);
1062 it->realized = EINA_TRUE;
1063 it->want_unrealize = EINA_FALSE;
1067 _item_unrealize_cb(Elm_Gen_Item *it)
1069 evas_object_del(VIEW(it));
1071 evas_object_del(it->spacer);
1076 _reorder_item_moving_effect_timer_cb(void *data)
1078 Elm_Gen_Item *it = data;
1082 tt = REORDER_EFFECT_TIME;
1083 t = ((0.0 > (t = ecore_loop_time_get()-it->item->moving_effect_start_time)) ? 0.0 : t);
1084 dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
1085 dy = ((it->item->ty - it->item->oy) / 10) * _elm_config->scale;
1089 it->item->rx += (1 * sin((t / tt) * (M_PI / 2)) * dx);
1090 it->item->ry += (1 * sin((t / tt) * (M_PI / 2)) * dy);
1098 if ((((dx > 0) && (it->item->rx >= it->item->tx)) || ((dx <= 0) && (it->item->rx <= it->item->tx))) &&
1099 (((dy > 0) && (it->item->ry >= it->item->ty)) || ((dy <= 0) && (it->item->ry <= it->item->ty))))
1101 evas_object_move(VIEW(it), it->item->tx, it->item->ty);
1105 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1106 if (it->wd->horizontal)
1107 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1109 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1112 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1113 it->item->moving = EINA_FALSE;
1114 it->item->item_moving_effect_timer = NULL;
1115 return ECORE_CALLBACK_CANCEL;
1118 evas_object_move(VIEW(it), it->item->rx, it->item->ry);
1122 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1123 if (it->wd->horizontal)
1124 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1126 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1129 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1131 return ECORE_CALLBACK_RENEW;
1135 _group_item_place(Pan *sd)
1137 Evas_Coord iw, ih, vw, vh;
1139 Eina_Bool was_realized;
1141 evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1142 if (sd->wd->horizontal)
1144 iw = sd->wd->group_item_width;
1150 ih = sd->wd->group_item_height;
1152 EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1154 was_realized = it->realized;
1155 if (it->item->group_realized)
1159 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1160 evas_object_move(VIEW(it), it->item->gx, it->item->gy);
1161 evas_object_resize(VIEW(it), iw, ih);
1162 evas_object_raise(VIEW(it));
1165 _elm_genlist_item_unrealize(it, EINA_FALSE);
1171 _item_place(Elm_Gen_Item *it,
1175 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1176 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1177 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1181 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &vw, &vh);
1183 /* Preload rows/columns at each side of the Gengrid */
1184 cvx = ox - PRELOAD * it->wd->item_width;
1185 cvy = oy - PRELOAD * it->wd->item_height;
1186 cvw = vw + 2 * PRELOAD * it->wd->item_width;
1187 cvh = vh + 2 * PRELOAD * it->wd->item_height;
1192 items_count = it->wd->item_count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
1193 if (it->wd->horizontal)
1195 int columns, items_visible = 0, items_row;
1197 if (it->wd->item_height > 0)
1198 items_visible = vh / it->wd->item_height;
1199 if (items_visible < 1)
1202 columns = items_count / items_visible;
1203 if (items_count % items_visible)
1206 tcw = (it->wd->item_width * columns) + (it->wd->group_item_width * eina_list_count(it->wd->group_items));
1207 alignw = (vw - tcw) * it->wd->align_x;
1209 items_row = items_visible;
1210 if ((unsigned int)items_row > it->wd->item_count)
1211 items_row = it->wd->item_count;
1213 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1214 tch = it->wd->nmax * it->wd->item_height;
1216 tch = items_row * it->wd->item_height;
1217 alignh = (vh - tch) * it->wd->align_y;
1221 unsigned int rows, items_visible = 0, items_col;
1223 if (it->wd->item_width > 0)
1224 items_visible = vw / it->wd->item_width;
1225 if (items_visible < 1)
1228 rows = items_count / items_visible;
1229 if (items_count % items_visible)
1232 tch = (it->wd->item_height * rows) + (it->wd->group_item_height * eina_list_count(it->wd->group_items));
1233 alignh = (vh - tch) * it->wd->align_y;
1235 items_col = items_visible;
1236 if (items_col > it->wd->item_count)
1237 items_col = it->wd->item_count;
1239 && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1240 tcw = it->wd->nmax * it->wd->item_width;
1242 tcw = items_col * it->wd->item_width;
1243 alignw = (vw - tcw) * it->wd->align_x;
1248 if (it->wd->horizontal)
1250 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;
1252 iw = it->wd->group_item_width;
1258 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;
1260 ih = it->wd->group_item_height;
1267 if (it->wd->horizontal)
1269 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;
1270 y = (cy * it->wd->item_height) - it->wd->pan_y + oy + alignh;
1274 x = (cx * it->wd->item_width) - it->wd->pan_x + ox + alignw;
1275 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;
1277 if (elm_widget_mirrored_get(WIDGET(it)))
1278 { /* Switch items side and componsate for pan_x when in RTL mode */
1279 evas_object_geometry_get(WIDGET(it), NULL, NULL, &ww, NULL);
1280 x = ww - x - it->wd->item_width - it->wd->pan_x - it->wd->pan_x;
1282 iw = it->wd->item_width;
1283 ih = it->wd->item_height;
1286 Eina_Bool was_realized = it->realized;
1287 if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1291 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1294 if (it->wd->horizontal)
1296 if (it->parent->item->gx < ox)
1298 it->parent->item->gx = x + it->wd->item_width - it->wd->group_item_width;
1299 if (it->parent->item->gx > ox)
1300 it->parent->item->gx = ox;
1302 it->parent->item->group_realized = EINA_TRUE;
1306 if (it->parent->item->gy < oy)
1308 it->parent->item->gy = y + it->wd->item_height - it->wd->group_item_height;
1309 if (it->parent->item->gy > oy)
1310 it->parent->item->gy = oy;
1312 it->parent->item->group_realized = EINA_TRUE;
1315 if (it->wd->reorder_mode)
1317 if (it->wd->reorder_it)
1319 if (it->item->moving) return;
1321 if (!it->wd->move_effect_enabled)
1326 if (it->wd->reorder_it == it)
1328 evas_object_move(VIEW(it),
1329 it->wd->reorder_item_x, it->wd->reorder_item_y);
1330 evas_object_resize(VIEW(it), iw, ih);
1335 if (it->wd->move_effect_enabled)
1337 if ((it->item->ox != x) || (it->item->oy != y))
1339 if (((it->wd->old_pan_x == it->wd->pan_x) && (it->wd->old_pan_y == it->wd->pan_y)) ||
1340 ((it->wd->old_pan_x != it->wd->pan_x) && !(it->item->ox - it->wd->pan_x + it->wd->old_pan_x == x)) ||
1341 ((it->wd->old_pan_y != it->wd->pan_y) && !(it->item->oy - it->wd->pan_y + it->wd->old_pan_y == y)))
1345 it->item->rx = it->item->ox;
1346 it->item->ry = it->item->oy;
1347 it->item->moving = EINA_TRUE;
1348 it->item->moving_effect_start_time = ecore_loop_time_get();
1349 it->item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
1356 Evas_Coord nx, ny, nw, nh;
1359 if (it->wd->horizontal)
1361 nx = x + (it->wd->group_item_width / 2);
1369 ny = y + (it->wd->group_item_height / 2);
1376 nx = x + (it->wd->item_width / 2);
1377 ny = y + (it->wd->item_height / 2);
1382 if ( ELM_RECTS_INTERSECT(it->wd->reorder_item_x, it->wd->reorder_item_y,
1383 it->wd->item_width, it->wd->item_height,
1386 if (it->wd->horizontal)
1388 if ((it->wd->nmax * it->wd->reorder_it->x + it->wd->reorder_it->y) >
1389 (it->wd->nmax * it->x + it->y))
1390 reorder_item_move_forward = EINA_TRUE;
1394 if ((it->wd->nmax * it->wd->reorder_it->y + it->wd->reorder_it->x) >
1395 (it->wd->nmax * it->y + it->x))
1396 reorder_item_move_forward = EINA_TRUE;
1399 it->wd->items = eina_inlist_remove(it->wd->items,
1400 EINA_INLIST_GET(it->wd->reorder_it));
1401 if (reorder_item_move_forward)
1402 it->wd->items = eina_inlist_prepend_relative(it->wd->items,
1403 EINA_INLIST_GET(it->wd->reorder_it),
1404 EINA_INLIST_GET(it));
1406 it->wd->items = eina_inlist_append_relative(it->wd->items,
1407 EINA_INLIST_GET(it->wd->reorder_it),
1408 EINA_INLIST_GET(it));
1410 it->wd->reorder_item_changed = EINA_TRUE;
1411 it->wd->move_effect_enabled = EINA_TRUE;
1412 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1413 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1419 else if (it->item->item_moving_effect_timer)
1421 ecore_animator_del(it->item->item_moving_effect_timer);
1422 it->item->item_moving_effect_timer = NULL;
1423 it->item->moving = EINA_FALSE;
1428 evas_object_move(VIEW(it), x, y);
1429 evas_object_resize(VIEW(it), iw, ih);
1432 it->item->group_realized = EINA_TRUE;
1437 _elm_genlist_item_unrealize(it, EINA_FALSE);
1439 it->item->group_realized = EINA_FALSE;
1444 _item_del(Elm_Gen_Item *it)
1446 Evas_Object *obj = WIDGET(it);
1448 evas_event_freeze(evas_object_evas_get(obj));
1449 it->wd->selected = eina_list_remove(it->wd->selected, it);
1450 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
1451 it->wd->item_count--;
1452 _elm_genlist_item_del_serious(it);
1453 elm_gengrid_item_class_unref((Elm_Gengrid_Item_Class *)it->itc);
1454 evas_event_thaw(evas_object_evas_get(obj));
1455 evas_event_thaw_eval(evas_object_evas_get(obj));
1459 _item_unselect(Elm_Gen_Item *it)
1461 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
1462 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
1463 it->highlighted = EINA_FALSE;
1466 it->selected = EINA_FALSE;
1467 it->wd->selected = eina_list_remove(it->wd->selected, it);
1468 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
1473 _calc_job(void *data)
1475 Widget_Data *wd = data;
1476 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1477 Elm_Gen_Item *it, *group_item = NULL;
1478 int count_group = 0;
1482 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1483 if ((cvw != 0) || (cvh != 0))
1485 if ((wd->horizontal) && (wd->item_height > 0))
1486 nmax = cvh / wd->item_height;
1487 else if (wd->item_width > 0)
1488 nmax = cvw / wd->item_width;
1493 EINA_INLIST_FOREACH(wd->items, it)
1495 if (it->item->prev_group != count_group)
1496 it->item->prev_group = count_group;
1499 count = count % nmax;
1501 wd->items_lost += nmax - count;
1502 //printf("%d items and I lost %d\n", count, wd->items_lost);
1504 if (count) count = 0;
1509 if (it->parent != group_item)
1510 it->parent = group_item;
1514 count = wd->item_count + wd->items_lost - count_group;
1517 minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width);
1518 minh = nmax * wd->item_height;
1522 minw = nmax * wd->item_width;
1523 minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1526 if ((minw != wd->minw) || (minh != wd->minh))
1530 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1534 evas_object_smart_changed(wd->pan_smart);
1536 wd->calc_job = NULL;
1540 _pan_add(Evas_Object *obj)
1543 Evas_Object_Smart_Clipped_Data *cd;
1546 cd = evas_object_smart_data_get(obj);
1549 sd->__clipped_data = *cd;
1551 evas_object_smart_data_set(obj, sd);
1555 _pan_del(Evas_Object *obj)
1557 Pan *sd = evas_object_smart_data_get(obj);
1564 _pan_set(Evas_Object *obj,
1568 Pan *sd = evas_object_smart_data_get(obj);
1569 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1572 evas_object_smart_changed(obj);
1576 _pan_get(Evas_Object *obj,
1580 Pan *sd = evas_object_smart_data_get(obj);
1581 if (x) *x = sd->wd->pan_x;
1582 if (y) *y = sd->wd->pan_y;
1586 _pan_child_size_get(Evas_Object *obj,
1590 Pan *sd = evas_object_smart_data_get(obj);
1591 if (w) *w = sd->wd->minw;
1592 if (h) *h = sd->wd->minh;
1596 _pan_max_get(Evas_Object *obj,
1600 Pan *sd = evas_object_smart_data_get(obj);
1604 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1606 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1608 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1612 _pan_min_get(Evas_Object *obj,
1616 Pan *sd = evas_object_smart_data_get(obj);
1617 Evas_Coord mx = 0, my = 0;
1620 _pan_max_get(obj, &mx, &my);
1622 *x = -mx * sd->wd->align_x;
1624 *y = -my * sd->wd->align_y;
1628 _pan_resize(Evas_Object *obj,
1632 Pan *sd = evas_object_smart_data_get(obj);
1635 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1636 if ((ow == w) && (oh == h)) return;
1637 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1638 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1642 _pan_calculate(Evas_Object *obj)
1644 Pan *sd = evas_object_smart_data_get(obj);
1645 Evas_Coord cx = 0, cy = 0;
1649 if (!sd->wd->nmax) return;
1651 sd->wd->reorder_item_changed = EINA_FALSE;
1653 EINA_INLIST_FOREACH(sd->wd->items, it)
1657 if (sd->wd->horizontal)
1674 _item_place(it, cx, cy);
1675 if (sd->wd->reorder_item_changed) return;
1678 if (sd->wd->horizontal)
1691 if (sd->wd->horizontal)
1693 cy = (cy + 1) % sd->wd->nmax;
1698 cx = (cx + 1) % sd->wd->nmax;
1703 _group_item_place(sd);
1706 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
1708 if (!sd->wd->reorder_item_changed)
1710 sd->wd->old_pan_x = sd->wd->pan_x;
1711 sd->wd->old_pan_y = sd->wd->pan_y;
1713 sd->wd->move_effect_enabled = EINA_FALSE;
1715 evas_object_smart_callback_call(sd->wd->obj, SIG_CHANGED, NULL);
1719 _pan_move(Evas_Object *obj,
1720 Evas_Coord x __UNUSED__,
1721 Evas_Coord y __UNUSED__)
1723 Pan *sd = evas_object_smart_data_get(obj);
1725 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1726 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1730 _hold_on(void *data __UNUSED__,
1732 void *event_info __UNUSED__)
1734 Widget_Data *wd = elm_widget_data_get(obj);
1736 elm_smart_scroller_hold_set(wd->scr, 1);
1740 _hold_off(void *data __UNUSED__,
1742 void *event_info __UNUSED__)
1744 Widget_Data *wd = elm_widget_data_get(obj);
1746 elm_smart_scroller_hold_set(wd->scr, 0);
1750 _freeze_on(void *data __UNUSED__,
1752 void *event_info __UNUSED__)
1754 Widget_Data *wd = elm_widget_data_get(obj);
1756 elm_smart_scroller_freeze_set(wd->scr, 1);
1760 _freeze_off(void *data __UNUSED__,
1762 void *event_info __UNUSED__)
1764 Widget_Data *wd = elm_widget_data_get(obj);
1766 elm_smart_scroller_freeze_set(wd->scr, 0);
1770 _scr_anim_start(void *data,
1771 Evas_Object *obj __UNUSED__,
1772 void *event_info __UNUSED__)
1774 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1778 _scr_anim_stop(void *data,
1779 Evas_Object *obj __UNUSED__,
1780 void *event_info __UNUSED__)
1782 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1786 _scr_drag_start(void *data,
1787 Evas_Object *obj __UNUSED__,
1788 void *event_info __UNUSED__)
1790 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1794 _scr_drag_stop(void *data,
1795 Evas_Object *obj __UNUSED__,
1796 void *event_info __UNUSED__)
1798 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1802 _edge_left(void *data,
1803 Evas_Object *scr __UNUSED__,
1804 void *event_info __UNUSED__)
1806 evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
1810 _edge_right(void *data,
1811 Evas_Object *scr __UNUSED__,
1812 void *event_info __UNUSED__)
1814 evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
1818 _edge_top(void *data,
1819 Evas_Object *scr __UNUSED__,
1820 void *event_info __UNUSED__)
1822 evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
1826 _edge_bottom(void *data,
1827 Evas_Object *scr __UNUSED__,
1828 void *event_info __UNUSED__)
1830 evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
1834 _scr_scroll(void *data,
1835 Evas_Object *obj __UNUSED__,
1836 void *event_info __UNUSED__)
1838 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1842 _elm_gengrid_item_compare(const void *data, const void *data1)
1844 Elm_Gen_Item *it, *item1;
1845 it = ELM_GEN_ITEM_FROM_INLIST(data);
1846 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
1847 return it->wd->item_compare_cb(it, item1);
1851 _item_disable_hook(Elm_Object_Item *it)
1853 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
1855 if (_it->generation < _it->wd->generation) return;
1859 if (elm_widget_item_disabled_get(_it))
1860 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
1862 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
1867 _item_del_pre_hook(Elm_Object_Item *it)
1869 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
1870 if ((_it->relcount > 0) || (_it->walking > 0))
1872 _elm_genlist_item_del_notserious(_it);
1879 static Elm_Gen_Item *
1880 _item_new(Widget_Data *wd,
1881 const Elm_Gengrid_Item_Class *itc,
1884 const void *func_data)
1888 it = _elm_genlist_item_new(wd, itc, data, NULL, func, func_data);
1889 if (!it) return NULL;
1890 elm_widget_item_disable_hook_set(it, _item_disable_hook);
1891 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
1892 elm_gengrid_item_class_ref((Elm_Gengrid_Item_Class *)itc);
1893 it->item = ELM_NEW(Elm_Gen_Item_Type);
1895 it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
1896 ELM_GEN_ITEM_SETUP(it);
1902 elm_gengrid_add(Evas_Object *parent)
1907 static Evas_Smart *smart = NULL;
1908 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1912 static Evas_Smart_Class sc;
1914 evas_object_smart_clipped_smart_set(&_pan_sc);
1916 sc.name = "elm_gengrid_pan";
1917 sc.version = EVAS_SMART_CLASS_VERSION;
1920 sc.resize = _pan_resize;
1921 sc.move = _pan_move;
1922 sc.calculate = _pan_calculate;
1923 if (!(smart = evas_smart_class_new(&sc))) return NULL;
1926 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1928 ELM_SET_WIDTYPE(widtype, "gengrid");
1930 elm_widget_type_set(obj, "gengrid");
1931 elm_widget_sub_object_add(parent, obj);
1932 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1933 elm_widget_data_set(obj, wd);
1934 elm_widget_del_hook_set(obj, _del_hook);
1935 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1936 elm_widget_theme_hook_set(obj, _theme_hook);
1937 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1938 elm_widget_can_focus_set(obj, EINA_TRUE);
1939 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1940 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1941 elm_widget_event_hook_set(obj, _event_hook);
1944 wd->scr = elm_smart_scroller_add(e);
1945 elm_smart_scroller_widget_set(wd->scr, obj);
1946 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1948 elm_smart_scroller_bounce_allow_set(wd->scr, bounce,
1949 _elm_config->thumbscroll_bounce_enable);
1950 elm_widget_resize_object_set(obj, wd->scr);
1952 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1953 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1954 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1955 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1956 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1957 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1958 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1959 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom,
1961 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1966 wd->h_bounce = bounce;
1967 wd->v_bounce = bounce;
1969 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1970 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1971 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1972 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1974 wd->pan_smart = evas_object_smart_add(e, smart);
1975 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1978 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1979 _pan_set, _pan_get, _pan_max_get,
1980 _pan_min_get, _pan_child_size_get);
1982 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1984 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1989 elm_gengrid_item_size_set(Evas_Object *obj,
1993 ELM_CHECK_WIDTYPE(obj, widtype);
1994 Widget_Data *wd = elm_widget_data_get(obj);
1996 if ((wd->item_width == w) && (wd->item_height == h)) return;
1998 wd->item_height = h;
1999 if (wd->calc_job) ecore_job_del(wd->calc_job);
2000 wd->calc_job = ecore_job_add(_calc_job, wd);
2004 elm_gengrid_item_size_get(const Evas_Object *obj,
2008 ELM_CHECK_WIDTYPE(obj, widtype);
2009 Widget_Data *wd = elm_widget_data_get(obj);
2011 if (w) *w = wd->item_width;
2012 if (h) *h = wd->item_height;
2016 elm_gengrid_group_item_size_set(Evas_Object *obj,
2020 ELM_CHECK_WIDTYPE(obj, widtype);
2021 Widget_Data *wd = elm_widget_data_get(obj);
2023 if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
2024 wd->group_item_width = w;
2025 wd->group_item_height = h;
2026 if (wd->calc_job) ecore_job_del(wd->calc_job);
2027 wd->calc_job = ecore_job_add(_calc_job, wd);
2031 elm_gengrid_group_item_size_get(const Evas_Object *obj,
2035 ELM_CHECK_WIDTYPE(obj, widtype);
2036 Widget_Data *wd = elm_widget_data_get(obj);
2038 if (w) *w = wd->group_item_width;
2039 if (h) *h = wd->group_item_height;
2043 elm_gengrid_align_set(Evas_Object *obj,
2047 ELM_CHECK_WIDTYPE(obj, widtype);
2049 Widget_Data *wd = elm_widget_data_get(obj);
2050 double old_h = wd->align_x, old_y = wd->align_y;
2054 else if (align_x < 0.0)
2056 wd->align_x = align_x;
2060 else if (align_y < 0.0)
2062 wd->align_y = align_y;
2064 if ((old_h != wd->align_x) || (old_y != wd->align_y))
2065 evas_object_smart_calculate(wd->pan_smart);
2069 elm_gengrid_align_get(const Evas_Object *obj,
2073 ELM_CHECK_WIDTYPE(obj, widtype);
2074 Widget_Data *wd = elm_widget_data_get(obj);
2075 if (align_x) *align_x = wd->align_x;
2076 if (align_y) *align_y = wd->align_y;
2079 EAPI Elm_Object_Item *
2080 elm_gengrid_item_append(Evas_Object *obj,
2081 const Elm_Gengrid_Item_Class *itc,
2084 const void *func_data)
2087 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2088 Widget_Data *wd = elm_widget_data_get(obj);
2089 if (!wd) return NULL;
2091 it = _item_new(wd, itc, data, func, func_data);
2092 if (!it) return NULL;
2093 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2096 wd->group_items = eina_list_prepend(wd->group_items, it);
2098 if (wd->calc_job) ecore_job_del(wd->calc_job);
2099 wd->calc_job = ecore_job_add(_calc_job, wd);
2101 return (Elm_Object_Item *)it;
2104 EAPI Elm_Object_Item *
2105 elm_gengrid_item_prepend(Evas_Object *obj,
2106 const Elm_Gengrid_Item_Class *itc,
2109 const void *func_data)
2112 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2113 Widget_Data *wd = elm_widget_data_get(obj);
2114 if (!wd) return NULL;
2116 it = _item_new(wd, itc, data, func, func_data);
2117 if (!it) return NULL;
2118 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2120 wd->group_items = eina_list_append(wd->group_items, it);
2122 if (wd->calc_job) ecore_job_del(wd->calc_job);
2123 wd->calc_job = ecore_job_add(_calc_job, wd);
2125 return (Elm_Object_Item *)it;
2128 EAPI Elm_Object_Item *
2129 elm_gengrid_item_insert_before(Evas_Object *obj,
2130 const Elm_Gengrid_Item_Class *itc,
2132 Elm_Object_Item *relative,
2134 const void *func_data)
2137 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2138 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2139 Widget_Data *wd = elm_widget_data_get(obj);
2140 if (!wd) return NULL;
2142 it = _item_new(wd, itc, data, func, func_data);
2143 if (!it) return NULL;
2144 wd->items = eina_inlist_prepend_relative
2145 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2147 wd->group_items = eina_list_append_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2149 if (wd->calc_job) ecore_job_del(wd->calc_job);
2150 wd->calc_job = ecore_job_add(_calc_job, wd);
2152 return (Elm_Object_Item *)it;
2155 EAPI Elm_Object_Item *
2156 elm_gengrid_item_insert_after(Evas_Object *obj,
2157 const Elm_Gengrid_Item_Class *itc,
2159 Elm_Object_Item *relative,
2161 const void *func_data)
2164 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2165 ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2166 Widget_Data *wd = elm_widget_data_get(obj);
2167 if (!wd) return NULL;
2169 it = _item_new(wd, itc, data, func, func_data);
2170 if (!it) return NULL;
2171 wd->items = eina_inlist_append_relative
2172 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2174 wd->group_items = eina_list_prepend_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2176 if (wd->calc_job) ecore_job_del(wd->calc_job);
2177 wd->calc_job = ecore_job_add(_calc_job, wd);
2179 return (Elm_Object_Item *)it;
2182 EAPI Elm_Object_Item *
2183 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2184 const Elm_Gengrid_Item_Class *itc,
2186 Eina_Compare_Cb comp,
2188 const void *func_data)
2191 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2192 Widget_Data *wd = elm_widget_data_get(obj);
2193 if (!wd) return NULL;
2195 it = _item_new(wd, itc, data, func, func_data);
2196 if (!it) return NULL;
2199 wd->state = eina_inlist_sorted_state_new();
2201 wd->item_compare_cb = comp;
2202 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
2203 _elm_gengrid_item_compare, wd->state);
2204 if (wd->calc_job) ecore_job_del(wd->calc_job);
2205 wd->calc_job = ecore_job_add(_calc_job, wd);
2207 return (Elm_Object_Item *)it;
2210 EINA_DEPRECATED Elm_Object_Item *
2211 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
2212 const Elm_Gengrid_Item_Class *itc,
2214 Eina_Compare_Cb comp,
2216 const void *func_data)
2218 return elm_gengrid_item_sorted_insert(obj, itc, data, comp, func, func_data);
2222 elm_gengrid_item_del(Elm_Object_Item *it)
2224 elm_object_item_del(it);
2228 elm_gengrid_horizontal_set(Evas_Object *obj,
2229 Eina_Bool horizontal)
2231 ELM_CHECK_WIDTYPE(obj, widtype);
2232 Widget_Data *wd = elm_widget_data_get(obj);
2234 horizontal = !!horizontal;
2235 if (horizontal == wd->horizontal) return;
2236 wd->horizontal = horizontal;
2238 /* Update the items to conform to the new layout */
2239 if (wd->calc_job) ecore_job_del(wd->calc_job);
2240 wd->calc_job = ecore_job_add(_calc_job, wd);
2244 elm_gengrid_horizontal_get(const Evas_Object *obj)
2246 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2247 Widget_Data *wd = elm_widget_data_get(obj);
2248 if (!wd) return EINA_FALSE;
2249 return wd->horizontal;
2253 elm_gengrid_clear(Evas_Object *obj)
2255 elm_genlist_clear(obj);
2258 EINA_DEPRECATED EAPI const Evas_Object *
2259 elm_gengrid_item_object_get(const Elm_Object_Item *it)
2261 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2266 elm_gengrid_item_update(Elm_Object_Item *it)
2268 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2269 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2270 if (!_it->realized) return;
2271 if (_it->want_unrealize) return;
2272 _elm_genlist_item_unrealize(_it, EINA_FALSE);
2274 _item_place(_it, _it->x, _it->y);
2278 elm_gengrid_item_data_get(const Elm_Object_Item *it)
2280 return elm_object_item_data_get(it);
2284 elm_gengrid_item_data_set(Elm_Object_Item *it,
2287 elm_object_item_data_set(it, (void *) data);
2290 EAPI const Elm_Gengrid_Item_Class *
2291 elm_gengrid_item_item_class_get(const Elm_Object_Item *it)
2293 return (Elm_Gengrid_Item_Class *) elm_genlist_item_item_class_get(it);
2296 EINA_DEPRECATED EAPI void
2297 elm_gengrid_item_item_class_set(Elm_Object_Item *it,
2298 const Elm_Gengrid_Item_Class *itc)
2300 elm_gengrid_item_item_class_update(it, itc);
2304 elm_gengrid_item_item_class_update(Elm_Object_Item *it,
2305 const Elm_Gengrid_Item_Class *itc)
2307 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2308 EINA_SAFETY_ON_NULL_RETURN(itc);
2309 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2310 if (_it->generation < _it->wd->generation) return;
2312 elm_gengrid_item_update(it);
2316 elm_gengrid_item_pos_get(const Elm_Object_Item *it,
2320 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2321 if (x) *x = ((Elm_Gen_Item *)it)->x;
2322 if (y) *y = ((Elm_Gen_Item *)it)->y;
2326 elm_gengrid_multi_select_set(Evas_Object *obj,
2329 ELM_CHECK_WIDTYPE(obj, widtype);
2330 Widget_Data *wd = elm_widget_data_get(obj);
2332 wd->multi = !!multi;
2336 elm_gengrid_multi_select_get(const Evas_Object *obj)
2338 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2339 Widget_Data *wd = elm_widget_data_get(obj);
2340 if (!wd) return EINA_FALSE;
2344 EAPI Elm_Object_Item *
2345 elm_gengrid_selected_item_get(const Evas_Object *obj)
2347 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2348 Widget_Data *wd = elm_widget_data_get(obj);
2349 if (!wd) return NULL;
2350 if (wd->selected) return wd->selected->data;
2354 EAPI const Eina_List *
2355 elm_gengrid_selected_items_get(const Evas_Object *obj)
2357 return elm_genlist_selected_items_get(obj);
2361 elm_gengrid_item_selected_set(Elm_Object_Item *it,
2364 elm_genlist_item_selected_set(it, selected);
2368 elm_gengrid_item_selected_get(const Elm_Object_Item *it)
2370 return elm_genlist_item_selected_get(it);
2374 elm_gengrid_item_disabled_set(Elm_Object_Item *it,
2377 elm_object_item_disabled_set(it, disabled);
2381 elm_gengrid_item_disabled_get(const Elm_Object_Item *it)
2383 return elm_object_item_disabled_get(it);
2386 static Evas_Object *
2387 _elm_gengrid_item_label_create(void *data,
2388 Evas_Object *obj __UNUSED__,
2389 Evas_Object *tooltip,
2390 void *it __UNUSED__)
2392 Evas_Object *label = elm_label_add(tooltip);
2395 elm_object_style_set(label, "tooltip");
2396 elm_object_text_set(label, data);
2401 _elm_gengrid_item_label_del_cb(void *data,
2402 Evas_Object *obj __UNUSED__,
2403 void *event_info __UNUSED__)
2405 eina_stringshare_del(data);
2409 elm_gengrid_item_tooltip_text_set(Elm_Object_Item *it,
2412 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2413 text = eina_stringshare_add(text);
2414 elm_gengrid_item_tooltip_content_cb_set(it, _elm_gengrid_item_label_create,
2416 _elm_gengrid_item_label_del_cb);
2420 elm_gengrid_item_tooltip_content_cb_set(Elm_Object_Item *it,
2421 Elm_Tooltip_Item_Content_Cb func,
2423 Evas_Smart_Cb del_cb)
2425 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
2426 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2428 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
2431 if (_it->tooltip.del_cb)
2432 _it->tooltip.del_cb((void *)_it->tooltip.data, WIDGET(_it), _it);
2433 _it->tooltip.content_cb = func;
2434 _it->tooltip.data = data;
2435 _it->tooltip.del_cb = del_cb;
2438 elm_widget_item_tooltip_content_cb_set(_it,
2439 _it->tooltip.content_cb,
2440 _it->tooltip.data, NULL);
2441 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
2442 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
2448 if (del_cb) del_cb((void *)data, NULL, NULL);
2452 elm_gengrid_item_tooltip_unset(Elm_Object_Item *it)
2454 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2455 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2457 if ((VIEW(_it)) && (_it->tooltip.content_cb))
2458 elm_widget_item_tooltip_unset(_it);
2460 if (_it->tooltip.del_cb)
2461 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
2462 _it->tooltip.del_cb = NULL;
2463 _it->tooltip.content_cb = NULL;
2464 _it->tooltip.data = NULL;
2465 _it->tooltip.free_size = EINA_FALSE;
2466 if (_it->tooltip.style)
2467 elm_gengrid_item_tooltip_style_set(it, NULL);
2471 elm_gengrid_item_tooltip_style_set(Elm_Object_Item *it,
2474 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2475 eina_stringshare_replace(&((Elm_Gen_Item *)it)->tooltip.style, style);
2476 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
2480 elm_gengrid_item_tooltip_style_get(const Elm_Object_Item *it)
2482 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2483 return ((Elm_Gen_Item *)it)->tooltip.style;
2487 elm_gengrid_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
2489 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2490 ((Elm_Gen_Item *)it)->tooltip.free_size = disable;
2491 if (VIEW(it)) return elm_widget_item_tooltip_window_mode_set(it, disable);
2496 elm_gengrid_item_tooltip_window_mode_get(const Elm_Object_Item *it)
2498 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2499 return ((Elm_Gen_Item *)it)->tooltip.free_size;
2503 elm_gengrid_item_cursor_set(Elm_Object_Item *it,
2506 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2507 eina_stringshare_replace(&((Elm_Gen_Item *)it)->mouse_cursor, cursor);
2508 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
2512 elm_gengrid_item_cursor_get(const Elm_Object_Item *it)
2514 return elm_widget_item_cursor_get(it);
2518 elm_gengrid_item_cursor_unset(Elm_Object_Item *it)
2520 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2521 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2522 if (!_it->mouse_cursor)
2526 elm_widget_item_cursor_unset(_it);
2528 eina_stringshare_del(_it->mouse_cursor);
2529 _it->mouse_cursor = NULL;
2533 elm_gengrid_item_cursor_style_set(Elm_Object_Item *it,
2536 elm_widget_item_cursor_style_set(it, style);
2540 elm_gengrid_item_cursor_style_get(const Elm_Object_Item *it)
2542 return elm_widget_item_cursor_style_get(it);
2546 elm_gengrid_item_cursor_engine_only_set(Elm_Object_Item *it,
2547 Eina_Bool engine_only)
2549 elm_widget_item_cursor_engine_only_set(it, engine_only);
2553 elm_gengrid_item_cursor_engine_only_get(const Elm_Object_Item *it)
2555 return elm_widget_item_cursor_engine_only_get(it);
2559 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2560 Eina_Bool reorder_mode)
2562 ELM_CHECK_WIDTYPE(obj, widtype);
2563 Widget_Data *wd = elm_widget_data_get(obj);
2565 wd->reorder_mode = !!reorder_mode;
2569 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2571 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2572 Widget_Data *wd = elm_widget_data_get(obj);
2573 if (!wd) return EINA_FALSE;
2574 return wd->reorder_mode;
2577 EINA_DEPRECATED EAPI void
2578 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2579 Eina_Bool always_select)
2582 elm_genlist_select_mode_set(obj, ELM_OBJECT_ALWAYS_SELECT);
2585 Elm_Object_Select_Mode_Type oldmode = elm_genlist_select_mode_get(obj);
2586 if (oldmode == ELM_OBJECT_ALWAYS_SELECT)
2587 elm_genlist_select_mode_set(obj, ELM_OBJECT_NORMAL_SELECT);
2591 EINA_DEPRECATED EAPI Eina_Bool
2592 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2594 Elm_Object_Select_Mode_Type oldmode = elm_genlist_select_mode_get(obj);
2595 if (oldmode == ELM_OBJECT_ALWAYS_SELECT)
2601 EINA_DEPRECATED EAPI void
2602 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2603 Eina_Bool no_select)
2606 elm_genlist_select_mode_set(obj, ELM_OBJECT_NO_SELECT);
2609 Elm_Object_Select_Mode_Type oldmode = elm_genlist_select_mode_get(obj);
2610 if (oldmode == ELM_OBJECT_NO_SELECT)
2611 elm_genlist_select_mode_set(obj, ELM_OBJECT_NORMAL_SELECT);
2615 EINA_DEPRECATED EAPI Eina_Bool
2616 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2618 Elm_Object_Select_Mode_Type oldmode = elm_genlist_select_mode_get(obj);
2619 if (oldmode == ELM_OBJECT_NO_SELECT)
2626 elm_gengrid_bounce_set(Evas_Object *obj,
2630 elm_genlist_bounce_set(obj, h_bounce, v_bounce);
2634 elm_gengrid_bounce_get(const Evas_Object *obj,
2635 Eina_Bool *h_bounce,
2636 Eina_Bool *v_bounce)
2638 elm_genlist_bounce_get(obj, h_bounce, v_bounce);
2642 elm_gengrid_page_relative_set(Evas_Object *obj,
2646 _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
2650 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2652 _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
2656 elm_gengrid_page_size_set(Evas_Object *obj,
2657 Evas_Coord h_pagesize,
2658 Evas_Coord v_pagesize)
2660 _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
2664 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2666 _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
2670 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2672 _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
2676 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2678 _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
2682 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2684 _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
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_gengrid_get(const Elm_Object_Item *it)
2714 return elm_object_item_widget_get(it);
2718 elm_gengrid_item_show(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
2720 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2721 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2722 Widget_Data *wd = _it->wd;
2723 Evas_Coord minx = 0, miny = 0;
2725 if ((_it->generation < _it->wd->generation)) return;
2726 _pan_min_get(wd->pan_smart, &minx, &miny);
2728 if (type==ELM_GENGRID_ITEM_SCROLLTO_IN)
2730 //TODO : type based handling like genlist
2734 elm_smart_scroller_region_bring_in(_it->wd->scr,
2735 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2736 _it->y * wd->item_height + miny,
2737 _it->wd->item_width,
2738 _it->wd->item_height);
2740 elm_smart_scroller_region_bring_in(_it->wd->scr,
2741 _it->x * wd->item_width + minx,
2742 ((_it->y - _it->item->prev_group) * wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2743 _it->wd->item_width,
2744 _it->wd->item_height);
2748 elm_gengrid_item_bring_in(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
2750 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2751 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2753 if (_it->generation < _it->wd->generation) return;
2755 Evas_Coord minx = 0, miny = 0;
2756 Widget_Data *wd = _it->wd;
2757 _pan_min_get(wd->pan_smart, &minx, &miny);
2759 if (type==ELM_GENGRID_ITEM_SCROLLTO_IN)
2761 //TODO : type based handling like genlist
2765 elm_smart_scroller_region_bring_in(_it->wd->scr,
2766 ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
2767 _it->y * wd->item_height + miny,
2768 _it->wd->item_width,
2769 _it->wd->item_height);
2771 elm_smart_scroller_region_bring_in(_it->wd->scr,
2772 _it->x * wd->item_width + minx,
2773 ((_it->y - _it->item->prev_group)* wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
2774 _it->wd->item_width,
2775 _it->wd->item_height);
2779 elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill)
2781 ELM_CHECK_WIDTYPE(obj, widtype);
2782 Widget_Data *wd = elm_widget_data_get(obj);
2785 if (wd->filled != fill)
2790 elm_gengrid_filled_get(const Evas_Object *obj)
2792 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2793 Widget_Data *wd = elm_widget_data_get(obj);
2794 if (!wd) return EINA_FALSE;
2798 EAPI Elm_Gengrid_Item_Class *
2799 elm_gengrid_item_class_new(void)
2801 Elm_Gengrid_Item_Class *itc;
2803 itc = calloc(1, sizeof(Elm_Gengrid_Item_Class));
2806 itc->version = CLASS_ALLOCATED;
2808 itc->delete_me = EINA_FALSE;
2814 elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
2816 if (itc && (itc->version == CLASS_ALLOCATED))
2818 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
2819 if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
2829 elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
2831 if (itc && (itc->version == CLASS_ALLOCATED))
2834 if (itc->refcount == 0) itc->refcount--;
2839 elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
2841 if (itc && (itc->version == CLASS_ALLOCATED))
2843 if (itc->refcount > 0) itc->refcount--;
2844 if (itc->delete_me && (!itc->refcount))
2845 elm_gengrid_item_class_free(itc);
2850 elm_gengrid_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode_Type mode)
2852 elm_genlist_select_mode_set(obj, mode);
2855 EAPI Elm_Object_Select_Mode_Type
2856 elm_gengrid_select_mode_get(const Evas_Object *obj)
2858 return elm_genlist_select_mode_get(obj);