1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
7 * Handle non-homogeneous objects too.
10 typedef struct _Widget_Data Widget_Data;
11 typedef struct _Pan Pan;
14 #define REORDER_EFFECT_TIME 0.5
16 struct _Elm_Gengrid_Item
21 const Elm_Gengrid_Item_Class *gic;
22 Elm_Gengrid_Item *parent_group_item;
23 Ecore_Timer *long_timer;
24 Ecore_Animator *item_moving_effect_timer;
26 Eina_List *labels, *icons, *states, *icon_objs;
33 Evas_Coord x, y, gx, gy, dx, dy, ox, oy, tx, ty, rx, ry;
34 unsigned int moving_effect_start_time;
42 Elm_Tooltip_Item_Content_Cb content_cb;
45 Eina_Bool free_size : 1;
48 const char *mouse_cursor;
50 Eina_Bool is_group : 1;
51 Eina_Bool want_unrealize : 1;
52 Eina_Bool group_realized : 1;
53 Eina_Bool realized : 1;
54 Eina_Bool dragging : 1;
56 Eina_Bool delete_me : 1;
57 Eina_Bool display_only : 1;
58 Eina_Bool disabled : 1;
59 Eina_Bool selected : 1;
60 Eina_Bool highlighted : 1;
66 Eina_Inlist_Sorted_State *state;
67 Evas_Object *self, *scr;
68 Evas_Object *pan_smart;
71 Eina_List *group_items;
74 Elm_Gengrid_Item *last_selected_item, *reorder_item;
75 double align_x, align_y;
77 Evas_Coord pan_x, pan_y, old_pan_x, old_pan_y;
78 Evas_Coord item_width, item_height; /* Each item size */
79 Evas_Coord group_item_width, group_item_height; /* Each group item size */
80 Evas_Coord minw, minh; /* Total obj size */
81 Evas_Coord reorder_item_x, reorder_item_y;
87 Eina_Bool horizontal : 1;
88 Eina_Bool on_hold : 1;
89 Eina_Bool longpressed : 1;
91 Eina_Bool no_select : 1;
92 Eina_Bool wasselected : 1;
93 Eina_Bool always_select : 1;
94 Eina_Bool clear_me : 1;
95 Eina_Bool h_bounce : 1;
96 Eina_Bool v_bounce : 1;
97 Eina_Bool reorder_mode : 1;
98 Eina_Bool reorder_item_changed : 1;
99 Eina_Bool move_effect_enabled : 1;
102 #define ELM_GENGRID_ITEM_FROM_INLIST(item) \
103 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
107 Evas_Object_Smart_Clipped_Data __clipped_data;
111 static const char *widtype = NULL;
112 static void _item_highlight(Elm_Gengrid_Item *item);
113 static void _item_unrealize(Elm_Gengrid_Item *item);
114 static void _item_select(Elm_Gengrid_Item *item);
115 static void _item_unselect(Elm_Gengrid_Item *item);
116 static void _calc_job(void *data);
117 static void _on_focus_hook(void *data,
119 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
120 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
121 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
122 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
123 static Eina_Bool _item_single_select_up(Widget_Data *wd);
124 static Eina_Bool _item_single_select_down(Widget_Data *wd);
125 static Eina_Bool _item_single_select_left(Widget_Data *wd);
126 static Eina_Bool _item_single_select_right(Widget_Data *wd);
127 static Eina_Bool _event_hook(Evas_Object *obj,
129 Evas_Callback_Type type,
131 static Eina_Bool _deselect_all_items(Widget_Data *wd);
133 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
134 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
136 static const char SIG_ACTIVATED[] = "activated";
137 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
138 static const char SIG_LONGPRESSED[] = "longpressed";
139 static const char SIG_SELECTED[] = "selected";
140 static const char SIG_UNSELECTED[] = "unselected";
141 static const char SIG_REALIZED[] = "realized";
142 static const char SIG_UNREALIZED[] = "unrealized";
143 static const char SIG_CHANGED[] = "changed";
144 static const char SIG_DRAG_START_UP[] = "drag,start,up";
145 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
146 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
147 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
148 static const char SIG_DRAG_STOP[] = "drag,stop";
149 static const char SIG_DRAG[] = "drag";
150 static const char SIG_SCROLL[] = "scroll";
151 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
152 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
153 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
154 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
155 static const char SIG_MOVED[] = "moved";
157 static const Evas_Smart_Cb_Description _signals[] = {
159 {SIG_CLICKED_DOUBLE, ""},
160 {SIG_LONGPRESSED, ""},
162 {SIG_UNSELECTED, ""},
164 {SIG_UNREALIZED, ""},
166 {SIG_DRAG_START_UP, ""},
167 {SIG_DRAG_START_DOWN, ""},
168 {SIG_DRAG_START_LEFT, ""},
169 {SIG_DRAG_START_RIGHT, ""},
173 {SIG_SCROLL_ANIM_START, ""},
174 {SIG_SCROLL_ANIM_STOP, ""},
175 {SIG_SCROLL_DRAG_START, ""},
176 {SIG_SCROLL_DRAG_STOP, ""},
181 static Eina_Compare_Cb _elm_gengrid_item_compare_cb;
182 static Eina_Compare_Cb _elm_gengrid_item_compare_data_cb;
185 _event_hook(Evas_Object *obj,
186 Evas_Object *src __UNUSED__,
187 Evas_Callback_Type type,
190 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
191 Evas_Event_Key_Down *ev = event_info;
192 Widget_Data *wd = elm_widget_data_get(obj);
193 if (!wd) return EINA_FALSE;
194 if (!wd->items) return EINA_FALSE;
195 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
196 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
198 Elm_Gengrid_Item *item = NULL;
201 Evas_Coord step_x = 0;
202 Evas_Coord step_y = 0;
205 Evas_Coord page_x = 0;
206 Evas_Coord page_y = 0;
208 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
209 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
210 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
211 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
213 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
215 if ((wd->horizontal) &&
216 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
217 (_item_multi_select_up(wd)))
218 || (_item_single_select_up(wd))))
220 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
223 else if ((!wd->horizontal) &&
224 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
225 (_item_multi_select_left(wd)))
226 || (_item_single_select_left(wd))))
228 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
234 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
236 if ((wd->horizontal) &&
237 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
238 (_item_multi_select_down(wd)))
239 || (_item_single_select_down(wd))))
241 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
244 else if ((!wd->horizontal) &&
245 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
246 (_item_multi_select_right(wd)))
247 || (_item_single_select_right(wd))))
249 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
255 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
257 if ((wd->horizontal) &&
258 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
259 (_item_multi_select_left(wd)))
260 || (_item_single_select_left(wd))))
262 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
265 else if ((!wd->horizontal) &&
266 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
267 (_item_multi_select_up(wd)))
268 || (_item_single_select_up(wd))))
270 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
276 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
278 if ((wd->horizontal) &&
279 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
280 (_item_multi_select_right(wd)))
281 || (_item_single_select_right(wd))))
283 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
286 else if ((!wd->horizontal) &&
287 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
288 (_item_multi_select_down(wd)))
289 || (_item_single_select_down(wd))))
291 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
297 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
299 item = elm_gengrid_first_item_get(obj);
300 elm_gengrid_item_bring_in(item);
301 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
304 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
306 item = elm_gengrid_last_item_get(obj);
307 elm_gengrid_item_bring_in(item);
308 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
311 else if ((!strcmp(ev->keyname, "Prior")) ||
312 (!strcmp(ev->keyname, "KP_Prior")))
317 x -= -(page_x * v_w) / 100;
324 y -= -(page_y * v_h) / 100;
329 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
334 x += -(page_x * v_w) / 100;
341 y += -(page_y * v_h) / 100;
346 else if (!strcmp(ev->keyname, "Escape"))
348 if (!_deselect_all_items(wd)) return EINA_FALSE;
349 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
352 else if ((!strcmp(ev->keyname, "Return")) ||
353 (!strcmp(ev->keyname, "KP_Enter")) ||
354 (!strcmp(ev->keyname, "space")))
356 item = elm_gengrid_selected_item_get(obj);
357 evas_object_smart_callback_call(item->wd->self, SIG_ACTIVATED, item);
359 else return EINA_FALSE;
361 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
362 elm_smart_scroller_child_pos_set(wd->scr, x, y);
367 _deselect_all_items(Widget_Data *wd)
369 if (!wd->selected) return EINA_FALSE;
371 elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
377 _item_multi_select_left(Widget_Data *wd)
379 if (!wd->selected) return EINA_FALSE;
381 Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
382 if (!prev) return EINA_TRUE;
383 if (elm_gengrid_item_selected_get(prev))
385 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
386 wd->last_selected_item = prev;
387 elm_gengrid_item_show(wd->last_selected_item);
391 elm_gengrid_item_selected_set(prev, EINA_TRUE);
392 elm_gengrid_item_show(prev);
399 _item_multi_select_right(Widget_Data *wd)
401 if (!wd->selected) return EINA_FALSE;
403 Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
404 if (!next) return EINA_TRUE;
405 if (elm_gengrid_item_selected_get(next))
407 elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
408 wd->last_selected_item = next;
409 elm_gengrid_item_show(wd->last_selected_item);
413 elm_gengrid_item_selected_set(next, EINA_TRUE);
414 elm_gengrid_item_show(next);
421 _item_multi_select_up(Widget_Data *wd)
424 Eina_Bool r = EINA_TRUE;
426 if (!wd->selected) return EINA_FALSE;
428 for (i = 0; (r) && (i < wd->nmax); i++)
429 r &= _item_multi_select_left(wd);
435 _item_multi_select_down(Widget_Data *wd)
438 Eina_Bool r = EINA_TRUE;
440 if (!wd->selected) return EINA_FALSE;
442 for (i = 0; (r) && (i < wd->nmax); i++)
443 r &= _item_multi_select_right(wd);
449 _item_single_select_up(Widget_Data *wd)
453 Elm_Gengrid_Item *prev;
457 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
458 while ((prev) && (prev->delete_me))
459 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
460 elm_gengrid_item_selected_set(prev, EINA_TRUE);
461 elm_gengrid_item_show(prev);
464 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
466 if (!prev) return EINA_FALSE;
468 for (i = 1; i < wd->nmax; i++)
470 Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
471 if (!tmp) return EINA_FALSE;
475 _deselect_all_items(wd);
477 elm_gengrid_item_selected_set(prev, EINA_TRUE);
478 elm_gengrid_item_show(prev);
483 _item_single_select_down(Widget_Data *wd)
487 Elm_Gengrid_Item *next;
491 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
492 while ((next) && (next->delete_me))
493 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
494 elm_gengrid_item_selected_set(next, EINA_TRUE);
495 elm_gengrid_item_show(next);
498 else next = elm_gengrid_item_next_get(wd->last_selected_item);
500 if (!next) return EINA_FALSE;
502 for (i = 1; i < wd->nmax; i++)
504 Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
505 if (!tmp) return EINA_FALSE;
509 _deselect_all_items(wd);
511 elm_gengrid_item_selected_set(next, EINA_TRUE);
512 elm_gengrid_item_show(next);
517 _item_single_select_left(Widget_Data *wd)
519 Elm_Gengrid_Item *prev;
522 prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
523 while ((prev) && (prev->delete_me))
524 prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
526 else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
528 if (!prev) return EINA_FALSE;
530 _deselect_all_items(wd);
532 elm_gengrid_item_selected_set(prev, EINA_TRUE);
533 elm_gengrid_item_show(prev);
538 _item_single_select_right(Widget_Data *wd)
540 Elm_Gengrid_Item *next;
543 next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
544 while ((next) && (next->delete_me))
545 next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
547 else next = elm_gengrid_item_next_get(wd->last_selected_item);
549 if (!next) return EINA_FALSE;
551 _deselect_all_items(wd);
553 elm_gengrid_item_selected_set(next, EINA_TRUE);
554 elm_gengrid_item_show(next);
559 _on_focus_hook(void *data __UNUSED__,
562 Widget_Data *wd = elm_widget_data_get(obj);
564 if (elm_widget_focus_get(obj))
566 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
567 evas_object_focus_set(wd->self, EINA_TRUE);
568 if ((wd->selected) && (!wd->last_selected_item))
569 wd->last_selected_item = eina_list_data_get(wd->selected);
573 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
574 evas_object_focus_set(wd->self, EINA_FALSE);
579 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
581 Widget_Data *wd = elm_widget_data_get(obj);
582 Elm_Gengrid_Item *item;
584 elm_smart_scroller_mirrored_set(wd->scr, rtl);
585 if (!wd->items) return;
586 item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
590 edje_object_mirrored_set(item->base.view, rtl);
591 elm_gengrid_item_update(item);
592 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
597 _theme_hook(Evas_Object *obj)
599 Widget_Data *wd = elm_widget_data_get(obj);
601 _elm_widget_mirrored_reload(obj);
602 _mirrored_set(obj, elm_widget_mirrored_get(obj));
603 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
604 elm_widget_style_get(obj));
608 _del_pre_hook(Evas_Object *obj)
610 Widget_Data *wd = elm_widget_data_get(obj);
612 elm_gengrid_clear(obj);
613 evas_object_del(wd->pan_smart);
614 wd->pan_smart = NULL;
618 _del_hook(Evas_Object *obj)
620 Widget_Data *wd = elm_widget_data_get(obj);
625 _signal_emit_hook(Evas_Object *obj,
626 const char *emission,
629 Widget_Data *wd = elm_widget_data_get(obj);
631 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
636 _mouse_move(void *data,
637 Evas *evas __UNUSED__,
641 Elm_Gengrid_Item *item = data;
642 Evas_Event_Mouse_Move *ev = event_info;
643 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
644 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
646 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
648 if (!item->wd->on_hold)
650 item->wd->on_hold = EINA_TRUE;
651 if (!item->wd->wasselected)
652 _item_unselect(item);
655 if ((item->dragging) && (item->down))
657 if (item->long_timer)
659 ecore_timer_del(item->long_timer);
660 item->long_timer = NULL;
662 evas_object_smart_callback_call(item->wd->self, SIG_DRAG, item);
665 if ((!item->down) || (item->wd->longpressed))
667 if (item->long_timer)
669 ecore_timer_del(item->long_timer);
670 item->long_timer = NULL;
672 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
674 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &ow, &oh);
676 it_scrl_x = ev->cur.canvas.x - item->wd->reorder_item->dx;
677 it_scrl_y = ev->cur.canvas.y - item->wd->reorder_item->dy;
679 if (it_scrl_x < ox) item->wd->reorder_item_x = ox;
680 else if (it_scrl_x + item->wd->item_width > ox + ow)
681 item->wd->reorder_item_x = ox + ow - item->wd->item_width;
682 else item->wd->reorder_item_x = it_scrl_x;
684 if (it_scrl_y < oy) item->wd->reorder_item_y = oy;
685 else if (it_scrl_y + item->wd->item_height > oy + oh)
686 item->wd->reorder_item_y = oy + oh - item->wd->item_height;
687 else item->wd->reorder_item_y = it_scrl_y;
689 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
690 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
694 if (!item->display_only)
695 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
696 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
697 x = ev->cur.canvas.x - x;
698 y = ev->cur.canvas.y - y;
701 if (adx < 0) adx = -dx;
704 if (ady < 0) ady = -dy;
707 if ((adx > minw) || (ady > minh))
709 const char *left_drag, *right_drag;
710 if (!elm_widget_mirrored_get(item->wd->self))
712 left_drag = SIG_DRAG_START_LEFT;
713 right_drag = SIG_DRAG_START_RIGHT;
717 left_drag = SIG_DRAG_START_RIGHT;
718 right_drag = SIG_DRAG_START_LEFT;
722 if (item->long_timer)
724 ecore_timer_del(item->long_timer);
725 item->long_timer = NULL;
727 if (!item->wd->wasselected)
728 _item_unselect(item);
732 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_START_UP,
737 evas_object_smart_callback_call(item->wd->self,
744 evas_object_smart_callback_call(item->wd->self,
745 SIG_DRAG_START_DOWN, item);
749 evas_object_smart_callback_call(item->wd->self,
752 evas_object_smart_callback_call(item->wd->self,
760 _long_press(void *data)
762 Elm_Gengrid_Item *item = data;
764 item->long_timer = NULL;
765 if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
766 item->wd->longpressed = EINA_TRUE;
767 evas_object_smart_callback_call(item->wd->self, SIG_LONGPRESSED, item);
768 if (item->wd->reorder_mode)
770 item->wd->reorder_item = item;
771 evas_object_raise(item->base.view);
772 elm_smart_scroller_hold_set(item->wd->scr, EINA_TRUE);
773 elm_smart_scroller_bounce_allow_set(item->wd->scr, EINA_FALSE, EINA_FALSE);
774 edje_object_signal_emit(item->base.view, "elm,state,reorder,enabled", "elm");
776 return ECORE_CALLBACK_CANCEL;
780 _mouse_down(void *data,
781 Evas *evas __UNUSED__,
785 Elm_Gengrid_Item *item = data;
786 Evas_Event_Mouse_Down *ev = event_info;
789 if (ev->button != 1) return;
792 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
793 item->dx = ev->canvas.x - x;
794 item->dy = ev->canvas.y - y;
795 item->wd->longpressed = EINA_FALSE;
796 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
797 else item->wd->on_hold = EINA_FALSE;
798 item->wd->wasselected = item->selected;
799 _item_highlight(item);
800 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
802 evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
803 evas_object_smart_callback_call(item->wd->self, SIG_ACTIVATED, item);
805 if (item->long_timer) ecore_timer_del(item->long_timer);
807 item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
810 item->long_timer = NULL;
814 _mouse_up(void *data,
815 Evas *evas __UNUSED__,
816 Evas_Object *obj __UNUSED__,
819 Elm_Gengrid_Item *item = data;
820 Evas_Event_Mouse_Up *ev = event_info;
821 Eina_Bool dragged = EINA_FALSE;
823 if (ev->button != 1) return;
824 item->down = EINA_FALSE;
825 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) item->wd->on_hold = EINA_TRUE;
826 else item->wd->on_hold = EINA_FALSE;
827 if (item->long_timer)
829 ecore_timer_del(item->long_timer);
830 item->long_timer = NULL;
834 item->dragging = EINA_FALSE;
835 evas_object_smart_callback_call(item->wd->self, SIG_DRAG_STOP, item);
838 if (item->wd->on_hold)
840 item->wd->longpressed = EINA_FALSE;
841 item->wd->on_hold = EINA_FALSE;
844 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
846 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
847 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
849 evas_object_smart_callback_call(item->wd->self, SIG_MOVED, item->wd->reorder_item);
850 item->wd->reorder_item = NULL;
851 elm_smart_scroller_hold_set(item->wd->scr, EINA_FALSE);
852 elm_smart_scroller_bounce_allow_set(item->wd->scr, item->wd->h_bounce, item->wd->v_bounce);
853 edje_object_signal_emit(item->base.view, "elm,state,reorder,disabled", "elm");
855 if (item->wd->longpressed)
857 item->wd->longpressed = EINA_FALSE;
858 if (!item->wd->wasselected) _item_unselect(item);
859 item->wd->wasselected = EINA_FALSE;
864 if (item->want_unrealize) _item_unrealize(item);
866 if ((item->disabled) || (dragged)) return;
871 _item_highlight(item);
874 else _item_unselect(item);
880 while (item->wd->selected)
881 _item_unselect(item->wd->selected->data);
885 const Eina_List *l, *l_next;
886 Elm_Gengrid_Item *item2;
888 EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
889 if (item2 != item) _item_unselect(item2);
891 _item_highlight(item);
897 _item_highlight(Elm_Gengrid_Item *item)
899 if ((item->wd->no_select) || (item->delete_me) || (item->highlighted)) return;
900 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
901 item->highlighted = EINA_TRUE;
905 _item_realize(Elm_Gengrid_Item *item)
910 if ((item->realized) || (item->delete_me)) return;
911 item->base.view = edje_object_add(evas_object_evas_get(item->wd->self));
912 edje_object_scale_set(item->base.view, elm_widget_scale_get(item->wd->self) *
914 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
915 evas_object_smart_member_add(item->base.view, item->wd->pan_smart);
916 elm_widget_sub_object_add(item->wd->self, item->base.view);
917 snprintf(style, sizeof(style), "item/%s",
918 item->gic->item_style ? item->gic->item_style : "default");
919 _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
920 elm_widget_style_get(item->wd->self));
922 evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
923 evas_object_color_set(item->spacer, 0, 0, 0, 0);
924 elm_widget_sub_object_add(item->wd->self, item->spacer);
925 evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
926 edje_object_part_swallow(item->base.view, "elm.swallow.pad", item->spacer);
928 if (item->gic->func.label_get)
934 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
936 EINA_LIST_FOREACH(item->labels, l, key)
938 char *s = item->gic->func.label_get
939 ((void *)item->base.data, item->wd->self, l->data);
942 edje_object_part_text_set(item->base.view, l->data, s);
948 if (item->gic->func.icon_get)
954 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
956 EINA_LIST_FOREACH(item->icons, l, key)
958 Evas_Object *ic = item->gic->func.icon_get
959 ((void *)item->base.data, item->wd->self, l->data);
962 item->icon_objs = eina_list_append(item->icon_objs, ic);
963 edje_object_part_swallow(item->base.view, key, ic);
964 evas_object_show(ic);
965 elm_widget_sub_object_add(item->wd->self, ic);
970 if (item->gic->func.state_get)
976 elm_widget_stringlist_get(edje_object_data_get(item->base.view,
978 EINA_LIST_FOREACH(item->states, l, key)
980 Eina_Bool on = item->gic->func.state_get
981 ((void *)item->base.data, item->wd->self, l->data);
984 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
985 edje_object_signal_emit(item->base.view, buf, "elm");
992 if ((!item->wd->group_item_width) && (!item->wd->group_item_height))
994 edje_object_size_min_restricted_calc(item->base.view,
995 &item->wd->group_item_width,
996 &item->wd->group_item_height,
997 item->wd->group_item_width,
998 item->wd->group_item_height);
1003 if ((!item->wd->item_width) && (!item->wd->item_height))
1005 edje_object_size_min_restricted_calc(item->base.view,
1006 &item->wd->item_width,
1007 &item->wd->item_height,
1008 item->wd->item_width,
1009 item->wd->item_height);
1010 elm_coords_finger_size_adjust(1, &item->wd->item_width,
1011 1, &item->wd->item_height);
1014 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1016 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_UP,
1018 evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1022 edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
1024 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
1026 evas_object_show(item->base.view);
1028 if (item->tooltip.content_cb)
1030 elm_widget_item_tooltip_content_cb_set(item,
1031 item->tooltip.content_cb,
1032 item->tooltip.data, NULL);
1033 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
1034 elm_widget_item_tooltip_size_restrict_disable(item, item->tooltip.free_size);
1037 if (item->mouse_cursor)
1038 elm_widget_item_cursor_set(item, item->mouse_cursor);
1040 item->realized = EINA_TRUE;
1041 item->want_unrealize = EINA_FALSE;
1045 _item_unrealize(Elm_Gengrid_Item *item)
1049 if (!item->realized) return;
1050 if (item->long_timer)
1052 ecore_timer_del(item->long_timer);
1053 item->long_timer = NULL;
1055 evas_object_del(item->base.view);
1056 item->base.view = NULL;
1057 evas_object_del(item->spacer);
1058 item->spacer = NULL;
1059 elm_widget_stringlist_free(item->labels);
1060 item->labels = NULL;
1061 elm_widget_stringlist_free(item->icons);
1063 elm_widget_stringlist_free(item->states);
1064 item->states = NULL;
1066 EINA_LIST_FREE(item->icon_objs, icon)
1067 evas_object_del(icon);
1069 item->realized = EINA_FALSE;
1070 item->want_unrealize = EINA_FALSE;
1074 _reorder_item_moving_effect_timer_cb(void *data)
1076 Elm_Gengrid_Item *item = data;
1080 time = REORDER_EFFECT_TIME;
1081 t = ((0.0 > (t = ecore_loop_time_get()-item->moving_effect_start_time)) ? 0.0 : t);
1082 dx = ((item->tx - item->ox) / 10) * _elm_config->scale;
1083 dy = ((item->ty - item->oy) / 10) * _elm_config->scale;
1087 item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
1088 item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
1096 if ((((dx > 0) && (item->rx >= item->tx)) || ((dx <= 0) && (item->rx <= item->tx))) &&
1097 (((dy > 0) && (item->ry >= item->ty)) || ((dy <= 0) && (item->ry <= item->ty))))
1099 evas_object_move(item->base.view, item->tx, item->ty);
1103 evas_object_geometry_get(item->wd->pan_smart, NULL, NULL, &vw, &vh);
1104 if (item->wd->horizontal)
1105 evas_object_resize(item->base.view, item->wd->group_item_width, vh);
1107 evas_object_resize(item->base.view, vw, item->wd->group_item_height);
1110 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1111 item->moving = EINA_FALSE;
1112 item->item_moving_effect_timer = NULL;
1113 return ECORE_CALLBACK_CANCEL;
1116 evas_object_move(item->base.view, item->rx, item->ry);
1120 evas_object_geometry_get(item->wd->pan_smart, NULL, NULL, &vw, &vh);
1121 if (item->wd->horizontal)
1122 evas_object_resize(item->base.view, item->wd->group_item_width, vh);
1124 evas_object_resize(item->base.view, vw, item->wd->group_item_height);
1127 evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
1129 return ECORE_CALLBACK_RENEW;
1133 _group_item_place(Pan *sd)
1135 Evas_Coord iw, ih, vw, vh;
1137 Eina_Bool was_realized;
1138 Elm_Gengrid_Item *it;
1139 evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1140 if (sd->wd->horizontal)
1142 iw = sd->wd->group_item_width;
1148 ih = sd->wd->group_item_height;
1150 EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1152 was_realized = it->realized;
1153 if (it->group_realized)
1157 evas_object_smart_callback_call(it->wd->self, SIG_REALIZED, it);
1158 evas_object_move(it->base.view, it->gx, it->gy);
1159 evas_object_resize(it->base.view, iw, ih);
1160 evas_object_raise(it->base.view);
1164 _item_unrealize(it);
1166 evas_object_smart_callback_call(it->wd->self, SIG_UNREALIZED, it);
1173 _item_place(Elm_Gengrid_Item *item,
1177 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1178 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1179 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1183 evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
1185 /* Preload rows/columns at each side of the Gengrid */
1186 cvx = ox - PRELOAD * item->wd->item_width;
1187 cvy = oy - PRELOAD * item->wd->item_height;
1188 cvw = vw + 2 * PRELOAD * item->wd->item_width;
1189 cvh = vh + 2 * PRELOAD * item->wd->item_height;
1194 items_count = item->wd->count - eina_list_count(item->wd->group_items) + item->wd->items_lost;
1195 if (item->wd->horizontal)
1197 int columns, items_visible = 0, items_row;
1199 if (item->wd->item_height > 0)
1200 items_visible = vh / item->wd->item_height;
1201 if (items_visible < 1)
1204 columns = items_count / items_visible;
1205 if (items_count % items_visible)
1208 tcw = (item->wd->item_width * columns) + (item->wd->group_item_width * eina_list_count(item->wd->group_items));
1209 alignw = (vw - tcw) * item->wd->align_x;
1211 items_row = items_visible;
1212 if (items_row > item->wd->count)
1213 items_row = item->wd->count;
1214 tch = items_row * item->wd->item_height;
1215 alignh = (vh - tch) * item->wd->align_y;
1219 int rows, items_visible = 0, items_col;
1221 if (item->wd->item_width > 0)
1222 items_visible = vw / item->wd->item_width;
1223 if (items_visible < 1)
1226 rows = items_count / items_visible;
1227 if (items_count % items_visible)
1230 tch = (item->wd->item_height * rows) + (item->wd->group_item_height * eina_list_count(item->wd->group_items));
1231 alignh = (vh - tch) * item->wd->align_y;
1233 items_col = items_visible;
1234 if (items_col > item->wd->count)
1235 items_col = item->wd->count;
1236 tcw = items_col * item->wd->item_width;
1237 alignw = (vw - tcw) * item->wd->align_x;
1242 if (item->wd->horizontal)
1244 x = (((cx - item->prev_group) * item->wd->item_width) + (item->prev_group * item->wd->group_item_width)) - item->wd->pan_x + ox + alignw;
1246 iw = item->wd->group_item_width;
1252 y = (((cy - item->prev_group) * item->wd->item_height) + (item->prev_group * item->wd->group_item_height)) - item->wd->pan_y + oy + alignh;
1254 ih = item->wd->group_item_height;
1261 if (item->wd->horizontal)
1263 x = (((cx - item->prev_group) * item->wd->item_width) + (item->prev_group * item->wd->group_item_width)) - item->wd->pan_x + ox + alignw;
1264 y = (cy * item->wd->item_height) - item->wd->pan_y + oy + alignh;
1268 x = (cx * item->wd->item_height) - item->wd->pan_x + ox + alignw;
1269 y = (((cy - item->prev_group) * item->wd->item_height) + (item->prev_group * item->wd->group_item_height)) - item->wd->pan_y + oy + alignh;
1271 if (elm_widget_mirrored_get(item->wd->self))
1272 { /* Switch items side and componsate for pan_x when in RTL mode */
1273 evas_object_geometry_get(item->wd->self, NULL, NULL, &ww, NULL);
1274 x = ww - x - item->wd->item_width - item->wd->pan_x - item->wd->pan_x;
1276 iw = item->wd->item_width;
1277 ih = item->wd->item_height;
1280 Eina_Bool was_realized = item->realized;
1281 if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1283 _item_realize(item);
1285 evas_object_smart_callback_call(item->wd->self, SIG_REALIZED, item);
1286 if (item->parent_group_item)
1288 if (item->wd->horizontal)
1290 if (item->parent_group_item->gx < 0)
1292 item->parent_group_item->gx = x + item->wd->item_width - item->wd->group_item_width;
1293 if (item->parent_group_item->gx > 0)
1294 item->parent_group_item->gx = 0;
1299 if (item->parent_group_item->gy < 0)
1301 item->parent_group_item->gy = y + item->wd->item_height - item->wd->group_item_height;
1302 if (item->parent_group_item->gy > 0)
1303 item->parent_group_item->gy = 0;
1305 item->parent_group_item->group_realized = EINA_TRUE;
1308 if ((item->wd->reorder_mode) && (item->wd->reorder_item))
1310 if (item->moving) return;
1312 if (!item->wd->move_effect_enabled)
1317 if (item->wd->reorder_item == item)
1319 evas_object_move(item->base.view,
1320 item->wd->reorder_item_x, item->wd->reorder_item_y);
1321 evas_object_resize(item->base.view, iw, ih);
1326 if (item->wd->move_effect_enabled)
1328 if ((item->ox != x) || (item->oy != y))
1330 if (((item->wd->old_pan_x == item->wd->pan_x) && (item->wd->old_pan_y == item->wd->pan_y)) ||
1331 ((item->wd->old_pan_x != item->wd->pan_x) && !(item->ox - item->wd->pan_x + item->wd->old_pan_x == x)) ||
1332 ((item->wd->old_pan_y != item->wd->pan_y) && !(item->oy - item->wd->pan_y + item->wd->old_pan_y == y)))
1336 item->rx = item->ox;
1337 item->ry = item->oy;
1338 item->moving = EINA_TRUE;
1339 item->moving_effect_start_time = ecore_loop_time_get();
1340 item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, item);
1347 Evas_Coord nx, ny, nw, nh;
1350 if (item->wd->horizontal)
1352 nx = x + (item->wd->group_item_width / 2);
1360 ny = y + (item->wd->group_item_height / 2);
1367 nx = x + (item->wd->item_width / 2);
1368 ny = y + (item->wd->item_height / 2);
1373 if ( ELM_RECTS_INTERSECT(item->wd->reorder_item_x, item->wd->reorder_item_y,
1374 item->wd->item_width, item->wd->item_height,
1377 if (item->wd->horizontal)
1379 if ((item->wd->nmax * item->wd->reorder_item->x + item->wd->reorder_item->y) >
1380 (item->wd->nmax * item->x + item->y))
1381 reorder_item_move_forward = EINA_TRUE;
1385 if ((item->wd->nmax * item->wd->reorder_item->y + item->wd->reorder_item->x) >
1386 (item->wd->nmax * item->y + item->x))
1387 reorder_item_move_forward = EINA_TRUE;
1390 item->wd->items = eina_inlist_remove(item->wd->items,
1391 EINA_INLIST_GET(item->wd->reorder_item));
1392 if (reorder_item_move_forward)
1393 item->wd->items = eina_inlist_prepend_relative(item->wd->items,
1394 EINA_INLIST_GET(item->wd->reorder_item),
1395 EINA_INLIST_GET(item));
1397 item->wd->items = eina_inlist_append_relative(item->wd->items,
1398 EINA_INLIST_GET(item->wd->reorder_item),
1399 EINA_INLIST_GET(item));
1401 item->wd->reorder_item_changed = EINA_TRUE;
1402 item->wd->move_effect_enabled = EINA_TRUE;
1403 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1404 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1410 if (!item->is_group)
1412 evas_object_move(item->base.view, x, y);
1413 evas_object_resize(item->base.view, iw, ih);
1416 item->group_realized = EINA_TRUE;
1420 if (!item->is_group)
1422 _item_unrealize(item);
1424 evas_object_smart_callback_call(item->wd->self, SIG_UNREALIZED, item);
1427 item->group_realized = EINA_FALSE;
1432 _item_label_hook(Elm_Gengrid_Item *it, const char *part)
1434 if (!it->gic->func.label_get) return NULL;
1435 return edje_object_part_text_get(it->base.view, part);
1438 static Elm_Gengrid_Item *
1439 _item_create(Widget_Data *wd,
1440 const Elm_Gengrid_Item_Class *gic,
1443 const void *func_data)
1445 Elm_Gengrid_Item *item;
1447 item = elm_widget_item_new(wd->self, Elm_Gengrid_Item);
1448 if (!item) return NULL;
1452 item->base.data = data;
1453 item->func.func = func;
1454 item->func.data = func_data;
1455 item->mouse_cursor = NULL;
1456 item->is_group = !strcmp(item->gic->item_style, "group_index");
1457 elm_widget_item_text_get_hook_set(item, _item_label_hook);
1463 _item_del(Elm_Gengrid_Item *item)
1465 elm_widget_item_pre_notify_del(item);
1467 item->wd->selected = eina_list_remove(item->wd->selected, item);
1468 if (item->realized) _item_unrealize(item);
1469 if ((!item->delete_me) && (item->gic->func.del))
1470 item->gic->func.del((void *)item->base.data, item->wd->self);
1471 item->delete_me = EINA_TRUE;
1472 item->wd->items = eina_inlist_remove(item->wd->items, EINA_INLIST_GET(item));
1473 if (item->long_timer) ecore_timer_del(item->long_timer);
1474 if (item->tooltip.del_cb)
1475 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
1476 item->wd->walking -= item->walking;
1479 item->wd->group_items = eina_list_remove(item->wd->group_items, item);
1480 if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
1481 item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
1482 elm_widget_item_del(item);
1486 _item_select(Elm_Gengrid_Item *item)
1488 if ((item->wd->no_select) || (item->delete_me)) return;
1491 if (item->wd->always_select) goto call;
1494 item->selected = EINA_TRUE;
1495 item->wd->selected = eina_list_append(item->wd->selected, item);
1498 item->wd->walking++;
1499 if (item->func.func)
1500 item->func.func((void *)item->func.data, item->wd->self, item);
1501 if (!item->delete_me)
1502 evas_object_smart_callback_call(item->wd->self, SIG_SELECTED, item);
1504 item->wd->walking--;
1505 item->wd->last_selected_item = item;
1506 if ((item->wd->clear_me) && (!item->wd->walking))
1507 elm_gengrid_clear(item->base.widget);
1510 if ((!item->walking) && (item->delete_me))
1511 if (!item->relcount) _item_del(item);
1516 _item_unselect(Elm_Gengrid_Item *item)
1518 if ((item->delete_me) || (!item->highlighted)) return;
1519 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
1520 item->highlighted = EINA_FALSE;
1523 item->selected = EINA_FALSE;
1524 item->wd->selected = eina_list_remove(item->wd->selected, item);
1525 evas_object_smart_callback_call(item->wd->self, SIG_UNSELECTED, item);
1530 _calc_job(void *data)
1532 Widget_Data *wd = data;
1533 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1534 Elm_Gengrid_Item *item, *group_item = NULL;
1535 int count_group = 0;
1539 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1540 if ((cvw != 0) || (cvh != 0))
1542 if ((wd->horizontal) && (wd->item_height > 0))
1543 nmax = cvh / wd->item_height;
1544 else if (wd->item_width > 0)
1545 nmax = cvw / wd->item_width;
1550 EINA_INLIST_FOREACH(wd->items, item)
1552 if (item->prev_group != count_group)
1553 item->prev_group = count_group;
1556 count = count % nmax;
1558 wd->items_lost += nmax - count;
1559 //printf("%d items and I lost %d\n", count, wd->items_lost);
1561 if (count) count = 0;
1566 if (item->parent_group_item != group_item)
1567 item->parent_group_item = group_item;
1571 count = wd->count + wd->items_lost - count_group;
1574 minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_height);
1575 minh = nmax * wd->item_height;
1579 minw = nmax * wd->item_width;
1580 minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1583 if ((minw != wd->minw) || (minh != wd->minh))
1587 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1591 evas_object_smart_changed(wd->pan_smart);
1593 wd->calc_job = NULL;
1597 _pan_add(Evas_Object *obj)
1600 Evas_Object_Smart_Clipped_Data *cd;
1603 cd = evas_object_smart_data_get(obj);
1606 sd->__clipped_data = *cd;
1608 evas_object_smart_data_set(obj, sd);
1612 _pan_del(Evas_Object *obj)
1614 Pan *sd = evas_object_smart_data_get(obj);
1621 _pan_set(Evas_Object *obj,
1625 Pan *sd = evas_object_smart_data_get(obj);
1626 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1629 evas_object_smart_changed(obj);
1633 _pan_get(Evas_Object *obj,
1637 Pan *sd = evas_object_smart_data_get(obj);
1638 if (x) *x = sd->wd->pan_x;
1639 if (y) *y = sd->wd->pan_y;
1643 _pan_child_size_get(Evas_Object *obj,
1647 Pan *sd = evas_object_smart_data_get(obj);
1648 if (w) *w = sd->wd->minw;
1649 if (h) *h = sd->wd->minh;
1653 _pan_max_get(Evas_Object *obj,
1657 Pan *sd = evas_object_smart_data_get(obj);
1661 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1663 *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1665 *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1669 _pan_min_get(Evas_Object *obj,
1673 Pan *sd = evas_object_smart_data_get(obj);
1677 _pan_max_get(obj, &mx, &my);
1679 *x = -mx * sd->wd->align_x;
1681 *y = -my * sd->wd->align_y;
1685 _pan_resize(Evas_Object *obj,
1689 Pan *sd = evas_object_smart_data_get(obj);
1692 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1693 if ((ow == w) && (oh == h)) return;
1694 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1695 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1699 _pan_calculate(Evas_Object *obj)
1701 Pan *sd = evas_object_smart_data_get(obj);
1702 Evas_Coord cx = 0, cy = 0;
1703 Elm_Gengrid_Item *item;
1706 if (!sd->wd->nmax) return;
1708 sd->wd->reorder_item_changed = EINA_FALSE;
1710 EINA_INLIST_FOREACH(sd->wd->items, item)
1714 if (sd->wd->horizontal)
1731 _item_place(item, cx, cy);
1732 if (sd->wd->reorder_item_changed) return;
1735 if (sd->wd->horizontal)
1748 if (sd->wd->horizontal)
1750 cy = (cy + 1) % sd->wd->nmax;
1755 cx = (cx + 1) % sd->wd->nmax;
1760 _group_item_place(sd);
1763 if ((sd->wd->reorder_mode) && (sd->wd->reorder_item))
1765 if (!sd->wd->reorder_item_changed)
1767 sd->wd->old_pan_x = sd->wd->pan_x;
1768 sd->wd->old_pan_y = sd->wd->pan_y;
1770 sd->wd->move_effect_enabled = EINA_FALSE;
1772 evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
1776 _pan_move(Evas_Object *obj,
1777 Evas_Coord x __UNUSED__,
1778 Evas_Coord y __UNUSED__)
1780 Pan *sd = evas_object_smart_data_get(obj);
1782 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1783 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1787 _hold_on(void *data __UNUSED__,
1789 void *event_info __UNUSED__)
1791 Widget_Data *wd = elm_widget_data_get(obj);
1793 elm_smart_scroller_hold_set(wd->scr, 1);
1797 _hold_off(void *data __UNUSED__,
1799 void *event_info __UNUSED__)
1801 Widget_Data *wd = elm_widget_data_get(obj);
1803 elm_smart_scroller_hold_set(wd->scr, 0);
1807 _freeze_on(void *data __UNUSED__,
1809 void *event_info __UNUSED__)
1811 Widget_Data *wd = elm_widget_data_get(obj);
1813 elm_smart_scroller_freeze_set(wd->scr, 1);
1817 _freeze_off(void *data __UNUSED__,
1819 void *event_info __UNUSED__)
1821 Widget_Data *wd = elm_widget_data_get(obj);
1823 elm_smart_scroller_freeze_set(wd->scr, 0);
1827 _scr_anim_start(void *data,
1828 Evas_Object *obj __UNUSED__,
1829 void *event_info __UNUSED__)
1831 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1835 _scr_anim_stop(void *data,
1836 Evas_Object *obj __UNUSED__,
1837 void *event_info __UNUSED__)
1839 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1843 _scr_drag_start(void *data,
1844 Evas_Object *obj __UNUSED__,
1845 void *event_info __UNUSED__)
1847 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1851 _scr_drag_stop(void *data,
1852 Evas_Object *obj __UNUSED__,
1853 void *event_info __UNUSED__)
1855 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1859 _scr_scroll(void *data,
1860 Evas_Object *obj __UNUSED__,
1861 void *event_info __UNUSED__)
1863 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1867 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1869 const Elm_Gengrid_Item *item = data;
1870 const Elm_Gengrid_Item *item1 = data1;
1872 return _elm_gengrid_item_compare_data_cb(item->base.data, item1->base.data);
1876 _elm_gengrid_item_compare(const void *data, const void *data1)
1878 Elm_Gengrid_Item *item, *item1;
1879 item = ELM_GENGRID_ITEM_FROM_INLIST(data);
1880 item1 = ELM_GENGRID_ITEM_FROM_INLIST(data1);
1881 return _elm_gengrid_item_compare_cb(item, item1);
1885 elm_gengrid_add(Evas_Object *parent)
1890 static Evas_Smart *smart = NULL;
1891 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1893 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1895 ELM_SET_WIDTYPE(widtype, "gengrid");
1896 elm_widget_type_set(obj, "gengrid");
1897 elm_widget_sub_object_add(parent, obj);
1898 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1899 elm_widget_data_set(obj, wd);
1900 elm_widget_del_hook_set(obj, _del_hook);
1901 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1902 elm_widget_theme_hook_set(obj, _theme_hook);
1903 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1904 elm_widget_can_focus_set(obj, EINA_TRUE);
1905 elm_widget_event_hook_set(obj, _event_hook);
1907 wd->scr = elm_smart_scroller_add(e);
1908 elm_smart_scroller_widget_set(wd->scr, obj);
1909 elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1911 elm_widget_resize_object_set(obj, wd->scr);
1913 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1914 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1915 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1916 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1917 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1919 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1924 wd->h_bounce = bounce;
1925 wd->v_bounce = bounce;
1926 wd->no_select = EINA_FALSE;
1928 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1929 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1930 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1931 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1933 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1937 static Evas_Smart_Class sc;
1939 evas_object_smart_clipped_smart_set(&_pan_sc);
1941 sc.name = "elm_gengrid_pan";
1942 sc.version = EVAS_SMART_CLASS_VERSION;
1945 sc.resize = _pan_resize;
1946 sc.move = _pan_move;
1947 sc.calculate = _pan_calculate;
1948 smart = evas_smart_class_new(&sc);
1952 wd->pan_smart = evas_object_smart_add(e, smart);
1953 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1957 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1958 _pan_set, _pan_get, _pan_max_get,
1959 _pan_min_get, _pan_child_size_get);
1961 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1966 elm_gengrid_item_size_set(Evas_Object *obj,
1970 ELM_CHECK_WIDTYPE(obj, widtype);
1971 Widget_Data *wd = elm_widget_data_get(obj);
1973 if ((wd->item_width == w) && (wd->item_height == h)) return;
1975 wd->item_height = h;
1976 if (wd->calc_job) ecore_job_del(wd->calc_job);
1977 wd->calc_job = ecore_job_add(_calc_job, wd);
1981 elm_gengrid_item_size_get(const Evas_Object *obj,
1985 ELM_CHECK_WIDTYPE(obj, widtype);
1986 Widget_Data *wd = elm_widget_data_get(obj);
1988 if (w) *w = wd->item_width;
1989 if (h) *h = wd->item_height;
1993 elm_gengrid_group_item_size_set(Evas_Object *obj,
1997 ELM_CHECK_WIDTYPE(obj, widtype);
1998 Widget_Data *wd = elm_widget_data_get(obj);
2000 if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
2001 wd->group_item_width = w;
2002 wd->group_item_height = h;
2003 if (wd->calc_job) ecore_job_del(wd->calc_job);
2004 wd->calc_job = ecore_job_add(_calc_job, wd);
2008 elm_gengrid_group_item_size_get(const Evas_Object *obj,
2012 ELM_CHECK_WIDTYPE(obj, widtype);
2013 Widget_Data *wd = elm_widget_data_get(obj);
2015 if (w) *w = wd->group_item_width;
2016 if (h) *h = wd->group_item_height;
2020 elm_gengrid_align_set(Evas_Object *obj,
2024 ELM_CHECK_WIDTYPE(obj, widtype);
2026 Widget_Data *wd = elm_widget_data_get(obj);
2027 double old_h = wd->align_x, old_y = wd->align_y;
2031 else if (align_x < 0.0)
2033 wd->align_x = align_x;
2037 else if (align_y < 0.0)
2039 wd->align_y = align_y;
2041 if ((old_h != wd->align_x) || (old_y != wd->align_y))
2042 evas_object_smart_calculate(wd->pan_smart);
2046 elm_gengrid_align_get(const Evas_Object *obj,
2050 ELM_CHECK_WIDTYPE(obj, widtype);
2051 Widget_Data *wd = elm_widget_data_get(obj);
2052 if (align_x) *align_x = wd->align_x;
2053 if (align_y) *align_y = wd->align_y;
2056 EAPI Elm_Gengrid_Item *
2057 elm_gengrid_item_append(Evas_Object *obj,
2058 const Elm_Gengrid_Item_Class *gic,
2061 const void *func_data)
2063 Elm_Gengrid_Item *item;
2064 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2065 Widget_Data *wd = elm_widget_data_get(obj);
2066 if (!wd) return NULL;
2068 item = _item_create(wd, gic, data, func, func_data);
2069 if (!item) return NULL;
2070 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(item));
2073 wd->group_items = eina_list_prepend(wd->group_items, item);
2075 if (wd->calc_job) ecore_job_del(wd->calc_job);
2076 wd->calc_job = ecore_job_add(_calc_job, wd);
2081 EAPI Elm_Gengrid_Item *
2082 elm_gengrid_item_prepend(Evas_Object *obj,
2083 const Elm_Gengrid_Item_Class *gic,
2086 const void *func_data)
2088 Elm_Gengrid_Item *item;
2089 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2090 Widget_Data *wd = elm_widget_data_get(obj);
2091 if (!wd) return NULL;
2093 item = _item_create(wd, gic, data, func, func_data);
2094 if (!item) return NULL;
2095 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(item));
2097 wd->group_items = eina_list_append(wd->group_items, item);
2099 if (wd->calc_job) ecore_job_del(wd->calc_job);
2100 wd->calc_job = ecore_job_add(_calc_job, wd);
2105 EAPI Elm_Gengrid_Item *
2106 elm_gengrid_item_insert_before(Evas_Object *obj,
2107 const Elm_Gengrid_Item_Class *gic,
2109 Elm_Gengrid_Item *relative,
2111 const void *func_data)
2113 Elm_Gengrid_Item *item;
2114 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2115 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2116 Widget_Data *wd = elm_widget_data_get(obj);
2117 if (!wd) return NULL;
2119 item = _item_create(wd, gic, data, func, func_data);
2120 if (!item) return NULL;
2121 wd->items = eina_inlist_prepend_relative
2122 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
2124 wd->group_items = eina_list_append_relative(wd->group_items, item, relative->parent_group_item);
2126 if (wd->calc_job) ecore_job_del(wd->calc_job);
2127 wd->calc_job = ecore_job_add(_calc_job, wd);
2132 EAPI Elm_Gengrid_Item *
2133 elm_gengrid_item_insert_after(Evas_Object *obj,
2134 const Elm_Gengrid_Item_Class *gic,
2136 Elm_Gengrid_Item *relative,
2138 const void *func_data)
2140 Elm_Gengrid_Item *item;
2141 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2142 EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2143 Widget_Data *wd = elm_widget_data_get(obj);
2144 if (!wd) return NULL;
2146 item = _item_create(wd, gic, data, func, func_data);
2147 if (!item) return NULL;
2148 wd->items = eina_inlist_append_relative
2149 (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
2151 wd->group_items = eina_list_prepend_relative(wd->group_items, item, relative->parent_group_item);
2153 if (wd->calc_job) ecore_job_del(wd->calc_job);
2154 wd->calc_job = ecore_job_add(_calc_job, wd);
2159 EAPI Elm_Gengrid_Item *
2160 elm_gengrid_item_direct_sorted_insert(Evas_Object *obj,
2161 const Elm_Gengrid_Item_Class *gic,
2163 Eina_Compare_Cb comp,
2165 const void *func_data)
2167 Elm_Gengrid_Item *item;
2168 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2169 Widget_Data *wd = elm_widget_data_get(obj);
2170 if (!wd) return NULL;
2172 item = _item_create(wd, gic, data, func, func_data);
2173 if (!item) return NULL;
2176 wd->state = eina_inlist_sorted_state_new();
2178 _elm_gengrid_item_compare_cb = comp;
2179 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(item),
2180 _elm_gengrid_item_compare, wd->state);
2181 if (wd->calc_job) ecore_job_del(wd->calc_job);
2182 wd->calc_job = ecore_job_add(_calc_job, wd);
2187 EAPI Elm_Gengrid_Item *
2188 elm_gengrid_item_sorted_insert(Evas_Object *obj,
2189 const Elm_Gengrid_Item_Class *gic,
2191 Eina_Compare_Cb comp,
2193 const void *func_data)
2195 _elm_gengrid_item_compare_data_cb = comp;
2197 return elm_gengrid_item_direct_sorted_insert(obj, gic, data, _elm_gengrid_item_compare_data, func, func_data);
2201 elm_gengrid_item_del(Elm_Gengrid_Item *item)
2203 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2204 if ((item->relcount > 0) || (item->walking > 0))
2206 item->delete_me = EINA_TRUE;
2207 elm_widget_item_pre_notify_del(item);
2209 item->wd->selected = eina_list_remove(item->wd->selected, item);
2210 if (item->gic->func.del)
2211 item->gic->func.del((void *)item->base.data, item->wd->self);
2219 elm_gengrid_horizontal_set(Evas_Object *obj,
2222 ELM_CHECK_WIDTYPE(obj, widtype);
2223 Widget_Data *wd = elm_widget_data_get(obj);
2225 if (setting == wd->horizontal) return;
2226 wd->horizontal = setting;
2228 /* Update the items to conform to the new layout */
2229 if (wd->calc_job) ecore_job_del(wd->calc_job);
2230 wd->calc_job = ecore_job_add(_calc_job, wd);
2234 elm_gengrid_horizontal_get(const Evas_Object *obj)
2236 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2237 Widget_Data *wd = elm_widget_data_get(obj);
2238 if (!wd) return EINA_FALSE;
2239 return wd->horizontal;
2243 elm_gengrid_clear(Evas_Object *obj)
2245 ELM_CHECK_WIDTYPE(obj, widtype);
2246 Widget_Data *wd = elm_widget_data_get(obj);
2251 eina_inlist_sorted_state_free(wd->state);
2256 ecore_job_del(wd->calc_job);
2257 wd->calc_job = NULL;
2260 if (wd->walking > 0)
2262 Elm_Gengrid_Item *item;
2264 EINA_INLIST_FOREACH(wd->items, item)
2265 item->delete_me = 1;
2271 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2273 wd->items = eina_inlist_remove(wd->items, wd->items);
2274 elm_widget_item_pre_notify_del(item);
2275 if (item->realized) _item_unrealize(item);
2276 if (item->gic->func.del)
2277 item->gic->func.del((void *)item->base.data, wd->self);
2278 if (item->long_timer) ecore_timer_del(item->long_timer);
2279 elm_widget_item_del(item);
2284 eina_list_free(wd->selected);
2285 wd->selected = NULL;
2293 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2294 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2297 EAPI const Evas_Object *
2298 elm_gengrid_item_object_get(const Elm_Gengrid_Item *item)
2300 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2301 return item->base.view;
2305 elm_gengrid_item_update(Elm_Gengrid_Item *item)
2307 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2308 if (!item->realized) return;
2309 if (item->want_unrealize) return;
2310 _item_unrealize(item);
2311 _item_realize(item);
2312 _item_place(item, item->x, item->y);
2316 elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
2318 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2319 return elm_widget_item_data_get(item);
2323 elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
2326 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2327 elm_widget_item_data_set(item, data);
2330 EAPI const Elm_Gengrid_Item_Class *
2331 elm_gengrid_item_item_class_get(const Elm_Gengrid_Item *item)
2333 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2334 if (item->delete_me) return NULL;
2339 elm_gengrid_item_item_class_set(Elm_Gengrid_Item *item,
2340 const Elm_Gengrid_Item_Class *gic)
2342 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2343 EINA_SAFETY_ON_NULL_RETURN(gic);
2344 if (item->delete_me) return;
2346 elm_gengrid_item_update(item);
2350 elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item,
2354 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2355 if (x) *x = item->x;
2356 if (y) *y = item->y;
2360 elm_gengrid_multi_select_set(Evas_Object *obj,
2363 ELM_CHECK_WIDTYPE(obj, widtype);
2364 Widget_Data *wd = elm_widget_data_get(obj);
2370 elm_gengrid_multi_select_get(const Evas_Object *obj)
2372 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2373 Widget_Data *wd = elm_widget_data_get(obj);
2374 if (!wd) return EINA_FALSE;
2378 EAPI Elm_Gengrid_Item *
2379 elm_gengrid_selected_item_get(const Evas_Object *obj)
2381 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2382 Widget_Data *wd = elm_widget_data_get(obj);
2383 if (!wd) return NULL;
2384 if (wd->selected) return wd->selected->data;
2388 EAPI const Eina_List *
2389 elm_gengrid_selected_items_get(const Evas_Object *obj)
2391 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2392 Widget_Data *wd = elm_widget_data_get(obj);
2393 if (!wd) return NULL;
2394 return wd->selected;
2398 elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
2401 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2402 Widget_Data *wd = item->wd;
2404 if (item->delete_me) return;
2405 selected = !!selected;
2406 if (item->selected == selected) return;
2412 while (wd->selected)
2413 _item_unselect(wd->selected->data);
2415 _item_highlight(item);
2419 _item_unselect(item);
2423 elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
2425 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2426 return item->selected;
2430 elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
2433 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2434 if (item->disabled == disabled) return;
2435 if (item->delete_me) return;
2436 item->disabled = !!disabled;
2440 edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
2442 edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
2447 elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
2449 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2450 if (item->delete_me) return EINA_FALSE;
2451 return item->disabled;
2454 static Evas_Object *
2455 _elm_gengrid_item_label_create(void *data,
2456 Evas_Object *obj __UNUSED__,
2457 Evas_Object *tooltip,
2458 void *item __UNUSED__)
2460 Evas_Object *label = elm_label_add(tooltip);
2463 elm_object_style_set(label, "tooltip");
2464 elm_object_text_set(label, data);
2469 _elm_gengrid_item_label_del_cb(void *data,
2470 Evas_Object *obj __UNUSED__,
2471 void *event_info __UNUSED__)
2473 eina_stringshare_del(data);
2477 elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
2480 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2481 text = eina_stringshare_add(text);
2482 elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create,
2484 _elm_gengrid_item_label_del_cb);
2488 elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item,
2489 Elm_Tooltip_Item_Content_Cb func,
2491 Evas_Smart_Cb del_cb)
2493 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
2495 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
2498 if (item->tooltip.del_cb)
2499 item->tooltip.del_cb((void *)item->tooltip.data,
2500 item->base.widget, item);
2501 item->tooltip.content_cb = func;
2502 item->tooltip.data = data;
2503 item->tooltip.del_cb = del_cb;
2504 if (item->base.view)
2506 elm_widget_item_tooltip_content_cb_set(item,
2507 item->tooltip.content_cb,
2508 item->tooltip.data, NULL);
2509 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
2510 elm_widget_item_tooltip_size_restrict_disable(item, item->tooltip.free_size);
2516 if (del_cb) del_cb((void *)data, NULL, NULL);
2520 elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
2522 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2523 if ((item->base.view) && (item->tooltip.content_cb))
2524 elm_widget_item_tooltip_unset(item);
2526 if (item->tooltip.del_cb)
2527 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
2528 item->tooltip.del_cb = NULL;
2529 item->tooltip.content_cb = NULL;
2530 item->tooltip.data = NULL;
2531 item->tooltip.free_size = EINA_FALSE;
2532 if (item->tooltip.style)
2533 elm_gengrid_item_tooltip_style_set(item, NULL);
2537 elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item,
2540 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2541 eina_stringshare_replace(&item->tooltip.style, style);
2542 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
2546 elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
2548 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2549 return item->tooltip.style;
2553 elm_gengrid_item_tooltip_size_restrict_disable(Elm_Gengrid_Item *item, Eina_Bool disable)
2555 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2556 item->tooltip.free_size = disable;
2557 if (item->base.view) return elm_widget_item_tooltip_size_restrict_disable(item, disable);
2562 elm_gengrid_item_tooltip_size_restrict_disabled_get(const Elm_Gengrid_Item *item)
2564 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2565 return item->tooltip.free_size;
2569 elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item,
2572 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2573 eina_stringshare_replace(&item->mouse_cursor, cursor);
2574 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
2578 elm_gengrid_item_cursor_get(const Elm_Gengrid_Item *item)
2580 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2581 return elm_widget_item_cursor_get(item);
2585 elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
2587 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2588 if (!item->mouse_cursor)
2591 if (item->base.view)
2592 elm_widget_item_cursor_unset(item);
2594 eina_stringshare_del(item->mouse_cursor);
2595 item->mouse_cursor = NULL;
2599 elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item,
2602 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2603 elm_widget_item_cursor_style_set(item, style);
2607 elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
2609 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2610 return elm_widget_item_cursor_style_get(item);
2614 elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item,
2615 Eina_Bool engine_only)
2617 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2618 elm_widget_item_cursor_engine_only_set(item, engine_only);
2622 elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
2624 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
2625 return elm_widget_item_cursor_engine_only_get(item);
2629 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2630 Eina_Bool reorder_mode)
2632 ELM_CHECK_WIDTYPE(obj, widtype);
2633 Widget_Data *wd = elm_widget_data_get(obj);
2635 wd->reorder_mode = reorder_mode;
2639 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2641 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2642 Widget_Data *wd = elm_widget_data_get(obj);
2643 if (!wd) return EINA_FALSE;
2644 return wd->reorder_mode;
2648 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2649 Eina_Bool always_select)
2651 ELM_CHECK_WIDTYPE(obj, widtype);
2652 Widget_Data *wd = elm_widget_data_get(obj);
2654 wd->always_select = always_select;
2658 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2660 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2661 Widget_Data *wd = elm_widget_data_get(obj);
2662 if (!wd) return EINA_FALSE;
2663 return wd->always_select;
2667 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2668 Eina_Bool no_select)
2670 ELM_CHECK_WIDTYPE(obj, widtype);
2671 Widget_Data *wd = elm_widget_data_get(obj);
2673 wd->no_select = no_select;
2677 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2679 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2680 Widget_Data *wd = elm_widget_data_get(obj);
2681 if (!wd) return EINA_FALSE;
2682 return wd->no_select;
2686 elm_gengrid_bounce_set(Evas_Object *obj,
2690 ELM_CHECK_WIDTYPE(obj, widtype);
2691 Widget_Data *wd = elm_widget_data_get(obj);
2693 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2694 wd->h_bounce = h_bounce;
2695 wd->v_bounce = v_bounce;
2699 elm_gengrid_bounce_get(const Evas_Object *obj,
2700 Eina_Bool *h_bounce,
2701 Eina_Bool *v_bounce)
2703 ELM_CHECK_WIDTYPE(obj, widtype);
2704 Widget_Data *wd = elm_widget_data_get(obj);
2706 if (h_bounce) *h_bounce = wd->h_bounce;
2707 if (v_bounce) *v_bounce = wd->v_bounce;
2711 elm_gengrid_page_relative_set(Evas_Object *obj,
2715 Evas_Coord pagesize_h;
2716 Evas_Coord pagesize_v;
2718 ELM_CHECK_WIDTYPE(obj, widtype);
2719 Widget_Data *wd = elm_widget_data_get(obj);
2722 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
2723 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
2728 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2730 ELM_CHECK_WIDTYPE(obj, widtype);
2731 Widget_Data *wd = elm_widget_data_get(obj);
2734 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
2738 elm_gengrid_page_size_set(Evas_Object *obj,
2739 Evas_Coord h_pagesize,
2740 Evas_Coord v_pagesize)
2745 ELM_CHECK_WIDTYPE(obj, widtype);
2746 Widget_Data *wd = elm_widget_data_get(obj);
2748 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
2749 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
2753 EAPI Elm_Gengrid_Item *
2754 elm_gengrid_first_item_get(const Evas_Object *obj)
2756 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2757 Widget_Data *wd = elm_widget_data_get(obj);
2758 if (!wd) return NULL;
2759 if (!wd->items) return NULL;
2760 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
2761 while ((item) && (item->delete_me))
2762 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2766 EAPI Elm_Gengrid_Item *
2767 elm_gengrid_last_item_get(const Evas_Object *obj)
2769 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2770 Widget_Data *wd = elm_widget_data_get(obj);
2771 if (!wd) return NULL;
2772 if (!wd->items) return NULL;
2773 Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
2774 while ((item) && (item->delete_me))
2775 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2779 EAPI Elm_Gengrid_Item *
2780 elm_gengrid_item_next_get(const Elm_Gengrid_Item *item)
2782 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2785 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
2786 if ((item) && (!item->delete_me)) break;
2788 return (Elm_Gengrid_Item *)item;
2791 EAPI Elm_Gengrid_Item *
2792 elm_gengrid_item_prev_get(const Elm_Gengrid_Item *item)
2794 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2797 item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
2798 if ((item) && (!item->delete_me)) break;
2800 return (Elm_Gengrid_Item *)item;
2804 elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item)
2806 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
2807 return item->base.widget;
2811 elm_gengrid_item_show(Elm_Gengrid_Item *item)
2813 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2814 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2815 Evas_Coord minx = 0, miny = 0;
2818 if ((!item) || (item->delete_me)) return;
2819 _pan_min_get(wd->pan_smart, &minx, &miny);
2822 elm_smart_scroller_region_bring_in(item->wd->scr,
2823 ((item->x - item->prev_group) * wd->item_width) + (item->prev_group * item->wd->group_item_width) + minx,
2824 item->y * wd->item_height + miny,
2825 item->wd->item_width,
2826 item->wd->item_height);
2828 elm_smart_scroller_region_bring_in(item->wd->scr,
2829 item->x * wd->item_width + minx,
2830 ((item->y - item->prev_group)* wd->item_height) + (item->prev_group * item->wd->group_item_height) + miny,
2831 item->wd->item_width,
2832 item->wd->item_height);
2836 elm_gengrid_item_bring_in(Elm_Gengrid_Item *item)
2838 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
2839 if (item->delete_me) return;
2841 Evas_Coord minx = 0, miny = 0;
2842 Widget_Data *wd = elm_widget_data_get(item->wd->self);
2844 _pan_min_get(wd->pan_smart, &minx, &miny);
2847 elm_smart_scroller_region_bring_in(item->wd->scr,
2848 ((item->x - item->prev_group) * wd->item_width) + (item->prev_group * item->wd->group_item_width) + minx,
2849 item->y * wd->item_height + miny,
2850 item->wd->item_width,
2851 item->wd->item_height);
2853 elm_smart_scroller_region_bring_in(item->wd->scr,
2854 item->x * wd->item_width + minx,
2855 ((item->y - item->prev_group)* wd->item_height) + (item->prev_group * item->wd->group_item_height) + miny,
2856 item->wd->item_width,
2857 item->wd->item_height);