2 # include "elementary_config.h"
5 #define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
6 #define ELM_INTERFACE_ATSPI_COMPONENT_PROTECTED
7 #define ELM_INTERFACE_ATSPI_SELECTION_PROTECTED
8 #define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
9 #define ELM_WIDGET_ITEM_PROTECTED
11 #include <Elementary.h>
12 #include <Elementary_Cursor.h>
14 #include "elm_widget_gengrid.h"
15 #include "elm_interface_scrollable.h"
17 #define MY_PAN_CLASS ELM_GENGRID_PAN_CLASS
19 #define MY_PAN_CLASS_NAME "Elm_Gengrid_Pan"
20 #define MY_PAN_CLASS_NAME_LEGACY "elm_gengrid_pan"
22 #define MY_CLASS ELM_GENGRID_CLASS
24 #define MY_CLASS_NAME "Elm_Gengrid"
25 #define MY_CLASS_NAME_LEGACY "elm_gengrid"
27 // internally allocated
28 #define CLASS_ALLOCATED 0x3a70f00f
32 * Handle non-homogeneous objects too.
36 #define REORDER_EFFECT_TIME 0.5
40 EAPI const char ELM_GENGRID_SMART_NAME[] = "elm_gengrid";
41 EAPI const char ELM_GENGRID_PAN_SMART_NAME[] = "elm_gengrid_pan";
43 #define ELM_PRIV_GENGRID_SIGNALS(cmd) \
44 cmd(SIG_ACTIVATED, "activated", "") \
45 cmd(SIG_CLICKED_DOUBLE, "clicked,double", "") \
46 cmd(SIG_CLICKED_RIGHT, "clicked,right", "") \
47 cmd(SIG_LONGPRESSED, "longpressed", "") \
48 cmd(SIG_SELECTED, "selected", "") \
49 cmd(SIG_UNSELECTED, "unselected", "") \
50 cmd(SIG_REALIZED, "realized", "") \
51 cmd(SIG_UNREALIZED, "unrealized", "") \
52 cmd(SIG_CHANGED, "changed", "") \
53 cmd(SIG_DRAG_START_UP, "drag,start,up", "") \
54 cmd(SIG_DRAG_START_DOWN, "drag,start,down", "") \
55 cmd(SIG_DRAG_START_LEFT, "drag,start,left", "") \
56 cmd(SIG_DRAG_START_RIGHT, "drag,start,right", "") \
57 cmd(SIG_DRAG_STOP, "drag,stop", "") \
58 cmd(SIG_DRAG, "drag", "") \
59 cmd(SIG_SCROLL, "scroll", "") \
60 cmd(SIG_SCROLL_ANIM_START, "scroll,anim,start", "") \
61 cmd(SIG_SCROLL_ANIM_STOP, "scroll,anim,stop", "") \
62 cmd(SIG_SCROLL_DRAG_START, "scroll,drag,start", "") \
63 cmd(SIG_SCROLL_DRAG_STOP, "scroll,drag,stop", "") \
64 cmd(SIG_SCROLL_PAGE_CHANGE, "scroll,page,changed", "") \
65 cmd(SIG_EDGE_TOP, "edge,top", "") \
66 cmd(SIG_EDGE_BOTTOM, "edge,bottom", "") \
67 cmd(SIG_EDGE_LEFT, "edge,left", "") \
68 cmd(SIG_EDGE_RIGHT, "edge,right", "") \
69 cmd(SIG_MOVED, "moved", "") \
70 cmd(SIG_INDEX_UPDATE, "index,update", "") \
71 cmd(SIG_HIGHLIGHTED, "highlighted", "") \
72 cmd(SIG_UNHIGHLIGHTED, "unhighlighted", "") \
73 cmd(SIG_ITEM_FOCUSED, "item,focused", "") \
74 cmd(SIG_ITEM_UNFOCUSED, "item,unfocused", "") \
75 cmd(SIG_PRESSED, "pressed", "") \
76 cmd(SIG_RELEASED, "released", "") \
77 cmd(SIG_ITEM_REORDER_START, "item,reorder,anim,start", "") \
78 cmd(SIG_ITEM_REORDER_STOP, "item,reorder,anim,stop", "")
80 ELM_PRIV_GENGRID_SIGNALS(ELM_PRIV_STATIC_VARIABLE_DECLARE);
82 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
83 ELM_PRIV_GENGRID_SIGNALS(ELM_PRIV_SMART_CALLBACKS_DESC)
84 {SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */
85 {SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
86 {SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */
87 {SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */
88 {SIG_ITEM_FOCUSED, ""},
89 {SIG_ITEM_UNFOCUSED, ""},
93 #undef ELM_PRIV_GENGRID_SIGNALS
95 static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
96 static Eina_Bool _key_action_select(Evas_Object *obj, const char *params);
97 static Eina_Bool _key_action_escape(Evas_Object *obj, const char *params);
98 static void _item_position_update(Eina_Inlist *list, int idx);
99 static void _item_mouse_callbacks_add(Elm_Gen_Item *it, Evas_Object *view);
100 static void _item_mouse_callbacks_del(Elm_Gen_Item *it, Evas_Object *view);
103 static const Elm_Action key_actions[] = {
104 {"move", _key_action_move},
105 {"select", _key_action_select},
106 {"escape", _key_action_escape},
111 //-- item cache handle routine --//
112 // push item cache into caches
114 _item_cache_push(Elm_Gengrid_Data *sd, Item_Cache *itc)
116 if (!itc || (sd->item_cache_max <= 0))
119 sd->item_cache_count++;
121 eina_inlist_prepend(sd->item_cache, EINA_INLIST_GET(itc));
126 // pop item cache from caches
128 _item_cache_pop(Elm_Gengrid_Data *sd, Item_Cache *itc)
130 if ((!itc) || (!sd->item_cache) ||
131 (sd->item_cache_count <= 0))
135 eina_inlist_remove (sd->item_cache, EINA_INLIST_GET(itc));
136 sd->item_cache_count--;
141 // free one item cache from caches
143 _item_cache_free(Item_Cache *itc)
147 evas_object_del(itc->spacer);
148 evas_object_del(itc->base_view);
149 eina_stringshare_del(itc->item_style);
150 ELM_SAFE_FREE(itc ,free);
153 // clean up item cache by removing overflowed caches
155 _item_cache_clean(Elm_Gengrid_Data *sd)
157 evas_event_freeze(evas_object_evas_get(sd->obj));
159 while ((sd->item_cache) && (sd->item_cache_count > sd->item_cache_max))
162 EINA_INLIST_CONTAINER_GET(sd->item_cache->last, Item_Cache);
163 _item_cache_free(_item_cache_pop(sd, itc));
165 evas_event_thaw(evas_object_evas_get(sd->obj));
166 evas_event_thaw_eval(evas_object_evas_get(sd->obj));
169 // empty all item caches
171 _item_cache_zero(Elm_Gengrid_Data *sd)
173 int pmax = sd->item_cache_max;
175 sd->item_cache_max = 0;
176 _item_cache_clean(sd);
177 sd->item_cache_max = pmax;
180 // add an item to item cache
182 _item_cache_add(Elm_Gen_Item *it)
184 if (it->item->nocache_once || it->item->nocache) return EINA_FALSE;
186 Item_Cache *itc = NULL;
187 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
188 Evas_Object *obj = sd->obj;
190 evas_event_freeze(evas_object_evas_get(obj));
191 if (sd->item_cache_max > 0)
192 itc = ELM_NEW(Item_Cache);
193 if (!_item_cache_push(sd, itc))
195 if (itc) ELM_SAFE_FREE(itc, free);
197 evas_event_thaw(evas_object_evas_get(obj));
198 evas_event_thaw_eval(evas_object_evas_get(obj));
202 itc->spacer = it->spacer;
203 itc->base_view = VIEW(it);
204 itc->item_style = eina_stringshare_add(it->itc->item_style);
210 edje_object_signal_emit(itc->base_view, "elm,state,unselected", "elm");
211 if (eo_do_ret(EO_OBJ(it), tmp, elm_wdg_item_disabled_get()))
212 edje_object_signal_emit(itc->base_view, "elm,state,enabled", "elm");
213 if (it == (Elm_Gen_Item *)sd->focused_item &&
214 (elm_widget_focus_highlight_enabled_get(obj) || _elm_config->win_auto_focus_enable))
215 edje_object_signal_emit(itc->base_view, "elm,state,unfocused", "elm");
217 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
218 // FIXME: other callbacks?
219 _item_mouse_callbacks_del(it, itc->base_view);
222 edje_object_mirrored_set(VIEW(it),
223 elm_widget_mirrored_get(WIDGET(it)));
224 edje_object_scale_set(VIEW(it),
225 elm_widget_scale_get(WIDGET(it))
226 * elm_config_scale_get());
228 evas_object_hide(itc->base_view);
229 evas_object_move(itc->base_view, -9999, -9999);
233 _item_cache_clean(sd);
235 evas_event_thaw(evas_object_evas_get(obj));
236 evas_event_thaw_eval(evas_object_evas_get(obj));
241 // find an item from item cache and remove it from the cache
243 _item_cache_find(Elm_Gen_Item *it)
245 if (it->item->nocache_once || it->item->nocache) return EINA_FALSE;
247 Item_Cache *itc = NULL;
249 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
251 EINA_INLIST_FOREACH_SAFE(sd->item_cache, l, itc)
253 if (((!it->itc->item_style) && (!itc->item_style)) ||
254 (it->itc->item_style && itc->item_style &&
255 (!strcmp(it->itc->item_style, itc->item_style))))
257 itc = _item_cache_pop(sd, itc);
260 it->spacer = itc->spacer;
261 VIEW(it) = itc->base_view;
263 itc->base_view = NULL;
265 _item_cache_free(itc);
273 _is_no_select(Elm_Gen_Item *it)
275 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
277 if ((sd->select_mode == ELM_OBJECT_SELECT_MODE_NONE) ||
278 (sd->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) ||
279 (it->select_mode == ELM_OBJECT_SELECT_MODE_NONE) ||
280 (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY))
285 EOLIAN static Elm_Object_Item *
286 _elm_gengrid_search_by_text_item_get(Eo *obj EINA_UNUSED,
287 Elm_Gengrid_Data *sd,
288 Elm_Object_Item *eo_item_to_search_from,
289 const char *part_name,
291 Elm_Glob_Match_Flags flags)
293 Elm_Gen_Item *it = NULL;
295 Eina_Inlist *start = NULL;
298 if (!pattern) return NULL;
299 if (!sd->items) return NULL;
301 if (flags & ELM_GLOB_MATCH_NO_ESCAPE) fnflags |= FNM_NOESCAPE;
302 if (flags & ELM_GLOB_MATCH_PATH) fnflags |= FNM_PATHNAME;
303 if (flags & ELM_GLOB_MATCH_PERIOD) fnflags |= FNM_PERIOD;
305 if (flags & ELM_GLOB_MATCH_NOCASE) fnflags |= FNM_CASEFOLD;
308 ELM_GENGRID_ITEM_DATA_GET(eo_item_to_search_from, item_to_search_from);
309 start = (item_to_search_from) ?
310 EINA_INLIST_GET(item_to_search_from) :
312 EINA_INLIST_FOREACH(start, it)
314 if (!it->itc->func.text_get) continue;
315 str = it->itc->func.text_get((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)),
316 WIDGET(it), part_name);
318 if (!fnmatch(pattern, str, fnflags))
329 _item_show_region(void *data)
331 Elm_Gengrid_Data *sd = data;
332 Evas_Coord cvw, cvh, it_xpos = 0, it_ypos = 0, col = 0, row = 0, minx = 0, miny = 0;
333 Evas_Coord vw = 0, vh = 0;
334 Elm_Object_Item *eo_it = NULL;
335 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh);
337 if ((cvw != 0) && (cvh != 0))
342 else if (sd->bring_in)
343 eo_it = sd->bring_in_it;
346 ELM_GENGRID_ITEM_DATA_GET(eo_it, it);
348 eo_do(sd->pan_obj, elm_obj_pan_pos_min_get(&minx, &miny));
349 if (sd->horizontal && (sd->item_height > 0))
351 row = cvh / sd->item_height;
352 if (row <= 0) row = 1;
353 x = (it->position - 1) / row;
354 if (elm_widget_mirrored_get(sd->obj))
356 col = sd->item_count / row;
357 if (sd->item_count % row == 0)
362 y = (it->position - 1) % row;
364 it_xpos = ((x - GG_IT(it)->prev_group) * sd->item_width)
365 + (GG_IT(it)->prev_group * sd->group_item_width)
368 miny = miny + ((cvh - (sd->item_height * row))
370 it_ypos = y * sd->item_height + miny;
374 else if (sd->item_width > 0)
376 col = cvw / sd->item_width;
377 if (col <= 0) col = 1;
378 y = (it->position - 1) / col;
379 x = (it->position - 1) % col;
380 it_xpos = x * sd->item_width + minx;
382 it_ypos = ((y - GG_IT(it)->prev_group) * sd->item_height)
383 + (GG_IT(it)->prev_group * sd->group_item_height)
386 minx = minx + ((cvw - (sd->item_width * col))
392 switch (sd->scroll_to_type)
394 case ELM_GENGRID_ITEM_SCROLLTO_TOP:
395 eo_do(WIDGET(it), elm_interface_scrollable_content_viewport_geometry_get
396 (NULL, NULL, &vw, &vh));
398 case ELM_GENGRID_ITEM_SCROLLTO_MIDDLE:
399 eo_do(WIDGET(it), elm_interface_scrollable_content_viewport_geometry_get
400 (NULL, NULL, &vw, &vh));
401 it_xpos = it_xpos - ((vw - sd->item_width) / 2);
402 it_ypos = it_ypos - ((vh - sd->item_height) / 2);
405 case ELM_GENGRID_ITEM_SCROLLTO_BOTTOM:
406 eo_do(WIDGET(it), elm_interface_scrollable_content_viewport_geometry_get
407 (NULL, NULL, &vw, &vh));
408 it_xpos = it_xpos - vw + sd->item_width;
409 it_ypos = it_ypos - vh + sd->item_height;
414 vh = sd->item_height;
420 eo_do(WIDGET(it), elm_interface_scrollable_content_region_show(
421 it_xpos, it_ypos, vw, vh));
422 sd->show_region = EINA_FALSE;
426 eo_do(WIDGET(it), elm_interface_scrollable_region_bring_in(
427 it_xpos, it_ypos, vw, vh));
428 sd->bring_in = EINA_FALSE;
434 _calc_job(void *data)
436 ELM_GENGRID_DATA_GET(data, sd);
437 Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
438 Elm_Gen_Item *it, *group_item = NULL;
444 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh);
446 if ((cvw != 0) || (cvh != 0))
448 if ((sd->horizontal) && (sd->item_height > 0))
449 nmax = cvh / sd->item_height;
450 else if (sd->item_width > 0)
451 nmax = cvw / sd->item_width;
456 EINA_INLIST_FOREACH(sd->items, it)
458 if (GG_IT(it)->prev_group != count_group)
459 GG_IT(it)->prev_group = count_group;
462 count = count % nmax;
464 sd->items_lost += nmax - count;
466 if (count) count = 0;
471 if (it->parent != group_item)
472 it->parent = group_item;
476 count = sd->item_count + sd->items_lost - count_group;
479 minw = (ceil(count / (float)nmax) * sd->item_width) +
480 (count_group * sd->group_item_width);
481 minh = nmax * sd->item_height;
485 minw = nmax * sd->item_width;
486 minh = (ceil(count / (float)nmax) * sd->item_height) +
487 (count_group * sd->group_item_height);
490 if ((minw != sd->minw) || (minh != sd->minh))
494 eo_do(sd->pan_obj, eo_event_callback_call
495 (ELM_PAN_EVENT_CHANGED, NULL));
499 evas_object_smart_changed(sd->pan_obj);
501 if (sd->show_region || sd->bring_in)
502 _item_show_region(sd);
508 _elm_gengrid_pan_eo_base_destructor(Eo *obj, Elm_Gengrid_Pan_Data *psd)
510 eo_data_unref(psd->wobj, psd->wsd);
511 eo_do_super(obj, MY_PAN_CLASS, eo_destructor());
515 _elm_gengrid_pan_evas_object_smart_move(Eo *obj EINA_UNUSED, Elm_Gengrid_Pan_Data *psd, Evas_Coord _gen_param2 EINA_UNUSED, Evas_Coord _gen_param3 EINA_UNUSED)
517 ecore_job_del(psd->wsd->calc_job);
518 psd->wsd->calc_job = ecore_job_add(_calc_job, psd->wobj);
522 _elm_gengrid_pan_evas_object_smart_resize(Eo *obj, Elm_Gengrid_Pan_Data *psd, Evas_Coord w, Evas_Coord h)
526 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
527 if ((ow == w) && (oh == h)) return;
528 ecore_job_del(psd->wsd->calc_job);
529 psd->wsd->calc_job = ecore_job_add(_calc_job, psd->wobj);
533 _item_unselect(Elm_Gen_Item *it)
535 Elm_Gen_Item_Type *item = GG_IT(it);
536 Elm_Gengrid_Data *sd = item->wsd;
537 Elm_Object_Item *eo_it = EO_OBJ(it);
539 if ((it->generation < sd->generation) || (!it->selected))
544 it->selected = EINA_FALSE;
545 sd->selected = eina_list_remove(sd->selected, eo_it);
546 eo_do(WIDGET(it), eo_event_callback_call
547 (EVAS_SELECTABLE_INTERFACE_EVENT_UNSELECTED, eo_it));
548 if (_elm_config->atspi_mode)
549 elm_interface_atspi_accessible_state_changed_signal_emit(eo_it, ELM_ATSPI_STATE_SELECTED, EINA_FALSE);
554 _item_mouse_in_cb(void *data,
555 Evas *evas EINA_UNUSED,
556 Evas_Object *obj EINA_UNUSED,
557 void *event_info EINA_UNUSED)
559 Elm_Gen_Item *it = data;
560 if (!elm_object_item_disabled_get(EO_OBJ(it)) &&
561 (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN))
562 elm_object_item_focus_set(EO_OBJ(it), EINA_TRUE);
566 _item_mouse_move_cb(void *data,
567 Evas *evas EINA_UNUSED,
571 Elm_Gen_Item *it = data;
572 Evas_Event_Mouse_Move *ev = event_info;
573 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
574 Evas_Coord minw = 0, minh = 0, x, y, w, h, dx, dy, adx, ady;
575 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
576 Elm_Object_Item *eo_it = EO_OBJ(it);
578 evas_object_geometry_get(obj, &x, &y, &w, &h);
579 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
583 sd->on_hold = EINA_TRUE;
584 if (!sd->was_selected)
586 it->unhighlight_cb(it);
591 else if (ELM_RECTS_POINT_OUT(x, y, w, h, ev->cur.canvas.x, ev->cur.canvas.y) &&
594 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
595 if (!sd->was_selected)
597 it->unhighlight_cb(it);
600 it->base->still_in = EINA_FALSE;
603 if ((it->dragging) && (it->down))
605 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
606 eo_do(WIDGET(it), eo_event_callback_call(EVAS_DRAGGABLE_INTERFACE_EVENT_DRAG, eo_it));
610 if ((!it->down) || (sd->longpressed))
612 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
613 if ((sd->reorder_mode) && (sd->reorder_it))
615 evas_object_geometry_get
616 (sd->pan_obj, &ox, &oy, &ow, &oh);
618 it_scrl_x = ev->cur.canvas.x - sd->reorder_it->dx;
619 it_scrl_y = ev->cur.canvas.y - sd->reorder_it->dy;
621 if (it_scrl_x < ox) sd->reorder_item_x = ox;
622 else if (it_scrl_x + sd->item_width > ox + ow)
623 sd->reorder_item_x = ox + ow - sd->item_width;
624 else sd->reorder_item_x = it_scrl_x;
626 if (it_scrl_y < oy) sd->reorder_item_y = oy;
627 else if (it_scrl_y + sd->item_height > oy + oh)
628 sd->reorder_item_y = oy + oh - sd->item_height;
629 else sd->reorder_item_y = it_scrl_y;
631 ecore_job_del(sd->calc_job);
632 sd->calc_job = ecore_job_add(_calc_job, sd->obj);
637 if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
638 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
640 x = ev->cur.canvas.x - x;
641 y = ev->cur.canvas.y - y;
645 if (adx < 0) adx = -dx;
649 if (ady < 0) ady = -dy;
653 if ((adx > minw) || (ady > minh))
655 const Eo_Event_Description *left_drag, *right_drag;
657 if (!elm_widget_mirrored_get(WIDGET(it)))
659 left_drag = EVAS_DRAGGABLE_INTERFACE_EVENT_DRAG_START_LEFT;
660 right_drag = EVAS_DRAGGABLE_INTERFACE_EVENT_DRAG_START_RIGHT;
664 left_drag = EVAS_DRAGGABLE_INTERFACE_EVENT_DRAG_START_RIGHT;
665 right_drag = EVAS_DRAGGABLE_INTERFACE_EVENT_DRAG_START_LEFT;
669 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
670 if (!sd->was_selected)
672 it->unhighlight_cb(it);
679 eo_do(WIDGET(it), eo_event_callback_call
680 (EVAS_DRAGGABLE_INTERFACE_EVENT_DRAG_START_UP, eo_it));
684 eo_do(WIDGET(it), eo_event_callback_call(left_drag, eo_it));
690 eo_do(WIDGET(it), eo_event_callback_call
691 (EVAS_DRAGGABLE_INTERFACE_EVENT_DRAG_START_DOWN, eo_it));
695 eo_do(WIDGET(it), eo_event_callback_call(left_drag, eo_it));
697 eo_do(WIDGET(it), eo_event_callback_call(right_drag, eo_it));
704 _long_press_cb(void *data)
707 Elm_Gen_Item *it = data;
708 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
710 it->long_timer = NULL;
711 if (eo_do_ret(EO_OBJ(it), tmp, elm_wdg_item_disabled_get()) || (it->dragging))
712 return ECORE_CALLBACK_CANCEL;
713 sd->longpressed = EINA_TRUE;
714 eo_do(WIDGET(it), eo_event_callback_call
715 (EVAS_CLICKABLE_INTERFACE_EVENT_LONGPRESSED, EO_OBJ(it)));
717 if (sd->reorder_mode)
720 evas_object_raise(VIEW(it));
721 eo_do(WIDGET(it), elm_interface_scrollable_hold_set(EINA_TRUE));
722 eo_do(WIDGET(it), elm_interface_scrollable_bounce_allow_get(
724 &(sd->old_v_bounce)));
726 eo_do(WIDGET(it), elm_interface_scrollable_bounce_allow_set(EINA_FALSE, EINA_FALSE));
727 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
730 return ECORE_CALLBACK_CANCEL;
734 _item_highlight(Elm_Gen_Item *it)
736 const char *selectraise = NULL;
737 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
739 if (_is_no_select(it) ||
740 (!sd->highlight) || (it->highlighted) ||
741 (it->generation < sd->generation))
744 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
745 eo_do(WIDGET(it), eo_event_callback_call
746 (ELM_GENGRID_EVENT_HIGHLIGHTED, EO_OBJ(it)));
748 selectraise = edje_object_data_get(VIEW(it), "selectraise");
749 if ((selectraise) && (!strcmp(selectraise, "on")))
750 evas_object_stack_above(VIEW(it), sd->stack);
752 it->highlighted = EINA_TRUE;
756 _item_unhighlight(Elm_Gen_Item *it)
758 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
759 Elm_Object_Item *eo_it = EO_OBJ(it);
761 if (!it->highlighted ||
762 (it->generation < sd->generation))
765 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
766 eo_do(WIDGET(it), eo_event_callback_call(
767 ELM_GENGRID_EVENT_UNHIGHLIGHTED, eo_it));
769 evas_object_stack_below(VIEW(it), sd->stack);
771 it->highlighted = EINA_FALSE;
775 _item_mouse_down_cb(void *data,
776 Evas *evas EINA_UNUSED,
780 Evas_Event_Mouse_Down *ev = event_info;
781 Elm_Gen_Item *it = data;
783 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
787 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
788 it->dx = ev->canvas.x - x;
789 it->dy = ev->canvas.y - y;
793 if (ev->button != 1) return;
796 sd->mouse_down = EINA_TRUE;
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 sd->longpressed = EINA_FALSE;
802 it->base->still_in = EINA_TRUE;
804 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
805 sd->on_hold = EINA_TRUE;
806 else sd->on_hold = EINA_FALSE;
808 if (sd->on_hold) return;
810 sd->was_selected = it->selected;
811 it->highlight_cb(it);
812 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
815 eo_event_callback_call(EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED_DOUBLE, EO_OBJ(it)),
816 eo_event_callback_call(ELM_GENGRID_EVENT_ACTIVATED, EO_OBJ(it)));
819 eo_do(WIDGET(it), eo_event_callback_call(EVAS_CLICKABLE_INTERFACE_EVENT_PRESSED, EO_OBJ(it)));
820 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
822 it->long_timer = ecore_timer_add
823 (_elm_config->longpress_timeout, _long_press_cb, it);
825 it->long_timer = NULL;
829 _item_text_realize(Elm_Gen_Item *it,
838 if (!it->itc->func.text_get) return;
841 *source = elm_widget_stringlist_get
842 (edje_object_data_get(target, "texts"));
843 EINA_LIST_FOREACH(*source, l, key)
845 if (parts && fnmatch(parts, key, FNM_PERIOD)) continue;
847 s = it->itc->func.text_get
848 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
851 edje_object_part_text_escaped_set(target, key, s);
856 edje_object_part_text_set(target, key, "");
858 if (_elm_config->atspi_mode)
859 elm_interface_atspi_accessible_name_changed_signal_emit(EO_OBJ(it));
864 _item_content_realize(Elm_Gen_Item *it,
866 Eina_List **contents,
871 Evas_Object *content;
875 EINA_LIST_FREE(*contents, content)
876 evas_object_del(content);
878 if (it->itc->func.content_get)
883 source = elm_widget_stringlist_get(edje_object_data_get(target, src));
885 EINA_LIST_FREE(source, key)
887 if (parts && fnmatch(parts, key, FNM_PERIOD))
890 Evas_Object *old = edje_object_part_swallow_get(target, key);
893 *contents = eina_list_remove(*contents, old);
894 evas_object_del(old);
897 if (it->itc->func.content_get)
898 content = it->itc->func.content_get
899 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
900 if (!content) continue;
901 *contents = eina_list_append(*contents, content);
902 if (!edje_object_part_swallow(target, key, content))
904 ERR("%s (%p) can not be swallowed into %s",
905 evas_object_type_get(content), content, key);
906 evas_object_hide(content);
909 elm_widget_sub_object_add(WIDGET(it), content);
910 if (eo_do_ret(EO_OBJ(it), tmp, elm_wdg_item_disabled_get()))
911 elm_widget_disabled_set(content, EINA_TRUE);
913 if (_elm_config->atspi_mode && eo_isa(content, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
914 eo_do(content, elm_interface_atspi_accessible_parent_set(EO_OBJ(it)));
920 _item_state_realize(Elm_Gen_Item *it, Evas_Object *target, const char *parts)
926 if (!it->itc->func.state_get) return;
928 src = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
929 EINA_LIST_FREE(src, key)
931 if (parts && fnmatch(parts, key, FNM_PERIOD)) continue;
933 Eina_Bool on = it->itc->func.state_get
934 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
938 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
939 edje_object_signal_emit(target, buf, "elm");
943 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
944 edje_object_signal_emit(target, buf, "elm");
947 edje_object_message_signal_process(target);
951 _view_inflate(Evas_Object *view, Elm_Gen_Item *it, Eina_List **sources,
952 Eina_List **contents)
955 if (sources) _item_text_realize(it, view, sources, NULL);
956 if (contents) _item_content_realize(it, view, contents, "contents", NULL);
957 _item_state_realize(it, view, NULL);
961 * Apply the right style for the created item view.
964 _view_style_update(Elm_Gen_Item *it, Evas_Object *view, const char *style)
967 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
968 snprintf(buf, sizeof(buf), "item/%s", style ? style : "default");
970 if (!elm_widget_theme_object_set(WIDGET(it), view,
972 elm_widget_style_get(WIDGET(it))))
974 ERR("%s is not a valid gengrid item style. "
975 "Automatically falls back into default style.",
977 elm_widget_theme_object_set
978 (WIDGET(it), view, "gengrid", "item/default", "default");
981 edje_object_mirrored_set(view, elm_widget_mirrored_get(WIDGET(it)));
982 edje_object_scale_set(view, elm_widget_scale_get(WIDGET(it)) *
983 elm_config_scale_get());
984 evas_object_stack_below(view, sd->stack);
988 * Create a VIEW(it) during _item_realize()
991 _view_create(Elm_Gen_Item *it, const char *style)
993 Evas_Object *view = edje_object_add(evas_object_evas_get(WIDGET(it)));
994 evas_object_smart_member_add(view, GG_IT(it)->wsd->pan_obj);
995 elm_widget_sub_object_add(WIDGET(it), view);
996 edje_object_scale_set(view, elm_widget_scale_get(WIDGET(it)) *
997 elm_config_scale_get());
999 _view_style_update(it, view, style);
1004 _view_clear(Evas_Object *view, Eina_List **texts, Eina_List **contents)
1010 EINA_LIST_FOREACH(*texts, l, part)
1011 edje_object_part_text_set(view, part, NULL);
1012 ELM_SAFE_FREE(*texts, elm_widget_stringlist_free);
1014 EINA_LIST_FREE(*contents, c)
1019 _elm_gengrid_item_all_contents_unset(Eo *eo_item EINA_UNUSED, Elm_Gen_Item *it, Eina_List **l)
1021 Evas_Object *content;
1023 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
1025 EINA_LIST_FREE (it->contents, content)
1027 evas_object_smart_member_del(content);
1028 // edje can be reused by item caching,
1029 // content should be un-swallowed from edje
1030 edje_object_part_unswallow(VIEW(it), content);
1031 evas_object_hide(content);
1032 if (l) *l = eina_list_append(*l, content);
1037 _elm_gengrid_item_unrealize(Elm_Gen_Item *it,
1040 if (!it->realized) return;
1041 if (GG_IT(it)->wsd->reorder_it == it) return;
1043 evas_event_freeze(evas_object_evas_get(WIDGET(it)));
1045 eo_do(WIDGET(it), eo_event_callback_call(ELM_GENGRID_EVENT_UNREALIZED, EO_OBJ(it)));
1046 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
1048 _view_clear(VIEW(it), &(it->texts), &(it->contents));
1050 ELM_SAFE_FREE(it->states, elm_widget_stringlist_free);
1051 eo_do(EO_OBJ(it), elm_wdg_item_track_cancel());
1053 it->unrealize_cb(it);
1055 it->realized = EINA_FALSE;
1056 it->want_unrealize = EINA_FALSE;
1058 evas_event_thaw(evas_object_evas_get(WIDGET(it)));
1059 evas_event_thaw_eval(evas_object_evas_get(WIDGET(it)));
1063 _item_mouse_up_cb(void *data,
1064 Evas *evas EINA_UNUSED,
1065 Evas_Object *obj EINA_UNUSED,
1069 Evas_Event_Mouse_Up *ev = event_info;
1070 Eina_Bool dragged = EINA_FALSE;
1071 Elm_Gen_Item *it = data;
1072 Elm_Object_Item *eo_it = EO_OBJ(it);
1073 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
1074 Evas_Coord x, y, dx, dy;
1076 if ((ev->button == 3) && (!it->dragging))
1078 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1079 dx = it->dx - (ev->canvas.x - x);
1080 dy = it->dy - (ev->canvas.y - y);
1081 if (dx < 0) dx = -dx;
1082 if (dy < 0) dy = -dy;
1083 if ((dx < 5) && (dy < 5))
1084 eo_do(WIDGET(it), eo_event_callback_call
1085 (EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED_RIGHT, EO_OBJ(it)));
1089 if (ev->button != 1) return;
1091 it->down = EINA_FALSE;
1092 sd->mouse_down = EINA_FALSE;
1093 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1094 sd->on_hold = EINA_TRUE;
1095 else sd->on_hold = EINA_FALSE;
1097 eo_do(WIDGET(it), eo_event_callback_call
1098 (ELM_GENGRID_EVENT_RELEASED, eo_it));
1099 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
1102 it->dragging = EINA_FALSE;
1103 eo_do(WIDGET(it), eo_event_callback_call
1104 (EVAS_DRAGGABLE_INTERFACE_EVENT_DRAG_STOP, eo_it));
1105 dragged = EINA_TRUE;
1108 if ((sd->reorder_mode) &&
1111 eo_do (WIDGET(it), eo_event_callback_call
1112 (ELM_WIDGET_EVENT_MOVED, EO_OBJ(sd->reorder_it)));
1113 sd->reorder_it = NULL;
1114 sd->move_effect_enabled = EINA_FALSE;
1115 ecore_job_del(sd->calc_job);
1117 ecore_job_add(_calc_job, sd->obj);
1119 eo_do(WIDGET(it), elm_interface_scrollable_hold_set(EINA_FALSE));
1120 eo_do(WIDGET(it), elm_interface_scrollable_bounce_allow_set(
1121 sd->old_h_bounce, sd->old_v_bounce));
1123 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
1125 if (sd->longpressed)
1127 sd->longpressed = EINA_FALSE;
1128 if (!sd->was_selected)
1130 it->unhighlight_cb(it);
1133 sd->was_selected = EINA_FALSE;
1138 if (it->want_unrealize)
1139 _elm_gengrid_item_unrealize(it, EINA_FALSE);
1142 if (eo_do_ret(eo_it, tmp, elm_wdg_item_disabled_get())) return;
1144 if (sd->on_hold || !it->base->still_in)
1146 sd->longpressed = EINA_FALSE;
1147 sd->on_hold = EINA_FALSE;
1151 if (sd->focused_item != eo_it)
1152 elm_object_item_focus_set(eo_it, EINA_TRUE);
1155 ((sd->multi_select_mode != ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL) ||
1156 (evas_key_modifier_is_set(ev->modifiers, "Control"))))
1160 it->highlight_cb(it);
1165 it->unhighlight_cb(it);
1173 while (sd->selected)
1175 Elm_Object_Item *eo_sel = sd->selected->data;
1176 Elm_Gen_Item *sel = eo_data_scope_get(eo_sel, ELM_GENGRID_ITEM_CLASS);
1177 it->unhighlight_cb(sel);
1183 const Eina_List *l, *l_next;
1184 Elm_Object_Item *eo_item2;
1186 EINA_LIST_FOREACH_SAFE(sd->selected, l, l_next, eo_item2)
1188 ELM_GENGRID_ITEM_DATA_GET(eo_item2, item2);
1191 it->unhighlight_cb(item2);
1192 it->unsel_cb(item2);
1196 it->highlight_cb(it);
1202 _item_mouse_callbacks_add(Elm_Gen_Item *it,
1205 evas_object_event_callback_add
1206 (view, EVAS_CALLBACK_MOUSE_IN, _item_mouse_in_cb, it);
1207 evas_object_event_callback_add
1208 (view, EVAS_CALLBACK_MOUSE_MOVE, _item_mouse_move_cb, it);
1209 evas_object_event_callback_add
1210 (view, EVAS_CALLBACK_MOUSE_DOWN, _item_mouse_down_cb, it);
1211 evas_object_event_callback_add
1212 (view, EVAS_CALLBACK_MOUSE_UP, _item_mouse_up_cb, it);
1216 _item_mouse_callbacks_del(Elm_Gen_Item *it,
1219 evas_object_event_callback_del_full
1220 (view, EVAS_CALLBACK_MOUSE_IN, _item_mouse_in_cb, it);
1221 evas_object_event_callback_del_full
1222 (view, EVAS_CALLBACK_MOUSE_MOVE, _item_mouse_move_cb, it);
1223 evas_object_event_callback_del_full
1224 (view, EVAS_CALLBACK_MOUSE_DOWN, _item_mouse_down_cb, it);
1225 evas_object_event_callback_del_full
1226 (view, EVAS_CALLBACK_MOUSE_UP, _item_mouse_up_cb, it);
1232 _elm_gengrid_item_index_update(Elm_Gen_Item *it)
1234 if (it->position_update)
1236 eo_do(WIDGET(it), eo_event_callback_call
1237 (ELM_GENGRID_EVENT_INDEX_UPDATE, EO_OBJ(it)));
1238 it->position_update = EINA_FALSE;
1243 _item_unrealize_cb(Elm_Gen_Item *it)
1245 if (!_item_cache_add(it))
1247 ELM_SAFE_FREE(VIEW(it), evas_object_del);
1248 ELM_SAFE_FREE(it->spacer, evas_object_del);
1253 _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
1255 Elm_Gen_Item *it = (Elm_Gen_Item *)data;
1256 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, NULL);
1258 if (it->itc->func.text_get)
1263 if (!(it->texts)) it->texts =
1264 elm_widget_stringlist_get(edje_object_data_get(VIEW(it), "texts"));
1266 EINA_LIST_FOREACH(it->texts, l, key)
1268 char *s = it->itc->func.text_get
1269 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
1278 _access_state_cb(void *data, Evas_Object *obj EINA_UNUSED)
1280 Elm_Gen_Item *it = (Elm_Gen_Item *)data;
1281 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, NULL);
1283 if (it->base->disabled)
1284 return strdup(E_("State: Disabled"));
1290 _access_on_highlight_cb(void *data)
1292 Evas_Coord x, y, w, h;
1293 Evas_Coord sx, sy, sw, sh;
1294 Elm_Gen_Item *it = (Elm_Gen_Item *)data;
1295 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
1297 evas_object_geometry_get(it->base->view, &x, &y, &w, &h);
1299 evas_object_geometry_get(it->base->widget, &sx, &sy, &sw, &sh);
1300 if ((x < sx) || (y < sy) || ((x + w) > (sx + sw)) || ((y + h) > (sy + sh)))
1301 elm_gengrid_item_bring_in(EO_OBJ(it),
1302 ELM_GENGRID_ITEM_SCROLLTO_IN);
1306 _access_widget_item_register(Elm_Gen_Item *it)
1308 Elm_Access_Info *ai;
1310 _elm_access_widget_item_register(it->base);
1312 ai = _elm_access_info_get(it->base->access_obj);
1314 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Gengrid Item"));
1315 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it);
1316 _elm_access_callback_set(ai, ELM_ACCESS_STATE, _access_state_cb, it);
1317 _elm_access_on_highlight_hook_set(ai, _access_on_highlight_cb, it);
1321 _elm_gengrid_item_focus_update(Elm_Gen_Item *it)
1323 const char *focus_raise;
1324 Evas_Object *obj = WIDGET(it);
1325 ELM_GENGRID_DATA_GET(obj, sd);
1327 if (elm_widget_focus_highlight_enabled_get(obj) || _elm_config->win_auto_focus_enable)
1329 edje_object_signal_emit
1330 (VIEW(it), "elm,state,focused", "elm");
1333 focus_raise = edje_object_data_get(VIEW(it), "focusraise");
1334 if ((focus_raise) && (!strcmp(focus_raise, "on")))
1339 evas_object_raise(VIEW(it));
1340 EINA_LIST_FOREACH(sd->group_items, l, it1)
1342 if (GG_IT(it1)->group_realized)
1343 evas_object_raise(VIEW(it1));
1349 _item_realize(Elm_Gen_Item *it)
1352 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
1353 Elm_Object_Item *eo_it = EO_OBJ(it);
1355 if ((it->realized) ||
1356 (it->generation < sd->generation))
1359 if (!_item_cache_find(it))
1361 VIEW(it) = _view_create(it, it->itc->item_style);
1362 if (it->item->nocache_once)
1363 it->item->nocache_once = EINA_FALSE;
1366 if (it->spacer && edje_object_part_exists(VIEW(it), "elm.swallow.pad"))
1369 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1370 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1371 elm_widget_sub_object_add(WIDGET(it), it->spacer);
1372 evas_object_size_hint_min_set(it->spacer, 2 * elm_config_scale_get(), 1);
1373 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
1377 if (_elm_config->access_mode) _access_widget_item_register(it);
1379 /* infate texts, contents and states of view object */
1380 _view_inflate(VIEW(it), it, &it->texts, &it->contents);
1384 if ((!sd->group_item_width)
1385 && (!sd->group_item_height))
1387 edje_object_size_min_restricted_calc
1388 (VIEW(it), &sd->group_item_width,
1389 &sd->group_item_height,
1390 sd->group_item_width,
1391 sd->group_item_height);
1396 if ((!sd->item_width)
1397 && (!sd->item_height))
1399 edje_object_size_min_restricted_calc
1400 (VIEW(it), &sd->item_width,
1404 elm_coords_finger_size_adjust
1405 (1, &sd->item_width, 1,
1409 _item_mouse_callbacks_add(it, VIEW(it));
1410 _elm_gengrid_item_index_update(it);
1413 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1414 if (eo_do_ret(eo_it, tmp, elm_wdg_item_disabled_get()))
1415 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1417 edje_object_message_signal_process(VIEW(it));
1418 evas_object_show(VIEW(it));
1420 if (it->tooltip.content_cb)
1423 elm_wdg_item_tooltip_content_cb_set(
1424 it->tooltip.content_cb, it->tooltip.data, NULL),
1425 elm_wdg_item_tooltip_style_set(it->tooltip.style),
1426 elm_wdg_item_tooltip_window_mode_set(it->tooltip.free_size));
1429 if (it->mouse_cursor)
1430 eo_do(eo_it, elm_wdg_item_cursor_set(it->mouse_cursor));
1432 if (it->cursor_engine_only)
1433 eo_do(eo_it, elm_wdg_item_cursor_engine_only_set(it->cursor_engine_only));
1435 if (eo_it == sd->focused_item)
1437 _elm_gengrid_item_focus_update(it);
1438 _elm_widget_item_highlight_in_theme(WIDGET(it), EO_OBJ(it));
1439 _elm_widget_highlight_in_theme_update(WIDGET(it));
1440 _elm_widget_focus_highlight_start(WIDGET(it));
1443 it->realized = EINA_TRUE;
1444 it->want_unrealize = EINA_FALSE;
1448 _reorder_item_move_animator_cb(void *data)
1450 Elm_Gen_Item *it = data;
1453 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
1455 tt = REORDER_EFFECT_TIME;
1456 t = ((0.0 > (t = ecore_loop_time_get() -
1457 GG_IT(it)->moving_effect_start_time)) ? 0.0 : t);
1458 dx = ((GG_IT(it)->tx - GG_IT(it)->ox) / 10)
1459 * elm_config_scale_get();
1460 dy = ((GG_IT(it)->ty - GG_IT(it)->oy) / 10)
1461 * elm_config_scale_get();
1465 GG_IT(it)->rx += (1 * sin((t / tt) * (M_PI / 2)) * dx);
1466 GG_IT(it)->ry += (1 * sin((t / tt) * (M_PI / 2)) * dy);
1470 GG_IT(it)->rx += dx;
1471 GG_IT(it)->ry += dy;
1474 if (((dx > 0) && (GG_IT(it)->rx >= GG_IT(it)->tx)) ||
1475 ((dx <= 0) && (GG_IT(it)->rx <= GG_IT(it)->tx))
1476 || ((dy > 0) && (GG_IT(it)->ry >= GG_IT(it)->ty)) ||
1477 ((dy <= 0) && (GG_IT(it)->ry <= GG_IT(it)->ty)))
1479 evas_object_move(VIEW(it), GG_IT(it)->tx, GG_IT(it)->ty);
1484 evas_object_geometry_get
1485 (sd->pan_obj, NULL, NULL, &vw, &vh);
1488 (VIEW(it), sd->group_item_width, vh);
1491 (VIEW(it), vw, sd->group_item_height);
1494 evas_object_resize(VIEW(it), sd->item_width, sd->item_height);
1495 GG_IT(it)->moving = EINA_FALSE;
1496 GG_IT(it)->item_reorder_move_animator = NULL;
1498 return ECORE_CALLBACK_CANCEL;
1501 evas_object_move(VIEW(it), GG_IT(it)->rx, GG_IT(it)->ry);
1506 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &vw, &vh);
1508 evas_object_resize(VIEW(it), sd->group_item_width, vh);
1510 evas_object_resize(VIEW(it), vw, sd->group_item_height);
1513 evas_object_resize(VIEW(it), sd->item_width, sd->item_height);
1515 return ECORE_CALLBACK_RENEW;
1519 _item_place(Elm_Gen_Item *it,
1523 Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1524 Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1525 Eina_Bool reorder_item_move_forward = EINA_FALSE;
1526 Eina_Bool was_realized;
1527 Elm_Gen_Item_Type *item;
1532 ELM_GENGRID_DATA_GET_FROM_ITEM(it, wsd);
1536 evas_object_geometry_get(wsd->pan_obj, &ox, &oy, &vw, &vh);
1538 /* Preload rows/columns at each side of the Gengrid */
1539 cvx = ox - PRELOAD * wsd->item_width;
1540 cvy = oy - PRELOAD * wsd->item_height;
1541 cvw = vw + 2 * PRELOAD * wsd->item_width;
1542 cvh = vh + 2 * PRELOAD * wsd->item_height;
1544 items_count = wsd->item_count -
1545 eina_list_count(wsd->group_items) + wsd->items_lost;
1546 if (wsd->horizontal)
1548 int columns, items_visible = 0, items_row;
1550 if (wsd->item_height > 0)
1551 items_visible = vh / wsd->item_height;
1552 if (items_visible < 1)
1555 columns = items_count / items_visible;
1556 if (items_count % items_visible)
1559 tcw = (wsd->item_width * columns) + (wsd->group_item_width *
1560 eina_list_count(wsd->group_items));
1561 alignw = (vw - tcw) * wsd->align_x;
1563 items_row = items_visible;
1564 if ((unsigned int)items_row > wsd->item_count)
1565 items_row = wsd->item_count;
1566 if (wsd->filled && (unsigned int)wsd->nmax
1567 > (unsigned int)wsd->item_count)
1568 tch = wsd->nmax * wsd->item_height;
1570 tch = items_row * wsd->item_height;
1571 alignh = (vh - tch) * wsd->align_y;
1572 item_pos = items_row * cx + cy + 1;
1573 if (item_pos != it->position && !it->position_update)
1575 it->position = item_pos;
1576 it->position_update = EINA_TRUE;
1581 unsigned int rows, items_visible = 0, items_col;
1583 if (wsd->item_width > 0)
1584 items_visible = vw / wsd->item_width;
1585 if (items_visible < 1)
1588 rows = items_count / items_visible;
1589 if (items_count % items_visible)
1592 tch = (wsd->item_height * rows) + (wsd->group_item_height *
1593 eina_list_count(wsd->group_items));
1594 alignh = (vh - tch) * wsd->align_y;
1596 items_col = items_visible;
1597 if (items_col > wsd->item_count)
1598 items_col = wsd->item_count;
1599 if (wsd->filled && (unsigned int)wsd->nmax
1600 > (unsigned int)wsd->item_count)
1601 tcw = wsd->nmax * wsd->item_width;
1603 tcw = items_col * wsd->item_width;
1604 alignw = (vw - tcw) * wsd->align_x;
1605 item_pos = cx + items_col * cy + 1;
1606 if (item_pos != it->position && !it->position_update)
1608 it->position = item_pos;
1609 it->position_update = EINA_TRUE;
1615 if (wsd->horizontal)
1617 x = (((cx - item->prev_group) * wsd->item_width)
1618 + (item->prev_group * wsd->group_item_width)) -
1619 wsd->pan_x + ox + alignw;
1621 iw = wsd->group_item_width;
1627 y = (((cy - item->prev_group) * wsd->item_height)
1628 + (item->prev_group * wsd->group_item_height))
1629 - wsd->pan_y + oy + alignh;
1631 ih = wsd->group_item_height;
1638 if (wsd->horizontal)
1640 x = (((cx - item->prev_group) * wsd->item_width)
1641 + (item->prev_group * wsd->group_item_width)) -
1642 wsd->pan_x + ox + alignw;
1643 y = (cy * wsd->item_height) - wsd->pan_y + oy + alignh;
1647 x = (cx * wsd->item_width) - wsd->pan_x + ox + alignw;
1648 y = (((cy - item->prev_group)
1649 * wsd->item_height) + (item->prev_group *
1650 wsd->group_item_height)) -
1651 wsd->pan_y + oy + alignh;
1653 if (elm_widget_mirrored_get(WIDGET(it))) /* Switch items side
1654 * and componsate for
1658 evas_object_geometry_get(WIDGET(it), NULL, NULL, &ww, NULL);
1659 x = ww - x - wsd->item_width - wsd->pan_x - wsd->pan_x + ox + ox;
1661 iw = wsd->item_width;
1662 ih = wsd->item_height;
1665 was_realized = it->realized;
1666 if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1671 _elm_gengrid_item_index_update(it);
1672 eo_do(WIDGET(it), eo_event_callback_call
1673 (ELM_GENGRID_EVENT_REALIZED, EO_OBJ(it)));
1677 if (wsd->horizontal)
1679 if (it->parent->item->gx < ox)
1681 it->parent->item->gx = x + wsd->item_width -
1682 wsd->group_item_width;
1683 if (it->parent->item->gx > ox)
1684 it->parent->item->gx = ox;
1686 it->parent->item->group_realized = EINA_TRUE;
1690 if (it->parent->item->gy < oy)
1692 it->parent->item->gy = y + wsd->item_height -
1693 wsd->group_item_height;
1694 if (it->parent->item->gy > oy)
1695 it->parent->item->gy = oy;
1697 it->parent->item->group_realized = EINA_TRUE;
1700 if (wsd->reorder_mode)
1702 if (wsd->reorder_it)
1704 if (item->moving) return;
1706 if (!wsd->move_effect_enabled)
1711 if (wsd->reorder_it == it)
1713 evas_object_move(VIEW(it), wsd->reorder_item_x,
1714 wsd->reorder_item_y);
1715 evas_object_resize(VIEW(it), iw, ih);
1720 Evas_Coord nx, ny, nw, nh;
1722 if (wsd->move_effect_enabled)
1724 if ((item->ox != x) || (item->oy != y))
1725 if (((wsd->old_pan_x == wsd->pan_x)
1726 && (wsd->old_pan_y == wsd->pan_y))
1727 || ((wsd->old_pan_x != wsd->pan_x) &&
1728 !(item->ox - wsd->pan_x
1729 + wsd->old_pan_x == x)) ||
1730 ((wsd->old_pan_y != wsd->pan_y) &&
1731 !(item->oy - wsd->pan_y +
1732 wsd->old_pan_y == y)))
1736 item->rx = item->ox;
1737 item->ry = item->oy;
1738 item->moving = EINA_TRUE;
1739 item->moving_effect_start_time =
1740 ecore_loop_time_get();
1741 item->item_reorder_move_animator =
1743 (_reorder_item_move_animator_cb, it);
1751 if (wsd->horizontal)
1753 nx = x + (wsd->group_item_width / 2);
1761 ny = y + (wsd->group_item_height / 2);
1768 nx = x + (wsd->item_width / 2);
1769 ny = y + (wsd->item_height / 2);
1774 if (ELM_RECTS_INTERSECT
1775 (wsd->reorder_item_x, wsd->reorder_item_y,
1776 wsd->item_width, wsd->item_height,
1779 if (wsd->horizontal)
1781 if ((wsd->nmax * wsd->reorder_it->x +
1782 wsd->reorder_it->y) >
1783 (wsd->nmax * it->x + it->y))
1784 reorder_item_move_forward = EINA_TRUE;
1788 if ((wsd->nmax * wsd->reorder_it->y +
1789 wsd->reorder_it->x) >
1790 (wsd->nmax * it->y + it->x))
1791 reorder_item_move_forward = EINA_TRUE;
1794 wsd->items = eina_inlist_remove
1796 EINA_INLIST_GET(wsd->reorder_it));
1797 if (reorder_item_move_forward)
1798 wsd->items = eina_inlist_prepend_relative
1800 EINA_INLIST_GET(wsd->reorder_it),
1801 EINA_INLIST_GET(it));
1803 wsd->items = eina_inlist_append_relative
1805 EINA_INLIST_GET(wsd->reorder_it),
1806 EINA_INLIST_GET(it));
1808 wsd->reorder_item_changed = EINA_TRUE;
1809 wsd->move_effect_enabled = EINA_TRUE;
1810 ecore_job_del(wsd->calc_job);
1812 ecore_job_add(_calc_job, wsd->obj);
1818 else if (item->item_reorder_move_animator)
1820 ELM_SAFE_FREE(item->item_reorder_move_animator,
1821 ecore_animator_del);
1822 item->moving = EINA_FALSE;
1827 evas_object_move(VIEW(it), x, y);
1828 evas_object_resize(VIEW(it), iw, ih);
1831 item->group_realized = EINA_TRUE;
1836 _elm_gengrid_item_unrealize(it, EINA_FALSE);
1838 item->group_realized = EINA_FALSE;
1843 _group_item_place(Elm_Gengrid_Pan_Data *psd)
1845 Evas_Coord iw, ih, vw, vh;
1846 Eina_Bool was_realized;
1850 evas_object_geometry_get(psd->wsd->pan_obj, NULL, NULL, &vw, &vh);
1851 if (psd->wsd->horizontal)
1853 iw = psd->wsd->group_item_width;
1859 ih = psd->wsd->group_item_height;
1862 EINA_LIST_FOREACH(psd->wsd->group_items, l, it)
1864 was_realized = it->realized;
1865 if (GG_IT(it)->group_realized)
1870 _elm_gengrid_item_index_update(it);
1871 eo_do(WIDGET(it), eo_event_callback_call
1872 (ELM_GENGRID_EVENT_REALIZED, EO_OBJ(it)));
1875 (VIEW(it), GG_IT(it)->gx,
1877 evas_object_resize(VIEW(it), iw, ih);
1878 evas_object_raise(VIEW(it));
1881 _elm_gengrid_item_unrealize(it, EINA_FALSE);
1886 _elm_gengrid_pan_evas_object_smart_calculate(Eo *obj EINA_UNUSED, Elm_Gengrid_Pan_Data *psd)
1888 Evas_Coord cx = 0, cy = 0;
1891 Elm_Gengrid_Data *sd = psd->wsd;
1893 if (!sd->nmax) return;
1895 sd->reorder_item_changed = EINA_FALSE;
1897 EINA_INLIST_FOREACH(sd->items, it)
1919 _item_place(it, cx, cy);
1920 if (sd->reorder_item_changed) return;
1938 cy = (cy + 1) % sd->nmax;
1943 cx = (cx + 1) % sd->nmax;
1948 _group_item_place(psd);
1950 if ((sd->reorder_mode) && (sd->reorder_it))
1952 if (!sd->reorder_item_changed)
1954 sd->old_pan_x = sd->pan_x;
1955 sd->old_pan_y = sd->pan_y;
1957 sd->move_effect_enabled = EINA_FALSE;
1960 eo_do(psd->wobj, eo_event_callback_call
1961 (ELM_INTERFACE_SCROLLABLE_EVENT_CHANGED, NULL));
1963 if (sd->focused_item)
1964 _elm_widget_focus_highlight_start(psd->wobj);
1968 _elm_gengrid_pan_elm_pan_pos_set(Eo *obj, Elm_Gengrid_Pan_Data *psd, Evas_Coord x, Evas_Coord y)
1970 if ((x == psd->wsd->pan_x) && (y == psd->wsd->pan_y)) return;
1971 psd->wsd->pan_x = x;
1972 psd->wsd->pan_y = y;
1973 evas_object_smart_changed(obj);
1977 _elm_gengrid_pan_elm_pan_pos_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Pan_Data *psd, Evas_Coord *x, Evas_Coord *y)
1979 if (x) *x = psd->wsd->pan_x;
1980 if (y) *y = psd->wsd->pan_y;
1984 _elm_gengrid_pan_elm_pan_content_size_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Pan_Data *psd, Evas_Coord *w, Evas_Coord *h)
1986 if (w) *w = psd->wsd->minw;
1987 if (h) *h = psd->wsd->minh;
1991 _elm_gengrid_pan_elm_pan_pos_max_get(Eo *obj, Elm_Gengrid_Pan_Data *psd, Evas_Coord *x, Evas_Coord *y)
1995 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1997 *x = (ow < psd->wsd->minw) ? psd->wsd->minw - ow : 0;
1999 *y = (oh < psd->wsd->minh) ? psd->wsd->minh - oh : 0;
2003 _elm_gengrid_pan_elm_pan_pos_min_get(Eo *obj, Elm_Gengrid_Pan_Data *psd, Evas_Coord *x, Evas_Coord *y)
2005 Evas_Coord mx = 0, my = 0;
2006 Eina_Bool mirrored = elm_widget_mirrored_get(psd->wsd->obj);
2008 eo_do(obj, elm_obj_pan_pos_max_get(&mx, &my));
2010 *x = -mx * (mirrored ? 1 - psd->wsd->align_x : psd->wsd->align_x);
2012 *y = -my * psd->wsd->align_y;
2016 _elm_gengrid_pan_class_constructor(Eo_Class *klass)
2018 evas_smart_legacy_type_register(MY_PAN_CLASS_NAME_LEGACY, klass);
2021 #include "elm_gengrid_pan.eo.c"
2024 _elm_gengrid_item_focused(Elm_Object_Item *eo_it)
2027 ELM_GENGRID_ITEM_DATA_GET(eo_it, it);
2028 Evas_Object *obj = WIDGET(it);
2029 ELM_GENGRID_DATA_GET(obj, sd);
2031 if (it->generation < sd->generation)
2034 if (_is_no_select(it) ||
2035 (eo_it == sd->focused_item) ||
2036 (eo_do_ret(eo_it, tmp, elm_wdg_item_disabled_get())))
2039 switch (_elm_config->focus_autoscroll_mode)
2041 case ELM_FOCUS_AUTOSCROLL_MODE_SHOW:
2042 elm_gengrid_item_show
2043 (eo_it, ELM_GENGRID_ITEM_SCROLLTO_IN);
2045 case ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN:
2046 elm_gengrid_item_bring_in
2047 (eo_it, ELM_GENGRID_ITEM_SCROLLTO_IN);
2053 sd->focused_item = eo_it;
2055 /* If item is not realized state, widget couldn't get focus_highlight data. */
2058 _elm_gengrid_item_focus_update(it);
2059 _elm_widget_item_highlight_in_theme(obj, eo_it);
2060 _elm_widget_highlight_in_theme_update(obj);
2061 _elm_widget_focus_highlight_start(obj);
2064 eo_do(obj, eo_event_callback_call(ELM_GENGRID_EVENT_ITEM_FOCUSED, eo_it));
2065 if (_elm_config->atspi_mode)
2066 elm_interface_atspi_accessible_state_changed_signal_emit(eo_it, ELM_ATSPI_STATE_FOCUSED, EINA_TRUE);
2070 _elm_gengrid_item_unfocused(Elm_Object_Item *eo_it)
2072 ELM_GENGRID_ITEM_DATA_GET(eo_it, it);
2073 Evas_Object *obj = WIDGET(it);
2074 ELM_GENGRID_DATA_GET(obj, sd);
2076 if (it->generation < sd->generation)
2079 if (_is_no_select(it))
2082 if ((!sd->focused_item) ||
2083 (eo_it != sd->focused_item))
2086 if (elm_widget_focus_highlight_enabled_get(obj) || _elm_config->win_auto_focus_enable)
2088 ELM_GENGRID_ITEM_DATA_GET(sd->focused_item, focus_it);
2089 edje_object_signal_emit
2090 (VIEW(focus_it), "elm,state,unfocused", "elm");
2093 sd->focused_item = NULL;
2094 eo_do(obj, eo_event_callback_call(ELM_GENGRID_EVENT_ITEM_UNFOCUSED, eo_it));
2095 if (_elm_config->atspi_mode)
2096 elm_interface_atspi_accessible_state_changed_signal_emit(eo_it, ELM_ATSPI_STATE_FOCUSED, EINA_FALSE);
2100 _item_focus_up(Elm_Gengrid_Data *sd)
2103 Elm_Gen_Item *prev = NULL;
2105 if (!sd->focused_item)
2107 prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
2108 while ((prev) && (prev->generation < sd->generation))
2109 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
2110 elm_object_item_focus_set(EO_OBJ(prev), EINA_TRUE);
2115 Elm_Object_Item *eo_prev = elm_gengrid_item_prev_get(sd->focused_item);
2116 if (!eo_prev) return EINA_FALSE;
2117 prev = eo_data_scope_get(eo_prev, ELM_GENGRID_ITEM_CLASS);
2118 if (eo_prev == sd->focused_item) return EINA_FALSE;
2121 for (i = 1; i < sd->nmax; i++)
2123 Elm_Object_Item *eo_tmp =
2124 elm_gengrid_item_prev_get(EO_OBJ(prev));
2125 if (!eo_tmp) return EINA_FALSE;
2126 prev = eo_data_scope_get(eo_tmp, ELM_GENGRID_ITEM_CLASS);
2129 elm_object_item_focus_set(EO_OBJ(prev), EINA_TRUE);
2135 _item_focus_down(Elm_Gengrid_Data *sd)
2137 unsigned int i, idx;
2138 Elm_Gen_Item *next = NULL;
2139 Elm_Object_Item *eo_tmp = NULL;
2141 if (!sd->focused_item)
2143 next = ELM_GEN_ITEM_FROM_INLIST(sd->items);
2144 while ((next) && (next->generation < sd->generation))
2145 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
2150 idx = elm_gengrid_item_index_get(sd->focused_item);
2152 if (idx > sd->item_count -
2153 ((sd->item_count % sd->nmax) == 0 ?
2154 sd->nmax : (sd->item_count % sd->nmax)))
2156 if (idx > sd->item_count - sd->nmax)
2158 eo_tmp = elm_gengrid_last_item_get(sd->obj);
2159 next = eo_data_scope_get(eo_tmp, ELM_GENGRID_ITEM_CLASS);
2163 next = eo_data_scope_get(sd->focused_item, ELM_GENGRID_ITEM_CLASS);
2164 for (i = 0; i < sd->nmax; i++)
2166 eo_tmp = elm_gengrid_item_next_get(EO_OBJ(next));
2167 if (!eo_tmp) return EINA_FALSE;
2168 next = eo_data_scope_get(eo_tmp, ELM_GENGRID_ITEM_CLASS);
2173 elm_object_item_focus_set(EO_OBJ(next), EINA_TRUE);
2179 _item_focus_left(Elm_Gengrid_Data *sd)
2183 if (!sd->focused_item)
2185 prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
2186 while ((prev) && (prev->generation < sd->generation))
2187 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
2191 Elm_Object_Item *eo_prev = elm_gengrid_item_prev_get(sd->focused_item);
2192 if (!eo_prev) return EINA_FALSE;
2193 prev = eo_data_scope_get(eo_prev, ELM_GENGRID_ITEM_CLASS);
2194 if (eo_prev == sd->focused_item) return EINA_FALSE;
2197 elm_object_item_focus_set(EO_OBJ(prev), EINA_TRUE);
2203 _item_focus_right(Elm_Gengrid_Data *sd)
2207 if (!sd->focused_item)
2209 next = ELM_GEN_ITEM_FROM_INLIST(sd->items);
2210 while ((next) && (next->generation < sd->generation))
2211 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
2215 Elm_Object_Item *eo_next = elm_gengrid_item_next_get(sd->focused_item);
2216 if (!eo_next) return EINA_FALSE;
2217 next = eo_data_scope_get(eo_next, ELM_GENGRID_ITEM_CLASS);
2218 if (eo_next == sd->focused_item) return EINA_FALSE;
2221 elm_object_item_focus_set(EO_OBJ(next), EINA_TRUE);
2227 _item_multi_select_left(Elm_Gengrid_Data *sd)
2229 Elm_Object_Item *eo_prev;
2231 if (!sd->selected) return EINA_FALSE;
2233 eo_prev = elm_gengrid_item_prev_get(sd->last_selected_item);
2234 if (!eo_prev) return EINA_TRUE;
2236 if (elm_gengrid_item_selected_get(eo_prev))
2238 elm_gengrid_item_selected_set(sd->last_selected_item, EINA_FALSE);
2239 sd->last_selected_item = eo_prev;
2240 elm_gengrid_item_show
2241 (eo_prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
2245 elm_gengrid_item_selected_set(eo_prev, EINA_TRUE);
2246 elm_gengrid_item_show(eo_prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
2253 _item_multi_select_right(Elm_Gengrid_Data *sd)
2255 Elm_Object_Item *eo_next;
2257 if (!sd->selected) return EINA_FALSE;
2259 eo_next = elm_gengrid_item_next_get(sd->last_selected_item);
2260 if (!eo_next) return EINA_TRUE;
2262 if (elm_gengrid_item_selected_get(eo_next))
2264 elm_gengrid_item_selected_set(sd->last_selected_item, EINA_FALSE);
2265 sd->last_selected_item = eo_next;
2266 elm_gengrid_item_show
2267 (eo_next, ELM_GENGRID_ITEM_SCROLLTO_IN);
2271 elm_gengrid_item_selected_set(eo_next, EINA_TRUE);
2272 elm_gengrid_item_show(eo_next, ELM_GENGRID_ITEM_SCROLLTO_IN);
2279 _item_multi_select_up(Elm_Gengrid_Data *sd)
2282 Eina_Bool r = EINA_TRUE;
2284 if (!sd->selected) return EINA_FALSE;
2286 for (i = 0; (r) && (i < sd->nmax); i++)
2287 r &= _item_multi_select_left(sd);
2293 _item_multi_select_down(Elm_Gengrid_Data *sd)
2296 Eina_Bool r = EINA_TRUE;
2298 if (!sd->selected) return EINA_FALSE;
2300 for (i = 0; (r) && (i < sd->nmax); i++)
2301 r &= _item_multi_select_right(sd);
2307 _all_items_deselect(Elm_Gengrid_Data *sd)
2309 if (!sd->selected) return EINA_FALSE;
2311 while (sd->selected)
2313 Elm_Object_Item *eo_it = sd->selected->data;
2314 elm_gengrid_item_selected_set(eo_it, EINA_FALSE);
2321 _item_single_select_up(Elm_Gengrid_Data *sd)
2324 Elm_Object_Item *eo_prev;
2327 eo_prev = EO_OBJ(ELM_GEN_ITEM_FROM_INLIST(sd->items->last));
2329 eo_prev = sd->last_selected_item;
2333 for (i = 0; i < sd->nmax; i++)
2335 eo_prev = elm_gengrid_item_prev_get(eo_prev);
2336 if (!eo_prev) return EINA_FALSE;
2339 if (!elm_object_item_disabled_get(eo_prev)) break;
2342 if (!eo_prev) return EINA_FALSE;
2344 _all_items_deselect(sd);
2345 elm_gengrid_item_selected_set(eo_prev, EINA_TRUE);
2351 _item_single_select_down(Elm_Gengrid_Data *sd)
2355 Elm_Object_Item *eo_next, *eo_orig;
2358 eo_next = EO_OBJ(ELM_GEN_ITEM_FROM_INLIST(sd->items));
2360 eo_next = sd->last_selected_item;
2365 for (i = 0; i < sd->nmax; i++)
2367 eo_next = elm_gengrid_item_next_get(eo_next);
2368 if (!eo_next) break;
2371 if (eo_next && !elm_object_item_disabled_get(eo_next)) break;
2376 idx = elm_gengrid_item_index_get(eo_orig);
2377 if (idx > sd->item_count -
2378 ((sd->item_count % sd->nmax) == 0 ?
2379 sd->nmax : (sd->item_count % sd->nmax)))
2382 eo_next = elm_gengrid_last_item_get(sd->obj);
2385 _all_items_deselect(sd);
2386 elm_gengrid_item_selected_set(eo_next, EINA_TRUE);
2392 _item_single_select_left(Elm_Gengrid_Data *sd)
2398 prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
2399 while ((prev) && (prev->generation < sd->generation)
2400 && elm_object_item_disabled_get(EO_OBJ(prev)))
2401 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
2405 Elm_Object_Item *eo_prev =
2406 elm_gengrid_item_prev_get(sd->last_selected_item);
2409 if (!elm_object_item_disabled_get(eo_prev))
2411 eo_prev = elm_gengrid_item_prev_get(eo_prev);
2413 prev = eo_data_scope_get(eo_prev, ELM_GENGRID_ITEM_CLASS);
2416 if (!prev) return EINA_FALSE;
2418 _all_items_deselect(sd);
2420 elm_gengrid_item_selected_set(EO_OBJ(prev), EINA_TRUE);
2426 _item_single_select_right(Elm_Gengrid_Data *sd)
2432 next = ELM_GEN_ITEM_FROM_INLIST(sd->items);
2433 while ((next) && (next->generation < sd->generation)
2434 && elm_object_item_disabled_get(EO_OBJ(next)))
2435 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
2439 Elm_Object_Item *eo_next =
2440 elm_gengrid_item_next_get(sd->last_selected_item);
2443 if (!elm_object_item_disabled_get(eo_next))
2445 eo_next = elm_gengrid_item_next_get(eo_next);
2447 next = eo_data_scope_get(eo_next, ELM_GENGRID_ITEM_CLASS);
2450 if (!next) return EINA_FALSE;
2452 _all_items_deselect(sd);
2454 elm_gengrid_item_selected_set(EO_OBJ(next), EINA_TRUE);
2460 _elm_gengrid_item_edge_check(Elm_Object_Item *eo_it,
2461 Elm_Focus_Direction dir)
2463 ELM_GENGRID_ITEM_DATA_GET(eo_it, it);
2464 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2465 ELM_GENGRID_DATA_GET(WIDGET(it), sd);
2466 Evas_Coord ix = 0, iy = 0; //item's geometry
2467 Evas_Coord cx = 0, cy = 0; //prev or next item's geometry
2468 Elm_Object_Item *eo_item = NULL;
2469 Elm_Gen_Item *tmp = it;
2470 Eina_Bool mirrored = elm_widget_mirrored_get(WIDGET(it));
2472 evas_object_geometry_get(VIEW(it), &ix, &iy, NULL, NULL);
2474 if (((sd->horizontal) && (dir == ELM_FOCUS_UP)) ||
2475 ((!sd->horizontal) && (dir == ELM_FOCUS_LEFT)))
2477 eo_item = elm_gengrid_item_prev_get(EO_OBJ(it));
2480 if (sd->reorder_mode || !elm_object_item_disabled_get(eo_item)) break;
2481 eo_item = elm_gengrid_item_prev_get(eo_item);
2485 ELM_GENGRID_ITEM_DATA_GET(eo_item, item);
2486 evas_object_geometry_get(VIEW(item), &cx, &cy, NULL, NULL);
2487 if ((sd->horizontal) && (ix == cx) && (iy > cy))
2489 else if ((!sd->horizontal) && (iy == cy))
2491 if ((!mirrored && (ix > cx)) || (mirrored && (ix < cx)))
2499 if ((dir == ELM_FOCUS_UP) || (!eo_item && sd->reorder_mode))
2502 else if (((sd->horizontal) && (dir == ELM_FOCUS_DOWN)) ||
2503 ((!sd->horizontal) && (dir == ELM_FOCUS_RIGHT)))
2505 eo_item = elm_gengrid_item_next_get(EO_OBJ(it));
2508 if (sd->reorder_mode || !elm_object_item_disabled_get(eo_item)) break;
2509 eo_item = elm_gengrid_item_next_get(eo_item);
2513 ELM_GENGRID_ITEM_DATA_GET(eo_item, item);
2514 evas_object_geometry_get(VIEW(item), &cx, &cy, NULL, NULL);
2515 if ((sd->horizontal) && (ix == cx) && (iy < cy))
2517 else if ((!sd->horizontal) && (iy == cy))
2519 if ((!mirrored && (ix < cx)) || (mirrored && (ix > cx)))
2527 if ((dir == ELM_FOCUS_DOWN) || (!eo_item && sd->reorder_mode))
2530 else if (((!sd->horizontal) && (dir == ELM_FOCUS_UP)) ||
2531 ((sd->horizontal) && (dir == ELM_FOCUS_LEFT)))
2533 Evas_Coord col, row, cvw, cvh;
2535 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh);
2536 if (sd->horizontal && sd->item_height > 0)
2538 row = cvh / sd->item_height;
2539 if (row <= 0) row = 1;
2540 col = tmp->position / row;
2544 else if (sd->item_width > 0)
2546 col = cvw / sd->item_width;
2547 if (col <= 0) col = 1;
2548 row = tmp->position / col;
2553 else if (((!sd->horizontal) && (dir == ELM_FOCUS_DOWN)) ||
2554 ((sd->horizontal) && (dir == ELM_FOCUS_RIGHT)))
2556 Evas_Coord col = 0, row = 0, cvw, cvh;
2559 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh);
2560 if (sd->horizontal && sd->item_height > 0)
2562 row = cvh / sd->item_height;
2563 if (row <= 0) row = 1;
2564 col = sd->item_count / row;
2565 x = sd->item_count % row;
2568 if ((tmp->position <= (row * col)) &&
2569 (tmp->position > (row * (col - 1))))
2574 if ((tmp->position <= ((col * row) + x)) &&
2575 (tmp->position > ((col - 1) * row) + x))
2579 else if (sd->item_width > 0)
2581 col = cvw / sd->item_width;
2582 if (col <= 0) col = 1;
2583 row = sd->item_count / col;
2584 x = sd->item_count % col;
2587 if ((tmp->position <= (col * row)) &&
2588 (tmp->position > (col * (row - 1))))
2593 if ((tmp->position <= ((col * row) + x)) &&
2594 (tmp->position > (((col * (row - 1)) + x))))
2603 static Elm_Object_Item *
2604 get_up_item(Elm_Gengrid_Data *sd, Elm_Object_Item *eo_it)
2606 Elm_Object_Item *eo_prev = NULL;
2609 eo_prev = elm_gengrid_item_prev_get(eo_it);
2613 for (i = 1; i < sd->nmax; i++)
2615 Elm_Object_Item *eo_tmp = elm_gengrid_item_prev_get(eo_prev);
2616 if (!eo_tmp) return eo_prev;
2623 static Elm_Object_Item *
2624 get_down_item(Elm_Gengrid_Data *sd, Elm_Object_Item *eo_it)
2626 Elm_Object_Item *eo_next = NULL;
2629 eo_next = elm_gengrid_item_next_get(eo_it);
2633 for (i = 1; i < sd->nmax; i++)
2635 Elm_Object_Item *eo_tmp = elm_gengrid_item_next_get(eo_next);
2636 if (!eo_tmp) return eo_next;
2643 typedef struct _Item_Info
2649 typedef struct _Reorder_Normal_Data
2652 Elm_Gen_Item *corner_item;
2654 } Reorder_Normal_Data;
2657 _free_reorder_normal_data(Reorder_Normal_Data *rnd)
2664 _anim_end(Elm_Gengrid_Data *sd)
2666 Eina_Inlist *tmp = NULL;
2667 Elm_Gen_Item *it1_prev = NULL, *it2_prev = NULL;
2668 it1_prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(sd->reorder.it1)->prev);
2669 it2_prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(sd->reorder.it2)->prev);
2671 if ((sd->reorder.type == ELM_GENGRID_REORDER_TYPE_NORMAL) &&
2672 ((!sd->horizontal && ((sd->reorder.dir == ELM_FOCUS_UP) || (sd->reorder.dir == ELM_FOCUS_DOWN))) ||
2673 (sd->horizontal && ((sd->reorder.dir == ELM_FOCUS_LEFT) || (sd->reorder.dir == ELM_FOCUS_RIGHT)))))
2675 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(sd->reorder.it1));
2676 if ((sd->reorder.dir == ELM_FOCUS_UP) ||
2677 (sd->reorder.dir == ELM_FOCUS_LEFT))
2681 tmp = eina_inlist_find(sd->items, EINA_INLIST_GET(it2_prev));
2682 sd->items = eina_inlist_append_relative(sd->items, EINA_INLIST_GET(sd->reorder.it1),
2686 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(sd->reorder.it1));
2688 else if ((sd->reorder.dir == ELM_FOCUS_DOWN) ||
2689 (sd->reorder.dir == ELM_FOCUS_RIGHT))
2691 tmp = eina_inlist_find(sd->items, EINA_INLIST_GET(sd->reorder.it2));
2692 sd->items = eina_inlist_append_relative(sd->items, EINA_INLIST_GET(sd->reorder.it1),
2696 else if ((sd->reorder.type == ELM_GENGRID_REORDER_TYPE_SWAP) &&
2697 ((!sd->horizontal && ((sd->reorder.dir == ELM_FOCUS_UP) || (sd->reorder.dir == ELM_FOCUS_DOWN))) ||
2698 (sd->horizontal && ((sd->reorder.dir == ELM_FOCUS_LEFT) || (sd->reorder.dir == ELM_FOCUS_RIGHT)))))
2700 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(sd->reorder.it1));
2701 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(sd->reorder.it2));
2705 tmp = eina_inlist_find(sd->items, EINA_INLIST_GET(it1_prev));
2706 sd->items = eina_inlist_append_relative(sd->items, EINA_INLIST_GET(sd->reorder.it2),
2710 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(sd->reorder.it2));
2713 tmp = eina_inlist_find(sd->items, EINA_INLIST_GET(it2_prev));
2714 sd->items = eina_inlist_append_relative(sd->items, EINA_INLIST_GET(sd->reorder.it1),
2718 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(sd->reorder.it1));
2720 else if ((!sd->horizontal && (sd->reorder.dir == ELM_FOCUS_LEFT)) ||
2721 (sd->horizontal && (sd->reorder.dir == ELM_FOCUS_UP)))
2723 if (!(sd->reorder.it2 == it1_prev))
2725 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(sd->reorder.it1));
2726 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(sd->reorder.it2));
2730 tmp = eina_inlist_find(sd->items, EINA_INLIST_GET(it1_prev));
2731 sd->items = eina_inlist_append_relative(sd->items, EINA_INLIST_GET(sd->reorder.it2),
2735 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(sd->reorder.it2));
2739 tmp = eina_inlist_find(sd->items, EINA_INLIST_GET(it2_prev));
2740 sd->items = eina_inlist_append_relative(sd->items, EINA_INLIST_GET(sd->reorder.it1),
2744 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(sd->reorder.it1));
2748 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(sd->reorder.it1));
2749 sd->items = eina_inlist_prepend_relative(sd->items, EINA_INLIST_GET(sd->reorder.it1),
2750 EINA_INLIST_GET(sd->reorder.it2));
2753 else if ((!sd->horizontal && (sd->reorder.dir == ELM_FOCUS_RIGHT)) ||
2754 (sd->horizontal && (sd->reorder.dir == ELM_FOCUS_DOWN)))
2756 if (!(sd->reorder.it1 == it2_prev))
2758 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(sd->reorder.it1));
2759 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(sd->reorder.it2));
2763 tmp = eina_inlist_find(sd->items, EINA_INLIST_GET(it1_prev));
2764 sd->items = eina_inlist_append_relative(sd->items, EINA_INLIST_GET(sd->reorder.it2),
2768 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(sd->reorder.it2));
2772 tmp = eina_inlist_find(sd->items, EINA_INLIST_GET(it2_prev));
2773 sd->items = eina_inlist_append_relative(sd->items, EINA_INLIST_GET(sd->reorder.it1),
2777 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(sd->reorder.it1));
2781 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(sd->reorder.it1));
2782 sd->items = eina_inlist_append_relative(sd->items, EINA_INLIST_GET(sd->reorder.it1),
2783 EINA_INLIST_GET(sd->reorder.it2));
2786 _item_position_update(sd->items, 0);
2788 ecore_job_del(sd->calc_job);
2789 sd->calc_job = ecore_job_add(_calc_job, sd->obj);
2793 _item_move_cb(void *data, double pos)
2795 Elm_Gengrid_Data *sd = data;
2797 Evas_Coord xx1, yy1, xx2, yy2;
2800 switch (sd->reorder.tween_mode)
2802 case ECORE_POS_MAP_LINEAR:
2803 frame = ecore_animator_pos_map(frame, sd->reorder.tween_mode, 0, 0);
2805 case ECORE_POS_MAP_ACCELERATE:
2806 case ECORE_POS_MAP_DECELERATE:
2807 case ECORE_POS_MAP_SINUSOIDAL:
2808 frame = ecore_animator_pos_map(frame, sd->reorder.tween_mode, 1.0, 0);
2810 case ECORE_POS_MAP_DIVISOR_INTERP:
2811 case ECORE_POS_MAP_BOUNCE:
2812 case ECORE_POS_MAP_SPRING:
2813 frame = ecore_animator_pos_map(frame, sd->reorder.tween_mode, 1.0, 1.0);
2816 frame = ecore_animator_pos_map(frame, sd->reorder.tween_mode, 0, 0);
2820 dx = sd->reorder.x2 - sd->reorder.x1;
2821 dy = sd->reorder.y2 - sd->reorder.y1;
2822 xx1 = sd->reorder.x1 + (dx * frame);
2823 yy1 = sd->reorder.y1 + (dy * frame);
2825 if (sd->reorder.type == ELM_GENGRID_REORDER_TYPE_NORMAL)
2828 Reorder_Normal_Data *rnd = sd->reorder.data;
2830 for (;i < rnd->no; i++)
2832 dx = rnd->items[i + 1].x - rnd->items[i].x;
2833 dy = rnd->items[i + 1].y - rnd->items[i].y;
2834 xx2 = rnd->items[i].x + (frame * dx);
2835 yy2 = rnd->items[i].y + (frame * dy);
2836 evas_object_move(VIEW(rnd->items[i].it), xx2, yy2);
2839 else if (sd->reorder.type == ELM_GENGRID_REORDER_TYPE_SWAP)
2841 xx2 = sd->reorder.x2 - (dx * frame);
2842 yy2 = sd->reorder.y2 - (dy * frame);
2843 evas_object_move(VIEW(sd->reorder.it2), xx2, yy2);
2846 evas_object_move(VIEW(sd->reorder.it1), xx1, yy1);
2851 if (sd->reorder.type == ELM_GENGRID_REORDER_TYPE_NORMAL)
2852 _free_reorder_normal_data(sd->reorder.data);
2853 elm_gengrid_item_show(EO_OBJ(sd->reorder.it1),
2854 ELM_GENGRID_ITEM_SCROLLTO_IN);
2855 eo_do(sd->obj, eo_event_callback_call
2856 (ELM_GENGRID_EVENT_ITEM_REORDER_ANIM_STOP, EO_OBJ(sd->reorder.it1)));
2857 eo_do(sd->obj, eo_event_callback_call
2858 (ELM_WIDGET_EVENT_MOVED, EO_OBJ(sd->reorder.it1)));
2859 sd->reorder.running = EINA_FALSE;
2861 _elm_widget_focus_highlight_start(sd->obj);
2867 _store_nearby_items(Elm_Gengrid_Data *sd)
2869 Reorder_Normal_Data *rnd = sd->reorder.data;
2871 Evas_Coord x, y, cvw, cvh, col = 0, row = 0;
2873 int corner_item_pos = 0;
2874 Eina_Inlist *it1_list, *it2_list;
2876 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh);
2878 rnd->no = abs(sd->reorder.it2->position - sd->reorder.it1->position);
2879 rnd->items = malloc(sizeof(Item_Info) * (rnd->no + 1));
2880 rnd->corner_item = NULL;
2882 if (sd->horizontal && sd->item_height > 0)
2884 row = cvh / sd->item_height;
2885 if (row <= 0) row = 1;
2886 if (sd->reorder.dir == ELM_FOCUS_RIGHT)
2888 corner_item_pos = (sd->reorder.it2->position + 1) / row;
2889 corner_item_pos = corner_item_pos * row;
2890 corner_item_pos = sd->reorder.it2->position - corner_item_pos;
2892 else if (sd->reorder.dir == ELM_FOCUS_LEFT)
2894 corner_item_pos = (sd->reorder.it2->position + 1) / row;
2895 corner_item_pos = (corner_item_pos + 1) * row;
2896 corner_item_pos = corner_item_pos - sd->reorder.it2->position;
2899 else if (sd->item_width > 0)
2901 col = cvw / sd->item_width;
2902 if (col <= 0) col = 1;
2903 if (sd->reorder.dir == ELM_FOCUS_DOWN)
2905 corner_item_pos = (sd->reorder.it2->position + 1) / col;
2906 corner_item_pos = corner_item_pos * col;
2907 corner_item_pos = sd->reorder.it2->position - corner_item_pos;
2909 else if (sd->reorder.dir == ELM_FOCUS_UP)
2911 corner_item_pos = (sd->reorder.it2->position + 1) / col;
2912 corner_item_pos = (corner_item_pos + 1) * col;
2913 corner_item_pos = corner_item_pos - sd->reorder.it2->position;
2917 it1_list = eina_inlist_find(sd->items, EINA_INLIST_GET(sd->reorder.it1));
2918 it2_list = eina_inlist_find(sd->items, EINA_INLIST_GET(sd->reorder.it2));
2920 if ((sd->reorder.it1->position) < (sd->reorder.it2)->position)
2922 for (itr = it2_list; itr != it1_list; itr = itr->prev)
2924 Elm_Gen_Item *cur = EINA_INLIST_CONTAINER_GET(itr, Elm_Gen_Item);
2925 evas_object_geometry_get(VIEW(cur), &x, &y, NULL, NULL);
2926 rnd->items[i].it = cur;
2927 rnd->items[i].x = x;
2928 rnd->items[i].y = y;
2929 if (i == (corner_item_pos - 1))
2930 rnd->corner_item = cur;
2933 rnd->items[i].it = sd->reorder.it1;
2934 rnd->items[i].x = sd->reorder.x1;
2935 rnd->items[i].y = sd->reorder.y1;
2937 else if (sd->reorder.it1->position > sd->reorder.it2->position)
2939 for (itr = it2_list; itr != it1_list; itr = itr->next)
2941 Elm_Gen_Item *cur = EINA_INLIST_CONTAINER_GET(itr, Elm_Gen_Item);
2942 evas_object_geometry_get(VIEW(cur), &x, &y, NULL, NULL);
2943 rnd->items[i].it = cur;
2944 rnd->items[i].x = x;
2945 rnd->items[i].y = y;
2946 if (i == (corner_item_pos - 1))
2947 rnd->corner_item = cur;
2950 rnd->items[i].it = sd->reorder.it1;
2951 rnd->items[i].x = sd->reorder.x1;
2952 rnd->items[i].y = sd->reorder.y1;
2957 _swap_items(Elm_Object_Item *eo_it1, Elm_Object_Item *eo_it2, Elm_Focus_Direction dir)
2959 ELM_GENGRID_ITEM_DATA_GET(eo_it1, it1);
2960 ELM_GENGRID_ITEM_DATA_GET(eo_it2, it2);
2961 ELM_GENGRID_DATA_GET(WIDGET(it1), sd);
2962 Evas_Coord xx1, yy1, xx2, yy2;
2964 sd->reorder.running = EINA_TRUE;
2965 sd->reorder.dir = dir;
2966 sd->reorder.it1 = it1;
2967 sd->reorder.it2 = it2;
2969 evas_object_geometry_get(VIEW(it1), &xx1, &yy1, NULL, NULL);
2970 evas_object_geometry_get(VIEW(it2), &xx2, &yy2, NULL, NULL);
2971 sd->reorder.x1 = xx1;
2972 sd->reorder.y1 = yy1;
2973 sd->reorder.x2 = xx2;
2974 sd->reorder.y2 = yy2;
2976 if (sd->reorder.type == ELM_GENGRID_REORDER_TYPE_NORMAL)
2978 Reorder_Normal_Data *rnd = malloc(sizeof(Reorder_Normal_Data));
2979 sd->reorder.data = rnd;
2980 _store_nearby_items(sd);
2981 if (rnd->corner_item)
2982 evas_object_raise(VIEW(rnd->corner_item));
2984 evas_object_raise(VIEW(it1));
2985 eo_do(sd->obj, eo_event_callback_call
2986 (ELM_GENGRID_EVENT_ITEM_REORDER_ANIM_START, EO_OBJ(sd->reorder.it1)));
2987 //TODO: Add elm config for time
2988 ecore_animator_timeline_add(0.3, _item_move_cb, sd);
2992 _item_horizontal_loop(Evas_Object *obj, Elm_Focus_Direction dir)
2994 ELM_GENGRID_DATA_GET(obj, sd);
2995 Elm_Object_Item *eo_item = sd->focused_item;
2996 unsigned int counter, i;
2998 ELM_GENGRID_ITEM_DATA_GET(eo_item, item);
3001 if (dir == ELM_FOCUS_UP)
3004 while (!_elm_gengrid_item_edge_check(EO_OBJ(item), dir))
3006 eo_item = elm_gengrid_item_prev_get(eo_item);
3007 item = eo_data_scope_get(eo_item, ELM_GENGRID_ITEM_CLASS);
3010 eo_item = elm_gengrid_first_item_get(obj);
3011 for (i = 0; i < counter; i++)
3012 eo_item = elm_gengrid_item_next_get(eo_item);
3018 if (_elm_gengrid_item_edge_check(EO_OBJ(item), dir))
3022 for (i = 0; i < sd->nmax; i++)
3023 eo_item = elm_gengrid_item_next_get(eo_item);
3024 item = eo_data_scope_get(eo_item, ELM_GENGRID_ITEM_CLASS);
3031 if (dir == ELM_FOCUS_RIGHT)
3033 while (!_elm_gengrid_item_edge_check(EO_OBJ(item), dir))
3035 if (!elm_gengrid_item_next_get(eo_item))
3037 eo_item = elm_gengrid_item_next_get(eo_item);
3038 item = eo_data_scope_get(eo_item, ELM_GENGRID_ITEM_CLASS);
3041 else if (dir == ELM_FOCUS_LEFT)
3043 while (!_elm_gengrid_item_edge_check(EO_OBJ(item), dir))
3045 if (!elm_gengrid_item_prev_get(EO_OBJ(item)))
3047 eo_item = elm_gengrid_item_prev_get(eo_item);
3048 item = eo_data_scope_get(eo_item, ELM_GENGRID_ITEM_CLASS);
3054 if (!eo_item) return EINA_FALSE;
3055 if (sd->reorder_mode && !(sd->focused_item == eo_item))
3057 _swap_items(sd->focused_item, eo_item, ELM_FOCUS_RIGHT);
3062 if (_elm_config->item_select_on_focus_disable)
3063 elm_object_item_focus_set(eo_item, EINA_TRUE);
3065 elm_gengrid_item_selected_set(eo_item, EINA_TRUE);
3072 _key_action_move(Evas_Object *obj, const char *params)
3074 ELM_GENGRID_DATA_GET(obj, sd);
3075 const char *dir = params;
3081 Evas_Coord step_x = 0;
3082 Evas_Coord step_y = 0;
3083 Evas_Coord page_x = 0;
3084 Evas_Coord page_y = 0;
3085 Elm_Object_Item *it = NULL;
3086 Eina_Bool mirrored = elm_widget_mirrored_get(obj);
3089 elm_interface_scrollable_content_pos_get(&x, &y),
3090 elm_interface_scrollable_step_size_get(&step_x, &step_y),
3091 elm_interface_scrollable_page_size_get(&page_x, &page_y),
3092 elm_interface_scrollable_content_viewport_geometry_get
3093 (NULL, NULL, &v_w, &v_h));
3095 if (sd->reorder_mode && sd->reorder.running) return EINA_TRUE;
3096 _elm_widget_focus_auto_show(obj);
3097 if ((!strcmp(dir, "left") && !mirrored) ||
3098 (!strcmp(dir, "right") && mirrored))
3100 if (sd->reorder_mode)
3102 Elm_Object_Item *eo_left;
3104 if (_elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_LEFT))
3106 if (sd->item_loop_enable)
3110 if (!sd->horizontal)
3111 eo_left = elm_gengrid_item_prev_get(sd->focused_item);
3113 eo_left = get_up_item(sd, sd->focused_item);
3116 _swap_items(sd->focused_item, eo_left, ELM_FOCUS_LEFT);
3122 Evas_Object *next = NULL;
3123 Elm_Object_Item *next_item = NULL;
3124 next_item = elm_object_item_focus_next_item_get(sd->focused_item,
3128 elm_object_item_focus_set(next_item, EINA_TRUE);
3131 next = elm_object_item_focus_next_object_get(sd->focused_item,
3135 elm_object_focus_set(next, EINA_TRUE);
3141 if (_elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_LEFT))
3143 if (sd->item_loop_enable)
3145 if (_item_horizontal_loop(obj, ELM_FOCUS_RIGHT))
3150 if (!_elm_config->item_select_on_focus_disable)
3152 return _item_single_select_up(sd);
3155 return _item_focus_up(sd);
3159 if (sd->focused_item && (_elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_LEFT) ||
3160 !elm_gengrid_item_prev_get(sd->focused_item)))
3162 if (sd->item_loop_enable)
3164 if (_item_horizontal_loop(obj, ELM_FOCUS_RIGHT))
3169 if (!_elm_config->item_select_on_focus_disable)
3171 return _item_single_select_left(sd);
3174 return _item_focus_left(sd);
3177 else if ((!strcmp(dir, "left_multi") && !mirrored) ||
3178 (!strcmp(dir, "right_multi") && mirrored))
3182 if (_item_multi_select_up(sd)) return EINA_TRUE;
3183 else if (_item_single_select_up(sd)) return EINA_TRUE;
3184 else return EINA_FALSE;
3188 if (_elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_LEFT))
3190 if (_item_multi_select_left(sd)) return EINA_TRUE;
3191 else if (_item_single_select_left(sd)) return EINA_TRUE;
3192 else return EINA_FALSE;
3195 else if ((!strcmp(dir, "right") && !mirrored) ||
3196 (!strcmp(dir, "left") && mirrored))
3198 if (sd->reorder_mode)
3200 Elm_Object_Item *eo_right;
3202 if (_elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_RIGHT))
3204 if (sd->item_loop_enable)
3208 if (!sd->horizontal)
3209 eo_right = elm_gengrid_item_next_get(sd->focused_item);
3211 eo_right = get_down_item(sd, sd->focused_item);
3214 _swap_items(sd->focused_item, eo_right, ELM_FOCUS_RIGHT);
3220 Evas_Object *next = NULL;
3221 Elm_Object_Item *next_item = NULL;
3222 next_item = elm_object_item_focus_next_item_get(sd->focused_item,
3226 elm_object_item_focus_set(next_item, EINA_TRUE);
3229 next = elm_object_item_focus_next_object_get(sd->focused_item,
3233 elm_object_focus_set(next, EINA_TRUE);
3239 if (sd->focused_item && _elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_RIGHT))
3241 if (sd->item_loop_enable)
3243 if (_item_horizontal_loop(obj, ELM_FOCUS_UP))
3247 if (!_elm_config->item_select_on_focus_disable)
3249 return _item_single_select_down(sd);
3252 return _item_focus_down(sd);
3256 if (sd->focused_item && (_elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_RIGHT) ||
3257 !elm_gengrid_item_next_get(sd->focused_item)))
3259 if (sd->item_loop_enable)
3261 if (_item_horizontal_loop(obj, ELM_FOCUS_LEFT))
3266 if (!_elm_config->item_select_on_focus_disable)
3268 return _item_single_select_right(sd);
3271 return _item_focus_right(sd);
3274 else if ((!strcmp(dir, "right_multi") && !mirrored) ||
3275 (!strcmp(dir, "left_multi") && mirrored))
3279 if (_item_multi_select_down(sd)) return EINA_TRUE;
3280 else if (_item_single_select_down(sd)) return EINA_TRUE;
3281 else return EINA_FALSE;
3285 if (_elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_RIGHT))
3287 if (_item_multi_select_right(sd)) return EINA_TRUE;
3288 else if (_item_single_select_right(sd)) return EINA_TRUE;
3289 else return EINA_FALSE;
3292 else if (!strcmp(dir, "up"))
3294 if (sd->reorder_mode)
3296 Elm_Object_Item *eo_up;
3298 if (_elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_UP))
3300 if (!sd->horizontal)
3301 eo_up = get_up_item(sd, sd->focused_item);
3303 eo_up = elm_gengrid_item_prev_get(sd->focused_item);
3306 _swap_items(sd->focused_item, eo_up, ELM_FOCUS_UP);
3312 Evas_Object *next = NULL;
3313 Elm_Object_Item *next_item = NULL;
3314 next_item = elm_object_item_focus_next_item_get(sd->focused_item,
3318 elm_object_item_focus_set(next_item, EINA_TRUE);
3321 next = elm_object_item_focus_next_object_get(sd->focused_item,
3325 elm_object_focus_set(next, EINA_TRUE);
3331 if (sd->focused_item && _elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_UP))
3333 if (!_elm_config->item_select_on_focus_disable)
3335 if (_item_single_select_left(sd)) return EINA_TRUE;
3336 else return EINA_FALSE;
3339 return _item_focus_left(sd);
3343 if (!_elm_config->item_select_on_focus_disable)
3345 return _item_single_select_up(sd);
3348 return _item_focus_up(sd);
3351 else if (!strcmp(dir, "up_multi"))
3355 if (_elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_UP))
3357 if (_item_multi_select_left(sd)) return EINA_TRUE;
3358 else if (_item_single_select_left(sd)) return EINA_TRUE;
3359 else return EINA_FALSE;
3363 if (_item_multi_select_up(sd)) return EINA_TRUE;
3364 else if (_item_single_select_up(sd)) return EINA_TRUE;
3365 else return EINA_FALSE;
3368 else if (!strcmp(dir, "down"))
3370 if (sd->reorder_mode)
3372 Elm_Object_Item *eo_down;
3374 if (_elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_DOWN))
3376 if (!sd->horizontal)
3377 eo_down = get_down_item(sd, sd->focused_item);
3379 eo_down = elm_gengrid_item_next_get(sd->focused_item);
3382 _swap_items(sd->focused_item, eo_down, ELM_FOCUS_DOWN);
3388 Evas_Object *next = NULL;
3389 Elm_Object_Item *next_item = NULL;
3390 next_item = elm_object_item_focus_next_item_get(sd->focused_item,
3394 elm_object_item_focus_set(next_item, EINA_TRUE);
3397 next = elm_object_item_focus_next_object_get(sd->focused_item,
3401 elm_object_focus_set(next, EINA_TRUE);
3407 if (sd->focused_item && _elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_DOWN))
3409 if (!_elm_config->item_select_on_focus_disable)
3411 return _item_single_select_right(sd);
3414 return _item_focus_right(sd);
3418 if (!_elm_config->item_select_on_focus_disable)
3420 return _item_single_select_down(sd);
3423 return _item_focus_down(sd);
3426 else if (!strcmp(dir, "down_multi"))
3430 if (_elm_gengrid_item_edge_check(sd->focused_item, ELM_FOCUS_DOWN))
3432 if (_item_multi_select_right(sd)) return EINA_TRUE;
3433 else if (_item_single_select_right(sd)) return EINA_TRUE;
3434 else return EINA_FALSE;
3438 if (_item_multi_select_down(sd)) return EINA_TRUE;
3439 else if (_item_single_select_down(sd)) return EINA_TRUE;
3440 else return EINA_FALSE;
3443 else if (!strcmp(dir, "first"))
3445 it = elm_gengrid_first_item_get(obj);
3446 if (!_elm_config->item_select_on_focus_disable)
3447 elm_gengrid_item_selected_set(it, EINA_TRUE);
3449 elm_object_item_focus_set(it, EINA_TRUE);
3452 else if (!strcmp(dir, "last"))
3454 it = elm_gengrid_last_item_get(obj);
3455 if (!_elm_config->item_select_on_focus_disable)
3456 elm_gengrid_item_selected_set(it, EINA_TRUE);
3458 elm_object_item_focus_set(it, EINA_TRUE);
3461 else if (!strcmp(dir, "prior"))
3466 x -= -(page_x * v_w) / 100;
3473 y -= -(page_y * v_h) / 100;
3478 else if (!strcmp(dir, "next"))
3483 x += -(page_x * v_w) / 100;
3490 y += -(page_y * v_h) / 100;
3495 else return EINA_FALSE;
3497 eo_do(obj, elm_interface_scrollable_content_pos_set(x, y, EINA_TRUE));
3502 _key_action_select(Evas_Object *obj, const char *params)
3504 ELM_GENGRID_DATA_GET(obj, sd);
3505 Elm_Object_Item *eo_it = elm_object_focused_item_get(obj);
3506 if (!eo_it) return EINA_TRUE;
3507 ELM_GENGRID_ITEM_DATA_GET(eo_it, it);
3510 ((sd->multi_select_mode != ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL) ||
3511 (!strcmp(params, "multi"))))
3515 it->highlight_cb(it);
3518 else it->unsel_cb(it);
3524 while (sd->selected)
3526 Elm_Object_Item *eo_sel = sd->selected->data;
3527 Elm_Gen_Item *sel = eo_data_scope_get(eo_sel, ELM_GENGRID_ITEM_CLASS);
3533 const Eina_List *l, *l_next;
3534 Elm_Object_Item *eo_item2;
3536 EINA_LIST_FOREACH_SAFE(sd->selected, l, l_next, eo_item2)
3538 ELM_GENGRID_ITEM_DATA_GET(eo_item2, item2);
3539 if (item2 != it) it->unsel_cb(item2);
3542 it->highlight_cb(it);
3547 eo_do(WIDGET(it), eo_event_callback_call(ELM_GENGRID_EVENT_ACTIVATED, eo_it));
3553 _key_action_escape(Evas_Object *obj, const char *params EINA_UNUSED)
3555 ELM_GENGRID_DATA_GET(obj, sd);
3557 if (!_all_items_deselect(sd)) return EINA_FALSE;
3561 EOLIAN static Eina_Bool
3562 _elm_gengrid_elm_widget_event(Eo *obj, Elm_Gengrid_Data *sd, Evas_Object *src, Evas_Callback_Type type, void *event_info)
3564 Evas_Event_Key_Down *ev = event_info;
3567 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
3568 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
3569 if (!sd->items) return EINA_FALSE;
3571 if (!_elm_config_key_binding_call(obj, ev, key_actions))
3574 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
3579 * This function searches the nearest visible item based on the given item.
3580 * If the given item is in the gengrid viewport, this returns the given item.
3581 * Or this searches the realized items and checks the nearest fully visible item
3582 * according to the given item's position.
3584 static Elm_Object_Item *
3585 _elm_gengrid_nearest_visible_item_get(Evas_Object *obj, Elm_Object_Item *eo_it)
3587 Evas_Coord vx = 0, vy = 0, vw = 0, vh = 0; // gengrid viewport geometry
3588 Evas_Coord ix = 0, iy = 0, iw = 0, ih = 0; // given item geometry
3589 Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0; // candidate item geometry
3590 Eina_List *item_list = NULL, *l = NULL;
3591 Elm_Object_Item *eo_item = NULL;
3592 ELM_GENGRID_DATA_GET(obj, sd);
3593 Eina_Bool search_next = EINA_FALSE;
3595 if (!eo_it) return NULL;
3596 ELM_GENGRID_ITEM_DATA_GET(eo_it, it);
3598 evas_object_geometry_get(sd->pan_obj, &vx, &vy, &vw, &vh);
3599 evas_object_geometry_get(VIEW(it), &ix, &iy, &iw, &ih); // FIXME: check if the item is realized or not
3601 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, ix, iy, iw, ih))
3603 if (!elm_object_item_disabled_get(eo_it))
3606 search_next = EINA_TRUE;
3609 item_list = elm_gengrid_realized_items_get(obj);
3611 if ((iy < vy) || search_next)
3613 EINA_LIST_FOREACH(item_list, l, eo_item)
3615 ELM_GENGRID_ITEM_DATA_GET(eo_item, item);
3616 evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch);
3617 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch) &&
3618 !elm_object_item_disabled_get(eo_item))
3620 eina_list_free(item_list);
3627 EINA_LIST_REVERSE_FOREACH(item_list, l, eo_item)
3629 ELM_GENGRID_ITEM_DATA_GET(eo_item, item);
3630 evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch);
3631 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch) &&
3632 !elm_object_item_disabled_get(eo_item))
3634 eina_list_free(item_list);
3639 eina_list_free(item_list);
3644 EOLIAN static Eina_Bool
3645 _elm_gengrid_elm_widget_on_focus(Eo *obj, Elm_Gengrid_Data *sd, Elm_Object_Item *item)
3647 Eina_Bool int_ret = EINA_FALSE;
3648 Elm_Object_Item *eo_it = NULL;
3650 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_on_focus(NULL));
3651 if (!int_ret) return EINA_FALSE;
3653 if (elm_widget_focus_get(obj) && (sd->selected) &&
3654 (!sd->last_selected_item))
3656 Elm_Object_Item *sel = eina_list_data_get(sd->selected);
3657 sd->last_selected_item = eo_data_scope_get(sel, ELM_GENGRID_ITEM_CLASS);
3660 if (elm_widget_focus_get(obj) && !sd->mouse_down)
3662 if (item) eo_it = item;
3665 if (sd->last_focused_item)
3666 eo_it = sd->last_focused_item;
3667 else if (sd->last_selected_item)
3668 eo_it = sd->last_selected_item;
3669 else if (_elm_config->first_item_focus_on_first_focus_in)
3670 eo_it = elm_gengrid_first_item_get(obj);
3674 eo_it = _elm_gengrid_nearest_visible_item_get(obj, eo_it);
3677 if (!_elm_config->item_select_on_focus_disable &&
3678 eo_it != sd->last_selected_item)
3679 elm_gengrid_item_selected_set(eo_it, EINA_TRUE);
3681 elm_object_item_focus_set(eo_it, EINA_TRUE);
3682 _elm_widget_focus_highlight_start(obj);
3688 if (sd->focused_item)
3690 sd->last_focused_item = sd->focused_item;
3691 _elm_gengrid_item_unfocused(sd->focused_item);
3698 EOLIAN static Eina_Bool
3699 _elm_gengrid_elm_widget_on_focus_region(Eo *obj, Elm_Gengrid_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3701 if (!sd->focused_item) return EINA_FALSE;
3702 if (elm_object_focus_region_show_mode_get(obj) == ELM_FOCUS_REGION_SHOW_ITEM)
3705 ELM_GENGRID_ITEM_DATA_GET(sd->focused_item, focus_it);
3706 evas_object_geometry_get(VIEW(focus_it), x, y, w, h);
3707 evas_object_geometry_get(obj, &vx, &vy, NULL, NULL);
3717 static Eina_Bool _elm_gengrid_smart_focus_next_enable = EINA_FALSE;
3719 EOLIAN static Eina_Bool
3720 _elm_gengrid_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *_pd EINA_UNUSED)
3722 return _elm_gengrid_smart_focus_next_enable;
3725 EOLIAN static Eina_Bool
3726 _elm_gengrid_elm_widget_focus_next(Eo *obj, Elm_Gengrid_Data *sd, Elm_Focus_Direction dir, Evas_Object **next, Elm_Object_Item **next_item)
3728 Eina_List *items = NULL;
3731 EINA_INLIST_FOREACH(sd->items, it)
3734 items = eina_list_append(items, it->base->access_obj);
3737 return elm_widget_focus_list_next_get
3738 (obj, items, eina_list_data_get, dir, next, next_item);
3741 EOLIAN static Eina_Bool
3742 _elm_gengrid_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *_pd EINA_UNUSED)
3747 EOLIAN static Eina_Bool
3748 _elm_gengrid_elm_widget_focus_direction(Eo *obj, Elm_Gengrid_Data *sd EINA_UNUSED, const Evas_Object *base, double degree, Evas_Object **direction, Elm_Object_Item **direction_item, double *weight)
3750 Eina_List *items = NULL, *l = NULL;
3751 Elm_Object_Item *eo_item = NULL;
3752 Eina_Bool ret = EINA_FALSE;
3753 double c_weight = 0.0;
3755 items = elm_gengrid_realized_items_get(obj);
3756 eo_item = elm_object_focused_item_get(base);
3759 ELM_GENGRID_ITEM_DATA_GET(eo_item, base_item);
3760 base = VIEW(base_item);
3763 EINA_LIST_FOREACH(items, l, eo_item)
3765 ELM_GENGRID_ITEM_DATA_GET(eo_item, item);
3767 c_weight = _elm_widget_focus_direction_weight_get(base, VIEW(item), degree);
3768 if ((c_weight == -1.0) ||
3769 ((c_weight != 0.0) && (*weight != -1.0) &&
3770 ((int)(*weight * 100000000) < (int)(c_weight * 100000000))))
3772 *direction = (Evas_Object *)obj;
3773 *direction_item = eo_item;
3778 eina_list_free(items);
3784 _mirrored_set(Evas_Object *obj,
3789 ELM_GENGRID_DATA_GET(obj, sd);
3791 _item_cache_zero(sd);
3792 eo_do_super(obj, MY_CLASS, elm_interface_scrollable_mirrored_set(rtl));
3794 if (!sd->items) return;
3795 it = ELM_GEN_ITEM_FROM_INLIST(sd->items);
3799 edje_object_mirrored_set(VIEW(it), rtl);
3800 elm_gengrid_item_update(EO_OBJ(it));
3801 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3805 EOLIAN static Eina_Bool
3806 _elm_gengrid_elm_widget_theme_apply(Eo *obj, Elm_Gengrid_Data *sd EINA_UNUSED)
3808 Eina_Bool int_ret = EINA_FALSE;
3809 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
3810 if (!int_ret) return EINA_FALSE;
3812 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3818 _item_position_update(Eina_Inlist *list,
3823 EINA_INLIST_FOREACH(list, it)
3825 it->position = idx++;
3826 it->position_update = EINA_TRUE;
3831 _elm_gengrid_item_del_not_serious(Elm_Gen_Item *it)
3833 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
3834 Elm_Object_Item *eo_it = EO_OBJ(it);
3836 eo_do(eo_it, elm_wdg_item_pre_notify_del());
3837 it->generation = sd->generation - 1; /* This means that the item is deleted */
3839 if (it->walking > 0) return;
3842 sd->selected = eina_list_remove(sd->selected, eo_it);
3843 if (sd->last_selected_item == eo_it)
3844 sd->last_selected_item = NULL;
3845 if (sd->focused_item == eo_it)
3846 sd->focused_item = NULL;
3847 if (sd->last_focused_item == eo_it)
3848 sd->last_focused_item = NULL;
3850 if (it->itc->func.del)
3851 it->itc->func.del((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it));
3855 _elm_gengrid_item_del_serious(Elm_Gen_Item *it)
3857 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
3860 _elm_gengrid_item_del_not_serious(it);
3861 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(it));
3862 if (it->tooltip.del_cb)
3863 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
3864 sd->walking -= it->walking;
3865 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
3867 sd->group_items = eina_list_remove(sd->group_items, it);
3869 ELM_SAFE_FREE(sd->state, eina_inlist_sorted_state_free);
3870 ecore_job_del(sd->calc_job);
3871 sd->calc_job = ecore_job_add(sd->calc_cb, sd->obj);
3873 ELM_SAFE_FREE(it->item, free);
3877 _item_del(Elm_Gen_Item *it)
3879 Evas_Object *obj = WIDGET(it);
3880 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
3882 evas_event_freeze(evas_object_evas_get(obj));
3883 sd->selected = eina_list_remove(sd->selected, it);
3884 if (it->realized) _elm_gengrid_item_unrealize(it, EINA_FALSE);
3885 _elm_gengrid_item_del_serious(it);
3886 elm_gengrid_item_class_unref((Elm_Gengrid_Item_Class *)it->itc);
3887 evas_event_thaw(evas_object_evas_get(obj));
3888 evas_event_thaw_eval(evas_object_evas_get(obj));
3892 _scroll_animate_start_cb(Evas_Object *obj,
3893 void *data EINA_UNUSED)
3895 eo_do(obj, eo_event_callback_call(EVAS_SCROLLABLE_INTERFACE_EVENT_SCROLL_ANIM_START, NULL));
3899 _scroll_animate_stop_cb(Evas_Object *obj,
3900 void *data EINA_UNUSED)
3902 eo_do(obj, eo_event_callback_call(EVAS_SCROLLABLE_INTERFACE_EVENT_SCROLL_ANIM_STOP, NULL));
3906 _scroll_drag_start_cb(Evas_Object *obj,
3907 void *data EINA_UNUSED)
3909 eo_do(obj, eo_event_callback_call(EVAS_SCROLLABLE_INTERFACE_EVENT_SCROLL_DRAG_START, NULL));
3913 _scroll_drag_stop_cb(Evas_Object *obj,
3914 void *data EINA_UNUSED)
3916 eo_do(obj, eo_event_callback_call(EVAS_SCROLLABLE_INTERFACE_EVENT_SCROLL_DRAG_STOP, NULL));
3920 _edge_left_cb(Evas_Object *obj,
3921 void *data EINA_UNUSED)
3923 eo_do(obj, eo_event_callback_call(ELM_GENGRID_EVENT_EDGE_LEFT, NULL));
3927 _edge_right_cb(Evas_Object *obj,
3928 void *data EINA_UNUSED)
3930 eo_do(obj, eo_event_callback_call(ELM_GENGRID_EVENT_EDGE_RIGHT, NULL));
3934 _edge_top_cb(Evas_Object *obj,
3935 void *data EINA_UNUSED)
3937 eo_do(obj, eo_event_callback_call(ELM_GENGRID_EVENT_EDGE_TOP, NULL));
3941 _edge_bottom_cb(Evas_Object *obj,
3942 void *data EINA_UNUSED)
3944 eo_do(obj, eo_event_callback_call(ELM_GENGRID_EVENT_EDGE_BOTTOM, NULL));
3948 _scroll_page_change_cb(Evas_Object *obj,
3949 void *data EINA_UNUSED)
3951 eo_do(obj, eo_event_callback_call(ELM_GENGRID_EVENT_SCROLL_PAGE_CHANGED, NULL));
3955 _scroll_cb(Evas_Object *obj,
3956 void *data EINA_UNUSED)
3958 eo_do(obj, eo_event_callback_call(EVAS_SCROLLABLE_INTERFACE_EVENT_SCROLL, NULL));
3962 _elm_gengrid_item_compare(const void *data,
3965 Elm_Gen_Item *it, *item1;
3966 Eina_Compare_Cb cb = NULL;
3969 it = ELM_GEN_ITEM_FROM_INLIST(data);
3970 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
3971 if (it && GG_IT(it)->wsd->item_compare_cb)
3972 cb = GG_IT(it)->wsd->item_compare_cb;
3973 else if (item1 && GG_IT(item1)->wsd->item_compare_cb)
3974 cb = GG_IT(item1)->wsd->item_compare_cb;
3975 if (cb && it && item1) return cb(EO_OBJ(it), EO_OBJ(item1));
3976 d = (char *)data - (char *)data1;
3977 if (d < 0) return -1;
3983 _elm_gengrid_item_elm_widget_item_disable(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
3986 if (it->generation < GG_IT(it)->wsd->generation) return;
3990 if (eo_do_ret(EO_OBJ(it), tmp, elm_wdg_item_disabled_get()))
3991 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
3993 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
3997 EOLIAN static Eina_Bool
3998 _elm_gengrid_item_elm_widget_item_del_pre(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
4000 if (it->walking > 0)
4002 _elm_gengrid_item_del_not_serious(it);
4010 EOLIAN static Evas_Object *
4011 _elm_gengrid_item_elm_widget_item_part_content_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it, const char * part)
4013 return edje_object_part_swallow_get(VIEW(it), part);
4016 EOLIAN static const char *
4017 _elm_gengrid_item_elm_widget_item_part_text_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it, const char * part)
4019 if (!it->itc->func.text_get) return NULL;
4020 return edje_object_part_text_get(VIEW(it), part);
4024 _elm_gengrid_item_elm_widget_item_signal_emit(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it, const char *emission, const char *source)
4026 edje_object_signal_emit(VIEW(it), emission, source);
4030 _elm_gengrid_item_elm_widget_item_focus_set(Eo *eo_it, Elm_Gen_Item *it, Eina_Bool focused)
4032 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
4033 Evas_Object *obj = WIDGET(it);
4034 ELM_GENGRID_DATA_GET(obj, sd);
4038 sd->last_focused_item = eo_it;
4039 if (!elm_object_focus_get(obj))
4040 elm_object_focus_set(obj, EINA_TRUE);
4042 if (!elm_widget_focus_get(obj))
4045 if (eo_it != sd->focused_item)
4047 if (sd->focused_item)
4048 _elm_gengrid_item_unfocused(sd->focused_item);
4049 _elm_gengrid_item_focused(eo_it);
4054 if (!elm_widget_focus_get(obj))
4056 _elm_gengrid_item_unfocused(eo_it);
4058 elm_widget_focus_region_show(obj);
4061 EOLIAN static Eina_Bool
4062 _elm_gengrid_item_elm_widget_item_focus_get(Eo *eo_it, Elm_Gen_Item *it)
4064 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4065 Evas_Object *obj = WIDGET(it);
4066 ELM_GENGRID_DATA_GET(obj, sd);
4068 if (eo_it == sd->focused_item)
4075 _internal_elm_gengrid_clear(Evas_Object *obj,
4078 Eina_Inlist *next, *l;
4080 ELM_GENGRID_DATA_GET(obj, sd);
4081 if (!sd->items) return;
4083 if (!standby) sd->generation++;
4085 ELM_SAFE_FREE(sd->state, eina_inlist_sorted_state_free);
4087 if (sd->walking > 0)
4089 sd->clear_me = EINA_TRUE;
4092 evas_event_freeze(evas_object_evas_get(obj));
4093 for (l = sd->items, next = l ? l->next : NULL;
4095 l = next, next = next ? next->next : NULL)
4097 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(l);
4099 if (it->generation < sd->generation)
4101 Elm_Gen_Item *itn = NULL;
4103 if (next) itn = ELM_GEN_ITEM_FROM_INLIST(next);
4104 if (itn) itn->walking++; /* prevent early death of subitem */
4107 if (itn) itn->walking--;
4110 sd->clear_me = EINA_FALSE;
4111 sd->pan_changed = EINA_TRUE;
4112 ELM_SAFE_FREE(sd->calc_job, ecore_job_del);
4113 sd->selected = eina_list_free(sd->selected);
4114 if (sd->clear_cb) sd->clear_cb(sd);
4122 evas_object_size_hint_min_set(sd->pan_obj, sd->minw, sd->minh);
4123 eo_do(sd->pan_obj, eo_event_callback_call
4124 (ELM_PAN_EVENT_CHANGED, NULL));
4126 eo_do(obj, elm_interface_scrollable_content_region_show(0, 0, 0, 0));
4127 evas_event_thaw(evas_object_evas_get(obj));
4128 evas_event_thaw_eval(evas_object_evas_get(obj));
4132 _item_select(Elm_Gen_Item *it)
4134 Evas_Object *obj = WIDGET(it);
4135 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
4136 Elm_Object_Item *eo_it = EO_OBJ(it);
4138 if (_is_no_select(it) ||
4139 (it->generation < sd->generation) ||
4140 (it->decorate_it_set))
4145 it->selected = EINA_TRUE;
4146 sd->selected = eina_list_append(sd->selected, eo_it);
4148 else if ((sd->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS) &&
4149 (it->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS))
4152 evas_object_ref(obj);
4155 if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), eo_it);
4156 if (it->generation == sd->generation)
4158 eo_do(WIDGET(it), eo_event_callback_call(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, eo_it));
4159 if (_elm_config->atspi_mode)
4160 elm_interface_atspi_accessible_state_changed_signal_emit(eo_it, ELM_ATSPI_STATE_SELECTED, EINA_TRUE);
4161 elm_object_item_focus_set(eo_it, EINA_TRUE);
4166 if ((sd->clear_me) && (!sd->walking))
4167 _internal_elm_gengrid_clear(WIDGET(it), EINA_TRUE);
4170 if ((!it->walking) && (it->generation < sd->generation))
4176 sd->last_selected_item = eo_it;
4178 evas_object_unref(obj);
4182 _elm_gengrid_item_eo_base_constructor(Eo *eo_it, Elm_Gen_Item *it)
4184 eo_it = eo_do_super_ret(eo_it, ELM_GENGRID_ITEM_CLASS, eo_it, eo_constructor());
4185 it->base = eo_data_scope_get(eo_it, ELM_WIDGET_ITEM_CLASS);
4186 eo_do(eo_it, elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_LIST_ITEM));
4191 static Elm_Gen_Item *
4192 _elm_gengrid_item_new(Elm_Gengrid_Data *sd,
4193 const Elm_Gen_Item_Class *itc,
4196 const void *func_data)
4198 if (!itc) return NULL;
4200 Eo *eo_it = eo_add(ELM_GENGRID_ITEM_CLASS, sd->obj);
4201 if (!eo_it) return NULL;
4202 ELM_GENGRID_ITEM_DATA_GET(eo_it, it);
4204 it->generation = sd->generation;
4206 elm_gengrid_item_class_ref((Elm_Gengrid_Item_Class *)itc);
4208 WIDGET_ITEM_DATA_SET(EO_OBJ(it), data);
4210 it->func.func = func;
4211 it->func.data = func_data;
4213 it->del_cb = (Ecore_Cb)_item_del;
4214 it->highlight_cb = (Ecore_Cb)_item_highlight;
4215 it->unhighlight_cb = (Ecore_Cb)_item_unhighlight;
4216 it->sel_cb = (Ecore_Cb)_item_select;
4217 it->unsel_cb = (Ecore_Cb)_item_unselect;
4218 it->unrealize_cb = (Ecore_Cb)_item_unrealize_cb;
4220 GG_IT(it) = ELM_NEW(Elm_Gen_Item_Type);
4221 GG_IT(it)->wsd = sd;
4223 it->group = it->itc->item_style &&
4224 (!strcmp(it->itc->item_style, "group_index"));
4230 /* common layout sizing won't apply here */
4232 _elm_gengrid_elm_layout_sizing_eval(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *_pd EINA_UNUSED)
4238 _elm_gengrid_evas_object_smart_add(Eo *obj, Elm_Gengrid_Data *priv)
4240 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
4241 Elm_Gengrid_Pan_Data *pan_data;
4242 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
4244 eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
4245 elm_widget_sub_object_parent_add(obj);
4247 priv->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
4248 evas_object_smart_member_add(priv->hit_rect, obj);
4249 elm_widget_sub_object_add(obj, priv->hit_rect);
4251 /* common scroller hit rectangle setup */
4252 evas_object_color_set(priv->hit_rect, 0, 0, 0, 0);
4253 evas_object_show(priv->hit_rect);
4254 evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
4256 elm_widget_can_focus_set(obj, EINA_TRUE);
4258 priv->calc_cb = (Ecore_Cb)_calc_job;
4260 priv->generation = 1;
4262 if (!elm_layout_theme_set(obj, "gengrid", "base",
4263 elm_widget_style_get(obj)))
4264 CRI("Failed to set layout!");
4266 eo_do(obj, elm_interface_scrollable_objects_set(wd->resize_obj, priv->hit_rect));
4268 priv->old_h_bounce = bounce;
4269 priv->old_v_bounce = bounce;
4271 eo_do(obj, elm_interface_scrollable_bounce_allow_set(bounce, bounce));
4274 elm_interface_scrollable_animate_start_cb_set
4275 (_scroll_animate_start_cb),
4276 elm_interface_scrollable_animate_stop_cb_set(_scroll_animate_stop_cb),
4277 elm_interface_scrollable_drag_start_cb_set(_scroll_drag_start_cb),
4278 elm_interface_scrollable_drag_stop_cb_set(_scroll_drag_stop_cb),
4279 elm_interface_scrollable_edge_left_cb_set(_edge_left_cb),
4280 elm_interface_scrollable_edge_right_cb_set(_edge_right_cb),
4281 elm_interface_scrollable_edge_top_cb_set(_edge_top_cb),
4282 elm_interface_scrollable_edge_bottom_cb_set(_edge_bottom_cb),
4283 elm_interface_scrollable_scroll_cb_set(_scroll_cb),
4284 elm_interface_scrollable_page_change_cb_set(_scroll_page_change_cb));
4286 //Tizen Only: Item should be shown as top position.
4287 priv->align_x = 0.0;
4288 priv->align_y = 0.0;
4289 priv->highlight = EINA_TRUE;
4290 priv->item_cache_max = CACHE_MAX;
4292 priv->pan_obj = eo_add(MY_PAN_CLASS, evas_object_evas_get(obj));
4293 pan_data = eo_data_scope_get(priv->pan_obj, MY_PAN_CLASS);
4294 eo_data_ref(obj, NULL);
4295 pan_data->wobj = obj;
4296 pan_data->wsd = priv;
4298 priv->stack = evas_object_rectangle_add(evas_object_evas_get(obj));
4299 evas_object_smart_member_add(priv->stack, priv->pan_obj);
4300 evas_object_raise(priv->stack);
4302 eo_do(obj, elm_interface_scrollable_extern_pan_set(priv->pan_obj));
4306 _elm_gengrid_evas_object_smart_del(Eo *obj, Elm_Gengrid_Data *sd)
4308 elm_gengrid_clear(obj);
4309 ELM_SAFE_FREE(sd->pan_obj, evas_object_del);
4310 ELM_SAFE_FREE(sd->stack, evas_object_del);
4312 _item_cache_zero(sd);
4313 ecore_job_del(sd->calc_job);
4315 eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
4319 _elm_gengrid_evas_object_smart_move(Eo *obj, Elm_Gengrid_Data *sd, Evas_Coord x, Evas_Coord y)
4321 eo_do_super(obj, MY_CLASS, evas_obj_smart_move(x, y));
4323 evas_object_move(sd->hit_rect, x, y);
4327 _elm_gengrid_evas_object_smart_resize(Eo *obj, Elm_Gengrid_Data *sd, Evas_Coord w, Evas_Coord h)
4329 eo_do_super(obj, MY_CLASS, evas_obj_smart_resize(w, h));
4331 evas_object_resize(sd->hit_rect, w, h);
4335 _elm_gengrid_evas_object_smart_member_add(Eo *obj, Elm_Gengrid_Data *sd, Evas_Object *member)
4337 eo_do_super(obj, MY_CLASS, evas_obj_smart_member_add(member));
4340 evas_object_raise(sd->hit_rect);
4344 _access_obj_process(Elm_Gengrid_Data * sd, Eina_Bool is_access)
4348 EINA_INLIST_FOREACH(sd->items, it)
4350 if (!it->realized) continue;
4351 if (is_access) _access_widget_item_register(it);
4353 _elm_access_widget_item_unregister(it->base);
4359 _elm_gengrid_elm_widget_access(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Eina_Bool acs)
4361 _elm_gengrid_smart_focus_next_enable = acs;
4362 _access_obj_process(sd, _elm_gengrid_smart_focus_next_enable);
4366 elm_gengrid_add(Evas_Object *parent)
4368 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
4369 Evas_Object *obj = eo_add(MY_CLASS, parent);
4374 _elm_gengrid_eo_base_constructor(Eo *obj, Elm_Gengrid_Data *sd)
4376 obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
4380 evas_obj_type_set(MY_CLASS_NAME_LEGACY),
4381 evas_obj_smart_callbacks_descriptions_set(_smart_callbacks),
4382 elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_TREE_TABLE));
4388 _elm_gengrid_item_size_set(Eo *obj, Elm_Gengrid_Data *sd, Evas_Coord w, Evas_Coord h)
4390 if ((sd->item_width == w) && (sd->item_height == h)) return;
4392 sd->item_height = h;
4393 ecore_job_del(sd->calc_job);
4394 sd->calc_job = ecore_job_add(_calc_job, obj);
4398 _elm_gengrid_item_size_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Evas_Coord *w, Evas_Coord *h)
4400 if (w) *w = sd->item_width;
4401 if (h) *h = sd->item_height;
4405 _elm_gengrid_group_item_size_set(Eo *obj, Elm_Gengrid_Data *sd, Evas_Coord w, Evas_Coord h)
4407 if ((sd->group_item_width == w) && (sd->group_item_height == h)) return;
4408 sd->group_item_width = w;
4409 sd->group_item_height = h;
4410 ecore_job_del(sd->calc_job);
4411 sd->calc_job = ecore_job_add(_calc_job, obj);
4415 _elm_gengrid_group_item_size_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Evas_Coord *w, Evas_Coord *h)
4417 if (w) *w = sd->group_item_width;
4418 if (h) *h = sd->group_item_height;
4422 _elm_gengrid_align_set(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, double align_x, double align_y)
4424 double old_h, old_y;
4426 old_h = sd->align_x;
4427 old_y = sd->align_y;
4431 else if (align_x < 0.0)
4433 sd->align_x = align_x;
4437 else if (align_y < 0.0)
4439 sd->align_y = align_y;
4441 if ((old_h != sd->align_x) || (old_y != sd->align_y))
4442 evas_object_smart_calculate(sd->pan_obj);
4446 _elm_gengrid_align_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, double *align_x, double *align_y)
4448 if (align_x) *align_x = sd->align_x;
4449 if (align_y) *align_y = sd->align_y;
4452 EOLIAN static Elm_Object_Item*
4453 _elm_gengrid_item_append(Eo *obj, Elm_Gengrid_Data *sd, const Elm_Gengrid_Item_Class *itc, const void *data, Evas_Smart_Cb func, const void *func_data)
4457 it = _elm_gengrid_item_new(sd, itc, data, func, func_data);
4458 if (!it) return NULL;
4460 sd->items = eina_inlist_append(sd->items, EINA_INLIST_GET(it));
4461 it->position = sd->item_count;
4462 it->position_update = EINA_TRUE;
4465 sd->group_items = eina_list_prepend(sd->group_items, it);
4467 ecore_job_del(sd->calc_job);
4468 sd->calc_job = ecore_job_add(_calc_job, obj);
4470 if (_elm_config->atspi_mode)
4472 elm_interface_atspi_accessible_added(EO_OBJ(it));
4473 elm_interface_atspi_accessible_children_changed_added_signal_emit(sd->obj, EO_OBJ(it));
4479 EOLIAN static Elm_Object_Item*
4480 _elm_gengrid_item_prepend(Eo *obj, Elm_Gengrid_Data *sd, const Elm_Gengrid_Item_Class *itc, const void *data, Evas_Smart_Cb func, const void *func_data)
4484 it = _elm_gengrid_item_new(sd, itc, data, func, func_data);
4485 if (!it) return NULL;
4487 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(it));
4488 _item_position_update(sd->items, 1);
4491 sd->group_items = eina_list_append(sd->group_items, it);
4493 ecore_job_del(sd->calc_job);
4494 sd->calc_job = ecore_job_add(_calc_job, obj);
4496 if (_elm_config->atspi_mode)
4498 elm_interface_atspi_accessible_added(EO_OBJ(it));
4499 elm_interface_atspi_accessible_children_changed_added_signal_emit(sd->obj, EO_OBJ(it));
4505 EOLIAN static Elm_Object_Item*
4506 _elm_gengrid_item_insert_before(Eo *obj, Elm_Gengrid_Data *sd, const Elm_Gengrid_Item_Class *itc, const void *data, Elm_Object_Item *eo_relative, Evas_Smart_Cb func, const void *func_data)
4510 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_relative, NULL);
4511 ELM_GENGRID_ITEM_DATA_GET(eo_relative, relative);
4513 ELM_GENGRID_ITEM_CHECK_OR_RETURN(relative, NULL);
4515 it = _elm_gengrid_item_new(sd, itc, data, func, func_data);
4516 if (!it) return NULL;
4517 sd->items = eina_inlist_prepend_relative
4518 (sd->items, EINA_INLIST_GET(it),
4519 EINA_INLIST_GET(relative));
4520 tmp = eina_inlist_find(sd->items, EINA_INLIST_GET(it));
4521 _item_position_update(tmp, relative->position);
4524 sd->group_items = eina_list_append_relative
4525 (sd->group_items, it, relative->parent);
4527 ecore_job_del(sd->calc_job);
4528 sd->calc_job = ecore_job_add(_calc_job, obj);
4533 EOLIAN static Elm_Object_Item*
4534 _elm_gengrid_item_insert_after(Eo *obj, Elm_Gengrid_Data *sd, const Elm_Gengrid_Item_Class *itc, const void *data, Elm_Object_Item *eo_relative, Evas_Smart_Cb func, const void *func_data)
4538 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_relative, NULL);
4539 ELM_GENGRID_ITEM_DATA_GET(eo_relative, relative);
4541 ELM_GENGRID_ITEM_CHECK_OR_RETURN(relative, NULL);
4543 it = _elm_gengrid_item_new(sd, itc, data, func, func_data);
4544 if (!it) return NULL;
4545 sd->items = eina_inlist_append_relative
4546 (sd->items, EINA_INLIST_GET(it),
4547 EINA_INLIST_GET(relative));
4548 tmp = eina_inlist_find(sd->items, EINA_INLIST_GET(it));
4549 _item_position_update(tmp, relative->position + 1);
4552 sd->group_items = eina_list_prepend_relative
4553 (sd->group_items, it, relative->parent);
4555 ecore_job_del(sd->calc_job);
4556 sd->calc_job = ecore_job_add(_calc_job, obj);
4561 EOLIAN static Elm_Object_Item*
4562 _elm_gengrid_item_sorted_insert(Eo *obj, Elm_Gengrid_Data *sd, const Elm_Gengrid_Item_Class *itc, const void *data, Eina_Compare_Cb comp, Evas_Smart_Cb func, const void *func_data)
4566 it = _elm_gengrid_item_new(sd, itc, data, func, func_data);
4567 if (!it) return NULL;
4571 sd->state = eina_inlist_sorted_state_new();
4572 eina_inlist_sorted_state_init(sd->state, sd->items);
4575 sd->item_compare_cb = comp;
4576 sd->items = eina_inlist_sorted_state_insert
4577 (sd->items, EINA_INLIST_GET(it), _elm_gengrid_item_compare, sd->state);
4578 _item_position_update(sd->items, 0);
4580 ecore_job_del(sd->calc_job);
4581 sd->calc_job = ecore_job_add(_calc_job, obj);
4587 _elm_gengrid_horizontal_set(Eo *obj, Elm_Gengrid_Data *sd, Eina_Bool horizontal)
4589 horizontal = !!horizontal;
4590 if (horizontal == sd->horizontal) return;
4591 sd->horizontal = horizontal;
4593 /* Update the items to conform to the new layout */
4594 ecore_job_del(sd->calc_job);
4595 sd->calc_job = ecore_job_add(_calc_job, obj);
4598 EOLIAN static Eina_Bool
4599 _elm_gengrid_horizontal_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
4601 return sd->horizontal;
4605 _elm_gengrid_clear(Eo *obj, Elm_Gengrid_Data *_pd EINA_UNUSED)
4607 _internal_elm_gengrid_clear(obj, EINA_FALSE);
4610 EINA_DEPRECATED EAPI const Evas_Object *
4611 elm_gengrid_item_object_get(const Elm_Object_Item *eo_it)
4613 ELM_GENGRID_ITEM_DATA_GET(eo_it, it);
4614 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, NULL);
4620 _elm_gengrid_item_update(Eo *eo_item EINA_UNUSED, Elm_Gen_Item *it)
4622 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
4624 if (!it->realized) return;
4625 if (it->want_unrealize) return;
4627 _elm_gengrid_item_unrealize(it, EINA_TRUE);
4629 _item_place(it, it->x, it->y);
4631 _elm_gengrid_item_index_update(it);
4635 _elm_gengrid_item_fields_update(Eo *eo_item EINA_UNUSED, Elm_Gen_Item *it,
4637 Elm_Gengrid_Item_Field_Type itf)
4639 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
4641 if (!it->realized) return;
4642 if (it->want_unrealize) return;
4644 if ((!itf) || (itf & ELM_GENGRID_ITEM_FIELD_TEXT))
4645 _item_text_realize(it, VIEW(it), &it->texts, parts);
4647 if ((!itf) || (itf & ELM_GENGRID_ITEM_FIELD_CONTENT))
4648 _item_content_realize(it, VIEW(it), &it->contents, "contents", parts);
4650 if ((!itf) || (itf & ELM_GENGRID_ITEM_FIELD_STATE))
4651 _item_state_realize(it, VIEW(it), parts);
4653 _item_place(it, it->x, it->y);
4656 EOLIAN static const Elm_Gengrid_Item_Class *
4657 _elm_gengrid_item_item_class_get(Eo *eo_item EINA_UNUSED, Elm_Gen_Item *item)
4659 if (item->generation < GG_IT(item)->wsd->generation) return NULL;
4664 _elm_gengrid_item_item_class_update(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it,
4665 const Elm_Gengrid_Item_Class *itc)
4667 EINA_SAFETY_ON_NULL_RETURN(itc);
4669 if (it->generation < GG_IT(it)->wsd->generation) return;
4671 it->item->nocache_once = EINA_TRUE;
4673 elm_gengrid_item_update(EO_OBJ(it));
4677 _elm_gengrid_item_pos_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it,
4686 _elm_gengrid_multi_select_set(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Eina_Bool multi)
4688 sd->multi = !!multi;
4691 EOLIAN static Eina_Bool
4692 _elm_gengrid_multi_select_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
4698 _elm_gengrid_multi_select_mode_set(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Elm_Object_Multi_Select_Mode mode)
4700 if (mode >= ELM_OBJECT_MULTI_SELECT_MODE_MAX)
4703 if (sd->multi_select_mode != mode)
4704 sd->multi_select_mode = mode;
4707 EOLIAN static Elm_Object_Multi_Select_Mode
4708 _elm_gengrid_multi_select_mode_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
4710 return sd->multi_select_mode;
4713 EOLIAN static Elm_Object_Item*
4714 _elm_gengrid_selected_item_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
4716 if (sd->selected) return sd->selected->data;
4720 EOLIAN static const Eina_List*
4721 _elm_gengrid_selected_items_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
4723 return sd->selected;
4727 _elm_gengrid_item_selected_set(Eo *eo_item EINA_UNUSED, Elm_Gen_Item *it,
4731 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
4732 if ((it->generation < sd->generation) || eo_do_ret(EO_OBJ(it), tmp, elm_wdg_item_disabled_get()))
4734 selected = !!selected;
4735 if (it->selected == selected) return;
4741 while (sd->selected)
4743 Elm_Object_Item *eo_sel = sd->selected->data;
4744 ELM_GENGRID_ITEM_DATA_GET(eo_sel, sel);
4745 it->unhighlight_cb(sel);
4749 it->highlight_cb(it);
4753 it->unhighlight_cb(it);
4757 EOLIAN static Eina_Bool
4758 _elm_gengrid_item_selected_get(Eo *eo_item EINA_UNUSED, Elm_Gen_Item *it)
4760 return it->selected;
4763 EOLIAN static Eina_List*
4764 _elm_gengrid_realized_items_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
4767 Eina_Bool done = EINA_FALSE;
4769 Eina_List *ret = NULL;
4771 EINA_INLIST_FOREACH(sd->items, it)
4776 ret = eina_list_append(ret, EO_OBJ(it));
4788 _elm_gengrid_realized_items_update(Eo *obj, Elm_Gengrid_Data *_pd EINA_UNUSED)
4791 Elm_Object_Item *it;
4793 list = elm_gengrid_realized_items_get(obj);
4794 EINA_LIST_FREE(list, it)
4795 elm_gengrid_item_update(it);
4798 static Evas_Object *
4799 _elm_gengrid_item_label_create(void *data,
4800 Evas_Object *obj EINA_UNUSED,
4801 Evas_Object *tooltip,
4802 void *it EINA_UNUSED)
4804 Evas_Object *label = elm_label_add(tooltip);
4807 elm_object_style_set(label, "tooltip");
4808 elm_object_text_set(label, data);
4813 _elm_gengrid_item_label_del_cb(void *data,
4814 Evas_Object *obj EINA_UNUSED,
4815 void *event_info EINA_UNUSED)
4817 eina_stringshare_del(data);
4821 elm_gengrid_item_tooltip_text_set(Elm_Object_Item *it,
4824 eo_do(it, elm_wdg_item_tooltip_text_set(text));
4828 _elm_gengrid_item_elm_widget_item_tooltip_text_set(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it, const char *text)
4830 text = eina_stringshare_add(text);
4831 elm_gengrid_item_tooltip_content_cb_set
4832 (EO_OBJ(it), _elm_gengrid_item_label_create, text,
4833 _elm_gengrid_item_label_del_cb);
4837 elm_gengrid_item_tooltip_content_cb_set(Elm_Object_Item *item,
4838 Elm_Tooltip_Item_Content_Cb func,
4840 Evas_Smart_Cb del_cb)
4842 eo_do(item, elm_wdg_item_tooltip_content_cb_set(func, data, del_cb));
4846 _elm_gengrid_item_elm_widget_item_tooltip_content_cb_set(Eo *eo_it, Elm_Gen_Item *it,
4847 Elm_Tooltip_Item_Content_Cb func,
4849 Evas_Smart_Cb del_cb)
4851 ELM_GENGRID_ITEM_CHECK_OR_GOTO(it, error);
4853 if ((it->tooltip.content_cb != func) || (it->tooltip.data != data))
4855 if (it->tooltip.del_cb)
4856 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
4857 it->tooltip.content_cb = func;
4858 it->tooltip.data = data;
4859 it->tooltip.del_cb = del_cb;
4863 eo_do_super(eo_it, ELM_GENGRID_ITEM_CLASS,
4864 elm_wdg_item_tooltip_content_cb_set
4865 (it->tooltip.content_cb, it->tooltip.data, NULL));
4867 elm_wdg_item_tooltip_style_set(it->tooltip.style),
4868 elm_wdg_item_tooltip_window_mode_set(it->tooltip.free_size));
4874 if (del_cb) del_cb((void *)data, NULL, NULL);
4878 elm_gengrid_item_tooltip_unset(Elm_Object_Item *item)
4880 eo_do(item, elm_wdg_item_tooltip_unset());
4884 _elm_gengrid_item_elm_widget_item_tooltip_unset(Eo *eo_it, Elm_Gen_Item *it)
4886 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
4888 if ((VIEW(it)) && (it->tooltip.content_cb))
4889 eo_do_super(eo_it, ELM_GENGRID_ITEM_CLASS,
4890 elm_wdg_item_tooltip_unset());
4892 if (it->tooltip.del_cb)
4893 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
4894 it->tooltip.del_cb = NULL;
4895 it->tooltip.content_cb = NULL;
4896 it->tooltip.data = NULL;
4897 it->tooltip.free_size = EINA_FALSE;
4898 if (it->tooltip.style)
4899 eo_do(eo_it, elm_wdg_item_tooltip_style_set(NULL));
4903 elm_gengrid_item_tooltip_style_set(Elm_Object_Item *it,
4906 eo_do(it, elm_wdg_item_tooltip_style_set(style));
4910 _elm_gengrid_item_elm_widget_item_tooltip_style_set(Eo *eo_it, Elm_Gen_Item *it,
4913 eina_stringshare_replace(&it->tooltip.style, style);
4914 if (VIEW(it)) eo_do_super(eo_it, ELM_GENGRID_ITEM_CLASS,
4915 elm_wdg_item_tooltip_style_set(style));
4919 elm_gengrid_item_tooltip_style_get(const Elm_Object_Item *it)
4922 return eo_do_ret(it, ret, elm_wdg_item_tooltip_style_get());
4925 EOLIAN static const char *
4926 _elm_gengrid_item_elm_widget_item_tooltip_style_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
4928 return it->tooltip.style;
4932 elm_gengrid_item_tooltip_window_mode_set(Elm_Object_Item *it,
4936 return eo_do_ret(it, ret, elm_wdg_item_tooltip_window_mode_set(disable));
4939 EOLIAN static Eina_Bool
4940 _elm_gengrid_item_elm_widget_item_tooltip_window_mode_set(Eo *eo_it, Elm_Gen_Item *it,
4943 it->tooltip.free_size = disable;
4947 eo_do_super(eo_it, ELM_GENGRID_ITEM_CLASS,
4948 ret = elm_wdg_item_tooltip_window_mode_set(disable));
4956 elm_gengrid_item_tooltip_window_mode_get(const Elm_Object_Item *it)
4959 return eo_do_ret(it, ret, elm_wdg_item_tooltip_window_mode_get());
4962 EOLIAN static Eina_Bool
4963 _elm_gengrid_item_elm_widget_item_tooltip_window_mode_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
4965 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4967 return it->tooltip.free_size;
4971 elm_gengrid_item_cursor_set(Elm_Object_Item *it,
4974 eo_do(it, elm_wdg_item_cursor_set(cursor));
4978 _elm_gengrid_item_elm_widget_item_cursor_set(Eo *eo_it, Elm_Gen_Item *it,
4981 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
4983 eina_stringshare_replace(&it->mouse_cursor, cursor);
4984 if (VIEW(it)) eo_do_super(eo_it, ELM_GENGRID_ITEM_CLASS,
4985 elm_wdg_item_cursor_set(cursor));
4989 elm_gengrid_item_cursor_get(const Elm_Object_Item *it)
4992 return eo_do_ret(it, ret, elm_wdg_item_cursor_get());
4996 elm_gengrid_item_cursor_unset(Elm_Object_Item *item)
4998 eo_do(item, elm_wdg_item_cursor_unset());
5002 _elm_gengrid_item_elm_widget_item_cursor_unset(Eo *eo_it, Elm_Gen_Item *it)
5004 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
5005 if (!it->mouse_cursor)
5008 if (VIEW(it)) eo_do_super(eo_it, ELM_GENGRID_ITEM_CLASS,
5009 elm_wdg_item_cursor_unset());
5011 ELM_SAFE_FREE(it->mouse_cursor, eina_stringshare_del);
5015 elm_gengrid_item_cursor_style_set(Elm_Object_Item *it,
5018 eo_do(it, elm_wdg_item_cursor_style_set(style));
5022 elm_gengrid_item_cursor_style_get(const Elm_Object_Item *it)
5025 return eo_do_ret(it, ret, elm_wdg_item_cursor_style_get());
5029 elm_gengrid_item_cursor_engine_only_set(Elm_Object_Item *eo_it,
5030 Eina_Bool engine_only)
5032 ELM_GENGRID_ITEM_DATA_GET(eo_it, it);
5033 it->cursor_engine_only = engine_only;
5035 eo_do(eo_it, elm_wdg_item_cursor_engine_only_set(engine_only));
5039 elm_gengrid_item_cursor_engine_only_get(const Elm_Object_Item *eo_it)
5041 ELM_GENGRID_ITEM_DATA_GET(eo_it, it);
5044 return eo_do_ret(eo_it, ret, elm_wdg_item_cursor_engine_only_get());
5045 else return it->cursor_engine_only;
5049 _elm_gengrid_reorder_mode_start(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Ecore_Pos_Map tween_mode)
5051 sd->reorder_mode = EINA_TRUE;
5052 sd->reorder.tween_mode = tween_mode;
5053 sd->reorder.type = ELM_GENGRID_REORDER_TYPE_NORMAL;
5057 _elm_gengrid_reorder_mode_stop(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5059 sd->reorder_mode = EINA_FALSE;
5060 sd->reorder.tween_mode = -1;
5064 _elm_gengrid_reorder_type_set(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Elm_Gengrid_Reorder_Type type)
5066 sd->reorder.type = type;
5070 _elm_gengrid_reorder_mode_set(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Eina_Bool reorder_mode)
5072 sd->reorder_mode = !!reorder_mode;
5075 EOLIAN static Eina_Bool
5076 _elm_gengrid_reorder_mode_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5078 return sd->reorder_mode;
5082 elm_gengrid_bounce_set(Evas_Object *obj,
5086 ELM_GENGRID_CHECK(obj);
5087 eo_do(obj, elm_interface_scrollable_bounce_allow_set(h_bounce, v_bounce));
5091 _elm_gengrid_elm_interface_scrollable_bounce_allow_set(Eo *obj, Elm_Gengrid_Data *sd EINA_UNUSED, Eina_Bool h_bounce, Eina_Bool v_bounce)
5093 eo_do_super(obj, MY_CLASS, elm_interface_scrollable_bounce_allow_set(!!h_bounce, !!v_bounce));
5097 elm_gengrid_bounce_get(const Evas_Object *obj,
5098 Eina_Bool *h_bounce,
5099 Eina_Bool *v_bounce)
5101 ELM_GENGRID_CHECK(obj);
5102 eo_do( obj, elm_interface_scrollable_bounce_allow_get(h_bounce, v_bounce));
5106 _elm_gengrid_page_relative_set(Eo *obj, Elm_Gengrid_Data *_pd EINA_UNUSED, double h_pagerel, double v_pagerel)
5108 Evas_Coord pagesize_h;
5109 Evas_Coord pagesize_v;
5111 eo_do( obj, elm_interface_scrollable_paging_get(NULL, NULL, &pagesize_h, &pagesize_v));
5112 eo_do( obj, elm_interface_scrollable_paging_set
5113 (h_pagerel, v_pagerel, pagesize_h, pagesize_v));
5117 _elm_gengrid_page_relative_get(Eo *obj, Elm_Gengrid_Data *_pd EINA_UNUSED, double *h_pagerel, double *v_pagerel)
5119 eo_do( obj, elm_interface_scrollable_paging_get(h_pagerel, v_pagerel, NULL, NULL));
5123 _elm_gengrid_page_size_set(Eo *obj, Elm_Gengrid_Data *_pd EINA_UNUSED, Evas_Coord h_pagesize, Evas_Coord v_pagesize)
5128 eo_do( obj, elm_interface_scrollable_paging_get(&pagerel_h, &pagerel_v, NULL, NULL));
5129 eo_do( obj, elm_interface_scrollable_paging_set
5130 (pagerel_h, pagerel_v, h_pagesize, v_pagesize));
5134 elm_gengrid_current_page_get(const Evas_Object *obj,
5138 ELM_GENGRID_CHECK(obj);
5139 eo_do( obj, elm_interface_scrollable_current_page_get(h_pagenumber, v_pagenumber));
5143 elm_gengrid_last_page_get(const Evas_Object *obj,
5147 ELM_GENGRID_CHECK(obj);
5148 eo_do( obj, elm_interface_scrollable_last_page_get(h_pagenumber, v_pagenumber));
5151 EINA_DEPRECATED EAPI void
5152 elm_gengrid_page_show(const Evas_Object *obj,
5156 ELM_GENGRID_CHECK(obj);
5157 eo_do( obj, elm_interface_scrollable_page_show(h_pagenumber, v_pagenumber));
5160 EINA_DEPRECATED EAPI void
5161 elm_gengrid_page_bring_in(const Evas_Object *obj,
5165 ELM_GENGRID_CHECK(obj);
5166 eo_do( obj, elm_interface_scrollable_page_bring_in(h_pagenumber, v_pagenumber));
5170 elm_gengrid_scroller_policy_set(Evas_Object *obj,
5171 Elm_Scroller_Policy policy_h,
5172 Elm_Scroller_Policy policy_v)
5174 ELM_GENGRID_CHECK(obj);
5175 eo_do(obj, elm_interface_scrollable_policy_set(policy_h, policy_v));
5179 _elm_gengrid_elm_interface_scrollable_policy_set(Eo *obj, Elm_Gengrid_Data *sd EINA_UNUSED, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
5181 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5182 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5185 eo_do_super(obj, MY_CLASS, elm_interface_scrollable_policy_set(policy_h, policy_v));
5189 elm_gengrid_scroller_policy_get(const Evas_Object *obj,
5190 Elm_Scroller_Policy *policy_h,
5191 Elm_Scroller_Policy *policy_v)
5193 ELM_GENGRID_CHECK(obj);
5194 eo_do( obj, elm_interface_scrollable_policy_get(policy_h, policy_v));
5198 _elm_gengrid_elm_interface_scrollable_policy_get(Eo *obj, Elm_Gengrid_Data *sd EINA_UNUSED, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
5200 Elm_Scroller_Policy s_policy_h, s_policy_v;
5202 eo_do_super(obj, MY_CLASS, elm_interface_scrollable_policy_get(&s_policy_h, &s_policy_v));
5203 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5204 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5207 EOLIAN static Elm_Object_Item*
5208 _elm_gengrid_first_item_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5210 if (!sd->items) return NULL;
5212 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(sd->items);
5214 while ((it) && (it->generation < sd->generation))
5215 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
5220 EOLIAN static Elm_Object_Item*
5221 _elm_gengrid_at_xy_item_get(const Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Evas_Coord x, Evas_Coord y, int *xposret, int *yposret)
5223 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(sd->items);
5225 Evas_Coord l = 0, r = 0, t = 0, b = 0; /* left, right, top, bottom */
5226 Eina_Bool init = EINA_TRUE;
5228 while ((it) && (it->generation < sd->generation))
5229 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
5234 Evas_Coord itx, ity;
5235 Evas_Coord itw, ith;
5236 evas_object_geometry_get(VIEW(it), &itx, &ity, &itw, &ith);
5238 /* Record leftmost, rightmost, top, bottom cords to set posret */
5239 if ((itw > 0) && (ith > 0) && (itx >= 0) && (ity >= 0))
5240 { /* A scroller, ignore items in negative cords,or not rendered */
5253 if ((itx + itw) > r)
5257 if ((ity + ith) > b)
5262 if (ELM_RECTS_INTERSECT
5263 (itx, ity, itw, ith, x, y, 1, 1))
5267 if (y <= (ity + (ith / 4))) *yposret = -1;
5268 else if (y >= (ity + ith - (ith / 4)))
5275 if (x <= (itx + (itw / 4))) *xposret = -1;
5276 else if (x >= (itx + itw - (itw / 4)))
5284 } while ((it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next)));
5286 /* No item found, tell the user if hit left/right/top/bottom of items */
5308 EOLIAN static Elm_Object_Item*
5309 _elm_gengrid_last_item_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5311 if (!sd->items) return NULL;
5313 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
5314 while ((it) && (it->generation < sd->generation))
5315 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
5320 EOLIAN static Elm_Object_Item *
5321 _elm_gengrid_item_next_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
5323 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, NULL);
5327 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
5328 if ((it) && (it->generation == GG_IT(it)->wsd->generation)) break;
5334 EOLIAN static Elm_Object_Item *
5335 _elm_gengrid_item_prev_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
5337 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, NULL);
5341 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
5342 if ((it) && (it->generation == GG_IT(it)->wsd->generation)) break;
5349 _elm_gengrid_item_show(Eo *eo_it, Elm_Gen_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
5351 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
5353 if ((it->generation < sd->generation)) return;
5355 sd->show_region = EINA_TRUE;
5356 sd->show_it = eo_it;
5357 sd->scroll_to_type = type;
5359 _item_show_region(sd);
5363 _elm_gengrid_item_bring_in(Eo *eo_it, Elm_Gen_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
5365 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
5367 if (it->generation < sd->generation) return;
5369 sd->bring_in = EINA_TRUE;
5370 sd->bring_in_it = eo_it;
5371 sd->scroll_to_type = type;
5373 _item_show_region(sd);
5377 _elm_gengrid_filled_set(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Eina_Bool fill)
5380 if (sd->filled != fill)
5384 EOLIAN static Eina_Bool
5385 _elm_gengrid_filled_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5390 EOLIAN static unsigned int
5391 _elm_gengrid_items_count(const Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5393 return sd->item_count;
5396 EAPI Elm_Gengrid_Item_Class *
5397 elm_gengrid_item_class_new(void)
5399 Elm_Gengrid_Item_Class *itc;
5401 itc = calloc(1, sizeof(Elm_Gengrid_Item_Class));
5404 itc->version = CLASS_ALLOCATED;
5406 itc->delete_me = EINA_FALSE;
5412 elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
5414 if (!itc || (itc->version != CLASS_ALLOCATED)) return;
5416 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
5417 if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
5426 elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
5428 if (itc && (itc->version == CLASS_ALLOCATED))
5431 if (itc->refcount == 0) itc->refcount--;
5436 elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
5438 if (itc && (itc->version == CLASS_ALLOCATED))
5440 if (itc->refcount > 0) itc->refcount--;
5441 if (itc->delete_me && (!itc->refcount))
5442 elm_gengrid_item_class_free(itc);
5447 _elm_gengrid_select_mode_set(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Elm_Object_Select_Mode mode)
5449 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
5452 if (sd->select_mode != mode)
5453 sd->select_mode = mode;
5456 EOLIAN static Elm_Object_Select_Mode
5457 _elm_gengrid_select_mode_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5459 return sd->select_mode;
5463 _elm_gengrid_highlight_mode_set(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Eina_Bool highlight)
5465 sd->highlight = !!highlight;
5468 EOLIAN static Eina_Bool
5469 _elm_gengrid_highlight_mode_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5471 return sd->highlight;
5475 _elm_gengrid_item_index_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
5477 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, -1);
5479 return it->position;
5483 _elm_gengrid_item_select_mode_set(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it,
5484 Elm_Object_Select_Mode mode)
5486 if (it->generation < GG_IT(it)->wsd->generation) return;
5487 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
5490 if (it->select_mode != mode)
5491 it->select_mode = mode;
5493 if (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
5494 elm_gengrid_item_update(EO_OBJ(it));
5497 EOLIAN static Elm_Object_Select_Mode
5498 _elm_gengrid_item_select_mode_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
5500 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, ELM_OBJECT_SELECT_MODE_MAX);
5502 return it->select_mode;
5505 EOLIAN Elm_Atspi_State_Set
5506 _elm_gengrid_item_elm_interface_atspi_accessible_state_set_get(Eo *eo_it, Elm_Gen_Item *it EINA_UNUSED)
5508 Elm_Atspi_State_Set ret;
5511 eo_do_super(eo_it, ELM_GENGRID_ITEM_CLASS, ret = elm_interface_atspi_accessible_state_set_get());
5513 eo_do(eo_it, sel = elm_obj_gengrid_item_selected_get());
5515 STATE_TYPE_SET(ret, ELM_ATSPI_STATE_SELECTABLE);
5518 STATE_TYPE_SET(ret, ELM_ATSPI_STATE_SELECTED);
5524 _elm_gengrid_item_elm_interface_atspi_accessible_name_get(Eo *eo_it, Elm_Gen_Item *it)
5529 eo_do_super(eo_it, ELM_GENGRID_ITEM_CLASS, ret = elm_interface_atspi_accessible_name_get());
5530 if (ret) return ret;
5532 buf = eina_strbuf_new();
5534 if (it->itc->func.text_get)
5540 elm_widget_stringlist_get(edje_object_data_get(VIEW(it), "texts"));
5542 EINA_LIST_FREE(texts, key)
5544 char *str_markup = it->itc->func.text_get
5545 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
5547 char *str_utf8 = _elm_util_mkup_to_text(str_markup);
5553 if (eina_strbuf_length_get(buf) > 0)
5554 eina_strbuf_append(buf, ", ");
5555 eina_strbuf_append(buf, str_utf8);
5561 ret = eina_strbuf_string_steal(buf);
5562 eina_strbuf_free(buf);
5567 _elm_gengrid_item_elm_interface_atspi_accessible_children_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
5569 Eina_List *ret = NULL;
5574 parts = elm_widget_stringlist_get(edje_object_data_get(VIEW(it), "contents"));
5576 EINA_LIST_FREE(parts, key)
5579 part = edje_object_part_swallow_get(VIEW(it), key);
5580 if (part && eo_isa(part, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
5582 ret = eina_list_append(ret, part);
5583 eo_do(part, elm_interface_atspi_accessible_parent_set(eo_it));
5590 EOLIAN static Eina_Bool
5591 _elm_gengrid_item_elm_interface_atspi_component_highlight_grab(Eo *eo_it, Elm_Gen_Item *it)
5593 elm_gengrid_item_show(eo_it, ELM_GENGRID_ITEM_SCROLLTO_IN);
5595 elm_object_accessibility_highlight_set(VIEW(it), EINA_TRUE);
5600 EOLIAN static Eina_Bool
5601 _elm_gengrid_item_elm_interface_atspi_component_highlight_clear(Eo *eo_it, Elm_Gen_Item *it)
5603 elm_object_accessibility_highlight_set(VIEW(it), EINA_FALSE);
5608 EAPI Elm_Object_Item *
5609 elm_gengrid_nth_item_get(const Evas_Object *obj, unsigned int nth)
5611 Elm_Gen_Item *it = NULL;
5615 ELM_GENGRID_CHECK(obj) NULL;
5616 ELM_GENGRID_DATA_GET(obj, sd);
5618 if (!sd->items) return NULL;
5620 a = eina_inlist_accessor_new(sd->items);
5621 if (!a) return NULL;
5622 if (eina_accessor_data_get(a, nth, &data))
5623 it = ELM_GEN_ITEM_FROM_INLIST(data);
5624 eina_accessor_free(a);
5629 _elm_gengrid_elm_widget_focus_highlight_geometry_get(const Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
5631 Evas_Coord ox, oy, oh, ow, item_x = 0, item_y = 0, item_w = 0, item_h = 0;
5633 evas_object_geometry_get(sd->pan_obj, &ox, &oy, &ow, &oh);
5635 if (sd->focused_item)
5637 ELM_GENGRID_ITEM_DATA_GET(sd->focused_item, focus_it);
5638 evas_object_geometry_get(VIEW(focus_it), &item_x, &item_y, &item_w, &item_h);
5639 elm_widget_focus_highlight_focus_part_geometry_get(VIEW(focus_it), &item_x, &item_y, &item_w, &item_h);
5653 else if (item_x > (ox + ow - item_w))
5655 *x = ox + ow - item_w;
5664 else if (item_y > (oy + oh - item_h))
5666 *y = oy + oh - item_h;
5671 EOLIAN static Elm_Object_Item *
5672 _elm_gengrid_elm_widget_focused_item_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5674 return sd->focused_item;
5678 _elm_gengrid_elm_widget_item_loop_enabled_set(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd, Eina_Bool enable)
5680 sd->item_loop_enable = !!enable;
5683 EOLIAN static Eina_Bool
5684 _elm_gengrid_elm_widget_item_loop_enabled_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5686 return sd->item_loop_enable;
5690 _elm_gengrid_wheel_disabled_set(Eo *obj, Elm_Gengrid_Data *sd, Eina_Bool disabled)
5692 disabled = !!disabled;
5693 if (sd->wheel_disabled != disabled)
5695 elm_interface_scrollable_wheel_disabled_set(disabled));
5697 sd->wheel_disabled = disabled;
5700 EOLIAN static Eina_Bool
5701 _elm_gengrid_wheel_disabled_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5703 return sd->wheel_disabled;
5707 _elm_gengrid_class_constructor(Eo_Class *klass)
5709 if (_elm_config->access_mode)
5710 _elm_gengrid_smart_focus_next_enable = EINA_TRUE;
5712 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
5715 EOLIAN const Elm_Atspi_Action *
5716 _elm_gengrid_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *pd EINA_UNUSED)
5718 static Elm_Atspi_Action atspi_actions[] = {
5719 { "move,prior", "move", "prior", _key_action_move},
5720 { "move,next", "move", "next", _key_action_move},
5721 { "move,left", "move", "left", _key_action_move},
5722 { "move,left,multi", "move", "left_multi", _key_action_move},
5723 { "move,right", "move", "right", _key_action_move},
5724 { "move,right,multi", "move", "right_multi", _key_action_move},
5725 { "move,up", "move", "up", _key_action_move},
5726 { "move,up,multi", "move", "up_multi", _key_action_move},
5727 { "move,down", "move", "down", _key_action_move},
5728 { "move,down,multi", "move", "down_multi", _key_action_move},
5729 { "move,first", "move", "first", _key_action_move},
5730 { "move,last", "move", "last", _key_action_move},
5731 { "select", "select", NULL, _key_action_select},
5732 { "select,multi", "select", "multi", _key_action_select},
5733 { "escape", "escape", NULL, _key_action_escape},
5734 { NULL, NULL, NULL, NULL }
5736 return &atspi_actions[0];
5740 _elm_gengrid_elm_interface_atspi_accessible_children_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *sd)
5742 Eina_List *ret = NULL;
5745 EINA_INLIST_FOREACH(sd->items, it)
5746 ret = eina_list_append(ret, EO_OBJ(it));
5751 EOLIAN Elm_Atspi_State_Set
5752 _elm_gengrid_elm_interface_atspi_accessible_state_set_get(Eo *obj, Elm_Gengrid_Data *sd EINA_UNUSED)
5754 Elm_Atspi_State_Set ret;
5756 eo_do_super(obj, ELM_GENGRID_CLASS, ret = elm_interface_atspi_accessible_state_set_get());
5758 STATE_TYPE_SET(ret, ELM_ATSPI_STATE_MANAGES_DESCENDANTS);
5760 if (elm_gengrid_multi_select_get(obj))
5761 STATE_TYPE_SET(ret, ELM_ATSPI_STATE_MULTISELECTABLE);
5767 _elm_gengrid_elm_interface_atspi_selection_selected_children_count_get(Eo *objm EINA_UNUSED, Elm_Gengrid_Data *pd)
5769 return eina_list_count(pd->selected);
5773 _elm_gengrid_elm_interface_atspi_selection_selected_child_get(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *pd, int child_idx)
5775 return eina_list_nth(pd->selected, child_idx);
5779 _elm_gengrid_elm_interface_atspi_selection_child_select(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *pd, int child_index)
5782 if (pd->select_mode != ELM_OBJECT_SELECT_MODE_NONE)
5784 EINA_INLIST_FOREACH(pd->items, item)
5786 if (child_index-- == 0)
5788 elm_gengrid_item_selected_set(EO_OBJ(item), EINA_TRUE);
5797 _elm_gengrid_elm_interface_atspi_selection_selected_child_deselect(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *pd, int child_index)
5802 EINA_LIST_FOREACH(pd->selected, l, item)
5804 if (child_index-- == 0)
5806 elm_gengrid_item_selected_set(item, EINA_FALSE);
5814 _elm_gengrid_elm_interface_atspi_selection_is_child_selected(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *pd, int child_index)
5818 EINA_INLIST_FOREACH(pd->items, item)
5820 if (child_index-- == 0)
5822 return elm_gengrid_item_selected_get(EO_OBJ(item));
5829 _elm_gengrid_elm_interface_atspi_selection_all_children_select(Eo *obj, Elm_Gengrid_Data *pd)
5833 if (!elm_gengrid_multi_select_get(obj))
5836 EINA_INLIST_FOREACH(pd->items, item)
5837 elm_gengrid_item_selected_set(EO_OBJ(item), EINA_TRUE);
5843 _elm_gengrid_elm_interface_atspi_selection_clear(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *pd)
5845 return _all_items_deselect(pd);
5849 _elm_gengrid_elm_interface_atspi_selection_child_deselect(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *pd, int child_index)
5852 if (pd->select_mode != ELM_OBJECT_SELECT_MODE_NONE)
5854 EINA_INLIST_FOREACH(pd->items, item)
5856 if (child_index-- == 0)
5858 elm_gengrid_item_selected_set(EO_OBJ(item), EINA_FALSE);
5866 #include "elm_gengrid.eo.c"
5867 #include "elm_gengrid_item.eo.c"