3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
6 #include "els_scroller.h"
7 #include "elm_gen_common.h"
9 #define MAX_ITEMS_PER_BLOCK 32
10 #define REORDER_EFFECT_TIME 0.5
12 #define ELM_GEN_SETUP(wd) \
13 (wd)->calc_cb = (Ecore_Cb)_calc_job; \
14 (wd)->clear_cb = (Ecore_Cb)_clear_cb; \
15 (wd)->sizing_cb = (Ecore_Cb)_sizing_eval
17 #define ELM_GEN_ITEM_SETUP(it) \
18 (it)->del_cb = (Ecore_Cb)_item_del; \
19 (it)->highlight_cb = (Ecore_Cb)_item_highlight; \
20 (it)->unsel_cb = (Ecore_Cb)_item_unselect; \
21 (it)->unhighlight_cb = (Ecore_Cb)_item_unhighlight; \
22 (it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
24 #define ELM_GENLIST_CHECK_ITC_VER(itc) \
29 ERR("Genlist_Item_Class(itc) is NULL"); \
32 if (itc->version != ELM_GENLIST_ITEM_CLASS_VERSION) \
34 ERR("Genlist_Item_Class version mismatched! required = (%d), current = (%d)", itc->version, ELM_GENLIST_ITEM_CLASS_VERSION); \
40 typedef struct _Item_Block Item_Block;
41 typedef struct _Item_Cache Item_Cache;
43 struct Elm_Gen_Item_Type
48 Evas_Coord w, h, minw, minh;
49 Elm_Gen_Item *group_item;
50 Elm_Genlist_Item_Type type;
51 Eina_List *mode_texts, *mode_contents, *mode_states, *mode_content_objs;
52 Eina_List *edit_texts, *edit_contents, *edit_states, *edit_content_objs;
53 Ecore_Timer *swipe_timer;
54 Evas_Coord scrl_x, scrl_y, old_scrl_y;
57 Evas_Object *mode_view;
63 Eina_Bool want_realize : 1;
64 Eina_Bool expanded : 1;
65 Eina_Bool mincalcd : 1;
68 Eina_Bool updateme : 1;
69 Eina_Bool nocache : 1; /* do not use cache for this item */
70 Eina_Bool nocache_once : 1; /* do not use cache for this item only once */
71 Eina_Bool stacking_even : 1;
72 Eina_Bool nostacking : 1;
73 Eina_Bool move_effect_enabled : 1;
74 Eina_Bool edit_mode_item_realized : 1;
85 Evas_Coord x, y, w, h, minw, minh;
87 int item_position_stamp;
89 Eina_Bool position_update : 1;
90 Eina_Bool want_unrealize : 1;
91 Eina_Bool realized : 1;
92 Eina_Bool changed : 1;
93 Eina_Bool updateme : 1;
95 Eina_Bool must_recalc : 1;
102 Evas_Object *base_view, *spacer;
104 const char *item_style; // it->itc->item_style
105 Eina_Bool tree : 1; // it->group
106 Eina_Bool compress : 1; // it->wd->compress
108 Eina_Bool selected : 1; // it->selected
109 Eina_Bool disabled : 1; // it->disabled
110 Eina_Bool expanded : 1; // it->item->expanded
113 static const char *widtype = NULL;
114 static void _item_cache_zero(Widget_Data *wd);
115 static void _del_hook(Evas_Object *obj);
116 static void _mirrored_set(Evas_Object *obj,
118 static void _theme_hook(Evas_Object *obj);
119 static void _show_region_hook(void *data,
121 static void _sizing_eval(Evas_Object *obj);
122 static void _item_realize(Elm_Gen_Item *it,
125 static void _item_unrealize_cb(Elm_Gen_Item *it);
126 static void _item_block_unrealize(Item_Block *itb);
127 static void _calc_job(void *data);
128 static void _on_focus_hook(void *data,
130 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
131 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
132 static Eina_Bool _item_single_select_up(Widget_Data *wd);
133 static Eina_Bool _item_single_select_down(Widget_Data *wd);
134 static Eina_Bool _event_hook(Evas_Object *obj,
136 Evas_Callback_Type type,
138 static void _signal_emit_hook(Evas_Object *obj,
139 const char *emission,
141 static Eina_Bool _deselect_all_items(Widget_Data *wd);
142 static void _pan_calculate(Evas_Object *obj);
143 static void _pan_max_get(Evas_Object *obj,
146 static void _item_position(Elm_Gen_Item *it,
150 static void _mode_item_realize(Elm_Gen_Item *it);
151 static void _mode_item_unrealize(Elm_Gen_Item *it);
152 static void _item_mode_set(Elm_Gen_Item *it);
153 static void _item_mode_unset(Widget_Data *wd);
154 static void _edit_mode_item_position(Elm_Gen_Item *it, int itx, int ity);
155 static void _edit_mode_item_realize(Elm_Gen_Item *it, Eina_Bool effect_on);
156 static void _edit_mode_item_unrealize(Elm_Gen_Item *it);
157 static void _group_items_recalc(void *data);
158 static void _item_move_after(Elm_Gen_Item *it,
159 Elm_Gen_Item *after);
160 static void _item_move_before(Elm_Gen_Item *it,
161 Elm_Gen_Item *before);
162 static void _item_auto_scroll(Widget_Data *wd);
163 static void _elm_genlist_clear(Evas_Object *obj,
165 static void _pan_child_size_get(Evas_Object *obj,
169 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
171 static const char SIG_ACTIVATED[] = "activated";
172 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
173 static const char SIG_SELECTED[] = "selected";
174 static const char SIG_UNSELECTED[] = "unselected";
175 static const char SIG_EXPANDED[] = "expanded";
176 static const char SIG_CONTRACTED[] = "contracted";
177 static const char SIG_EXPAND_REQUEST[] = "expand,request";
178 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
179 static const char SIG_REALIZED[] = "realized";
180 static const char SIG_UNREALIZED[] = "unrealized";
181 static const char SIG_DRAG_START_UP[] = "drag,start,up";
182 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
183 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
184 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
185 static const char SIG_DRAG_STOP[] = "drag,stop";
186 static const char SIG_DRAG[] = "drag";
187 static const char SIG_LONGPRESSED[] = "longpressed";
188 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
189 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
190 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
191 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
192 static const char SIG_EDGE_TOP[] = "edge,top";
193 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
194 static const char SIG_EDGE_LEFT[] = "edge,left";
195 static const char SIG_EDGE_RIGHT[] = "edge,right";
196 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
197 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
198 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
199 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
200 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
201 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
202 static const char SIG_SWIPE[] = "swipe";
203 static const char SIG_MOVED[] = "moved";
204 static const char SIG_INDEX_UPDATE[] = "index,update";
206 static const Evas_Smart_Cb_Description _signals[] = {
207 {SIG_CLICKED_DOUBLE, ""},
210 {SIG_UNSELECTED, ""},
212 {SIG_CONTRACTED, ""},
213 {SIG_EXPAND_REQUEST, ""},
214 {SIG_CONTRACT_REQUEST, ""},
216 {SIG_UNREALIZED, ""},
217 {SIG_DRAG_START_UP, ""},
218 {SIG_DRAG_START_DOWN, ""},
219 {SIG_DRAG_START_LEFT, ""},
220 {SIG_DRAG_START_RIGHT, ""},
223 {SIG_LONGPRESSED, ""},
224 {SIG_SCROLL_ANIM_START, ""},
225 {SIG_SCROLL_ANIM_STOP, ""},
226 {SIG_SCROLL_DRAG_START, ""},
227 {SIG_SCROLL_DRAG_STOP, ""},
229 {SIG_EDGE_BOTTOM, ""},
231 {SIG_EDGE_RIGHT, ""},
232 {SIG_MULTI_SWIPE_LEFT, ""},
233 {SIG_MULTI_SWIPE_RIGHT, ""},
234 {SIG_MULTI_SWIPE_UP, ""},
235 {SIG_MULTI_SWIPE_DOWN, ""},
236 {SIG_MULTI_PINCH_OUT, ""},
237 {SIG_MULTI_PINCH_IN, ""},
244 #undef ELM_CHECK_WIDTYPE
245 #define ELM_CHECK_WIDTYPE(obj, widtype) \
246 if ((!obj) || (!elm_genlist_type_check((obj), __func__))) return
247 #undef ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN
248 #define ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, ...) \
249 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
250 ELM_CHECK_WIDTYPE(WIDGET((it)), widtype) __VA_ARGS__;
252 static const char *_gengrid = NULL;
253 static const char *_genlist = NULL;
255 /* THIS FUNCTION IS HACKY AND TEMPORARY!!! */
257 elm_genlist_type_check(const Evas_Object *obj,
260 const char *provided, *expected = "(unknown)";
261 static int abort_on_warn = -1;
262 provided = elm_widget_type_get(obj);
263 if (!_genlist) _genlist = eina_stringshare_add("genlist");
264 if (!_gengrid) _gengrid = eina_stringshare_add("gengrid");
265 if (EINA_LIKELY(provided == _genlist) || EINA_LIKELY(provided == _gengrid))
267 if ((!provided) || (!provided[0]))
269 provided = evas_object_type_get(obj);
270 if ((!provided) || (!provided[0]))
271 provided = "(unknown)";
273 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
274 if (abort_on_warn == -1)
276 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
277 else abort_on_warn = 0;
279 if (abort_on_warn == 1) abort();
284 _event_hook(Evas_Object *obj,
285 Evas_Object *src __UNUSED__,
286 Evas_Callback_Type type,
289 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
290 Evas_Event_Key_Down *ev = event_info;
291 Widget_Data *wd = elm_widget_data_get(obj);
292 Evas_Coord pan_max_x = 0, pan_max_y = 0;
293 if (!wd) return EINA_FALSE;
294 if (!wd->items) return EINA_FALSE;
295 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
296 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
298 Elm_Object_Item *it = NULL;
301 Evas_Coord step_x = 0;
302 Evas_Coord step_y = 0;
305 Evas_Coord page_x = 0;
306 Evas_Coord page_y = 0;
308 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
309 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
310 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
311 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
313 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
317 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
321 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
323 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
324 (_item_multi_select_up(wd)))
325 || (_item_single_select_up(wd)))
327 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
333 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
335 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
336 (_item_multi_select_down(wd)))
337 || (_item_single_select_down(wd)))
339 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
345 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
347 it = elm_genlist_first_item_get(obj);
348 elm_genlist_item_bring_in(it);
349 elm_genlist_item_selected_set(it, EINA_TRUE);
350 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
353 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
355 it = elm_genlist_last_item_get(obj);
356 elm_genlist_item_bring_in(it);
357 elm_genlist_item_selected_set(it, EINA_TRUE);
358 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
361 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
364 y -= -(page_y * v_h) / 100;
368 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
371 y += -(page_y * v_h) / 100;
375 else if (!strcmp(ev->keyname, "Escape"))
377 if (!_deselect_all_items(wd)) return EINA_FALSE;
378 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
381 else if (((!strcmp(ev->keyname, "Return")) ||
382 (!strcmp(ev->keyname, "KP_Enter")) ||
383 (!strcmp(ev->keyname, "space")))
384 && (!wd->multi) && (wd->selected))
386 it = elm_genlist_selected_item_get(obj);
387 elm_genlist_item_expanded_set(it,
388 !elm_genlist_item_expanded_get(it));
389 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
391 else return EINA_FALSE;
393 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
394 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
396 if (x > pan_max_x) x = pan_max_x;
398 if (y > pan_max_y) y = pan_max_y;
399 elm_smart_scroller_child_pos_set(wd->scr, x, y);
404 _deselect_all_items(Widget_Data *wd)
406 if (!wd->selected) return EINA_FALSE;
408 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
414 _item_multi_select_up(Widget_Data *wd)
416 if (!wd->selected) return EINA_FALSE;
417 if (!wd->multi) return EINA_FALSE;
419 Elm_Object_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
420 if (!prev) return EINA_TRUE;
422 if (elm_genlist_item_selected_get(prev))
424 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
425 wd->last_selected_item = prev;
426 elm_genlist_item_show(wd->last_selected_item);
430 elm_genlist_item_selected_set(prev, EINA_TRUE);
431 elm_genlist_item_show(prev);
437 _item_multi_select_down(Widget_Data *wd)
439 if (!wd->selected) return EINA_FALSE;
440 if (!wd->multi) return EINA_FALSE;
442 Elm_Object_Item *next;
443 next = elm_genlist_item_next_get(wd->last_selected_item);
444 if (!next) return EINA_TRUE;
446 if (elm_genlist_item_selected_get(next))
448 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
449 wd->last_selected_item = next;
450 elm_genlist_item_show(wd->last_selected_item);
454 elm_genlist_item_selected_set(next, EINA_TRUE);
455 elm_genlist_item_show(next);
461 _item_single_select_up(Widget_Data *wd)
466 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
467 while ((prev) && (prev->generation < wd->generation))
468 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
470 else prev = (Elm_Gen_Item *) elm_genlist_item_prev_get(wd->last_selected_item);
472 if (!prev) return EINA_FALSE;
474 _deselect_all_items(wd);
476 elm_genlist_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
477 elm_genlist_item_show((Elm_Object_Item *) prev);
482 _item_single_select_down(Widget_Data *wd)
487 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
488 while ((next) && (next->generation < wd->generation))
489 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
491 else next = (Elm_Gen_Item *) elm_genlist_item_next_get(wd->last_selected_item);
493 if (!next) return EINA_FALSE;
495 _deselect_all_items(wd);
497 elm_genlist_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
498 elm_genlist_item_show((Elm_Object_Item *) next);
503 _on_focus_hook(void *data __UNUSED__,
506 Widget_Data *wd = elm_widget_data_get(obj);
508 if (elm_widget_focus_get(obj))
510 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
511 evas_object_focus_set(wd->obj, EINA_TRUE);
512 if ((wd->selected) && (!wd->last_selected_item))
513 wd->last_selected_item = eina_list_data_get(wd->selected);
517 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
518 evas_object_focus_set(wd->obj, EINA_FALSE);
523 _del_hook(Evas_Object *obj)
525 Widget_Data *wd = elm_widget_data_get(obj);
527 _item_cache_zero(wd);
528 if (wd->calc_job) ecore_job_del(wd->calc_job);
529 if (wd->update_job) ecore_job_del(wd->update_job);
530 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
531 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
532 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
533 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
534 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
539 _del_pre_hook(Evas_Object *obj)
541 Widget_Data *wd = elm_widget_data_get(obj);
543 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
544 elm_genlist_clear(obj);
545 evas_object_del(wd->pan_smart);
546 wd->pan_smart = NULL;
550 _mirrored_set(Evas_Object *obj,
553 Widget_Data *wd = elm_widget_data_get(obj);
555 _item_cache_zero(wd);
556 elm_smart_scroller_mirrored_set(wd->scr, rtl);
560 _theme_hook(Evas_Object *obj)
562 Widget_Data *wd = elm_widget_data_get(obj);
565 evas_event_freeze(evas_object_evas_get(wd->obj));
566 _item_cache_zero(wd);
567 _elm_widget_mirrored_reload(obj);
568 _mirrored_set(obj, elm_widget_mirrored_get(obj));
569 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
570 elm_widget_style_get(obj));
571 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
572 wd->item_width = wd->item_height = 0;
573 wd->group_item_width = wd->group_item_height = 0;
574 wd->minw = wd->minh = wd->realminw = 0;
575 EINA_INLIST_FOREACH(wd->blocks, itb)
580 if (itb->realized) _item_block_unrealize(itb);
581 EINA_LIST_FOREACH(itb->items, l, it)
582 it->item->mincalcd = EINA_FALSE;
584 itb->changed = EINA_TRUE;
586 if (wd->calc_job) ecore_job_del(wd->calc_job);
587 wd->calc_job = ecore_job_add(_calc_job, wd);
589 evas_event_thaw(evas_object_evas_get(wd->obj));
590 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
594 _show_region_hook(void *data,
597 Widget_Data *wd = elm_widget_data_get(data);
598 Evas_Coord x, y, w, h;
600 elm_widget_show_region_get(obj, &x, &y, &w, &h);
601 //x & y are screen coordinates, Add with pan coordinates
604 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
608 _translate_hook(Evas_Object *obj)
610 evas_object_smart_callback_call(obj, "language,changed", NULL);
614 _sizing_eval(Evas_Object *obj)
616 Widget_Data *wd = elm_widget_data_get(obj);
617 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
619 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
620 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
622 if (wd->height_for_width)
626 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
627 if ((vw != 0) && (vw != wd->prev_viewport_w))
631 wd->prev_viewport_w = vw;
632 EINA_INLIST_FOREACH(wd->blocks, itb)
634 itb->must_recalc = EINA_TRUE;
636 if (wd->calc_job) ecore_job_del(wd->calc_job);
637 wd->calc_job = ecore_job_add(_calc_job, wd);
640 if (wd->mode == ELM_LIST_LIMIT)
646 elm_smart_scroller_child_viewport_size_get(wd->scr, &vmw, &vmh);
647 edje_object_size_min_calc
648 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
655 edje_object_size_min_calc
656 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
660 evas_object_size_hint_min_set(obj, minw, minh);
661 evas_object_size_hint_max_set(obj, maxw, maxh);
665 _signal_emit_hook(Evas_Object *obj,
666 const char *emission,
669 Widget_Data *wd = elm_widget_data_get(obj);
670 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
675 _item_highlight(Elm_Gen_Item *it)
677 const char *selectraise;
678 if ((it->wd->no_select) || (it->generation < it->wd->generation) ||
679 (it->highlighted) || elm_widget_item_disabled_get(it) ||
680 (it->display_only) || (it->item->mode_view))
682 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
683 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
684 selectraise = edje_object_data_get(VIEW(it), "selectraise");
685 if ((selectraise) && (!strcmp(selectraise, "on")))
687 if (it->edit_obj) evas_object_raise(it->edit_obj);
688 else evas_object_raise(VIEW(it));
689 if ((it->item->group_item) && (it->item->group_item->realized))
690 evas_object_raise(it->item->VIEW(group_item));
692 it->highlighted = EINA_TRUE;
696 _item_unhighlight(Elm_Gen_Item *it)
698 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
699 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
700 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
701 if (!it->item->nostacking)
703 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
705 if (it->edit_obj) evas_object_lower(it->edit_obj);
706 else evas_object_lower(VIEW(it));
710 if (it->edit_obj) evas_object_raise(it->edit_obj);
711 else evas_object_raise(VIEW(it));
714 it->highlighted = EINA_FALSE;
718 _item_block_position_update(Eina_Inlist *list, int idx)
722 EINA_INLIST_FOREACH(list, tmp)
724 tmp->position = idx++;
725 tmp->position_update = EINA_TRUE;
730 _item_position_update(Eina_List *list, int idx)
735 EINA_LIST_FOREACH(list, l, it)
737 it->position = idx++;
738 it->position_update = EINA_TRUE;
743 _item_block_del(Elm_Gen_Item *it)
746 Item_Block *itb = it->item->block;
748 itb->items = eina_list_remove(itb->items, it);
750 itb->changed = EINA_TRUE;
751 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
752 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
755 il = EINA_INLIST_GET(itb);
756 Item_Block *itbn = (Item_Block *)(il->next);
758 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
761 _item_block_position_update(il->next, itb->position);
762 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
765 if (itbn) itbn->changed = EINA_TRUE;
769 if (itb->count < itb->wd->max_items_per_block/2)
771 il = EINA_INLIST_GET(itb);
772 Item_Block *itbp = (Item_Block *)(il->prev);
773 Item_Block *itbn = (Item_Block *)(il->next);
774 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
778 EINA_LIST_FREE(itb->items, it2)
780 it2->item->block = itbp;
781 itbp->items = eina_list_append(itbp->items, it2);
783 itbp->changed = EINA_TRUE;
785 _item_block_position_update(EINA_INLIST_GET(itb)->next,
787 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
788 EINA_INLIST_GET(itb));
791 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
795 Eina_List *last = eina_list_last(itb->items);
796 Elm_Gen_Item *it2 = last->data;
798 it2->item->block = itbn;
799 itb->items = eina_list_remove_list(itb->items, last);
800 itbn->items = eina_list_prepend(itbn->items, it2);
802 itbn->changed = EINA_TRUE;
804 _item_block_position_update(EINA_INLIST_GET(itb)->next,
807 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
815 _item_del(Elm_Gen_Item *it)
817 Evas_Object *obj = WIDGET(it);
819 evas_event_freeze(evas_object_evas_get(obj));
820 elm_genlist_item_subitems_clear((Elm_Object_Item *)it);
821 if (it->wd->show_item == it) it->wd->show_item = NULL;
822 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
823 if (it->item->edit_mode_item_realized) _edit_mode_item_unrealize(it);
824 if (it->item->block) _item_block_del(it);
825 if (it->item->queued)
826 it->wd->queue = eina_list_remove(it->wd->queue, it);
827 if (it->wd->anchor_item == it)
829 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
830 if (!it->wd->anchor_item)
831 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
833 if (it->wd->expanded_item == it) it->wd->expanded_item = NULL;
835 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
836 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
837 _elm_genlist_item_del_serious(it);
838 elm_genlist_item_class_unref((Elm_Genlist_Item_Class *)it->itc);
839 evas_event_thaw(evas_object_evas_get(obj));
840 evas_event_thaw_eval(evas_object_evas_get(obj));
844 _clear_cb(Widget_Data *wd)
846 wd->anchor_item = NULL;
849 Item_Block *itb = (Item_Block *)(wd->blocks);
851 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
852 if (itb->items) eina_list_free(itb->items);
855 if (wd->queue_idle_enterer)
857 ecore_idle_enterer_del(wd->queue_idle_enterer);
858 wd->queue_idle_enterer = NULL;
860 if (wd->must_recalc_idler)
862 ecore_idler_del(wd->must_recalc_idler);
863 wd->must_recalc_idler = NULL;
865 if (wd->queue) wd->queue = eina_list_free(wd->queue);
866 if (wd->reorder_move_animator)
868 ecore_animator_del(wd->reorder_move_animator);
869 wd->reorder_move_animator = NULL;
871 wd->show_item = NULL;
872 wd->reorder_old_pan_y = 0;
876 _item_unselect(Elm_Gen_Item *it)
878 if ((it->generation < it->wd->generation) || (!it->selected)) return;
879 it->selected = EINA_FALSE;
880 it->wd->selected = eina_list_remove(it->wd->selected, it);
881 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
885 _mouse_move(void *data,
886 Evas *evas __UNUSED__,
890 Elm_Gen_Item *it = data;
891 Evas_Event_Mouse_Move *ev = event_info;
892 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
893 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
895 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
897 if (!it->wd->on_hold)
899 it->wd->on_hold = EINA_TRUE;
900 if ((!it->wd->wasselected) && (!it->flipped))
902 _item_unhighlight(it);
907 if (it->wd->multitouched)
909 it->wd->cur_x = ev->cur.canvas.x;
910 it->wd->cur_y = ev->cur.canvas.y;
913 if ((it->dragging) && (it->down))
915 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
918 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
919 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
920 if (abs((it->wd->history[it->wd->movements].x -
921 it->wd->history[0].x)) > 40)
922 it->wd->swipe = EINA_TRUE;
928 ecore_timer_del(it->long_timer);
929 it->long_timer = NULL;
931 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
934 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
938 ecore_timer_del(it->long_timer);
939 it->long_timer = NULL;
941 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
943 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
944 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
946 if (!it->wd->reorder_start_y)
947 it->wd->reorder_start_y = it->item->block->y + it->y;
951 else if (it_scrl_y + it->wd->reorder_it->item->h > oy + oh)
952 y_pos = oy + oh - it->wd->reorder_it->item->h;
957 _item_position(it, it->edit_obj, it->item->scrl_x, y_pos);
959 _item_position(it, VIEW(it), it->item->scrl_x, y_pos);
961 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
962 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
966 if (!it->display_only)
967 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
968 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
969 x = ev->cur.canvas.x - x;
970 y = ev->cur.canvas.y - y;
973 if (adx < 0) adx = -dx;
976 if (ady < 0) ady = -dy;
979 if ((adx > minw) || (ady > minh))
981 it->dragging = EINA_TRUE;
984 ecore_timer_del(it->long_timer);
985 it->long_timer = NULL;
987 if (!it->wd->wasselected)
989 _item_unhighlight(it);
995 evas_object_smart_callback_call(WIDGET(it),
996 SIG_DRAG_START_UP, it);
1000 evas_object_smart_callback_call(WIDGET(it),
1001 SIG_DRAG_START_LEFT, it);
1003 evas_object_smart_callback_call(WIDGET(it),
1004 SIG_DRAG_START_RIGHT, it);
1010 evas_object_smart_callback_call(WIDGET(it),
1011 SIG_DRAG_START_DOWN, it);
1015 evas_object_smart_callback_call(WIDGET(it),
1016 SIG_DRAG_START_LEFT, it);
1018 evas_object_smart_callback_call(WIDGET(it),
1019 SIG_DRAG_START_RIGHT, it);
1026 _long_press(void *data)
1028 Elm_Gen_Item *it = data, *it_tmp;
1029 Eina_List *list, *l;
1031 it->long_timer = NULL;
1032 if (elm_widget_item_disabled_get(it) || (it->dragging) || (it->display_only))
1033 return ECORE_CALLBACK_CANCEL;
1034 it->wd->longpressed = EINA_TRUE;
1035 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
1036 if ((it->wd->reorder_mode) && (!it->group))
1038 it->wd->reorder_it = it;
1039 it->wd->reorder_start_y = 0;
1041 evas_object_raise(it->edit_obj);
1043 evas_object_raise(VIEW(it));
1045 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1046 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1048 list = elm_genlist_realized_items_get(it->wd->obj);
1049 EINA_LIST_FOREACH(list, l, it_tmp)
1051 if (it != it_tmp) _item_unselect(it_tmp);
1053 if (elm_genlist_item_expanded_get((Elm_Object_Item *)it))
1055 elm_genlist_item_expanded_set((Elm_Object_Item *)it, EINA_FALSE);
1056 return ECORE_CALLBACK_RENEW;
1059 if (!it->wd->edit_mode)
1060 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
1062 return ECORE_CALLBACK_CANCEL;
1066 _swipe(Elm_Gen_Item *it)
1071 if ((it->display_only) || elm_widget_item_disabled_get(it)) return;
1072 it->wd->swipe = EINA_FALSE;
1073 for (i = 0; i < it->wd->movements; i++)
1075 sum += it->wd->history[i].x;
1076 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1079 sum /= it->wd->movements;
1080 if (abs(sum - it->wd->history[0].x) <= 10) return;
1081 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
1085 _swipe_cancel(void *data)
1087 Elm_Gen_Item *it = data;
1089 if (!it) return ECORE_CALLBACK_CANCEL;
1090 it->wd->swipe = EINA_FALSE;
1091 it->wd->movements = 0;
1092 return ECORE_CALLBACK_RENEW;
1096 _multi_cancel(void *data)
1098 Widget_Data *wd = data;
1100 if (!wd) return ECORE_CALLBACK_CANCEL;
1101 wd->multi_timeout = EINA_TRUE;
1102 return ECORE_CALLBACK_RENEW;
1106 _multi_touch_gesture_eval(void *data)
1108 Elm_Gen_Item *it = data;
1110 it->wd->multitouched = EINA_FALSE;
1111 if (it->wd->multi_timer)
1113 ecore_timer_del(it->wd->multi_timer);
1114 it->wd->multi_timer = NULL;
1116 if (it->wd->multi_timeout)
1118 it->wd->multi_timeout = EINA_FALSE;
1122 Evas_Coord minw = 0, minh = 0;
1123 Evas_Coord off_x, off_y, off_mx, off_my;
1125 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1126 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1127 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1128 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1129 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1131 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1133 if ((off_x + off_mx) > (off_y + off_my))
1135 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1136 evas_object_smart_callback_call(WIDGET(it),
1137 SIG_MULTI_SWIPE_RIGHT, it);
1138 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1139 evas_object_smart_callback_call(WIDGET(it),
1140 SIG_MULTI_SWIPE_LEFT, it);
1141 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1142 evas_object_smart_callback_call(WIDGET(it),
1143 SIG_MULTI_PINCH_OUT, it);
1145 evas_object_smart_callback_call(WIDGET(it),
1146 SIG_MULTI_PINCH_IN, it);
1150 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1151 evas_object_smart_callback_call(WIDGET(it),
1152 SIG_MULTI_SWIPE_DOWN, it);
1153 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1154 evas_object_smart_callback_call(WIDGET(it),
1155 SIG_MULTI_SWIPE_UP, it);
1156 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1157 evas_object_smart_callback_call(WIDGET(it),
1158 SIG_MULTI_PINCH_OUT, it);
1160 evas_object_smart_callback_call(WIDGET(it),
1161 SIG_MULTI_PINCH_IN, it);
1164 it->wd->multi_timeout = EINA_FALSE;
1168 _multi_down(void *data,
1169 Evas *evas __UNUSED__,
1170 Evas_Object *obj __UNUSED__,
1173 Elm_Gen_Item *it = data;
1174 Evas_Event_Multi_Down *ev = event_info;
1176 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1177 it->wd->multi_device = ev->device;
1178 it->wd->multi_down = EINA_TRUE;
1179 it->wd->multitouched = EINA_TRUE;
1180 it->wd->prev_mx = ev->canvas.x;
1181 it->wd->prev_my = ev->canvas.y;
1182 if (!it->wd->wasselected)
1184 _item_unhighlight(it);
1187 it->wd->wasselected = EINA_FALSE;
1188 it->wd->longpressed = EINA_FALSE;
1191 ecore_timer_del(it->long_timer);
1192 it->long_timer = NULL;
1196 it->dragging = EINA_FALSE;
1197 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1199 if (it->item->swipe_timer)
1201 ecore_timer_del(it->item->swipe_timer);
1202 it->item->swipe_timer = NULL;
1204 if (it->wd->on_hold)
1206 it->wd->swipe = EINA_FALSE;
1207 it->wd->movements = 0;
1208 it->wd->on_hold = EINA_FALSE;
1213 _multi_up(void *data,
1214 Evas *evas __UNUSED__,
1215 Evas_Object *obj __UNUSED__,
1218 Elm_Gen_Item *it = data;
1219 Evas_Event_Multi_Up *ev = event_info;
1221 if (it->wd->multi_device != ev->device) return;
1222 it->wd->multi_device = 0;
1223 it->wd->multi_down = EINA_FALSE;
1224 if (it->wd->mouse_down) return;
1225 _multi_touch_gesture_eval(data);
1229 _multi_move(void *data,
1230 Evas *evas __UNUSED__,
1231 Evas_Object *obj __UNUSED__,
1234 Elm_Gen_Item *it = data;
1235 Evas_Event_Multi_Move *ev = event_info;
1237 if (it->wd->multi_device != ev->device) return;
1238 it->wd->cur_mx = ev->cur.canvas.x;
1239 it->wd->cur_my = ev->cur.canvas.y;
1243 _mouse_down(void *data,
1244 Evas *evas __UNUSED__,
1248 Elm_Gen_Item *it = data;
1249 Evas_Event_Mouse_Down *ev = event_info;
1252 if (ev->button != 1) return;
1253 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1255 it->wd->on_hold = EINA_TRUE;
1258 it->down = EINA_TRUE;
1259 it->dragging = EINA_FALSE;
1260 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1261 it->dx = ev->canvas.x - x;
1262 it->dy = ev->canvas.y - y;
1263 it->wd->mouse_down = EINA_TRUE;
1264 if (!it->wd->multitouched)
1266 it->wd->prev_x = ev->canvas.x;
1267 it->wd->prev_y = ev->canvas.y;
1268 it->wd->multi_timeout = EINA_FALSE;
1269 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1270 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1272 it->wd->longpressed = EINA_FALSE;
1273 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1274 else it->wd->on_hold = EINA_FALSE;
1275 if (it->wd->on_hold) return;
1276 it->wd->wasselected = it->selected;
1277 _item_highlight(it);
1278 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1279 if ((!elm_widget_item_disabled_get(it)) && (!it->display_only))
1281 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1282 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
1284 if (it->long_timer) ecore_timer_del(it->long_timer);
1285 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
1286 it->item->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1288 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1291 it->long_timer = NULL;
1292 it->wd->swipe = EINA_FALSE;
1293 it->wd->movements = 0;
1297 _mouse_up(void *data,
1298 Evas *evas __UNUSED__,
1299 Evas_Object *obj __UNUSED__,
1302 Elm_Gen_Item *it = data;
1303 Evas_Event_Mouse_Up *ev = event_info;
1304 Eina_Bool dragged = EINA_FALSE;
1306 if (ev->button != 1) return;
1307 it->down = EINA_FALSE;
1308 it->wd->mouse_down = EINA_FALSE;
1309 if (it->wd->multitouched)
1311 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1312 if (it->wd->multi_down) return;
1313 _multi_touch_gesture_eval(data);
1316 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1317 else it->wd->on_hold = EINA_FALSE;
1320 ecore_timer_del(it->long_timer);
1321 it->long_timer = NULL;
1325 it->dragging = EINA_FALSE;
1326 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1329 if (it->item->swipe_timer)
1331 ecore_timer_del(it->item->swipe_timer);
1332 it->item->swipe_timer = NULL;
1334 if (it->wd->multi_timer)
1336 ecore_timer_del(it->wd->multi_timer);
1337 it->wd->multi_timer = NULL;
1338 it->wd->multi_timeout = EINA_FALSE;
1340 if (it->wd->on_hold)
1342 if (it->wd->swipe) _swipe(data);
1343 it->wd->longpressed = EINA_FALSE;
1344 it->wd->on_hold = EINA_FALSE;
1347 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1349 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1351 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1353 if (it_scrl_y <= it->wd->reorder_rel->item->scrl_y)
1354 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1356 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1360 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1361 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1363 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
1364 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1365 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1366 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
1368 if (it->wd->longpressed)
1370 it->wd->longpressed = EINA_FALSE;
1371 if ((!it->wd->wasselected) && (!it->flipped))
1373 _item_unhighlight(it);
1376 it->wd->wasselected = EINA_FALSE;
1381 if (it->want_unrealize)
1383 _elm_genlist_item_unrealize(it, EINA_FALSE);
1384 if (it->item->block->want_unrealize)
1385 _item_block_unrealize(it->item->block);
1388 if (elm_widget_item_disabled_get(it) || (dragged) || (it->display_only))
1390 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1395 _item_highlight(it);
1400 _item_unhighlight(it);
1408 Widget_Data *wd = it->wd;
1411 while (wd->selected)
1413 _item_unhighlight(wd->selected->data);
1414 _item_unselect(wd->selected->data);
1420 const Eina_List *l, *l_next;
1423 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1426 _item_unhighlight(it2);
1427 _item_unselect(it2);
1429 //_item_highlight(it);
1432 _item_highlight(it);
1438 _signal_expand_toggle(void *data,
1439 Evas_Object *obj __UNUSED__,
1440 const char *emission __UNUSED__,
1441 const char *source __UNUSED__)
1443 Elm_Gen_Item *it = data;
1445 if (it->item->expanded)
1446 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1448 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1452 _signal_expand(void *data,
1453 Evas_Object *obj __UNUSED__,
1454 const char *emission __UNUSED__,
1455 const char *source __UNUSED__)
1457 Elm_Gen_Item *it = data;
1459 if (!it->item->expanded)
1460 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1464 _signal_contract(void *data,
1465 Evas_Object *obj __UNUSED__,
1466 const char *emission __UNUSED__,
1467 const char *source __UNUSED__)
1469 Elm_Gen_Item *it = data;
1471 if (it->item->expanded)
1472 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1476 _scr_hold_timer_cb(void *data)
1478 if (!data) return ECORE_CALLBACK_CANCEL;
1479 Widget_Data *wd = data;
1480 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1481 wd->scr_hold_timer = NULL;
1482 return ECORE_CALLBACK_CANCEL;
1486 _mode_finished_signal_cb(void *data,
1488 const char *emission __UNUSED__,
1489 const char *source __UNUSED__)
1493 Elm_Gen_Item *it = data;
1494 if ((it->generation < it->wd->generation) || (!it->realized) || (!it->item->mode_view)) return;
1496 Evas *te = evas_object_evas_get(obj);
1498 evas_event_freeze(te);
1499 it->item->nocache_once = EINA_FALSE;
1500 _mode_item_unrealize(it);
1501 if (it->item->group_item)
1502 evas_object_raise(it->item->VIEW(group_item));
1503 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1504 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1505 evas_event_thaw(te);
1506 evas_event_thaw_eval(te);
1510 _item_cache_clean(Widget_Data *wd)
1512 evas_event_freeze(evas_object_evas_get(wd->obj));
1513 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1517 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1518 wd->item_cache = eina_inlist_remove(wd->item_cache,
1519 wd->item_cache->last);
1520 wd->item_cache_count--;
1521 if (itc->spacer) evas_object_del(itc->spacer);
1522 if (itc->base_view) evas_object_del(itc->base_view);
1523 eina_stringshare_del(itc->item_style);
1526 evas_event_thaw(evas_object_evas_get(wd->obj));
1527 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1531 _item_cache_zero(Widget_Data *wd)
1533 int pmax = wd->item_cache_max;
1534 wd->item_cache_max = 0;
1535 _item_cache_clean(wd);
1536 wd->item_cache_max = pmax;
1540 _item_cache_add(Elm_Gen_Item *it)
1544 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1545 if (it->wd->item_cache_max <= 0)
1547 evas_object_del(VIEW(it));
1549 evas_object_del(it->spacer);
1551 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1552 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1556 it->wd->item_cache_count++;
1557 itc = calloc(1, sizeof(Item_Cache));
1560 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1561 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1564 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1565 EINA_INLIST_GET(itc));
1566 itc->spacer = it->spacer;
1568 itc->base_view = VIEW(it);
1570 edje_object_signal_emit(itc->base_view, "elm,state,unselected", "elm");
1571 evas_object_hide(itc->base_view);
1572 evas_object_move(itc->base_view, -9999, -9999);
1573 itc->item_style = eina_stringshare_add(it->itc->item_style);
1574 if (it->item->type & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1575 itc->compress = (it->wd->compress);
1576 itc->selected = it->selected;
1577 itc->disabled = elm_widget_item_disabled_get(it);
1578 itc->expanded = it->item->expanded;
1581 ecore_timer_del(it->long_timer);
1582 it->long_timer = NULL;
1584 if (it->item->swipe_timer)
1586 ecore_timer_del(it->item->swipe_timer);
1587 it->item->swipe_timer = NULL;
1589 // FIXME: other callbacks?
1590 edje_object_signal_callback_del_full(itc->base_view,
1591 "elm,action,expand,toggle",
1592 "elm", _signal_expand_toggle, it);
1593 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1595 _signal_expand, it);
1596 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1597 "elm", _signal_contract, it);
1598 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1600 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1602 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1604 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1606 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1608 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1610 _item_cache_clean(it->wd);
1611 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1612 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1616 _item_cache_find(Elm_Gen_Item *it)
1621 if (it->item->type & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1622 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1624 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1626 if ((itc->tree == tree) &&
1627 (itc->compress == it->wd->compress) &&
1628 (((!it->itc->item_style) && (!itc->item_style)) ||
1629 (it->itc->item_style && itc->item_style &&
1630 (!strcmp(it->itc->item_style, itc->item_style)))))
1632 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1633 EINA_INLIST_GET(itc));
1634 it->wd->item_cache_count--;
1642 _elm_genlist_item_index_update(Elm_Gen_Item *it)
1644 if (it->position_update || it->item->block->position_update)
1646 evas_object_smart_callback_call(WIDGET(it), SIG_INDEX_UPDATE, it);
1647 it->position_update = EINA_FALSE;
1652 _elm_genlist_item_odd_even_update(Elm_Gen_Item *it)
1654 if (!it->item->nostacking)
1656 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
1658 if (it->edit_obj) evas_object_lower(it->edit_obj);
1659 else evas_object_lower(VIEW(it));
1663 if (it->edit_obj) evas_object_raise(it->edit_obj);
1664 else evas_object_raise(VIEW(it));
1668 if (it->item->order_num_in & 0x1)
1670 edje_object_signal_emit(VIEW(it), "elm,state,odd", "elm");
1671 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,odd", "elm");
1675 edje_object_signal_emit(VIEW(it), "elm,state,even", "elm");
1676 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,even", "elm");
1681 _elm_genlist_item_state_update(Elm_Gen_Item *it, Item_Cache *itc)
1685 if (it->selected != itc->selected)
1688 edje_object_signal_emit(VIEW(it),
1689 "elm,state,selected", "elm");
1692 edje_object_signal_emit(it->edit_obj,
1693 "elm,state,selected", "elm");
1695 if (elm_widget_item_disabled_get(it) != itc->disabled)
1697 if (elm_widget_item_disabled_get(it))
1698 edje_object_signal_emit(VIEW(it),
1699 "elm,state,disabled", "elm");
1701 edje_object_signal_emit(it->edit_obj,
1702 "elm,state,disabled", "elm");
1704 if (it->item->expanded != itc->expanded)
1706 if (it->item->expanded)
1707 edje_object_signal_emit(VIEW(it),
1708 "elm,state,expanded", "elm");
1710 edje_object_signal_emit(it->edit_obj,
1711 "elm,state,expanded", "elm");
1718 edje_object_signal_emit(VIEW(it),
1719 "elm,state,selected", "elm");
1721 edje_object_signal_emit(it->edit_obj,
1722 "elm,state,selected", "elm");
1725 if (elm_widget_item_disabled_get(it))
1727 edje_object_signal_emit(VIEW(it),
1728 "elm,state,disabled", "elm");
1730 edje_object_signal_emit(it->edit_obj,
1731 "elm,state,disabled", "elm");
1733 if (it->item->expanded)
1735 edje_object_signal_emit(VIEW(it),
1736 "elm,state,expanded", "elm");
1738 edje_object_signal_emit(it->edit_obj,
1739 "elm,state,expanded", "elm");
1745 _item_cache_free(Item_Cache *itc)
1747 if (itc->spacer) evas_object_del(itc->spacer);
1748 if (itc->base_view) evas_object_del(itc->base_view);
1749 eina_stringshare_del(itc->item_style);
1754 _item_text_realize(Elm_Gen_Item *it,
1755 Evas_Object *target,
1759 if (it->itc->func.text_get)
1764 *source = elm_widget_stringlist_get(edje_object_data_get(target, "texts"));
1765 EINA_LIST_FOREACH(*source, l, key)
1767 if (parts && fnmatch(parts, key, FNM_PERIOD))
1770 char *s = it->itc->func.text_get
1771 ((void *)it->base.data, WIDGET(it), key);
1775 edje_object_part_text_set(target, key, s);
1780 edje_object_part_text_set(target, key, "");
1787 _item_content_unrealize(Elm_Gen_Item *it,
1788 Evas_Object *target,
1792 Eina_List *res = it->content_objs;
1794 if (it->itc->func.content_get)
1798 Evas_Object *ic = NULL;
1800 EINA_LIST_FOREACH(*source, l, key)
1802 if (parts && fnmatch(parts, key, FNM_PERIOD))
1805 ic = edje_object_part_swallow_get(target, key);
1808 res = eina_list_remove(res, ic);
1809 edje_object_part_unswallow(target, ic);
1810 evas_object_del(ic);
1819 _item_content_realize(Elm_Gen_Item *it,
1820 Evas_Object *target,
1824 Eina_List *res = NULL;
1826 if (it->itc->func.content_get)
1830 Evas_Object *ic = NULL;
1832 *source = elm_widget_stringlist_get(edje_object_data_get(target, "contents"));
1834 if (parts && (eina_list_count(*source) != eina_list_count(it->content_objs)))
1835 res = it->content_objs;
1837 EINA_LIST_FOREACH(*source, l, key)
1839 if (parts && fnmatch(parts, key, FNM_PERIOD))
1842 if (it->itc->func.content_get)
1843 ic = it->itc->func.content_get
1844 ((void *)it->base.data, WIDGET(it), key);
1847 res = eina_list_append(res, ic);
1848 edje_object_part_swallow(target, key, ic);
1849 evas_object_show(ic);
1850 elm_widget_sub_object_add(WIDGET(it), ic);
1851 if (elm_widget_item_disabled_get(it))
1852 elm_widget_disabled_set(ic, EINA_TRUE);
1861 _item_state_realize(Elm_Gen_Item *it,
1862 Evas_Object *target,
1866 if (it->itc->func.state_get)
1872 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1873 EINA_LIST_FOREACH(*source, l, key)
1875 if (parts && fnmatch(parts, key, FNM_PERIOD))
1878 Eina_Bool on = it->itc->func.state_get
1879 ((void *)it->base.data, WIDGET(it), key);
1883 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1884 edje_object_signal_emit(target, buf, "elm");
1888 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1889 edje_object_signal_emit(target, buf, "elm");
1896 _item_flips_realize(Elm_Gen_Item *it,
1897 Evas_Object *target,
1900 Eina_List *res = NULL;
1902 if (it->itc->func.content_get)
1906 Evas_Object *ic = NULL;
1908 *source = elm_widget_stringlist_get(edje_object_data_get(target, "flips"));
1910 EINA_LIST_FOREACH(*source, l, key)
1912 if (it->itc->func.content_get)
1913 ic = it->itc->func.content_get
1914 ((void *)it->base.data, WIDGET(it), key);
1917 res = eina_list_append(res, ic);
1918 edje_object_part_swallow(target, key, ic);
1919 evas_object_show(ic);
1920 elm_widget_sub_object_add(WIDGET(it), ic);
1921 if (elm_widget_item_disabled_get(it))
1922 elm_widget_disabled_set(ic, EINA_TRUE);
1931 _item_realize(Elm_Gen_Item *it,
1935 const char *treesize;
1938 Item_Cache *itc = NULL;
1940 if (it->generation < it->wd->generation) return;
1941 //evas_event_freeze(evas_object_evas_get(it->wd->obj));
1944 if (it->item->order_num_in != in)
1946 it->item->order_num_in = in;
1947 _elm_genlist_item_odd_even_update(it);
1948 _elm_genlist_item_state_update(it, NULL);
1949 _elm_genlist_item_index_update(it);
1951 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1952 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1955 it->item->order_num_in = in;
1957 if (it->item->nocache_once)
1958 it->item->nocache_once = EINA_FALSE;
1959 else if (!it->item->nocache)
1960 itc = _item_cache_find(it);
1963 VIEW(it) = itc->base_view;
1964 itc->base_view = NULL;
1965 it->spacer = itc->spacer;
1970 const char *stacking_even;
1971 const char *stacking;
1973 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
1974 edje_object_scale_set(VIEW(it),
1975 elm_widget_scale_get(WIDGET(it)) *
1976 _elm_config->scale);
1977 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
1978 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
1980 if (it->item->type & ELM_GENLIST_ITEM_SUBITEMS)
1981 snprintf(buf, sizeof(buf), "tree%s/%s", it->wd->compress ? "_compress" : "", it->itc->item_style ?: "default");
1983 snprintf(buf, sizeof(buf), "item%s/%s", it->wd->compress ? "_compress" : "", it->itc->item_style ?: "default");
1985 _elm_theme_object_set(WIDGET(it), VIEW(it), "genlist", buf,
1986 elm_widget_style_get(WIDGET(it)));
1988 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
1989 if (!stacking_even) stacking_even = "above";
1990 it->item->stacking_even = !!strcmp("above", stacking_even);
1992 stacking = edje_object_data_get(VIEW(it), "stacking");
1993 if (!stacking) stacking = "yes";
1994 it->item->nostacking = !!strcmp("yes", stacking);
1996 edje_object_mirrored_set(VIEW(it),
1997 elm_widget_mirrored_get(WIDGET(it)));
1999 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
2000 evas_object_color_set(it->spacer, 0, 0, 0, 0);
2001 elm_widget_sub_object_add(WIDGET(it), it->spacer);
2004 _elm_genlist_item_odd_even_update(it);
2006 treesize = edje_object_data_get(VIEW(it), "treesize");
2007 if (treesize) tsize = atoi(treesize);
2008 evas_object_size_hint_min_set(it->spacer,
2009 (it->item->expanded_depth * tsize) * _elm_config->scale, 1);
2010 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
2013 edje_object_signal_callback_add(VIEW(it),
2014 "elm,action,expand,toggle",
2015 "elm", _signal_expand_toggle, it);
2016 edje_object_signal_callback_add(VIEW(it), "elm,action,expand",
2017 "elm", _signal_expand, it);
2018 edje_object_signal_callback_add(VIEW(it), "elm,action,contract",
2019 "elm", _signal_contract, it);
2020 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
2022 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
2024 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
2026 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_DOWN,
2028 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_UP,
2030 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_MOVE,
2033 if ((it->wd->edit_mode) && (!it->edit_obj) &&
2034 (it->item->type != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
2035 _edit_mode_item_realize(it, EINA_FALSE);
2037 _elm_genlist_item_state_update(it, itc);
2038 _elm_genlist_item_index_update(it);
2041 if ((calc) && (it->wd->homogeneous) &&
2042 ((it->wd->item_width) ||
2043 ((it->wd->item_width) && (it->wd->group_item_width))))
2045 /* homogenous genlist shortcut */
2046 if (!it->item->mincalcd)
2050 it->item->w = it->item->minw = it->wd->group_item_width;
2051 it->item->h = it->item->minh = it->wd->group_item_height;
2055 it->item->w = it->item->minw = it->wd->item_width;
2056 it->item->h = it->item->minh = it->wd->item_height;
2058 it->item->mincalcd = EINA_TRUE;
2063 /* FIXME: If you see that assert, please notify us and we
2064 will clean our mess */
2065 assert(eina_list_count(it->content_objs) == 0);
2067 _item_text_realize(it, VIEW(it), &it->texts, NULL);
2068 it->content_objs = _item_content_realize(it, VIEW(it), &it->contents, NULL);
2069 _item_state_realize(it, VIEW(it), &it->states, NULL);
2072 edje_object_signal_emit(VIEW(it), "elm,state,flip,enabled", "elm");
2073 it->content_objs = _item_flips_realize(it, VIEW(it), &it->contents);
2076 if (!it->item->mincalcd)
2078 Evas_Coord mw = -1, mh = -1;
2080 if (!it->display_only)
2081 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2082 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2083 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
2085 if (!it->display_only)
2086 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2087 it->item->w = it->item->minw = mw;
2088 it->item->h = it->item->minh = mh;
2089 it->item->mincalcd = EINA_TRUE;
2091 if ((!it->wd->group_item_width) && (it->group))
2093 it->wd->group_item_width = mw;
2094 it->wd->group_item_height = mh;
2096 else if ((!it->wd->item_width) && (it->item->type == ELM_GENLIST_ITEM_NONE))
2098 it->wd->item_width = mw;
2099 it->wd->item_height = mh;
2102 if (!calc) evas_object_show(VIEW(it));
2105 if (it->tooltip.content_cb)
2107 elm_widget_item_tooltip_content_cb_set(it,
2108 it->tooltip.content_cb,
2109 it->tooltip.data, NULL);
2110 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2111 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
2114 if (it->mouse_cursor)
2115 elm_widget_item_cursor_set(it, it->mouse_cursor);
2117 it->realized = EINA_TRUE;
2118 it->want_unrealize = EINA_FALSE;
2120 if (itc) _item_cache_free(itc);
2121 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
2122 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2124 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
2126 if ((!calc) && (it->wd->edit_mode) && (it->item->type != ELM_GENLIST_ITEM_GROUP))
2128 if (it->itc->edit_item_style)
2130 if (!it->edit_obj) _edit_mode_item_realize(it, EINA_FALSE);
2131 edje_object_message_signal_process(it->edit_obj);
2134 edje_object_message_signal_process(VIEW(it));
2138 _item_unrealize_cb(Elm_Gen_Item *it)
2140 if (it->item->nocache_once || it->item->nocache)
2142 evas_object_del(VIEW(it));
2144 evas_object_del(it->spacer);
2149 edje_object_mirrored_set(VIEW(it),
2150 elm_widget_mirrored_get(WIDGET(it)));
2151 edje_object_scale_set(VIEW(it),
2152 elm_widget_scale_get(WIDGET(it))
2153 * _elm_config->scale);
2154 _item_cache_add(it);
2157 _mode_item_unrealize(it);
2159 it->realized = EINA_FALSE;
2160 it->want_unrealize = EINA_FALSE;
2161 if (it->wd->edit_mode) _edit_mode_item_unrealize(it);
2165 _item_block_recalc(Item_Block *itb,
2171 Evas_Coord minw = 0, minh = 0;
2172 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2175 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2177 EINA_LIST_FOREACH(itb->items, l, it)
2179 if (it->generation < it->wd->generation) continue;
2180 showme |= it->item->showme;
2185 if (!it->item->mincalcd) changed = EINA_TRUE;
2188 _item_realize(it, in, EINA_TRUE);
2189 _elm_genlist_item_unrealize(it, EINA_TRUE);
2194 _item_realize(it, in, EINA_TRUE);
2195 _elm_genlist_item_unrealize(it, EINA_TRUE);
2199 _item_realize(it, in, EINA_FALSE);
2200 minh += it->item->minh;
2201 if (minw < it->item->minw) minw = it->item->minw;
2209 itb->changed = EINA_FALSE;
2210 itb->position_update = EINA_FALSE;
2211 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2212 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2217 _item_block_realize(Item_Block *itb)
2219 if (itb->realized) return;
2220 itb->realized = EINA_TRUE;
2221 itb->want_unrealize = EINA_FALSE;
2225 _item_block_unrealize(Item_Block *itb)
2229 Eina_Bool dragging = EINA_FALSE;
2231 if (!itb->realized) return;
2232 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2233 EINA_LIST_FOREACH(itb->items, l, it)
2235 if (itb->must_recalc || !it->group)
2239 dragging = EINA_TRUE;
2240 it->want_unrealize = EINA_TRUE;
2243 _elm_genlist_item_unrealize(it, EINA_FALSE);
2248 itb->realized = EINA_FALSE;
2249 itb->want_unrealize = EINA_TRUE;
2252 itb->want_unrealize = EINA_FALSE;
2253 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2254 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2258 _get_space_for_reorder_item(Elm_Gen_Item *it)
2260 Evas_Coord rox, roy, row, roh, oy, oh;
2261 Eina_Bool top = EINA_FALSE;
2262 Elm_Gen_Item *reorder_it = it->wd->reorder_it;
2263 if (!reorder_it) return 0;
2265 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2266 evas_object_geometry_get(it->wd->VIEW(reorder_it), &rox, &roy, &row, &roh);
2268 if ((it->wd->reorder_start_y < it->item->block->y) &&
2269 (roy - oy + (roh / 2) >= it->item->block->y - it->wd->pan_y))
2271 it->item->block->reorder_offset = it->wd->reorder_it->item->h * -1;
2272 if (it->item->block->count == 1)
2273 it->wd->reorder_rel = it;
2275 else if ((it->wd->reorder_start_y >= it->item->block->y) &&
2276 (roy - oy + (roh / 2) <= it->item->block->y - it->wd->pan_y))
2278 it->item->block->reorder_offset = it->wd->reorder_it->item->h;
2281 it->item->block->reorder_offset = 0;
2283 it->item->scrl_y += it->item->block->reorder_offset;
2285 top = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2286 rox, roy + (roh / 2), row, 1));
2289 it->wd->reorder_rel = it;
2290 it->item->scrl_y += it->wd->reorder_it->item->h;
2291 return it->wd->reorder_it->item->h;
2298 _reorder_move_animator_cb(void *data)
2300 Elm_Gen_Item *it = data;
2301 Eina_Bool down = EINA_FALSE;
2303 int y, dy = it->item->h / 10 * _elm_config->scale, diff;
2305 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2307 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2310 diff = abs(it->item->old_scrl_y - it->item->scrl_y);
2311 if (diff > it->item->h) y = diff / 2;
2313 if (it->item->old_scrl_y < it->item->scrl_y)
2315 it->item->old_scrl_y += y;
2318 else if (it->item->old_scrl_y > it->item->scrl_y)
2320 it->item->old_scrl_y -= y;
2325 _item_position(it, it->edit_obj, it->item->scrl_x, it->item->old_scrl_y);
2327 _item_position(it, VIEW(it), it->item->scrl_x, it->item->old_scrl_y);
2328 _group_items_recalc(it->wd);
2330 if ((it->wd->reorder_pan_move) ||
2331 (down && it->item->old_scrl_y >= it->item->scrl_y) ||
2332 (!down && it->item->old_scrl_y <= it->item->scrl_y))
2334 it->item->old_scrl_y = it->item->scrl_y;
2335 it->item->move_effect_enabled = EINA_FALSE;
2336 it->wd->reorder_move_animator = NULL;
2337 return ECORE_CALLBACK_CANCEL;
2339 return ECORE_CALLBACK_RENEW;
2343 _item_position(Elm_Gen_Item *it,
2351 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2352 evas_object_resize(view, it->item->w, it->item->h);
2353 evas_object_move(view, it_x, it_y);
2354 evas_object_show(view);
2355 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2356 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2360 _item_block_position(Item_Block *itb,
2366 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2367 Eina_Bool vis = EINA_FALSE;
2369 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2370 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2371 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2373 EINA_LIST_FOREACH(itb->items, l, it)
2375 if (it->generation < it->wd->generation) continue;
2376 else if (it->wd->reorder_it == it) continue;
2379 it->item->w = itb->w;
2380 it->item->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2381 it->item->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2383 vis = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2384 cvx, cvy, cvw, cvh));
2387 if ((itb->realized) && (!it->realized))
2389 if (vis) _item_realize(it, in, EINA_FALSE);
2393 if (vis || it->dragging)
2395 if (it->wd->reorder_mode)
2396 y += _get_space_for_reorder_item(it);
2397 git = it->item->group_item;
2400 if (git->item->scrl_y < oy)
2401 git->item->scrl_y = oy;
2402 if ((git->item->scrl_y + git->item->h) > (it->item->scrl_y + it->item->h))
2403 git->item->scrl_y = (it->item->scrl_y + it->item->h) - git->item->h;
2404 git->item->want_realize = EINA_TRUE;
2406 if ((it->wd->reorder_it) && (it->item->old_scrl_y != it->item->scrl_y))
2408 if (!it->item->move_effect_enabled)
2410 it->item->move_effect_enabled = EINA_TRUE;
2411 it->wd->reorder_move_animator =
2413 _reorder_move_animator_cb, it);
2416 if (!it->item->move_effect_enabled)
2418 if ((it->wd->edit_mode) && (it->itc->edit_item_style))
2419 _edit_mode_item_position(it, it->item->scrl_x,
2423 if (it->item->mode_view)
2424 _item_position(it, it->item->mode_view,
2428 _item_position(it, VIEW(it), it->item->scrl_x,
2431 it->item->old_scrl_y = it->item->scrl_y;
2436 _elm_genlist_item_unrealize(it, EINA_FALSE);
2443 if (vis) it->item->want_realize = EINA_TRUE;
2447 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2448 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2452 _group_items_recalc(void *data)
2454 Widget_Data *wd = data;
2458 evas_event_freeze(evas_object_evas_get(wd->obj));
2459 EINA_LIST_FOREACH(wd->group_items, l, git)
2461 if (git->item->want_realize)
2464 _item_realize(git, 0, EINA_FALSE);
2465 evas_object_resize(VIEW(git), wd->minw, git->item->h);
2466 evas_object_move(VIEW(git), git->item->scrl_x, git->item->scrl_y);
2467 evas_object_show(VIEW(git));
2468 evas_object_raise(VIEW(git));
2470 else if (!git->item->want_realize && git->realized)
2473 _elm_genlist_item_unrealize(git, EINA_FALSE);
2476 evas_event_thaw(evas_object_evas_get(wd->obj));
2477 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2481 _must_recalc_idler(void *data)
2483 Widget_Data *wd = data;
2484 if (wd->calc_job) ecore_job_del(wd->calc_job);
2485 wd->calc_job = ecore_job_add(_calc_job, wd);
2486 wd->must_recalc_idler = NULL;
2487 return ECORE_CALLBACK_CANCEL;
2491 _scroll_item(Widget_Data *wd)
2493 Elm_Gen_Item *it = NULL;
2494 Evas_Coord gith = 0;
2495 Evas_Coord ow, oh, dx = 0, dy = 0, dw = 0, dh = 0;
2497 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
2499 dx = it->x + it->item->block->x;
2500 dy = it->y + it->item->block->y;
2501 dw = it->item->block->w;
2503 switch (wd->scrollto_type)
2505 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
2506 if (it->item->group_item) gith = it->item->group_item->item->h;
2509 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
2510 dy += (it->item->h / 2 - oh / 2);
2512 case ELM_GENLIST_ITEM_SCROLLTO_IN:
2514 if ((wd->expanded_item) &&
2515 ((wd->show_item->y + wd->show_item->item->block->y + wd->show_item->item->h)
2516 - (wd->expanded_item->y + wd->expanded_item->item->block->y) > oh))
2518 it = wd->expanded_item;
2519 if (it->item->group_item) gith = it->item->group_item->item->h;
2520 dx = it->x + it->item->block->x;
2521 dy = it->y + it->item->block->y - gith;
2522 dw = it->item->block->w;
2526 if ((it->item->group_item) && (wd->pan_y > (it->y + it->item->block->y)))
2527 gith = it->item->group_item->item->h;
2534 elm_smart_scroller_region_bring_in(wd->scr, dx, dy, dw, dh);
2536 elm_smart_scroller_child_region_show(wd->scr, dx, dy, dw, dh);
2538 it->item->showme = EINA_FALSE;
2539 wd->show_item = NULL;
2540 wd->auto_scroll_enabled = EINA_FALSE;
2541 wd->check_scroll = EINA_FALSE;
2545 _calc_job(void *data)
2547 Widget_Data *wd = data;
2548 Item_Block *itb, *chb = NULL;
2549 Evas_Coord minw = -1, minh = 0, y = 0, ow, dy = 0, vw;
2550 Evas_Coord pan_w = 0, pan_h = 0;
2552 Eina_Bool minw_change = EINA_FALSE;
2553 Eina_Bool did_must_recalc = EINA_FALSE;
2556 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2557 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, NULL);
2562 evas_event_freeze(evas_object_evas_get(wd->obj));
2563 EINA_INLIST_FOREACH(wd->blocks, itb)
2565 Eina_Bool showme = EINA_FALSE;
2568 showme = itb->showme;
2569 itb->showme = EINA_FALSE;
2572 if (itb->realized) _item_block_unrealize(itb);
2574 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2576 if (itb->must_recalc)
2580 EINA_LIST_FOREACH(itb->items, l, it)
2581 if (it->item->mincalcd) it->item->mincalcd = EINA_FALSE;
2582 itb->changed = EINA_TRUE;
2583 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2584 if (itb->realized) _item_block_unrealize(itb);
2585 itb->must_recalc = EINA_FALSE;
2587 showme = _item_block_recalc(itb, in, EINA_FALSE);
2593 if (minw == -1) minw = itb->minw;
2594 else if ((!itb->must_recalc) && (minw < itb->minw))
2597 minw_change = EINA_TRUE;
2602 minw_change = EINA_TRUE;
2608 if ((showme) && (wd->show_item) && (!wd->show_item->item->queued))
2609 wd->check_scroll = EINA_TRUE;
2613 EINA_INLIST_FOREACH(wd->blocks, itb)
2619 if ((chb) && (EINA_INLIST_GET(chb)->next))
2621 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2623 if (itb->realized) _item_block_unrealize(itb);
2626 wd->realminw = minw;
2627 if (minw < wd->w) minw = wd->w;
2628 if ((minw != wd->minw) || (minh != wd->minh))
2632 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2633 _sizing_eval(wd->obj);
2634 if ((wd->anchor_item) && (wd->anchor_item->item->block) && (!wd->auto_scroll_enabled))
2639 it = wd->anchor_item;
2640 it_y = wd->anchor_y;
2641 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2642 it->item->block->y + it->y + it_y);
2643 wd->anchor_item = it;
2644 wd->anchor_y = it_y;
2647 if (did_must_recalc)
2649 if (!wd->must_recalc_idler)
2650 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2652 if (wd->check_scroll)
2654 _pan_child_size_get(wd->pan_smart, &pan_w, &pan_h);
2655 if (EINA_INLIST_GET(wd->show_item) == wd->items->last)
2656 wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
2657 switch (wd->scrollto_type)
2659 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
2662 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
2665 case ELM_GENLIST_ITEM_SCROLLTO_IN:
2670 if ((pan_w > (wd->show_item->x + wd->show_item->item->block->x)) &&
2671 (pan_h > (wd->show_item->y + wd->show_item->item->block->y + dy)))
2676 wd->calc_job = NULL;
2677 evas_object_smart_changed(wd->pan_smart);
2678 evas_event_thaw(evas_object_evas_get(wd->obj));
2679 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2683 _update_job(void *data)
2685 Widget_Data *wd = data;
2689 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2691 wd->update_job = NULL;
2694 evas_event_freeze(evas_object_evas_get(wd->obj));
2695 EINA_INLIST_FOREACH(wd->blocks, itb)
2697 Evas_Coord itminw, itminh;
2704 _item_block_position(itb, num);
2708 recalc = EINA_FALSE;
2709 EINA_LIST_FOREACH(itb->items, l2, it)
2711 if (it->item->updateme)
2713 itminw = it->item->minw;
2714 itminh = it->item->minh;
2716 it->item->updateme = EINA_FALSE;
2719 _elm_genlist_item_unrealize(it, EINA_FALSE);
2720 _item_realize(it, num, EINA_FALSE);
2721 position = EINA_TRUE;
2725 _item_realize(it, num, EINA_TRUE);
2726 _elm_genlist_item_unrealize(it, EINA_TRUE);
2728 if ((it->item->minw != itminw) || (it->item->minh != itminh))
2733 itb->updateme = EINA_FALSE;
2736 position = EINA_TRUE;
2737 itb->changed = EINA_TRUE;
2738 _item_block_recalc(itb, num0, EINA_FALSE);
2739 _item_block_position(itb, num0);
2744 if (wd->calc_job) ecore_job_del(wd->calc_job);
2745 wd->calc_job = ecore_job_add(_calc_job, wd);
2747 evas_event_thaw(evas_object_evas_get(wd->obj));
2748 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2752 _pan_set(Evas_Object *obj,
2756 Pan *sd = evas_object_smart_data_get(obj);
2760 // Evas_Coord ow, oh;
2761 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2762 // ow = sd->wd->minw - ow;
2763 // if (ow < 0) ow = 0;
2764 // oh = sd->wd->minh - oh;
2765 // if (oh < 0) oh = 0;
2766 // if (x < 0) x = 0;
2767 // if (y < 0) y = 0;
2768 // if (x > ow) x = ow;
2769 // if (y > oh) y = oh;
2770 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2774 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2776 if ((itb->y + itb->h) > y)
2781 EINA_LIST_FOREACH(itb->items, l2, it)
2783 if ((itb->y + it->y) >= y)
2785 sd->wd->anchor_item = it;
2786 sd->wd->anchor_y = -(itb->y + it->y - y);
2793 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2797 _pan_get(Evas_Object *obj,
2801 Pan *sd = evas_object_smart_data_get(obj);
2804 if (x) *x = sd->wd->pan_x;
2805 if (y) *y = sd->wd->pan_y;
2809 _pan_max_get(Evas_Object *obj,
2813 Pan *sd = evas_object_smart_data_get(obj);
2817 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2818 ow = sd->wd->minw - ow;
2820 oh = sd->wd->minh - oh;
2827 _pan_min_get(Evas_Object *obj __UNUSED__,
2836 _pan_child_size_get(Evas_Object *obj,
2840 Pan *sd = evas_object_smart_data_get(obj);
2843 if (w) *w = sd->wd->minw;
2844 if (h) *h = sd->wd->minh;
2848 _pan_add(Evas_Object *obj)
2851 Evas_Object_Smart_Clipped_Data *cd;
2854 cd = evas_object_smart_data_get(obj);
2857 sd->__clipped_data = *cd;
2859 evas_object_smart_data_set(obj, sd);
2863 _pan_del(Evas_Object *obj)
2865 Pan *sd = evas_object_smart_data_get(obj);
2870 ecore_job_del(sd->resize_job);
2871 sd->resize_job = NULL;
2877 _pan_resize_job(void *data)
2881 _sizing_eval(sd->wd->obj);
2882 sd->resize_job = NULL;
2886 _pan_resize(Evas_Object *obj,
2890 Pan *sd = evas_object_smart_data_get(obj);
2894 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2895 if ((ow == w) && (oh == h)) return;
2896 if ((sd->wd->height_for_width) && (ow != w))
2899 if (sd->resize_job) ecore_job_del(sd->resize_job);
2900 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2902 sd->wd->pan_changed = EINA_TRUE;
2903 evas_object_smart_changed(obj);
2904 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2905 sd->wd->calc_job = NULL;
2907 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2908 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2913 _pan_calculate(Evas_Object *obj)
2915 Pan *sd = evas_object_smart_data_get(obj);
2917 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2923 evas_event_freeze(evas_object_evas_get(obj));
2925 if (sd->wd->pan_changed)
2928 sd->wd->pan_changed = EINA_FALSE;
2931 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2932 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2933 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2935 git->item->want_realize = EINA_FALSE;
2937 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2939 itb->w = sd->wd->minw;
2940 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2941 itb->y - sd->wd->pan_y + oy,
2943 cvx, cvy, cvw, cvh))
2945 if ((!itb->realized) || (itb->changed))
2946 _item_block_realize(itb);
2947 _item_block_position(itb, in);
2951 if (itb->realized) _item_block_unrealize(itb);
2955 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2956 _group_items_recalc(sd->wd);
2957 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2959 if (sd->wd->pan_y != sd->wd->reorder_old_pan_y)
2960 sd->wd->reorder_pan_move = EINA_TRUE;
2961 else sd->wd->reorder_pan_move = EINA_FALSE;
2962 evas_object_raise(sd->wd->VIEW(reorder_it));
2963 sd->wd->reorder_old_pan_y = sd->wd->pan_y;
2964 sd->wd->start_time = ecore_loop_time_get();
2966 _item_auto_scroll(sd->wd);
2967 evas_event_thaw(evas_object_evas_get(obj));
2968 evas_event_thaw_eval(evas_object_evas_get(obj));
2972 _pan_move(Evas_Object *obj,
2973 Evas_Coord x __UNUSED__,
2974 Evas_Coord y __UNUSED__)
2976 Pan *sd = evas_object_smart_data_get(obj);
2980 sd->wd->pan_changed = EINA_TRUE;
2981 evas_object_smart_changed(obj);
2982 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2983 sd->wd->calc_job = NULL;
2987 _hold_on(void *data __UNUSED__,
2989 void *event_info __UNUSED__)
2991 Widget_Data *wd = elm_widget_data_get(obj);
2993 elm_smart_scroller_hold_set(wd->scr, 1);
2997 _hold_off(void *data __UNUSED__,
2999 void *event_info __UNUSED__)
3001 Widget_Data *wd = elm_widget_data_get(obj);
3003 elm_smart_scroller_hold_set(wd->scr, 0);
3007 _freeze_on(void *data __UNUSED__,
3009 void *event_info __UNUSED__)
3011 Widget_Data *wd = elm_widget_data_get(obj);
3013 elm_smart_scroller_freeze_set(wd->scr, 1);
3017 _freeze_off(void *data __UNUSED__,
3019 void *event_info __UNUSED__)
3021 Widget_Data *wd = elm_widget_data_get(obj);
3023 elm_smart_scroller_freeze_set(wd->scr, 0);
3027 _scr_anim_start(void *data,
3028 Evas_Object *obj __UNUSED__,
3029 void *event_info __UNUSED__)
3031 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
3035 _scr_anim_stop(void *data,
3036 Evas_Object *obj __UNUSED__,
3037 void *event_info __UNUSED__)
3039 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
3043 _scr_drag_start(void *data,
3044 Evas_Object *obj __UNUSED__,
3045 void *event_info __UNUSED__)
3047 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
3051 _scr_drag_stop(void *data,
3052 Evas_Object *obj __UNUSED__,
3053 void *event_info __UNUSED__)
3055 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
3059 _edge_left(void *data,
3060 Evas_Object *scr __UNUSED__,
3061 void *event_info __UNUSED__)
3063 Evas_Object *obj = data;
3064 evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
3068 _edge_right(void *data,
3069 Evas_Object *scr __UNUSED__,
3070 void *event_info __UNUSED__)
3072 Evas_Object *obj = data;
3073 evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
3077 _edge_top(void *data,
3078 Evas_Object *scr __UNUSED__,
3079 void *event_info __UNUSED__)
3081 Evas_Object *obj = data;
3082 evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
3086 _edge_bottom(void *data,
3087 Evas_Object *scr __UNUSED__,
3088 void *event_info __UNUSED__)
3090 Evas_Object *obj = data;
3091 evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
3095 _mode_item_realize(Elm_Gen_Item *it)
3099 if ((it->item->mode_view) || (it->generation < it->wd->generation)) return;
3101 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3102 it->item->mode_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
3103 edje_object_scale_set(it->item->mode_view,
3104 elm_widget_scale_get(WIDGET(it)) *
3105 _elm_config->scale);
3106 evas_object_smart_member_add(it->item->mode_view, it->wd->pan_smart);
3107 elm_widget_sub_object_add(WIDGET(it), it->item->mode_view);
3109 strncpy(buf, "item", sizeof(buf));
3110 if (it->wd->compress)
3111 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3113 if (it->item->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3114 strncat(buf, "/", sizeof(buf) - strlen(buf));
3115 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3117 _elm_theme_object_set(WIDGET(it), it->item->mode_view, "genlist", buf,
3118 elm_widget_style_get(WIDGET(it)));
3119 edje_object_mirrored_set(it->item->mode_view,
3120 elm_widget_mirrored_get(WIDGET(it)));
3122 /* signal callback add */
3123 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3125 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_UP,
3127 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3130 /* text_get, content_get, state_get */
3131 /* FIXME: If you see that assert, please notify us and we
3132 will clean our mess */
3133 assert(eina_list_count(it->item->mode_content_objs) == 0);
3135 _item_text_realize(it, it->item->mode_view, &it->item->mode_texts, NULL);
3136 it->item->mode_content_objs =
3137 _item_content_realize(it, it->item->mode_view,
3138 &it->item->mode_contents, NULL);
3139 _item_state_realize(it, it->item->mode_view, &it->item->mode_states, NULL);
3141 edje_object_part_swallow(it->item->mode_view,
3142 edje_object_data_get(it->item->mode_view, "mode_part"),
3145 it->want_unrealize = EINA_FALSE;
3146 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3147 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3151 _mode_item_unrealize(Elm_Gen_Item *it)
3153 Widget_Data *wd = it->wd;
3154 Evas_Object *content;
3155 if (!it->item->mode_view) return;
3157 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3158 elm_widget_stringlist_free(it->item->mode_texts);
3159 it->item->mode_texts = NULL;
3160 elm_widget_stringlist_free(it->item->mode_contents);
3161 it->item->mode_contents = NULL;
3162 elm_widget_stringlist_free(it->item->mode_states);
3164 EINA_LIST_FREE(it->item->mode_content_objs, content)
3165 evas_object_del(content);
3167 edje_object_part_unswallow(it->item->mode_view, VIEW(it));
3168 evas_object_smart_member_add(VIEW(it), wd->pan_smart);
3169 evas_object_del(it->item->mode_view);
3170 it->item->mode_view = NULL;
3172 if (wd->mode_item == it)
3173 wd->mode_item = NULL;
3174 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3175 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3179 _item_mode_set(Elm_Gen_Item *it)
3182 Widget_Data *wd = it->wd;
3187 it->item->nocache_once = EINA_TRUE;
3189 if (wd->scr_hold_timer)
3191 ecore_timer_del(wd->scr_hold_timer);
3192 wd->scr_hold_timer = NULL;
3194 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3195 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3197 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3198 _mode_item_realize(it);
3199 if (it->item->group_item)
3200 evas_object_raise(it->item->VIEW(group_item));
3201 _item_position(it, it->item->mode_view, it->item->scrl_x, it->item->scrl_y);
3202 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3203 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3205 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3206 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3210 _item_mode_unset(Widget_Data *wd)
3213 if (!wd->mode_item) return;
3214 char buf[1024], buf2[1024];
3218 it->item->nocache_once = EINA_TRUE;
3220 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3221 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3223 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3224 edje_object_signal_callback_add(it->item->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3226 wd->mode_item = NULL;
3230 _edit_mode_item_position(Elm_Gen_Item *it, int itx, int ity)
3232 if ((!it) || (!it->wd->edit_mode)) return;
3233 evas_object_resize(it->edit_obj, it->item->w, it->item->h);
3234 evas_object_move(it->edit_obj, itx, ity);
3238 _edit_mode_item_realize(Elm_Gen_Item *it, Eina_Bool effect_on)
3241 const char *stacking_even;
3242 const char *stacking;
3244 if ((!it) || (it->item->edit_mode_item_realized) ||
3245 (it->generation < it->wd->generation))
3248 it->edit_obj = edje_object_add(evas_object_evas_get(WIDGET(it)));
3249 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(WIDGET(it)) *
3250 _elm_config->scale);
3251 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
3252 elm_widget_sub_object_add(WIDGET(it), it->edit_obj);
3254 if (it->item->type & ELM_GENLIST_ITEM_SUBITEMS)
3255 strncpy(buf, "tree", sizeof(buf));
3256 else strncpy(buf, "item", sizeof(buf));
3257 if (it->wd->compress)
3258 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3260 strncat(buf, "/", sizeof(buf) - strlen(buf));
3261 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
3263 _elm_theme_object_set(WIDGET(it), it->edit_obj, "genlist", buf,
3264 elm_widget_style_get(WIDGET(it)));
3266 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
3267 if (!stacking_even) stacking_even = "above";
3268 it->item->stacking_even = !!strcmp("above", stacking_even);
3270 stacking = edje_object_data_get(VIEW(it), "stacking");
3271 if (!stacking) stacking = "yes";
3272 it->item->nostacking = !!strcmp("yes", stacking);
3274 edje_object_mirrored_set(it->edit_obj,
3275 elm_widget_mirrored_get(WIDGET(it)));
3277 _elm_genlist_item_odd_even_update(it);
3278 _elm_genlist_item_state_update(it, NULL);
3280 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,edit,enabled,effect", "elm");
3281 else edje_object_signal_emit(it->edit_obj, "elm,state,edit,enabled", "elm");
3283 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
3285 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
3287 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
3289 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_DOWN,
3291 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_UP,
3293 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_MOVE,
3296 _item_text_realize(it, it->edit_obj, &it->item->edit_texts, NULL);
3297 if (it->flipped) edje_object_signal_emit(it->edit_obj, "elm,state,flip,enabled", "elm");
3298 it->item->edit_content_objs =
3299 _item_content_realize(it, it->edit_obj, &it->item->edit_contents, NULL);
3300 _item_state_realize(it, it->edit_obj, &it->item->edit_states, NULL);
3301 edje_object_part_swallow(it->edit_obj, "elm.swallow.edit.content", VIEW(it));
3303 _edit_mode_item_position(it, it->item->scrl_x, it->item->scrl_y);
3304 evas_object_show(it->edit_obj);
3306 it->item->edit_mode_item_realized = EINA_TRUE;
3307 it->want_unrealize = EINA_FALSE;
3311 _edit_mode_item_unrealize(Elm_Gen_Item *it)
3314 if ((!it) || (!it->item->edit_mode_item_realized)) return;
3316 edje_object_part_unswallow(it->edit_obj, VIEW(it));
3317 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
3318 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
3319 _elm_genlist_item_odd_even_update(it);
3320 _elm_genlist_item_state_update(it, NULL);
3322 evas_object_del(it->edit_obj);
3323 it->edit_obj = NULL;
3324 elm_widget_stringlist_free(it->item->edit_texts);
3325 it->item->edit_texts = NULL;
3326 elm_widget_stringlist_free(it->item->edit_contents);
3327 it->item->edit_contents = NULL;
3328 elm_widget_stringlist_free(it->item->edit_states);
3329 it->item->edit_states = NULL;
3330 EINA_LIST_FREE(it->item->edit_content_objs, icon)
3331 evas_object_del(icon);
3332 edje_object_message_signal_process(it->edit_obj);
3334 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
3336 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
3338 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
3340 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_DOWN,
3342 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_UP,
3344 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_MOVE,
3346 it->item->edit_mode_item_realized = EINA_FALSE;
3350 _item_auto_scroll(Widget_Data *wd)
3353 Elm_Gen_Item *tmp_item = NULL;
3355 if ((wd->expanded_item) && (wd->auto_scroll_enabled))
3357 tmp_item = eina_list_data_get(eina_list_last(wd->expanded_item->item->items));
3358 if (!tmp_item) return;
3359 wd->show_item = tmp_item;
3360 wd->bring_in = EINA_TRUE;
3361 wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
3362 if ((wd->show_item->item->queued) || (!wd->show_item->item->mincalcd))
3364 wd->show_item->item->showme = EINA_TRUE;
3365 wd->auto_scroll_enabled = EINA_FALSE;
3373 elm_genlist_add(Evas_Object *parent)
3378 Evas_Coord minw, minh;
3379 static Evas_Smart *smart = NULL;
3383 static Evas_Smart_Class sc;
3385 evas_object_smart_clipped_smart_set(&_pan_sc);
3387 sc.name = "elm_genlist_pan";
3388 sc.version = EVAS_SMART_CLASS_VERSION;
3391 sc.resize = _pan_resize;
3392 sc.move = _pan_move;
3393 sc.calculate = _pan_calculate;
3394 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3397 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3399 ELM_SET_WIDTYPE(widtype, "genlist");
3401 elm_widget_type_set(obj, "genlist");
3402 elm_widget_sub_object_add(parent, obj);
3403 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3404 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3405 elm_widget_data_set(obj, wd);
3406 elm_widget_del_hook_set(obj, _del_hook);
3407 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3408 elm_widget_theme_hook_set(obj, _theme_hook);
3409 elm_widget_can_focus_set(obj, EINA_TRUE);
3410 elm_widget_event_hook_set(obj, _event_hook);
3411 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3412 elm_widget_translate_hook_set(obj, _translate_hook);
3415 wd->scr = elm_smart_scroller_add(e);
3416 elm_smart_scroller_widget_set(wd->scr, obj);
3417 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3418 elm_widget_style_get(obj));
3419 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3420 _elm_config->thumbscroll_bounce_enable);
3421 elm_widget_resize_object_set(obj, wd->scr);
3423 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3424 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3425 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3426 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3427 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
3428 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
3429 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
3430 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
3433 wd->mode = ELM_LIST_SCROLL;
3434 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3435 wd->item_cache_max = wd->max_items_per_block * 2;
3436 wd->longpress_timeout = _elm_config->longpress_timeout;
3438 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3439 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3440 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3441 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3443 wd->pan_smart = evas_object_smart_add(e, smart);
3444 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3447 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3448 _pan_set, _pan_get, _pan_max_get,
3449 _pan_min_get, _pan_child_size_get);
3451 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3453 evas_object_size_hint_min_set(obj, minw, minh);
3455 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3457 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3463 _item_select(Elm_Gen_Item *it)
3465 if ((it->wd->no_select) || (it->generation < it->wd->generation) || (it->mode_set)) return;
3468 it->selected = EINA_TRUE;
3469 it->wd->selected = eina_list_append(it->wd->selected, it);
3471 else if (!it->wd->always_select) return;
3473 evas_object_ref(WIDGET(it));
3476 if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), it);
3477 if (it->generation == it->wd->generation)
3478 evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
3481 evas_object_unref(WIDGET(it));
3482 if ((it->wd->clear_me) && (!it->wd->walking))
3483 _elm_genlist_clear(WIDGET(it), EINA_TRUE);
3486 if ((!it->walking) && (it->generation < it->wd->generation))
3491 elm_widget_item_free(it);
3495 it->wd->last_selected_item = (Elm_Object_Item *)it;
3499 static Evas_Object *
3500 _item_content_get_hook(Elm_Gen_Item *it, const char *part)
3502 return edje_object_part_swallow_get(VIEW(it), part);
3506 _item_content_set_hook(Elm_Gen_Item *it, const char *part, Evas_Object *content)
3508 if (content && part)
3510 it->content_objs = eina_list_append(it->content_objs, content);
3511 edje_object_part_swallow(VIEW(it), part, content);
3515 static Evas_Object *
3516 _item_content_unset_hook(Elm_Gen_Item *it, const char *part)
3519 obj = edje_object_part_swallow_get(VIEW(it), part);
3520 if (!obj) return NULL;
3521 it->content_objs = eina_list_remove(it->content_objs, obj);
3522 edje_object_part_unswallow(VIEW(it), obj);
3527 _item_text_hook(Elm_Gen_Item *it, const char *part)
3529 if (!it->itc->func.text_get) return NULL;
3530 return edje_object_part_text_get(VIEW(it), part);
3534 _item_disable_hook(Elm_Object_Item *it)
3538 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3540 if (_it->generation < _it->wd->generation) return;
3543 elm_genlist_item_selected_set(it, EINA_FALSE);
3547 if (elm_widget_item_disabled_get(it))
3549 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
3551 edje_object_signal_emit(_it->edit_obj, "elm,state,disabled", "elm");
3555 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
3557 edje_object_signal_emit(_it->edit_obj, "elm,state,enabled", "elm");
3559 EINA_LIST_FOREACH(_it->content_objs, l, obj)
3560 elm_widget_disabled_set(obj, elm_widget_item_disabled_get(_it));
3565 _item_del_pre_hook(Elm_Object_Item *it)
3567 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3569 if ((_it->relcount > 0) || (_it->walking > 0))
3571 elm_genlist_item_subitems_clear(it);
3572 if (_it->wd->show_item == _it) _it->wd->show_item = NULL;
3573 _elm_genlist_item_del_notserious(_it);
3574 if (_it->item->block)
3576 if (_it->realized) _elm_genlist_item_unrealize(_it, EINA_FALSE);
3577 _it->item->block->changed = EINA_TRUE;
3578 if (_it->wd->calc_job) ecore_job_del(_it->wd->calc_job);
3579 _it->wd->calc_job = ecore_job_add(_calc_job, _it->wd);
3583 _it->parent->item->items =
3584 eina_list_remove(_it->parent->item->items, it);
3594 _elm_genlist_item_new(Widget_Data *wd,
3595 const Elm_Gen_Item_Class *itc,
3597 Elm_Gen_Item *parent,
3599 const void *func_data)
3603 it = elm_widget_item_new(wd->obj, Elm_Gen_Item);
3604 if (!it) return NULL;
3606 it->generation = wd->generation;
3608 elm_genlist_item_class_ref((Elm_Genlist_Item_Class *)itc);
3609 it->base.data = data;
3610 it->parent = parent;
3611 it->func.func = func;
3612 it->func.data = func_data;
3613 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
3614 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
3615 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
3616 elm_widget_item_text_get_hook_set(it, _item_text_hook);
3617 elm_widget_item_disable_hook_set(it, _item_disable_hook);
3618 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
3620 it->sel_cb = (Ecore_Cb)_item_select;
3625 static Elm_Gen_Item *
3626 _item_new(Widget_Data *wd,
3627 const Elm_Genlist_Item_Class *itc,
3629 Elm_Gen_Item *parent,
3630 Elm_Genlist_Item_Type type,
3632 const void *func_data)
3634 Elm_Gen_Item *it, *it2;
3637 it = _elm_genlist_item_new(wd, itc, data, parent, func, func_data);
3638 if (!it) return NULL;
3639 it->item = ELM_NEW(Elm_Gen_Item_Type);
3640 it->item->type = type;
3641 if (type & ELM_GENLIST_ITEM_GROUP) it->group++;
3642 it->item->expanded_depth = 0;
3643 ELM_GEN_ITEM_SETUP(it);
3646 if (it->parent->group)
3647 it->item->group_item = parent;
3648 else if (it->parent->item->group_item)
3649 it->item->group_item = it->parent->item->group_item;
3651 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
3653 if (!it2->parent->group) depth += 1;
3655 it->item->expanded_depth = depth;
3661 _item_block_new(Widget_Data *wd, Eina_Bool prepend)
3665 itb = calloc(1, sizeof(Item_Block));
3666 if (!itb) return NULL;
3670 wd->blocks = eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3671 _item_block_position_update(wd->blocks, 0);
3675 wd->blocks = eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3676 itb->position_update = EINA_TRUE;
3677 if (wd->blocks != EINA_INLIST_GET(itb))
3679 itb->position = ((Item_Block *) (EINA_INLIST_GET(itb)->prev))->position + 1;
3690 _item_block_add(Widget_Data *wd,
3693 Item_Block *itb = NULL;
3700 itb = calloc(1, sizeof(Item_Block));
3701 if (!itb) return EINA_FALSE;
3703 if (!it->item->rel->item->block)
3706 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3707 itb->items = eina_list_append(itb->items, it);
3708 itb->position_update = EINA_TRUE;
3709 it->position = eina_list_count(itb->items);
3710 it->position_update = EINA_TRUE;
3712 if (wd->blocks != EINA_INLIST_GET(itb))
3714 itb->position = ((Item_Block *) (EINA_INLIST_GET(itb)->prev))->position + 1;
3725 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3726 if (it->item->before)
3728 wd->blocks = eina_inlist_prepend_relative
3729 (wd->blocks, EINA_INLIST_GET(itb),
3730 EINA_INLIST_GET(it->item->rel->item->block));
3732 eina_list_prepend_relative_list(itb->items, it, tmp);
3734 /* Update index from where we prepended */
3735 _item_position_update(eina_list_prev(tmp), it->item->rel->position);
3736 _item_block_position_update(EINA_INLIST_GET(itb),
3737 it->item->rel->item->block->position);
3741 wd->blocks = eina_inlist_append_relative
3742 (wd->blocks, EINA_INLIST_GET(itb),
3743 EINA_INLIST_GET(it->item->rel->item->block));
3745 eina_list_append_relative_list(itb->items, it, tmp);
3747 /* Update block index from where we appended */
3748 _item_position_update(eina_list_next(tmp), it->item->rel->position + 1);
3749 _item_block_position_update(EINA_INLIST_GET(itb),
3750 it->item->rel->item->block->position + 1);
3756 if (it->item->before)
3760 itb = (Item_Block *)(wd->blocks);
3761 if (itb->count >= wd->max_items_per_block)
3763 itb = _item_block_new(wd, EINA_TRUE);
3764 if (!itb) return EINA_FALSE;
3769 itb = _item_block_new(wd, EINA_TRUE);
3770 if (!itb) return EINA_FALSE;
3772 itb->items = eina_list_prepend(itb->items, it);
3774 _item_position_update(itb->items, 0);
3780 itb = (Item_Block *)(wd->blocks->last);
3781 if (itb->count >= wd->max_items_per_block)
3783 itb = _item_block_new(wd, EINA_FALSE);
3784 if (!itb) return EINA_FALSE;
3789 itb = _item_block_new(wd, EINA_FALSE);
3790 if (!itb) return EINA_FALSE;
3792 itb->items = eina_list_append(itb->items, it);
3793 it->position = eina_list_count(itb->items);
3801 if (it->item->rel->item->queued)
3803 /* NOTE: for a strange reason eina_list and eina_inlist don't have the same property
3804 on sorted insertion order, so the queue is not always ordered like the item list.
3805 This lead to issue where we depend on an item that is not yet created. As a quick
3806 work around, we reschedule the calc of the item and stop reordering the list to
3807 prevent any nasty issue to show up here.
3809 wd->queue = eina_list_append(wd->queue, it);
3810 wd->requeued = EINA_TRUE;
3811 it->item->queued = EINA_TRUE;
3814 itb = it->item->rel->item->block;
3815 if (!itb) goto newblock;
3816 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3817 if (it->item->before)
3819 itb->items = eina_list_prepend_relative_list(itb->items, it, tmp);
3820 _item_position_update(eina_list_prev(tmp), it->item->rel->position);
3824 itb->items = eina_list_append_relative_list(itb->items, it, tmp);
3825 _item_position_update(eina_list_next(tmp), it->item->rel->position + 1);
3829 itb->changed = EINA_TRUE;
3830 it->item->block = itb;
3831 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3832 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3835 it->item->rel->relcount--;
3836 if ((it->item->rel->generation < it->wd->generation) && (!it->item->rel->relcount))
3838 _item_del(it->item->rel);
3839 elm_widget_item_free(it->item->rel);
3841 it->item->rel = NULL;
3843 if (itb->count > itb->wd->max_items_per_block)
3848 Eina_Bool done = EINA_FALSE;
3850 newc = itb->count / 2;
3852 if (EINA_INLIST_GET(itb)->prev)
3854 Item_Block *itbp = (Item_Block *)(EINA_INLIST_GET(itb)->prev);
3856 if (itbp->count + newc < wd->max_items_per_block / 2)
3858 /* moving items to previous block */
3859 while ((itb->count > newc) && (itb->items))
3861 it2 = eina_list_data_get(itb->items);
3862 itb->items = eina_list_remove_list(itb->items, itb->items);
3865 itbp->items = eina_list_append(itbp->items, it2);
3866 it2->item->block = itbp;
3874 if (!done && EINA_INLIST_GET(itb)->next)
3876 Item_Block *itbn = (Item_Block *)(EINA_INLIST_GET(itb)->next);
3878 if (itbn->count + newc < wd->max_items_per_block / 2)
3880 /* moving items to next block */
3881 while ((itb->count > newc) && (itb->items))
3885 l = eina_list_last(itb->items);
3886 it2 = eina_list_data_get(l);
3887 itb->items = eina_list_remove_list(itb->items, l);
3890 itbn->items = eina_list_prepend(itbn->items, it2);
3891 it2->item->block = itbn;
3901 /* moving items to new block */
3902 itb2 = calloc(1, sizeof(Item_Block));
3903 if (!itb2) return EINA_FALSE;
3906 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3907 EINA_INLIST_GET(itb));
3908 itb2->changed = EINA_TRUE;
3909 while ((itb->count > newc) && (itb->items))
3913 l = eina_list_last(itb->items);
3915 itb->items = eina_list_remove_list(itb->items, l);
3918 itb2->items = eina_list_prepend(itb2->items, it2);
3919 it2->item->block = itb2;
3929 _queue_process(Widget_Data *wd)
3932 Eina_Bool showme = EINA_FALSE;
3935 t0 = ecore_loop_time_get();
3936 //evas_event_freeze(evas_object_evas_get(wd->obj));
3937 for (n = 0; (wd->queue) && (n < 128); n++)
3941 it = eina_list_data_get(wd->queue);
3942 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3943 it->item->queued = EINA_FALSE;
3944 if (!_item_block_add(wd, it)) continue;
3946 _item_block_realize(it->item->block);
3947 t = ecore_time_get();
3948 if (it->item->block->changed)
3950 showme = _item_block_recalc(it->item->block, it->item->block->num, EINA_TRUE);
3951 it->item->block->changed = 0;
3952 if (wd->pan_changed)
3954 if (wd->calc_job) ecore_job_del(wd->calc_job);
3955 wd->calc_job = NULL;
3957 wd->pan_changed = EINA_FALSE;
3960 if (showme) it->item->block->showme = EINA_TRUE;
3961 /* same as eina_inlist_count > 1 */
3962 if (wd->blocks && wd->blocks->next)
3964 if ((t - t0) > (ecore_animator_frametime_get())) break;
3967 //evas_event_thaw(evas_object_evas_get(wd->obj));
3968 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3973 _idle_process(void *data, Eina_Bool *wakeup)
3975 Widget_Data *wd = data;
3978 //static double q_start = 0.0;
3979 //if (q_start == 0.0) q_start = ecore_time_get();
3981 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3985 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3987 return ECORE_CALLBACK_CANCEL;
3989 return ECORE_CALLBACK_RENEW;
3993 _item_idle_enterer(void *data)
3995 Widget_Data *wd = data;
3996 Eina_Bool wakeup = EINA_FALSE;
3997 Eina_Bool ok = _idle_process(data, &wakeup);
4002 if (wd->calc_job) ecore_job_del(wd->calc_job);
4003 wd->calc_job = ecore_job_add(_calc_job, wd);
4005 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
4010 _item_queue(Widget_Data *wd,
4014 if (it->item->queued) return;
4015 it->item->queued = EINA_TRUE;
4016 if (cb && !wd->requeued)
4017 wd->queue = eina_list_sorted_insert(wd->queue, cb, it);
4019 wd->queue = eina_list_append(wd->queue, it);
4020 // FIXME: why does a freeze then thaw here cause some genlist
4021 // elm_genlist_item_append() to be much much slower?
4022 // evas_event_freeze(evas_object_evas_get(wd->obj));
4023 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
4025 if (wd->queue_idle_enterer)
4027 ecore_idle_enterer_del(wd->queue_idle_enterer);
4028 wd->queue_idle_enterer = NULL;
4032 // evas_event_thaw(evas_object_evas_get(wd->obj));
4033 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4034 if (!wd->queue_idle_enterer)
4035 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
4039 _elm_genlist_item_compare(const void *data, const void *data1)
4041 const Elm_Gen_Item *it, *item1;
4042 it = ELM_GEN_ITEM_FROM_INLIST(data);
4043 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
4044 return it->wd->item_compare_cb(it, item1);
4048 _elm_genlist_item_list_compare(const void *data, const void *data1)
4050 const Elm_Gen_Item *it = data;
4051 const Elm_Gen_Item *item1 = data1;
4052 return it->wd->item_compare_cb(it, item1);
4056 _item_move_after(Elm_Gen_Item *it, Elm_Gen_Item *after)
4061 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4062 _item_block_del(it);
4064 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
4065 it->item->rel = after;
4066 it->item->rel->relcount++;
4067 it->item->before = EINA_FALSE;
4068 if (after->item->group_item) it->item->group_item = after->item->group_item;
4069 _item_queue(it->wd, it, NULL);
4071 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
4075 _item_move_before(Elm_Gen_Item *it, Elm_Gen_Item *before)
4078 if (!before) return;
4080 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4081 _item_block_del(it);
4082 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
4083 it->item->rel = before;
4084 it->item->rel->relcount++;
4085 it->item->before = EINA_TRUE;
4086 if (before->item->group_item) it->item->group_item = before->item->group_item;
4087 _item_queue(it->wd, it, NULL);
4089 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
4093 elm_genlist_items_count(const Evas_Object *obj)
4095 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4096 Widget_Data *wd = elm_widget_data_get(obj);
4098 return wd->item_count;
4101 EAPI Elm_Object_Item *
4102 elm_genlist_item_append(Evas_Object *obj,
4103 const Elm_Genlist_Item_Class *itc,
4105 Elm_Object_Item *parent,
4106 Elm_Genlist_Item_Type type,
4108 const void *func_data)
4110 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4111 Widget_Data *wd = elm_widget_data_get(obj);
4112 if (!wd) return NULL;
4113 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4115 if (!it) return NULL;
4119 wd->group_items = eina_list_append(wd->group_items, it);
4120 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
4121 it->item->rel = NULL;
4125 Elm_Gen_Item *it2 = NULL;
4126 Eina_List *ll = eina_list_last(it->parent->item->items);
4127 if (ll) it2 = ll->data;
4128 it->parent->item->items = eina_list_append(it->parent->item->items, it);
4129 if (!it2) it2 = it->parent;
4131 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
4132 EINA_INLIST_GET(it2));
4133 it->item->rel = it2;
4134 it->item->rel->relcount++;
4136 it->item->before = EINA_FALSE;
4137 _item_queue(wd, it, NULL);
4138 return (Elm_Object_Item *)it;
4141 EAPI Elm_Object_Item *
4142 elm_genlist_item_prepend(Evas_Object *obj,
4143 const Elm_Genlist_Item_Class *itc,
4145 Elm_Object_Item *parent,
4146 Elm_Genlist_Item_Type type,
4148 const void *func_data)
4150 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4151 Widget_Data *wd = elm_widget_data_get(obj);
4152 if (!wd) return NULL;
4153 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4155 if (!it) return NULL;
4159 wd->group_items = eina_list_prepend(wd->group_items, it);
4160 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
4161 it->item->rel = NULL;
4165 Elm_Gen_Item *it2 = NULL;
4166 Eina_List *ll = it->parent->item->items;
4167 if (ll) it2 = ll->data;
4168 it->parent->item->items = eina_list_prepend(it->parent->item->items, it);
4169 if (!it2) it2 = it->parent;
4171 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4172 EINA_INLIST_GET(it2));
4173 it->item->rel = it2;
4174 it->item->rel->relcount++;
4176 it->item->before = EINA_TRUE;
4177 _item_queue(wd, it, NULL);
4178 return (Elm_Object_Item *)it;
4181 EAPI Elm_Object_Item *
4182 elm_genlist_item_insert_after(Evas_Object *obj,
4183 const Elm_Genlist_Item_Class *itc,
4185 Elm_Object_Item *parent,
4186 Elm_Object_Item *after,
4187 Elm_Genlist_Item_Type type,
4189 const void *func_data)
4191 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4192 ELM_OBJ_ITEM_CHECK_OR_RETURN(after, NULL);
4193 Widget_Data *wd = elm_widget_data_get(obj);
4194 Elm_Gen_Item *_after = (Elm_Gen_Item *) after;
4195 if (!wd) return NULL;
4196 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
4197 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4199 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4201 if (!it) return NULL;
4204 if ((it->group) && (_after->group))
4205 wd->group_items = eina_list_append_relative(wd->group_items, it,
4210 it->parent->item->items =
4211 eina_list_append_relative(it->parent->item->items, it, _after);
4213 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
4214 EINA_INLIST_GET(_after));
4215 it->item->rel = _after;
4216 it->item->rel->relcount++;
4217 it->item->before = EINA_FALSE;
4218 _item_queue(wd, it, NULL);
4219 return (Elm_Object_Item *)it;
4222 EAPI Elm_Object_Item *
4223 elm_genlist_item_insert_before(Evas_Object *obj,
4224 const Elm_Genlist_Item_Class *itc,
4226 Elm_Object_Item *parent,
4227 Elm_Object_Item *before,
4228 Elm_Genlist_Item_Type type,
4230 const void *func_data)
4232 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4233 ELM_OBJ_ITEM_CHECK_OR_RETURN(before, NULL);
4234 Widget_Data *wd = elm_widget_data_get(obj);
4235 Elm_Gen_Item *_before = (Elm_Gen_Item *) before;
4236 if (!wd) return NULL;
4237 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
4238 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4240 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4242 if (!it) return NULL;
4245 if (it->group && _before->group)
4246 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
4251 it->parent->item->items =
4252 eina_list_prepend_relative(it->parent->item->items, it, _before);
4254 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4255 EINA_INLIST_GET(_before));
4256 it->item->rel = _before;
4257 it->item->rel->relcount++;
4258 it->item->before = EINA_TRUE;
4259 _item_queue(wd, it, NULL);
4260 return (Elm_Object_Item *)it;
4263 EAPI Elm_Object_Item *
4264 elm_genlist_item_sorted_insert(Evas_Object *obj,
4265 const Elm_Genlist_Item_Class *itc,
4267 Elm_Object_Item *parent,
4268 Elm_Genlist_Item_Type type,
4269 Eina_Compare_Cb comp,
4271 const void *func_data)
4273 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4274 Widget_Data *wd = elm_widget_data_get(obj);
4275 if (!wd) return NULL;
4276 Elm_Gen_Item *rel = NULL;
4277 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, type,
4279 if (!it) return NULL;
4281 wd->item_compare_cb = comp;
4288 l = eina_list_search_sorted_near_list(it->parent->item->items,
4289 _elm_genlist_item_list_compare,
4293 rel = eina_list_data_get(l);
4297 if (cmp_result >= 0)
4299 it->parent->item->items = eina_list_prepend_relative_list(it->parent->item->items, it, l);
4300 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
4301 it->item->before = EINA_FALSE;
4303 else if (cmp_result < 0)
4305 it->parent->item->items = eina_list_append_relative_list(it->parent->item->items, it, l);
4306 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
4307 it->item->before = EINA_TRUE;
4314 wd->state = eina_inlist_sorted_state_new();
4315 eina_inlist_sorted_state_init(wd->state, wd->items);
4316 wd->requeued = EINA_FALSE;
4320 wd->group_items = eina_list_append(wd->group_items, it);
4322 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
4323 _elm_genlist_item_compare, wd->state);
4325 if (EINA_INLIST_GET(it)->next)
4327 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4328 it->item->before = EINA_TRUE;
4330 else if (EINA_INLIST_GET(it)->prev)
4332 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4333 it->item->before = EINA_FALSE;
4339 it->item->rel = rel;
4340 it->item->rel->relcount++;
4343 _item_queue(wd, it, _elm_genlist_item_list_compare);
4345 return (Elm_Object_Item *)it;
4349 _elm_genlist_clear(Evas_Object *obj, Eina_Bool standby)
4351 Eina_Inlist *next, *l;
4353 ELM_CHECK_WIDTYPE(obj, widtype);
4354 Widget_Data *wd = elm_widget_data_get(obj);
4357 if (!standby) wd->generation++;
4361 eina_inlist_sorted_state_free(wd->state);
4365 if (wd->walking > 0)
4367 wd->clear_me = EINA_TRUE;
4370 evas_event_freeze(evas_object_evas_get(wd->obj));
4371 for (l = wd->items, next = l ? l->next : NULL;
4373 l = next, next = next ? next->next : NULL)
4375 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(l);
4377 if (it->generation < wd->generation)
4379 Elm_Gen_Item *itn = NULL;
4381 if (next) itn = ELM_GEN_ITEM_FROM_INLIST(next);
4382 if (itn) itn->walking++; /* prevent early death of subitem */
4384 elm_widget_item_free(it);
4385 if (itn) itn->walking--;
4388 wd->clear_me = EINA_FALSE;
4389 wd->pan_changed = EINA_TRUE;
4392 ecore_job_del(wd->calc_job);
4393 wd->calc_job = NULL;
4395 if (wd->selected) wd->selected = eina_list_free(wd->selected);
4396 if (wd->clear_cb) wd->clear_cb(wd);
4403 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4404 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4406 if (wd->sizing_cb) wd->sizing_cb(wd->obj);
4407 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
4408 evas_event_thaw(evas_object_evas_get(wd->obj));
4409 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4413 elm_genlist_clear(Evas_Object *obj)
4415 _elm_genlist_clear(obj, EINA_FALSE);
4419 elm_genlist_multi_select_set(Evas_Object *obj,
4422 ELM_CHECK_WIDTYPE(obj, widtype);
4423 Widget_Data *wd = elm_widget_data_get(obj);
4425 wd->multi = !!multi;
4429 elm_genlist_multi_select_get(const Evas_Object *obj)
4431 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4432 Widget_Data *wd = elm_widget_data_get(obj);
4433 if (!wd) return EINA_FALSE;
4437 EAPI Elm_Object_Item *
4438 elm_genlist_selected_item_get(const Evas_Object *obj)
4440 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4441 Widget_Data *wd = elm_widget_data_get(obj);
4442 if (!wd) return NULL;
4443 if (wd->selected) return wd->selected->data;
4447 EAPI const Eina_List *
4448 elm_genlist_selected_items_get(const Evas_Object *obj)
4450 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4451 Widget_Data *wd = elm_widget_data_get(obj);
4452 if (!wd) return NULL;
4453 return wd->selected;
4457 elm_genlist_realized_items_get(const Evas_Object *obj)
4459 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4460 Widget_Data *wd = elm_widget_data_get(obj);
4461 Eina_List *list = NULL;
4463 Eina_Bool done = EINA_FALSE;
4464 if (!wd) return NULL;
4465 EINA_INLIST_FOREACH(wd->blocks, itb)
4473 EINA_LIST_FOREACH(itb->items, l, it)
4475 if (it->realized) list = eina_list_append(list, it);
4486 EAPI Elm_Object_Item *
4487 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4492 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4493 Widget_Data *wd = elm_widget_data_get(obj);
4494 Evas_Coord ox, oy, ow, oh;
4497 if (!wd) return NULL;
4498 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4500 EINA_INLIST_FOREACH(wd->blocks, itb)
4505 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4506 oy + itb->y - itb->wd->pan_y,
4507 itb->w, itb->h, x, y, 1, 1))
4509 EINA_LIST_FOREACH(itb->items, l, it)
4511 Evas_Coord itx, ity;
4513 itx = ox + itb->x + it->x - itb->wd->pan_x;
4514 ity = oy + itb->y + it->y - itb->wd->pan_y;
4515 if (ELM_RECTS_INTERSECT(itx, ity, it->item->w, it->item->h, x, y, 1, 1))
4519 if (y <= (ity + (it->item->h / 4))) *posret = -1;
4520 else if (y >= (ity + it->item->h - (it->item->h / 4)))
4524 return (Elm_Object_Item *)it;
4526 lasty = ity + it->item->h;
4531 if (y > lasty) *posret = 1;
4537 EAPI Elm_Object_Item *
4538 elm_genlist_first_item_get(const Evas_Object *obj)
4540 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4541 Widget_Data *wd = elm_widget_data_get(obj);
4542 if (!wd) return NULL;
4543 if (!wd->items) return NULL;
4544 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
4545 while ((it) && (it->generation < wd->generation))
4546 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4547 return (Elm_Object_Item *)it;
4550 EAPI Elm_Object_Item *
4551 elm_genlist_last_item_get(const Evas_Object *obj)
4553 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4554 Widget_Data *wd = elm_widget_data_get(obj);
4555 if (!wd) return NULL;
4556 if (!wd->items) return NULL;
4557 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
4558 while ((it) && (it->generation < wd->generation))
4559 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4560 return (Elm_Object_Item *)it;
4563 EAPI Elm_Object_Item *
4564 elm_genlist_item_next_get(const Elm_Object_Item *it)
4566 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4567 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4570 _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->next);
4571 if ((_it) && (_it->generation == _it->wd->generation)) break;
4573 return (Elm_Object_Item *) _it;
4576 EAPI Elm_Object_Item *
4577 elm_genlist_item_prev_get(const Elm_Object_Item *it)
4579 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4580 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4583 _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->prev);
4584 if ((_it) && (_it->generation == _it->wd->generation)) break;
4586 return (Elm_Object_Item *) _it;
4589 EINA_DEPRECATED EAPI Evas_Object *
4590 elm_genlist_item_genlist_get(const Elm_Object_Item *it)
4592 return elm_object_item_widget_get(it);
4595 EAPI Elm_Object_Item *
4596 elm_genlist_item_parent_get(const Elm_Object_Item *it)
4598 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4599 return (Elm_Object_Item *) ((Elm_Gen_Item *)it)->parent;
4603 elm_genlist_item_subitems_clear(Elm_Object_Item *it)
4605 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4606 Eina_List *tl = NULL, *l;
4608 Elm_Object_Item *it2;
4609 _it = (Elm_Gen_Item *)it;
4611 EINA_LIST_FOREACH(_it->item->items, l, it2)
4612 tl = eina_list_append(tl, it2);
4613 EINA_LIST_FREE(tl, it2)
4614 elm_object_item_del(it2);
4618 elm_genlist_item_selected_set(Elm_Object_Item *it,
4621 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4622 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4623 Widget_Data *wd = _it->wd;
4625 if ((_it->generation < wd->generation) || elm_widget_item_disabled_get(_it))
4627 selected = !!selected;
4628 if (_it->selected == selected) return;
4634 while (wd->selected)
4636 if (_it->unhighlight_cb) _it->unhighlight_cb(wd->selected->data);
4637 _it->unsel_cb(wd->selected->data);
4640 _it->highlight_cb(_it);
4644 if (_it->unhighlight_cb) _it->unhighlight_cb(_it);
4649 elm_genlist_item_selected_get(const Elm_Object_Item *it)
4651 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4652 return ((Elm_Gen_Item *)it)->selected;
4656 elm_genlist_item_expanded_set(Elm_Object_Item *it,
4659 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4660 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4661 expanded = !!expanded;
4662 if (_it->item->expanded == expanded) return;
4663 _it->item->expanded = expanded;
4664 if (_it->item->expanded)
4667 edje_object_signal_emit(VIEW(_it), "elm,state,expanded", "elm");
4668 evas_object_smart_callback_call(WIDGET(_it), SIG_EXPANDED, _it);
4669 _it->wd->auto_scroll_enabled = EINA_TRUE;
4670 _it->wd->expanded_item = _it;
4675 edje_object_signal_emit(VIEW(_it), "elm,state,contracted", "elm");
4676 evas_object_smart_callback_call(WIDGET(_it), SIG_CONTRACTED, _it);
4677 _it->wd->auto_scroll_enabled = EINA_FALSE;
4678 _it->wd->expanded_item = NULL;
4683 elm_genlist_item_expanded_get(const Elm_Object_Item *it)
4685 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4686 return ((Elm_Gen_Item *)it)->item->expanded;
4690 elm_genlist_item_expanded_depth_get(const Elm_Object_Item *it)
4692 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, 0);
4693 return ((Elm_Gen_Item *)it)->item->expanded_depth;
4696 EINA_DEPRECATED EAPI void
4697 elm_genlist_item_disabled_set(Elm_Object_Item *it,
4700 elm_object_item_disabled_set(it, disabled);
4703 EINA_DEPRECATED EAPI Eina_Bool
4704 elm_genlist_item_disabled_get(const Elm_Object_Item *it)
4706 return elm_object_item_disabled_get(it);
4710 elm_genlist_item_display_only_set(Elm_Object_Item *it,
4711 Eina_Bool display_only)
4713 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4714 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4715 display_only = !!display_only;
4716 if (_it->display_only == display_only) return;
4717 if (_it->generation < _it->wd->generation) return;
4718 _it->display_only = display_only;
4719 _it->item->mincalcd = EINA_FALSE;
4720 _it->item->updateme = EINA_TRUE;
4721 if (_it->item->block) _it->item->block->updateme = EINA_TRUE;
4722 if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
4723 _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
4727 elm_genlist_item_display_only_get(const Elm_Object_Item *it)
4729 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4730 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4731 if (_it->generation < _it->wd->generation) return EINA_FALSE;
4732 return _it->display_only;
4736 elm_genlist_item_show(Elm_Object_Item *it)
4738 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4739 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4740 Evas_Coord gith = 0;
4741 if (_it->generation < _it->wd->generation) return;
4742 if ((_it->item->queued) || (!_it->item->mincalcd))
4744 _it->wd->show_item = _it;
4745 _it->wd->bring_in = EINA_FALSE;
4746 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
4747 _it->item->showme = EINA_TRUE;
4750 if (_it->wd->show_item)
4752 _it->wd->show_item->item->showme = EINA_FALSE;
4753 _it->wd->show_item = NULL;
4755 if ((_it->item->group_item) &&
4756 (_it->wd->pan_y > (_it->y + _it->item->block->y)))
4757 gith = _it->item->group_item->item->h;
4758 elm_smart_scroller_child_region_show(_it->wd->scr,
4759 _it->x + _it->item->block->x,
4760 _it->y + _it->item->block->y - gith,
4761 _it->item->block->w, _it->item->h);
4765 elm_genlist_item_promote(Elm_Object_Item *it)
4767 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4768 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4769 if (_it->generation < _it->wd->generation) return;
4770 _item_move_before(_it,
4771 (Elm_Gen_Item *) elm_genlist_first_item_get(WIDGET(_it)));
4775 elm_genlist_item_demote(Elm_Object_Item *it)
4777 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4778 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4779 if (_it->generation < _it->wd->generation) return;
4780 _item_move_after(_it,
4781 (Elm_Gen_Item *) elm_genlist_last_item_get(WIDGET(_it)));
4785 elm_genlist_item_bring_in(Elm_Object_Item *it)
4787 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4788 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4789 Evas_Coord gith = 0;
4790 if (_it->generation < _it->wd->generation) return;
4791 if ((_it->item->queued) || (!_it->item->mincalcd))
4793 _it->wd->show_item = _it;
4794 _it->wd->bring_in = EINA_TRUE;
4795 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
4796 _it->item->showme = EINA_TRUE;
4799 if (_it->wd->show_item)
4801 _it->wd->show_item->item->showme = EINA_FALSE;
4802 _it->wd->show_item = NULL;
4804 if ((_it->item->group_item) &&
4805 (_it->wd->pan_y > (_it->y + _it->item->block->y)))
4806 gith = _it->item->group_item->item->h;
4807 elm_smart_scroller_region_bring_in(_it->wd->scr,
4808 _it->x + _it->item->block->x,
4809 _it->y + _it->item->block->y - gith,
4810 _it->item->block->w, _it->item->h);
4814 elm_genlist_item_top_show(Elm_Object_Item *it)
4816 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4817 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4819 Evas_Coord gith = 0;
4821 if (_it->generation < _it->wd->generation) return;
4822 if ((_it->item->queued) || (!_it->item->mincalcd))
4824 _it->wd->show_item = _it;
4825 _it->wd->bring_in = EINA_FALSE;
4826 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_TOP;
4827 _it->item->showme = EINA_TRUE;
4830 if (_it->wd->show_item)
4832 _it->wd->show_item->item->showme = EINA_FALSE;
4833 _it->wd->show_item = NULL;
4835 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4836 if (_it->item->group_item) gith = _it->item->group_item->item->h;
4837 elm_smart_scroller_child_region_show(_it->wd->scr,
4838 _it->x + _it->item->block->x,
4839 _it->y + _it->item->block->y - gith,
4840 _it->item->block->w, oh);
4844 elm_genlist_item_top_bring_in(Elm_Object_Item *it)
4846 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4847 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4849 Evas_Coord gith = 0;
4851 if (_it->generation < _it->wd->generation) return;
4852 if ((_it->item->queued) || (!_it->item->mincalcd))
4854 _it->wd->show_item = _it;
4855 _it->wd->bring_in = EINA_TRUE;
4856 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_TOP;
4857 _it->item->showme = EINA_TRUE;
4860 if (_it->wd->show_item)
4862 _it->wd->show_item->item->showme = EINA_FALSE;
4863 _it->wd->show_item = NULL;
4865 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4866 if (_it->item->group_item) gith = _it->item->group_item->item->h;
4867 elm_smart_scroller_region_bring_in(_it->wd->scr,
4868 _it->x + _it->item->block->x,
4869 _it->y + _it->item->block->y - gith,
4870 _it->item->block->w, oh);
4874 elm_genlist_item_middle_show(Elm_Object_Item *it)
4876 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4877 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4880 if (_it->generation < _it->wd->generation) return;
4881 if ((_it->item->queued) || (!_it->item->mincalcd))
4883 _it->wd->show_item = _it;
4884 _it->wd->bring_in = EINA_FALSE;
4885 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_MIDDLE;
4886 _it->item->showme = EINA_TRUE;
4889 if (_it->wd->show_item)
4891 _it->wd->show_item->item->showme = EINA_FALSE;
4892 _it->wd->show_item = NULL;
4894 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4895 elm_smart_scroller_child_region_show(_it->wd->scr,
4896 _it->x + _it->item->block->x,
4897 _it->y + _it->item->block->y - oh / 2 +
4898 _it->item->h / 2, _it->item->block->w,
4903 elm_genlist_item_middle_bring_in(Elm_Object_Item *it)
4905 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4906 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4909 if (_it->generation < _it->wd->generation) return;
4910 if ((_it->item->queued) || (!_it->item->mincalcd))
4912 _it->wd->show_item = _it;
4913 _it->wd->bring_in = EINA_TRUE;
4914 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_MIDDLE;
4915 _it->item->showme = EINA_TRUE;
4918 if (_it->wd->show_item)
4920 _it->wd->show_item->item->showme = EINA_FALSE;
4921 _it->wd->show_item = NULL;
4923 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4924 elm_smart_scroller_region_bring_in(_it->wd->scr,
4925 _it->x + _it->item->block->x,
4926 _it->y + _it->item->block->y - oh / 2 +
4927 _it->item->h / 2, _it->item->block->w,
4932 elm_genlist_item_del(Elm_Object_Item *it)
4934 elm_object_item_del(it);
4938 elm_genlist_item_data_set(Elm_Object_Item *it,
4941 elm_object_item_data_set(it, (void *) data);
4945 elm_genlist_item_data_get(const Elm_Object_Item *it)
4947 return elm_object_item_data_get(it);
4951 elm_genlist_item_icons_orphan(Elm_Object_Item *it)
4953 elm_genlist_item_contents_orphan(it);
4956 EINA_DEPRECATED EAPI void
4957 elm_genlist_item_contents_orphan(Elm_Object_Item *it)
4959 elm_genlist_item_all_contents_unset(it, NULL);
4963 elm_genlist_item_all_contents_unset(Elm_Object_Item *it, Eina_List **l)
4965 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4967 Evas_Object *content;
4968 EINA_LIST_FREE(((Elm_Gen_Item *)it)->content_objs, content)
4970 elm_widget_sub_object_del(WIDGET(it), content);
4971 evas_object_smart_member_del(content);
4972 evas_object_hide(content);
4974 *l = eina_list_append(*l, content);
4978 EINA_DEPRECATED EAPI const Evas_Object *
4979 elm_genlist_item_object_get(const Elm_Object_Item *it)
4981 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4986 elm_genlist_item_update(Elm_Object_Item *it)
4988 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4989 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
4991 if (!_it->item->block) return;
4992 if (_it->generation < _it->wd->generation) return;
4993 _it->item->mincalcd = EINA_FALSE;
4994 _it->item->updateme = EINA_TRUE;
4995 _it->item->block->updateme = EINA_TRUE;
4996 if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
4997 _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
5001 elm_genlist_item_fields_update(Elm_Object_Item *it,
5003 Elm_Genlist_Item_Field_Type itf)
5005 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5006 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5008 if (!_it->item->block) return;
5009 if (_it->generation < _it->wd->generation) return;
5011 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_TEXT))
5012 _item_text_realize(_it, VIEW(_it), &_it->texts, parts);
5013 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_CONTENT))
5015 _it->content_objs = _item_content_unrealize(_it, VIEW(_it),
5016 &_it->contents, parts);
5017 _it->content_objs = _item_content_realize(_it, VIEW(_it),
5018 &_it->contents, parts);
5020 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
5021 _item_state_realize(_it, VIEW(_it), &_it->states, parts);
5025 elm_genlist_item_item_class_update(Elm_Object_Item *it,
5026 const Elm_Genlist_Item_Class *itc)
5028 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5029 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5031 if (!_it->item->block) return;
5032 EINA_SAFETY_ON_NULL_RETURN(itc);
5033 if (_it->generation < _it->wd->generation) return;
5035 _it->item->nocache_once = EINA_TRUE;
5036 elm_genlist_item_update(it);
5039 EAPI const Elm_Genlist_Item_Class *
5040 elm_genlist_item_item_class_get(const Elm_Object_Item *it)
5042 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
5043 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5044 if (_it->generation < _it->wd->generation) return NULL;
5048 static Evas_Object *
5049 _elm_genlist_item_label_create(void *data,
5050 Evas_Object *obj __UNUSED__,
5051 Evas_Object *tooltip,
5052 void *it __UNUSED__)
5054 Evas_Object *label = elm_label_add(tooltip);
5057 elm_object_style_set(label, "tooltip");
5058 elm_object_text_set(label, data);
5063 _elm_genlist_item_label_del_cb(void *data,
5064 Evas_Object *obj __UNUSED__,
5065 void *event_info __UNUSED__)
5067 eina_stringshare_del(data);
5071 elm_genlist_item_tooltip_text_set(Elm_Object_Item *it,
5074 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5075 text = eina_stringshare_add(text);
5076 elm_genlist_item_tooltip_content_cb_set(it, _elm_genlist_item_label_create,
5078 _elm_genlist_item_label_del_cb);
5082 elm_genlist_item_tooltip_content_cb_set(Elm_Object_Item *it,
5083 Elm_Tooltip_Item_Content_Cb func,
5085 Evas_Smart_Cb del_cb)
5087 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
5088 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5090 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
5093 if (_it->tooltip.del_cb)
5094 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(it), it);
5096 _it->tooltip.content_cb = func;
5097 _it->tooltip.data = data;
5098 _it->tooltip.del_cb = del_cb;
5102 elm_widget_item_tooltip_content_cb_set(_it,
5103 _it->tooltip.content_cb,
5104 _it->tooltip.data, NULL);
5105 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
5106 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
5112 if (del_cb) del_cb((void *)data, NULL, NULL);
5116 elm_genlist_item_tooltip_unset(Elm_Object_Item *it)
5118 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5119 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5121 if ((VIEW(_it)) && (_it->tooltip.content_cb))
5122 elm_widget_item_tooltip_unset(_it);
5124 if (_it->tooltip.del_cb)
5125 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
5126 _it->tooltip.del_cb = NULL;
5127 _it->tooltip.content_cb = NULL;
5128 _it->tooltip.data = NULL;
5129 _it->tooltip.free_size = EINA_FALSE;
5130 if (_it->tooltip.style)
5131 elm_genlist_item_tooltip_style_set(it, NULL);
5135 elm_genlist_item_tooltip_style_set(Elm_Object_Item *it,
5138 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5139 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5141 eina_stringshare_replace(&_it->tooltip.style, style);
5142 if (VIEW(_it)) elm_widget_item_tooltip_style_set(_it, style);
5146 elm_genlist_item_tooltip_style_get(const Elm_Object_Item *it)
5148 return elm_object_item_tooltip_style_get(it);
5152 elm_genlist_item_tooltip_window_mode_set(Elm_Object_Item *it,
5155 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
5156 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5158 _it->tooltip.free_size = disable;
5159 if (VIEW(_it)) return elm_widget_item_tooltip_window_mode_set(_it, disable);
5164 elm_genlist_item_tooltip_window_mode_get(const Elm_Object_Item *it)
5166 return elm_object_tooltip_window_mode_get(VIEW(it));
5170 elm_genlist_item_cursor_set(Elm_Object_Item *it,
5173 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5174 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5175 eina_stringshare_replace(&_it->mouse_cursor, cursor);
5176 if (VIEW(_it)) elm_widget_item_cursor_set(_it, cursor);
5180 elm_genlist_item_cursor_get(const Elm_Object_Item *it)
5182 return elm_widget_item_cursor_get(it);
5186 elm_genlist_item_cursor_unset(Elm_Object_Item *it)
5188 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5189 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5191 if (!_it->mouse_cursor) return;
5193 if (VIEW(_it)) elm_widget_item_cursor_unset(_it);
5195 eina_stringshare_del(_it->mouse_cursor);
5196 _it->mouse_cursor = NULL;
5200 elm_genlist_item_cursor_style_set(Elm_Object_Item *it,
5203 elm_widget_item_cursor_style_set(it, style);
5207 elm_genlist_item_cursor_style_get(const Elm_Object_Item *it)
5209 return elm_widget_item_cursor_style_get(it);
5213 elm_genlist_item_cursor_engine_only_set(Elm_Object_Item *it,
5214 Eina_Bool engine_only)
5216 elm_widget_item_cursor_engine_only_set(it, engine_only);
5220 elm_genlist_item_cursor_engine_only_get(const Elm_Object_Item *it)
5222 return elm_widget_item_cursor_engine_only_get(it);
5226 elm_genlist_item_index_get(const Elm_Object_Item *it)
5228 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, -1);
5229 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5231 if (_it->item->block)
5232 return _it->position + _it->item->block->position;
5237 elm_genlist_mode_set(Evas_Object *obj,
5240 ELM_CHECK_WIDTYPE(obj, widtype);
5241 Widget_Data *wd = elm_widget_data_get(obj);
5243 if (wd->mode == mode) return;
5249 elm_genlist_horizontal_set(Evas_Object *obj,
5252 elm_genlist_mode_set(obj, mode);
5256 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5259 elm_genlist_mode_set(obj, mode);
5263 elm_genlist_mode_get(const Evas_Object *obj)
5265 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5266 Widget_Data *wd = elm_widget_data_get(obj);
5267 if (!wd) return ELM_LIST_LAST;
5271 EINA_DEPRECATED EAPI Elm_List_Mode
5272 elm_genlist_horizontal_get(const Evas_Object *obj)
5274 return elm_genlist_mode_get(obj);
5277 EINA_DEPRECATED EAPI Elm_List_Mode
5278 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5280 return elm_genlist_mode_get(obj);
5284 elm_genlist_always_select_mode_set(Evas_Object *obj,
5285 Eina_Bool always_select)
5287 ELM_CHECK_WIDTYPE(obj, widtype);
5288 Widget_Data *wd = elm_widget_data_get(obj);
5290 wd->always_select = !!always_select;
5294 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5296 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5297 Widget_Data *wd = elm_widget_data_get(obj);
5298 if (!wd) return EINA_FALSE;
5299 return wd->always_select;
5303 elm_genlist_no_select_mode_set(Evas_Object *obj,
5304 Eina_Bool no_select)
5306 ELM_CHECK_WIDTYPE(obj, widtype);
5307 Widget_Data *wd = elm_widget_data_get(obj);
5309 wd->no_select = !!no_select;
5313 elm_genlist_no_select_mode_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->no_select;
5322 elm_genlist_compress_mode_set(Evas_Object *obj,
5325 ELM_CHECK_WIDTYPE(obj, widtype);
5326 Widget_Data *wd = elm_widget_data_get(obj);
5328 wd->compress = !!compress;
5329 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
5333 elm_genlist_compress_mode_get(const Evas_Object *obj)
5335 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5336 Widget_Data *wd = elm_widget_data_get(obj);
5337 if (!wd) return EINA_FALSE;
5338 return wd->compress;
5342 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5343 Eina_Bool height_for_width)
5345 ELM_CHECK_WIDTYPE(obj, widtype);
5346 Widget_Data *wd = elm_widget_data_get(obj);
5348 wd->height_for_width = !!height_for_width;
5349 if (wd->height_for_width)
5351 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5352 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5357 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5359 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5360 Widget_Data *wd = elm_widget_data_get(obj);
5361 if (!wd) return EINA_FALSE;
5362 return wd->height_for_width;
5366 elm_genlist_bounce_set(Evas_Object *obj,
5370 ELM_CHECK_WIDTYPE(obj, widtype);
5371 Widget_Data *wd = elm_widget_data_get(obj);
5373 wd->h_bounce = !!h_bounce;
5374 wd->v_bounce = !!v_bounce;
5375 elm_smart_scroller_bounce_allow_set(wd->scr, wd->h_bounce, wd->v_bounce);
5379 elm_genlist_bounce_get(const Evas_Object *obj,
5380 Eina_Bool *h_bounce,
5381 Eina_Bool *v_bounce)
5383 ELM_CHECK_WIDTYPE(obj, widtype);
5384 Widget_Data *wd = elm_widget_data_get(obj);
5386 if (h_bounce) *h_bounce = wd->h_bounce;
5387 if (v_bounce) *v_bounce = wd->v_bounce;
5391 elm_genlist_homogeneous_set(Evas_Object *obj,
5392 Eina_Bool homogeneous)
5394 ELM_CHECK_WIDTYPE(obj, widtype);
5395 Widget_Data *wd = elm_widget_data_get(obj);
5397 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5398 wd->homogeneous = !!homogeneous;
5402 elm_genlist_homogeneous_get(const Evas_Object *obj)
5404 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5405 Widget_Data *wd = elm_widget_data_get(obj);
5406 if (!wd) return EINA_FALSE;
5407 return wd->homogeneous;
5411 elm_genlist_block_count_set(Evas_Object *obj,
5414 ELM_CHECK_WIDTYPE(obj, widtype);
5415 Widget_Data *wd = elm_widget_data_get(obj);
5417 wd->max_items_per_block = count;
5418 wd->item_cache_max = wd->max_items_per_block * 2;
5419 _item_cache_clean(wd);
5423 elm_genlist_block_count_get(const Evas_Object *obj)
5425 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5426 Widget_Data *wd = elm_widget_data_get(obj);
5428 return wd->max_items_per_block;
5432 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5435 ELM_CHECK_WIDTYPE(obj, widtype);
5436 Widget_Data *wd = elm_widget_data_get(obj);
5438 wd->longpress_timeout = timeout;
5442 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5444 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5445 Widget_Data *wd = elm_widget_data_get(obj);
5447 return wd->longpress_timeout;
5451 elm_genlist_scroller_policy_set(Evas_Object *obj,
5452 Elm_Scroller_Policy policy_h,
5453 Elm_Scroller_Policy policy_v)
5455 ELM_CHECK_WIDTYPE(obj, widtype);
5456 Widget_Data *wd = elm_widget_data_get(obj);
5457 if ((!wd) || (!wd->scr)) return;
5458 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5459 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5461 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5465 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5466 Elm_Scroller_Policy *policy_h,
5467 Elm_Scroller_Policy *policy_v)
5469 ELM_CHECK_WIDTYPE(obj, widtype);
5470 Widget_Data *wd = elm_widget_data_get(obj);
5471 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5472 if ((!wd) || (!wd->scr)) return;
5473 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5474 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5475 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5479 elm_genlist_realized_items_update(Evas_Object *obj)
5481 ELM_CHECK_WIDTYPE(obj, widtype);
5483 Eina_List *list, *l;
5484 Elm_Object_Item *it;
5486 list = elm_genlist_realized_items_get(obj);
5487 EINA_LIST_FOREACH(list, l, it)
5488 elm_genlist_item_update(it);
5492 elm_genlist_item_mode_set(Elm_Object_Item *it,
5493 const char *mode_type,
5496 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5497 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5499 Widget_Data *wd = _it->wd;
5501 Elm_Object_Item *it2;
5504 if (!mode_type) return;
5505 if ((_it->generation < _it->wd->generation) ||
5506 elm_widget_item_disabled_get(_it)) return;
5507 if (wd->edit_mode) return;
5509 if ((wd->mode_item == _it) &&
5510 (!strcmp(mode_type, wd->mode_type)) &&
5513 if (!_it->itc->mode_item_style) return;
5514 _it->mode_set = mode_set;
5518 EINA_LIST_FOREACH(wd->selected, l, it2)
5519 if (((Elm_Gen_Item *)it2)->realized)
5520 elm_genlist_item_selected_set(it2, EINA_FALSE);
5524 it2 = elm_genlist_selected_item_get(wd->obj);
5525 if ((it2) && (((Elm_Gen_Item *)it2)->realized))
5526 elm_genlist_item_selected_set(it2, EINA_FALSE);
5529 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5531 ((_it == wd->mode_item) && (!mode_set)))
5532 _item_mode_unset(wd);
5534 eina_stringshare_replace(&wd->mode_type, mode_type);
5535 if (mode_set) _item_mode_set(_it);
5539 elm_genlist_mode_item_style_get(const Evas_Object *obj)
5541 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5542 Widget_Data *wd = elm_widget_data_get(obj);
5543 if (!wd) return NULL;
5544 return wd->mode_item->itc->mode_item_style;
5548 elm_genlist_mode_item_style_set(Evas_Object *obj, const char *style)
5550 ELM_CHECK_WIDTYPE(obj, widtype);
5551 Widget_Data *wd = elm_widget_data_get(obj);
5553 if ((style == wd->mode_item->itc->mode_item_style) ||
5554 (style && wd->mode_item->itc->mode_item_style &&
5555 (!strcmp(style, wd->mode_item->itc->mode_item_style))))
5557 eina_stringshare_replace((const char**)&wd->mode_item->itc->mode_item_style, style);
5558 elm_genlist_realized_items_update(obj);
5562 elm_genlist_mode_type_get(const Evas_Object *obj)
5564 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5565 Widget_Data *wd = elm_widget_data_get(obj);
5566 if (!wd) return NULL;
5567 return wd->mode_type;
5570 EAPI const Elm_Object_Item *
5571 elm_genlist_mode_item_get(const Evas_Object *obj)
5573 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5574 Widget_Data *wd = elm_widget_data_get(obj);
5575 if (!wd) return NULL;
5576 return (Elm_Object_Item *) wd->mode_item;
5580 elm_genlist_edit_mode_get(const Evas_Object *obj)
5582 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5583 Widget_Data *wd = elm_widget_data_get(obj);
5584 if (!wd) return EINA_FALSE;
5586 return wd->edit_mode;
5590 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5592 ELM_CHECK_WIDTYPE(obj, widtype);
5593 Eina_List *list, *l;
5596 Widget_Data *wd = elm_widget_data_get(obj);
5598 edit_mode = !!edit_mode;
5599 if (wd->edit_mode == edit_mode) return;
5600 wd->edit_mode = edit_mode;
5602 list = elm_genlist_realized_items_get(obj);
5605 EINA_LIST_FOREACH(list, l, it)
5607 if (it->item->type != ELM_GENLIST_ITEM_GROUP)
5608 _edit_mode_item_unrealize(it);
5610 _item_cache_zero(wd);
5614 EINA_LIST_FOREACH(list, l, it)
5616 if (it->item->type != ELM_GENLIST_ITEM_GROUP)
5618 if (it->selected) _item_unselect(it);
5619 if (it->itc->edit_item_style)
5620 _edit_mode_item_realize(it, EINA_TRUE);
5624 if (wd->calc_job) ecore_job_del(wd->calc_job);
5625 wd->calc_job = ecore_job_add(_calc_job, wd);
5629 elm_genlist_reorder_mode_set(Evas_Object *obj,
5630 Eina_Bool reorder_mode)
5632 ELM_CHECK_WIDTYPE(obj, widtype);
5633 Widget_Data *wd = elm_widget_data_get(obj);
5635 wd->reorder_mode = !!reorder_mode;
5639 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5641 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5642 Widget_Data *wd = elm_widget_data_get(obj);
5643 if (!wd) return EINA_FALSE;
5644 return wd->reorder_mode;
5647 EAPI Elm_Genlist_Item_Type
5648 elm_genlist_item_type_get(const Elm_Object_Item *it)
5650 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ELM_GENLIST_ITEM_MAX);
5651 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5652 return _it->item->type;
5655 EINA_DEPRECATED EAPI Elm_Genlist_Item_Type
5656 elm_genlist_item_flags_get(const Elm_Object_Item *it)
5658 return elm_genlist_item_type_get(it);
5661 EAPI Elm_Genlist_Item_Class *
5662 elm_genlist_item_class_new(void)
5664 Elm_Genlist_Item_Class *itc;
5666 itc = calloc(1, sizeof(Elm_Genlist_Item_Class));
5669 itc->version = ELM_GENLIST_ITEM_CLASS_VERSION;
5671 itc->delete_me = EINA_FALSE;
5677 elm_genlist_item_class_free(Elm_Genlist_Item_Class *itc)
5679 if (itc && (itc->version == ELM_GENLIST_ITEM_CLASS_VERSION))
5681 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
5682 if (itc->refcount > 0) elm_genlist_item_class_unref(itc);
5692 elm_genlist_item_class_ref(Elm_Genlist_Item_Class *itc)
5694 if (itc && (itc->version == ELM_GENLIST_ITEM_CLASS_VERSION))
5697 if (itc->refcount == 0) itc->refcount--;
5702 elm_genlist_item_class_unref(Elm_Genlist_Item_Class *itc)
5704 if (itc && (itc->version == ELM_GENLIST_ITEM_CLASS_VERSION))
5706 if (itc->refcount > 0) itc->refcount--;
5707 if (itc->delete_me && (!itc->refcount))
5708 elm_genlist_item_class_free(itc);
5712 void _flip_job(void *data)
5714 Elm_Gen_Item *it = (Elm_Gen_Item *) data;
5715 _elm_genlist_item_unrealize(it, EINA_FALSE);
5716 if (it->selected) _item_unselect(it);
5717 it->flipped = EINA_TRUE;
5718 it->item->nocache = EINA_TRUE;
5722 elm_genlist_item_flip_set(Elm_Object_Item *it,
5725 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5726 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5729 if (_it->flipped == flip) return;
5733 ecore_job_add(_flip_job, _it);
5734 if (_it->wd->calc_job) ecore_job_del(_it->wd->calc_job);
5735 _it->wd->calc_job = ecore_job_add(_calc_job, _it->wd);
5739 _it->flipped = flip;
5740 _item_cache_zero(_it->wd);
5741 elm_genlist_item_update(it);
5742 _it->item->nocache = EINA_FALSE;
5747 elm_genlist_item_flip_get(const Elm_Object_Item *it)
5749 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
5750 Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
5751 return _it->flipped;
5754 /* for gengrid as of now */
5756 _elm_genlist_page_relative_set(Evas_Object *obj,
5760 Evas_Coord pagesize_h;
5761 Evas_Coord pagesize_v;
5763 ELM_CHECK_WIDTYPE(obj, widtype);
5764 Widget_Data *wd = elm_widget_data_get(obj);
5767 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
5768 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
5772 /* for gengrid as of now */
5774 _elm_genlist_page_relative_get(const Evas_Object *obj,
5778 ELM_CHECK_WIDTYPE(obj, widtype);
5779 Widget_Data *wd = elm_widget_data_get(obj);
5782 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
5785 /* for gengrid as of now */
5787 _elm_genlist_page_size_set(Evas_Object *obj,
5788 Evas_Coord h_pagesize,
5789 Evas_Coord v_pagesize)
5794 ELM_CHECK_WIDTYPE(obj, widtype);
5795 Widget_Data *wd = elm_widget_data_get(obj);
5797 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
5798 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
5802 /* for gengrid as of now */
5804 _elm_genlist_current_page_get(const Evas_Object *obj,
5808 ELM_CHECK_WIDTYPE(obj, widtype);
5809 Widget_Data *wd = elm_widget_data_get(obj);
5811 elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber);
5814 /* for gengrid as of now */
5816 _elm_genlist_last_page_get(const Evas_Object *obj,
5820 ELM_CHECK_WIDTYPE(obj, widtype);
5821 Widget_Data *wd = elm_widget_data_get(obj);
5823 elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber);
5826 /* for gengrid as of now */
5828 _elm_genlist_page_show(const Evas_Object *obj,
5832 ELM_CHECK_WIDTYPE(obj, widtype);
5833 Widget_Data *wd = elm_widget_data_get(obj);
5835 elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber);
5838 /* for gengrid as of now */
5840 _elm_genlist_page_bring_in(const Evas_Object *obj,
5844 ELM_CHECK_WIDTYPE(obj, widtype);
5845 Widget_Data *wd = elm_widget_data_get(obj);
5847 elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber);
5851 _elm_genlist_item_unrealize(Elm_Gen_Item *it,
5854 Evas_Object *content;
5856 if (!it->realized) return;
5857 if (it->wd->reorder_it == it) return;
5859 evas_event_freeze(evas_object_evas_get(WIDGET(it)));
5861 evas_object_smart_callback_call(WIDGET(it), SIG_UNREALIZED, it);
5864 ecore_timer_del(it->long_timer);
5865 it->long_timer = NULL;
5868 elm_widget_stringlist_free(it->texts);
5870 elm_widget_stringlist_free(it->contents);
5871 it->contents = NULL;
5872 elm_widget_stringlist_free(it->states);
5875 EINA_LIST_FREE(it->content_objs, content)
5876 evas_object_del(content);
5878 it->unrealize_cb(it);
5880 it->realized = EINA_FALSE;
5881 it->want_unrealize = EINA_FALSE;
5882 evas_event_thaw(evas_object_evas_get(WIDGET(it)));
5883 evas_event_thaw_eval(evas_object_evas_get(WIDGET(it)));
5887 _elm_genlist_item_del_notserious(Elm_Gen_Item *it)
5889 elm_widget_item_pre_notify_del(it);
5890 it->generation = it->wd->generation - 1; /* This means that the item is deleted */
5891 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5893 if (it->itc->func.del)
5894 it->itc->func.del((void *)it->base.data, WIDGET(it));
5898 _elm_genlist_item_del_serious(Elm_Gen_Item *it)
5900 _elm_genlist_item_del_notserious(it);
5901 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5902 if (it->tooltip.del_cb)
5903 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
5904 it->wd->walking -= it->walking;
5905 if (it->long_timer) ecore_timer_del(it->long_timer);
5907 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
5911 eina_inlist_sorted_state_free(it->wd->state);
5912 it->wd->state = NULL;
5914 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5915 it->wd->calc_job = ecore_job_add(it->wd->calc_cb, it->wd);
5919 if (it->wd->last_selected_item == (Elm_Object_Item *)it)
5920 it->wd->last_selected_item = NULL;
5921 it->wd->item_count--;