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;
89 Evas_Coord x, y, w, h, minw, minh;
91 int item_position_stamp;
93 Eina_Bool position_update : 1;
94 Eina_Bool want_unrealize : 1;
95 Eina_Bool realized : 1;
96 Eina_Bool changed : 1;
97 Eina_Bool updateme : 1;
99 Eina_Bool must_recalc : 1;
106 Evas_Object *base_view, *spacer;
108 const char *item_style; // it->itc->item_style
109 Eina_Bool tree : 1; // it->group
110 Eina_Bool compress : 1; // it->wd->compress
112 Eina_Bool selected : 1; // it->selected
113 Eina_Bool disabled : 1; // it->disabled
114 Eina_Bool expanded : 1; // it->item->expanded
117 static const char *widtype = NULL;
118 static void _item_cache_zero(Widget_Data *wd);
119 static void _del_hook(Evas_Object *obj);
120 static void _mirrored_set(Evas_Object *obj,
122 static void _theme_hook(Evas_Object *obj);
123 static void _show_region_hook(void *data,
125 static void _sizing_eval(Evas_Object *obj);
126 static void _item_realize(Elm_Gen_Item *it,
129 static void _item_unrealize_cb(Elm_Gen_Item *it);
130 static void _item_block_unrealize(Item_Block *itb);
131 static void _calc_job(void *data);
132 static void _on_focus_hook(void *data,
134 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
135 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
136 static Eina_Bool _item_single_select_up(Widget_Data *wd);
137 static Eina_Bool _item_single_select_down(Widget_Data *wd);
138 static Eina_Bool _event_hook(Evas_Object *obj,
140 Evas_Callback_Type type,
142 static void _signal_emit_hook(Evas_Object *obj,
143 const char *emission,
145 static Eina_Bool _deselect_all_items(Widget_Data *wd);
146 static void _pan_calculate(Evas_Object *obj);
147 static void _pan_max_get(Evas_Object *obj,
150 static void _item_position(Elm_Gen_Item *it,
154 static void _mode_item_realize(Elm_Gen_Item *it);
155 static void _mode_item_unrealize(Elm_Gen_Item *it);
156 static void _item_mode_set(Elm_Gen_Item *it);
157 static void _item_mode_unset(Widget_Data *wd);
158 static void _edit_mode_item_position(Elm_Gen_Item *it, int itx, int ity);
159 static void _edit_mode_item_realize(Elm_Gen_Item *it, Eina_Bool effect_on);
160 static void _edit_mode_item_unrealize(Elm_Gen_Item *it);
161 static void _group_items_recalc(void *data);
162 static void _item_move_after(Elm_Gen_Item *it,
163 Elm_Gen_Item *after);
164 static void _item_move_before(Elm_Gen_Item *it,
165 Elm_Gen_Item *before);
166 static void _item_auto_scroll(Widget_Data *wd);
167 static void _elm_genlist_clear(Evas_Object *obj,
169 static void _pan_child_size_get(Evas_Object *obj,
173 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
175 static const char SIG_ACTIVATED[] = "activated";
176 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
177 static const char SIG_SELECTED[] = "selected";
178 static const char SIG_UNSELECTED[] = "unselected";
179 static const char SIG_EXPANDED[] = "expanded";
180 static const char SIG_CONTRACTED[] = "contracted";
181 static const char SIG_EXPAND_REQUEST[] = "expand,request";
182 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
183 static const char SIG_REALIZED[] = "realized";
184 static const char SIG_UNREALIZED[] = "unrealized";
185 static const char SIG_DRAG_START_UP[] = "drag,start,up";
186 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
187 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
188 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
189 static const char SIG_DRAG_STOP[] = "drag,stop";
190 static const char SIG_DRAG[] = "drag";
191 static const char SIG_LONGPRESSED[] = "longpressed";
192 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
193 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
194 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
195 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
196 static const char SIG_EDGE_TOP[] = "edge,top";
197 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
198 static const char SIG_EDGE_LEFT[] = "edge,left";
199 static const char SIG_EDGE_RIGHT[] = "edge,right";
200 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
201 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
202 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
203 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
204 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
205 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
206 static const char SIG_SWIPE[] = "swipe";
207 static const char SIG_MOVED[] = "moved";
208 static const char SIG_INDEX_UPDATE[] = "index,update";
210 static const Evas_Smart_Cb_Description _signals[] = {
211 {SIG_CLICKED_DOUBLE, ""},
214 {SIG_UNSELECTED, ""},
216 {SIG_CONTRACTED, ""},
217 {SIG_EXPAND_REQUEST, ""},
218 {SIG_CONTRACT_REQUEST, ""},
220 {SIG_UNREALIZED, ""},
221 {SIG_DRAG_START_UP, ""},
222 {SIG_DRAG_START_DOWN, ""},
223 {SIG_DRAG_START_LEFT, ""},
224 {SIG_DRAG_START_RIGHT, ""},
227 {SIG_LONGPRESSED, ""},
228 {SIG_SCROLL_ANIM_START, ""},
229 {SIG_SCROLL_ANIM_STOP, ""},
230 {SIG_SCROLL_DRAG_START, ""},
231 {SIG_SCROLL_DRAG_STOP, ""},
233 {SIG_EDGE_BOTTOM, ""},
235 {SIG_EDGE_RIGHT, ""},
236 {SIG_MULTI_SWIPE_LEFT, ""},
237 {SIG_MULTI_SWIPE_RIGHT, ""},
238 {SIG_MULTI_SWIPE_UP, ""},
239 {SIG_MULTI_SWIPE_DOWN, ""},
240 {SIG_MULTI_PINCH_OUT, ""},
241 {SIG_MULTI_PINCH_IN, ""},
248 #undef ELM_CHECK_WIDTYPE
249 #define ELM_CHECK_WIDTYPE(obj, widtype) \
250 if ((!obj) || (!elm_genlist_type_check((obj), __func__))) return
251 #undef ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN
252 #define ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, ...) \
253 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
254 ELM_CHECK_WIDTYPE(WIDGET((it)), widtype) __VA_ARGS__;
256 static const char *_gengrid = NULL;
257 static const char *_genlist = NULL;
259 /* THIS FUNCTION IS HACKY AND TEMPORARY!!! */
261 elm_genlist_type_check(const Evas_Object *obj,
264 const char *provided, *expected = "(unknown)";
265 static int abort_on_warn = -1;
266 provided = elm_widget_type_get(obj);
267 if (!_genlist) _genlist = eina_stringshare_add("genlist");
268 if (!_gengrid) _gengrid = eina_stringshare_add("gengrid");
269 if (EINA_LIKELY(provided == _genlist) || EINA_LIKELY(provided == _gengrid))
271 if ((!provided) || (!provided[0]))
273 provided = evas_object_type_get(obj);
274 if ((!provided) || (!provided[0]))
275 provided = "(unknown)";
277 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
278 if (abort_on_warn == -1)
280 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
281 else abort_on_warn = 0;
283 if (abort_on_warn == 1) abort();
288 _event_hook(Evas_Object *obj,
289 Evas_Object *src __UNUSED__,
290 Evas_Callback_Type type,
293 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
294 Evas_Event_Key_Down *ev = event_info;
295 Widget_Data *wd = elm_widget_data_get(obj);
296 Evas_Coord pan_max_x = 0, pan_max_y = 0;
297 if (!wd) return EINA_FALSE;
298 if (!wd->items) return EINA_FALSE;
299 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
300 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
302 Elm_Object_Item *it = NULL;
305 Evas_Coord step_x = 0;
306 Evas_Coord step_y = 0;
309 Evas_Coord page_x = 0;
310 Evas_Coord page_y = 0;
312 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
313 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
314 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
315 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
317 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
321 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
325 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
327 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
328 (_item_multi_select_up(wd)))
329 || (_item_single_select_up(wd)))
331 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
337 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
339 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
340 (_item_multi_select_down(wd)))
341 || (_item_single_select_down(wd)))
343 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
349 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
351 it = elm_genlist_first_item_get(obj);
352 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
353 elm_genlist_item_selected_set(it, EINA_TRUE);
354 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
357 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
359 it = elm_genlist_last_item_get(obj);
360 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
361 elm_genlist_item_selected_set(it, EINA_TRUE);
362 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
365 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
368 y -= -(page_y * v_h) / 100;
372 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
375 y += -(page_y * v_h) / 100;
379 else if (!strcmp(ev->keyname, "Escape"))
381 if (!_deselect_all_items(wd)) return EINA_FALSE;
382 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
385 else if (((!strcmp(ev->keyname, "Return")) ||
386 (!strcmp(ev->keyname, "KP_Enter")) ||
387 (!strcmp(ev->keyname, "space")))
388 && (!wd->multi) && (wd->selected))
390 it = elm_genlist_selected_item_get(obj);
391 elm_genlist_item_expanded_set(it,
392 !elm_genlist_item_expanded_get(it));
393 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
395 else return EINA_FALSE;
397 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
398 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
400 if (x > pan_max_x) x = pan_max_x;
402 if (y > pan_max_y) y = pan_max_y;
403 elm_smart_scroller_child_pos_set(wd->scr, x, y);
408 _deselect_all_items(Widget_Data *wd)
410 if (!wd->selected) return EINA_FALSE;
412 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
418 _item_multi_select_up(Widget_Data *wd)
420 if (!wd->selected) return EINA_FALSE;
421 if (!wd->multi) return EINA_FALSE;
423 Elm_Object_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
424 if (!prev) return EINA_TRUE;
426 if (elm_genlist_item_selected_get(prev))
428 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
429 wd->last_selected_item = prev;
430 elm_genlist_item_show(wd->last_selected_item);
434 elm_genlist_item_selected_set(prev, EINA_TRUE);
435 elm_genlist_item_show(prev);
441 _item_multi_select_down(Widget_Data *wd)
443 if (!wd->selected) return EINA_FALSE;
444 if (!wd->multi) return EINA_FALSE;
446 Elm_Object_Item *next;
447 next = elm_genlist_item_next_get(wd->last_selected_item);
448 if (!next) return EINA_TRUE;
450 if (elm_genlist_item_selected_get(next))
452 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
453 wd->last_selected_item = next;
454 elm_genlist_item_show(wd->last_selected_item);
458 elm_genlist_item_selected_set(next, EINA_TRUE);
459 elm_genlist_item_show(next);
465 _item_single_select_up(Widget_Data *wd)
470 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
471 while ((prev) && (prev->generation < wd->generation))
472 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
474 else prev = (Elm_Gen_Item *) elm_genlist_item_prev_get(wd->last_selected_item);
476 if (!prev) return EINA_FALSE;
478 _deselect_all_items(wd);
480 elm_genlist_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
481 elm_genlist_item_show((Elm_Object_Item *) prev);
486 _item_single_select_down(Widget_Data *wd)
491 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
492 while ((next) && (next->generation < wd->generation))
493 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
495 else next = (Elm_Gen_Item *) elm_genlist_item_next_get(wd->last_selected_item);
497 if (!next) return EINA_FALSE;
499 _deselect_all_items(wd);
501 elm_genlist_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
502 elm_genlist_item_show((Elm_Object_Item *) next);
507 _on_focus_hook(void *data __UNUSED__,
510 Widget_Data *wd = elm_widget_data_get(obj);
512 if (elm_widget_focus_get(obj))
514 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
515 evas_object_focus_set(wd->obj, EINA_TRUE);
516 if ((wd->selected) && (!wd->last_selected_item))
517 wd->last_selected_item = eina_list_data_get(wd->selected);
521 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
522 evas_object_focus_set(wd->obj, EINA_FALSE);
527 _del_hook(Evas_Object *obj)
529 Widget_Data *wd = elm_widget_data_get(obj);
531 _item_cache_zero(wd);
532 if (wd->calc_job) ecore_job_del(wd->calc_job);
533 if (wd->update_job) ecore_job_del(wd->update_job);
534 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
535 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
536 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
537 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
538 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
543 _del_pre_hook(Evas_Object *obj)
545 Widget_Data *wd = elm_widget_data_get(obj);
547 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
548 elm_genlist_clear(obj);
549 evas_object_del(wd->pan_smart);
550 wd->pan_smart = NULL;
554 _mirrored_set(Evas_Object *obj,
557 Widget_Data *wd = elm_widget_data_get(obj);
559 _item_cache_zero(wd);
560 elm_smart_scroller_mirrored_set(wd->scr, rtl);
564 _theme_hook(Evas_Object *obj)
566 Widget_Data *wd = elm_widget_data_get(obj);
569 evas_event_freeze(evas_object_evas_get(wd->obj));
570 _item_cache_zero(wd);
571 _elm_widget_mirrored_reload(obj);
572 _mirrored_set(obj, elm_widget_mirrored_get(obj));
573 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
574 elm_widget_style_get(obj));
575 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
576 wd->item_width = wd->item_height = 0;
577 wd->group_item_width = wd->group_item_height = 0;
578 wd->minw = wd->minh = wd->realminw = 0;
579 EINA_INLIST_FOREACH(wd->blocks, itb)
584 if (itb->realized) _item_block_unrealize(itb);
585 EINA_LIST_FOREACH(itb->items, l, it)
586 it->item->mincalcd = EINA_FALSE;
588 itb->changed = EINA_TRUE;
590 if (wd->calc_job) ecore_job_del(wd->calc_job);
591 wd->calc_job = ecore_job_add(_calc_job, wd);
593 evas_event_thaw(evas_object_evas_get(wd->obj));
594 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
598 _show_region_hook(void *data,
601 Widget_Data *wd = elm_widget_data_get(data);
602 Evas_Coord x, y, w, h;
604 elm_widget_show_region_get(obj, &x, &y, &w, &h);
605 //x & y are screen coordinates, Add with pan coordinates
608 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
612 _translate_hook(Evas_Object *obj)
614 evas_object_smart_callback_call(obj, "language,changed", NULL);
618 _sizing_eval(Evas_Object *obj)
620 Widget_Data *wd = elm_widget_data_get(obj);
621 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
623 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
624 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
626 if (wd->height_for_width)
630 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
631 if ((vw != 0) && (vw != wd->prev_viewport_w))
635 wd->prev_viewport_w = vw;
636 EINA_INLIST_FOREACH(wd->blocks, itb)
638 itb->must_recalc = EINA_TRUE;
640 if (wd->calc_job) ecore_job_del(wd->calc_job);
641 wd->calc_job = ecore_job_add(_calc_job, wd);
644 if (wd->mode == ELM_LIST_LIMIT)
650 elm_smart_scroller_child_viewport_size_get(wd->scr, &vmw, &vmh);
651 edje_object_size_min_calc
652 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
659 edje_object_size_min_calc
660 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
664 evas_object_size_hint_min_set(obj, minw, minh);
665 evas_object_size_hint_max_set(obj, maxw, maxh);
669 _signal_emit_hook(Evas_Object *obj,
670 const char *emission,
673 Widget_Data *wd = elm_widget_data_get(obj);
674 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
679 _item_highlight(Elm_Gen_Item *it)
681 const char *selectraise;
682 if ((it->wd->no_select) || (it->generation < it->wd->generation) ||
683 (it->highlighted) || elm_widget_item_disabled_get(it) ||
684 (it->display_only) || (it->item->mode_view))
686 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
687 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
688 selectraise = edje_object_data_get(VIEW(it), "selectraise");
689 if ((selectraise) && (!strcmp(selectraise, "on")))
691 if (it->edit_obj) evas_object_raise(it->edit_obj);
692 else evas_object_raise(VIEW(it));
693 if ((it->item->group_item) && (it->item->group_item->realized))
694 evas_object_raise(it->item->VIEW(group_item));
696 it->highlighted = EINA_TRUE;
700 _item_unhighlight(Elm_Gen_Item *it)
702 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
703 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
704 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
705 if (!it->item->nostacking)
707 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
709 if (it->edit_obj) evas_object_lower(it->edit_obj);
710 else evas_object_lower(VIEW(it));
714 if (it->edit_obj) evas_object_raise(it->edit_obj);
715 else evas_object_raise(VIEW(it));
718 it->highlighted = EINA_FALSE;
722 _item_block_position_update(Eina_Inlist *list, int idx)
726 EINA_INLIST_FOREACH(list, tmp)
728 tmp->position = idx++;
729 tmp->position_update = EINA_TRUE;
734 _item_position_update(Eina_List *list, int idx)
739 EINA_LIST_FOREACH(list, l, it)
741 it->position = idx++;
742 it->position_update = EINA_TRUE;
747 _item_block_del(Elm_Gen_Item *it)
750 Item_Block *itb = it->item->block;
752 itb->items = eina_list_remove(itb->items, it);
754 itb->changed = EINA_TRUE;
755 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
756 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
759 il = EINA_INLIST_GET(itb);
760 Item_Block *itbn = (Item_Block *)(il->next);
762 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
765 _item_block_position_update(il->next, itb->position);
766 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
769 if (itbn) itbn->changed = EINA_TRUE;
773 if (itb->count < itb->wd->max_items_per_block/2)
775 il = EINA_INLIST_GET(itb);
776 Item_Block *itbp = (Item_Block *)(il->prev);
777 Item_Block *itbn = (Item_Block *)(il->next);
778 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
782 EINA_LIST_FREE(itb->items, it2)
784 it2->item->block = itbp;
785 itbp->items = eina_list_append(itbp->items, it2);
787 itbp->changed = EINA_TRUE;
789 _item_block_position_update(EINA_INLIST_GET(itb)->next,
791 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
792 EINA_INLIST_GET(itb));
795 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
799 Eina_List *last = eina_list_last(itb->items);
800 Elm_Gen_Item *it2 = last->data;
802 it2->item->block = itbn;
803 itb->items = eina_list_remove_list(itb->items, last);
804 itbn->items = eina_list_prepend(itbn->items, it2);
806 itbn->changed = EINA_TRUE;
808 _item_block_position_update(EINA_INLIST_GET(itb)->next,
811 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
819 _item_del(Elm_Gen_Item *it)
821 Evas_Object *obj = WIDGET(it);
823 evas_event_freeze(evas_object_evas_get(obj));
824 elm_genlist_item_subitems_clear((Elm_Object_Item *)it);
825 if (it->wd->show_item == it) it->wd->show_item = NULL;
826 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
827 if (it->item->edit_mode_item_realized) _edit_mode_item_unrealize(it);
828 if (it->item->block) _item_block_del(it);
829 if (it->item->queued)
830 it->wd->queue = eina_list_remove(it->wd->queue, it);
831 if (it->wd->anchor_item == it)
833 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
834 if (!it->wd->anchor_item)
835 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
837 if (it->wd->expanded_item == it) it->wd->expanded_item = NULL;
839 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
840 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
841 _elm_genlist_item_del_serious(it);
842 elm_genlist_item_class_unref((Elm_Genlist_Item_Class *)it->itc);
843 evas_event_thaw(evas_object_evas_get(obj));
844 evas_event_thaw_eval(evas_object_evas_get(obj));
848 _clear_cb(Widget_Data *wd)
850 wd->anchor_item = NULL;
853 Item_Block *itb = (Item_Block *)(wd->blocks);
855 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
856 if (itb->items) eina_list_free(itb->items);
859 if (wd->queue_idle_enterer)
861 ecore_idle_enterer_del(wd->queue_idle_enterer);
862 wd->queue_idle_enterer = NULL;
864 if (wd->must_recalc_idler)
866 ecore_idler_del(wd->must_recalc_idler);
867 wd->must_recalc_idler = NULL;
869 if (wd->queue) wd->queue = eina_list_free(wd->queue);
870 if (wd->reorder_move_animator)
872 ecore_animator_del(wd->reorder_move_animator);
873 wd->reorder_move_animator = NULL;
875 wd->show_item = NULL;
876 wd->reorder_old_pan_y = 0;
880 _item_unselect(Elm_Gen_Item *it)
882 if ((it->generation < it->wd->generation) || (!it->selected)) return;
883 it->selected = EINA_FALSE;
884 it->wd->selected = eina_list_remove(it->wd->selected, it);
885 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
889 _mouse_move(void *data,
890 Evas *evas __UNUSED__,
894 Elm_Gen_Item *it = data;
895 Evas_Event_Mouse_Move *ev = event_info;
896 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
897 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
899 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
901 if (!it->wd->on_hold)
903 it->wd->on_hold = EINA_TRUE;
904 if ((!it->wd->wasselected) && (!it->flipped))
906 _item_unhighlight(it);
911 if (it->wd->multitouched)
913 it->wd->cur_x = ev->cur.canvas.x;
914 it->wd->cur_y = ev->cur.canvas.y;
917 if ((it->dragging) && (it->down))
919 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
922 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
923 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
924 if (abs((it->wd->history[it->wd->movements].x -
925 it->wd->history[0].x)) > 40)
926 it->wd->swipe = EINA_TRUE;
932 ecore_timer_del(it->long_timer);
933 it->long_timer = NULL;
935 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
938 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
942 ecore_timer_del(it->long_timer);
943 it->long_timer = NULL;
945 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
947 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
948 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
950 if (!it->wd->reorder_start_y)
951 it->wd->reorder_start_y = it->item->block->y + it->y;
955 else if (it_scrl_y + it->wd->reorder_it->item->h > oy + oh)
956 y_pos = oy + oh - it->wd->reorder_it->item->h;
961 _item_position(it, it->edit_obj, it->item->scrl_x, y_pos);
963 _item_position(it, VIEW(it), it->item->scrl_x, y_pos);
965 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
966 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
970 if (!it->display_only)
971 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
972 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
973 x = ev->cur.canvas.x - x;
974 y = ev->cur.canvas.y - y;
977 if (adx < 0) adx = -dx;
980 if (ady < 0) ady = -dy;
983 if ((adx > minw) || (ady > minh))
985 it->dragging = EINA_TRUE;
988 ecore_timer_del(it->long_timer);
989 it->long_timer = NULL;
991 if (!it->wd->wasselected)
993 _item_unhighlight(it);
999 evas_object_smart_callback_call(WIDGET(it),
1000 SIG_DRAG_START_UP, it);
1004 evas_object_smart_callback_call(WIDGET(it),
1005 SIG_DRAG_START_LEFT, it);
1007 evas_object_smart_callback_call(WIDGET(it),
1008 SIG_DRAG_START_RIGHT, it);
1014 evas_object_smart_callback_call(WIDGET(it),
1015 SIG_DRAG_START_DOWN, it);
1019 evas_object_smart_callback_call(WIDGET(it),
1020 SIG_DRAG_START_LEFT, it);
1022 evas_object_smart_callback_call(WIDGET(it),
1023 SIG_DRAG_START_RIGHT, it);
1030 _long_press(void *data)
1032 Elm_Gen_Item *it = data, *it_tmp;
1033 Eina_List *list, *l;
1035 it->long_timer = NULL;
1036 if (elm_widget_item_disabled_get(it) || (it->dragging) || (it->display_only))
1037 return ECORE_CALLBACK_CANCEL;
1038 it->wd->longpressed = EINA_TRUE;
1039 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
1040 if ((it->wd->reorder_mode) && (!it->group))
1042 it->wd->reorder_it = it;
1043 it->wd->reorder_start_y = 0;
1045 evas_object_raise(it->edit_obj);
1047 evas_object_raise(VIEW(it));
1049 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1050 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1052 list = elm_genlist_realized_items_get(it->wd->obj);
1053 EINA_LIST_FOREACH(list, l, it_tmp)
1055 if (it != it_tmp) _item_unselect(it_tmp);
1057 if (elm_genlist_item_expanded_get((Elm_Object_Item *)it))
1059 elm_genlist_item_expanded_set((Elm_Object_Item *)it, EINA_FALSE);
1060 return ECORE_CALLBACK_RENEW;
1063 if (!it->wd->edit_mode)
1064 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
1066 return ECORE_CALLBACK_CANCEL;
1070 _swipe(Elm_Gen_Item *it)
1075 if ((it->display_only) || elm_widget_item_disabled_get(it)) return;
1076 it->wd->swipe = EINA_FALSE;
1077 for (i = 0; i < it->wd->movements; i++)
1079 sum += it->wd->history[i].x;
1080 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1083 sum /= it->wd->movements;
1084 if (abs(sum - it->wd->history[0].x) <= 10) return;
1085 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
1089 _swipe_cancel(void *data)
1091 Elm_Gen_Item *it = data;
1093 if (!it) return ECORE_CALLBACK_CANCEL;
1094 it->wd->swipe = EINA_FALSE;
1095 it->wd->movements = 0;
1096 return ECORE_CALLBACK_RENEW;
1100 _multi_cancel(void *data)
1102 Widget_Data *wd = data;
1104 if (!wd) return ECORE_CALLBACK_CANCEL;
1105 wd->multi_timeout = EINA_TRUE;
1106 return ECORE_CALLBACK_RENEW;
1110 _multi_touch_gesture_eval(void *data)
1112 Elm_Gen_Item *it = data;
1114 it->wd->multitouched = EINA_FALSE;
1115 if (it->wd->multi_timer)
1117 ecore_timer_del(it->wd->multi_timer);
1118 it->wd->multi_timer = NULL;
1120 if (it->wd->multi_timeout)
1122 it->wd->multi_timeout = EINA_FALSE;
1126 Evas_Coord minw = 0, minh = 0;
1127 Evas_Coord off_x, off_y, off_mx, off_my;
1129 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1130 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1131 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1132 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1133 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1135 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1137 if ((off_x + off_mx) > (off_y + off_my))
1139 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1140 evas_object_smart_callback_call(WIDGET(it),
1141 SIG_MULTI_SWIPE_RIGHT, it);
1142 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1143 evas_object_smart_callback_call(WIDGET(it),
1144 SIG_MULTI_SWIPE_LEFT, it);
1145 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1146 evas_object_smart_callback_call(WIDGET(it),
1147 SIG_MULTI_PINCH_OUT, it);
1149 evas_object_smart_callback_call(WIDGET(it),
1150 SIG_MULTI_PINCH_IN, it);
1154 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1155 evas_object_smart_callback_call(WIDGET(it),
1156 SIG_MULTI_SWIPE_DOWN, it);
1157 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1158 evas_object_smart_callback_call(WIDGET(it),
1159 SIG_MULTI_SWIPE_UP, it);
1160 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1161 evas_object_smart_callback_call(WIDGET(it),
1162 SIG_MULTI_PINCH_OUT, it);
1164 evas_object_smart_callback_call(WIDGET(it),
1165 SIG_MULTI_PINCH_IN, it);
1168 it->wd->multi_timeout = EINA_FALSE;
1172 _multi_down(void *data,
1173 Evas *evas __UNUSED__,
1174 Evas_Object *obj __UNUSED__,
1177 Elm_Gen_Item *it = data;
1178 Evas_Event_Multi_Down *ev = event_info;
1180 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1181 it->wd->multi_device = ev->device;
1182 it->wd->multi_down = EINA_TRUE;
1183 it->wd->multitouched = EINA_TRUE;
1184 it->wd->prev_mx = ev->canvas.x;
1185 it->wd->prev_my = ev->canvas.y;
1186 if (!it->wd->wasselected)
1188 _item_unhighlight(it);
1191 it->wd->wasselected = EINA_FALSE;
1192 it->wd->longpressed = EINA_FALSE;
1195 ecore_timer_del(it->long_timer);
1196 it->long_timer = NULL;
1200 it->dragging = EINA_FALSE;
1201 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1203 if (it->item->swipe_timer)
1205 ecore_timer_del(it->item->swipe_timer);
1206 it->item->swipe_timer = NULL;
1208 if (it->wd->on_hold)
1210 it->wd->swipe = EINA_FALSE;
1211 it->wd->movements = 0;
1212 it->wd->on_hold = EINA_FALSE;
1217 _multi_up(void *data,
1218 Evas *evas __UNUSED__,
1219 Evas_Object *obj __UNUSED__,
1222 Elm_Gen_Item *it = data;
1223 Evas_Event_Multi_Up *ev = event_info;
1225 if (it->wd->multi_device != ev->device) return;
1226 it->wd->multi_device = 0;
1227 it->wd->multi_down = EINA_FALSE;
1228 if (it->wd->mouse_down) return;
1229 _multi_touch_gesture_eval(data);
1233 _multi_move(void *data,
1234 Evas *evas __UNUSED__,
1235 Evas_Object *obj __UNUSED__,
1238 Elm_Gen_Item *it = data;
1239 Evas_Event_Multi_Move *ev = event_info;
1241 if (it->wd->multi_device != ev->device) return;
1242 it->wd->cur_mx = ev->cur.canvas.x;
1243 it->wd->cur_my = ev->cur.canvas.y;
1247 _mouse_down(void *data,
1248 Evas *evas __UNUSED__,
1252 Elm_Gen_Item *it = data;
1253 Evas_Event_Mouse_Down *ev = event_info;
1256 if (ev->button != 1) return;
1257 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1259 it->wd->on_hold = EINA_TRUE;
1262 it->down = EINA_TRUE;
1263 it->dragging = EINA_FALSE;
1264 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1265 it->dx = ev->canvas.x - x;
1266 it->dy = ev->canvas.y - y;
1267 it->wd->mouse_down = EINA_TRUE;
1268 if (!it->wd->multitouched)
1270 it->wd->prev_x = ev->canvas.x;
1271 it->wd->prev_y = ev->canvas.y;
1272 it->wd->multi_timeout = EINA_FALSE;
1273 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1274 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1276 it->wd->longpressed = EINA_FALSE;
1277 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1278 else it->wd->on_hold = EINA_FALSE;
1279 if (it->wd->on_hold) return;
1280 it->wd->wasselected = it->selected;
1281 _item_highlight(it);
1282 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1283 if ((!elm_widget_item_disabled_get(it)) && (!it->display_only))
1285 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1286 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
1288 if (it->long_timer) ecore_timer_del(it->long_timer);
1289 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
1290 it->item->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1292 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1295 it->long_timer = NULL;
1296 it->wd->swipe = EINA_FALSE;
1297 it->wd->movements = 0;
1301 _mouse_up(void *data,
1302 Evas *evas __UNUSED__,
1303 Evas_Object *obj __UNUSED__,
1306 Elm_Gen_Item *it = data;
1307 Evas_Event_Mouse_Up *ev = event_info;
1308 Eina_Bool dragged = EINA_FALSE;
1310 if (ev->button != 1) return;
1311 it->down = EINA_FALSE;
1312 it->wd->mouse_down = EINA_FALSE;
1313 if (it->wd->multitouched)
1315 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1316 if (it->wd->multi_down) return;
1317 _multi_touch_gesture_eval(data);
1320 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1321 else it->wd->on_hold = EINA_FALSE;
1324 ecore_timer_del(it->long_timer);
1325 it->long_timer = NULL;
1329 it->dragging = EINA_FALSE;
1330 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1333 if (it->item->swipe_timer)
1335 ecore_timer_del(it->item->swipe_timer);
1336 it->item->swipe_timer = NULL;
1338 if (it->wd->multi_timer)
1340 ecore_timer_del(it->wd->multi_timer);
1341 it->wd->multi_timer = NULL;
1342 it->wd->multi_timeout = EINA_FALSE;
1344 if (it->wd->on_hold)
1346 if (it->wd->swipe) _swipe(data);
1347 it->wd->longpressed = EINA_FALSE;
1348 it->wd->on_hold = EINA_FALSE;
1351 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1353 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1355 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1357 if (it_scrl_y <= it->wd->reorder_rel->item->scrl_y)
1358 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1360 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1364 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1365 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1367 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
1368 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1369 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1370 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
1372 if (it->wd->longpressed)
1374 it->wd->longpressed = EINA_FALSE;
1375 if ((!it->wd->wasselected) && (!it->flipped))
1377 _item_unhighlight(it);
1380 it->wd->wasselected = EINA_FALSE;
1385 if (it->want_unrealize)
1387 _elm_genlist_item_unrealize(it, EINA_FALSE);
1388 if (it->item->block->want_unrealize)
1389 _item_block_unrealize(it->item->block);
1392 if (elm_widget_item_disabled_get(it) || (dragged) || (it->display_only))
1394 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1399 _item_highlight(it);
1404 _item_unhighlight(it);
1412 Widget_Data *wd = it->wd;
1415 while (wd->selected)
1417 _item_unhighlight(wd->selected->data);
1418 _item_unselect(wd->selected->data);
1424 const Eina_List *l, *l_next;
1427 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1430 _item_unhighlight(it2);
1431 _item_unselect(it2);
1433 //_item_highlight(it);
1436 _item_highlight(it);
1442 _signal_expand_toggle(void *data,
1443 Evas_Object *obj __UNUSED__,
1444 const char *emission __UNUSED__,
1445 const char *source __UNUSED__)
1447 Elm_Gen_Item *it = data;
1449 if (it->item->expanded)
1450 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1452 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1456 _signal_expand(void *data,
1457 Evas_Object *obj __UNUSED__,
1458 const char *emission __UNUSED__,
1459 const char *source __UNUSED__)
1461 Elm_Gen_Item *it = data;
1463 if (!it->item->expanded)
1464 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1468 _signal_contract(void *data,
1469 Evas_Object *obj __UNUSED__,
1470 const char *emission __UNUSED__,
1471 const char *source __UNUSED__)
1473 Elm_Gen_Item *it = data;
1475 if (it->item->expanded)
1476 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1480 _scr_hold_timer_cb(void *data)
1482 if (!data) return ECORE_CALLBACK_CANCEL;
1483 Widget_Data *wd = data;
1484 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1485 wd->scr_hold_timer = NULL;
1486 return ECORE_CALLBACK_CANCEL;
1490 _mode_finished_signal_cb(void *data,
1492 const char *emission __UNUSED__,
1493 const char *source __UNUSED__)
1497 Elm_Gen_Item *it = data;
1498 if ((it->generation < it->wd->generation) || (!it->realized) || (!it->item->mode_view)) return;
1500 Evas *te = evas_object_evas_get(obj);
1502 evas_event_freeze(te);
1503 it->item->nocache_once = EINA_FALSE;
1504 _mode_item_unrealize(it);
1505 if (it->item->group_item)
1506 evas_object_raise(it->item->VIEW(group_item));
1507 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1508 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1509 evas_event_thaw(te);
1510 evas_event_thaw_eval(te);
1514 _item_cache_clean(Widget_Data *wd)
1516 evas_event_freeze(evas_object_evas_get(wd->obj));
1517 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1521 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1522 wd->item_cache = eina_inlist_remove(wd->item_cache,
1523 wd->item_cache->last);
1524 wd->item_cache_count--;
1525 if (itc->spacer) evas_object_del(itc->spacer);
1526 if (itc->base_view) evas_object_del(itc->base_view);
1527 eina_stringshare_del(itc->item_style);
1530 evas_event_thaw(evas_object_evas_get(wd->obj));
1531 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1535 _item_cache_zero(Widget_Data *wd)
1537 int pmax = wd->item_cache_max;
1538 wd->item_cache_max = 0;
1539 _item_cache_clean(wd);
1540 wd->item_cache_max = pmax;
1544 _item_cache_add(Elm_Gen_Item *it)
1548 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1549 if (it->wd->item_cache_max <= 0)
1551 evas_object_del(VIEW(it));
1553 evas_object_del(it->spacer);
1555 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1556 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1560 it->wd->item_cache_count++;
1561 itc = calloc(1, sizeof(Item_Cache));
1564 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1565 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1568 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1569 EINA_INLIST_GET(itc));
1570 itc->spacer = it->spacer;
1572 itc->base_view = VIEW(it);
1574 edje_object_signal_emit(itc->base_view, "elm,state,unselected", "elm");
1575 evas_object_hide(itc->base_view);
1576 evas_object_move(itc->base_view, -9999, -9999);
1577 itc->item_style = eina_stringshare_add(it->itc->item_style);
1578 if (it->item->type & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1579 itc->compress = (it->wd->compress);
1580 itc->selected = it->selected;
1581 itc->disabled = elm_widget_item_disabled_get(it);
1582 itc->expanded = it->item->expanded;
1585 ecore_timer_del(it->long_timer);
1586 it->long_timer = NULL;
1588 if (it->item->swipe_timer)
1590 ecore_timer_del(it->item->swipe_timer);
1591 it->item->swipe_timer = NULL;
1593 // FIXME: other callbacks?
1594 edje_object_signal_callback_del_full(itc->base_view,
1595 "elm,action,expand,toggle",
1596 "elm", _signal_expand_toggle, it);
1597 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1599 _signal_expand, it);
1600 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1601 "elm", _signal_contract, it);
1602 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1604 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1606 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1608 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1610 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1612 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1614 _item_cache_clean(it->wd);
1615 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1616 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1620 _item_cache_find(Elm_Gen_Item *it)
1625 if (it->item->type & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1626 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1628 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1630 if ((itc->tree == tree) &&
1631 (itc->compress == it->wd->compress) &&
1632 (((!it->itc->item_style) && (!itc->item_style)) ||
1633 (it->itc->item_style && itc->item_style &&
1634 (!strcmp(it->itc->item_style, itc->item_style)))))
1636 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1637 EINA_INLIST_GET(itc));
1638 it->wd->item_cache_count--;
1646 _elm_genlist_item_index_update(Elm_Gen_Item *it)
1648 if (it->position_update || it->item->block->position_update)
1650 evas_object_smart_callback_call(WIDGET(it), SIG_INDEX_UPDATE, it);
1651 it->position_update = EINA_FALSE;
1656 _elm_genlist_item_odd_even_update(Elm_Gen_Item *it)
1658 if (!it->item->nostacking)
1660 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
1662 if (it->edit_obj) evas_object_lower(it->edit_obj);
1663 else evas_object_lower(VIEW(it));
1667 if (it->edit_obj) evas_object_raise(it->edit_obj);
1668 else evas_object_raise(VIEW(it));
1672 if (it->item->order_num_in & 0x1)
1674 edje_object_signal_emit(VIEW(it), "elm,state,odd", "elm");
1675 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,odd", "elm");
1679 edje_object_signal_emit(VIEW(it), "elm,state,even", "elm");
1680 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,even", "elm");
1685 _elm_genlist_item_state_update(Elm_Gen_Item *it, Item_Cache *itc)
1689 if (it->selected != itc->selected)
1692 edje_object_signal_emit(VIEW(it),
1693 "elm,state,selected", "elm");
1696 edje_object_signal_emit(it->edit_obj,
1697 "elm,state,selected", "elm");
1699 if (elm_widget_item_disabled_get(it) != itc->disabled)
1701 if (elm_widget_item_disabled_get(it))
1702 edje_object_signal_emit(VIEW(it),
1703 "elm,state,disabled", "elm");
1705 edje_object_signal_emit(it->edit_obj,
1706 "elm,state,disabled", "elm");
1708 if (it->item->expanded != itc->expanded)
1710 if (it->item->expanded)
1711 edje_object_signal_emit(VIEW(it),
1712 "elm,state,expanded", "elm");
1714 edje_object_signal_emit(it->edit_obj,
1715 "elm,state,expanded", "elm");
1722 edje_object_signal_emit(VIEW(it),
1723 "elm,state,selected", "elm");
1725 edje_object_signal_emit(it->edit_obj,
1726 "elm,state,selected", "elm");
1729 if (elm_widget_item_disabled_get(it))
1731 edje_object_signal_emit(VIEW(it),
1732 "elm,state,disabled", "elm");
1734 edje_object_signal_emit(it->edit_obj,
1735 "elm,state,disabled", "elm");
1737 if (it->item->expanded)
1739 edje_object_signal_emit(VIEW(it),
1740 "elm,state,expanded", "elm");
1742 edje_object_signal_emit(it->edit_obj,
1743 "elm,state,expanded", "elm");
1749 _item_cache_free(Item_Cache *itc)
1751 if (itc->spacer) evas_object_del(itc->spacer);
1752 if (itc->base_view) evas_object_del(itc->base_view);
1753 eina_stringshare_del(itc->item_style);
1758 _item_text_realize(Elm_Gen_Item *it,
1759 Evas_Object *target,
1763 if (it->itc->func.text_get)
1768 *source = elm_widget_stringlist_get(edje_object_data_get(target, "texts"));
1769 EINA_LIST_FOREACH(*source, l, key)
1771 if (parts && fnmatch(parts, key, FNM_PERIOD))
1774 char *s = it->itc->func.text_get
1775 ((void *)it->base.data, WIDGET(it), key);
1779 edje_object_part_text_set(target, key, s);
1784 edje_object_part_text_set(target, key, "");
1791 _item_content_unrealize(Elm_Gen_Item *it,
1792 Evas_Object *target,
1796 Eina_List *res = it->content_objs;
1798 if (it->itc->func.content_get)
1802 Evas_Object *ic = NULL;
1804 EINA_LIST_FOREACH(*source, l, key)
1806 if (parts && fnmatch(parts, key, FNM_PERIOD))
1809 ic = edje_object_part_swallow_get(target, key);
1812 res = eina_list_remove(res, ic);
1813 edje_object_part_unswallow(target, ic);
1814 evas_object_del(ic);
1823 _item_content_realize(Elm_Gen_Item *it,
1824 Evas_Object *target,
1828 Eina_List *res = NULL;
1830 if (it->itc->func.content_get)
1834 Evas_Object *ic = NULL;
1836 *source = elm_widget_stringlist_get(edje_object_data_get(target, "contents"));
1838 if (parts && (eina_list_count(*source) != eina_list_count(it->content_objs)))
1839 res = it->content_objs;
1841 EINA_LIST_FOREACH(*source, l, key)
1843 if (parts && fnmatch(parts, key, FNM_PERIOD))
1846 if (it->itc->func.content_get)
1847 ic = it->itc->func.content_get
1848 ((void *)it->base.data, WIDGET(it), key);
1851 res = eina_list_append(res, ic);
1852 edje_object_part_swallow(target, key, ic);
1853 evas_object_show(ic);
1854 elm_widget_sub_object_add(WIDGET(it), ic);
1855 if (elm_widget_item_disabled_get(it))
1856 elm_widget_disabled_set(ic, EINA_TRUE);
1865 _item_state_realize(Elm_Gen_Item *it,
1866 Evas_Object *target,
1870 if (it->itc->func.state_get)
1876 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1877 EINA_LIST_FOREACH(*source, l, key)
1879 if (parts && fnmatch(parts, key, FNM_PERIOD))
1882 Eina_Bool on = it->itc->func.state_get
1883 ((void *)it->base.data, WIDGET(it), key);
1887 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1888 edje_object_signal_emit(target, buf, "elm");
1892 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1893 edje_object_signal_emit(target, buf, "elm");
1900 _item_flips_realize(Elm_Gen_Item *it,
1901 Evas_Object *target,
1904 Eina_List *res = NULL;
1906 if (it->itc->func.content_get)
1910 Evas_Object *ic = NULL;
1912 *source = elm_widget_stringlist_get(edje_object_data_get(target, "flips"));
1914 EINA_LIST_FOREACH(*source, l, key)
1916 if (it->itc->func.content_get)
1917 ic = it->itc->func.content_get
1918 ((void *)it->base.data, WIDGET(it), key);
1921 res = eina_list_append(res, ic);
1922 edje_object_part_swallow(target, key, ic);
1923 evas_object_show(ic);
1924 elm_widget_sub_object_add(WIDGET(it), ic);
1925 if (elm_widget_item_disabled_get(it))
1926 elm_widget_disabled_set(ic, EINA_TRUE);
1935 _item_realize(Elm_Gen_Item *it,
1939 const char *treesize;
1942 Item_Cache *itc = NULL;
1944 if (it->generation < it->wd->generation) return;
1945 //evas_event_freeze(evas_object_evas_get(it->wd->obj));
1948 if (it->item->order_num_in != in)
1950 it->item->order_num_in = in;
1951 _elm_genlist_item_odd_even_update(it);
1952 _elm_genlist_item_state_update(it, NULL);
1953 _elm_genlist_item_index_update(it);
1955 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1956 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1959 it->item->order_num_in = in;
1961 if (it->item->nocache_once)
1962 it->item->nocache_once = EINA_FALSE;
1963 else if (!it->item->nocache)
1964 itc = _item_cache_find(it);
1967 VIEW(it) = itc->base_view;
1968 itc->base_view = NULL;
1969 it->spacer = itc->spacer;
1974 const char *stacking_even;
1975 const char *stacking;
1977 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
1978 edje_object_scale_set(VIEW(it),
1979 elm_widget_scale_get(WIDGET(it)) *
1980 _elm_config->scale);
1981 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
1982 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
1984 if (it->item->type & ELM_GENLIST_ITEM_SUBITEMS)
1985 snprintf(buf, sizeof(buf), "tree%s/%s", it->wd->compress ? "_compress" : "", it->itc->item_style ?: "default");
1987 snprintf(buf, sizeof(buf), "item%s/%s", it->wd->compress ? "_compress" : "", it->itc->item_style ?: "default");
1989 _elm_theme_object_set(WIDGET(it), VIEW(it), "genlist", buf,
1990 elm_widget_style_get(WIDGET(it)));
1992 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
1993 if (!stacking_even) stacking_even = "above";
1994 it->item->stacking_even = !!strcmp("above", stacking_even);
1996 stacking = edje_object_data_get(VIEW(it), "stacking");
1997 if (!stacking) stacking = "yes";
1998 it->item->nostacking = !!strcmp("yes", stacking);
2000 edje_object_mirrored_set(VIEW(it),
2001 elm_widget_mirrored_get(WIDGET(it)));
2003 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
2004 evas_object_color_set(it->spacer, 0, 0, 0, 0);
2005 elm_widget_sub_object_add(WIDGET(it), it->spacer);
2008 _elm_genlist_item_odd_even_update(it);
2010 treesize = edje_object_data_get(VIEW(it), "treesize");
2011 if (treesize) tsize = atoi(treesize);
2012 evas_object_size_hint_min_set(it->spacer,
2013 (it->item->expanded_depth * tsize) * _elm_config->scale, 1);
2014 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
2017 edje_object_signal_callback_add(VIEW(it),
2018 "elm,action,expand,toggle",
2019 "elm", _signal_expand_toggle, it);
2020 edje_object_signal_callback_add(VIEW(it), "elm,action,expand",
2021 "elm", _signal_expand, it);
2022 edje_object_signal_callback_add(VIEW(it), "elm,action,contract",
2023 "elm", _signal_contract, it);
2024 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
2026 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
2028 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
2030 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_DOWN,
2032 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_UP,
2034 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_MOVE,
2037 if ((it->wd->edit_mode) && (!it->edit_obj) &&
2038 (it->item->type != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
2039 _edit_mode_item_realize(it, EINA_FALSE);
2041 _elm_genlist_item_state_update(it, itc);
2042 _elm_genlist_item_index_update(it);
2045 if ((calc) && (it->wd->homogeneous) &&
2046 ((it->wd->item_width) ||
2047 ((it->wd->item_width) && (it->wd->group_item_width))))
2049 /* homogenous genlist shortcut */
2050 if (!it->item->mincalcd)
2054 it->item->w = it->item->minw = it->wd->group_item_width;
2055 it->item->h = it->item->minh = it->wd->group_item_height;
2059 it->item->w = it->item->minw = it->wd->item_width;
2060 it->item->h = it->item->minh = it->wd->item_height;
2062 it->item->mincalcd = EINA_TRUE;
2067 /* FIXME: If you see that assert, please notify us and we
2068 will clean our mess */
2069 assert(eina_list_count(it->content_objs) == 0);
2071 _item_text_realize(it, VIEW(it), &it->texts, NULL);
2072 it->content_objs = _item_content_realize(it, VIEW(it), &it->contents, NULL);
2073 _item_state_realize(it, VIEW(it), &it->states, NULL);
2076 edje_object_signal_emit(VIEW(it), "elm,state,flip,enabled", "elm");
2077 it->content_objs = _item_flips_realize(it, VIEW(it), &it->contents);
2080 if (!it->item->mincalcd)
2082 Evas_Coord mw = -1, mh = -1;
2084 if (!it->display_only)
2085 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2086 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2087 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
2089 if (!it->display_only)
2090 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2091 it->item->w = it->item->minw = mw;
2092 it->item->h = it->item->minh = mh;
2093 it->item->mincalcd = EINA_TRUE;
2095 if ((!it->wd->group_item_width) && (it->group))
2097 it->wd->group_item_width = mw;
2098 it->wd->group_item_height = mh;
2100 else if ((!it->wd->item_width) && (it->item->type == ELM_GENLIST_ITEM_NONE))
2102 it->wd->item_width = mw;
2103 it->wd->item_height = mh;
2106 if (!calc) evas_object_show(VIEW(it));
2109 if (it->tooltip.content_cb)
2111 elm_widget_item_tooltip_content_cb_set(it,
2112 it->tooltip.content_cb,
2113 it->tooltip.data, NULL);
2114 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2115 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
2118 if (it->mouse_cursor)
2119 elm_widget_item_cursor_set(it, it->mouse_cursor);
2121 it->realized = EINA_TRUE;
2122 it->want_unrealize = EINA_FALSE;
2124 if (itc) _item_cache_free(itc);
2125 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
2126 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2128 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
2130 if ((!calc) && (it->wd->edit_mode) && (it->item->type != ELM_GENLIST_ITEM_GROUP))
2132 if (it->itc->edit_item_style)
2134 if (!it->edit_obj) _edit_mode_item_realize(it, EINA_FALSE);
2135 edje_object_message_signal_process(it->edit_obj);
2138 edje_object_message_signal_process(VIEW(it));
2142 _item_unrealize_cb(Elm_Gen_Item *it)
2144 if (it->item->nocache_once || it->item->nocache)
2146 evas_object_del(VIEW(it));
2148 evas_object_del(it->spacer);
2153 edje_object_mirrored_set(VIEW(it),
2154 elm_widget_mirrored_get(WIDGET(it)));
2155 edje_object_scale_set(VIEW(it),
2156 elm_widget_scale_get(WIDGET(it))
2157 * _elm_config->scale);
2158 _item_cache_add(it);
2161 _mode_item_unrealize(it);
2163 it->realized = EINA_FALSE;
2164 it->want_unrealize = EINA_FALSE;
2165 if (it->wd->edit_mode) _edit_mode_item_unrealize(it);
2169 _item_block_recalc(Item_Block *itb,
2175 Evas_Coord minw = 0, minh = 0;
2176 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2179 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2181 EINA_LIST_FOREACH(itb->items, l, it)
2183 if (it->generation < it->wd->generation) continue;
2184 showme |= it->item->showme;
2189 if (!it->item->mincalcd) changed = EINA_TRUE;
2192 _item_realize(it, in, EINA_TRUE);
2193 _elm_genlist_item_unrealize(it, EINA_TRUE);
2198 _item_realize(it, in, EINA_TRUE);
2199 _elm_genlist_item_unrealize(it, EINA_TRUE);
2203 _item_realize(it, in, EINA_FALSE);
2204 minh += it->item->minh;
2205 if (minw < it->item->minw) minw = it->item->minw;
2213 itb->changed = EINA_FALSE;
2214 itb->position_update = EINA_FALSE;
2215 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2216 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2221 _item_block_realize(Item_Block *itb)
2223 if (itb->realized) return;
2224 itb->realized = EINA_TRUE;
2225 itb->want_unrealize = EINA_FALSE;
2229 _item_block_unrealize(Item_Block *itb)
2233 Eina_Bool dragging = EINA_FALSE;
2235 if (!itb->realized) return;
2236 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2237 EINA_LIST_FOREACH(itb->items, l, it)
2239 if (itb->must_recalc || !it->group)
2243 dragging = EINA_TRUE;
2244 it->want_unrealize = EINA_TRUE;
2247 _elm_genlist_item_unrealize(it, EINA_FALSE);
2252 itb->realized = EINA_FALSE;
2253 itb->want_unrealize = EINA_TRUE;
2256 itb->want_unrealize = EINA_FALSE;
2257 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2258 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2262 _get_space_for_reorder_item(Elm_Gen_Item *it)
2264 Evas_Coord rox, roy, row, roh, oy, oh;
2265 Eina_Bool top = EINA_FALSE;
2266 Elm_Gen_Item *reorder_it = it->wd->reorder_it;
2267 if (!reorder_it) return 0;
2269 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2270 evas_object_geometry_get(it->wd->VIEW(reorder_it), &rox, &roy, &row, &roh);
2272 if ((it->wd->reorder_start_y < it->item->block->y) &&
2273 (roy - oy + (roh / 2) >= it->item->block->y - it->wd->pan_y))
2275 it->item->block->reorder_offset = it->wd->reorder_it->item->h * -1;
2276 if (it->item->block->count == 1)
2277 it->wd->reorder_rel = it;
2279 else if ((it->wd->reorder_start_y >= it->item->block->y) &&
2280 (roy - oy + (roh / 2) <= it->item->block->y - it->wd->pan_y))
2282 it->item->block->reorder_offset = it->wd->reorder_it->item->h;
2285 it->item->block->reorder_offset = 0;
2287 it->item->scrl_y += it->item->block->reorder_offset;
2289 top = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2290 rox, roy + (roh / 2), row, 1));
2293 it->wd->reorder_rel = it;
2294 it->item->scrl_y += it->wd->reorder_it->item->h;
2295 return it->wd->reorder_it->item->h;
2302 _reorder_move_animator_cb(void *data)
2304 Elm_Gen_Item *it = data;
2305 Eina_Bool down = EINA_FALSE;
2307 int y, dy = it->item->h / 10 * _elm_config->scale, diff;
2309 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2311 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2314 diff = abs(it->item->old_scrl_y - it->item->scrl_y);
2315 if (diff > it->item->h) y = diff / 2;
2317 if (it->item->old_scrl_y < it->item->scrl_y)
2319 it->item->old_scrl_y += y;
2322 else if (it->item->old_scrl_y > it->item->scrl_y)
2324 it->item->old_scrl_y -= y;
2329 _item_position(it, it->edit_obj, it->item->scrl_x, it->item->old_scrl_y);
2331 _item_position(it, VIEW(it), it->item->scrl_x, it->item->old_scrl_y);
2332 _group_items_recalc(it->wd);
2334 if ((it->wd->reorder_pan_move) ||
2335 (down && it->item->old_scrl_y >= it->item->scrl_y) ||
2336 (!down && it->item->old_scrl_y <= it->item->scrl_y))
2338 it->item->old_scrl_y = it->item->scrl_y;
2339 it->item->move_effect_enabled = EINA_FALSE;
2340 it->wd->reorder_move_animator = NULL;
2341 return ECORE_CALLBACK_CANCEL;
2343 return ECORE_CALLBACK_RENEW;
2347 _item_position(Elm_Gen_Item *it,
2355 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2356 evas_object_resize(view, it->item->w, it->item->h);
2357 evas_object_move(view, it_x, it_y);
2358 evas_object_show(view);
2359 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2360 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2364 _item_block_position(Item_Block *itb,
2370 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2371 Eina_Bool vis = EINA_FALSE;
2373 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2374 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2375 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2377 EINA_LIST_FOREACH(itb->items, l, it)
2379 if (it->generation < it->wd->generation) continue;
2380 else if (it->wd->reorder_it == it) continue;
2383 it->item->w = itb->w;
2384 it->item->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2385 it->item->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2387 vis = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2388 cvx, cvy, cvw, cvh));
2391 if ((itb->realized) && (!it->realized))
2393 if (vis) _item_realize(it, in, EINA_FALSE);
2397 if (vis || it->dragging)
2399 if (it->wd->reorder_mode)
2400 y += _get_space_for_reorder_item(it);
2401 git = it->item->group_item;
2404 if (git->item->scrl_y < oy)
2405 git->item->scrl_y = oy;
2406 if ((git->item->scrl_y + git->item->h) > (it->item->scrl_y + it->item->h))
2407 git->item->scrl_y = (it->item->scrl_y + it->item->h) - git->item->h;
2408 git->item->want_realize = EINA_TRUE;
2410 if ((it->wd->reorder_it) && (it->item->old_scrl_y != it->item->scrl_y))
2412 if (!it->item->move_effect_enabled)
2414 it->item->move_effect_enabled = EINA_TRUE;
2415 it->wd->reorder_move_animator =
2417 _reorder_move_animator_cb, it);
2420 if (!it->item->move_effect_enabled)
2422 if ((it->wd->edit_mode) && (it->itc->edit_item_style))
2423 _edit_mode_item_position(it, it->item->scrl_x,
2427 if (it->item->mode_view)
2428 _item_position(it, it->item->mode_view,
2432 _item_position(it, VIEW(it), it->item->scrl_x,
2435 it->item->old_scrl_y = it->item->scrl_y;
2440 _elm_genlist_item_unrealize(it, EINA_FALSE);
2447 if (vis) it->item->want_realize = EINA_TRUE;
2451 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2452 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2456 _group_items_recalc(void *data)
2458 Widget_Data *wd = data;
2462 evas_event_freeze(evas_object_evas_get(wd->obj));
2463 EINA_LIST_FOREACH(wd->group_items, l, git)
2465 if (git->item->want_realize)
2468 _item_realize(git, 0, EINA_FALSE);
2469 evas_object_resize(VIEW(git), wd->minw, git->item->h);
2470 evas_object_move(VIEW(git), git->item->scrl_x, git->item->scrl_y);
2471 evas_object_show(VIEW(git));
2472 evas_object_raise(VIEW(git));
2474 else if (!git->item->want_realize && git->realized)
2477 _elm_genlist_item_unrealize(git, EINA_FALSE);
2480 evas_event_thaw(evas_object_evas_get(wd->obj));
2481 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2485 _must_recalc_idler(void *data)
2487 Widget_Data *wd = data;
2488 if (wd->calc_job) ecore_job_del(wd->calc_job);
2489 wd->calc_job = ecore_job_add(_calc_job, wd);
2490 wd->must_recalc_idler = NULL;
2491 return ECORE_CALLBACK_CANCEL;
2495 _scroll_item(Widget_Data *wd)
2497 Elm_Gen_Item *it = NULL;
2498 Evas_Coord gith = 0;
2499 Evas_Coord ow, oh, dx = 0, dy = 0, dw = 0, dh = 0;
2501 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
2503 dx = it->x + it->item->block->x;
2504 dy = it->y + it->item->block->y;
2505 dw = it->item->block->w;
2507 switch (wd->scrollto_type)
2509 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
2510 if (it->item->group_item) gith = it->item->group_item->item->h;
2513 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
2514 dy += (it->item->h / 2 - oh / 2);
2516 case ELM_GENLIST_ITEM_SCROLLTO_IN:
2518 if ((wd->expanded_item) &&
2519 ((wd->show_item->y + wd->show_item->item->block->y + wd->show_item->item->h)
2520 - (wd->expanded_item->y + wd->expanded_item->item->block->y) > oh))
2522 it = wd->expanded_item;
2523 if (it->item->group_item) gith = it->item->group_item->item->h;
2524 dx = it->x + it->item->block->x;
2525 dy = it->y + it->item->block->y - gith;
2526 dw = it->item->block->w;
2530 if ((it->item->group_item) && (wd->pan_y > (it->y + it->item->block->y)))
2531 gith = it->item->group_item->item->h;
2538 elm_smart_scroller_region_bring_in(wd->scr, dx, dy, dw, dh);
2540 elm_smart_scroller_child_region_show(wd->scr, dx, dy, dw, dh);
2542 it->item->showme = EINA_FALSE;
2543 wd->show_item = NULL;
2544 wd->auto_scroll_enabled = EINA_FALSE;
2545 wd->check_scroll = EINA_FALSE;
2549 _calc_job(void *data)
2551 Widget_Data *wd = data;
2552 Item_Block *itb, *chb = NULL;
2553 Evas_Coord minw = -1, minh = 0, y = 0, ow, dy = 0, vw;
2554 Evas_Coord pan_w = 0, pan_h = 0;
2556 Eina_Bool minw_change = EINA_FALSE;
2557 Eina_Bool did_must_recalc = EINA_FALSE;
2560 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2561 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, NULL);
2566 evas_event_freeze(evas_object_evas_get(wd->obj));
2567 EINA_INLIST_FOREACH(wd->blocks, itb)
2569 Eina_Bool showme = EINA_FALSE;
2572 showme = itb->showme;
2573 itb->showme = EINA_FALSE;
2576 if (itb->realized) _item_block_unrealize(itb);
2578 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2580 if (itb->must_recalc)
2584 EINA_LIST_FOREACH(itb->items, l, it)
2585 if (it->item->mincalcd) it->item->mincalcd = EINA_FALSE;
2586 itb->changed = EINA_TRUE;
2587 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2588 if (itb->realized) _item_block_unrealize(itb);
2589 itb->must_recalc = EINA_FALSE;
2591 showme = _item_block_recalc(itb, in, EINA_FALSE);
2597 if (minw == -1) minw = itb->minw;
2598 else if ((!itb->must_recalc) && (minw < itb->minw))
2601 minw_change = EINA_TRUE;
2606 minw_change = EINA_TRUE;
2612 if ((showme) && (wd->show_item) && (!wd->show_item->item->queued))
2613 wd->check_scroll = EINA_TRUE;
2617 EINA_INLIST_FOREACH(wd->blocks, itb)
2623 if ((chb) && (EINA_INLIST_GET(chb)->next))
2625 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2627 if (itb->realized) _item_block_unrealize(itb);
2630 wd->realminw = minw;
2631 if (minw < wd->w) minw = wd->w;
2632 if ((minw != wd->minw) || (minh != wd->minh))
2636 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2637 _sizing_eval(wd->obj);
2638 if ((wd->anchor_item) && (wd->anchor_item->item->block) && (!wd->auto_scroll_enabled))
2643 it = wd->anchor_item;
2644 it_y = wd->anchor_y;
2645 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2646 it->item->block->y + it->y + it_y);
2647 wd->anchor_item = it;
2648 wd->anchor_y = it_y;
2651 if (did_must_recalc)
2653 if (!wd->must_recalc_idler)
2654 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2656 if (wd->check_scroll)
2658 _pan_child_size_get(wd->pan_smart, &pan_w, &pan_h);
2659 if (EINA_INLIST_GET(wd->show_item) == wd->items->last)
2660 wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
2661 switch (wd->scrollto_type)
2663 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
2666 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
2669 case ELM_GENLIST_ITEM_SCROLLTO_IN:
2674 if ((pan_w > (wd->show_item->x + wd->show_item->item->block->x)) &&
2675 (pan_h > (wd->show_item->y + wd->show_item->item->block->y + dy)))
2680 wd->calc_job = NULL;
2681 evas_object_smart_changed(wd->pan_smart);
2682 evas_event_thaw(evas_object_evas_get(wd->obj));
2683 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2687 _update_job(void *data)
2689 Widget_Data *wd = data;
2693 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2695 wd->update_job = NULL;
2698 evas_event_freeze(evas_object_evas_get(wd->obj));
2699 EINA_INLIST_FOREACH(wd->blocks, itb)
2701 Evas_Coord itminw, itminh;
2708 _item_block_position(itb, num);
2712 recalc = EINA_FALSE;
2713 EINA_LIST_FOREACH(itb->items, l2, it)
2715 if (it->item->updateme)
2717 itminw = it->item->minw;
2718 itminh = it->item->minh;
2720 it->item->updateme = EINA_FALSE;
2723 _elm_genlist_item_unrealize(it, EINA_FALSE);
2724 _item_realize(it, num, EINA_FALSE);
2725 position = EINA_TRUE;
2729 _item_realize(it, num, EINA_TRUE);
2730 _elm_genlist_item_unrealize(it, EINA_TRUE);
2732 if ((it->item->minw != itminw) || (it->item->minh != itminh))
2737 itb->updateme = EINA_FALSE;
2740 position = EINA_TRUE;
2741 itb->changed = EINA_TRUE;
2742 _item_block_recalc(itb, num0, EINA_FALSE);
2743 _item_block_position(itb, num0);
2748 if (wd->calc_job) ecore_job_del(wd->calc_job);
2749 wd->calc_job = ecore_job_add(_calc_job, wd);
2751 evas_event_thaw(evas_object_evas_get(wd->obj));
2752 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2756 _pan_set(Evas_Object *obj,
2760 Pan *sd = evas_object_smart_data_get(obj);
2764 // Evas_Coord ow, oh;
2765 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2766 // ow = sd->wd->minw - ow;
2767 // if (ow < 0) ow = 0;
2768 // oh = sd->wd->minh - oh;
2769 // if (oh < 0) oh = 0;
2770 // if (x < 0) x = 0;
2771 // if (y < 0) y = 0;
2772 // if (x > ow) x = ow;
2773 // if (y > oh) y = oh;
2774 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2778 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2780 if ((itb->y + itb->h) > y)
2785 EINA_LIST_FOREACH(itb->items, l2, it)
2787 if ((itb->y + it->y) >= y)
2789 sd->wd->anchor_item = it;
2790 sd->wd->anchor_y = -(itb->y + it->y - y);
2797 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2801 _pan_get(Evas_Object *obj,
2805 Pan *sd = evas_object_smart_data_get(obj);
2808 if (x) *x = sd->wd->pan_x;
2809 if (y) *y = sd->wd->pan_y;
2813 _pan_max_get(Evas_Object *obj,
2817 Pan *sd = evas_object_smart_data_get(obj);
2821 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2822 ow = sd->wd->minw - ow;
2824 oh = sd->wd->minh - oh;
2831 _pan_min_get(Evas_Object *obj __UNUSED__,
2840 _pan_child_size_get(Evas_Object *obj,
2844 Pan *sd = evas_object_smart_data_get(obj);
2847 if (w) *w = sd->wd->minw;
2848 if (h) *h = sd->wd->minh;
2852 _pan_add(Evas_Object *obj)
2855 Evas_Object_Smart_Clipped_Data *cd;
2858 cd = evas_object_smart_data_get(obj);
2861 sd->__clipped_data = *cd;
2863 evas_object_smart_data_set(obj, sd);
2867 _pan_del(Evas_Object *obj)
2869 Pan *sd = evas_object_smart_data_get(obj);
2874 ecore_job_del(sd->resize_job);
2875 sd->resize_job = NULL;
2881 _pan_resize_job(void *data)
2885 _sizing_eval(sd->wd->obj);
2886 sd->resize_job = NULL;
2890 _pan_resize(Evas_Object *obj,
2894 Pan *sd = evas_object_smart_data_get(obj);
2898 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2899 if ((ow == w) && (oh == h)) return;
2900 if ((sd->wd->height_for_width) && (ow != w))
2903 if (sd->resize_job) ecore_job_del(sd->resize_job);
2904 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2906 sd->wd->pan_changed = EINA_TRUE;
2907 evas_object_smart_changed(obj);
2908 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2909 sd->wd->calc_job = NULL;
2911 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2912 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2917 _pan_calculate(Evas_Object *obj)
2919 Pan *sd = evas_object_smart_data_get(obj);
2921 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2927 evas_event_freeze(evas_object_evas_get(obj));
2929 if (sd->wd->pan_changed)
2932 sd->wd->pan_changed = EINA_FALSE;
2935 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2936 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2937 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2939 git->item->want_realize = EINA_FALSE;
2941 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2943 itb->w = sd->wd->minw;
2944 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2945 itb->y - sd->wd->pan_y + oy,
2947 cvx, cvy, cvw, cvh))
2949 if ((!itb->realized) || (itb->changed))
2950 _item_block_realize(itb);
2951 _item_block_position(itb, in);
2955 if (itb->realized) _item_block_unrealize(itb);
2959 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2960 _group_items_recalc(sd->wd);
2961 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2963 if (sd->wd->pan_y != sd->wd->reorder_old_pan_y)
2964 sd->wd->reorder_pan_move = EINA_TRUE;
2965 else sd->wd->reorder_pan_move = EINA_FALSE;
2966 evas_object_raise(sd->wd->VIEW(reorder_it));
2967 sd->wd->reorder_old_pan_y = sd->wd->pan_y;
2968 sd->wd->start_time = ecore_loop_time_get();
2970 _item_auto_scroll(sd->wd);
2971 evas_event_thaw(evas_object_evas_get(obj));
2972 evas_event_thaw_eval(evas_object_evas_get(obj));
2976 _pan_move(Evas_Object *obj,
2977 Evas_Coord x __UNUSED__,
2978 Evas_Coord y __UNUSED__)
2980 Pan *sd = evas_object_smart_data_get(obj);
2984 sd->wd->pan_changed = EINA_TRUE;
2985 evas_object_smart_changed(obj);
2986 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2987 sd->wd->calc_job = NULL;
2991 _hold_on(void *data __UNUSED__,
2993 void *event_info __UNUSED__)
2995 Widget_Data *wd = elm_widget_data_get(obj);
2997 elm_smart_scroller_hold_set(wd->scr, 1);
3001 _hold_off(void *data __UNUSED__,
3003 void *event_info __UNUSED__)
3005 Widget_Data *wd = elm_widget_data_get(obj);
3007 elm_smart_scroller_hold_set(wd->scr, 0);
3011 _freeze_on(void *data __UNUSED__,
3013 void *event_info __UNUSED__)
3015 Widget_Data *wd = elm_widget_data_get(obj);
3017 elm_smart_scroller_freeze_set(wd->scr, 1);
3021 _freeze_off(void *data __UNUSED__,
3023 void *event_info __UNUSED__)
3025 Widget_Data *wd = elm_widget_data_get(obj);
3027 elm_smart_scroller_freeze_set(wd->scr, 0);
3031 _scr_anim_start(void *data,
3032 Evas_Object *obj __UNUSED__,
3033 void *event_info __UNUSED__)
3035 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
3039 _scr_anim_stop(void *data,
3040 Evas_Object *obj __UNUSED__,
3041 void *event_info __UNUSED__)
3043 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
3047 _scr_drag_start(void *data,
3048 Evas_Object *obj __UNUSED__,
3049 void *event_info __UNUSED__)
3051 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
3055 _scr_drag_stop(void *data,
3056 Evas_Object *obj __UNUSED__,
3057 void *event_info __UNUSED__)
3059 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
3063 _edge_left(void *data,
3064 Evas_Object *scr __UNUSED__,
3065 void *event_info __UNUSED__)
3067 Evas_Object *obj = data;
3068 evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
3072 _edge_right(void *data,
3073 Evas_Object *scr __UNUSED__,
3074 void *event_info __UNUSED__)
3076 Evas_Object *obj = data;
3077 evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
3081 _edge_top(void *data,
3082 Evas_Object *scr __UNUSED__,
3083 void *event_info __UNUSED__)
3085 Evas_Object *obj = data;
3086 evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
3090 _edge_bottom(void *data,
3091 Evas_Object *scr __UNUSED__,
3092 void *event_info __UNUSED__)
3094 Evas_Object *obj = data;
3095 evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
3099 _mode_item_realize(Elm_Gen_Item *it)
3103 if ((it->item->mode_view) || (it->generation < it->wd->generation)) return;
3105 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3106 it->item->mode_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
3107 edje_object_scale_set(it->item->mode_view,
3108 elm_widget_scale_get(WIDGET(it)) *
3109 _elm_config->scale);
3110 evas_object_smart_member_add(it->item->mode_view, it->wd->pan_smart);
3111 elm_widget_sub_object_add(WIDGET(it), it->item->mode_view);
3113 strncpy(buf, "item", sizeof(buf));
3114 if (it->wd->compress)
3115 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3117 if (it->item->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3118 strncat(buf, "/", sizeof(buf) - strlen(buf));
3119 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3121 _elm_theme_object_set(WIDGET(it), it->item->mode_view, "genlist", buf,
3122 elm_widget_style_get(WIDGET(it)));
3123 edje_object_mirrored_set(it->item->mode_view,
3124 elm_widget_mirrored_get(WIDGET(it)));
3126 /* signal callback add */
3127 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3129 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_UP,
3131 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3134 /* text_get, content_get, state_get */
3135 /* FIXME: If you see that assert, please notify us and we
3136 will clean our mess */
3137 assert(eina_list_count(it->item->mode_content_objs) == 0);
3139 _item_text_realize(it, it->item->mode_view, &it->item->mode_texts, NULL);
3140 it->item->mode_content_objs =
3141 _item_content_realize(it, it->item->mode_view,
3142 &it->item->mode_contents, NULL);
3143 _item_state_realize(it, it->item->mode_view, &it->item->mode_states, NULL);
3145 edje_object_part_swallow(it->item->mode_view,
3146 edje_object_data_get(it->item->mode_view, "mode_part"),
3149 it->want_unrealize = EINA_FALSE;
3150 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3151 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3155 _mode_item_unrealize(Elm_Gen_Item *it)
3157 Widget_Data *wd = it->wd;
3158 Evas_Object *content;
3159 if (!it->item->mode_view) return;
3161 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3162 elm_widget_stringlist_free(it->item->mode_texts);
3163 it->item->mode_texts = NULL;
3164 elm_widget_stringlist_free(it->item->mode_contents);
3165 it->item->mode_contents = NULL;
3166 elm_widget_stringlist_free(it->item->mode_states);
3168 EINA_LIST_FREE(it->item->mode_content_objs, content)
3169 evas_object_del(content);
3171 edje_object_part_unswallow(it->item->mode_view, VIEW(it));
3172 evas_object_smart_member_add(VIEW(it), wd->pan_smart);
3173 evas_object_del(it->item->mode_view);
3174 it->item->mode_view = NULL;
3176 if (wd->mode_item == it)
3177 wd->mode_item = NULL;
3178 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3179 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3183 _item_mode_set(Elm_Gen_Item *it)
3186 Widget_Data *wd = it->wd;
3191 it->item->nocache_once = EINA_TRUE;
3193 if (wd->scr_hold_timer)
3195 ecore_timer_del(wd->scr_hold_timer);
3196 wd->scr_hold_timer = NULL;
3198 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3199 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3201 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3202 _mode_item_realize(it);
3203 if (it->item->group_item)
3204 evas_object_raise(it->item->VIEW(group_item));
3205 _item_position(it, it->item->mode_view, it->item->scrl_x, it->item->scrl_y);
3206 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3207 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3209 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3210 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3214 _item_mode_unset(Widget_Data *wd)
3217 if (!wd->mode_item) return;
3218 char buf[1024], buf2[1024];
3222 it->item->nocache_once = EINA_TRUE;
3224 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3225 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3227 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3228 edje_object_signal_callback_add(it->item->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3230 wd->mode_item = NULL;
3234 _edit_mode_item_position(Elm_Gen_Item *it, int itx, int ity)
3236 if ((!it) || (!it->wd->edit_mode)) return;
3237 evas_object_resize(it->edit_obj, it->item->w, it->item->h);
3238 evas_object_move(it->edit_obj, itx, ity);
3242 _edit_mode_item_realize(Elm_Gen_Item *it, Eina_Bool effect_on)
3245 const char *stacking_even;
3246 const char *stacking;
3248 if ((!it) || (it->item->edit_mode_item_realized) ||
3249 (it->generation < it->wd->generation))
3252 it->edit_obj = edje_object_add(evas_object_evas_get(WIDGET(it)));
3253 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(WIDGET(it)) *
3254 _elm_config->scale);
3255 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
3256 elm_widget_sub_object_add(WIDGET(it), it->edit_obj);
3258 if (it->item->type & ELM_GENLIST_ITEM_SUBITEMS)
3259 strncpy(buf, "tree", sizeof(buf));
3260 else strncpy(buf, "item", sizeof(buf));
3261 if (it->wd->compress)
3262 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3264 strncat(buf, "/", sizeof(buf) - strlen(buf));
3265 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
3267 _elm_theme_object_set(WIDGET(it), it->edit_obj, "genlist", buf,
3268 elm_widget_style_get(WIDGET(it)));
3270 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
3271 if (!stacking_even) stacking_even = "above";
3272 it->item->stacking_even = !!strcmp("above", stacking_even);
3274 stacking = edje_object_data_get(VIEW(it), "stacking");
3275 if (!stacking) stacking = "yes";
3276 it->item->nostacking = !!strcmp("yes", stacking);
3278 edje_object_mirrored_set(it->edit_obj,
3279 elm_widget_mirrored_get(WIDGET(it)));
3281 _elm_genlist_item_odd_even_update(it);
3282 _elm_genlist_item_state_update(it, NULL);
3284 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,edit,enabled,effect", "elm");
3285 else edje_object_signal_emit(it->edit_obj, "elm,state,edit,enabled", "elm");
3287 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
3289 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
3291 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
3293 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_DOWN,
3295 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_UP,
3297 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_MOVE,
3300 _item_text_realize(it, it->edit_obj, &it->item->edit_texts, NULL);
3301 if (it->flipped) edje_object_signal_emit(it->edit_obj, "elm,state,flip,enabled", "elm");
3302 it->item->edit_content_objs =
3303 _item_content_realize(it, it->edit_obj, &it->item->edit_contents, NULL);
3304 _item_state_realize(it, it->edit_obj, &it->item->edit_states, NULL);
3305 edje_object_part_swallow(it->edit_obj, "elm.swallow.edit.content", VIEW(it));
3307 _edit_mode_item_position(it, it->item->scrl_x, it->item->scrl_y);
3308 evas_object_show(it->edit_obj);
3310 it->item->edit_mode_item_realized = EINA_TRUE;
3311 it->want_unrealize = EINA_FALSE;
3315 _edit_mode_item_unrealize(Elm_Gen_Item *it)
3318 if ((!it) || (!it->item->edit_mode_item_realized)) return;
3320 edje_object_part_unswallow(it->edit_obj, VIEW(it));
3321 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
3322 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
3323 _elm_genlist_item_odd_even_update(it);
3324 _elm_genlist_item_state_update(it, NULL);
3326 evas_object_del(it->edit_obj);
3327 it->edit_obj = NULL;
3328 elm_widget_stringlist_free(it->item->edit_texts);
3329 it->item->edit_texts = NULL;
3330 elm_widget_stringlist_free(it->item->edit_contents);
3331 it->item->edit_contents = NULL;
3332 elm_widget_stringlist_free(it->item->edit_states);
3333 it->item->edit_states = NULL;
3334 EINA_LIST_FREE(it->item->edit_content_objs, icon)
3335 evas_object_del(icon);
3336 edje_object_message_signal_process(it->edit_obj);
3338 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
3340 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
3342 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
3344 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_DOWN,
3346 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_UP,
3348 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_MOVE,
3350 it->item->edit_mode_item_realized = EINA_FALSE;
3354 _item_auto_scroll(Widget_Data *wd)
3357 Elm_Gen_Item *tmp_item = NULL;
3359 if ((wd->expanded_item) && (wd->auto_scroll_enabled))
3361 tmp_item = eina_list_data_get(eina_list_last(wd->expanded_item->item->items));
3362 if (!tmp_item) return;
3363 wd->show_item = tmp_item;
3364 wd->bring_in = EINA_TRUE;
3365 wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
3366 if ((wd->show_item->item->queued) || (!wd->show_item->item->mincalcd))
3368 wd->show_item->item->showme = EINA_TRUE;
3369 wd->auto_scroll_enabled = EINA_FALSE;
3377 elm_genlist_add(Evas_Object *parent)
3382 Evas_Coord minw, minh;
3383 static Evas_Smart *smart = NULL;
3387 static Evas_Smart_Class sc;
3389 evas_object_smart_clipped_smart_set(&_pan_sc);
3391 sc.name = "elm_genlist_pan";
3392 sc.version = EVAS_SMART_CLASS_VERSION;
3395 sc.resize = _pan_resize;
3396 sc.move = _pan_move;
3397 sc.calculate = _pan_calculate;
3398 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3401 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3403 ELM_SET_WIDTYPE(widtype, "genlist");
3405 elm_widget_type_set(obj, "genlist");
3406 elm_widget_sub_object_add(parent, obj);
3407 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3408 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3409 elm_widget_data_set(obj, wd);
3410 elm_widget_del_hook_set(obj, _del_hook);
3411 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3412 elm_widget_theme_hook_set(obj, _theme_hook);
3413 elm_widget_can_focus_set(obj, EINA_TRUE);
3414 elm_widget_event_hook_set(obj, _event_hook);
3415 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3416 elm_widget_translate_hook_set(obj, _translate_hook);
3419 wd->scr = elm_smart_scroller_add(e);
3420 elm_smart_scroller_widget_set(wd->scr, obj);
3421 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3422 elm_widget_style_get(obj));
3423 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3424 _elm_config->thumbscroll_bounce_enable);
3425 elm_widget_resize_object_set(obj, wd->scr);
3427 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3428 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3429 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3430 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3431 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
3432 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
3433 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
3434 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
3437 wd->mode = ELM_LIST_SCROLL;
3438 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3439 wd->item_cache_max = wd->max_items_per_block * 2;
3440 wd->longpress_timeout = _elm_config->longpress_timeout;
3442 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3443 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3444 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3445 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3447 wd->pan_smart = evas_object_smart_add(e, smart);
3448 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3451 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3452 _pan_set, _pan_get, _pan_max_get,
3453 _pan_min_get, _pan_child_size_get);
3455 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3457 evas_object_size_hint_min_set(obj, minw, minh);
3459 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3461 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3467 _item_select(Elm_Gen_Item *it)
3469 if ((it->wd->no_select) || (it->generation < it->wd->generation) || (it->mode_set)) return;
3472 it->selected = EINA_TRUE;
3473 it->wd->selected = eina_list_append(it->wd->selected, it);
3475 else if (!it->wd->always_select) return;
3477 evas_object_ref(WIDGET(it));
3480 if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), it);
3481 if (it->generation == it->wd->generation)
3482 evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
3485 evas_object_unref(WIDGET(it));
3486 if ((it->wd->clear_me) && (!it->wd->walking))
3487 _elm_genlist_clear(WIDGET(it), EINA_TRUE);
3490 if ((!it->walking) && (it->generation < it->wd->generation))
3495 elm_widget_item_free(it);
3499 it->wd->last_selected_item = (Elm_Object_Item *)it;
3503 static Evas_Object *
3504 _item_content_get_hook(Elm_Gen_Item *it, const char *part)
3506 return edje_object_part_swallow_get(VIEW(it), part);
3510 _item_content_set_hook(Elm_Gen_Item *it, const char *part, Evas_Object *content)
3512 if (content && part)
3514 it->content_objs = eina_list_append(it->content_objs, content);
3515 edje_object_part_swallow(VIEW(it), part, content);
3519 static Evas_Object *
3520 _item_content_unset_hook(Elm_Gen_Item *it, const char *part)
3523 obj = edje_object_part_swallow_get(VIEW(it), part);
3524 if (!obj) return NULL;
3525 it->content_objs = eina_list_remove(it->content_objs, obj);
3526 edje_object_part_unswallow(VIEW(it), obj);
3531 _item_text_hook(Elm_Gen_Item *it, const char *part)
3533 if (!it->itc->func.text_get) return NULL;
3534 return edje_object_part_text_get(VIEW(it), part);
3538 _item_disable_hook(Elm_Object_Item *it)
3542 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3544 if (_it->generation < _it->wd->generation) return;
3547 elm_genlist_item_selected_set(it, EINA_FALSE);
3551 if (elm_widget_item_disabled_get(it))
3553 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
3555 edje_object_signal_emit(_it->edit_obj, "elm,state,disabled", "elm");
3559 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
3561 edje_object_signal_emit(_it->edit_obj, "elm,state,enabled", "elm");
3563 EINA_LIST_FOREACH(_it->content_objs, l, obj)
3564 elm_widget_disabled_set(obj, elm_widget_item_disabled_get(_it));
3569 _item_del_pre_hook(Elm_Object_Item *it)
3571 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3573 if ((_it->relcount > 0) || (_it->walking > 0))
3575 elm_genlist_item_subitems_clear(it);
3576 if (_it->wd->show_item == _it) _it->wd->show_item = NULL;
3577 _elm_genlist_item_del_notserious(_it);
3578 if (_it->item->block)
3580 if (_it->realized) _elm_genlist_item_unrealize(_it, EINA_FALSE);
3581 _it->item->block->changed = EINA_TRUE;
3582 if (_it->wd->calc_job) ecore_job_del(_it->wd->calc_job);
3583 _it->wd->calc_job = ecore_job_add(_calc_job, _it->wd);
3587 _it->parent->item->items =
3588 eina_list_remove(_it->parent->item->items, it);
3598 _elm_genlist_item_new(Widget_Data *wd,
3599 const Elm_Gen_Item_Class *itc,
3601 Elm_Gen_Item *parent,
3603 const void *func_data)
3607 it = elm_widget_item_new(wd->obj, Elm_Gen_Item);
3608 if (!it) return NULL;
3610 it->generation = wd->generation;
3612 elm_genlist_item_class_ref((Elm_Genlist_Item_Class *)itc);
3613 it->base.data = data;
3614 it->parent = parent;
3615 it->func.func = func;
3616 it->func.data = func_data;
3617 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
3618 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
3619 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
3620 elm_widget_item_text_get_hook_set(it, _item_text_hook);
3621 elm_widget_item_disable_hook_set(it, _item_disable_hook);
3622 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
3624 it->sel_cb = (Ecore_Cb)_item_select;
3629 static Elm_Gen_Item *
3630 _item_new(Widget_Data *wd,
3631 const Elm_Genlist_Item_Class *itc,
3633 Elm_Gen_Item *parent,
3634 Elm_Genlist_Item_Type type,
3636 const void *func_data)
3638 Elm_Gen_Item *it, *it2;
3641 it = _elm_genlist_item_new(wd, itc, data, parent, func, func_data);
3642 if (!it) return NULL;
3643 it->item = ELM_NEW(Elm_Gen_Item_Type);
3644 it->item->type = type;
3645 if (type & ELM_GENLIST_ITEM_GROUP) it->group++;
3646 it->item->expanded_depth = 0;
3647 ELM_GEN_ITEM_SETUP(it);
3650 if (it->parent->group)
3651 it->item->group_item = parent;
3652 else if (it->parent->item->group_item)
3653 it->item->group_item = it->parent->item->group_item;
3655 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
3657 if (!it2->parent->group) depth += 1;
3659 it->item->expanded_depth = depth;
3665 _item_block_new(Widget_Data *wd, Eina_Bool prepend)
3669 itb = calloc(1, sizeof(Item_Block));
3670 if (!itb) return NULL;
3674 wd->blocks = eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3675 _item_block_position_update(wd->blocks, 0);
3679 wd->blocks = eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3680 itb->position_update = EINA_TRUE;
3681 if (wd->blocks != EINA_INLIST_GET(itb))
3683 itb->position = ((Item_Block *) (EINA_INLIST_GET(itb)->prev))->position + 1;
3694 _item_block_add(Widget_Data *wd,
3697 Item_Block *itb = NULL;
3704 itb = calloc(1, sizeof(Item_Block));
3705 if (!itb) return EINA_FALSE;
3707 if (!it->item->rel->item->block)
3710 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3711 itb->items = eina_list_append(itb->items, it);
3712 itb->position_update = EINA_TRUE;
3713 it->position = eina_list_count(itb->items);
3714 it->position_update = EINA_TRUE;
3716 if (wd->blocks != EINA_INLIST_GET(itb))
3718 itb->position = ((Item_Block *) (EINA_INLIST_GET(itb)->prev))->position + 1;
3729 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3730 if (it->item->before)
3732 wd->blocks = eina_inlist_prepend_relative
3733 (wd->blocks, EINA_INLIST_GET(itb),
3734 EINA_INLIST_GET(it->item->rel->item->block));
3736 eina_list_prepend_relative_list(itb->items, it, tmp);
3738 /* Update index from where we prepended */
3739 _item_position_update(eina_list_prev(tmp), it->item->rel->position);
3740 _item_block_position_update(EINA_INLIST_GET(itb),
3741 it->item->rel->item->block->position);
3745 wd->blocks = eina_inlist_append_relative
3746 (wd->blocks, EINA_INLIST_GET(itb),
3747 EINA_INLIST_GET(it->item->rel->item->block));
3749 eina_list_append_relative_list(itb->items, it, tmp);
3751 /* Update block index from where we appended */
3752 _item_position_update(eina_list_next(tmp), it->item->rel->position + 1);
3753 _item_block_position_update(EINA_INLIST_GET(itb),
3754 it->item->rel->item->block->position + 1);
3760 if (it->item->before)
3764 itb = (Item_Block *)(wd->blocks);
3765 if (itb->count >= wd->max_items_per_block)
3767 itb = _item_block_new(wd, EINA_TRUE);
3768 if (!itb) return EINA_FALSE;
3773 itb = _item_block_new(wd, EINA_TRUE);
3774 if (!itb) return EINA_FALSE;
3776 itb->items = eina_list_prepend(itb->items, it);
3778 _item_position_update(itb->items, 0);
3784 itb = (Item_Block *)(wd->blocks->last);
3785 if (itb->count >= wd->max_items_per_block)
3787 itb = _item_block_new(wd, EINA_FALSE);
3788 if (!itb) return EINA_FALSE;
3793 itb = _item_block_new(wd, EINA_FALSE);
3794 if (!itb) return EINA_FALSE;
3796 itb->items = eina_list_append(itb->items, it);
3797 it->position = eina_list_count(itb->items);
3805 if (it->item->rel->item->queued)
3807 /* NOTE: for a strange reason eina_list and eina_inlist don't have the same property
3808 on sorted insertion order, so the queue is not always ordered like the item list.
3809 This lead to issue where we depend on an item that is not yet created. As a quick
3810 work around, we reschedule the calc of the item and stop reordering the list to
3811 prevent any nasty issue to show up here.
3813 wd->queue = eina_list_append(wd->queue, it);
3814 wd->requeued = EINA_TRUE;
3815 it->item->queued = EINA_TRUE;
3818 itb = it->item->rel->item->block;
3819 if (!itb) goto newblock;
3820 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3821 if (it->item->before)
3823 itb->items = eina_list_prepend_relative_list(itb->items, it, tmp);
3824 _item_position_update(eina_list_prev(tmp), it->item->rel->position);
3828 itb->items = eina_list_append_relative_list(itb->items, it, tmp);
3829 _item_position_update(eina_list_next(tmp), it->item->rel->position + 1);
3833 itb->changed = EINA_TRUE;
3834 it->item->block = itb;
3835 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3836 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3839 it->item->rel->relcount--;
3840 if ((it->item->rel->generation < it->wd->generation) && (!it->item->rel->relcount))
3842 _item_del(it->item->rel);
3843 elm_widget_item_free(it->item->rel);
3845 it->item->rel = NULL;
3847 if (itb->count > itb->wd->max_items_per_block)
3852 Eina_Bool done = EINA_FALSE;
3854 newc = itb->count / 2;
3856 if (EINA_INLIST_GET(itb)->prev)
3858 Item_Block *itbp = (Item_Block *)(EINA_INLIST_GET(itb)->prev);
3860 if (itbp->count + newc < wd->max_items_per_block / 2)
3862 /* moving items to previous block */
3863 while ((itb->count > newc) && (itb->items))
3865 it2 = eina_list_data_get(itb->items);
3866 itb->items = eina_list_remove_list(itb->items, itb->items);
3869 itbp->items = eina_list_append(itbp->items, it2);
3870 it2->item->block = itbp;
3878 if (!done && EINA_INLIST_GET(itb)->next)
3880 Item_Block *itbn = (Item_Block *)(EINA_INLIST_GET(itb)->next);
3882 if (itbn->count + newc < wd->max_items_per_block / 2)
3884 /* moving items to next block */
3885 while ((itb->count > newc) && (itb->items))
3889 l = eina_list_last(itb->items);
3890 it2 = eina_list_data_get(l);
3891 itb->items = eina_list_remove_list(itb->items, l);
3894 itbn->items = eina_list_prepend(itbn->items, it2);
3895 it2->item->block = itbn;
3905 /* moving items to new block */
3906 itb2 = calloc(1, sizeof(Item_Block));
3907 if (!itb2) return EINA_FALSE;
3910 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3911 EINA_INLIST_GET(itb));
3912 itb2->changed = EINA_TRUE;
3913 while ((itb->count > newc) && (itb->items))
3917 l = eina_list_last(itb->items);
3919 itb->items = eina_list_remove_list(itb->items, l);
3922 itb2->items = eina_list_prepend(itb2->items, it2);
3923 it2->item->block = itb2;
3933 _queue_process(Widget_Data *wd)
3936 Eina_Bool showme = EINA_FALSE;
3939 t0 = ecore_loop_time_get();
3940 //evas_event_freeze(evas_object_evas_get(wd->obj));
3941 for (n = 0; (wd->queue) && (n < 128); n++)
3945 it = eina_list_data_get(wd->queue);
3946 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3947 it->item->queued = EINA_FALSE;
3948 if (!_item_block_add(wd, it)) continue;
3950 _item_block_realize(it->item->block);
3951 t = ecore_time_get();
3952 if (it->item->block->changed)
3954 showme = _item_block_recalc(it->item->block, it->item->block->num, EINA_TRUE);
3955 it->item->block->changed = 0;
3956 if (wd->pan_changed)
3958 if (wd->calc_job) ecore_job_del(wd->calc_job);
3959 wd->calc_job = NULL;
3961 wd->pan_changed = EINA_FALSE;
3964 if (showme) it->item->block->showme = EINA_TRUE;
3965 /* same as eina_inlist_count > 1 */
3966 if (wd->blocks && wd->blocks->next)
3968 if ((t - t0) > (ecore_animator_frametime_get())) break;
3971 //evas_event_thaw(evas_object_evas_get(wd->obj));
3972 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3977 _idle_process(void *data, Eina_Bool *wakeup)
3979 Widget_Data *wd = data;
3982 //static double q_start = 0.0;
3983 //if (q_start == 0.0) q_start = ecore_time_get();
3985 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3989 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3991 return ECORE_CALLBACK_CANCEL;
3993 return ECORE_CALLBACK_RENEW;
3997 _item_idle_enterer(void *data)
3999 Widget_Data *wd = data;
4000 Eina_Bool wakeup = EINA_FALSE;
4001 Eina_Bool ok = _idle_process(data, &wakeup);
4006 if (wd->calc_job) ecore_job_del(wd->calc_job);
4007 wd->calc_job = ecore_job_add(_calc_job, wd);
4009 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
4014 _item_queue(Widget_Data *wd,
4018 if (it->item->queued) return;
4019 it->item->queued = EINA_TRUE;
4020 if (cb && !wd->requeued)
4021 wd->queue = eina_list_sorted_insert(wd->queue, cb, it);
4023 wd->queue = eina_list_append(wd->queue, it);
4024 // FIXME: why does a freeze then thaw here cause some genlist
4025 // elm_genlist_item_append() to be much much slower?
4026 // evas_event_freeze(evas_object_evas_get(wd->obj));
4027 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
4029 if (wd->queue_idle_enterer)
4031 ecore_idle_enterer_del(wd->queue_idle_enterer);
4032 wd->queue_idle_enterer = NULL;
4036 // evas_event_thaw(evas_object_evas_get(wd->obj));
4037 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4038 if (!wd->queue_idle_enterer)
4039 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
4043 _elm_genlist_item_compare(const void *data, const void *data1)
4045 const Elm_Gen_Item *it, *item1;
4046 it = ELM_GEN_ITEM_FROM_INLIST(data);
4047 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
4048 return it->wd->item_compare_cb(it, item1);
4052 _elm_genlist_item_list_compare(const void *data, const void *data1)
4054 const Elm_Gen_Item *it = data;
4055 const Elm_Gen_Item *item1 = data1;
4056 return it->wd->item_compare_cb(it, item1);
4060 _item_move_after(Elm_Gen_Item *it, Elm_Gen_Item *after)
4065 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4066 _item_block_del(it);
4068 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
4069 it->item->rel = after;
4070 it->item->rel->relcount++;
4071 it->item->before = EINA_FALSE;
4072 if (after->item->group_item) it->item->group_item = after->item->group_item;
4073 _item_queue(it->wd, it, NULL);
4075 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
4079 _item_move_before(Elm_Gen_Item *it, Elm_Gen_Item *before)
4082 if (!before) return;
4084 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4085 _item_block_del(it);
4086 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
4087 it->item->rel = before;
4088 it->item->rel->relcount++;
4089 it->item->before = EINA_TRUE;
4090 if (before->item->group_item) it->item->group_item = before->item->group_item;
4091 _item_queue(it->wd, it, NULL);
4093 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
4097 elm_genlist_items_count(const Evas_Object *obj)
4099 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4100 Widget_Data *wd = elm_widget_data_get(obj);
4102 return wd->item_count;
4105 EAPI Elm_Object_Item *
4106 elm_genlist_item_append(Evas_Object *obj,
4107 const Elm_Genlist_Item_Class *itc,
4109 Elm_Object_Item *parent,
4110 Elm_Genlist_Item_Type type,
4112 const void *func_data)
4114 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4115 Widget_Data *wd = elm_widget_data_get(obj);
4116 if (!wd) return NULL;
4117 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4119 if (!it) return NULL;
4123 wd->group_items = eina_list_append(wd->group_items, it);
4124 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
4125 it->item->rel = NULL;
4129 Elm_Gen_Item *it2 = NULL;
4130 Eina_List *ll = eina_list_last(it->parent->item->items);
4131 if (ll) it2 = ll->data;
4132 it->parent->item->items = eina_list_append(it->parent->item->items, it);
4133 if (!it2) it2 = it->parent;
4135 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
4136 EINA_INLIST_GET(it2));
4137 it->item->rel = it2;
4138 it->item->rel->relcount++;
4140 it->item->before = EINA_FALSE;
4141 _item_queue(wd, it, NULL);
4142 return (Elm_Object_Item *)it;
4145 EAPI Elm_Object_Item *
4146 elm_genlist_item_prepend(Evas_Object *obj,
4147 const Elm_Genlist_Item_Class *itc,
4149 Elm_Object_Item *parent,
4150 Elm_Genlist_Item_Type type,
4152 const void *func_data)
4154 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4155 Widget_Data *wd = elm_widget_data_get(obj);
4156 if (!wd) return NULL;
4157 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4159 if (!it) return NULL;
4163 wd->group_items = eina_list_prepend(wd->group_items, it);
4164 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
4165 it->item->rel = NULL;
4169 Elm_Gen_Item *it2 = NULL;
4170 Eina_List *ll = it->parent->item->items;
4171 if (ll) it2 = ll->data;
4172 it->parent->item->items = eina_list_prepend(it->parent->item->items, it);
4173 if (!it2) it2 = it->parent;
4175 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4176 EINA_INLIST_GET(it2));
4177 it->item->rel = it2;
4178 it->item->rel->relcount++;
4180 it->item->before = EINA_TRUE;
4181 _item_queue(wd, it, NULL);
4182 return (Elm_Object_Item *)it;
4185 EAPI Elm_Object_Item *
4186 elm_genlist_item_insert_after(Evas_Object *obj,
4187 const Elm_Genlist_Item_Class *itc,
4189 Elm_Object_Item *parent,
4190 Elm_Object_Item *after,
4191 Elm_Genlist_Item_Type type,
4193 const void *func_data)
4195 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4196 ELM_OBJ_ITEM_CHECK_OR_RETURN(after, NULL);
4197 Widget_Data *wd = elm_widget_data_get(obj);
4198 Elm_Gen_Item *_after = (Elm_Gen_Item *) after;
4199 if (!wd) return NULL;
4200 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
4201 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4203 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4205 if (!it) return NULL;
4208 if ((it->group) && (_after->group))
4209 wd->group_items = eina_list_append_relative(wd->group_items, it,
4214 it->parent->item->items =
4215 eina_list_append_relative(it->parent->item->items, it, _after);
4217 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
4218 EINA_INLIST_GET(_after));
4219 it->item->rel = _after;
4220 it->item->rel->relcount++;
4221 it->item->before = EINA_FALSE;
4222 _item_queue(wd, it, NULL);
4223 return (Elm_Object_Item *)it;
4226 EAPI Elm_Object_Item *
4227 elm_genlist_item_insert_before(Evas_Object *obj,
4228 const Elm_Genlist_Item_Class *itc,
4230 Elm_Object_Item *parent,
4231 Elm_Object_Item *before,
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(before, NULL);
4238 Widget_Data *wd = elm_widget_data_get(obj);
4239 Elm_Gen_Item *_before = (Elm_Gen_Item *) before;
4240 if (!wd) return NULL;
4241 /* It makes no sense to insert before in an empty list with before != 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 && _before->group)
4250 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
4255 it->parent->item->items =
4256 eina_list_prepend_relative(it->parent->item->items, it, _before);
4258 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4259 EINA_INLIST_GET(_before));
4260 it->item->rel = _before;
4261 it->item->rel->relcount++;
4262 it->item->before = EINA_TRUE;
4263 _item_queue(wd, it, NULL);
4264 return (Elm_Object_Item *)it;
4267 EAPI Elm_Object_Item *
4268 elm_genlist_item_sorted_insert(Evas_Object *obj,
4269 const Elm_Genlist_Item_Class *itc,
4271 Elm_Object_Item *parent,
4272 Elm_Genlist_Item_Type type,
4273 Eina_Compare_Cb comp,
4275 const void *func_data)
4277 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4278 Widget_Data *wd = elm_widget_data_get(obj);
4279 if (!wd) return NULL;
4280 Elm_Gen_Item *rel = NULL;
4281 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4283 if (!it) return NULL;
4285 wd->item_compare_cb = comp;
4292 l = eina_list_search_sorted_near_list(it->parent->item->items,
4293 _elm_genlist_item_list_compare,
4297 rel = eina_list_data_get(l);
4301 if (cmp_result >= 0)
4303 it->parent->item->items = eina_list_prepend_relative_list(it->parent->item->items, it, l);
4304 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
4305 it->item->before = EINA_FALSE;
4307 else if (cmp_result < 0)
4309 it->parent->item->items = eina_list_append_relative_list(it->parent->item->items, it, l);
4310 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
4311 it->item->before = EINA_TRUE;
4318 wd->state = eina_inlist_sorted_state_new();
4319 eina_inlist_sorted_state_init(wd->state, wd->items);
4320 wd->requeued = EINA_FALSE;
4324 wd->group_items = eina_list_append(wd->group_items, it);
4326 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
4327 _elm_genlist_item_compare, wd->state);
4329 if (EINA_INLIST_GET(it)->next)
4331 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4332 it->item->before = EINA_TRUE;
4334 else if (EINA_INLIST_GET(it)->prev)
4336 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4337 it->item->before = EINA_FALSE;
4343 it->item->rel = rel;
4344 it->item->rel->relcount++;
4347 _item_queue(wd, it, _elm_genlist_item_list_compare);
4349 return (Elm_Object_Item *)it;
4353 _elm_genlist_clear(Evas_Object *obj, Eina_Bool standby)
4355 Eina_Inlist *next, *l;
4357 ELM_CHECK_WIDTYPE(obj, widtype);
4358 Widget_Data *wd = elm_widget_data_get(obj);
4361 if (!standby) wd->generation++;
4365 eina_inlist_sorted_state_free(wd->state);
4369 if (wd->walking > 0)
4371 wd->clear_me = EINA_TRUE;
4374 evas_event_freeze(evas_object_evas_get(wd->obj));
4375 for (l = wd->items, next = l ? l->next : NULL;
4377 l = next, next = next ? next->next : NULL)
4379 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(l);
4381 if (it->generation < wd->generation)
4383 Elm_Gen_Item *itn = NULL;
4385 if (next) itn = ELM_GEN_ITEM_FROM_INLIST(next);
4386 if (itn) itn->walking++; /* prevent early death of subitem */
4388 elm_widget_item_free(it);
4389 if (itn) itn->walking--;
4392 wd->clear_me = EINA_FALSE;
4393 wd->pan_changed = EINA_TRUE;
4396 ecore_job_del(wd->calc_job);
4397 wd->calc_job = NULL;
4399 if (wd->selected) wd->selected = eina_list_free(wd->selected);
4400 if (wd->clear_cb) wd->clear_cb(wd);
4407 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4408 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4410 if (wd->sizing_cb) wd->sizing_cb(wd->obj);
4411 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
4412 evas_event_thaw(evas_object_evas_get(wd->obj));
4413 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4417 elm_genlist_clear(Evas_Object *obj)
4419 _elm_genlist_clear(obj, EINA_FALSE);
4423 elm_genlist_multi_select_set(Evas_Object *obj,
4426 ELM_CHECK_WIDTYPE(obj, widtype);
4427 Widget_Data *wd = elm_widget_data_get(obj);
4429 wd->multi = !!multi;
4433 elm_genlist_multi_select_get(const Evas_Object *obj)
4435 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4436 Widget_Data *wd = elm_widget_data_get(obj);
4437 if (!wd) return EINA_FALSE;
4441 EAPI Elm_Object_Item *
4442 elm_genlist_selected_item_get(const Evas_Object *obj)
4444 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4445 Widget_Data *wd = elm_widget_data_get(obj);
4446 if (!wd) return NULL;
4447 if (wd->selected) return wd->selected->data;
4451 EAPI const Eina_List *
4452 elm_genlist_selected_items_get(const Evas_Object *obj)
4454 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4455 Widget_Data *wd = elm_widget_data_get(obj);
4456 if (!wd) return NULL;
4457 return wd->selected;
4461 elm_genlist_realized_items_get(const Evas_Object *obj)
4463 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4464 Widget_Data *wd = elm_widget_data_get(obj);
4465 Eina_List *list = NULL;
4467 Eina_Bool done = EINA_FALSE;
4468 if (!wd) return NULL;
4469 EINA_INLIST_FOREACH(wd->blocks, itb)
4477 EINA_LIST_FOREACH(itb->items, l, it)
4479 if (it->realized) list = eina_list_append(list, it);
4490 EAPI Elm_Object_Item *
4491 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4496 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4497 Widget_Data *wd = elm_widget_data_get(obj);
4498 Evas_Coord ox, oy, ow, oh;
4501 if (!wd) return NULL;
4502 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4504 EINA_INLIST_FOREACH(wd->blocks, itb)
4509 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4510 oy + itb->y - itb->wd->pan_y,
4511 itb->w, itb->h, x, y, 1, 1))
4513 EINA_LIST_FOREACH(itb->items, l, it)
4515 Evas_Coord itx, ity;
4517 itx = ox + itb->x + it->x - itb->wd->pan_x;
4518 ity = oy + itb->y + it->y - itb->wd->pan_y;
4519 if (ELM_RECTS_INTERSECT(itx, ity, it->item->w, it->item->h, x, y, 1, 1))
4523 if (y <= (ity + (it->item->h / 4))) *posret = -1;
4524 else if (y >= (ity + it->item->h - (it->item->h / 4)))
4528 return (Elm_Object_Item *)it;
4530 lasty = ity + it->item->h;
4535 if (y > lasty) *posret = 1;
4541 EAPI Elm_Object_Item *
4542 elm_genlist_first_item_get(const Evas_Object *obj)
4544 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4545 Widget_Data *wd = elm_widget_data_get(obj);
4546 if (!wd) return NULL;
4547 if (!wd->items) return NULL;
4548 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
4549 while ((it) && (it->generation < wd->generation))
4550 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4551 return (Elm_Object_Item *)it;
4554 EAPI Elm_Object_Item *
4555 elm_genlist_last_item_get(const Evas_Object *obj)
4557 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4558 Widget_Data *wd = elm_widget_data_get(obj);
4559 if (!wd) return NULL;
4560 if (!wd->items) return NULL;
4561 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
4562 while ((it) && (it->generation < wd->generation))
4563 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4564 return (Elm_Object_Item *)it;
4567 EAPI Elm_Object_Item *
4568 elm_genlist_item_next_get(const Elm_Object_Item *it)
4570 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4571 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4574 _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->next);
4575 if ((_it) && (_it->generation == _it->wd->generation)) break;
4577 return (Elm_Object_Item *) _it;
4580 EAPI Elm_Object_Item *
4581 elm_genlist_item_prev_get(const Elm_Object_Item *it)
4583 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4584 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4587 _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->prev);
4588 if ((_it) && (_it->generation == _it->wd->generation)) break;
4590 return (Elm_Object_Item *) _it;
4593 EAPI Elm_Object_Item *
4594 elm_genlist_item_parent_get(const Elm_Object_Item *it)
4596 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4597 return (Elm_Object_Item *) ((Elm_Gen_Item *)it)->parent;
4601 elm_genlist_item_subitems_clear(Elm_Object_Item *it)
4603 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4604 Eina_List *tl = NULL, *l;
4606 Elm_Object_Item *it2;
4607 _it = (Elm_Gen_Item *)it;
4609 EINA_LIST_FOREACH(_it->item->items, l, it2)
4610 tl = eina_list_append(tl, it2);
4611 EINA_LIST_FREE(tl, it2)
4612 elm_object_item_del(it2);
4616 elm_genlist_item_selected_set(Elm_Object_Item *it,
4619 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4620 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4621 Widget_Data *wd = _it->wd;
4623 if ((_it->generation < wd->generation) || elm_widget_item_disabled_get(_it))
4625 selected = !!selected;
4626 if (_it->selected == selected) return;
4632 while (wd->selected)
4634 if (_it->unhighlight_cb) _it->unhighlight_cb(wd->selected->data);
4635 _it->unsel_cb(wd->selected->data);
4638 _it->highlight_cb(_it);
4642 if (_it->unhighlight_cb) _it->unhighlight_cb(_it);
4647 elm_genlist_item_selected_get(const Elm_Object_Item *it)
4649 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4650 return ((Elm_Gen_Item *)it)->selected;
4654 elm_genlist_item_expanded_set(Elm_Object_Item *it,
4657 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4658 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4659 expanded = !!expanded;
4660 if (_it->item->expanded == expanded) return;
4661 _it->item->expanded = expanded;
4662 if (_it->item->expanded)
4665 edje_object_signal_emit(VIEW(_it), "elm,state,expanded", "elm");
4666 evas_object_smart_callback_call(WIDGET(_it), SIG_EXPANDED, _it);
4667 _it->wd->auto_scroll_enabled = EINA_TRUE;
4668 _it->wd->expanded_item = _it;
4673 edje_object_signal_emit(VIEW(_it), "elm,state,contracted", "elm");
4674 evas_object_smart_callback_call(WIDGET(_it), SIG_CONTRACTED, _it);
4675 _it->wd->auto_scroll_enabled = EINA_FALSE;
4676 _it->wd->expanded_item = NULL;
4681 elm_genlist_item_expanded_get(const Elm_Object_Item *it)
4683 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4684 return ((Elm_Gen_Item *)it)->item->expanded;
4688 elm_genlist_item_expanded_depth_get(const Elm_Object_Item *it)
4690 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, 0);
4691 return ((Elm_Gen_Item *)it)->item->expanded_depth;
4695 elm_genlist_item_display_only_set(Elm_Object_Item *it,
4696 Eina_Bool display_only)
4698 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4699 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4700 display_only = !!display_only;
4701 if (_it->display_only == display_only) return;
4702 if (_it->generation < _it->wd->generation) return;
4703 _it->display_only = display_only;
4704 _it->item->mincalcd = EINA_FALSE;
4705 _it->item->updateme = EINA_TRUE;
4706 if (_it->item->block) _it->item->block->updateme = EINA_TRUE;
4707 if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
4708 _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
4712 elm_genlist_item_display_only_get(const Elm_Object_Item *it)
4714 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4715 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4716 if (_it->generation < _it->wd->generation) return EINA_FALSE;
4717 return _it->display_only;
4721 elm_genlist_item_show(Elm_Object_Item *it)
4723 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4724 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4725 Evas_Coord gith = 0;
4726 if (_it->generation < _it->wd->generation) return;
4727 if ((_it->item->queued) || (!_it->item->mincalcd))
4729 _it->wd->show_item = _it;
4730 _it->wd->bring_in = EINA_FALSE;
4731 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
4732 _it->item->showme = EINA_TRUE;
4735 if (_it->wd->show_item)
4737 _it->wd->show_item->item->showme = EINA_FALSE;
4738 _it->wd->show_item = NULL;
4740 if ((_it->item->group_item) &&
4741 (_it->wd->pan_y > (_it->y + _it->item->block->y)))
4742 gith = _it->item->group_item->item->h;
4743 elm_smart_scroller_child_region_show(_it->wd->scr,
4744 _it->x + _it->item->block->x,
4745 _it->y + _it->item->block->y - gith,
4746 _it->item->block->w, _it->item->h);
4750 elm_genlist_item_promote(Elm_Object_Item *it)
4752 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4753 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4754 if (_it->generation < _it->wd->generation) return;
4755 _item_move_before(_it,
4756 (Elm_Gen_Item *) elm_genlist_first_item_get(WIDGET(_it)));
4760 elm_genlist_item_demote(Elm_Object_Item *it)
4762 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4763 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4764 if (_it->generation < _it->wd->generation) return;
4765 _item_move_after(_it,
4766 (Elm_Gen_Item *) elm_genlist_last_item_get(WIDGET(_it)));
4770 elm_genlist_item_bring_in(Elm_Object_Item *it, Elm_Genlist_Item_Scrollto_Type type)
4773 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4774 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4775 Evas_Coord x, y, w, h;
4776 Evas_Coord gith = 0;
4777 if (_it->generation < _it->wd->generation) return;
4778 if ((_it->item->queued) || (!_it->item->mincalcd))
4780 _it->wd->show_item = _it;
4781 _it->wd->bring_in = EINA_TRUE;
4782 _it->wd->scrollto_type = type;
4783 _it->item->showme = EINA_TRUE;
4786 if (_it->wd->show_item)
4788 _it->wd->show_item->item->showme = EINA_FALSE;
4789 _it->wd->show_item = NULL;
4792 x = _it->x + _it->item->block->x;
4793 if (type==ELM_GENLIST_ITEM_SCROLLTO_IN)
4795 if ((_it->item->group_item) &&
4796 (_it->wd->pan_y > (_it->y + _it->item->block->y)))
4797 gith = _it->item->group_item->item->h;
4799 w = _it->item->block->w;
4801 y = _it->y + _it->item->block->y - gith;
4803 else if (type==ELM_GENLIST_ITEM_SCROLLTO_TOP)
4805 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &w, &h);
4806 if (_it->item->group_item) gith = _it->item->group_item->item->h;
4807 y = _it->y + _it->item->block->y - gith;
4809 else if (type==ELM_GENLIST_ITEM_SCROLLTO_MIDDLE)
4811 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &w, &h);
4812 w = _it->item->block->w;
4813 y = _it->y + _it->item->block->y - h / 2 + _it->item->h / 2;
4818 elm_smart_scroller_region_bring_in(_it->wd->scr,x, y, w, h);
4822 elm_genlist_item_top_show(Elm_Object_Item *it)
4824 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4825 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4827 Evas_Coord gith = 0;
4829 if (_it->generation < _it->wd->generation) return;
4830 if ((_it->item->queued) || (!_it->item->mincalcd))
4832 _it->wd->show_item = _it;
4833 _it->wd->bring_in = EINA_FALSE;
4834 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_TOP;
4835 _it->item->showme = EINA_TRUE;
4838 if (_it->wd->show_item)
4840 _it->wd->show_item->item->showme = EINA_FALSE;
4841 _it->wd->show_item = NULL;
4843 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4844 if (_it->item->group_item) gith = _it->item->group_item->item->h;
4845 elm_smart_scroller_child_region_show(_it->wd->scr,
4846 _it->x + _it->item->block->x,
4847 _it->y + _it->item->block->y - gith,
4848 _it->item->block->w, oh);
4852 elm_genlist_item_top_bring_in(Elm_Object_Item *it)
4854 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_TOP);
4858 elm_genlist_item_middle_show(Elm_Object_Item *it)
4860 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4861 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4864 if (_it->generation < _it->wd->generation) return;
4865 if ((_it->item->queued) || (!_it->item->mincalcd))
4867 _it->wd->show_item = _it;
4868 _it->wd->bring_in = EINA_FALSE;
4869 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_MIDDLE;
4870 _it->item->showme = EINA_TRUE;
4873 if (_it->wd->show_item)
4875 _it->wd->show_item->item->showme = EINA_FALSE;
4876 _it->wd->show_item = NULL;
4878 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4879 elm_smart_scroller_child_region_show(_it->wd->scr,
4880 _it->x + _it->item->block->x,
4881 _it->y + _it->item->block->y - oh / 2 +
4882 _it->item->h / 2, _it->item->block->w,
4887 elm_genlist_item_middle_bring_in(Elm_Object_Item *it)
4889 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
4892 EINA_DEPRECATED EAPI void
4893 elm_genlist_item_contents_orphan(Elm_Object_Item *it)
4895 elm_genlist_item_all_contents_unset(it, NULL);
4899 elm_genlist_item_all_contents_unset(Elm_Object_Item *it, Eina_List **l)
4901 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4903 Evas_Object *content;
4904 EINA_LIST_FREE(((Elm_Gen_Item *)it)->content_objs, content)
4906 elm_widget_sub_object_del(WIDGET(it), content);
4907 evas_object_smart_member_del(content);
4908 evas_object_hide(content);
4910 *l = eina_list_append(*l, content);
4914 EINA_DEPRECATED EAPI const Evas_Object *
4915 elm_genlist_item_object_get(const Elm_Object_Item *it)
4917 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4922 elm_genlist_item_update(Elm_Object_Item *it)
4924 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4925 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4927 if (!_it->item->block) return;
4928 if (_it->generation < _it->wd->generation) return;
4929 _it->item->mincalcd = EINA_FALSE;
4930 _it->item->updateme = EINA_TRUE;
4931 _it->item->block->updateme = EINA_TRUE;
4932 if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
4933 _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
4937 elm_genlist_item_fields_update(Elm_Object_Item *it,
4939 Elm_Genlist_Item_Field_Type itf)
4941 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4942 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4944 if (!_it->item->block) return;
4945 if (_it->generation < _it->wd->generation) return;
4947 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_TEXT))
4948 _item_text_realize(_it, VIEW(_it), &_it->texts, parts);
4949 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_CONTENT))
4951 _it->content_objs = _item_content_unrealize(_it, VIEW(_it),
4952 &_it->contents, parts);
4953 _it->content_objs = _item_content_realize(_it, VIEW(_it),
4954 &_it->contents, parts);
4956 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
4957 _item_state_realize(_it, VIEW(_it), &_it->states, parts);
4961 elm_genlist_item_item_class_update(Elm_Object_Item *it,
4962 const Elm_Genlist_Item_Class *itc)
4964 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4965 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4967 if (!_it->item->block) return;
4968 EINA_SAFETY_ON_NULL_RETURN(itc);
4969 if (_it->generation < _it->wd->generation) return;
4971 _it->item->nocache_once = EINA_TRUE;
4972 elm_genlist_item_update(it);
4975 EAPI const Elm_Genlist_Item_Class *
4976 elm_genlist_item_item_class_get(const Elm_Object_Item *it)
4978 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4979 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4980 if (_it->generation < _it->wd->generation) return NULL;
4984 static Evas_Object *
4985 _elm_genlist_item_label_create(void *data,
4986 Evas_Object *obj __UNUSED__,
4987 Evas_Object *tooltip,
4988 void *it __UNUSED__)
4990 Evas_Object *label = elm_label_add(tooltip);
4993 elm_object_style_set(label, "tooltip");
4994 elm_object_text_set(label, data);
4999 _elm_genlist_item_label_del_cb(void *data,
5000 Evas_Object *obj __UNUSED__,
5001 void *event_info __UNUSED__)
5003 eina_stringshare_del(data);
5007 elm_genlist_item_tooltip_text_set(Elm_Object_Item *it,
5010 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5011 text = eina_stringshare_add(text);
5012 elm_genlist_item_tooltip_content_cb_set(it, _elm_genlist_item_label_create,
5014 _elm_genlist_item_label_del_cb);
5018 elm_genlist_item_tooltip_content_cb_set(Elm_Object_Item *it,
5019 Elm_Tooltip_Item_Content_Cb func,
5021 Evas_Smart_Cb del_cb)
5023 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
5024 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5026 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
5029 if (_it->tooltip.del_cb)
5030 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(it), it);
5032 _it->tooltip.content_cb = func;
5033 _it->tooltip.data = data;
5034 _it->tooltip.del_cb = del_cb;
5038 elm_widget_item_tooltip_content_cb_set(_it,
5039 _it->tooltip.content_cb,
5040 _it->tooltip.data, NULL);
5041 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
5042 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
5048 if (del_cb) del_cb((void *)data, NULL, NULL);
5052 elm_genlist_item_tooltip_unset(Elm_Object_Item *it)
5054 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5055 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5057 if ((VIEW(_it)) && (_it->tooltip.content_cb))
5058 elm_widget_item_tooltip_unset(_it);
5060 if (_it->tooltip.del_cb)
5061 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
5062 _it->tooltip.del_cb = NULL;
5063 _it->tooltip.content_cb = NULL;
5064 _it->tooltip.data = NULL;
5065 _it->tooltip.free_size = EINA_FALSE;
5066 if (_it->tooltip.style)
5067 elm_genlist_item_tooltip_style_set(it, NULL);
5071 elm_genlist_item_tooltip_style_set(Elm_Object_Item *it,
5074 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5075 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5077 eina_stringshare_replace(&_it->tooltip.style, style);
5078 if (VIEW(_it)) elm_widget_item_tooltip_style_set(_it, style);
5082 elm_genlist_item_tooltip_style_get(const Elm_Object_Item *it)
5084 return elm_object_item_tooltip_style_get(it);
5088 elm_genlist_item_tooltip_window_mode_set(Elm_Object_Item *it,
5091 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
5092 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5094 _it->tooltip.free_size = disable;
5095 if (VIEW(_it)) return elm_widget_item_tooltip_window_mode_set(_it, disable);
5100 elm_genlist_item_tooltip_window_mode_get(const Elm_Object_Item *it)
5102 return elm_object_tooltip_window_mode_get(VIEW(it));
5106 elm_genlist_item_cursor_set(Elm_Object_Item *it,
5109 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5110 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5111 eina_stringshare_replace(&_it->mouse_cursor, cursor);
5112 if (VIEW(_it)) elm_widget_item_cursor_set(_it, cursor);
5116 elm_genlist_item_cursor_get(const Elm_Object_Item *it)
5118 return elm_widget_item_cursor_get(it);
5122 elm_genlist_item_cursor_unset(Elm_Object_Item *it)
5124 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5125 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5127 if (!_it->mouse_cursor) return;
5129 if (VIEW(_it)) elm_widget_item_cursor_unset(_it);
5131 eina_stringshare_del(_it->mouse_cursor);
5132 _it->mouse_cursor = NULL;
5136 elm_genlist_item_cursor_style_set(Elm_Object_Item *it,
5139 elm_widget_item_cursor_style_set(it, style);
5143 elm_genlist_item_cursor_style_get(const Elm_Object_Item *it)
5145 return elm_widget_item_cursor_style_get(it);
5149 elm_genlist_item_cursor_engine_only_set(Elm_Object_Item *it,
5150 Eina_Bool engine_only)
5152 elm_widget_item_cursor_engine_only_set(it, engine_only);
5156 elm_genlist_item_cursor_engine_only_get(const Elm_Object_Item *it)
5158 return elm_widget_item_cursor_engine_only_get(it);
5162 elm_genlist_item_index_get(const Elm_Object_Item *it)
5164 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, -1);
5165 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5167 if (_it->item->block)
5168 return _it->position + _it->item->block->position;
5173 elm_genlist_mode_set(Evas_Object *obj,
5176 ELM_CHECK_WIDTYPE(obj, widtype);
5177 Widget_Data *wd = elm_widget_data_get(obj);
5179 if (wd->mode == mode) return;
5186 elm_genlist_mode_get(const Evas_Object *obj)
5188 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5189 Widget_Data *wd = elm_widget_data_get(obj);
5190 if (!wd) return ELM_LIST_LAST;
5195 elm_genlist_always_select_mode_set(Evas_Object *obj,
5196 Eina_Bool always_select)
5198 ELM_CHECK_WIDTYPE(obj, widtype);
5199 Widget_Data *wd = elm_widget_data_get(obj);
5201 wd->always_select = !!always_select;
5205 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5207 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5208 Widget_Data *wd = elm_widget_data_get(obj);
5209 if (!wd) return EINA_FALSE;
5210 return wd->always_select;
5214 elm_genlist_no_select_mode_set(Evas_Object *obj,
5215 Eina_Bool no_select)
5217 ELM_CHECK_WIDTYPE(obj, widtype);
5218 Widget_Data *wd = elm_widget_data_get(obj);
5220 wd->no_select = !!no_select;
5224 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5226 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5227 Widget_Data *wd = elm_widget_data_get(obj);
5228 if (!wd) return EINA_FALSE;
5229 return wd->no_select;
5233 elm_genlist_compress_mode_set(Evas_Object *obj,
5236 ELM_CHECK_WIDTYPE(obj, widtype);
5237 Widget_Data *wd = elm_widget_data_get(obj);
5239 wd->compress = !!compress;
5240 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
5244 elm_genlist_compress_mode_get(const Evas_Object *obj)
5246 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5247 Widget_Data *wd = elm_widget_data_get(obj);
5248 if (!wd) return EINA_FALSE;
5249 return wd->compress;
5253 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5254 Eina_Bool height_for_width)
5256 ELM_CHECK_WIDTYPE(obj, widtype);
5257 Widget_Data *wd = elm_widget_data_get(obj);
5259 wd->height_for_width = !!height_for_width;
5260 if (wd->height_for_width)
5262 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5263 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5268 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5270 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5271 Widget_Data *wd = elm_widget_data_get(obj);
5272 if (!wd) return EINA_FALSE;
5273 return wd->height_for_width;
5277 elm_genlist_bounce_set(Evas_Object *obj,
5281 ELM_CHECK_WIDTYPE(obj, widtype);
5282 Widget_Data *wd = elm_widget_data_get(obj);
5284 wd->h_bounce = !!h_bounce;
5285 wd->v_bounce = !!v_bounce;
5286 elm_smart_scroller_bounce_allow_set(wd->scr, wd->h_bounce, wd->v_bounce);
5290 elm_genlist_bounce_get(const Evas_Object *obj,
5291 Eina_Bool *h_bounce,
5292 Eina_Bool *v_bounce)
5294 ELM_CHECK_WIDTYPE(obj, widtype);
5295 Widget_Data *wd = elm_widget_data_get(obj);
5297 if (h_bounce) *h_bounce = wd->h_bounce;
5298 if (v_bounce) *v_bounce = wd->v_bounce;
5302 elm_genlist_homogeneous_set(Evas_Object *obj,
5303 Eina_Bool homogeneous)
5305 ELM_CHECK_WIDTYPE(obj, widtype);
5306 Widget_Data *wd = elm_widget_data_get(obj);
5308 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5309 wd->homogeneous = !!homogeneous;
5313 elm_genlist_homogeneous_get(const Evas_Object *obj)
5315 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5316 Widget_Data *wd = elm_widget_data_get(obj);
5317 if (!wd) return EINA_FALSE;
5318 return wd->homogeneous;
5322 elm_genlist_block_count_set(Evas_Object *obj,
5325 ELM_CHECK_WIDTYPE(obj, widtype);
5326 Widget_Data *wd = elm_widget_data_get(obj);
5328 wd->max_items_per_block = count;
5329 wd->item_cache_max = wd->max_items_per_block * 2;
5330 _item_cache_clean(wd);
5334 elm_genlist_block_count_get(const Evas_Object *obj)
5336 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5337 Widget_Data *wd = elm_widget_data_get(obj);
5339 return wd->max_items_per_block;
5343 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5346 ELM_CHECK_WIDTYPE(obj, widtype);
5347 Widget_Data *wd = elm_widget_data_get(obj);
5349 wd->longpress_timeout = timeout;
5353 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5355 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5356 Widget_Data *wd = elm_widget_data_get(obj);
5358 return wd->longpress_timeout;
5362 elm_genlist_scroller_policy_set(Evas_Object *obj,
5363 Elm_Scroller_Policy policy_h,
5364 Elm_Scroller_Policy policy_v)
5366 ELM_CHECK_WIDTYPE(obj, widtype);
5367 Widget_Data *wd = elm_widget_data_get(obj);
5368 if ((!wd) || (!wd->scr)) return;
5369 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5370 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5372 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5376 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5377 Elm_Scroller_Policy *policy_h,
5378 Elm_Scroller_Policy *policy_v)
5380 ELM_CHECK_WIDTYPE(obj, widtype);
5381 Widget_Data *wd = elm_widget_data_get(obj);
5382 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5383 if ((!wd) || (!wd->scr)) return;
5384 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5385 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5386 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5390 elm_genlist_realized_items_update(Evas_Object *obj)
5392 ELM_CHECK_WIDTYPE(obj, widtype);
5394 Eina_List *list, *l;
5395 Elm_Object_Item *it;
5397 list = elm_genlist_realized_items_get(obj);
5398 EINA_LIST_FOREACH(list, l, it)
5399 elm_genlist_item_update(it);
5403 elm_genlist_item_mode_set(Elm_Object_Item *it,
5404 const char *mode_type,
5407 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5408 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5410 Widget_Data *wd = _it->wd;
5412 Elm_Object_Item *it2;
5415 if (!mode_type) return;
5416 if ((_it->generation < _it->wd->generation) ||
5417 elm_widget_item_disabled_get(_it)) return;
5418 if (wd->edit_mode) return;
5420 if ((wd->mode_item == _it) &&
5421 (!strcmp(mode_type, wd->mode_type)) &&
5424 if (!_it->itc->mode_item_style) return;
5425 _it->mode_set = mode_set;
5429 EINA_LIST_FOREACH(wd->selected, l, it2)
5430 if (((Elm_Gen_Item *)it2)->realized)
5431 elm_genlist_item_selected_set(it2, EINA_FALSE);
5435 it2 = elm_genlist_selected_item_get(wd->obj);
5436 if ((it2) && (((Elm_Gen_Item *)it2)->realized))
5437 elm_genlist_item_selected_set(it2, EINA_FALSE);
5440 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5442 ((_it == wd->mode_item) && (!mode_set)))
5443 _item_mode_unset(wd);
5445 eina_stringshare_replace(&wd->mode_type, mode_type);
5446 if (mode_set) _item_mode_set(_it);
5450 elm_genlist_mode_type_get(const Evas_Object *obj)
5452 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5453 Widget_Data *wd = elm_widget_data_get(obj);
5454 if (!wd) return NULL;
5455 return wd->mode_type;
5458 EAPI const Elm_Object_Item *
5459 elm_genlist_mode_item_get(const Evas_Object *obj)
5461 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5462 Widget_Data *wd = elm_widget_data_get(obj);
5463 if (!wd) return NULL;
5464 return (Elm_Object_Item *) wd->mode_item;
5468 elm_genlist_edit_mode_get(const Evas_Object *obj)
5470 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5471 Widget_Data *wd = elm_widget_data_get(obj);
5472 if (!wd) return EINA_FALSE;
5474 return wd->edit_mode;
5478 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5480 ELM_CHECK_WIDTYPE(obj, widtype);
5481 Eina_List *list, *l;
5484 Widget_Data *wd = elm_widget_data_get(obj);
5486 edit_mode = !!edit_mode;
5487 if (wd->edit_mode == edit_mode) return;
5488 wd->edit_mode = edit_mode;
5490 list = elm_genlist_realized_items_get(obj);
5493 EINA_LIST_FOREACH(list, l, it)
5495 if (it->item->type != ELM_GENLIST_ITEM_GROUP)
5496 _edit_mode_item_unrealize(it);
5498 _item_cache_zero(wd);
5502 EINA_LIST_FOREACH(list, l, it)
5504 if (it->item->type != ELM_GENLIST_ITEM_GROUP)
5506 if (it->selected) _item_unselect(it);
5507 if (it->itc->edit_item_style)
5508 _edit_mode_item_realize(it, EINA_TRUE);
5512 if (wd->calc_job) ecore_job_del(wd->calc_job);
5513 wd->calc_job = ecore_job_add(_calc_job, wd);
5517 elm_genlist_reorder_mode_set(Evas_Object *obj,
5518 Eina_Bool reorder_mode)
5520 ELM_CHECK_WIDTYPE(obj, widtype);
5521 Widget_Data *wd = elm_widget_data_get(obj);
5523 wd->reorder_mode = !!reorder_mode;
5527 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5529 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5530 Widget_Data *wd = elm_widget_data_get(obj);
5531 if (!wd) return EINA_FALSE;
5532 return wd->reorder_mode;
5535 EAPI Elm_Genlist_Item_Type
5536 elm_genlist_item_type_get(const Elm_Object_Item *it)
5538 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ELM_GENLIST_ITEM_MAX);
5539 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5540 return _it->item->type;
5543 EINA_DEPRECATED EAPI Elm_Genlist_Item_Type
5544 elm_genlist_item_flags_get(const Elm_Object_Item *it)
5546 return elm_genlist_item_type_get(it);
5549 EAPI Elm_Genlist_Item_Class *
5550 elm_genlist_item_class_new(void)
5552 Elm_Genlist_Item_Class *itc;
5554 itc = calloc(1, sizeof(Elm_Genlist_Item_Class));
5557 itc->version = CLASS_ALLOCATED;
5559 itc->delete_me = EINA_FALSE;
5565 elm_genlist_item_class_free(Elm_Genlist_Item_Class *itc)
5567 if (itc && (itc->version == CLASS_ALLOCATED))
5569 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
5570 if (itc->refcount > 0) elm_genlist_item_class_unref(itc);
5580 elm_genlist_item_class_ref(Elm_Genlist_Item_Class *itc)
5582 if (itc && (itc->version == CLASS_ALLOCATED))
5585 if (itc->refcount == 0) itc->refcount--;
5590 elm_genlist_item_class_unref(Elm_Genlist_Item_Class *itc)
5592 if (itc && (itc->version == CLASS_ALLOCATED))
5594 if (itc->refcount > 0) itc->refcount--;
5595 if (itc->delete_me && (!itc->refcount))
5596 elm_genlist_item_class_free(itc);
5600 void _flip_job(void *data)
5602 Elm_Gen_Item *it = (Elm_Gen_Item *) data;
5603 _elm_genlist_item_unrealize(it, EINA_FALSE);
5604 if (it->selected) _item_unselect(it);
5605 it->flipped = EINA_TRUE;
5606 it->item->nocache = EINA_TRUE;
5610 elm_genlist_item_flip_set(Elm_Object_Item *it,
5613 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5614 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5617 if (_it->flipped == flip) return;
5621 ecore_job_add(_flip_job, _it);
5622 if (_it->wd->calc_job) ecore_job_del(_it->wd->calc_job);
5623 _it->wd->calc_job = ecore_job_add(_calc_job, _it->wd);
5627 _it->flipped = flip;
5628 _item_cache_zero(_it->wd);
5629 elm_genlist_item_update(it);
5630 _it->item->nocache = EINA_FALSE;
5635 elm_genlist_item_flip_get(const Elm_Object_Item *it)
5637 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
5638 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5639 return _it->flipped;
5642 /* for gengrid as of now */
5644 _elm_genlist_page_relative_set(Evas_Object *obj,
5648 Evas_Coord pagesize_h;
5649 Evas_Coord pagesize_v;
5651 ELM_CHECK_WIDTYPE(obj, widtype);
5652 Widget_Data *wd = elm_widget_data_get(obj);
5655 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
5656 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
5660 /* for gengrid as of now */
5662 _elm_genlist_page_relative_get(const Evas_Object *obj,
5666 ELM_CHECK_WIDTYPE(obj, widtype);
5667 Widget_Data *wd = elm_widget_data_get(obj);
5670 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
5673 /* for gengrid as of now */
5675 _elm_genlist_page_size_set(Evas_Object *obj,
5676 Evas_Coord h_pagesize,
5677 Evas_Coord v_pagesize)
5682 ELM_CHECK_WIDTYPE(obj, widtype);
5683 Widget_Data *wd = elm_widget_data_get(obj);
5685 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
5686 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
5690 /* for gengrid as of now */
5692 _elm_genlist_current_page_get(const Evas_Object *obj,
5696 ELM_CHECK_WIDTYPE(obj, widtype);
5697 Widget_Data *wd = elm_widget_data_get(obj);
5699 elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber);
5702 /* for gengrid as of now */
5704 _elm_genlist_last_page_get(const Evas_Object *obj,
5708 ELM_CHECK_WIDTYPE(obj, widtype);
5709 Widget_Data *wd = elm_widget_data_get(obj);
5711 elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber);
5714 /* for gengrid as of now */
5716 _elm_genlist_page_show(const Evas_Object *obj,
5720 ELM_CHECK_WIDTYPE(obj, widtype);
5721 Widget_Data *wd = elm_widget_data_get(obj);
5723 elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber);
5726 /* for gengrid as of now */
5728 _elm_genlist_page_bring_in(const Evas_Object *obj,
5732 ELM_CHECK_WIDTYPE(obj, widtype);
5733 Widget_Data *wd = elm_widget_data_get(obj);
5735 elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber);
5739 _elm_genlist_item_unrealize(Elm_Gen_Item *it,
5742 Evas_Object *content;
5744 if (!it->realized) return;
5745 if (it->wd->reorder_it == it) return;
5747 evas_event_freeze(evas_object_evas_get(WIDGET(it)));
5749 evas_object_smart_callback_call(WIDGET(it), SIG_UNREALIZED, it);
5752 ecore_timer_del(it->long_timer);
5753 it->long_timer = NULL;
5756 elm_widget_stringlist_free(it->texts);
5758 elm_widget_stringlist_free(it->contents);
5759 it->contents = NULL;
5760 elm_widget_stringlist_free(it->states);
5763 EINA_LIST_FREE(it->content_objs, content)
5764 evas_object_del(content);
5766 it->unrealize_cb(it);
5768 it->realized = EINA_FALSE;
5769 it->want_unrealize = EINA_FALSE;
5770 evas_event_thaw(evas_object_evas_get(WIDGET(it)));
5771 evas_event_thaw_eval(evas_object_evas_get(WIDGET(it)));
5775 _elm_genlist_item_del_notserious(Elm_Gen_Item *it)
5777 elm_widget_item_pre_notify_del(it);
5778 it->generation = it->wd->generation - 1; /* This means that the item is deleted */
5779 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5781 if (it->itc->func.del)
5782 it->itc->func.del((void *)it->base.data, WIDGET(it));
5786 _elm_genlist_item_del_serious(Elm_Gen_Item *it)
5788 _elm_genlist_item_del_notserious(it);
5789 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5790 if (it->tooltip.del_cb)
5791 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
5792 it->wd->walking -= it->walking;
5793 if (it->long_timer) ecore_timer_del(it->long_timer);
5795 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
5799 eina_inlist_sorted_state_free(it->wd->state);
5800 it->wd->state = NULL;
5802 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5803 it->wd->calc_job = ecore_job_add(it->wd->calc_cb, it->wd);
5807 if (it->wd->last_selected_item == (Elm_Object_Item *)it)
5808 it->wd->last_selected_item = NULL;
5809 it->wd->item_count--;