1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 #include "els_scroller.h"
9 * Handle non-homogeneous objects too.
13 #define REORDER_EFFECT_TIME 0.5
15 #define ELM_GEN_SETUP(wd) \
16 (wd)->calc_cb = (Ecore_Cb)_calc_job
18 #define ELM_GEN_ITEM_SETUP(it) \
19 (it)->del_cb = (Ecore_Cb)_item_del; \
20 (it)->highlight_cb = (Ecore_Cb)_item_highlight; \
21 (it)->unsel_cb = (Ecore_Cb)_item_unselect; \
22 (it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
24 struct Elm_Gen_Item_Type
27 Ecore_Animator *item_moving_effect_timer;
28 Evas_Coord gx, gy, ox, oy, tx, ty, rx, ry;
29 unsigned int moving_effect_start_time;
32 Eina_Bool group_realized : 1;
39 Eina_Inlist_Sorted_State *state;
40 Evas_Object *obj; /* the gengrid object */
41 Evas_Object *scr; /* a smart scroller object which is used internally in genlist */
42 Evas_Object *pan_smart; /* "elm_genlist_pan" evas smart object. this is an extern pan of smart scroller(scr). */
44 Eina_List *group_items; /* list of groups index items */
45 Eina_Inlist *items; /* inlist of all items */
46 Elm_Gen_Item *reorder_it; /* item currently being repositioned */
47 Elm_Gen_Item *last_selected_item;
48 Pan *pan; /* pan_smart object's smart data */
51 int item_width, item_height;
52 int group_item_width, group_item_height;
55 Evas_Coord pan_x, pan_y;
56 Eina_Bool reorder_mode : 1;
57 Eina_Bool on_hold : 1;
59 Eina_Bool no_select : 1;
60 Eina_Bool wasselected : 1;
61 Eina_Bool always_select : 1;
62 Eina_Bool clear_me : 1;
63 Eina_Bool h_bounce : 1;
64 Eina_Bool v_bounce : 1;
65 Ecore_Cb del_cb, calc_cb, sizing_cb;
67 ////////////////////////////////////
68 double align_x, align_y;
70 Evas_Coord old_pan_x, old_pan_y;
71 Evas_Coord reorder_item_x, reorder_item_y;
77 Eina_Bool horizontal : 1;
78 Eina_Bool longpressed : 1;
79 Eina_Bool reorder_item_changed : 1;
80 Eina_Bool move_effect_enabled : 1;
84 static const char *widtype = NULL;
85 static void _item_highlight(Elm_Gen_Item *it);
86 static void _item_unrealize_cb(Elm_Gen_Item *it);
87 static void _item_unselect(Elm_Gen_Item *it);
88 static void _calc_job(void *data);
89 static void _on_focus_hook(void *data,
91 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
92 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
93 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
94 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
95 static Eina_Bool _item_single_select_up(Widget_Data *wd);
96 static Eina_Bool _item_single_select_down(Widget_Data *wd);
97 static Eina_Bool _item_single_select_left(Widget_Data *wd);
98 static Eina_Bool _item_single_select_right(Widget_Data *wd);
99 static Eina_Bool _event_hook(Evas_Object *obj,
101 Evas_Callback_Type type,
103 static Eina_Bool _deselect_all_items(Widget_Data *wd);
105 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
106 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
108 static const char SIG_ACTIVATED[] = "activated";
109 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
110 static const char SIG_LONGPRESSED[] = "longpressed";
111 static const char SIG_SELECTED[] = "selected";
112 static const char SIG_UNSELECTED[] = "unselected";
113 static const char SIG_REALIZED[] = "realized";
114 static const char SIG_UNREALIZED[] = "unrealized";
115 static const char SIG_CHANGED[] = "changed";
116 static const char SIG_DRAG_START_UP[] = "drag,start,up";
117 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
118 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
119 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
120 static const char SIG_DRAG_STOP[] = "drag,stop";
121 static const char SIG_DRAG[] = "drag";
122 static const char SIG_SCROLL[] = "scroll";
123 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
124 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
125 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
126 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
127 static const char SIG_EDGE_TOP[] = "edge,top";
128 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
129 static const char SIG_EDGE_LEFT[] = "edge,left";
130 static const char SIG_EDGE_RIGHT[] = "edge,right";
131 static const char SIG_MOVED[] = "moved";
133 static const Evas_Smart_Cb_Description _signals[] = {
135 {SIG_CLICKED_DOUBLE, ""},
136 {SIG_LONGPRESSED, ""},
138 {SIG_UNSELECTED, ""},
140 {SIG_UNREALIZED, ""},
142 {SIG_DRAG_START_UP, ""},
143 {SIG_DRAG_START_DOWN, ""},
144 {SIG_DRAG_START_LEFT, ""},
145 {SIG_DRAG_START_RIGHT, ""},
149 {SIG_SCROLL_ANIM_START, ""},
150 {SIG_SCROLL_ANIM_STOP, ""},
151 {SIG_SCROLL_DRAG_START, ""},
152 {SIG_SCROLL_DRAG_STOP, ""},
154 {SIG_EDGE_BOTTOM, ""},
156 {SIG_EDGE_RIGHT, ""},
161 static Eina_Compare_Cb _elm_gengrid_item_compare_cb;
162 static Eina_Compare_Cb _elm_gengrid_item_compare_data_cb;
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_Gen_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 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
284 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
286 it = elm_gengrid_last_item_get(obj);
287 elm_gengrid_item_bring_in(it);
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")))
335 it = elm_gengrid_selected_item_get(obj);
336 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
338 else return EINA_FALSE;
340 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
341 elm_smart_scroller_child_pos_set(wd->scr, x, y);
346 _deselect_all_items(Widget_Data *wd)
348 if (!wd->selected) return EINA_FALSE;
350 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
356 _item_multi_select_left(Widget_Data *wd)
358 if (!wd->selected) return EINA_FALSE;
360 Elm_Gen_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
361 if (!prev) return EINA_TRUE;
362 if (elm_gengrid_item_selected_get(prev))
364 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
365 wd->last_selected_item = prev;
366 elm_gengrid_item_show(wd->last_selected_item);
370 elm_gengrid_item_selected_set(prev, EINA_TRUE);
371 elm_gengrid_item_show(prev);
378 _item_multi_select_right(Widget_Data *wd)
380 if (!wd->selected) return EINA_FALSE;
382 Elm_Gen_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
383 if (!next) return EINA_TRUE;
384 if (elm_gengrid_item_selected_get(next))
386 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
387 wd->last_selected_item = next;
388 elm_gengrid_item_show(wd->last_selected_item);
392 elm_gengrid_item_selected_set(next, EINA_TRUE);
393 elm_gengrid_item_show(next);
400 _item_multi_select_up(Widget_Data *wd)
403 Eina_Bool r = EINA_TRUE;
405 if (!wd->selected) return EINA_FALSE;
407 for (i = 0; (r) && (i < wd->nmax); i++)
408 r &= _item_multi_select_left(wd);
414 _item_multi_select_down(Widget_Data *wd)
417 Eina_Bool r = EINA_TRUE;
419 if (!wd->selected) return EINA_FALSE;
421 for (i = 0; (r) && (i < wd->nmax); i++)
422 r &= _item_multi_select_right(wd);
428 _item_single_select_up(Widget_Data *wd)
436 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
437 while ((prev) && (prev->generation < wd->generation))
438 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
439 elm_gengrid_item_selected_set(prev, EINA_TRUE);
440 elm_gengrid_item_show(prev);
443 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
445 if (!prev) return EINA_FALSE;
447 for (i = 1; i < wd->nmax; i++)
449 Elm_Gen_Item *tmp = elm_gengrid_item_prev_get(prev);
450 if (!tmp) return EINA_FALSE;
454 _deselect_all_items(wd);
456 elm_gengrid_item_selected_set(prev, EINA_TRUE);
457 elm_gengrid_item_show(prev);
462 _item_single_select_down(Widget_Data *wd)
470 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
471 while ((next) && (next->generation < wd->generation))
472 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
473 elm_gengrid_item_selected_set(next, EINA_TRUE);
474 elm_gengrid_item_show(next);
477 else next = elm_gengrid_item_next_get(wd->last_selected_item);
479 if (!next) return EINA_FALSE;
481 for (i = 1; i < wd->nmax; i++)
483 Elm_Gen_Item *tmp = elm_gengrid_item_next_get(next);
484 if (!tmp) return EINA_FALSE;
488 _deselect_all_items(wd);
490 elm_gengrid_item_selected_set(next, EINA_TRUE);
491 elm_gengrid_item_show(next);
496 _item_single_select_left(Widget_Data *wd)
501 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
502 while ((prev) && (prev->generation < wd->generation))
503 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
505 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
507 if (!prev) return EINA_FALSE;
509 _deselect_all_items(wd);
511 elm_gengrid_item_selected_set(prev, EINA_TRUE);
512 elm_gengrid_item_show(prev);
517 _item_single_select_right(Widget_Data *wd)
522 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
523 while ((next) && (next->generation < wd->generation))
524 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
526 else next = elm_gengrid_item_next_get(wd->last_selected_item);
528 if (!next) return EINA_FALSE;
530 _deselect_all_items(wd);
532 elm_gengrid_item_selected_set(next, EINA_TRUE);
533 elm_gengrid_item_show(next);
538 _on_focus_hook(void *data __UNUSED__,
541 Widget_Data *wd = elm_widget_data_get(obj);
543 if (elm_widget_focus_get(obj))
545 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
546 evas_object_focus_set(wd->obj, EINA_TRUE);
547 if ((wd->selected) && (!wd->last_selected_item))
548 wd->last_selected_item = eina_list_data_get(wd->selected);
552 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
553 evas_object_focus_set(wd->obj, EINA_FALSE);
558 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
560 Widget_Data *wd = elm_widget_data_get(obj);
563 elm_smart_scroller_mirrored_set(wd->scr, rtl);
564 if (!wd->items) return;
565 it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
569 edje_object_mirrored_set(VIEW(it), rtl);
570 elm_gengrid_item_update(it);
571 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
576 _theme_hook(Evas_Object *obj)
578 Widget_Data *wd = elm_widget_data_get(obj);
580 _elm_widget_mirrored_reload(obj);
581 _mirrored_set(obj, elm_widget_mirrored_get(obj));
582 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
583 elm_widget_style_get(obj));
587 _del_pre_hook(Evas_Object *obj)
589 Widget_Data *wd = elm_widget_data_get(obj);
591 elm_gengrid_clear(obj);
592 evas_object_del(wd->pan_smart);
593 wd->pan_smart = NULL;
597 _del_hook(Evas_Object *obj)
599 Widget_Data *wd = elm_widget_data_get(obj);
600 if (wd->calc_job) ecore_job_del(wd->calc_job);
605 _signal_emit_hook(Evas_Object *obj,
606 const char *emission,
609 Widget_Data *wd = elm_widget_data_get(obj);
611 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
616 _signal_callback_add_hook(Evas_Object *obj,
617 const char *emission,
619 Edje_Signal_Cb func_cb,
622 Widget_Data *wd = elm_widget_data_get(obj);
624 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
625 emission, source, func_cb, data);
629 _signal_callback_del_hook(Evas_Object *obj,
630 const char *emission,
632 Edje_Signal_Cb func_cb,
635 Widget_Data *wd = elm_widget_data_get(obj);
637 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scr),
638 emission, source, func_cb, data);
642 _mouse_move(void *data,
643 Evas *evas __UNUSED__,
647 Elm_Gen_Item *it = data;
648 Evas_Event_Mouse_Move *ev = event_info;
649 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
650 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
652 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
654 if (!it->wd->on_hold)
656 it->wd->on_hold = EINA_TRUE;
657 if (!it->wd->wasselected)
661 if ((it->dragging) && (it->down))
665 ecore_timer_del(it->long_timer);
666 it->long_timer = NULL;
668 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
671 if ((!it->down) || (it->wd->longpressed))
675 ecore_timer_del(it->long_timer);
676 it->long_timer = NULL;
678 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
680 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
682 it_scrl_x = ev->cur.canvas.x - it->wd->reorder_it->dx;
683 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
685 if (it_scrl_x < ox) it->wd->reorder_item_x = ox;
686 else if (it_scrl_x + it->wd->item_width > ox + ow)
687 it->wd->reorder_item_x = ox + ow - it->wd->item_width;
688 else it->wd->reorder_item_x = it_scrl_x;
690 if (it_scrl_y < oy) it->wd->reorder_item_y = oy;
691 else if (it_scrl_y + it->wd->item_height > oy + oh)
692 it->wd->reorder_item_y = oy + oh - it->wd->item_height;
693 else it->wd->reorder_item_y = it_scrl_y;
695 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
696 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
700 if (!it->display_only)
701 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
702 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
703 x = ev->cur.canvas.x - x;
704 y = ev->cur.canvas.y - y;
707 if (adx < 0) adx = -dx;
710 if (ady < 0) ady = -dy;
713 if ((adx > minw) || (ady > minh))
715 const char *left_drag, *right_drag;
716 if (!elm_widget_mirrored_get(WIDGET(it)))
718 left_drag = SIG_DRAG_START_LEFT;
719 right_drag = SIG_DRAG_START_RIGHT;
723 left_drag = SIG_DRAG_START_RIGHT;
724 right_drag = SIG_DRAG_START_LEFT;
730 ecore_timer_del(it->long_timer);
731 it->long_timer = NULL;
733 if (!it->wd->wasselected)
738 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_START_UP,
743 evas_object_smart_callback_call(WIDGET(it),
750 evas_object_smart_callback_call(WIDGET(it),
751 SIG_DRAG_START_DOWN, it);
755 evas_object_smart_callback_call(WIDGET(it),
758 evas_object_smart_callback_call(WIDGET(it),
766 _long_press(void *data)
768 Elm_Gen_Item *it = data;
770 it->long_timer = NULL;
771 if ((it->disabled) || (it->dragging)) return ECORE_CALLBACK_CANCEL;
772 it->wd->longpressed = EINA_TRUE;
773 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
774 if (it->wd->reorder_mode)
776 it->wd->reorder_it = it;
777 evas_object_raise(VIEW(it));
778 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
779 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
780 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
782 return ECORE_CALLBACK_CANCEL;
786 _mouse_down(void *data,
787 Evas *evas __UNUSED__,
791 Elm_Gen_Item *it = data;
792 Evas_Event_Mouse_Down *ev = event_info;
795 if (ev->button != 1) return;
798 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
799 it->dx = ev->canvas.x - x;
800 it->dy = ev->canvas.y - y;
801 it->wd->longpressed = EINA_FALSE;
802 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
803 else it->wd->on_hold = EINA_FALSE;
804 it->wd->wasselected = it->selected;
806 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
808 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
809 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
811 if (it->long_timer) ecore_timer_del(it->long_timer);
813 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
816 it->long_timer = NULL;
820 _mouse_up(void *data,
821 Evas *evas __UNUSED__,
822 Evas_Object *obj __UNUSED__,
825 Elm_Gen_Item *it = data;
826 Evas_Event_Mouse_Up *ev = event_info;
827 Eina_Bool dragged = EINA_FALSE;
829 if (ev->button != 1) return;
830 it->down = EINA_FALSE;
831 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
832 else it->wd->on_hold = EINA_FALSE;
835 ecore_timer_del(it->long_timer);
836 it->long_timer = NULL;
840 it->dragging = EINA_FALSE;
841 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
846 it->wd->longpressed = EINA_FALSE;
847 it->wd->on_hold = EINA_FALSE;
850 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
852 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it->wd->reorder_it);
853 it->wd->reorder_it = NULL;
854 it->wd->move_effect_enabled = EINA_FALSE;
855 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
856 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
858 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
859 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
860 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
862 if (it->wd->longpressed)
864 it->wd->longpressed = EINA_FALSE;
865 if (!it->wd->wasselected) _item_unselect(it);
866 it->wd->wasselected = EINA_FALSE;
871 if (it->want_unrealize)
872 _elm_genlist_item_unrealize(it, EINA_FALSE);
874 if ((it->disabled) || (dragged)) return;
882 else _item_unselect(it);
888 while (it->wd->selected)
889 _item_unselect(it->wd->selected->data);
893 const Eina_List *l, *l_next;
896 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, item2)
897 if (item2 != it) _item_unselect(item2);
905 _item_highlight(Elm_Gen_Item *it)
907 if ((it->wd->no_select) || (it->generation < it->wd->generation) || (it->highlighted)) return;
908 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
909 it->highlighted = EINA_TRUE;
913 _item_realize(Elm_Gen_Item *it)
918 if ((it->realized) || (it->generation < it->wd->generation)) return;
919 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
920 edje_object_scale_set(VIEW(it), elm_widget_scale_get(WIDGET(it)) *
922 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
923 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
924 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
925 snprintf(style, sizeof(style), "item/%s",
926 it->itc->item_style ? it->itc->item_style : "default");
927 _elm_theme_object_set(WIDGET(it), VIEW(it), "gengrid", style,
928 elm_widget_style_get(WIDGET(it)));
930 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
931 evas_object_color_set(it->spacer, 0, 0, 0, 0);
932 elm_widget_sub_object_add(WIDGET(it), it->spacer);
933 evas_object_size_hint_min_set(it->spacer, 2 * _elm_config->scale, 1);
934 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
936 if (it->itc->func.text_get)
942 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
944 EINA_LIST_FOREACH(it->labels, l, key)
946 char *s = it->itc->func.text_get
947 ((void *)it->base.data, WIDGET(it), key);
950 edje_object_part_text_set(VIEW(it), key, s);
956 if (it->itc->func.content_get)
960 Evas_Object *ic = NULL;
963 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
965 EINA_LIST_FOREACH(it->contents, l, key)
967 if (it->itc->func.content_get)
968 ic = it->itc->func.content_get
969 ((void *)it->base.data, WIDGET(it), key);
972 it->content_objs = eina_list_append(it->content_objs, ic);
973 edje_object_part_swallow(VIEW(it), key, ic);
974 evas_object_show(ic);
975 elm_widget_sub_object_add(WIDGET(it), ic);
980 if (it->itc->func.state_get)
986 elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
988 EINA_LIST_FOREACH(it->states, l, key)
990 Eina_Bool on = it->itc->func.state_get
991 ((void *)it->base.data, WIDGET(it), l->data);
994 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
995 edje_object_signal_emit(VIEW(it), buf, "elm");
1002 if ((!it->wd->group_item_width) && (!it->wd->group_item_height))
1004 edje_object_size_min_restricted_calc(VIEW(it),
1005 &it->wd->group_item_width,
1006 &it->wd->group_item_height,
1007 it->wd->group_item_width,
1008 it->wd->group_item_height);
1013 if ((!it->wd->item_width) && (!it->wd->item_height))
1015 edje_object_size_min_restricted_calc(VIEW(it),
1016 &it->wd->item_width,
1017 &it->wd->item_height,
1019 it->wd->item_height);
1020 elm_coords_finger_size_adjust(1, &it->wd->item_width,
1021 1, &it->wd->item_height);
1024 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1026 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1028 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1032 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1034 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1036 evas_object_show(VIEW(it));
1038 if (it->tooltip.content_cb)
1040 elm_widget_item_tooltip_content_cb_set(it,
1041 it->tooltip.content_cb,
1042 it->tooltip.data, NULL);
1043 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1044 elm_widget_item_tooltip_size_restrict_disable(it, it->tooltip.free_size);
1047 if (it->mouse_cursor)
1048 elm_widget_item_cursor_set(it, it->mouse_cursor);
1050 it->realized = EINA_TRUE;
1051 it->want_unrealize = EINA_FALSE;
1055 _item_unrealize_cb(Elm_Gen_Item *it)
1057 evas_object_del(VIEW(it));
1059 evas_object_del(it->spacer);
1064 _reorder_item_moving_effect_timer_cb(void *data)
1066 Elm_Gen_Item *it = data;
1070 time = REORDER_EFFECT_TIME;
1071 t = ((0.0 > (t = ecore_loop_time_get()-it->item->moving_effect_start_time)) ? 0.0 : t);
1072 dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
1073 dy = ((it->item->ty - it->item->oy) / 10) * _elm_config->scale;
1077 it->item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
1078 it->item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
1086 if ((((dx > 0) && (it->item->rx >= it->item->tx)) || ((dx <= 0) && (it->item->rx <= it->item->tx))) &&
1087 (((dy > 0) && (it->item->ry >= it->item->ty)) || ((dy <= 0) && (it->item->ry <= it->item->ty))))
1089 evas_object_move(VIEW(it), it->item->tx, it->item->ty);
1093 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1094 if (it->wd->horizontal)
1095 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1097 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1100 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1101 it->item->moving = EINA_FALSE;
1102 it->item->item_moving_effect_timer = NULL;
1103 return ECORE_CALLBACK_CANCEL;
1106 evas_object_move(VIEW(it), it->item->rx, it->item->ry);
1110 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1111 if (it->wd->horizontal)
1112 evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1114 evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1117 evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1119 return ECORE_CALLBACK_RENEW;
1123 _group_item_place(Pan *sd)
1125 Evas_Coord iw, ih, vw, vh;
1127 Eina_Bool was_realized;
1129 evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1130 if (sd->wd->horizontal)
1132 iw = sd->wd->group_item_width;
1138 ih = sd->wd->group_item_height;
1140 EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1142 was_realized = it->realized;
1143 if (it->item->group_realized)
1147 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1148 evas_object_move(VIEW(it), it->item->gx, it->item->gy);
1149 evas_object_resize(VIEW(it), iw, ih);
1150 evas_object_raise(VIEW(it));
1153 _elm_genlist_item_unrealize(it, EINA_FALSE);
1159 _item_place(Elm_Gen_Item *it,
1163 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1164 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1165 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1169 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &vw, &vh);
1171 /* Preload rows/columns at each side of the Gengrid */
1172 cvx = ox - PRELOAD * it->wd->item_width;
1173 cvy = oy - PRELOAD * it->wd->item_height;
1174 cvw = vw + 2 * PRELOAD * it->wd->item_width;
1175 cvh = vh + 2 * PRELOAD * it->wd->item_height;
1180 items_count = it->wd->count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
1181 if (it->wd->horizontal)
1183 int columns, items_visible = 0, items_row;
1185 if (it->wd->item_height > 0)
1186 items_visible = vh / it->wd->item_height;
1187 if (items_visible < 1)
1190 columns = items_count / items_visible;
1191 if (items_count % items_visible)
1194 tcw = (it->wd->item_width * columns) + (it->wd->group_item_width * eina_list_count(it->wd->group_items));
1195 alignw = (vw - tcw) * it->wd->align_x;
1197 items_row = items_visible;
1198 if (items_row > it->wd->count)
1199 items_row = it->wd->count;
1200 tch = items_row * it->wd->item_height;
1201 alignh = (vh - tch) * it->wd->align_y;
1205 int rows, items_visible = 0, items_col;
1207 if (it->wd->item_width > 0)
1208 items_visible = vw / it->wd->item_width;
1209 if (items_visible < 1)
1212 rows = items_count / items_visible;
1213 if (items_count % items_visible)
1216 tch = (it->wd->item_height * rows) + (it->wd->group_item_height * eina_list_count(it->wd->group_items));
1217 alignh = (vh - tch) * it->wd->align_y;
1219 items_col = items_visible;
1220 if (items_col > it->wd->count)
1221 items_col = it->wd->count;
1222 tcw = items_col * it->wd->item_width;
1223 alignw = (vw - tcw) * it->wd->align_x;
1228 if (it->wd->horizontal)
1230 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;
1232 iw = it->wd->group_item_width;
1238 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;
1240 ih = it->wd->group_item_height;
1247 if (it->wd->horizontal)
1249 x = (((cx - it->item->prev_group) * it->wd->item_width) + (it->item->prev_group * it->wd->group_item_width)) - it->wd->pan_x + ox + alignw;
1250 y = (cy * it->wd->item_height) - it->wd->pan_y + oy + alignh;
1254 x = (cx * it->wd->item_width) - it->wd->pan_x + ox + alignw;
1255 y = (((cy - it->item->prev_group) * it->wd->item_height) + (it->item->prev_group * it->wd->group_item_height)) - it->wd->pan_y + oy + alignh;
1257 if (elm_widget_mirrored_get(WIDGET(it)))
1258 { /* Switch items side and componsate for pan_x when in RTL mode */
1259 evas_object_geometry_get(WIDGET(it), NULL, NULL, &ww, NULL);
1260 x = ww - x - it->wd->item_width - it->wd->pan_x - it->wd->pan_x;
1262 iw = it->wd->item_width;
1263 ih = it->wd->item_height;
1266 Eina_Bool was_realized = it->realized;
1267 if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1271 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1274 if (it->wd->horizontal)
1276 if (it->parent->item->gx < ox)
1278 it->parent->item->gx = x + it->wd->item_width - it->wd->group_item_width;
1279 if (it->parent->item->gx > ox)
1280 it->parent->item->gx = ox;
1282 it->parent->item->group_realized = EINA_TRUE;
1286 if (it->parent->item->gy < oy)
1288 it->parent->item->gy = y + it->wd->item_height - it->wd->group_item_height;
1289 if (it->parent->item->gy > oy)
1290 it->parent->item->gy = oy;
1292 it->parent->item->group_realized = EINA_TRUE;
1295 if (it->wd->reorder_mode)
1297 if (it->wd->reorder_it)
1299 if (it->item->moving) return;
1301 if (!it->wd->move_effect_enabled)
1306 if (it->wd->reorder_it == it)
1308 evas_object_move(VIEW(it),
1309 it->wd->reorder_item_x, it->wd->reorder_item_y);
1310 evas_object_resize(VIEW(it), iw, ih);
1315 if (it->wd->move_effect_enabled)
1317 if ((it->item->ox != x) || (it->item->oy != y))
1319 if (((it->wd->old_pan_x == it->wd->pan_x) && (it->wd->old_pan_y == it->wd->pan_y)) ||
1320 ((it->wd->old_pan_x != it->wd->pan_x) && !(it->item->ox - it->wd->pan_x + it->wd->old_pan_x == x)) ||
1321 ((it->wd->old_pan_y != it->wd->pan_y) && !(it->item->oy - it->wd->pan_y + it->wd->old_pan_y == y)))
1325 it->item->rx = it->item->ox;
1326 it->item->ry = it->item->oy;
1327 it->item->moving = EINA_TRUE;
1328 it->item->moving_effect_start_time = ecore_loop_time_get();
1329 it->item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
1336 Evas_Coord nx, ny, nw, nh;
1339 if (it->wd->horizontal)
1341 nx = x + (it->wd->group_item_width / 2);
1349 ny = y + (it->wd->group_item_height / 2);
1356 nx = x + (it->wd->item_width / 2);
1357 ny = y + (it->wd->item_height / 2);
1362 if ( ELM_RECTS_INTERSECT(it->wd->reorder_item_x, it->wd->reorder_item_y,
1363 it->wd->item_width, it->wd->item_height,
1366 if (it->wd->horizontal)
1368 if ((it->wd->nmax * it->wd->reorder_it->x + it->wd->reorder_it->y) >
1369 (it->wd->nmax * it->x + it->y))
1370 reorder_item_move_forward = EINA_TRUE;
1374 if ((it->wd->nmax * it->wd->reorder_it->y + it->wd->reorder_it->x) >
1375 (it->wd->nmax * it->y + it->x))
1376 reorder_item_move_forward = EINA_TRUE;
1379 it->wd->items = eina_inlist_remove(it->wd->items,
1380 EINA_INLIST_GET(it->wd->reorder_it));
1381 if (reorder_item_move_forward)
1382 it->wd->items = eina_inlist_prepend_relative(it->wd->items,
1383 EINA_INLIST_GET(it->wd->reorder_it),
1384 EINA_INLIST_GET(it));
1386 it->wd->items = eina_inlist_append_relative(it->wd->items,
1387 EINA_INLIST_GET(it->wd->reorder_it),
1388 EINA_INLIST_GET(it));
1390 it->wd->reorder_item_changed = EINA_TRUE;
1391 it->wd->move_effect_enabled = EINA_TRUE;
1392 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1393 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1399 else if (it->item->item_moving_effect_timer)
1401 ecore_animator_del(it->item->item_moving_effect_timer);
1402 it->item->item_moving_effect_timer = NULL;
1403 it->item->moving = EINA_FALSE;
1408 evas_object_move(VIEW(it), x, y);
1409 evas_object_resize(VIEW(it), iw, ih);
1412 it->item->group_realized = EINA_TRUE;
1417 _elm_genlist_item_unrealize(it, EINA_FALSE);
1419 it->item->group_realized = EINA_FALSE;
1424 _item_del(Elm_Gen_Item *it)
1426 Evas_Object *obj = WIDGET(it);
1428 evas_event_freeze(evas_object_evas_get(obj));
1429 it->wd->selected = eina_list_remove(it->wd->selected, it);
1430 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
1432 _elm_genlist_item_del_serious(it);
1433 evas_event_thaw(evas_object_evas_get(obj));
1434 evas_event_thaw_eval(evas_object_evas_get(obj));
1438 _item_unselect(Elm_Gen_Item *it)
1440 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
1441 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
1442 it->highlighted = EINA_FALSE;
1445 it->selected = EINA_FALSE;
1446 it->wd->selected = eina_list_remove(it->wd->selected, it);
1447 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
1452 _calc_job(void *data)
1454 Widget_Data *wd = data;
1455 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1456 Elm_Gen_Item *it, *group_item = NULL;
1457 int count_group = 0;
1461 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1462 if ((cvw != 0) || (cvh != 0))
1464 if ((wd->horizontal) && (wd->item_height > 0))
1465 nmax = cvh / wd->item_height;
1466 else if (wd->item_width > 0)
1467 nmax = cvw / wd->item_width;
1472 EINA_INLIST_FOREACH(wd->items, it)
1474 if (it->item->prev_group != count_group)
1475 it->item->prev_group = count_group;
1478 count = count % nmax;
1480 wd->items_lost += nmax - count;
1481 //printf("%d items and I lost %d\n", count, wd->items_lost);
1483 if (count) count = 0;
1488 if (it->parent != group_item)
1489 it->parent = group_item;
1493 count = wd->count + wd->items_lost - count_group;
1496 minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width);
1497 minh = nmax * wd->item_height;
1501 minw = nmax * wd->item_width;
1502 minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1505 if ((minw != wd->minw) || (minh != wd->minh))
1509 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1513 evas_object_smart_changed(wd->pan_smart);
1515 wd->calc_job = NULL;
1519 _pan_add(Evas_Object *obj)
1522 Evas_Object_Smart_Clipped_Data *cd;
1525 cd = evas_object_smart_data_get(obj);
1528 sd->__clipped_data = *cd;
1530 evas_object_smart_data_set(obj, sd);
1534 _pan_del(Evas_Object *obj)
1536 Pan *sd = evas_object_smart_data_get(obj);
1543 _pan_set(Evas_Object *obj,
1547 Pan *sd = evas_object_smart_data_get(obj);
1548 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1551 evas_object_smart_changed(obj);
1555 _pan_get(Evas_Object *obj,
1559 Pan *sd = evas_object_smart_data_get(obj);
1560 if (x) *x = sd->wd->pan_x;
1561 if (y) *y = sd->wd->pan_y;
1565 _pan_child_size_get(Evas_Object *obj,
1569 Pan *sd = evas_object_smart_data_get(obj);
1570 if (w) *w = sd->wd->minw;
1571 if (h) *h = sd->wd->minh;
1575 _pan_max_get(Evas_Object *obj,
1579 Pan *sd = evas_object_smart_data_get(obj);
1583 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1585 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1587 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1591 _pan_min_get(Evas_Object *obj,
1595 Pan *sd = evas_object_smart_data_get(obj);
1599 _pan_max_get(obj, &mx, &my);
1601 *x = -mx * sd->wd->align_x;
1603 *y = -my * sd->wd->align_y;
1607 _pan_resize(Evas_Object *obj,
1611 Pan *sd = evas_object_smart_data_get(obj);
1614 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1615 if ((ow == w) && (oh == h)) return;
1616 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1617 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1621 _pan_calculate(Evas_Object *obj)
1623 Pan *sd = evas_object_smart_data_get(obj);
1624 Evas_Coord cx = 0, cy = 0;
1628 if (!sd->wd->nmax) return;
1630 sd->wd->reorder_item_changed = EINA_FALSE;
1632 EINA_INLIST_FOREACH(sd->wd->items, it)
1636 if (sd->wd->horizontal)
1653 _item_place(it, cx, cy);
1654 if (sd->wd->reorder_item_changed) return;
1657 if (sd->wd->horizontal)
1670 if (sd->wd->horizontal)
1672 cy = (cy + 1) % sd->wd->nmax;
1677 cx = (cx + 1) % sd->wd->nmax;
1682 _group_item_place(sd);
1685 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
1687 if (!sd->wd->reorder_item_changed)
1689 sd->wd->old_pan_x = sd->wd->pan_x;
1690 sd->wd->old_pan_y = sd->wd->pan_y;
1692 sd->wd->move_effect_enabled = EINA_FALSE;
1694 evas_object_smart_callback_call(sd->wd->obj, SIG_CHANGED, NULL);
1698 _pan_move(Evas_Object *obj,
1699 Evas_Coord x __UNUSED__,
1700 Evas_Coord y __UNUSED__)
1702 Pan *sd = evas_object_smart_data_get(obj);
1704 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1705 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1709 _hold_on(void *data __UNUSED__,
1711 void *event_info __UNUSED__)
1713 Widget_Data *wd = elm_widget_data_get(obj);
1715 elm_smart_scroller_hold_set(wd->scr, 1);
1719 _hold_off(void *data __UNUSED__,
1721 void *event_info __UNUSED__)
1723 Widget_Data *wd = elm_widget_data_get(obj);
1725 elm_smart_scroller_hold_set(wd->scr, 0);
1729 _freeze_on(void *data __UNUSED__,
1731 void *event_info __UNUSED__)
1733 Widget_Data *wd = elm_widget_data_get(obj);
1735 elm_smart_scroller_freeze_set(wd->scr, 1);
1739 _freeze_off(void *data __UNUSED__,
1741 void *event_info __UNUSED__)
1743 Widget_Data *wd = elm_widget_data_get(obj);
1745 elm_smart_scroller_freeze_set(wd->scr, 0);
1749 _scr_anim_start(void *data,
1750 Evas_Object *obj __UNUSED__,
1751 void *event_info __UNUSED__)
1753 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1757 _scr_anim_stop(void *data,
1758 Evas_Object *obj __UNUSED__,
1759 void *event_info __UNUSED__)
1761 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1765 _scr_drag_start(void *data,
1766 Evas_Object *obj __UNUSED__,
1767 void *event_info __UNUSED__)
1769 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1773 _scr_drag_stop(void *data,
1774 Evas_Object *obj __UNUSED__,
1775 void *event_info __UNUSED__)
1777 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1781 _edge_left(void *data,
1782 Evas_Object *scr __UNUSED__,
1783 void *event_info __UNUSED__)
1785 evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
1789 _edge_right(void *data,
1790 Evas_Object *scr __UNUSED__,
1791 void *event_info __UNUSED__)
1793 evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
1797 _edge_top(void *data,
1798 Evas_Object *scr __UNUSED__,
1799 void *event_info __UNUSED__)
1801 evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
1805 _edge_bottom(void *data,
1806 Evas_Object *scr __UNUSED__,
1807 void *event_info __UNUSED__)
1809 evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
1813 _scr_scroll(void *data,
1814 Evas_Object *obj __UNUSED__,
1815 void *event_info __UNUSED__)
1817 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1821 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1823 const Elm_Gen_Item *it = data;
1824 const Elm_Gen_Item *item1 = data1;
1826 return _elm_gengrid_item_compare_data_cb(it->base.data, item1->base.data);
1830 _elm_gengrid_item_compare(const void *data, const void *data1)
1832 Elm_Gen_Item *it, *item1;
1833 it = ELM_GEN_ITEM_FROM_INLIST(data);
1834 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
1835 return _elm_gengrid_item_compare_cb(it, item1);
1838 static Elm_Gen_Item *
1839 _item_new(Widget_Data *wd,
1840 const Elm_Gengrid_Item_Class *itc,
1843 const void *func_data)
1847 it = _elm_genlist_item_new(wd, itc, data, NULL, func, func_data);
1848 if (!it) return NULL;
1849 it->item = ELM_NEW(Elm_Gen_Item_Type);
1851 it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
1852 ELM_GEN_ITEM_SETUP(it);
1858 elm_gengrid_add(Evas_Object *parent)
1863 static Evas_Smart *smart = NULL;
1864 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1868 static Evas_Smart_Class sc;
1870 evas_object_smart_clipped_smart_set(&_pan_sc);
1872 sc.name = "elm_gengrid_pan";
1873 sc.version = EVAS_SMART_CLASS_VERSION;
1876 sc.resize = _pan_resize;
1877 sc.move = _pan_move;
1878 sc.calculate = _pan_calculate;
1879 if (!(smart = evas_smart_class_new(&sc))) return NULL;
1882 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1884 ELM_SET_WIDTYPE(widtype, "gengrid");
1886 elm_widget_type_set(obj, "gengrid");
1887 elm_widget_sub_object_add(parent, obj);
1888 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1889 elm_widget_data_set(obj, wd);
1890 elm_widget_del_hook_set(obj, _del_hook);
1891 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1892 elm_widget_theme_hook_set(obj, _theme_hook);
1893 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1894 elm_widget_can_focus_set(obj, EINA_TRUE);
1895 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1896 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1897 elm_widget_event_hook_set(obj, _event_hook);
1900 wd->scr = elm_smart_scroller_add(e);
1901 elm_smart_scroller_widget_set(wd->scr, obj);
1902 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1904 elm_smart_scroller_bounce_allow_set(wd->scr, bounce,
1905 _elm_config->thumbscroll_bounce_enable);
1906 elm_widget_resize_object_set(obj, wd->scr);
1908 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1909 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1910 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1911 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1912 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1913 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1914 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1915 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom,
1917 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1922 wd->h_bounce = bounce;
1923 wd->v_bounce = bounce;
1925 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1926 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1927 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1928 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1930 wd->pan_smart = evas_object_smart_add(e, smart);
1931 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1934 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1935 _pan_set, _pan_get, _pan_max_get,
1936 _pan_min_get, _pan_child_size_get);
1938 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1940 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1945 elm_gengrid_item_size_set(Evas_Object *obj,
1949 ELM_CHECK_WIDTYPE(obj, widtype);
1950 Widget_Data *wd = elm_widget_data_get(obj);
1952 if ((wd->item_width == w) && (wd->item_height == h)) return;
1954 wd->item_height = h;
1955 if (wd->calc_job) ecore_job_del(wd->calc_job);
1956 wd->calc_job = ecore_job_add(_calc_job, wd);
1960 elm_gengrid_item_size_get(const Evas_Object *obj,
1964 ELM_CHECK_WIDTYPE(obj, widtype);
1965 Widget_Data *wd = elm_widget_data_get(obj);
1967 if (w) *w = wd->item_width;
1968 if (h) *h = wd->item_height;
1972 elm_gengrid_group_item_size_set(Evas_Object *obj,
1976 ELM_CHECK_WIDTYPE(obj, widtype);
1977 Widget_Data *wd = elm_widget_data_get(obj);
1979 if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
1980 wd->group_item_width = w;
1981 wd->group_item_height = h;
1982 if (wd->calc_job) ecore_job_del(wd->calc_job);
1983 wd->calc_job = ecore_job_add(_calc_job, wd);
1987 elm_gengrid_group_item_size_get(const Evas_Object *obj,
1991 ELM_CHECK_WIDTYPE(obj, widtype);
1992 Widget_Data *wd = elm_widget_data_get(obj);
1994 if (w) *w = wd->group_item_width;
1995 if (h) *h = wd->group_item_height;
1999 elm_gengrid_align_set(Evas_Object *obj,
2003 ELM_CHECK_WIDTYPE(obj, widtype);
2005 Widget_Data *wd = elm_widget_data_get(obj);
2006 double old_h = wd->align_x, old_y = wd->align_y;
2010 else if (align_x < 0.0)
2012 wd->align_x = align_x;
2016 else if (align_y < 0.0)
2018 wd->align_y = align_y;
2020 if ((old_h != wd->align_x) || (old_y != wd->align_y))
2021 evas_object_smart_calculate(wd->pan_smart);
2025 elm_gengrid_align_get(const Evas_Object *obj,
2029 ELM_CHECK_WIDTYPE(obj, widtype);
2030 Widget_Data *wd = elm_widget_data_get(obj);
2031 if (align_x) *align_x = wd->align_x;
2032 if (align_y) *align_y = wd->align_y;
2036 elm_gengrid_item_append(Evas_Object *obj,
2037 const Elm_Gengrid_Item_Class *itc,
2040 const void *func_data)
2043 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2044 Widget_Data *wd = elm_widget_data_get(obj);
2045 if (!wd) return NULL;
2047 it = _item_new(wd, itc, data, func, func_data);
2048 if (!it) return NULL;
2049 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2052 wd->group_items = eina_list_prepend(wd->group_items, it);
2054 if (wd->calc_job) ecore_job_del(wd->calc_job);
2055 wd->calc_job = ecore_job_add(_calc_job, wd);
2061 elm_gengrid_item_prepend(Evas_Object *obj,
2062 const Elm_Gengrid_Item_Class *itc,
2065 const void *func_data)
2068 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2069 Widget_Data *wd = elm_widget_data_get(obj);
2070 if (!wd) return NULL;
2072 it = _item_new(wd, itc, data, func, func_data);
2073 if (!it) return NULL;
2074 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2076 wd->group_items = eina_list_append(wd->group_items, it);
2078 if (wd->calc_job) ecore_job_del(wd->calc_job);
2079 wd->calc_job = ecore_job_add(_calc_job, wd);
2085 elm_gengrid_item_insert_before(Evas_Object *obj,
2086 const Elm_Gengrid_Item_Class *itc,
2088 Elm_Gen_Item *relative,
2090 const void *func_data)
2093 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2094 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2095 Widget_Data *wd = elm_widget_data_get(obj);
2096 if (!wd) return NULL;
2098 it = _item_new(wd, itc, data, func, func_data);
2099 if (!it) return NULL;
2100 wd->items = eina_inlist_prepend_relative
2101 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(relative));
2103 wd->group_items = eina_list_append_relative(wd->group_items, it, relative->parent);
2105 if (wd->calc_job) ecore_job_del(wd->calc_job);
2106 wd->calc_job = ecore_job_add(_calc_job, wd);
2112 elm_gengrid_item_insert_after(Evas_Object *obj,
2113 const Elm_Gengrid_Item_Class *itc,
2115 Elm_Gen_Item *relative,
2117 const void *func_data)
2120 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2121 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2122 Widget_Data *wd = elm_widget_data_get(obj);
2123 if (!wd) return NULL;
2125 it = _item_new(wd, itc, data, func, func_data);
2126 if (!it) return NULL;
2127 wd->items = eina_inlist_append_relative
2128 (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(relative));
2130 wd->group_items = eina_list_prepend_relative(wd->group_items, it, relative->parent);
2132 if (wd->calc_job) ecore_job_del(wd->calc_job);
2133 wd->calc_job = ecore_job_add(_calc_job, wd);
2139 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
2140 const Elm_Gengrid_Item_Class *itc,
2142 Eina_Compare_Cb comp,
2144 const void *func_data)
2147 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2148 Widget_Data *wd = elm_widget_data_get(obj);
2149 if (!wd) return NULL;
2151 it = _item_new(wd, itc, data, func, func_data);
2152 if (!it) return NULL;
2155 wd->state = eina_inlist_sorted_state_new();
2157 _elm_gengrid_item_compare_cb = comp;
2158 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
2159 _elm_gengrid_item_compare, wd->state);
2160 if (wd->calc_job) ecore_job_del(wd->calc_job);
2161 wd->calc_job = ecore_job_add(_calc_job, wd);
2167 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2168 const Elm_Gengrid_Item_Class *itc,
2170 Eina_Compare_Cb comp,
2172 const void *func_data)
2174 _elm_gengrid_item_compare_data_cb = comp;
2176 return elm_gengrid_item_direct_sorted_insert(obj, itc, data, _elm_gengrid_item_compare_data, func, func_data);
2180 elm_gengrid_item_del(Elm_Gen_Item *it)
2182 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2183 if ((it->relcount > 0) || (it->walking > 0))
2185 _elm_genlist_item_del_notserious(it);
2193 elm_gengrid_horizontal_set(Evas_Object *obj,
2196 ELM_CHECK_WIDTYPE(obj, widtype);
2197 Widget_Data *wd = elm_widget_data_get(obj);
2199 if (setting == wd->horizontal) return;
2200 wd->horizontal = setting;
2202 /* Update the items to conform to the new layout */
2203 if (wd->calc_job) ecore_job_del(wd->calc_job);
2204 wd->calc_job = ecore_job_add(_calc_job, wd);
2208 elm_gengrid_horizontal_get(const Evas_Object *obj)
2210 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2211 Widget_Data *wd = elm_widget_data_get(obj);
2212 if (!wd) return EINA_FALSE;
2213 return wd->horizontal;
2217 elm_gengrid_clear(Evas_Object *obj)
2219 elm_genlist_clear(obj);
2222 EAPI const Evas_Object *
2223 elm_gengrid_item_object_get(const Elm_Gen_Item *it)
2225 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2230 elm_gengrid_item_update(Elm_Gen_Item *it)
2232 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2233 if (!it->realized) return;
2234 if (it->want_unrealize) return;
2235 _elm_genlist_item_unrealize(it, EINA_FALSE);
2237 _item_place(it, it->x, it->y);
2241 elm_gengrid_item_data_get(const Elm_Gen_Item *it)
2243 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2244 return elm_widget_item_data_get(it);
2248 elm_gengrid_item_data_set(Elm_Gen_Item *it,
2251 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2252 elm_widget_item_data_set(it, data);
2255 EAPI const Elm_Gengrid_Item_Class *
2256 elm_gengrid_item_item_class_get(const Elm_Gen_Item *it)
2258 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2259 if (it->generation < it->wd->generation) return NULL;
2264 elm_gengrid_item_item_class_set(Elm_Gen_Item *it,
2265 const Elm_Gengrid_Item_Class *itc)
2267 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2268 EINA_SAFETY_ON_NULL_RETURN(itc);
2269 if (it->generation < it->wd->generation) return;
2271 elm_gengrid_item_update(it);
2275 elm_gengrid_item_pos_get(const Elm_Gen_Item *it,
2279 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2285 elm_gengrid_multi_select_set(Evas_Object *obj,
2288 ELM_CHECK_WIDTYPE(obj, widtype);
2289 Widget_Data *wd = elm_widget_data_get(obj);
2295 elm_gengrid_multi_select_get(const Evas_Object *obj)
2297 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2298 Widget_Data *wd = elm_widget_data_get(obj);
2299 if (!wd) return EINA_FALSE;
2304 elm_gengrid_selected_item_get(const Evas_Object *obj)
2306 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2307 Widget_Data *wd = elm_widget_data_get(obj);
2308 if (!wd) return NULL;
2309 if (wd->selected) return wd->selected->data;
2313 EAPI const Eina_List *
2314 elm_gengrid_selected_items_get(const Evas_Object *obj)
2316 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2317 Widget_Data *wd = elm_widget_data_get(obj);
2318 if (!wd) return NULL;
2319 return wd->selected;
2323 elm_gengrid_item_selected_set(Elm_Gen_Item *it,
2326 elm_genlist_item_selected_set(it, selected);
2330 elm_gengrid_item_selected_get(const Elm_Gen_Item *it)
2332 return elm_genlist_item_selected_get(it);
2336 elm_gengrid_item_disabled_set(Elm_Gen_Item *it,
2339 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2340 if (it->disabled == disabled) return;
2341 if (it->generation < it->wd->generation) return;
2342 it->disabled = !!disabled;
2346 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
2348 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
2353 elm_gengrid_item_disabled_get(const Elm_Gen_Item *it)
2355 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
2356 if (it->generation < it->wd->generation) return EINA_FALSE;
2357 return it->disabled;
2360 static Evas_Object *
2361 _elm_gengrid_item_label_create(void *data,
2362 Evas_Object *obj __UNUSED__,
2363 Evas_Object *tooltip,
2364 void *it __UNUSED__)
2366 Evas_Object *label = elm_label_add(tooltip);
2369 elm_object_style_set(label, "tooltip");
2370 elm_object_text_set(label, data);
2375 _elm_gengrid_item_label_del_cb(void *data,
2376 Evas_Object *obj __UNUSED__,
2377 void *event_info __UNUSED__)
2379 eina_stringshare_del(data);
2383 elm_gengrid_item_tooltip_text_set(Elm_Gen_Item *it,
2386 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2387 text = eina_stringshare_add(text);
2388 elm_gengrid_item_tooltip_content_cb_set(it, _elm_gengrid_item_label_create,
2390 _elm_gengrid_item_label_del_cb);
2394 elm_gengrid_item_tooltip_content_cb_set(Elm_Gen_Item *it,
2395 Elm_Tooltip_Item_Content_Cb func,
2397 Evas_Smart_Cb del_cb)
2399 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(it, error);
2401 if ((it->tooltip.content_cb == func) && (it->tooltip.data == data))
2404 if (it->tooltip.del_cb)
2405 it->tooltip.del_cb((void *)it->tooltip.data,
2407 it->tooltip.content_cb = func;
2408 it->tooltip.data = data;
2409 it->tooltip.del_cb = del_cb;
2412 elm_widget_item_tooltip_content_cb_set(it,
2413 it->tooltip.content_cb,
2414 it->tooltip.data, NULL);
2415 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2416 elm_widget_item_tooltip_size_restrict_disable(it, it->tooltip.free_size);
2422 if (del_cb) del_cb((void *)data, NULL, NULL);
2426 elm_gengrid_item_tooltip_unset(Elm_Gen_Item *it)
2428 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2429 if ((VIEW(it)) && (it->tooltip.content_cb))
2430 elm_widget_item_tooltip_unset(it);
2432 if (it->tooltip.del_cb)
2433 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
2434 it->tooltip.del_cb = NULL;
2435 it->tooltip.content_cb = NULL;
2436 it->tooltip.data = NULL;
2437 it->tooltip.free_size = EINA_FALSE;
2438 if (it->tooltip.style)
2439 elm_gengrid_item_tooltip_style_set(it, NULL);
2443 elm_gengrid_item_tooltip_style_set(Elm_Gen_Item *it,
2446 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2447 eina_stringshare_replace(&it->tooltip.style, style);
2448 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
2452 elm_gengrid_item_tooltip_style_get(const Elm_Gen_Item *it)
2454 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2455 return it->tooltip.style;
2459 elm_gengrid_item_tooltip_size_restrict_disable(Elm_Gen_Item *it, Eina_Bool disable)
2461 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
2462 it->tooltip.free_size = disable;
2463 if (VIEW(it)) return elm_widget_item_tooltip_size_restrict_disable(it, disable);
2468 elm_gengrid_item_tooltip_size_restrict_disabled_get(const Elm_Gen_Item *it)
2470 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
2471 return it->tooltip.free_size;
2475 elm_gengrid_item_cursor_set(Elm_Gen_Item *it,
2478 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2479 eina_stringshare_replace(&it->mouse_cursor, cursor);
2480 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
2484 elm_gengrid_item_cursor_get(const Elm_Gen_Item *it)
2486 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2487 return elm_widget_item_cursor_get(it);
2491 elm_gengrid_item_cursor_unset(Elm_Gen_Item *it)
2493 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2494 if (!it->mouse_cursor)
2498 elm_widget_item_cursor_unset(it);
2500 eina_stringshare_del(it->mouse_cursor);
2501 it->mouse_cursor = NULL;
2505 elm_gengrid_item_cursor_style_set(Elm_Gen_Item *it,
2508 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2509 elm_widget_item_cursor_style_set(it, style);
2513 elm_gengrid_item_cursor_style_get(const Elm_Gen_Item *it)
2515 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2516 return elm_widget_item_cursor_style_get(it);
2520 elm_gengrid_item_cursor_engine_only_set(Elm_Gen_Item *it,
2521 Eina_Bool engine_only)
2523 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2524 elm_widget_item_cursor_engine_only_set(it, engine_only);
2528 elm_gengrid_item_cursor_engine_only_get(const Elm_Gen_Item *it)
2530 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
2531 return elm_widget_item_cursor_engine_only_get(it);
2535 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2536 Eina_Bool reorder_mode)
2538 ELM_CHECK_WIDTYPE(obj, widtype);
2539 Widget_Data *wd = elm_widget_data_get(obj);
2541 wd->reorder_mode = reorder_mode;
2545 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2547 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2548 Widget_Data *wd = elm_widget_data_get(obj);
2549 if (!wd) return EINA_FALSE;
2550 return wd->reorder_mode;
2554 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2555 Eina_Bool always_select)
2557 elm_genlist_always_select_mode_set(obj, always_select);
2561 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2563 return elm_genlist_always_select_mode_get(obj);
2567 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2568 Eina_Bool no_select)
2570 elm_genlist_no_select_mode_set(obj, no_select);
2574 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2576 return elm_genlist_no_select_mode_get(obj);
2580 elm_gengrid_bounce_set(Evas_Object *obj,
2584 elm_genlist_bounce_set(obj, h_bounce, v_bounce);
2588 elm_gengrid_bounce_get(const Evas_Object *obj,
2589 Eina_Bool *h_bounce,
2590 Eina_Bool *v_bounce)
2592 elm_genlist_bounce_get(obj, h_bounce, v_bounce);
2596 elm_gengrid_page_relative_set(Evas_Object *obj,
2600 _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
2604 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2606 _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
2610 elm_gengrid_page_size_set(Evas_Object *obj,
2611 Evas_Coord h_pagesize,
2612 Evas_Coord v_pagesize)
2614 _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
2618 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2620 _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
2624 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2626 _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
2630 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2632 _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
2636 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2638 _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
2642 elm_gengrid_first_item_get(const Evas_Object *obj)
2644 return elm_genlist_first_item_get(obj);
2648 elm_gengrid_last_item_get(const Evas_Object *obj)
2650 return elm_genlist_last_item_get(obj);
2654 elm_gengrid_item_next_get(const Elm_Gen_Item *it)
2656 return elm_genlist_item_next_get(it);
2660 elm_gengrid_item_prev_get(const Elm_Gen_Item *it)
2662 return elm_genlist_item_prev_get(it);
2666 elm_gengrid_item_gengrid_get(const Elm_Gen_Item *it)
2668 return _elm_genlist_item_widget_get(it);
2672 elm_gengrid_item_show(Elm_Gen_Item *it)
2674 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2675 Widget_Data *wd = it->wd;
2676 Evas_Coord minx = 0, miny = 0;
2679 if ((!it) || (it->generation < it->wd->generation)) return;
2680 _pan_min_get(wd->pan_smart, &minx, &miny);
2683 elm_smart_scroller_region_bring_in(it->wd->scr,
2684 ((it->x - it->item->prev_group) * wd->item_width) + (it->item->prev_group * it->wd->group_item_width) + minx,
2685 it->y * wd->item_height + miny,
2687 it->wd->item_height);
2689 elm_smart_scroller_region_bring_in(it->wd->scr,
2690 it->x * wd->item_width + minx,
2691 ((it->y - it->item->prev_group)* wd->item_height) + (it->item->prev_group * it->wd->group_item_height) + miny,
2693 it->wd->item_height);
2697 elm_gengrid_item_bring_in(Elm_Gen_Item *it)
2699 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2700 if (it->generation < it->wd->generation) return;
2702 Evas_Coord minx = 0, miny = 0;
2703 Widget_Data *wd = it->wd;
2705 _pan_min_get(wd->pan_smart, &minx, &miny);
2708 elm_smart_scroller_region_bring_in(it->wd->scr,
2709 ((it->x - it->item->prev_group) * wd->item_width) + (it->item->prev_group * it->wd->group_item_width) + minx,
2710 it->y * wd->item_height + miny,
2712 it->wd->item_height);
2714 elm_smart_scroller_region_bring_in(it->wd->scr,
2715 it->x * wd->item_width + minx,
2716 ((it->y - it->item->prev_group)* wd->item_height) + (it->item->prev_group * it->wd->group_item_height) + miny,
2718 it->wd->item_height);