3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
6 #include "els_scroller.h"
7 #include "elm_gen_common.h"
9 // internally allocated
10 #define CLASS_ALLOCATED 0x3a70f11f
12 #define MAX_ITEMS_PER_BLOCK 32
13 #define REORDER_EFFECT_TIME 0.5
15 #define ELM_GEN_SETUP(wd) \
16 (wd)->calc_cb = (Ecore_Cb)_calc_job; \
17 (wd)->clear_cb = (Ecore_Cb)_clear_cb; \
18 (wd)->sizing_cb = (Ecore_Cb)_sizing_eval
20 #define ELM_GEN_ITEM_SETUP(it) \
21 (it)->del_cb = (Ecore_Cb)_item_del; \
22 (it)->highlight_cb = (Ecore_Cb)_item_highlight; \
23 (it)->unsel_cb = (Ecore_Cb)_item_unselect; \
24 (it)->unhighlight_cb = (Ecore_Cb)_item_unhighlight; \
25 (it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
27 #define ELM_GENLIST_CHECK_ITC_VER(itc) \
32 ERR("Genlist_Item_Class(itc) is NULL"); \
35 if ((itc->version != ELM_GENLIST_ITEM_CLASS_VERSION) && \
36 (itc->version != CLASS_ALLOCATED)) \
38 ERR("Genlist_Item_Class version mismatched! current = (%d), required = (%d) or (%d)", itc->version, ELM_GENLIST_ITEM_CLASS_VERSION, CLASS_ALLOCATED); \
44 typedef struct _Item_Block Item_Block;
45 typedef struct _Item_Cache Item_Cache;
47 struct Elm_Gen_Item_Type
52 Evas_Coord w, h, minw, minh;
53 Elm_Gen_Item *group_item;
54 Elm_Genlist_Item_Type type;
55 Eina_List *mode_texts, *mode_contents, *mode_states, *mode_content_objs;
56 Eina_List *edit_texts, *edit_contents, *edit_states, *edit_content_objs;
57 Ecore_Timer *swipe_timer;
58 Evas_Coord scrl_x, scrl_y, old_scrl_y;
61 Evas_Object *mode_view;
67 Eina_Bool want_realize : 1;
68 Eina_Bool expanded : 1;
69 Eina_Bool mincalcd : 1;
72 Eina_Bool updateme : 1;
73 Eina_Bool nocache : 1; /* do not use cache for this item */
74 Eina_Bool nocache_once : 1; /* do not use cache for this item only once */
75 Eina_Bool stacking_even : 1;
76 Eina_Bool nostacking : 1;
77 Eina_Bool move_effect_enabled : 1;
78 Eina_Bool edit_mode_item_realized : 1;
79 Eina_Bool tree_effect_finished : 1; /* tree effect */
90 Evas_Coord x, y, w, h, minw, minh;
92 int item_position_stamp;
94 Eina_Bool position_update : 1;
95 Eina_Bool want_unrealize : 1;
96 Eina_Bool realized : 1;
97 Eina_Bool changed : 1;
98 Eina_Bool updateme : 1;
100 Eina_Bool must_recalc : 1;
107 Evas_Object *base_view, *spacer;
109 const char *item_style; // it->itc->item_style
110 Eina_Bool tree : 1; // it->group
111 Eina_Bool compress : 1; // it->wd->compress
113 Eina_Bool selected : 1; // it->selected
114 Eina_Bool disabled : 1; // it->disabled
115 Eina_Bool expanded : 1; // it->item->expanded
118 static const char *widtype = NULL;
119 static void _item_cache_zero(Widget_Data *wd);
120 static void _del_hook(Evas_Object *obj);
121 static void _mirrored_set(Evas_Object *obj,
123 static void _theme_hook(Evas_Object *obj);
124 static void _show_region_hook(void *data,
126 static void _sizing_eval(Evas_Object *obj);
127 static void _item_realize(Elm_Gen_Item *it,
130 static void _item_unrealize_cb(Elm_Gen_Item *it);
131 static void _item_block_unrealize(Item_Block *itb);
132 static void _calc_job(void *data);
133 static void _on_focus_hook(void *data,
135 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
136 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
137 static Eina_Bool _item_single_select_up(Widget_Data *wd);
138 static Eina_Bool _item_single_select_down(Widget_Data *wd);
139 static Eina_Bool _event_hook(Evas_Object *obj,
141 Evas_Callback_Type type,
143 static void _signal_emit_hook(Evas_Object *obj,
144 const char *emission,
146 static Eina_Bool _deselect_all_items(Widget_Data *wd);
147 static void _pan_calculate(Evas_Object *obj);
148 static void _pan_max_get(Evas_Object *obj,
151 static void _item_position(Elm_Gen_Item *it,
155 static void _mode_item_realize(Elm_Gen_Item *it);
156 static void _mode_item_unrealize(Elm_Gen_Item *it);
157 static void _item_mode_set(Elm_Gen_Item *it);
158 static void _item_mode_unset(Widget_Data *wd);
159 static void _edit_mode_item_position(Elm_Gen_Item *it, int itx, int ity);
160 static void _edit_mode_item_realize(Elm_Gen_Item *it, Eina_Bool effect_on);
161 static void _edit_mode_item_unrealize(Elm_Gen_Item *it);
162 static void _group_items_recalc(void *data);
163 static void _item_move_after(Elm_Gen_Item *it,
164 Elm_Gen_Item *after);
165 static void _item_move_before(Elm_Gen_Item *it,
166 Elm_Gen_Item *before);
167 static void _item_auto_scroll(Widget_Data *wd);
168 static void _elm_genlist_clear(Evas_Object *obj,
170 static void _pan_child_size_get(Evas_Object *obj,
173 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
174 static void _item_contract_emit(Elm_Gen_Item *it);
175 static int _item_tree_effect_before(Elm_Gen_Item *it);
176 static void _item_tree_effect(Widget_Data *wd, int y);
177 static void _item_tree_effect_finish(Widget_Data *wd);
178 static Eina_Bool _item_moving_effect_timer_cb(void *data);
180 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
182 static const char SIG_ACTIVATED[] = "activated";
183 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
184 static const char SIG_SELECTED[] = "selected";
185 static const char SIG_UNSELECTED[] = "unselected";
186 static const char SIG_EXPANDED[] = "expanded";
187 static const char SIG_CONTRACTED[] = "contracted";
188 static const char SIG_EXPAND_REQUEST[] = "expand,request";
189 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
190 static const char SIG_REALIZED[] = "realized";
191 static const char SIG_UNREALIZED[] = "unrealized";
192 static const char SIG_DRAG_START_UP[] = "drag,start,up";
193 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
194 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
195 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
196 static const char SIG_DRAG_STOP[] = "drag,stop";
197 static const char SIG_DRAG[] = "drag";
198 static const char SIG_LONGPRESSED[] = "longpressed";
199 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
200 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
201 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
202 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
203 static const char SIG_EDGE_TOP[] = "edge,top";
204 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
205 static const char SIG_EDGE_LEFT[] = "edge,left";
206 static const char SIG_EDGE_RIGHT[] = "edge,right";
207 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
208 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
209 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
210 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
211 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
212 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
213 static const char SIG_SWIPE[] = "swipe";
214 static const char SIG_MOVED[] = "moved";
215 static const char SIG_INDEX_UPDATE[] = "index,update";
216 static const char SIG_TREE_EFFECT_FINISHED [] = "tree,effect,finished";
218 static const Evas_Smart_Cb_Description _signals[] = {
219 {SIG_CLICKED_DOUBLE, ""},
222 {SIG_UNSELECTED, ""},
224 {SIG_CONTRACTED, ""},
225 {SIG_EXPAND_REQUEST, ""},
226 {SIG_CONTRACT_REQUEST, ""},
228 {SIG_UNREALIZED, ""},
229 {SIG_DRAG_START_UP, ""},
230 {SIG_DRAG_START_DOWN, ""},
231 {SIG_DRAG_START_LEFT, ""},
232 {SIG_DRAG_START_RIGHT, ""},
235 {SIG_LONGPRESSED, ""},
236 {SIG_SCROLL_ANIM_START, ""},
237 {SIG_SCROLL_ANIM_STOP, ""},
238 {SIG_SCROLL_DRAG_START, ""},
239 {SIG_SCROLL_DRAG_STOP, ""},
241 {SIG_EDGE_BOTTOM, ""},
243 {SIG_EDGE_RIGHT, ""},
244 {SIG_MULTI_SWIPE_LEFT, ""},
245 {SIG_MULTI_SWIPE_RIGHT, ""},
246 {SIG_MULTI_SWIPE_UP, ""},
247 {SIG_MULTI_SWIPE_DOWN, ""},
248 {SIG_MULTI_PINCH_OUT, ""},
249 {SIG_MULTI_PINCH_IN, ""},
252 {SIG_TREE_EFFECT_FINISHED, ""},
257 #undef ELM_CHECK_WIDTYPE
258 #define ELM_CHECK_WIDTYPE(obj, widtype) \
259 if ((!obj) || (!elm_genlist_type_check((obj), __func__))) return
260 #undef ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN
261 #define ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, ...) \
262 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
263 ELM_CHECK_WIDTYPE(WIDGET((it)), widtype) __VA_ARGS__;
265 static const char *_gengrid = NULL;
266 static const char *_genlist = NULL;
268 /* THIS FUNCTION IS HACKY AND TEMPORARY!!! */
270 elm_genlist_type_check(const Evas_Object *obj,
273 const char *provided, *expected = "(unknown)";
274 static int abort_on_warn = -1;
275 provided = elm_widget_type_get(obj);
276 if (!_genlist) _genlist = eina_stringshare_add("genlist");
277 if (!_gengrid) _gengrid = eina_stringshare_add("gengrid");
278 if (EINA_LIKELY(provided == _genlist) || EINA_LIKELY(provided == _gengrid))
280 if ((!provided) || (!provided[0]))
282 provided = evas_object_type_get(obj);
283 if ((!provided) || (!provided[0]))
284 provided = "(unknown)";
286 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
287 if (abort_on_warn == -1)
289 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
290 else abort_on_warn = 0;
292 if (abort_on_warn == 1) abort();
297 _event_hook(Evas_Object *obj,
298 Evas_Object *src __UNUSED__,
299 Evas_Callback_Type type,
302 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
303 Evas_Event_Key_Down *ev = event_info;
304 Widget_Data *wd = elm_widget_data_get(obj);
305 Evas_Coord pan_max_x = 0, pan_max_y = 0;
306 if (!wd) return EINA_FALSE;
307 if (!wd->items) return EINA_FALSE;
308 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
309 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
311 Elm_Object_Item *it = NULL;
314 Evas_Coord step_x = 0;
315 Evas_Coord step_y = 0;
318 Evas_Coord page_x = 0;
319 Evas_Coord page_y = 0;
321 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
322 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
323 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
324 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
326 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
330 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
334 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
336 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
337 (_item_multi_select_up(wd)))
338 || (_item_single_select_up(wd)))
340 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
346 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
348 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
349 (_item_multi_select_down(wd)))
350 || (_item_single_select_down(wd)))
352 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
358 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
360 it = elm_genlist_first_item_get(obj);
361 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
362 elm_genlist_item_selected_set(it, EINA_TRUE);
363 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
366 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
368 it = elm_genlist_last_item_get(obj);
369 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
370 elm_genlist_item_selected_set(it, EINA_TRUE);
371 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
374 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
377 y -= -(page_y * v_h) / 100;
381 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
384 y += -(page_y * v_h) / 100;
388 else if (!strcmp(ev->keyname, "Escape"))
390 if (!_deselect_all_items(wd)) return EINA_FALSE;
391 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
394 else if (((!strcmp(ev->keyname, "Return")) ||
395 (!strcmp(ev->keyname, "KP_Enter")) ||
396 (!strcmp(ev->keyname, "space")))
397 && (!wd->multi) && (wd->selected))
399 it = elm_genlist_selected_item_get(obj);
400 elm_genlist_item_expanded_set(it,
401 !elm_genlist_item_expanded_get(it));
402 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
404 else return EINA_FALSE;
406 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
407 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
409 if (x > pan_max_x) x = pan_max_x;
411 if (y > pan_max_y) y = pan_max_y;
412 elm_smart_scroller_child_pos_set(wd->scr, x, y);
417 _deselect_all_items(Widget_Data *wd)
419 if (!wd->selected) return EINA_FALSE;
421 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
427 _item_multi_select_up(Widget_Data *wd)
429 if (!wd->selected) return EINA_FALSE;
430 if (!wd->multi) return EINA_FALSE;
432 Elm_Object_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
433 if (!prev) return EINA_TRUE;
435 if (elm_genlist_item_selected_get(prev))
437 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
438 wd->last_selected_item = prev;
439 elm_genlist_item_show(wd->last_selected_item, ELM_GENLIST_ITEM_SCROLLTO_IN);
443 elm_genlist_item_selected_set(prev, EINA_TRUE);
444 elm_genlist_item_show(prev, ELM_GENLIST_ITEM_SCROLLTO_IN);
450 _item_multi_select_down(Widget_Data *wd)
452 if (!wd->selected) return EINA_FALSE;
453 if (!wd->multi) return EINA_FALSE;
455 Elm_Object_Item *next;
456 next = elm_genlist_item_next_get(wd->last_selected_item);
457 if (!next) return EINA_TRUE;
459 if (elm_genlist_item_selected_get(next))
461 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
462 wd->last_selected_item = next;
463 elm_genlist_item_show(wd->last_selected_item, ELM_GENLIST_ITEM_SCROLLTO_IN);
467 elm_genlist_item_selected_set(next, EINA_TRUE);
468 elm_genlist_item_show(next, ELM_GENLIST_ITEM_SCROLLTO_IN);
474 _item_single_select_up(Widget_Data *wd)
479 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
480 while ((prev) && (prev->generation < wd->generation))
481 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
483 else prev = (Elm_Gen_Item *) elm_genlist_item_prev_get(wd->last_selected_item);
485 if (!prev) return EINA_FALSE;
487 _deselect_all_items(wd);
489 elm_genlist_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
490 elm_genlist_item_show((Elm_Object_Item *) prev, ELM_GENLIST_ITEM_SCROLLTO_IN);
495 _item_single_select_down(Widget_Data *wd)
500 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
501 while ((next) && (next->generation < wd->generation))
502 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
504 else next = (Elm_Gen_Item *) elm_genlist_item_next_get(wd->last_selected_item);
506 if (!next) return EINA_FALSE;
508 _deselect_all_items(wd);
510 elm_genlist_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
511 elm_genlist_item_show((Elm_Object_Item *) next, ELM_GENLIST_ITEM_SCROLLTO_IN);
516 _on_focus_hook(void *data __UNUSED__,
519 Widget_Data *wd = elm_widget_data_get(obj);
521 if (elm_widget_focus_get(obj))
523 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
524 evas_object_focus_set(wd->obj, EINA_TRUE);
525 if ((wd->selected) && (!wd->last_selected_item))
526 wd->last_selected_item = eina_list_data_get(wd->selected);
530 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
531 evas_object_focus_set(wd->obj, EINA_FALSE);
536 _del_hook(Evas_Object *obj)
538 Widget_Data *wd = elm_widget_data_get(obj);
540 _item_cache_zero(wd);
541 if (wd->calc_job) ecore_job_del(wd->calc_job);
542 if (wd->update_job) ecore_job_del(wd->update_job);
543 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
544 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
545 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
546 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
547 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
552 _del_pre_hook(Evas_Object *obj)
554 Widget_Data *wd = elm_widget_data_get(obj);
556 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
557 elm_genlist_clear(obj);
558 evas_object_del(wd->pan_smart);
559 wd->pan_smart = NULL;
563 _mirrored_set(Evas_Object *obj,
566 Widget_Data *wd = elm_widget_data_get(obj);
568 _item_cache_zero(wd);
569 elm_smart_scroller_mirrored_set(wd->scr, rtl);
573 _theme_hook(Evas_Object *obj)
575 Widget_Data *wd = elm_widget_data_get(obj);
578 evas_event_freeze(evas_object_evas_get(wd->obj));
579 _item_cache_zero(wd);
580 _elm_widget_mirrored_reload(obj);
581 _mirrored_set(obj, elm_widget_mirrored_get(obj));
582 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
583 elm_widget_style_get(obj));
584 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
585 wd->item_width = wd->item_height = 0;
586 wd->group_item_width = wd->group_item_height = 0;
587 wd->minw = wd->minh = wd->realminw = 0;
588 EINA_INLIST_FOREACH(wd->blocks, itb)
593 if (itb->realized) _item_block_unrealize(itb);
594 EINA_LIST_FOREACH(itb->items, l, it)
595 it->item->mincalcd = EINA_FALSE;
597 itb->changed = EINA_TRUE;
599 if (wd->calc_job) ecore_job_del(wd->calc_job);
600 wd->calc_job = ecore_job_add(_calc_job, wd);
602 evas_event_thaw(evas_object_evas_get(wd->obj));
603 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
607 _show_region_hook(void *data,
610 Widget_Data *wd = elm_widget_data_get(data);
611 Evas_Coord x, y, w, h;
613 elm_widget_show_region_get(obj, &x, &y, &w, &h);
614 //x & y are screen coordinates, Add with pan coordinates
617 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
621 _translate_hook(Evas_Object *obj)
623 evas_object_smart_callback_call(obj, "language,changed", NULL);
627 _sizing_eval(Evas_Object *obj)
629 Widget_Data *wd = elm_widget_data_get(obj);
630 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
632 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
633 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
635 if (wd->height_for_width)
639 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
640 if ((vw != 0) && (vw != wd->prev_viewport_w))
644 wd->prev_viewport_w = vw;
645 EINA_INLIST_FOREACH(wd->blocks, itb)
647 itb->must_recalc = EINA_TRUE;
649 if (wd->calc_job) ecore_job_del(wd->calc_job);
650 wd->calc_job = ecore_job_add(_calc_job, wd);
653 if (wd->mode == ELM_LIST_LIMIT)
659 elm_smart_scroller_child_viewport_size_get(wd->scr, &vmw, &vmh);
660 edje_object_size_min_calc
661 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
668 edje_object_size_min_calc
669 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
673 evas_object_size_hint_min_set(obj, minw, minh);
674 evas_object_size_hint_max_set(obj, maxw, maxh);
678 _signal_emit_hook(Evas_Object *obj,
679 const char *emission,
682 Widget_Data *wd = elm_widget_data_get(obj);
683 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
688 _item_highlight(Elm_Gen_Item *it)
690 const char *selectraise;
691 if ((it->wd->select_mode == ELM_OBJECT_NO_SELECT) ||
692 (it->wd->no_highlight) ||
693 (it->generation < it->wd->generation) ||
694 (it->highlighted) || elm_widget_item_disabled_get(it) ||
695 (it->display_only) || (it->item->mode_view))
697 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
698 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
699 selectraise = edje_object_data_get(VIEW(it), "selectraise");
700 if ((selectraise) && (!strcmp(selectraise, "on")))
702 if (it->edit_obj) evas_object_raise(it->edit_obj);
703 else evas_object_raise(VIEW(it));
704 if ((it->item->group_item) && (it->item->group_item->realized))
705 evas_object_raise(it->item->VIEW(group_item));
707 it->highlighted = EINA_TRUE;
711 _item_unhighlight(Elm_Gen_Item *it)
713 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
714 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
715 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
716 if (!it->item->nostacking)
718 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
720 if (it->edit_obj) evas_object_lower(it->edit_obj);
721 else evas_object_lower(VIEW(it));
725 if (it->edit_obj) evas_object_raise(it->edit_obj);
726 else evas_object_raise(VIEW(it));
729 it->highlighted = EINA_FALSE;
733 _item_block_position_update(Eina_Inlist *list, int idx)
737 EINA_INLIST_FOREACH(list, tmp)
739 tmp->position = idx++;
740 tmp->position_update = EINA_TRUE;
745 _item_position_update(Eina_List *list, int idx)
750 EINA_LIST_FOREACH(list, l, it)
752 it->position = idx++;
753 it->position_update = EINA_TRUE;
758 _item_block_del(Elm_Gen_Item *it)
761 Item_Block *itb = it->item->block;
763 itb->items = eina_list_remove(itb->items, it);
765 itb->changed = EINA_TRUE;
766 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
767 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
770 il = EINA_INLIST_GET(itb);
771 Item_Block *itbn = (Item_Block *)(il->next);
773 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
776 _item_block_position_update(il->next, itb->position);
777 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
780 if (itbn) itbn->changed = EINA_TRUE;
784 if (itb->count < itb->wd->max_items_per_block/2)
786 il = EINA_INLIST_GET(itb);
787 Item_Block *itbp = (Item_Block *)(il->prev);
788 Item_Block *itbn = (Item_Block *)(il->next);
789 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
793 EINA_LIST_FREE(itb->items, it2)
795 it2->item->block = itbp;
796 itbp->items = eina_list_append(itbp->items, it2);
798 itbp->changed = EINA_TRUE;
800 _item_block_position_update(EINA_INLIST_GET(itb)->next,
802 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
803 EINA_INLIST_GET(itb));
806 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
810 Eina_List *last = eina_list_last(itb->items);
811 Elm_Gen_Item *it2 = last->data;
813 it2->item->block = itbn;
814 itb->items = eina_list_remove_list(itb->items, last);
815 itbn->items = eina_list_prepend(itbn->items, it2);
817 itbn->changed = EINA_TRUE;
819 _item_block_position_update(EINA_INLIST_GET(itb)->next,
822 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
830 _item_subitems_clear(Elm_Gen_Item *it)
832 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
833 Eina_List *tl = NULL, *l;
834 Elm_Object_Item *it2;
836 EINA_LIST_FOREACH(it->item->items, l, it2)
837 tl = eina_list_append(tl, it2);
838 EINA_LIST_FREE(tl, it2)
839 elm_object_item_del(it2);
843 _item_del(Elm_Gen_Item *it)
845 Evas_Object *obj = WIDGET(it);
847 evas_event_freeze(evas_object_evas_get(obj));
848 elm_genlist_item_subitems_clear((Elm_Object_Item *)it);
849 if (it->wd->show_item == it) it->wd->show_item = NULL;
850 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
851 if (it->item->edit_mode_item_realized) _edit_mode_item_unrealize(it);
852 if (it->item->block) _item_block_del(it);
853 if (it->item->queued)
854 it->wd->queue = eina_list_remove(it->wd->queue, it);
855 if (it->wd->anchor_item == it)
857 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
858 if (!it->wd->anchor_item)
859 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
861 if (it->wd->expanded_item == it) it->wd->expanded_item = NULL;
863 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
864 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
865 _elm_genlist_item_del_serious(it);
866 elm_genlist_item_class_unref((Elm_Genlist_Item_Class *)it->itc);
867 evas_event_thaw(evas_object_evas_get(obj));
868 evas_event_thaw_eval(evas_object_evas_get(obj));
872 _clear_cb(Widget_Data *wd)
874 wd->anchor_item = NULL;
877 Item_Block *itb = (Item_Block *)(wd->blocks);
879 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
880 if (itb->items) eina_list_free(itb->items);
883 if (wd->queue_idle_enterer)
885 ecore_idle_enterer_del(wd->queue_idle_enterer);
886 wd->queue_idle_enterer = NULL;
888 if (wd->must_recalc_idler)
890 ecore_idler_del(wd->must_recalc_idler);
891 wd->must_recalc_idler = NULL;
893 if (wd->queue) wd->queue = eina_list_free(wd->queue);
894 if (wd->reorder_move_animator)
896 ecore_animator_del(wd->reorder_move_animator);
897 wd->reorder_move_animator = NULL;
899 wd->show_item = NULL;
900 wd->reorder_old_pan_y = 0;
904 _item_unselect(Elm_Gen_Item *it)
906 if ((it->generation < it->wd->generation) || (!it->selected)) return;
907 it->selected = EINA_FALSE;
908 it->wd->selected = eina_list_remove(it->wd->selected, it);
909 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
913 _mouse_move(void *data,
914 Evas *evas __UNUSED__,
918 Elm_Gen_Item *it = data;
919 Evas_Event_Mouse_Move *ev = event_info;
920 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
921 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
923 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
925 if (!it->wd->on_hold)
927 it->wd->on_hold = EINA_TRUE;
928 if ((!it->wd->wasselected) && (!it->flipped))
930 _item_unhighlight(it);
935 if (it->wd->multitouched)
937 it->wd->cur_x = ev->cur.canvas.x;
938 it->wd->cur_y = ev->cur.canvas.y;
941 if ((it->dragging) && (it->down))
943 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
946 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
947 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
948 if (abs((it->wd->history[it->wd->movements].x -
949 it->wd->history[0].x)) > 40)
950 it->wd->swipe = EINA_TRUE;
956 ecore_timer_del(it->long_timer);
957 it->long_timer = NULL;
959 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
962 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
966 ecore_timer_del(it->long_timer);
967 it->long_timer = NULL;
969 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
971 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
972 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
974 if (!it->wd->reorder_start_y)
975 it->wd->reorder_start_y = it->item->block->y + it->y;
979 else if (it_scrl_y + it->wd->reorder_it->item->h > oy + oh)
980 y_pos = oy + oh - it->wd->reorder_it->item->h;
985 _item_position(it, it->edit_obj, it->item->scrl_x, y_pos);
987 _item_position(it, VIEW(it), it->item->scrl_x, y_pos);
989 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
990 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
994 if (!it->display_only)
995 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
996 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
997 x = ev->cur.canvas.x - x;
998 y = ev->cur.canvas.y - y;
1001 if (adx < 0) adx = -dx;
1004 if (ady < 0) ady = -dy;
1007 if ((adx > minw) || (ady > minh))
1009 it->dragging = EINA_TRUE;
1012 ecore_timer_del(it->long_timer);
1013 it->long_timer = NULL;
1015 if (!it->wd->wasselected)
1017 _item_unhighlight(it);
1023 evas_object_smart_callback_call(WIDGET(it),
1024 SIG_DRAG_START_UP, it);
1028 evas_object_smart_callback_call(WIDGET(it),
1029 SIG_DRAG_START_LEFT, it);
1031 evas_object_smart_callback_call(WIDGET(it),
1032 SIG_DRAG_START_RIGHT, it);
1038 evas_object_smart_callback_call(WIDGET(it),
1039 SIG_DRAG_START_DOWN, it);
1043 evas_object_smart_callback_call(WIDGET(it),
1044 SIG_DRAG_START_LEFT, it);
1046 evas_object_smart_callback_call(WIDGET(it),
1047 SIG_DRAG_START_RIGHT, it);
1054 _long_press(void *data)
1056 Elm_Gen_Item *it = data, *it_tmp;
1057 Eina_List *list, *l;
1059 it->long_timer = NULL;
1060 if (elm_widget_item_disabled_get(it) || (it->dragging) || (it->display_only))
1061 return ECORE_CALLBACK_CANCEL;
1062 it->wd->longpressed = EINA_TRUE;
1063 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
1064 if ((it->wd->reorder_mode) && (!it->group))
1066 it->wd->reorder_it = it;
1067 it->wd->reorder_start_y = 0;
1069 evas_object_raise(it->edit_obj);
1071 evas_object_raise(VIEW(it));
1073 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1074 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1076 list = elm_genlist_realized_items_get(it->wd->obj);
1077 EINA_LIST_FOREACH(list, l, it_tmp)
1079 if (it != it_tmp) _item_unselect(it_tmp);
1081 if (elm_genlist_item_expanded_get((Elm_Object_Item *)it))
1083 elm_genlist_item_expanded_set((Elm_Object_Item *)it, EINA_FALSE);
1084 return ECORE_CALLBACK_RENEW;
1087 if (!it->wd->edit_mode)
1088 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
1090 return ECORE_CALLBACK_CANCEL;
1094 _swipe(Elm_Gen_Item *it)
1099 if ((it->display_only) || elm_widget_item_disabled_get(it)) return;
1100 it->wd->swipe = EINA_FALSE;
1101 for (i = 0; i < it->wd->movements; i++)
1103 sum += it->wd->history[i].x;
1104 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1107 sum /= it->wd->movements;
1108 if (abs(sum - it->wd->history[0].x) <= 10) return;
1109 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
1113 _swipe_cancel(void *data)
1115 Elm_Gen_Item *it = data;
1117 if (!it) return ECORE_CALLBACK_CANCEL;
1118 it->wd->swipe = EINA_FALSE;
1119 it->wd->movements = 0;
1120 return ECORE_CALLBACK_RENEW;
1124 _multi_cancel(void *data)
1126 Widget_Data *wd = data;
1128 if (!wd) return ECORE_CALLBACK_CANCEL;
1129 wd->multi_timeout = EINA_TRUE;
1130 return ECORE_CALLBACK_RENEW;
1134 _multi_touch_gesture_eval(void *data)
1136 Elm_Gen_Item *it = data;
1138 it->wd->multitouched = EINA_FALSE;
1139 if (it->wd->multi_timer)
1141 ecore_timer_del(it->wd->multi_timer);
1142 it->wd->multi_timer = NULL;
1144 if (it->wd->multi_timeout)
1146 it->wd->multi_timeout = EINA_FALSE;
1150 Evas_Coord minw = 0, minh = 0;
1151 Evas_Coord off_x, off_y, off_mx, off_my;
1153 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1154 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1155 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1156 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1157 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1159 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1161 if ((off_x + off_mx) > (off_y + off_my))
1163 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1164 evas_object_smart_callback_call(WIDGET(it),
1165 SIG_MULTI_SWIPE_RIGHT, it);
1166 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1167 evas_object_smart_callback_call(WIDGET(it),
1168 SIG_MULTI_SWIPE_LEFT, it);
1169 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1170 evas_object_smart_callback_call(WIDGET(it),
1171 SIG_MULTI_PINCH_OUT, it);
1173 evas_object_smart_callback_call(WIDGET(it),
1174 SIG_MULTI_PINCH_IN, it);
1178 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1179 evas_object_smart_callback_call(WIDGET(it),
1180 SIG_MULTI_SWIPE_DOWN, it);
1181 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1182 evas_object_smart_callback_call(WIDGET(it),
1183 SIG_MULTI_SWIPE_UP, it);
1184 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1185 evas_object_smart_callback_call(WIDGET(it),
1186 SIG_MULTI_PINCH_OUT, it);
1188 evas_object_smart_callback_call(WIDGET(it),
1189 SIG_MULTI_PINCH_IN, it);
1192 it->wd->multi_timeout = EINA_FALSE;
1196 _multi_down(void *data,
1197 Evas *evas __UNUSED__,
1198 Evas_Object *obj __UNUSED__,
1201 Elm_Gen_Item *it = data;
1202 Evas_Event_Multi_Down *ev = event_info;
1204 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1205 it->wd->multi_device = ev->device;
1206 it->wd->multi_down = EINA_TRUE;
1207 it->wd->multitouched = EINA_TRUE;
1208 it->wd->prev_mx = ev->canvas.x;
1209 it->wd->prev_my = ev->canvas.y;
1210 if (!it->wd->wasselected)
1212 _item_unhighlight(it);
1215 it->wd->wasselected = EINA_FALSE;
1216 it->wd->longpressed = EINA_FALSE;
1219 ecore_timer_del(it->long_timer);
1220 it->long_timer = NULL;
1224 it->dragging = EINA_FALSE;
1225 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1227 if (it->item->swipe_timer)
1229 ecore_timer_del(it->item->swipe_timer);
1230 it->item->swipe_timer = NULL;
1232 if (it->wd->on_hold)
1234 it->wd->swipe = EINA_FALSE;
1235 it->wd->movements = 0;
1236 it->wd->on_hold = EINA_FALSE;
1241 _multi_up(void *data,
1242 Evas *evas __UNUSED__,
1243 Evas_Object *obj __UNUSED__,
1246 Elm_Gen_Item *it = data;
1247 Evas_Event_Multi_Up *ev = event_info;
1249 if (it->wd->multi_device != ev->device) return;
1250 it->wd->multi_device = 0;
1251 it->wd->multi_down = EINA_FALSE;
1252 if (it->wd->mouse_down) return;
1253 _multi_touch_gesture_eval(data);
1257 _multi_move(void *data,
1258 Evas *evas __UNUSED__,
1259 Evas_Object *obj __UNUSED__,
1262 Elm_Gen_Item *it = data;
1263 Evas_Event_Multi_Move *ev = event_info;
1265 if (it->wd->multi_device != ev->device) return;
1266 it->wd->cur_mx = ev->cur.canvas.x;
1267 it->wd->cur_my = ev->cur.canvas.y;
1271 _mouse_down(void *data,
1272 Evas *evas __UNUSED__,
1276 Elm_Gen_Item *it = data;
1277 Evas_Event_Mouse_Down *ev = event_info;
1280 if (ev->button != 1) return;
1281 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1283 it->wd->on_hold = EINA_TRUE;
1286 it->down = EINA_TRUE;
1287 it->dragging = EINA_FALSE;
1288 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1289 it->dx = ev->canvas.x - x;
1290 it->dy = ev->canvas.y - y;
1291 it->wd->mouse_down = EINA_TRUE;
1292 if (!it->wd->multitouched)
1294 it->wd->prev_x = ev->canvas.x;
1295 it->wd->prev_y = ev->canvas.y;
1296 it->wd->multi_timeout = EINA_FALSE;
1297 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1298 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1300 it->wd->longpressed = EINA_FALSE;
1301 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1302 else it->wd->on_hold = EINA_FALSE;
1303 if (it->wd->on_hold) return;
1304 it->wd->wasselected = it->selected;
1305 _item_highlight(it);
1306 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1307 if ((!elm_widget_item_disabled_get(it)) && (!it->display_only))
1309 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1310 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
1312 if (it->long_timer) ecore_timer_del(it->long_timer);
1313 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
1314 it->item->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1316 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1319 it->long_timer = NULL;
1320 it->wd->swipe = EINA_FALSE;
1321 it->wd->movements = 0;
1325 _mouse_up(void *data,
1326 Evas *evas __UNUSED__,
1327 Evas_Object *obj __UNUSED__,
1330 Elm_Gen_Item *it = data;
1331 Evas_Event_Mouse_Up *ev = event_info;
1332 Eina_Bool dragged = EINA_FALSE;
1334 if (ev->button != 1) return;
1335 it->down = EINA_FALSE;
1336 it->wd->mouse_down = EINA_FALSE;
1337 if (it->wd->multitouched)
1339 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1340 if (it->wd->multi_down) return;
1341 _multi_touch_gesture_eval(data);
1344 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1345 else it->wd->on_hold = EINA_FALSE;
1348 ecore_timer_del(it->long_timer);
1349 it->long_timer = NULL;
1353 it->dragging = EINA_FALSE;
1354 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1357 if (it->item->swipe_timer)
1359 ecore_timer_del(it->item->swipe_timer);
1360 it->item->swipe_timer = NULL;
1362 if (it->wd->multi_timer)
1364 ecore_timer_del(it->wd->multi_timer);
1365 it->wd->multi_timer = NULL;
1366 it->wd->multi_timeout = EINA_FALSE;
1368 if (it->wd->on_hold)
1370 if (it->wd->swipe) _swipe(data);
1371 it->wd->longpressed = EINA_FALSE;
1372 it->wd->on_hold = EINA_FALSE;
1375 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1377 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1379 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1381 if (it_scrl_y <= it->wd->reorder_rel->item->scrl_y)
1382 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1384 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1388 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1389 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1391 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
1392 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1393 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1394 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
1396 if (it->wd->longpressed)
1398 it->wd->longpressed = EINA_FALSE;
1399 if ((!it->wd->wasselected) && (!it->flipped))
1401 _item_unhighlight(it);
1404 it->wd->wasselected = EINA_FALSE;
1409 if (it->want_unrealize)
1411 _elm_genlist_item_unrealize(it, EINA_FALSE);
1412 if (it->item->block->want_unrealize)
1413 _item_block_unrealize(it->item->block);
1416 if (elm_widget_item_disabled_get(it) || (dragged) || (it->display_only))
1418 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1423 _item_highlight(it);
1428 _item_unhighlight(it);
1436 Widget_Data *wd = it->wd;
1439 while (wd->selected)
1441 _item_unhighlight(wd->selected->data);
1442 _item_unselect(wd->selected->data);
1448 const Eina_List *l, *l_next;
1451 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1454 _item_unhighlight(it2);
1455 _item_unselect(it2);
1457 //_item_highlight(it);
1460 _item_highlight(it);
1466 _signal_expand_toggle(void *data,
1467 Evas_Object *obj __UNUSED__,
1468 const char *emission __UNUSED__,
1469 const char *source __UNUSED__)
1471 Elm_Gen_Item *it = data;
1473 if (it->item->expanded)
1474 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1476 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1480 _signal_expand(void *data,
1481 Evas_Object *obj __UNUSED__,
1482 const char *emission __UNUSED__,
1483 const char *source __UNUSED__)
1485 Elm_Gen_Item *it = data;
1487 if (!it->item->expanded)
1488 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1492 _signal_contract(void *data,
1493 Evas_Object *obj __UNUSED__,
1494 const char *emission __UNUSED__,
1495 const char *source __UNUSED__)
1497 Elm_Gen_Item *it = data;
1499 if (it->item->expanded)
1500 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1504 _scr_hold_timer_cb(void *data)
1506 if (!data) return ECORE_CALLBACK_CANCEL;
1507 Widget_Data *wd = data;
1508 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1509 wd->scr_hold_timer = NULL;
1510 return ECORE_CALLBACK_CANCEL;
1514 _mode_finished_signal_cb(void *data,
1516 const char *emission __UNUSED__,
1517 const char *source __UNUSED__)
1521 Elm_Gen_Item *it = data;
1522 if ((it->generation < it->wd->generation) || (!it->realized) || (!it->item->mode_view)) return;
1524 Evas *te = evas_object_evas_get(obj);
1526 evas_event_freeze(te);
1527 it->item->nocache_once = EINA_FALSE;
1528 _mode_item_unrealize(it);
1529 if (it->item->group_item)
1530 evas_object_raise(it->item->VIEW(group_item));
1531 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1532 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1533 evas_event_thaw(te);
1534 evas_event_thaw_eval(te);
1538 _item_cache_clean(Widget_Data *wd)
1540 evas_event_freeze(evas_object_evas_get(wd->obj));
1541 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1545 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1546 wd->item_cache = eina_inlist_remove(wd->item_cache,
1547 wd->item_cache->last);
1548 wd->item_cache_count--;
1549 if (itc->spacer) evas_object_del(itc->spacer);
1550 if (itc->base_view) evas_object_del(itc->base_view);
1551 eina_stringshare_del(itc->item_style);
1554 evas_event_thaw(evas_object_evas_get(wd->obj));
1555 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1559 _item_cache_zero(Widget_Data *wd)
1561 int pmax = wd->item_cache_max;
1562 wd->item_cache_max = 0;
1563 _item_cache_clean(wd);
1564 wd->item_cache_max = pmax;
1568 _item_cache_add(Elm_Gen_Item *it)
1572 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1573 if (it->wd->item_cache_max <= 0)
1575 evas_object_del(VIEW(it));
1577 evas_object_del(it->spacer);
1579 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1580 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1584 it->wd->item_cache_count++;
1585 itc = calloc(1, sizeof(Item_Cache));
1588 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1589 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1592 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1593 EINA_INLIST_GET(itc));
1594 itc->spacer = it->spacer;
1596 itc->base_view = VIEW(it);
1598 edje_object_signal_emit(itc->base_view, "elm,state,unselected", "elm");
1599 evas_object_hide(itc->base_view);
1600 evas_object_move(itc->base_view, -9999, -9999);
1601 itc->item_style = eina_stringshare_add(it->itc->item_style);
1602 if (it->item->type & ELM_GENLIST_ITEM_TREE) itc->tree = 1;
1603 itc->compress = (it->wd->compress);
1604 itc->selected = it->selected;
1605 itc->disabled = elm_widget_item_disabled_get(it);
1606 itc->expanded = it->item->expanded;
1609 ecore_timer_del(it->long_timer);
1610 it->long_timer = NULL;
1612 if (it->item->swipe_timer)
1614 ecore_timer_del(it->item->swipe_timer);
1615 it->item->swipe_timer = NULL;
1617 // FIXME: other callbacks?
1618 edje_object_signal_callback_del_full(itc->base_view,
1619 "elm,action,expand,toggle",
1620 "elm", _signal_expand_toggle, it);
1621 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1623 _signal_expand, it);
1624 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1625 "elm", _signal_contract, it);
1626 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1628 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1630 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1632 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1634 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1636 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1638 _item_cache_clean(it->wd);
1639 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1640 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1644 _item_cache_find(Elm_Gen_Item *it)
1649 if (it->item->type & ELM_GENLIST_ITEM_TREE) tree = 1;
1650 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1652 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1654 if ((itc->tree == tree) &&
1655 (itc->compress == it->wd->compress) &&
1656 (((!it->itc->item_style) && (!itc->item_style)) ||
1657 (it->itc->item_style && itc->item_style &&
1658 (!strcmp(it->itc->item_style, itc->item_style)))))
1660 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1661 EINA_INLIST_GET(itc));
1662 it->wd->item_cache_count--;
1670 _elm_genlist_item_index_update(Elm_Gen_Item *it)
1672 if (it->position_update || it->item->block->position_update)
1674 evas_object_smart_callback_call(WIDGET(it), SIG_INDEX_UPDATE, it);
1675 it->position_update = EINA_FALSE;
1680 _elm_genlist_item_odd_even_update(Elm_Gen_Item *it)
1682 if (!it->item->nostacking)
1684 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
1686 if (it->edit_obj) evas_object_lower(it->edit_obj);
1687 else evas_object_lower(VIEW(it));
1691 if (it->edit_obj) evas_object_raise(it->edit_obj);
1692 else evas_object_raise(VIEW(it));
1696 if (it->item->order_num_in & 0x1)
1698 edje_object_signal_emit(VIEW(it), "elm,state,odd", "elm");
1699 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,odd", "elm");
1703 edje_object_signal_emit(VIEW(it), "elm,state,even", "elm");
1704 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,even", "elm");
1709 _elm_genlist_item_state_update(Elm_Gen_Item *it, Item_Cache *itc)
1713 if (it->selected != itc->selected)
1716 edje_object_signal_emit(VIEW(it),
1717 "elm,state,selected", "elm");
1720 edje_object_signal_emit(it->edit_obj,
1721 "elm,state,selected", "elm");
1723 if (elm_widget_item_disabled_get(it) != itc->disabled)
1725 if (elm_widget_item_disabled_get(it))
1726 edje_object_signal_emit(VIEW(it),
1727 "elm,state,disabled", "elm");
1729 edje_object_signal_emit(it->edit_obj,
1730 "elm,state,disabled", "elm");
1732 if (it->item->expanded != itc->expanded)
1734 if (it->item->expanded)
1735 edje_object_signal_emit(VIEW(it),
1736 "elm,state,expanded", "elm");
1738 edje_object_signal_emit(it->edit_obj,
1739 "elm,state,expanded", "elm");
1746 edje_object_signal_emit(VIEW(it),
1747 "elm,state,selected", "elm");
1749 edje_object_signal_emit(it->edit_obj,
1750 "elm,state,selected", "elm");
1753 if (elm_widget_item_disabled_get(it))
1755 edje_object_signal_emit(VIEW(it),
1756 "elm,state,disabled", "elm");
1758 edje_object_signal_emit(it->edit_obj,
1759 "elm,state,disabled", "elm");
1761 if (it->item->expanded)
1763 edje_object_signal_emit(VIEW(it),
1764 "elm,state,expanded", "elm");
1766 edje_object_signal_emit(it->edit_obj,
1767 "elm,state,expanded", "elm");
1773 _item_cache_free(Item_Cache *itc)
1775 if (itc->spacer) evas_object_del(itc->spacer);
1776 if (itc->base_view) evas_object_del(itc->base_view);
1777 eina_stringshare_del(itc->item_style);
1782 _item_text_realize(Elm_Gen_Item *it,
1783 Evas_Object *target,
1787 if (it->itc->func.text_get)
1792 *source = elm_widget_stringlist_get(edje_object_data_get(target, "texts"));
1793 EINA_LIST_FOREACH(*source, l, key)
1795 if (parts && fnmatch(parts, key, FNM_PERIOD))
1798 char *s = it->itc->func.text_get
1799 ((void *)it->base.data, WIDGET(it), key);
1803 edje_object_part_text_set(target, key, s);
1808 edje_object_part_text_set(target, key, "");
1815 _item_content_unrealize(Elm_Gen_Item *it,
1816 Evas_Object *target,
1820 Eina_List *res = it->content_objs;
1822 if (it->itc->func.content_get)
1826 Evas_Object *ic = NULL;
1828 EINA_LIST_FOREACH(*source, l, key)
1830 if (parts && fnmatch(parts, key, FNM_PERIOD))
1833 ic = edje_object_part_swallow_get(target, key);
1836 res = eina_list_remove(res, ic);
1837 edje_object_part_unswallow(target, ic);
1838 evas_object_del(ic);
1847 _item_content_realize(Elm_Gen_Item *it,
1848 Evas_Object *target,
1852 Eina_List *res = NULL;
1854 if (it->itc->func.content_get)
1858 Evas_Object *ic = NULL;
1860 *source = elm_widget_stringlist_get(edje_object_data_get(target, "contents"));
1862 if (parts && (eina_list_count(*source) != eina_list_count(it->content_objs)))
1863 res = it->content_objs;
1865 EINA_LIST_FOREACH(*source, l, key)
1867 if (parts && fnmatch(parts, key, FNM_PERIOD))
1870 if (it->itc->func.content_get)
1871 ic = it->itc->func.content_get
1872 ((void *)it->base.data, WIDGET(it), key);
1875 res = eina_list_append(res, ic);
1876 edje_object_part_swallow(target, key, ic);
1877 evas_object_show(ic);
1878 elm_widget_sub_object_add(WIDGET(it), ic);
1879 if (elm_widget_item_disabled_get(it))
1880 elm_widget_disabled_set(ic, EINA_TRUE);
1889 _item_state_realize(Elm_Gen_Item *it,
1890 Evas_Object *target,
1894 if (it->itc->func.state_get)
1900 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1901 EINA_LIST_FOREACH(*source, l, key)
1903 if (parts && fnmatch(parts, key, FNM_PERIOD))
1906 Eina_Bool on = it->itc->func.state_get
1907 ((void *)it->base.data, WIDGET(it), key);
1911 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1912 edje_object_signal_emit(target, buf, "elm");
1916 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1917 edje_object_signal_emit(target, buf, "elm");
1924 _item_flips_realize(Elm_Gen_Item *it,
1925 Evas_Object *target,
1928 Eina_List *res = NULL;
1930 if (it->itc->func.content_get)
1934 Evas_Object *ic = NULL;
1936 *source = elm_widget_stringlist_get(edje_object_data_get(target, "flips"));
1938 EINA_LIST_FOREACH(*source, l, key)
1940 if (it->itc->func.content_get)
1941 ic = it->itc->func.content_get
1942 ((void *)it->base.data, WIDGET(it), key);
1945 res = eina_list_append(res, ic);
1946 edje_object_part_swallow(target, key, ic);
1947 evas_object_show(ic);
1948 elm_widget_sub_object_add(WIDGET(it), ic);
1949 if (elm_widget_item_disabled_get(it))
1950 elm_widget_disabled_set(ic, EINA_TRUE);
1959 _item_realize(Elm_Gen_Item *it,
1963 const char *treesize;
1966 Item_Cache *itc = NULL;
1968 if (it->generation < it->wd->generation) return;
1969 //evas_event_freeze(evas_object_evas_get(it->wd->obj));
1972 if (it->item->order_num_in != in)
1974 it->item->order_num_in = in;
1975 _elm_genlist_item_odd_even_update(it);
1976 _elm_genlist_item_state_update(it, NULL);
1977 _elm_genlist_item_index_update(it);
1979 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1980 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1983 it->item->order_num_in = in;
1985 if (it->item->nocache_once)
1986 it->item->nocache_once = EINA_FALSE;
1987 else if (!it->item->nocache)
1988 itc = _item_cache_find(it);
1989 if (itc && (!it->wd->tree_effect_enabled))
1991 VIEW(it) = itc->base_view;
1992 itc->base_view = NULL;
1993 it->spacer = itc->spacer;
1998 const char *stacking_even;
1999 const char *stacking;
2001 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
2002 edje_object_scale_set(VIEW(it),
2003 elm_widget_scale_get(WIDGET(it)) *
2004 _elm_config->scale);
2005 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
2006 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
2008 if (it->item->type & ELM_GENLIST_ITEM_TREE)
2009 snprintf(buf, sizeof(buf), "tree%s/%s", it->wd->compress ? "_compress" : "", it->itc->item_style ?: "default");
2011 snprintf(buf, sizeof(buf), "item%s/%s", it->wd->compress ? "_compress" : "", it->itc->item_style ?: "default");
2013 _elm_theme_object_set(WIDGET(it), VIEW(it), "genlist", buf,
2014 elm_widget_style_get(WIDGET(it)));
2016 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
2017 if (!stacking_even) stacking_even = "above";
2018 it->item->stacking_even = !!strcmp("above", stacking_even);
2020 stacking = edje_object_data_get(VIEW(it), "stacking");
2021 if (!stacking) stacking = "yes";
2022 it->item->nostacking = !!strcmp("yes", stacking);
2024 edje_object_mirrored_set(VIEW(it),
2025 elm_widget_mirrored_get(WIDGET(it)));
2027 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
2028 evas_object_color_set(it->spacer, 0, 0, 0, 0);
2029 elm_widget_sub_object_add(WIDGET(it), it->spacer);
2032 _elm_genlist_item_odd_even_update(it);
2034 treesize = edje_object_data_get(VIEW(it), "treesize");
2035 if (treesize) tsize = atoi(treesize);
2036 evas_object_size_hint_min_set(it->spacer,
2037 (it->item->expanded_depth * tsize) * _elm_config->scale, 1);
2038 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
2041 edje_object_signal_callback_add(VIEW(it),
2042 "elm,action,expand,toggle",
2043 "elm", _signal_expand_toggle, it);
2044 edje_object_signal_callback_add(VIEW(it), "elm,action,expand",
2045 "elm", _signal_expand, it);
2046 edje_object_signal_callback_add(VIEW(it), "elm,action,contract",
2047 "elm", _signal_contract, it);
2048 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
2050 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
2052 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
2054 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_DOWN,
2056 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_UP,
2058 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_MOVE,
2061 if ((it->wd->edit_mode) && (!it->edit_obj) &&
2062 (it->item->type != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
2063 _edit_mode_item_realize(it, EINA_FALSE);
2065 _elm_genlist_item_state_update(it, itc);
2066 _elm_genlist_item_index_update(it);
2069 if ((calc) && (it->wd->homogeneous) &&
2070 ((it->wd->item_width) ||
2071 ((it->wd->item_width) && (it->wd->group_item_width))))
2073 /* homogenous genlist shortcut */
2074 if (!it->item->mincalcd)
2078 it->item->w = it->item->minw = it->wd->group_item_width;
2079 it->item->h = it->item->minh = it->wd->group_item_height;
2083 it->item->w = it->item->minw = it->wd->item_width;
2084 it->item->h = it->item->minh = it->wd->item_height;
2086 it->item->mincalcd = EINA_TRUE;
2091 /* FIXME: If you see that assert, please notify us and we
2092 will clean our mess */
2093 assert(eina_list_count(it->content_objs) == 0);
2095 _item_text_realize(it, VIEW(it), &it->texts, NULL);
2096 it->content_objs = _item_content_realize(it, VIEW(it), &it->contents, NULL);
2097 _item_state_realize(it, VIEW(it), &it->states, NULL);
2100 edje_object_signal_emit(VIEW(it), "elm,state,flip,enabled", "elm");
2101 it->content_objs = _item_flips_realize(it, VIEW(it), &it->contents);
2104 if (!it->item->mincalcd)
2106 Evas_Coord mw = -1, mh = -1;
2108 if (!it->display_only)
2109 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2110 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2111 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
2113 if (!it->display_only)
2114 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2115 it->item->w = it->item->minw = mw;
2116 it->item->h = it->item->minh = mh;
2117 it->item->mincalcd = EINA_TRUE;
2119 if ((!it->wd->group_item_width) && (it->group))
2121 it->wd->group_item_width = mw;
2122 it->wd->group_item_height = mh;
2124 else if ((!it->wd->item_width) && (it->item->type == ELM_GENLIST_ITEM_NONE))
2126 it->wd->item_width = mw;
2127 it->wd->item_height = mh;
2130 if (!calc) evas_object_show(VIEW(it));
2133 if (it->tooltip.content_cb)
2135 elm_widget_item_tooltip_content_cb_set(it,
2136 it->tooltip.content_cb,
2137 it->tooltip.data, NULL);
2138 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2139 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
2142 if (it->mouse_cursor)
2143 elm_widget_item_cursor_set(it, it->mouse_cursor);
2145 it->realized = EINA_TRUE;
2146 it->want_unrealize = EINA_FALSE;
2148 if (itc) _item_cache_free(itc);
2149 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
2150 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2152 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
2154 if ((!calc) && (it->wd->edit_mode) && (it->item->type != ELM_GENLIST_ITEM_GROUP))
2156 if (it->itc->edit_item_style)
2158 if (!it->edit_obj) _edit_mode_item_realize(it, EINA_FALSE);
2159 edje_object_message_signal_process(it->edit_obj);
2162 edje_object_message_signal_process(VIEW(it));
2166 _item_unrealize_cb(Elm_Gen_Item *it)
2168 if (it->item->nocache_once || it->item->nocache)
2170 evas_object_del(VIEW(it));
2172 evas_object_del(it->spacer);
2177 edje_object_mirrored_set(VIEW(it),
2178 elm_widget_mirrored_get(WIDGET(it)));
2179 edje_object_scale_set(VIEW(it),
2180 elm_widget_scale_get(WIDGET(it))
2181 * _elm_config->scale);
2182 _item_cache_add(it);
2185 _mode_item_unrealize(it);
2187 it->realized = EINA_FALSE;
2188 it->want_unrealize = EINA_FALSE;
2189 if (it->wd->edit_mode) _edit_mode_item_unrealize(it);
2193 _item_block_recalc(Item_Block *itb,
2199 Evas_Coord minw = 0, minh = 0;
2200 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2203 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2205 EINA_LIST_FOREACH(itb->items, l, it)
2207 if (it->generation < it->wd->generation) continue;
2208 showme |= it->item->showme;
2213 if (!it->item->mincalcd) changed = EINA_TRUE;
2216 _item_realize(it, in, EINA_TRUE);
2217 _elm_genlist_item_unrealize(it, EINA_TRUE);
2222 _item_realize(it, in, EINA_TRUE);
2223 _elm_genlist_item_unrealize(it, EINA_TRUE);
2227 _item_realize(it, in, EINA_FALSE);
2228 minh += it->item->minh;
2229 if (minw < it->item->minw) minw = it->item->minw;
2237 itb->changed = EINA_FALSE;
2238 itb->position_update = EINA_FALSE;
2239 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2240 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2245 _item_block_realize(Item_Block *itb)
2247 if (itb->realized) return;
2248 itb->realized = EINA_TRUE;
2249 itb->want_unrealize = EINA_FALSE;
2253 _item_block_unrealize(Item_Block *itb)
2257 Eina_Bool dragging = EINA_FALSE;
2259 if (!itb->realized) return;
2260 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2261 EINA_LIST_FOREACH(itb->items, l, it)
2263 if (itb->must_recalc || !it->group)
2267 dragging = EINA_TRUE;
2268 it->want_unrealize = EINA_TRUE;
2271 _elm_genlist_item_unrealize(it, EINA_FALSE);
2276 itb->realized = EINA_FALSE;
2277 itb->want_unrealize = EINA_TRUE;
2280 itb->want_unrealize = EINA_FALSE;
2281 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2282 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2286 _get_space_for_reorder_item(Elm_Gen_Item *it)
2288 Evas_Coord rox, roy, row, roh, oy, oh;
2289 Eina_Bool top = EINA_FALSE;
2290 Elm_Gen_Item *reorder_it = it->wd->reorder_it;
2291 if (!reorder_it) return 0;
2293 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2294 evas_object_geometry_get(it->wd->VIEW(reorder_it), &rox, &roy, &row, &roh);
2296 if ((it->wd->reorder_start_y < it->item->block->y) &&
2297 (roy - oy + (roh / 2) >= it->item->block->y - it->wd->pan_y))
2299 it->item->block->reorder_offset = it->wd->reorder_it->item->h * -1;
2300 if (it->item->block->count == 1)
2301 it->wd->reorder_rel = it;
2303 else if ((it->wd->reorder_start_y >= it->item->block->y) &&
2304 (roy - oy + (roh / 2) <= it->item->block->y - it->wd->pan_y))
2306 it->item->block->reorder_offset = it->wd->reorder_it->item->h;
2309 it->item->block->reorder_offset = 0;
2311 it->item->scrl_y += it->item->block->reorder_offset;
2313 top = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2314 rox, roy + (roh / 2), row, 1));
2317 it->wd->reorder_rel = it;
2318 it->item->scrl_y += it->wd->reorder_it->item->h;
2319 return it->wd->reorder_it->item->h;
2326 _reorder_move_animator_cb(void *data)
2328 Elm_Gen_Item *it = data;
2329 Eina_Bool down = EINA_FALSE;
2331 int y, dy = it->item->h / 10 * _elm_config->scale, diff;
2333 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2335 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2338 diff = abs(it->item->old_scrl_y - it->item->scrl_y);
2339 if (diff > it->item->h) y = diff / 2;
2341 if (it->item->old_scrl_y < it->item->scrl_y)
2343 it->item->old_scrl_y += y;
2346 else if (it->item->old_scrl_y > it->item->scrl_y)
2348 it->item->old_scrl_y -= y;
2353 _item_position(it, it->edit_obj, it->item->scrl_x, it->item->old_scrl_y);
2355 _item_position(it, VIEW(it), it->item->scrl_x, it->item->old_scrl_y);
2356 _group_items_recalc(it->wd);
2358 if ((it->wd->reorder_pan_move) ||
2359 (down && it->item->old_scrl_y >= it->item->scrl_y) ||
2360 (!down && it->item->old_scrl_y <= it->item->scrl_y))
2362 it->item->old_scrl_y = it->item->scrl_y;
2363 it->item->move_effect_enabled = EINA_FALSE;
2364 it->wd->reorder_move_animator = NULL;
2365 return ECORE_CALLBACK_CANCEL;
2367 return ECORE_CALLBACK_RENEW;
2371 _item_position(Elm_Gen_Item *it,
2379 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2380 evas_object_resize(view, it->item->w, it->item->h);
2381 evas_object_move(view, it_x, it_y);
2382 evas_object_show(view);
2383 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2384 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2388 _item_block_position(Item_Block *itb,
2394 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2395 Eina_Bool vis = EINA_FALSE;
2397 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2398 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2399 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2401 EINA_LIST_FOREACH(itb->items, l, it)
2403 if (it->generation < it->wd->generation) continue;
2404 else if (it->wd->reorder_it == it) continue;
2407 it->item->w = itb->w;
2408 it->item->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2409 it->item->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2411 vis = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2412 cvx, cvy, cvw, cvh));
2415 if ((itb->realized) && (!it->realized))
2417 if (vis) _item_realize(it, in, EINA_FALSE);
2421 if (vis || it->dragging)
2423 if (it->wd->reorder_mode)
2424 y += _get_space_for_reorder_item(it);
2425 git = it->item->group_item;
2428 if (git->item->scrl_y < oy)
2429 git->item->scrl_y = oy;
2430 if ((git->item->scrl_y + git->item->h) > (it->item->scrl_y + it->item->h))
2431 git->item->scrl_y = (it->item->scrl_y + it->item->h) - git->item->h;
2432 git->item->want_realize = EINA_TRUE;
2434 if ((it->wd->reorder_it) && (it->item->old_scrl_y != it->item->scrl_y))
2436 if (!it->item->move_effect_enabled)
2438 it->item->move_effect_enabled = EINA_TRUE;
2439 it->wd->reorder_move_animator =
2441 _reorder_move_animator_cb, it);
2444 if (!it->item->move_effect_enabled)
2446 if ((it->wd->edit_mode) && (it->itc->edit_item_style))
2447 _edit_mode_item_position(it, it->item->scrl_x,
2451 if (it->item->mode_view)
2452 _item_position(it, it->item->mode_view,
2456 _item_position(it, VIEW(it), it->item->scrl_x,
2459 it->item->old_scrl_y = it->item->scrl_y;
2464 if (!it->wd->item_moving_effect_timer)
2465 _elm_genlist_item_unrealize(it, EINA_FALSE);
2472 if (vis) it->item->want_realize = EINA_TRUE;
2476 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2477 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2481 _group_items_recalc(void *data)
2483 Widget_Data *wd = data;
2487 evas_event_freeze(evas_object_evas_get(wd->obj));
2488 EINA_LIST_FOREACH(wd->group_items, l, git)
2490 if (git->item->want_realize)
2493 _item_realize(git, 0, EINA_FALSE);
2494 evas_object_resize(VIEW(git), wd->minw, git->item->h);
2495 evas_object_move(VIEW(git), git->item->scrl_x, git->item->scrl_y);
2496 evas_object_show(VIEW(git));
2497 evas_object_raise(VIEW(git));
2499 else if (!git->item->want_realize && git->realized)
2502 _elm_genlist_item_unrealize(git, EINA_FALSE);
2505 evas_event_thaw(evas_object_evas_get(wd->obj));
2506 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2510 _must_recalc_idler(void *data)
2512 Widget_Data *wd = data;
2513 if (wd->calc_job) ecore_job_del(wd->calc_job);
2514 wd->calc_job = ecore_job_add(_calc_job, wd);
2515 wd->must_recalc_idler = NULL;
2516 return ECORE_CALLBACK_CANCEL;
2520 _scroll_item(Widget_Data *wd)
2522 Elm_Gen_Item *it = NULL;
2523 Evas_Coord gith = 0;
2524 Evas_Coord ow, oh, dx = 0, dy = 0, dw = 0, dh = 0;
2526 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
2528 dx = it->x + it->item->block->x;
2529 dy = it->y + it->item->block->y;
2530 dw = it->item->block->w;
2532 switch (wd->scrollto_type)
2534 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
2535 if (it->item->group_item) gith = it->item->group_item->item->h;
2538 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
2539 dy += (it->item->h / 2 - oh / 2);
2541 case ELM_GENLIST_ITEM_SCROLLTO_IN:
2543 if ((wd->expanded_item) &&
2544 ((wd->show_item->y + wd->show_item->item->block->y + wd->show_item->item->h)
2545 - (wd->expanded_item->y + wd->expanded_item->item->block->y) > oh))
2547 it = wd->expanded_item;
2548 if (it->item->group_item) gith = it->item->group_item->item->h;
2549 dx = it->x + it->item->block->x;
2550 dy = it->y + it->item->block->y - gith;
2551 dw = it->item->block->w;
2555 if ((it->item->group_item) && (wd->pan_y > (it->y + it->item->block->y)))
2556 gith = it->item->group_item->item->h;
2563 elm_smart_scroller_region_bring_in(wd->scr, dx, dy, dw, dh);
2565 elm_smart_scroller_child_region_show(wd->scr, dx, dy, dw, dh);
2567 it->item->showme = EINA_FALSE;
2568 wd->show_item = NULL;
2569 wd->auto_scroll_enabled = EINA_FALSE;
2570 wd->check_scroll = EINA_FALSE;
2574 _calc_job(void *data)
2576 Widget_Data *wd = data;
2577 Item_Block *itb, *chb = NULL;
2578 Evas_Coord minw = -1, minh = 0, y = 0, ow, dy = 0, vw;
2579 Evas_Coord pan_w = 0, pan_h = 0;
2581 Eina_Bool minw_change = EINA_FALSE;
2582 Eina_Bool did_must_recalc = EINA_FALSE;
2585 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2586 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, NULL);
2591 evas_event_freeze(evas_object_evas_get(wd->obj));
2592 EINA_INLIST_FOREACH(wd->blocks, itb)
2594 Eina_Bool showme = EINA_FALSE;
2597 showme = itb->showme;
2598 itb->showme = EINA_FALSE;
2601 if (itb->realized) _item_block_unrealize(itb);
2603 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2605 if (itb->must_recalc)
2609 EINA_LIST_FOREACH(itb->items, l, it)
2610 if (it->item->mincalcd) it->item->mincalcd = EINA_FALSE;
2611 itb->changed = EINA_TRUE;
2612 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2613 if (itb->realized) _item_block_unrealize(itb);
2614 itb->must_recalc = EINA_FALSE;
2616 showme = _item_block_recalc(itb, in, EINA_FALSE);
2622 if (minw == -1) minw = itb->minw;
2623 else if ((!itb->must_recalc) && (minw < itb->minw))
2626 minw_change = EINA_TRUE;
2631 minw_change = EINA_TRUE;
2637 if ((showme) && (wd->show_item) && (!wd->show_item->item->queued))
2638 wd->check_scroll = EINA_TRUE;
2642 EINA_INLIST_FOREACH(wd->blocks, itb)
2648 if ((chb) && (EINA_INLIST_GET(chb)->next))
2650 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2652 if (itb->realized) _item_block_unrealize(itb);
2655 wd->realminw = minw;
2656 if (minw < wd->w) minw = wd->w;
2657 if ((minw != wd->minw) || (minh != wd->minh))
2661 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2662 _sizing_eval(wd->obj);
2663 if ((wd->anchor_item) && (wd->anchor_item->item->block) && (!wd->auto_scroll_enabled))
2668 it = wd->anchor_item;
2669 it_y = wd->anchor_y;
2670 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2671 it->item->block->y + it->y + it_y);
2672 wd->anchor_item = it;
2673 wd->anchor_y = it_y;
2676 if (did_must_recalc)
2678 if (!wd->must_recalc_idler)
2679 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2681 if (wd->check_scroll)
2683 _pan_child_size_get(wd->pan_smart, &pan_w, &pan_h);
2684 if (EINA_INLIST_GET(wd->show_item) == wd->items->last)
2685 wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
2686 switch (wd->scrollto_type)
2688 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
2691 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
2694 case ELM_GENLIST_ITEM_SCROLLTO_IN:
2699 if ((pan_w > (wd->show_item->x + wd->show_item->item->block->x)) &&
2700 (pan_h > (wd->show_item->y + wd->show_item->item->block->y + dy)))
2705 wd->calc_job = NULL;
2706 evas_object_smart_changed(wd->pan_smart);
2707 evas_event_thaw(evas_object_evas_get(wd->obj));
2708 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2712 _update_job(void *data)
2714 Widget_Data *wd = data;
2718 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2720 wd->update_job = NULL;
2723 evas_event_freeze(evas_object_evas_get(wd->obj));
2724 EINA_INLIST_FOREACH(wd->blocks, itb)
2726 Evas_Coord itminw, itminh;
2733 _item_block_position(itb, num);
2737 recalc = EINA_FALSE;
2738 EINA_LIST_FOREACH(itb->items, l2, it)
2740 if (it->item->updateme)
2742 itminw = it->item->minw;
2743 itminh = it->item->minh;
2745 it->item->updateme = EINA_FALSE;
2748 _elm_genlist_item_unrealize(it, EINA_FALSE);
2749 _item_realize(it, num, EINA_FALSE);
2750 position = EINA_TRUE;
2754 _item_realize(it, num, EINA_TRUE);
2755 _elm_genlist_item_unrealize(it, EINA_TRUE);
2757 if ((it->item->minw != itminw) || (it->item->minh != itminh))
2762 itb->updateme = EINA_FALSE;
2765 position = EINA_TRUE;
2766 itb->changed = EINA_TRUE;
2767 _item_block_recalc(itb, num0, EINA_FALSE);
2768 _item_block_position(itb, num0);
2773 if (wd->calc_job) ecore_job_del(wd->calc_job);
2774 wd->calc_job = ecore_job_add(_calc_job, wd);
2776 evas_event_thaw(evas_object_evas_get(wd->obj));
2777 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2781 _pan_set(Evas_Object *obj,
2785 Pan *sd = evas_object_smart_data_get(obj);
2789 // Evas_Coord ow, oh;
2790 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2791 // ow = sd->wd->minw - ow;
2792 // if (ow < 0) ow = 0;
2793 // oh = sd->wd->minh - oh;
2794 // if (oh < 0) oh = 0;
2795 // if (x < 0) x = 0;
2796 // if (y < 0) y = 0;
2797 // if (x > ow) x = ow;
2798 // if (y > oh) y = oh;
2799 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2803 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2805 if ((itb->y + itb->h) > y)
2810 EINA_LIST_FOREACH(itb->items, l2, it)
2812 if ((itb->y + it->y) >= y)
2814 sd->wd->anchor_item = it;
2815 sd->wd->anchor_y = -(itb->y + it->y - y);
2822 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2826 _pan_get(Evas_Object *obj,
2830 Pan *sd = evas_object_smart_data_get(obj);
2833 if (x) *x = sd->wd->pan_x;
2834 if (y) *y = sd->wd->pan_y;
2838 _pan_max_get(Evas_Object *obj,
2842 Pan *sd = evas_object_smart_data_get(obj);
2846 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2847 ow = sd->wd->minw - ow;
2849 oh = sd->wd->minh - oh;
2856 _pan_min_get(Evas_Object *obj __UNUSED__,
2865 _pan_child_size_get(Evas_Object *obj,
2869 Pan *sd = evas_object_smart_data_get(obj);
2872 if (w) *w = sd->wd->minw;
2873 if (h) *h = sd->wd->minh;
2877 _pan_add(Evas_Object *obj)
2880 Evas_Object_Smart_Clipped_Data *cd;
2883 cd = evas_object_smart_data_get(obj);
2886 sd->__clipped_data = *cd;
2888 evas_object_smart_data_set(obj, sd);
2892 _pan_del(Evas_Object *obj)
2894 Pan *sd = evas_object_smart_data_get(obj);
2899 ecore_job_del(sd->resize_job);
2900 sd->resize_job = NULL;
2906 _pan_resize_job(void *data)
2910 _sizing_eval(sd->wd->obj);
2911 sd->resize_job = NULL;
2915 _pan_resize(Evas_Object *obj,
2919 Pan *sd = evas_object_smart_data_get(obj);
2923 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2924 if ((ow == w) && (oh == h)) return;
2925 if ((sd->wd->height_for_width) && (ow != w))
2928 if (sd->resize_job) ecore_job_del(sd->resize_job);
2929 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2931 sd->wd->pan_changed = EINA_TRUE;
2932 evas_object_smart_changed(obj);
2933 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2934 sd->wd->calc_job = NULL;
2936 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2937 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2942 _pan_calculate(Evas_Object *obj)
2944 Pan *sd = evas_object_smart_data_get(obj);
2946 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2952 evas_event_freeze(evas_object_evas_get(obj));
2954 if (sd->wd->pan_changed)
2957 sd->wd->pan_changed = EINA_FALSE;
2960 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2961 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2962 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2964 git->item->want_realize = EINA_FALSE;
2966 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2968 itb->w = sd->wd->minw;
2969 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2970 itb->y - sd->wd->pan_y + oy,
2972 cvx, cvy, cvw, cvh))
2974 if ((!itb->realized) || (itb->changed))
2975 _item_block_realize(itb);
2976 _item_block_position(itb, in);
2980 if (itb->realized) _item_block_unrealize(itb);
2984 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2985 _group_items_recalc(sd->wd);
2986 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2988 if (sd->wd->pan_y != sd->wd->reorder_old_pan_y)
2989 sd->wd->reorder_pan_move = EINA_TRUE;
2990 else sd->wd->reorder_pan_move = EINA_FALSE;
2991 evas_object_raise(sd->wd->VIEW(reorder_it));
2992 sd->wd->reorder_old_pan_y = sd->wd->pan_y;
2993 sd->wd->start_time = ecore_loop_time_get();
2996 if (sd->wd->tree_effect_enabled && (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_NONE))
2998 if (!sd->wd->item_moving_effect_timer)
3000 _item_tree_effect_before(sd->wd->expanded_item);
3001 evas_object_raise(sd->wd->alpha_bg);
3002 evas_object_show(sd->wd->alpha_bg);
3003 sd->wd->start_time = ecore_time_get();
3004 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
3008 _item_auto_scroll(sd->wd);
3010 evas_event_thaw(evas_object_evas_get(obj));
3011 evas_event_thaw_eval(evas_object_evas_get(obj));
3015 _pan_move(Evas_Object *obj,
3016 Evas_Coord x __UNUSED__,
3017 Evas_Coord y __UNUSED__)
3019 Pan *sd = evas_object_smart_data_get(obj);
3023 sd->wd->pan_changed = EINA_TRUE;
3024 evas_object_smart_changed(obj);
3025 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3026 sd->wd->calc_job = NULL;
3030 _hold_on(void *data __UNUSED__,
3032 void *event_info __UNUSED__)
3034 Widget_Data *wd = elm_widget_data_get(obj);
3036 elm_smart_scroller_hold_set(wd->scr, 1);
3040 _hold_off(void *data __UNUSED__,
3042 void *event_info __UNUSED__)
3044 Widget_Data *wd = elm_widget_data_get(obj);
3046 elm_smart_scroller_hold_set(wd->scr, 0);
3050 _freeze_on(void *data __UNUSED__,
3052 void *event_info __UNUSED__)
3054 Widget_Data *wd = elm_widget_data_get(obj);
3056 elm_smart_scroller_freeze_set(wd->scr, 1);
3060 _freeze_off(void *data __UNUSED__,
3062 void *event_info __UNUSED__)
3064 Widget_Data *wd = elm_widget_data_get(obj);
3066 elm_smart_scroller_freeze_set(wd->scr, 0);
3070 _scr_anim_start(void *data,
3071 Evas_Object *obj __UNUSED__,
3072 void *event_info __UNUSED__)
3074 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
3078 _scr_anim_stop(void *data,
3079 Evas_Object *obj __UNUSED__,
3080 void *event_info __UNUSED__)
3082 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
3086 _scr_drag_start(void *data,
3087 Evas_Object *obj __UNUSED__,
3088 void *event_info __UNUSED__)
3090 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
3094 _scr_drag_stop(void *data,
3095 Evas_Object *obj __UNUSED__,
3096 void *event_info __UNUSED__)
3098 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
3102 _edge_left(void *data,
3103 Evas_Object *scr __UNUSED__,
3104 void *event_info __UNUSED__)
3106 Evas_Object *obj = data;
3107 evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
3111 _edge_right(void *data,
3112 Evas_Object *scr __UNUSED__,
3113 void *event_info __UNUSED__)
3115 Evas_Object *obj = data;
3116 evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
3120 _edge_top(void *data,
3121 Evas_Object *scr __UNUSED__,
3122 void *event_info __UNUSED__)
3124 Evas_Object *obj = data;
3125 evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
3129 _edge_bottom(void *data,
3130 Evas_Object *scr __UNUSED__,
3131 void *event_info __UNUSED__)
3133 Evas_Object *obj = data;
3134 evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
3138 _mode_item_realize(Elm_Gen_Item *it)
3142 if ((it->item->mode_view) || (it->generation < it->wd->generation)) return;
3144 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3145 it->item->mode_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
3146 edje_object_scale_set(it->item->mode_view,
3147 elm_widget_scale_get(WIDGET(it)) *
3148 _elm_config->scale);
3149 evas_object_smart_member_add(it->item->mode_view, it->wd->pan_smart);
3150 elm_widget_sub_object_add(WIDGET(it), it->item->mode_view);
3152 strncpy(buf, "item", sizeof(buf));
3153 if (it->wd->compress)
3154 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3156 if (it->item->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3157 strncat(buf, "/", sizeof(buf) - strlen(buf));
3158 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3160 _elm_theme_object_set(WIDGET(it), it->item->mode_view, "genlist", buf,
3161 elm_widget_style_get(WIDGET(it)));
3162 edje_object_mirrored_set(it->item->mode_view,
3163 elm_widget_mirrored_get(WIDGET(it)));
3165 /* signal callback add */
3166 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3168 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_UP,
3170 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3173 /* text_get, content_get, state_get */
3174 /* FIXME: If you see that assert, please notify us and we
3175 will clean our mess */
3176 assert(eina_list_count(it->item->mode_content_objs) == 0);
3178 _item_text_realize(it, it->item->mode_view, &it->item->mode_texts, NULL);
3179 it->item->mode_content_objs =
3180 _item_content_realize(it, it->item->mode_view,
3181 &it->item->mode_contents, NULL);
3182 _item_state_realize(it, it->item->mode_view, &it->item->mode_states, NULL);
3184 edje_object_part_swallow(it->item->mode_view,
3185 edje_object_data_get(it->item->mode_view, "mode_part"),
3188 it->want_unrealize = EINA_FALSE;
3189 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3190 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3194 _mode_item_unrealize(Elm_Gen_Item *it)
3196 Widget_Data *wd = it->wd;
3197 Evas_Object *content;
3198 if (!it->item->mode_view) return;
3200 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3201 elm_widget_stringlist_free(it->item->mode_texts);
3202 it->item->mode_texts = NULL;
3203 elm_widget_stringlist_free(it->item->mode_contents);
3204 it->item->mode_contents = NULL;
3205 elm_widget_stringlist_free(it->item->mode_states);
3207 EINA_LIST_FREE(it->item->mode_content_objs, content)
3208 evas_object_del(content);
3210 edje_object_part_unswallow(it->item->mode_view, VIEW(it));
3211 evas_object_smart_member_add(VIEW(it), wd->pan_smart);
3212 evas_object_del(it->item->mode_view);
3213 it->item->mode_view = NULL;
3215 if (wd->mode_item == it)
3216 wd->mode_item = NULL;
3217 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3218 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3222 _item_mode_set(Elm_Gen_Item *it)
3225 Widget_Data *wd = it->wd;
3230 it->item->nocache_once = EINA_TRUE;
3232 if (wd->scr_hold_timer)
3234 ecore_timer_del(wd->scr_hold_timer);
3235 wd->scr_hold_timer = NULL;
3237 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3238 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3240 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3241 _mode_item_realize(it);
3242 if (it->item->group_item)
3243 evas_object_raise(it->item->VIEW(group_item));
3244 _item_position(it, it->item->mode_view, it->item->scrl_x, it->item->scrl_y);
3245 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3246 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3248 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3249 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3253 _item_mode_unset(Widget_Data *wd)
3256 if (!wd->mode_item) return;
3257 char buf[1024], buf2[1024];
3261 it->item->nocache_once = EINA_TRUE;
3263 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3264 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3266 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3267 edje_object_signal_callback_add(it->item->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3269 wd->mode_item = NULL;
3273 _edit_mode_item_position(Elm_Gen_Item *it, int itx, int ity)
3275 if ((!it) || (!it->wd->edit_mode)) return;
3276 evas_object_resize(it->edit_obj, it->item->w, it->item->h);
3277 evas_object_move(it->edit_obj, itx, ity);
3281 _edit_mode_item_realize(Elm_Gen_Item *it, Eina_Bool effect_on)
3284 const char *stacking_even;
3285 const char *stacking;
3287 if ((!it) || (it->item->edit_mode_item_realized) ||
3288 (it->generation < it->wd->generation))
3291 it->edit_obj = edje_object_add(evas_object_evas_get(WIDGET(it)));
3292 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(WIDGET(it)) *
3293 _elm_config->scale);
3294 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
3295 elm_widget_sub_object_add(WIDGET(it), it->edit_obj);
3297 if (it->item->type & ELM_GENLIST_ITEM_TREE)
3298 strncpy(buf, "tree", sizeof(buf));
3299 else strncpy(buf, "item", sizeof(buf));
3300 if (it->wd->compress)
3301 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3303 strncat(buf, "/", sizeof(buf) - strlen(buf));
3304 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
3306 _elm_theme_object_set(WIDGET(it), it->edit_obj, "genlist", buf,
3307 elm_widget_style_get(WIDGET(it)));
3309 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
3310 if (!stacking_even) stacking_even = "above";
3311 it->item->stacking_even = !!strcmp("above", stacking_even);
3313 stacking = edje_object_data_get(VIEW(it), "stacking");
3314 if (!stacking) stacking = "yes";
3315 it->item->nostacking = !!strcmp("yes", stacking);
3317 edje_object_mirrored_set(it->edit_obj,
3318 elm_widget_mirrored_get(WIDGET(it)));
3320 _elm_genlist_item_odd_even_update(it);
3321 _elm_genlist_item_state_update(it, NULL);
3323 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,edit,enabled,effect", "elm");
3324 else edje_object_signal_emit(it->edit_obj, "elm,state,edit,enabled", "elm");
3326 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
3328 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
3330 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
3332 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_DOWN,
3334 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_UP,
3336 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_MOVE,
3339 _item_text_realize(it, it->edit_obj, &it->item->edit_texts, NULL);
3340 if (it->flipped) edje_object_signal_emit(it->edit_obj, "elm,state,flip,enabled", "elm");
3341 it->item->edit_content_objs =
3342 _item_content_realize(it, it->edit_obj, &it->item->edit_contents, NULL);
3343 _item_state_realize(it, it->edit_obj, &it->item->edit_states, NULL);
3344 edje_object_part_swallow(it->edit_obj, "elm.swallow.edit.content", VIEW(it));
3346 _edit_mode_item_position(it, it->item->scrl_x, it->item->scrl_y);
3347 evas_object_show(it->edit_obj);
3349 it->item->edit_mode_item_realized = EINA_TRUE;
3350 it->want_unrealize = EINA_FALSE;
3354 _edit_mode_item_unrealize(Elm_Gen_Item *it)
3357 if ((!it) || (!it->item->edit_mode_item_realized)) return;
3359 edje_object_part_unswallow(it->edit_obj, VIEW(it));
3360 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
3361 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
3362 _elm_genlist_item_odd_even_update(it);
3363 _elm_genlist_item_state_update(it, NULL);
3365 evas_object_del(it->edit_obj);
3366 it->edit_obj = NULL;
3367 elm_widget_stringlist_free(it->item->edit_texts);
3368 it->item->edit_texts = NULL;
3369 elm_widget_stringlist_free(it->item->edit_contents);
3370 it->item->edit_contents = NULL;
3371 elm_widget_stringlist_free(it->item->edit_states);
3372 it->item->edit_states = NULL;
3373 EINA_LIST_FREE(it->item->edit_content_objs, icon)
3374 evas_object_del(icon);
3375 edje_object_message_signal_process(it->edit_obj);
3377 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
3379 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
3381 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
3383 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_DOWN,
3385 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_UP,
3387 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_MOVE,
3389 it->item->edit_mode_item_realized = EINA_FALSE;
3393 _item_auto_scroll(Widget_Data *wd)
3396 Elm_Gen_Item *tmp_item = NULL;
3398 if ((wd->expanded_item) && (wd->auto_scroll_enabled))
3400 tmp_item = eina_list_data_get(eina_list_last(wd->expanded_item->item->items));
3401 if (!tmp_item) return;
3402 wd->show_item = tmp_item;
3403 wd->bring_in = EINA_TRUE;
3404 wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
3405 if ((wd->show_item->item->queued) || (!wd->show_item->item->mincalcd))
3407 wd->show_item->item->showme = EINA_TRUE;
3408 wd->auto_scroll_enabled = EINA_FALSE;
3416 elm_genlist_add(Evas_Object *parent)
3421 Evas_Coord minw, minh;
3422 static Evas_Smart *smart = NULL;
3426 static Evas_Smart_Class sc;
3428 evas_object_smart_clipped_smart_set(&_pan_sc);
3430 sc.name = "elm_genlist_pan";
3431 sc.version = EVAS_SMART_CLASS_VERSION;
3434 sc.resize = _pan_resize;
3435 sc.move = _pan_move;
3436 sc.calculate = _pan_calculate;
3437 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3440 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3442 ELM_SET_WIDTYPE(widtype, "genlist");
3444 elm_widget_type_set(obj, "genlist");
3445 elm_widget_sub_object_add(parent, obj);
3446 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3447 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3448 elm_widget_data_set(obj, wd);
3449 elm_widget_del_hook_set(obj, _del_hook);
3450 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3451 elm_widget_theme_hook_set(obj, _theme_hook);
3452 elm_widget_can_focus_set(obj, EINA_TRUE);
3453 elm_widget_event_hook_set(obj, _event_hook);
3454 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3455 elm_widget_translate_hook_set(obj, _translate_hook);
3458 wd->scr = elm_smart_scroller_add(e);
3459 elm_smart_scroller_widget_set(wd->scr, obj);
3460 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3461 elm_widget_style_get(obj));
3462 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3463 _elm_config->thumbscroll_bounce_enable);
3464 elm_widget_resize_object_set(obj, wd->scr);
3466 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3467 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3468 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3469 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3470 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
3471 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
3472 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
3473 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
3476 wd->mode = ELM_LIST_SCROLL;
3477 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3478 wd->item_cache_max = wd->max_items_per_block * 2;
3479 wd->longpress_timeout = _elm_config->longpress_timeout;
3481 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3482 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3483 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3484 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3486 wd->pan_smart = evas_object_smart_add(e, smart);
3487 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3490 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3491 _pan_set, _pan_get, _pan_max_get,
3492 _pan_min_get, _pan_child_size_get);
3494 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3496 evas_object_size_hint_min_set(obj, minw, minh);
3498 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3500 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3506 _item_select(Elm_Gen_Item *it)
3508 if ((it->generation < it->wd->generation) || (it->mode_set) ||
3509 (it->wd->select_mode == ELM_OBJECT_NO_SELECT))
3513 it->selected = EINA_TRUE;
3514 it->wd->selected = eina_list_append(it->wd->selected, it);
3516 else if (it->wd->select_mode == ELM_OBJECT_ALWAYS_SELECT) return;
3518 evas_object_ref(WIDGET(it));
3521 if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), it);
3522 if (it->generation == it->wd->generation)
3523 evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
3526 evas_object_unref(WIDGET(it));
3527 if ((it->wd->clear_me) && (!it->wd->walking))
3528 _elm_genlist_clear(WIDGET(it), EINA_TRUE);
3531 if ((!it->walking) && (it->generation < it->wd->generation))
3536 elm_widget_item_free(it);
3540 it->wd->last_selected_item = (Elm_Object_Item *)it;
3544 static Evas_Object *
3545 _item_content_get_hook(Elm_Gen_Item *it, const char *part)
3547 return edje_object_part_swallow_get(VIEW(it), part);
3551 _item_content_set_hook(Elm_Gen_Item *it, const char *part, Evas_Object *content)
3553 if (content && part)
3555 it->content_objs = eina_list_append(it->content_objs, content);
3556 edje_object_part_swallow(VIEW(it), part, content);
3560 static Evas_Object *
3561 _item_content_unset_hook(Elm_Gen_Item *it, const char *part)
3564 obj = edje_object_part_swallow_get(VIEW(it), part);
3565 if (!obj) return NULL;
3566 it->content_objs = eina_list_remove(it->content_objs, obj);
3567 edje_object_part_unswallow(VIEW(it), obj);
3572 _item_text_hook(Elm_Gen_Item *it, const char *part)
3574 if (!it->itc->func.text_get) return NULL;
3575 return edje_object_part_text_get(VIEW(it), part);
3579 _item_disable_hook(Elm_Object_Item *it)
3583 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3585 if (_it->generation < _it->wd->generation) return;
3588 elm_genlist_item_selected_set(it, EINA_FALSE);
3592 if (elm_widget_item_disabled_get(it))
3594 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
3596 edje_object_signal_emit(_it->edit_obj, "elm,state,disabled", "elm");
3600 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
3602 edje_object_signal_emit(_it->edit_obj, "elm,state,enabled", "elm");
3604 EINA_LIST_FOREACH(_it->content_objs, l, obj)
3605 elm_widget_disabled_set(obj, elm_widget_item_disabled_get(_it));
3610 _item_del_pre_hook(Elm_Object_Item *it)
3612 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3614 if ((_it->relcount > 0) || (_it->walking > 0))
3616 elm_genlist_item_subitems_clear(it);
3617 if (_it->wd->show_item == _it) _it->wd->show_item = NULL;
3618 _elm_genlist_item_del_notserious(_it);
3619 if (_it->item->block)
3621 if (_it->realized) _elm_genlist_item_unrealize(_it, EINA_FALSE);
3622 _it->item->block->changed = EINA_TRUE;
3623 if (_it->wd->calc_job) ecore_job_del(_it->wd->calc_job);
3624 _it->wd->calc_job = ecore_job_add(_calc_job, _it->wd);
3628 _it->parent->item->items =
3629 eina_list_remove(_it->parent->item->items, it);
3639 _elm_genlist_item_new(Widget_Data *wd,
3640 const Elm_Gen_Item_Class *itc,
3642 Elm_Gen_Item *parent,
3644 const void *func_data)
3648 it = elm_widget_item_new(wd->obj, Elm_Gen_Item);
3649 if (!it) return NULL;
3651 it->generation = wd->generation;
3653 elm_genlist_item_class_ref((Elm_Genlist_Item_Class *)itc);
3654 it->base.data = data;
3655 it->parent = parent;
3656 it->func.func = func;
3657 it->func.data = func_data;
3658 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
3659 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
3660 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
3661 elm_widget_item_text_get_hook_set(it, _item_text_hook);
3662 elm_widget_item_disable_hook_set(it, _item_disable_hook);
3663 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
3665 it->sel_cb = (Ecore_Cb)_item_select;
3670 static Elm_Gen_Item *
3671 _item_new(Widget_Data *wd,
3672 const Elm_Genlist_Item_Class *itc,
3674 Elm_Gen_Item *parent,
3675 Elm_Genlist_Item_Type type,
3677 const void *func_data)
3679 Elm_Gen_Item *it, *it2;
3682 it = _elm_genlist_item_new(wd, itc, data, parent, func, func_data);
3683 if (!it) return NULL;
3684 it->item = ELM_NEW(Elm_Gen_Item_Type);
3685 it->item->type = type;
3686 if (type & ELM_GENLIST_ITEM_GROUP) it->group++;
3687 it->item->expanded_depth = 0;
3688 ELM_GEN_ITEM_SETUP(it);
3691 if (it->parent->group)
3692 it->item->group_item = parent;
3693 else if (it->parent->item->group_item)
3694 it->item->group_item = it->parent->item->group_item;
3696 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
3698 if (!it2->parent->group) depth += 1;
3700 it->item->expanded_depth = depth;
3706 _item_block_new(Widget_Data *wd, Eina_Bool prepend)
3710 itb = calloc(1, sizeof(Item_Block));
3711 if (!itb) return NULL;
3715 wd->blocks = eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3716 _item_block_position_update(wd->blocks, 0);
3720 wd->blocks = eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3721 itb->position_update = EINA_TRUE;
3722 if (wd->blocks != EINA_INLIST_GET(itb))
3724 itb->position = ((Item_Block *) (EINA_INLIST_GET(itb)->prev))->position + 1;
3735 _item_block_add(Widget_Data *wd,
3738 Item_Block *itb = NULL;
3745 itb = calloc(1, sizeof(Item_Block));
3746 if (!itb) return EINA_FALSE;
3748 if (!it->item->rel->item->block)
3751 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3752 itb->items = eina_list_append(itb->items, it);
3753 itb->position_update = EINA_TRUE;
3754 it->position = eina_list_count(itb->items);
3755 it->position_update = EINA_TRUE;
3757 if (wd->blocks != EINA_INLIST_GET(itb))
3759 itb->position = ((Item_Block *) (EINA_INLIST_GET(itb)->prev))->position + 1;
3770 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3771 if (it->item->before)
3773 wd->blocks = eina_inlist_prepend_relative
3774 (wd->blocks, EINA_INLIST_GET(itb),
3775 EINA_INLIST_GET(it->item->rel->item->block));
3777 eina_list_prepend_relative_list(itb->items, it, tmp);
3779 /* Update index from where we prepended */
3780 _item_position_update(eina_list_prev(tmp), it->item->rel->position);
3781 _item_block_position_update(EINA_INLIST_GET(itb),
3782 it->item->rel->item->block->position);
3786 wd->blocks = eina_inlist_append_relative
3787 (wd->blocks, EINA_INLIST_GET(itb),
3788 EINA_INLIST_GET(it->item->rel->item->block));
3790 eina_list_append_relative_list(itb->items, it, tmp);
3792 /* Update block index from where we appended */
3793 _item_position_update(eina_list_next(tmp), it->item->rel->position + 1);
3794 _item_block_position_update(EINA_INLIST_GET(itb),
3795 it->item->rel->item->block->position + 1);
3801 if (it->item->before)
3805 itb = (Item_Block *)(wd->blocks);
3806 if (itb->count >= wd->max_items_per_block)
3808 itb = _item_block_new(wd, EINA_TRUE);
3809 if (!itb) return EINA_FALSE;
3814 itb = _item_block_new(wd, EINA_TRUE);
3815 if (!itb) return EINA_FALSE;
3817 itb->items = eina_list_prepend(itb->items, it);
3819 _item_position_update(itb->items, 0);
3825 itb = (Item_Block *)(wd->blocks->last);
3826 if (itb->count >= wd->max_items_per_block)
3828 itb = _item_block_new(wd, EINA_FALSE);
3829 if (!itb) return EINA_FALSE;
3834 itb = _item_block_new(wd, EINA_FALSE);
3835 if (!itb) return EINA_FALSE;
3837 itb->items = eina_list_append(itb->items, it);
3838 it->position = eina_list_count(itb->items);
3846 if (it->item->rel->item->queued)
3848 /* NOTE: for a strange reason eina_list and eina_inlist don't have the same property
3849 on sorted insertion order, so the queue is not always ordered like the item list.
3850 This lead to issue where we depend on an item that is not yet created. As a quick
3851 work around, we reschedule the calc of the item and stop reordering the list to
3852 prevent any nasty issue to show up here.
3854 wd->queue = eina_list_append(wd->queue, it);
3855 wd->requeued = EINA_TRUE;
3856 it->item->queued = EINA_TRUE;
3859 itb = it->item->rel->item->block;
3860 if (!itb) goto newblock;
3861 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3862 if (it->item->before)
3864 itb->items = eina_list_prepend_relative_list(itb->items, it, tmp);
3865 _item_position_update(eina_list_prev(tmp), it->item->rel->position);
3869 itb->items = eina_list_append_relative_list(itb->items, it, tmp);
3870 _item_position_update(eina_list_next(tmp), it->item->rel->position + 1);
3874 itb->changed = EINA_TRUE;
3875 it->item->block = itb;
3876 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3877 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3880 it->item->rel->relcount--;
3881 if ((it->item->rel->generation < it->wd->generation) && (!it->item->rel->relcount))
3883 _item_del(it->item->rel);
3884 elm_widget_item_free(it->item->rel);
3886 it->item->rel = NULL;
3888 if (itb->count > itb->wd->max_items_per_block)
3893 Eina_Bool done = EINA_FALSE;
3895 newc = itb->count / 2;
3897 if (EINA_INLIST_GET(itb)->prev)
3899 Item_Block *itbp = (Item_Block *)(EINA_INLIST_GET(itb)->prev);
3901 if (itbp->count + newc < wd->max_items_per_block / 2)
3903 /* moving items to previous block */
3904 while ((itb->count > newc) && (itb->items))
3906 it2 = eina_list_data_get(itb->items);
3907 itb->items = eina_list_remove_list(itb->items, itb->items);
3910 itbp->items = eina_list_append(itbp->items, it2);
3911 it2->item->block = itbp;
3919 if (!done && EINA_INLIST_GET(itb)->next)
3921 Item_Block *itbn = (Item_Block *)(EINA_INLIST_GET(itb)->next);
3923 if (itbn->count + newc < wd->max_items_per_block / 2)
3925 /* moving items to next block */
3926 while ((itb->count > newc) && (itb->items))
3930 l = eina_list_last(itb->items);
3931 it2 = eina_list_data_get(l);
3932 itb->items = eina_list_remove_list(itb->items, l);
3935 itbn->items = eina_list_prepend(itbn->items, it2);
3936 it2->item->block = itbn;
3946 /* moving items to new block */
3947 itb2 = calloc(1, sizeof(Item_Block));
3948 if (!itb2) return EINA_FALSE;
3951 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3952 EINA_INLIST_GET(itb));
3953 itb2->changed = EINA_TRUE;
3954 while ((itb->count > newc) && (itb->items))
3958 l = eina_list_last(itb->items);
3960 itb->items = eina_list_remove_list(itb->items, l);
3963 itb2->items = eina_list_prepend(itb2->items, it2);
3964 it2->item->block = itb2;
3974 _queue_process(Widget_Data *wd)
3977 Eina_Bool showme = EINA_FALSE;
3980 t0 = ecore_loop_time_get();
3981 //evas_event_freeze(evas_object_evas_get(wd->obj));
3982 for (n = 0; (wd->queue) && (n < 128); n++)
3986 it = eina_list_data_get(wd->queue);
3987 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3988 it->item->queued = EINA_FALSE;
3989 if (!_item_block_add(wd, it)) continue;
3991 _item_block_realize(it->item->block);
3992 t = ecore_time_get();
3993 if (it->item->block->changed)
3995 showme = _item_block_recalc(it->item->block, it->item->block->num, EINA_TRUE);
3996 it->item->block->changed = 0;
3997 if (wd->pan_changed)
3999 if (wd->calc_job) ecore_job_del(wd->calc_job);
4000 wd->calc_job = NULL;
4002 wd->pan_changed = EINA_FALSE;
4005 if (showme) it->item->block->showme = EINA_TRUE;
4006 /* same as eina_inlist_count > 1 */
4007 if (wd->blocks && wd->blocks->next)
4009 if ((t - t0) > (ecore_animator_frametime_get())) break;
4012 //evas_event_thaw(evas_object_evas_get(wd->obj));
4013 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4018 _idle_process(void *data, Eina_Bool *wakeup)
4020 Widget_Data *wd = data;
4023 //static double q_start = 0.0;
4024 //if (q_start == 0.0) q_start = ecore_time_get();
4026 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
4030 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
4032 return ECORE_CALLBACK_CANCEL;
4034 return ECORE_CALLBACK_RENEW;
4038 _item_idle_enterer(void *data)
4040 Widget_Data *wd = data;
4041 Eina_Bool wakeup = EINA_FALSE;
4042 Eina_Bool ok = _idle_process(data, &wakeup);
4047 if (wd->calc_job) ecore_job_del(wd->calc_job);
4048 wd->calc_job = ecore_job_add(_calc_job, wd);
4050 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
4055 _item_queue(Widget_Data *wd,
4059 if (it->item->queued) return;
4060 it->item->queued = EINA_TRUE;
4061 if (cb && !wd->requeued)
4062 wd->queue = eina_list_sorted_insert(wd->queue, cb, it);
4064 wd->queue = eina_list_append(wd->queue, it);
4065 // FIXME: why does a freeze then thaw here cause some genlist
4066 // elm_genlist_item_append() to be much much slower?
4067 // evas_event_freeze(evas_object_evas_get(wd->obj));
4068 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
4070 if (wd->queue_idle_enterer)
4072 ecore_idle_enterer_del(wd->queue_idle_enterer);
4073 wd->queue_idle_enterer = NULL;
4077 // evas_event_thaw(evas_object_evas_get(wd->obj));
4078 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4079 if (!wd->queue_idle_enterer)
4080 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
4084 _elm_genlist_item_compare(const void *data, const void *data1)
4086 const Elm_Gen_Item *it, *item1;
4087 it = ELM_GEN_ITEM_FROM_INLIST(data);
4088 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
4089 return it->wd->item_compare_cb(it, item1);
4093 _elm_genlist_item_list_compare(const void *data, const void *data1)
4095 const Elm_Gen_Item *it = data;
4096 const Elm_Gen_Item *item1 = data1;
4097 return it->wd->item_compare_cb(it, item1);
4101 _item_move_after(Elm_Gen_Item *it, Elm_Gen_Item *after)
4106 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4107 _item_block_del(it);
4109 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
4110 it->item->rel = after;
4111 it->item->rel->relcount++;
4112 it->item->before = EINA_FALSE;
4113 if (after->item->group_item) it->item->group_item = after->item->group_item;
4114 _item_queue(it->wd, it, NULL);
4116 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
4120 _item_move_before(Elm_Gen_Item *it, Elm_Gen_Item *before)
4123 if (!before) return;
4125 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4126 _item_block_del(it);
4127 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
4128 it->item->rel = before;
4129 it->item->rel->relcount++;
4130 it->item->before = EINA_TRUE;
4131 if (before->item->group_item) it->item->group_item = before->item->group_item;
4132 _item_queue(it->wd, it, NULL);
4134 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
4138 elm_genlist_items_count(const Evas_Object *obj)
4140 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4141 Widget_Data *wd = elm_widget_data_get(obj);
4143 return wd->item_count;
4146 EAPI Elm_Object_Item *
4147 elm_genlist_item_append(Evas_Object *obj,
4148 const Elm_Genlist_Item_Class *itc,
4150 Elm_Object_Item *parent,
4151 Elm_Genlist_Item_Type type,
4153 const void *func_data)
4155 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4156 Widget_Data *wd = elm_widget_data_get(obj);
4157 if (!wd) return NULL;
4158 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4160 if (!it) return NULL;
4164 wd->group_items = eina_list_append(wd->group_items, it);
4165 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
4166 it->item->rel = NULL;
4170 Elm_Gen_Item *it2 = NULL;
4171 Eina_List *ll = eina_list_last(it->parent->item->items);
4172 if (ll) it2 = ll->data;
4173 it->parent->item->items = eina_list_append(it->parent->item->items, it);
4174 if (!it2) it2 = it->parent;
4176 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
4177 EINA_INLIST_GET(it2));
4178 it->item->rel = it2;
4179 it->item->rel->relcount++;
4181 it->item->before = EINA_FALSE;
4182 _item_queue(wd, it, NULL);
4183 return (Elm_Object_Item *)it;
4186 EAPI Elm_Object_Item *
4187 elm_genlist_item_prepend(Evas_Object *obj,
4188 const Elm_Genlist_Item_Class *itc,
4190 Elm_Object_Item *parent,
4191 Elm_Genlist_Item_Type type,
4193 const void *func_data)
4195 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4196 Widget_Data *wd = elm_widget_data_get(obj);
4197 if (!wd) return NULL;
4198 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4200 if (!it) return NULL;
4204 wd->group_items = eina_list_prepend(wd->group_items, it);
4205 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
4206 it->item->rel = NULL;
4210 Elm_Gen_Item *it2 = NULL;
4211 Eina_List *ll = it->parent->item->items;
4212 if (ll) it2 = ll->data;
4213 it->parent->item->items = eina_list_prepend(it->parent->item->items, it);
4214 if (!it2) it2 = it->parent;
4216 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4217 EINA_INLIST_GET(it2));
4218 it->item->rel = it2;
4219 it->item->rel->relcount++;
4221 it->item->before = EINA_TRUE;
4222 _item_queue(wd, it, NULL);
4223 return (Elm_Object_Item *)it;
4226 EAPI Elm_Object_Item *
4227 elm_genlist_item_insert_after(Evas_Object *obj,
4228 const Elm_Genlist_Item_Class *itc,
4230 Elm_Object_Item *parent,
4231 Elm_Object_Item *after,
4232 Elm_Genlist_Item_Type type,
4234 const void *func_data)
4236 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4237 ELM_OBJ_ITEM_CHECK_OR_RETURN(after, NULL);
4238 Widget_Data *wd = elm_widget_data_get(obj);
4239 Elm_Gen_Item *_after = (Elm_Gen_Item *) after;
4240 if (!wd) return NULL;
4241 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
4242 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4244 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4246 if (!it) return NULL;
4249 if ((it->group) && (_after->group))
4250 wd->group_items = eina_list_append_relative(wd->group_items, it,
4255 it->parent->item->items =
4256 eina_list_append_relative(it->parent->item->items, it, _after);
4258 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
4259 EINA_INLIST_GET(_after));
4260 it->item->rel = _after;
4261 it->item->rel->relcount++;
4262 it->item->before = EINA_FALSE;
4263 _item_queue(wd, it, NULL);
4264 return (Elm_Object_Item *)it;
4267 EAPI Elm_Object_Item *
4268 elm_genlist_item_insert_before(Evas_Object *obj,
4269 const Elm_Genlist_Item_Class *itc,
4271 Elm_Object_Item *parent,
4272 Elm_Object_Item *before,
4273 Elm_Genlist_Item_Type type,
4275 const void *func_data)
4277 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4278 ELM_OBJ_ITEM_CHECK_OR_RETURN(before, NULL);
4279 Widget_Data *wd = elm_widget_data_get(obj);
4280 Elm_Gen_Item *_before = (Elm_Gen_Item *) before;
4281 if (!wd) return NULL;
4282 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
4283 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4285 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4287 if (!it) return NULL;
4290 if (it->group && _before->group)
4291 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
4296 it->parent->item->items =
4297 eina_list_prepend_relative(it->parent->item->items, it, _before);
4299 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4300 EINA_INLIST_GET(_before));
4301 it->item->rel = _before;
4302 it->item->rel->relcount++;
4303 it->item->before = EINA_TRUE;
4304 _item_queue(wd, it, NULL);
4305 return (Elm_Object_Item *)it;
4308 EAPI Elm_Object_Item *
4309 elm_genlist_item_sorted_insert(Evas_Object *obj,
4310 const Elm_Genlist_Item_Class *itc,
4312 Elm_Object_Item *parent,
4313 Elm_Genlist_Item_Type type,
4314 Eina_Compare_Cb comp,
4316 const void *func_data)
4318 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4319 Widget_Data *wd = elm_widget_data_get(obj);
4320 if (!wd) return NULL;
4321 Elm_Gen_Item *rel = NULL;
4322 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4324 if (!it) return NULL;
4326 wd->item_compare_cb = comp;
4333 l = eina_list_search_sorted_near_list(it->parent->item->items,
4334 _elm_genlist_item_list_compare,
4338 rel = eina_list_data_get(l);
4342 if (cmp_result >= 0)
4344 it->parent->item->items = eina_list_prepend_relative_list(it->parent->item->items, it, l);
4345 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
4346 it->item->before = EINA_FALSE;
4348 else if (cmp_result < 0)
4350 it->parent->item->items = eina_list_append_relative_list(it->parent->item->items, it, l);
4351 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
4352 it->item->before = EINA_TRUE;
4359 wd->state = eina_inlist_sorted_state_new();
4360 eina_inlist_sorted_state_init(wd->state, wd->items);
4361 wd->requeued = EINA_FALSE;
4365 wd->group_items = eina_list_append(wd->group_items, it);
4367 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
4368 _elm_genlist_item_compare, wd->state);
4370 if (EINA_INLIST_GET(it)->next)
4372 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4373 it->item->before = EINA_TRUE;
4375 else if (EINA_INLIST_GET(it)->prev)
4377 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4378 it->item->before = EINA_FALSE;
4384 it->item->rel = rel;
4385 it->item->rel->relcount++;
4388 _item_queue(wd, it, _elm_genlist_item_list_compare);
4390 return (Elm_Object_Item *)it;
4394 _elm_genlist_clear(Evas_Object *obj, Eina_Bool standby)
4396 Eina_Inlist *next, *l;
4398 ELM_CHECK_WIDTYPE(obj, widtype);
4399 Widget_Data *wd = elm_widget_data_get(obj);
4402 if (!standby) wd->generation++;
4406 eina_inlist_sorted_state_free(wd->state);
4410 if (wd->walking > 0)
4412 wd->clear_me = EINA_TRUE;
4415 evas_event_freeze(evas_object_evas_get(wd->obj));
4416 for (l = wd->items, next = l ? l->next : NULL;
4418 l = next, next = next ? next->next : NULL)
4420 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(l);
4422 if (it->generation < wd->generation)
4424 Elm_Gen_Item *itn = NULL;
4426 if (next) itn = ELM_GEN_ITEM_FROM_INLIST(next);
4427 if (itn) itn->walking++; /* prevent early death of subitem */
4429 elm_widget_item_free(it);
4430 if (itn) itn->walking--;
4433 wd->clear_me = EINA_FALSE;
4434 wd->pan_changed = EINA_TRUE;
4437 ecore_job_del(wd->calc_job);
4438 wd->calc_job = NULL;
4440 if (wd->selected) wd->selected = eina_list_free(wd->selected);
4441 if (wd->clear_cb) wd->clear_cb(wd);
4447 if (wd->alpha_bg) evas_object_del(wd->alpha_bg);
4448 wd->alpha_bg = NULL;
4452 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4453 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4455 if (wd->sizing_cb) wd->sizing_cb(wd->obj);
4456 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
4457 evas_event_thaw(evas_object_evas_get(wd->obj));
4458 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4462 elm_genlist_clear(Evas_Object *obj)
4464 _elm_genlist_clear(obj, EINA_FALSE);
4468 elm_genlist_multi_select_set(Evas_Object *obj,
4471 ELM_CHECK_WIDTYPE(obj, widtype);
4472 Widget_Data *wd = elm_widget_data_get(obj);
4474 wd->multi = !!multi;
4478 elm_genlist_multi_select_get(const Evas_Object *obj)
4480 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4481 Widget_Data *wd = elm_widget_data_get(obj);
4482 if (!wd) return EINA_FALSE;
4486 EAPI Elm_Object_Item *
4487 elm_genlist_selected_item_get(const Evas_Object *obj)
4489 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4490 Widget_Data *wd = elm_widget_data_get(obj);
4491 if (!wd) return NULL;
4492 if (wd->selected) return wd->selected->data;
4496 EAPI const Eina_List *
4497 elm_genlist_selected_items_get(const Evas_Object *obj)
4499 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4500 Widget_Data *wd = elm_widget_data_get(obj);
4501 if (!wd) return NULL;
4502 return wd->selected;
4506 elm_genlist_realized_items_get(const Evas_Object *obj)
4508 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4509 Widget_Data *wd = elm_widget_data_get(obj);
4510 Eina_List *list = NULL;
4512 Eina_Bool done = EINA_FALSE;
4513 if (!wd) return NULL;
4514 EINA_INLIST_FOREACH(wd->blocks, itb)
4522 EINA_LIST_FOREACH(itb->items, l, it)
4524 if (it->realized) list = eina_list_append(list, it);
4535 EAPI Elm_Object_Item *
4536 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4541 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4542 Widget_Data *wd = elm_widget_data_get(obj);
4543 Evas_Coord ox, oy, ow, oh;
4546 if (!wd) return NULL;
4547 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4549 EINA_INLIST_FOREACH(wd->blocks, itb)
4554 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4555 oy + itb->y - itb->wd->pan_y,
4556 itb->w, itb->h, x, y, 1, 1))
4558 EINA_LIST_FOREACH(itb->items, l, it)
4560 Evas_Coord itx, ity;
4562 itx = ox + itb->x + it->x - itb->wd->pan_x;
4563 ity = oy + itb->y + it->y - itb->wd->pan_y;
4564 if (ELM_RECTS_INTERSECT(itx, ity, it->item->w, it->item->h, x, y, 1, 1))
4568 if (y <= (ity + (it->item->h / 4))) *posret = -1;
4569 else if (y >= (ity + it->item->h - (it->item->h / 4)))
4573 return (Elm_Object_Item *)it;
4575 lasty = ity + it->item->h;
4580 if (y > lasty) *posret = 1;
4586 EAPI Elm_Object_Item *
4587 elm_genlist_first_item_get(const Evas_Object *obj)
4589 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4590 Widget_Data *wd = elm_widget_data_get(obj);
4591 if (!wd) return NULL;
4592 if (!wd->items) return NULL;
4593 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
4594 while ((it) && (it->generation < wd->generation))
4595 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4596 return (Elm_Object_Item *)it;
4599 EAPI Elm_Object_Item *
4600 elm_genlist_last_item_get(const Evas_Object *obj)
4602 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4603 Widget_Data *wd = elm_widget_data_get(obj);
4604 if (!wd) return NULL;
4605 if (!wd->items) return NULL;
4606 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
4607 while ((it) && (it->generation < wd->generation))
4608 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4609 return (Elm_Object_Item *)it;
4612 EAPI Elm_Object_Item *
4613 elm_genlist_item_next_get(const Elm_Object_Item *it)
4615 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4616 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4619 _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->next);
4620 if ((_it) && (_it->generation == _it->wd->generation)) break;
4622 return (Elm_Object_Item *) _it;
4625 EAPI Elm_Object_Item *
4626 elm_genlist_item_prev_get(const Elm_Object_Item *it)
4628 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4629 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4632 _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->prev);
4633 if ((_it) && (_it->generation == _it->wd->generation)) break;
4635 return (Elm_Object_Item *) _it;
4638 EAPI Elm_Object_Item *
4639 elm_genlist_item_parent_get(const Elm_Object_Item *it)
4641 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4642 return (Elm_Object_Item *) ((Elm_Gen_Item *)it)->parent;
4646 elm_genlist_item_subitems_clear(Elm_Object_Item *it)
4648 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4649 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
4651 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4653 if (!wd->tree_effect_enabled || !wd->move_effect_mode)
4654 _item_subitems_clear(_it);
4657 if (!wd->item_moving_effect_timer)
4659 wd->expanded_item = _it;
4660 _item_tree_effect_before(_it);
4661 evas_object_raise(wd->alpha_bg);
4662 evas_object_show(wd->alpha_bg);
4663 wd->start_time = ecore_time_get();
4664 wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, wd);
4667 _item_subitems_clear(_it);
4672 elm_genlist_item_selected_set(Elm_Object_Item *it,
4675 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4676 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4677 Widget_Data *wd = _it->wd;
4679 if ((_it->generation < wd->generation) || elm_widget_item_disabled_get(_it))
4681 selected = !!selected;
4682 if (_it->selected == selected) return;
4688 while (wd->selected)
4690 if (_it->unhighlight_cb) _it->unhighlight_cb(wd->selected->data);
4691 _it->unsel_cb(wd->selected->data);
4694 _it->highlight_cb(_it);
4698 if (_it->unhighlight_cb) _it->unhighlight_cb(_it);
4703 elm_genlist_item_selected_get(const Elm_Object_Item *it)
4705 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4706 return ((Elm_Gen_Item *)it)->selected;
4710 _elm_genlist_expanded_next_item_get(Elm_Gen_Item *it)
4713 if (it->item->expanded)
4715 it2 = (Elm_Gen_Item *) elm_genlist_item_next_get((Elm_Object_Item *) it);
4719 it2 = (Elm_Gen_Item *) elm_genlist_item_next_get((Elm_Object_Item *) it);
4722 if (it->item->expanded_depth >= it2->item->expanded_depth) break;
4723 it2 = (Elm_Gen_Item *) elm_genlist_item_next_get((Elm_Object_Item *) it2);
4730 _elm_genlist_move_items_set(Elm_Gen_Item *it)
4733 Elm_Gen_Item *it2 = NULL;
4734 Evas_Coord ox, oy, ow, oh, dh = 0;
4736 it->wd->expanded_next_item = _elm_genlist_expanded_next_item_get(it);
4738 if (it->item->expanded)
4740 it->wd->move_items = elm_genlist_realized_items_get(it->wd->obj);
4741 EINA_LIST_FOREACH(it->wd->move_items, l, it2)
4743 if (it2 == it->wd->expanded_next_item) break;
4744 it->wd->move_items = eina_list_remove(it->wd->move_items, it2);
4749 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
4750 it2 = it->wd->expanded_next_item;
4751 while (it2 && (dh < oy + oh))
4754 it->wd->move_items = eina_list_append(it->wd->move_items, it2);
4755 it2 = (Elm_Gen_Item *) elm_genlist_item_next_get((Elm_Object_Item *) it2);
4761 elm_genlist_item_expanded_set(Elm_Object_Item *it,
4764 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4765 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4766 expanded = !!expanded;
4767 if (_it->item->expanded == expanded) return;
4768 _it->item->expanded = expanded;
4769 _it->wd->expanded_item = _it;
4770 _elm_genlist_move_items_set(_it);
4772 if (_it->wd->tree_effect_enabled && !_it->wd->alpha_bg)
4773 _it->wd->alpha_bg = _create_tray_alpha_bg(WIDGET(_it));
4775 if (_it->item->expanded)
4777 _it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4779 edje_object_signal_emit(VIEW(_it), "elm,state,expanded", "elm");
4780 evas_object_smart_callback_call(WIDGET(_it), SIG_EXPANDED, _it);
4781 _it->wd->auto_scroll_enabled = EINA_TRUE;
4785 _it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4787 edje_object_signal_emit(VIEW(_it), "elm,state,contracted", "elm");
4788 evas_object_smart_callback_call(WIDGET(_it), SIG_CONTRACTED, _it);
4789 _it->wd->auto_scroll_enabled = EINA_FALSE;
4794 elm_genlist_item_expanded_get(const Elm_Object_Item *it)
4796 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4797 return ((Elm_Gen_Item *)it)->item->expanded;
4801 elm_genlist_item_expanded_depth_get(const Elm_Object_Item *it)
4803 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, 0);
4804 return ((Elm_Gen_Item *)it)->item->expanded_depth;
4808 elm_genlist_item_display_only_set(Elm_Object_Item *it,
4809 Eina_Bool display_only)
4811 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4812 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4813 display_only = !!display_only;
4814 if (_it->display_only == display_only) return;
4815 if (_it->generation < _it->wd->generation) return;
4816 _it->display_only = display_only;
4817 _it->item->mincalcd = EINA_FALSE;
4818 _it->item->updateme = EINA_TRUE;
4819 if (_it->item->block) _it->item->block->updateme = EINA_TRUE;
4820 if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
4821 _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
4825 elm_genlist_item_display_only_get(const Elm_Object_Item *it)
4827 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4828 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4829 if (_it->generation < _it->wd->generation) return EINA_FALSE;
4830 return _it->display_only;
4833 static Eina_Bool _elm_genlist_item_compute_coordinates(
4834 Elm_Object_Item *it,
4835 Elm_Genlist_Item_Scrollto_Type type,
4841 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4842 Evas_Coord gith = 0;
4843 if (_it->generation < _it->wd->generation) return EINA_FALSE;
4844 if ((_it->item->queued) || (!_it->item->mincalcd))
4846 _it->wd->show_item = _it;
4847 _it->wd->bring_in = EINA_FALSE;
4848 _it->wd->scrollto_type = type;
4849 _it->item->showme = EINA_TRUE;
4852 if (_it->wd->show_item)
4854 _it->wd->show_item->item->showme = EINA_FALSE;
4855 _it->wd->show_item = NULL;
4858 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, w, h);
4859 if (type==ELM_GENLIST_ITEM_SCROLLTO_IN)
4861 if ((_it->item->group_item) &&
4862 (_it->wd->pan_y > (_it->y + _it->item->block->y)))
4863 gith = _it->item->group_item->item->h;
4866 *y = _it->y + _it->item->block->y - gith;
4868 else if (type==ELM_GENLIST_ITEM_SCROLLTO_TOP)
4870 if (_it->item->group_item) gith = _it->item->group_item->item->h;
4871 *y = _it->y + _it->item->block->y - gith;
4873 else if (type==ELM_GENLIST_ITEM_SCROLLTO_MIDDLE)
4875 *y = _it->y + _it->item->block->y - *h / 2 + _it->item->h / 2;
4880 *x = _it->x + _it->item->block->x;
4881 *w = _it->item->block->w;
4886 elm_genlist_item_promote(Elm_Object_Item *it)
4888 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4889 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4890 if (_it->generation < _it->wd->generation) return;
4891 _item_move_before(_it,
4892 (Elm_Gen_Item *) elm_genlist_first_item_get(WIDGET(_it)));
4896 elm_genlist_item_demote(Elm_Object_Item *it)
4898 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4899 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4900 if (_it->generation < _it->wd->generation) return;
4901 _item_move_after(_it,
4902 (Elm_Gen_Item *) elm_genlist_last_item_get(WIDGET(_it)));
4906 elm_genlist_item_show(Elm_Object_Item *it, Elm_Genlist_Item_Scrollto_Type type)
4908 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4909 Evas_Coord x, y, w, h;
4910 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4912 if (_elm_genlist_item_compute_coordinates(it, type, &x, &y, &w, &h))
4913 elm_smart_scroller_child_region_show(_it->wd->scr, x, y, w, h);
4917 elm_genlist_item_bring_in(Elm_Object_Item *it, Elm_Genlist_Item_Scrollto_Type type)
4920 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4921 Evas_Coord x, y, w, h;
4922 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4924 if (_elm_genlist_item_compute_coordinates(it, type, &x, &y, &w, &h))
4925 elm_smart_scroller_region_bring_in(_it->wd->scr,x, y, w, h);
4928 EINA_DEPRECATED EAPI void
4929 elm_genlist_item_top_show(Elm_Object_Item *it)
4931 elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_TOP);
4934 EINA_DEPRECATED EAPI void
4935 elm_genlist_item_top_bring_in(Elm_Object_Item *it)
4937 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_TOP);
4940 EINA_DEPRECATED EAPI void
4941 elm_genlist_item_middle_show(Elm_Object_Item *it)
4943 elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
4946 EINA_DEPRECATED EAPI void
4947 elm_genlist_item_middle_bring_in(Elm_Object_Item *it)
4949 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
4952 EINA_DEPRECATED EAPI void
4953 elm_genlist_item_contents_orphan(Elm_Object_Item *it)
4955 elm_genlist_item_all_contents_unset(it, NULL);
4959 elm_genlist_item_all_contents_unset(Elm_Object_Item *it, Eina_List **l)
4961 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4963 Evas_Object *content;
4964 EINA_LIST_FREE(((Elm_Gen_Item *)it)->content_objs, content)
4966 elm_widget_sub_object_del(WIDGET(it), content);
4967 evas_object_smart_member_del(content);
4968 evas_object_hide(content);
4970 *l = eina_list_append(*l, content);
4974 EINA_DEPRECATED EAPI const Evas_Object *
4975 elm_genlist_item_object_get(const Elm_Object_Item *it)
4977 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4982 elm_genlist_item_update(Elm_Object_Item *it)
4984 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4985 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4987 if (!_it->item->block) return;
4988 if (_it->generation < _it->wd->generation) return;
4989 _it->item->mincalcd = EINA_FALSE;
4990 _it->item->updateme = EINA_TRUE;
4991 _it->item->block->updateme = EINA_TRUE;
4992 if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
4993 _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
4997 elm_genlist_item_fields_update(Elm_Object_Item *it,
4999 Elm_Genlist_Item_Field_Type itf)
5001 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5002 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5004 if (!_it->item->block) return;
5005 if (_it->generation < _it->wd->generation) return;
5007 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_TEXT))
5008 _item_text_realize(_it, VIEW(_it), &_it->texts, parts);
5009 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_CONTENT))
5011 _it->content_objs = _item_content_unrealize(_it, VIEW(_it),
5012 &_it->contents, parts);
5013 _it->content_objs = _item_content_realize(_it, VIEW(_it),
5014 &_it->contents, parts);
5016 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
5017 _item_state_realize(_it, VIEW(_it), &_it->states, parts);
5021 elm_genlist_item_item_class_update(Elm_Object_Item *it,
5022 const Elm_Genlist_Item_Class *itc)
5024 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5025 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5027 if (!_it->item->block) return;
5028 EINA_SAFETY_ON_NULL_RETURN(itc);
5029 if (_it->generation < _it->wd->generation) return;
5031 _it->item->nocache_once = EINA_TRUE;
5032 elm_genlist_item_update(it);
5035 EAPI const Elm_Genlist_Item_Class *
5036 elm_genlist_item_item_class_get(const Elm_Object_Item *it)
5038 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
5039 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5040 if (_it->generation < _it->wd->generation) return NULL;
5044 static Evas_Object *
5045 _elm_genlist_item_label_create(void *data,
5046 Evas_Object *obj __UNUSED__,
5047 Evas_Object *tooltip,
5048 void *it __UNUSED__)
5050 Evas_Object *label = elm_label_add(tooltip);
5053 elm_object_style_set(label, "tooltip");
5054 elm_object_text_set(label, data);
5059 _elm_genlist_item_label_del_cb(void *data,
5060 Evas_Object *obj __UNUSED__,
5061 void *event_info __UNUSED__)
5063 eina_stringshare_del(data);
5067 elm_genlist_item_tooltip_text_set(Elm_Object_Item *it,
5070 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5071 text = eina_stringshare_add(text);
5072 elm_genlist_item_tooltip_content_cb_set(it, _elm_genlist_item_label_create,
5074 _elm_genlist_item_label_del_cb);
5078 elm_genlist_item_tooltip_content_cb_set(Elm_Object_Item *it,
5079 Elm_Tooltip_Item_Content_Cb func,
5081 Evas_Smart_Cb del_cb)
5083 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
5084 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5086 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
5089 if (_it->tooltip.del_cb)
5090 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(it), it);
5092 _it->tooltip.content_cb = func;
5093 _it->tooltip.data = data;
5094 _it->tooltip.del_cb = del_cb;
5098 elm_widget_item_tooltip_content_cb_set(_it,
5099 _it->tooltip.content_cb,
5100 _it->tooltip.data, NULL);
5101 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
5102 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
5108 if (del_cb) del_cb((void *)data, NULL, NULL);
5112 elm_genlist_item_tooltip_unset(Elm_Object_Item *it)
5114 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5115 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5117 if ((VIEW(_it)) && (_it->tooltip.content_cb))
5118 elm_widget_item_tooltip_unset(_it);
5120 if (_it->tooltip.del_cb)
5121 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
5122 _it->tooltip.del_cb = NULL;
5123 _it->tooltip.content_cb = NULL;
5124 _it->tooltip.data = NULL;
5125 _it->tooltip.free_size = EINA_FALSE;
5126 if (_it->tooltip.style)
5127 elm_genlist_item_tooltip_style_set(it, NULL);
5131 elm_genlist_item_tooltip_style_set(Elm_Object_Item *it,
5134 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5135 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5137 eina_stringshare_replace(&_it->tooltip.style, style);
5138 if (VIEW(_it)) elm_widget_item_tooltip_style_set(_it, style);
5142 elm_genlist_item_tooltip_style_get(const Elm_Object_Item *it)
5144 return elm_object_item_tooltip_style_get(it);
5148 elm_genlist_item_tooltip_window_mode_set(Elm_Object_Item *it,
5151 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
5152 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5154 _it->tooltip.free_size = disable;
5155 if (VIEW(_it)) return elm_widget_item_tooltip_window_mode_set(_it, disable);
5160 elm_genlist_item_tooltip_window_mode_get(const Elm_Object_Item *it)
5162 return elm_object_tooltip_window_mode_get(VIEW(it));
5166 elm_genlist_item_cursor_set(Elm_Object_Item *it,
5169 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5170 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5171 eina_stringshare_replace(&_it->mouse_cursor, cursor);
5172 if (VIEW(_it)) elm_widget_item_cursor_set(_it, cursor);
5176 elm_genlist_item_cursor_get(const Elm_Object_Item *it)
5178 return elm_widget_item_cursor_get(it);
5182 elm_genlist_item_cursor_unset(Elm_Object_Item *it)
5184 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5185 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5187 if (!_it->mouse_cursor) return;
5189 if (VIEW(_it)) elm_widget_item_cursor_unset(_it);
5191 eina_stringshare_del(_it->mouse_cursor);
5192 _it->mouse_cursor = NULL;
5196 elm_genlist_item_cursor_style_set(Elm_Object_Item *it,
5199 elm_widget_item_cursor_style_set(it, style);
5203 elm_genlist_item_cursor_style_get(const Elm_Object_Item *it)
5205 return elm_widget_item_cursor_style_get(it);
5209 elm_genlist_item_cursor_engine_only_set(Elm_Object_Item *it,
5210 Eina_Bool engine_only)
5212 elm_widget_item_cursor_engine_only_set(it, engine_only);
5216 elm_genlist_item_cursor_engine_only_get(const Elm_Object_Item *it)
5218 return elm_widget_item_cursor_engine_only_get(it);
5222 elm_genlist_item_index_get(const Elm_Object_Item *it)
5224 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, -1);
5225 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5227 if (_it->item->block)
5228 return _it->position + _it->item->block->position;
5233 elm_genlist_mode_set(Evas_Object *obj,
5236 ELM_CHECK_WIDTYPE(obj, widtype);
5237 Widget_Data *wd = elm_widget_data_get(obj);
5239 if (wd->mode == mode) return;
5246 elm_genlist_mode_get(const Evas_Object *obj)
5248 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5249 Widget_Data *wd = elm_widget_data_get(obj);
5250 if (!wd) return ELM_LIST_LAST;
5254 EINA_DEPRECATED EAPI void
5255 elm_genlist_always_select_mode_set(Evas_Object *obj,
5256 Eina_Bool always_select)
5258 ELM_CHECK_WIDTYPE(obj, widtype);
5259 Widget_Data *wd = elm_widget_data_get(obj);
5262 elm_genlist_select_mode_set(obj, ELM_OBJECT_ALWAYS_SELECT);
5265 Elm_Object_Select_Mode_Type oldmode = elm_genlist_select_mode_get(obj);
5266 if (oldmode == ELM_OBJECT_ALWAYS_SELECT)
5267 elm_genlist_select_mode_set(obj, ELM_OBJECT_NORMAL_SELECT);
5271 EINA_DEPRECATED EAPI Eina_Bool
5272 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5274 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5275 Widget_Data *wd = elm_widget_data_get(obj);
5276 if (!wd) return EINA_FALSE;
5277 Elm_Object_Select_Mode_Type oldmode = elm_genlist_select_mode_get(obj);
5278 if (oldmode == ELM_OBJECT_ALWAYS_SELECT)
5283 EINA_DEPRECATED EAPI void
5284 elm_genlist_no_select_mode_set(Evas_Object *obj,
5285 Eina_Bool no_select)
5287 ELM_CHECK_WIDTYPE(obj, widtype);
5288 Widget_Data *wd = elm_widget_data_get(obj);
5291 elm_genlist_select_mode_set(obj, ELM_OBJECT_NO_SELECT);
5294 Elm_Object_Select_Mode_Type oldmode = elm_genlist_select_mode_get(obj);
5295 if (oldmode == ELM_OBJECT_NO_SELECT)
5296 elm_genlist_select_mode_set(obj, ELM_OBJECT_NORMAL_SELECT);
5300 EINA_DEPRECATED EAPI Eina_Bool
5301 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5303 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5304 Widget_Data *wd = elm_widget_data_get(obj);
5305 if (!wd) return EINA_FALSE;
5306 Elm_Object_Select_Mode_Type oldmode = elm_genlist_select_mode_get(obj);
5307 if (oldmode == ELM_OBJECT_NO_SELECT)
5313 elm_genlist_compress_mode_set(Evas_Object *obj,
5316 ELM_CHECK_WIDTYPE(obj, widtype);
5317 Widget_Data *wd = elm_widget_data_get(obj);
5319 wd->compress = !!compress;
5320 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
5324 elm_genlist_compress_mode_get(const Evas_Object *obj)
5326 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5327 Widget_Data *wd = elm_widget_data_get(obj);
5328 if (!wd) return EINA_FALSE;
5329 return wd->compress;
5333 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5334 Eina_Bool height_for_width)
5336 ELM_CHECK_WIDTYPE(obj, widtype);
5337 Widget_Data *wd = elm_widget_data_get(obj);
5339 wd->height_for_width = !!height_for_width;
5340 if (wd->height_for_width)
5342 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5343 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5348 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5350 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5351 Widget_Data *wd = elm_widget_data_get(obj);
5352 if (!wd) return EINA_FALSE;
5353 return wd->height_for_width;
5357 elm_genlist_bounce_set(Evas_Object *obj,
5361 ELM_CHECK_WIDTYPE(obj, widtype);
5362 Widget_Data *wd = elm_widget_data_get(obj);
5364 wd->h_bounce = !!h_bounce;
5365 wd->v_bounce = !!v_bounce;
5366 elm_smart_scroller_bounce_allow_set(wd->scr, wd->h_bounce, wd->v_bounce);
5370 elm_genlist_bounce_get(const Evas_Object *obj,
5371 Eina_Bool *h_bounce,
5372 Eina_Bool *v_bounce)
5374 ELM_CHECK_WIDTYPE(obj, widtype);
5375 Widget_Data *wd = elm_widget_data_get(obj);
5377 if (h_bounce) *h_bounce = wd->h_bounce;
5378 if (v_bounce) *v_bounce = wd->v_bounce;
5382 elm_genlist_homogeneous_set(Evas_Object *obj,
5383 Eina_Bool homogeneous)
5385 ELM_CHECK_WIDTYPE(obj, widtype);
5386 Widget_Data *wd = elm_widget_data_get(obj);
5388 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5389 wd->homogeneous = !!homogeneous;
5393 elm_genlist_homogeneous_get(const Evas_Object *obj)
5395 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5396 Widget_Data *wd = elm_widget_data_get(obj);
5397 if (!wd) return EINA_FALSE;
5398 return wd->homogeneous;
5402 elm_genlist_block_count_set(Evas_Object *obj,
5405 ELM_CHECK_WIDTYPE(obj, widtype);
5406 Widget_Data *wd = elm_widget_data_get(obj);
5408 wd->max_items_per_block = count;
5409 wd->item_cache_max = wd->max_items_per_block * 2;
5410 _item_cache_clean(wd);
5414 elm_genlist_block_count_get(const Evas_Object *obj)
5416 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5417 Widget_Data *wd = elm_widget_data_get(obj);
5419 return wd->max_items_per_block;
5423 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5426 ELM_CHECK_WIDTYPE(obj, widtype);
5427 Widget_Data *wd = elm_widget_data_get(obj);
5429 wd->longpress_timeout = timeout;
5433 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5435 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5436 Widget_Data *wd = elm_widget_data_get(obj);
5438 return wd->longpress_timeout;
5442 elm_genlist_scroller_policy_set(Evas_Object *obj,
5443 Elm_Scroller_Policy policy_h,
5444 Elm_Scroller_Policy policy_v)
5446 ELM_CHECK_WIDTYPE(obj, widtype);
5447 Widget_Data *wd = elm_widget_data_get(obj);
5448 if ((!wd) || (!wd->scr)) return;
5449 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5450 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5452 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5456 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5457 Elm_Scroller_Policy *policy_h,
5458 Elm_Scroller_Policy *policy_v)
5460 ELM_CHECK_WIDTYPE(obj, widtype);
5461 Widget_Data *wd = elm_widget_data_get(obj);
5462 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5463 if ((!wd) || (!wd->scr)) return;
5464 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5465 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5466 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5470 elm_genlist_realized_items_update(Evas_Object *obj)
5472 ELM_CHECK_WIDTYPE(obj, widtype);
5474 Eina_List *list, *l;
5475 Elm_Object_Item *it;
5477 list = elm_genlist_realized_items_get(obj);
5478 EINA_LIST_FOREACH(list, l, it)
5479 elm_genlist_item_update(it);
5483 elm_genlist_item_mode_set(Elm_Object_Item *it,
5484 const char *mode_type,
5487 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5488 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5490 Widget_Data *wd = _it->wd;
5492 Elm_Object_Item *it2;
5495 if (!mode_type) return;
5496 if ((_it->generation < _it->wd->generation) ||
5497 elm_widget_item_disabled_get(_it)) return;
5498 if (wd->edit_mode) return;
5500 if ((wd->mode_item == _it) &&
5501 (!strcmp(mode_type, wd->mode_type)) &&
5504 if (!_it->itc->mode_item_style) return;
5505 _it->mode_set = mode_set;
5509 EINA_LIST_FOREACH(wd->selected, l, it2)
5510 if (((Elm_Gen_Item *)it2)->realized)
5511 elm_genlist_item_selected_set(it2, EINA_FALSE);
5515 it2 = elm_genlist_selected_item_get(wd->obj);
5516 if ((it2) && (((Elm_Gen_Item *)it2)->realized))
5517 elm_genlist_item_selected_set(it2, EINA_FALSE);
5520 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5522 ((_it == wd->mode_item) && (!mode_set)))
5523 _item_mode_unset(wd);
5525 eina_stringshare_replace(&wd->mode_type, mode_type);
5526 if (mode_set) _item_mode_set(_it);
5530 elm_genlist_mode_type_get(const Evas_Object *obj)
5532 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5533 Widget_Data *wd = elm_widget_data_get(obj);
5534 if (!wd) return NULL;
5535 return wd->mode_type;
5538 EAPI const Elm_Object_Item *
5539 elm_genlist_mode_item_get(const Evas_Object *obj)
5541 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5542 Widget_Data *wd = elm_widget_data_get(obj);
5543 if (!wd) return NULL;
5544 return (Elm_Object_Item *) wd->mode_item;
5548 elm_genlist_edit_mode_get(const Evas_Object *obj)
5550 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5551 Widget_Data *wd = elm_widget_data_get(obj);
5552 if (!wd) return EINA_FALSE;
5554 return wd->edit_mode;
5558 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5560 ELM_CHECK_WIDTYPE(obj, widtype);
5561 Eina_List *list, *l;
5564 Widget_Data *wd = elm_widget_data_get(obj);
5566 edit_mode = !!edit_mode;
5567 if (wd->edit_mode == edit_mode) return;
5568 wd->edit_mode = edit_mode;
5570 list = elm_genlist_realized_items_get(obj);
5573 EINA_LIST_FOREACH(list, l, it)
5575 if (it->item->type != ELM_GENLIST_ITEM_GROUP)
5576 _edit_mode_item_unrealize(it);
5578 _item_cache_zero(wd);
5582 EINA_LIST_FOREACH(list, l, it)
5584 if (it->item->type != ELM_GENLIST_ITEM_GROUP)
5586 if (it->selected) _item_unselect(it);
5587 if (it->itc->edit_item_style)
5588 _edit_mode_item_realize(it, EINA_TRUE);
5592 if (wd->calc_job) ecore_job_del(wd->calc_job);
5593 wd->calc_job = ecore_job_add(_calc_job, wd);
5597 elm_genlist_reorder_mode_set(Evas_Object *obj,
5598 Eina_Bool reorder_mode)
5600 ELM_CHECK_WIDTYPE(obj, widtype);
5601 Widget_Data *wd = elm_widget_data_get(obj);
5603 wd->reorder_mode = !!reorder_mode;
5607 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5609 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5610 Widget_Data *wd = elm_widget_data_get(obj);
5611 if (!wd) return EINA_FALSE;
5612 return wd->reorder_mode;
5615 EAPI Elm_Genlist_Item_Type
5616 elm_genlist_item_type_get(const Elm_Object_Item *it)
5618 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ELM_GENLIST_ITEM_MAX);
5619 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5620 return _it->item->type;
5623 EINA_DEPRECATED EAPI Elm_Genlist_Item_Type
5624 elm_genlist_item_flags_get(const Elm_Object_Item *it)
5626 return elm_genlist_item_type_get(it);
5629 EAPI Elm_Genlist_Item_Class *
5630 elm_genlist_item_class_new(void)
5632 Elm_Genlist_Item_Class *itc;
5634 itc = calloc(1, sizeof(Elm_Genlist_Item_Class));
5637 itc->version = CLASS_ALLOCATED;
5639 itc->delete_me = EINA_FALSE;
5645 elm_genlist_item_class_free(Elm_Genlist_Item_Class *itc)
5647 if (itc && (itc->version == CLASS_ALLOCATED))
5649 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
5650 if (itc->refcount > 0) elm_genlist_item_class_unref(itc);
5660 elm_genlist_item_class_ref(Elm_Genlist_Item_Class *itc)
5662 if (itc && (itc->version == CLASS_ALLOCATED))
5665 if (itc->refcount == 0) itc->refcount--;
5670 elm_genlist_item_class_unref(Elm_Genlist_Item_Class *itc)
5672 if (itc && (itc->version == CLASS_ALLOCATED))
5674 if (itc->refcount > 0) itc->refcount--;
5675 if (itc->delete_me && (!itc->refcount))
5676 elm_genlist_item_class_free(itc);
5680 void _flip_job(void *data)
5682 Elm_Gen_Item *it = (Elm_Gen_Item *) data;
5683 _elm_genlist_item_unrealize(it, EINA_FALSE);
5684 if (it->selected) _item_unselect(it);
5685 it->flipped = EINA_TRUE;
5686 it->item->nocache = EINA_TRUE;
5690 elm_genlist_item_flip_set(Elm_Object_Item *it,
5693 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5694 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5697 if (_it->flipped == flip) return;
5701 ecore_job_add(_flip_job, _it);
5702 if (_it->wd->calc_job) ecore_job_del(_it->wd->calc_job);
5703 _it->wd->calc_job = ecore_job_add(_calc_job, _it->wd);
5707 _it->flipped = flip;
5708 _item_cache_zero(_it->wd);
5709 elm_genlist_item_update(it);
5710 _it->item->nocache = EINA_FALSE;
5715 elm_genlist_item_flip_get(const Elm_Object_Item *it)
5717 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
5718 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5719 return _it->flipped;
5723 elm_genlist_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode_Type mode)
5725 ELM_CHECK_WIDTYPE(obj, widtype);
5726 Widget_Data *wd = elm_widget_data_get(obj);
5728 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
5730 if (wd->select_mode != mode)
5731 wd->select_mode = mode;
5734 EAPI Elm_Object_Select_Mode_Type
5735 elm_genlist_select_mode_get(const Evas_Object *obj)
5737 ELM_CHECK_WIDTYPE(obj, widtype) ELM_OBJECT_SELECT_MODE_MAX;
5738 Widget_Data *wd = elm_widget_data_get(obj);
5739 if (!wd) return ELM_OBJECT_SELECT_MODE_MAX;
5740 return wd->select_mode;
5744 elm_genlist_hilight_mode_set(Evas_Object *obj,
5747 ELM_CHECK_WIDTYPE(obj, widtype);
5748 Widget_Data *wd = elm_widget_data_get(obj);
5750 hilight = !!hilight;
5751 wd->no_highlight = !hilight;
5755 elm_genlist_hilight_mode_get(const Evas_Object *obj)
5757 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5758 Widget_Data *wd = elm_widget_data_get(obj);
5759 if (!wd) return EINA_FALSE;
5760 return !wd->no_highlight;
5763 /* for gengrid as of now */
5765 _elm_genlist_page_relative_set(Evas_Object *obj,
5769 Evas_Coord pagesize_h;
5770 Evas_Coord pagesize_v;
5772 ELM_CHECK_WIDTYPE(obj, widtype);
5773 Widget_Data *wd = elm_widget_data_get(obj);
5776 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
5777 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
5781 /* for gengrid as of now */
5783 _elm_genlist_page_relative_get(const Evas_Object *obj,
5787 ELM_CHECK_WIDTYPE(obj, widtype);
5788 Widget_Data *wd = elm_widget_data_get(obj);
5791 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
5794 /* for gengrid as of now */
5796 _elm_genlist_page_size_set(Evas_Object *obj,
5797 Evas_Coord h_pagesize,
5798 Evas_Coord v_pagesize)
5803 ELM_CHECK_WIDTYPE(obj, widtype);
5804 Widget_Data *wd = elm_widget_data_get(obj);
5806 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
5807 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
5811 /* for gengrid as of now */
5813 _elm_genlist_current_page_get(const Evas_Object *obj,
5817 ELM_CHECK_WIDTYPE(obj, widtype);
5818 Widget_Data *wd = elm_widget_data_get(obj);
5820 elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber);
5823 /* for gengrid as of now */
5825 _elm_genlist_last_page_get(const Evas_Object *obj,
5829 ELM_CHECK_WIDTYPE(obj, widtype);
5830 Widget_Data *wd = elm_widget_data_get(obj);
5832 elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber);
5835 /* for gengrid as of now */
5837 _elm_genlist_page_show(const Evas_Object *obj,
5841 ELM_CHECK_WIDTYPE(obj, widtype);
5842 Widget_Data *wd = elm_widget_data_get(obj);
5844 elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber);
5847 /* for gengrid as of now */
5849 _elm_genlist_page_bring_in(const Evas_Object *obj,
5853 ELM_CHECK_WIDTYPE(obj, widtype);
5854 Widget_Data *wd = elm_widget_data_get(obj);
5856 elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber);
5860 _elm_genlist_item_unrealize(Elm_Gen_Item *it,
5863 Evas_Object *content;
5865 if (!it->realized) return;
5866 if (it->wd->reorder_it == it) return;
5868 evas_event_freeze(evas_object_evas_get(WIDGET(it)));
5870 evas_object_smart_callback_call(WIDGET(it), SIG_UNREALIZED, it);
5873 ecore_timer_del(it->long_timer);
5874 it->long_timer = NULL;
5877 elm_widget_stringlist_free(it->texts);
5879 elm_widget_stringlist_free(it->contents);
5880 it->contents = NULL;
5881 elm_widget_stringlist_free(it->states);
5884 EINA_LIST_FREE(it->content_objs, content)
5885 evas_object_del(content);
5887 it->unrealize_cb(it);
5889 it->realized = EINA_FALSE;
5890 it->want_unrealize = EINA_FALSE;
5891 evas_event_thaw(evas_object_evas_get(WIDGET(it)));
5892 evas_event_thaw_eval(evas_object_evas_get(WIDGET(it)));
5896 _elm_genlist_item_del_notserious(Elm_Gen_Item *it)
5898 elm_widget_item_pre_notify_del(it);
5899 it->generation = it->wd->generation - 1; /* This means that the item is deleted */
5900 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5902 if (it->itc->func.del)
5903 it->itc->func.del((void *)it->base.data, WIDGET(it));
5907 _elm_genlist_item_del_serious(Elm_Gen_Item *it)
5909 _elm_genlist_item_del_notserious(it);
5910 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5911 if (it->tooltip.del_cb)
5912 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
5913 it->wd->walking -= it->walking;
5914 if (it->long_timer) ecore_timer_del(it->long_timer);
5916 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
5920 eina_inlist_sorted_state_free(it->wd->state);
5921 it->wd->state = NULL;
5923 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5924 it->wd->calc_job = ecore_job_add(it->wd->calc_cb, it->wd);
5928 if (it->wd->last_selected_item == (Elm_Object_Item *)it)
5929 it->wd->last_selected_item = NULL;
5930 it->wd->item_count--;
5934 elm_genlist_tree_effect_enabled_set(Evas_Object *obj, Eina_Bool enabled)
5936 ELM_CHECK_WIDTYPE(obj, widtype);
5937 Widget_Data *wd = elm_widget_data_get(obj);
5939 wd->tree_effect_enabled = !!enabled;
5943 elm_genlist_tree_effect_enabled_get(const Evas_Object *obj)
5945 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5946 Widget_Data *wd = elm_widget_data_get(obj);
5947 if (!wd) return EINA_FALSE;
5948 return wd->tree_effect_enabled;
5952 _create_tray_alpha_bg(const Evas_Object *obj)
5954 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5955 Widget_Data *wd = elm_widget_data_get(obj);
5956 if (!wd) return NULL;
5958 Evas_Object *bg = NULL;
5959 Evas_Coord ox, oy, ow, oh;
5961 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5962 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5963 evas_object_color_set(bg,0,0,0,0);
5964 evas_object_resize(bg , ow, oh);
5965 evas_object_move(bg , ox, oy);
5970 _item_contract_emit(Elm_Gen_Item *it)
5975 edje_object_signal_emit(VIEW(it), "elm,state,contract_flip", "");
5976 it->item->tree_effect_finished = EINA_FALSE;
5978 EINA_LIST_FOREACH(it->item->items, l, it2)
5979 if (it2) _item_contract_emit(it2);
5983 _item_tree_effect_before(Elm_Gen_Item *it)
5988 EINA_LIST_FOREACH(it->item->items, l, it2)
5990 if (it2->parent && (it == it2->parent))
5992 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5993 edje_object_signal_emit(VIEW(it2), "elm,state,hide", "");
5994 else if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5995 _item_contract_emit(it2);
5998 return ECORE_CALLBACK_CANCEL;
6002 _item_tree_effect(Widget_Data *wd, int y)
6004 Elm_Gen_Item *it = NULL, *expanded_next_it;
6006 expanded_next_it = wd->expanded_next_item;
6008 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
6010 it = (Elm_Gen_Item *) elm_genlist_item_prev_get((Elm_Object_Item *) expanded_next_it);
6013 if (it->item->expanded_depth <= expanded_next_it->item->expanded_depth) break;
6014 if (it->item->scrl_y && (it->item->scrl_y < expanded_next_it->item->old_scrl_y + y) &&
6015 (it->item->expanded_depth > expanded_next_it->item->expanded_depth))
6017 if (!it->item->tree_effect_finished)
6019 edje_object_signal_emit(VIEW(it), "flip_item", "");
6020 evas_object_show(VIEW(it));
6021 it->item->tree_effect_finished = EINA_TRUE;
6024 it = (Elm_Gen_Item *) elm_genlist_item_prev_get((Elm_Object_Item *) it);
6027 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
6029 it = (Elm_Gen_Item *) elm_genlist_item_prev_get((Elm_Object_Item *) expanded_next_it);
6032 if ((it->item->scrl_y > expanded_next_it->item->old_scrl_y + y) &&
6033 (it->item->expanded_depth > expanded_next_it->item->expanded_depth))
6035 if (!it->item->tree_effect_finished)
6037 edje_object_signal_emit(VIEW(it), "elm,state,hide", "");
6038 it->item->tree_effect_finished = EINA_TRUE;
6043 it = (Elm_Gen_Item *) elm_genlist_item_prev_get((Elm_Object_Item *) it);
6049 _item_tree_effect_finish(Widget_Data *wd)
6052 Elm_Gen_Item *it = NULL;
6055 if (wd->item_moving_effect_timer)
6057 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
6058 _item_subitems_clear(wd->expanded_item);
6059 EINA_INLIST_FOREACH(wd->blocks, itb)
6061 EINA_LIST_FOREACH(itb->items, l, it)
6063 it->item->tree_effect_finished = EINA_TRUE;
6064 it->item->old_scrl_y = it->item->scrl_y;
6068 _item_auto_scroll(wd);
6069 evas_object_lower(wd->alpha_bg);
6070 evas_object_hide(wd->alpha_bg);
6071 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
6072 if (wd->move_items) wd->move_items = eina_list_free(wd->move_items);
6074 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
6075 evas_object_smart_callback_call(wd->obj, SIG_TREE_EFFECT_FINISHED, NULL);
6076 evas_object_smart_changed(wd->pan_smart);
6078 wd->item_moving_effect_timer = NULL;
6082 _item_moving_effect_timer_cb(void *data)
6084 Widget_Data *wd = data;
6085 if (!wd) return EINA_FALSE;
6086 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
6087 Elm_Gen_Item *it = NULL, *it2, *expanded_next_it;
6089 double effect_duration = 0.5, t;
6090 int y = 0, dy = 0, dh = 0;
6091 Eina_Bool end = EINA_FALSE, vis = EINA_TRUE;
6094 t = ((0.0 > (t = ecore_time_get() - wd->start_time)) ? 0.0 : t);
6095 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
6096 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
6097 if (t > effect_duration) end = EINA_TRUE;
6099 // Below while statement is needed, when the genlist is resized.
6100 it2 = wd->expanded_item;
6103 evas_object_move(VIEW(it2), it2->item->scrl_x, it2->item->scrl_y);
6104 vis = (ELM_RECTS_INTERSECT(it2->item->scrl_x, it2->item->scrl_y, it2->item->w, it2->item->h,
6105 cvx, cvy, cvw, cvh));
6106 it2 = (Elm_Gen_Item *) elm_genlist_item_prev_get((Elm_Object_Item *) it2);
6109 if (wd->expanded_next_item)
6111 expanded_next_it = wd->expanded_next_item;
6114 EINA_LIST_FOREACH(wd->move_items, l, it)
6116 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
6118 expanded_next_it->item->old_scrl_y = wd->expanded_item->item->old_scrl_y + wd->expanded_item->item->h;
6119 if (expanded_next_it->item->scrl_y < expanded_next_it->item->old_scrl_y) //did not calculate next item position
6120 expanded_next_it->item->scrl_y = cvy + cvh;
6122 dy = ((expanded_next_it->item->scrl_y >= (cvy + cvh)) ?
6123 cvy + cvh : expanded_next_it->item->scrl_y) -
6124 expanded_next_it->item->old_scrl_y;
6126 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
6128 if (expanded_next_it->item->scrl_y > expanded_next_it->item->old_scrl_y) //did not calculate next item position
6129 expanded_next_it->item->old_scrl_y = cvy + cvh;
6131 if (expanded_next_it->item->old_scrl_y > (cvy + cvh))
6133 dy = (wd->expanded_item->item->scrl_y + wd->expanded_item->item->h) -
6135 expanded_next_it->item->old_scrl_y = cvy + cvh;
6139 dy = (wd->expanded_item->item->scrl_y + wd->expanded_item->item->h) -
6140 expanded_next_it->item->old_scrl_y;
6144 if (t <= effect_duration)
6146 y = ((1 - (1 - (t / effect_duration)) * (1 - (t /effect_duration))) * dy);
6156 _item_realize(it, in, 0);
6160 if (it != expanded_next_it)
6162 it->item->old_scrl_y = expanded_next_it->item->old_scrl_y + expanded_next_it->item->h + dh;
6166 if ((it->item->old_scrl_y + y) < (cvy + cvh))
6167 _item_position(it, VIEW(it),it->item->scrl_x, it->item->old_scrl_y + y);
6170 _item_tree_effect(wd, y);
6174 int expanded_item_num = 0;
6177 if (wd->expanded_item)
6178 it = (Elm_Gen_Item *) elm_genlist_item_next_get((Elm_Object_Item *) wd->expanded_item);
6183 expanded_item_num++;
6184 it2 = (Elm_Gen_Item *) elm_genlist_item_next_get((Elm_Object_Item *) it2);
6190 if (wd->expanded_item->item->expanded_depth >= it->item->expanded_depth) break;
6191 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
6193 if (!it->item->tree_effect_finished)
6195 if (t >= (((num - 1) * effect_duration) / expanded_item_num))
6197 edje_object_signal_emit(VIEW(it), "flip_item", "");
6198 evas_object_show(VIEW(it));
6199 it->item->tree_effect_finished = EINA_TRUE;
6203 it = (Elm_Gen_Item *) elm_genlist_item_next_get((Elm_Object_Item *) it);
6209 _item_tree_effect_finish(wd);
6210 return ECORE_CALLBACK_CANCEL;
6212 return ECORE_CALLBACK_RENEW;