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); \
42 typedef struct _Item_Block Item_Block;
43 typedef struct _Item_Cache Item_Cache;
45 struct Elm_Gen_Item_Type
50 Evas_Coord w, h, minw, minh;
51 Elm_Gen_Item *group_item;
52 Elm_Genlist_Item_Flags flags;
53 Eina_List *mode_texts, *mode_contents, *mode_states, *mode_content_objs;
54 Eina_List *edit_texts, *edit_contents, *edit_states, *edit_content_objs;
55 Ecore_Timer *swipe_timer;
56 Evas_Coord scrl_x, scrl_y, old_scrl_y;
59 Evas_Object *mode_view;
65 Eina_Bool want_realize : 1;
66 Eina_Bool expanded : 1;
67 Eina_Bool mincalcd : 1;
70 Eina_Bool updateme : 1;
71 Eina_Bool nocache : 1;
72 Eina_Bool stacking_even : 1;
73 Eina_Bool nostacking : 1;
74 Eina_Bool move_effect_enabled : 1;
75 Eina_Bool edit_mode_item_realized : 1;
86 Evas_Coord x, y, w, h, minw, minh;
88 int item_position_stamp;
90 Eina_Bool position_update : 1;
91 Eina_Bool want_unrealize : 1;
92 Eina_Bool realized : 1;
93 Eina_Bool changed : 1;
94 Eina_Bool updateme : 1;
96 Eina_Bool must_recalc : 1;
103 Evas_Object *base_view, *spacer;
105 const char *item_style; // it->itc->item_style
106 Eina_Bool tree : 1; // it->group
107 Eina_Bool compress : 1; // it->wd->compress
109 Eina_Bool selected : 1; // it->selected
110 Eina_Bool disabled : 1; // it->disabled
111 Eina_Bool expanded : 1; // it->item->expanded
114 static const char *widtype = NULL;
115 static void _item_cache_zero(Widget_Data *wd);
116 static void _del_hook(Evas_Object *obj);
117 static void _mirrored_set(Evas_Object *obj,
119 static void _theme_hook(Evas_Object *obj);
120 static void _show_region_hook(void *data,
122 static void _sizing_eval(Evas_Object *obj);
123 static void _item_realize(Elm_Gen_Item *it,
126 static void _item_unrealize_cb(Elm_Gen_Item *it);
127 static void _item_block_unrealize(Item_Block *itb);
128 static void _calc_job(void *data);
129 static void _on_focus_hook(void *data,
131 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
132 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
133 static Eina_Bool _item_single_select_up(Widget_Data *wd);
134 static Eina_Bool _item_single_select_down(Widget_Data *wd);
135 static Eina_Bool _event_hook(Evas_Object *obj,
137 Evas_Callback_Type type,
139 static void _signal_emit_hook(Evas_Object *obj,
140 const char *emission,
142 static Eina_Bool _deselect_all_items(Widget_Data *wd);
143 static void _pan_calculate(Evas_Object *obj);
144 static void _pan_max_get(Evas_Object *obj,
147 static void _item_position(Elm_Gen_Item *it,
151 static void _mode_item_realize(Elm_Gen_Item *it);
152 static void _mode_item_unrealize(Elm_Gen_Item *it);
153 static void _item_mode_set(Elm_Gen_Item *it);
154 static void _item_mode_unset(Widget_Data *wd);
155 static void _edit_mode_item_position(Elm_Gen_Item *it, int itx, int ity);
156 static void _edit_mode_item_realize(Elm_Gen_Item *it, Eina_Bool effect_on);
157 static void _edit_mode_item_unrealize(Elm_Gen_Item *it);
158 static void _group_items_recalc(void *data);
159 static void _item_move_after(Elm_Gen_Item *it,
160 Elm_Gen_Item *after);
161 static void _item_move_before(Elm_Gen_Item *it,
162 Elm_Gen_Item *before);
163 static void _item_auto_scroll(Widget_Data *wd);
164 static void _elm_genlist_clear(Evas_Object *obj,
166 static void _pan_child_size_get(Evas_Object *obj,
170 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
172 static const char SIG_ACTIVATED[] = "activated";
173 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
174 static const char SIG_SELECTED[] = "selected";
175 static const char SIG_UNSELECTED[] = "unselected";
176 static const char SIG_EXPANDED[] = "expanded";
177 static const char SIG_CONTRACTED[] = "contracted";
178 static const char SIG_EXPAND_REQUEST[] = "expand,request";
179 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
180 static const char SIG_REALIZED[] = "realized";
181 static const char SIG_UNREALIZED[] = "unrealized";
182 static const char SIG_DRAG_START_UP[] = "drag,start,up";
183 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
184 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
185 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
186 static const char SIG_DRAG_STOP[] = "drag,stop";
187 static const char SIG_DRAG[] = "drag";
188 static const char SIG_LONGPRESSED[] = "longpressed";
189 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
190 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
191 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
192 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
193 static const char SIG_EDGE_TOP[] = "edge,top";
194 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
195 static const char SIG_EDGE_LEFT[] = "edge,left";
196 static const char SIG_EDGE_RIGHT[] = "edge,right";
197 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
198 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
199 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
200 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
201 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
202 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
203 static const char SIG_SWIPE[] = "swipe";
204 static const char SIG_MOVED[] = "moved";
205 static const char SIG_INDEX_UPDATE[] = "index,update";
207 static const Evas_Smart_Cb_Description _signals[] = {
208 {SIG_CLICKED_DOUBLE, ""},
211 {SIG_UNSELECTED, ""},
213 {SIG_CONTRACTED, ""},
214 {SIG_EXPAND_REQUEST, ""},
215 {SIG_CONTRACT_REQUEST, ""},
217 {SIG_UNREALIZED, ""},
218 {SIG_DRAG_START_UP, ""},
219 {SIG_DRAG_START_DOWN, ""},
220 {SIG_DRAG_START_LEFT, ""},
221 {SIG_DRAG_START_RIGHT, ""},
224 {SIG_LONGPRESSED, ""},
225 {SIG_SCROLL_ANIM_START, ""},
226 {SIG_SCROLL_ANIM_STOP, ""},
227 {SIG_SCROLL_DRAG_START, ""},
228 {SIG_SCROLL_DRAG_STOP, ""},
230 {SIG_EDGE_BOTTOM, ""},
232 {SIG_EDGE_RIGHT, ""},
233 {SIG_MULTI_SWIPE_LEFT, ""},
234 {SIG_MULTI_SWIPE_RIGHT, ""},
235 {SIG_MULTI_SWIPE_UP, ""},
236 {SIG_MULTI_SWIPE_DOWN, ""},
237 {SIG_MULTI_PINCH_OUT, ""},
238 {SIG_MULTI_PINCH_IN, ""},
245 #undef ELM_CHECK_WIDTYPE
246 #define ELM_CHECK_WIDTYPE(obj, widtype) \
247 if ((!obj) || (!elm_genlist_type_check((obj), __func__))) return
248 #undef ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN
249 #define ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, ...) \
250 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
251 ELM_CHECK_WIDTYPE(WIDGET((it)), widtype) __VA_ARGS__;
253 static const char *_gengrid = NULL;
254 static const char *_genlist = NULL;
256 /* THIS FUNCTION IS HACKY AND TEMPORARY!!! */
258 elm_genlist_type_check(const Evas_Object *obj,
261 const char *provided, *expected = "(unknown)";
262 static int abort_on_warn = -1;
263 provided = elm_widget_type_get(obj);
264 if (!_genlist) _genlist = eina_stringshare_add("genlist");
265 if (!_gengrid) _gengrid = eina_stringshare_add("gengrid");
266 if (EINA_LIKELY(provided == _genlist) || EINA_LIKELY(provided == _gengrid))
268 if ((!provided) || (!provided[0]))
270 provided = evas_object_type_get(obj);
271 if ((!provided) || (!provided[0]))
272 provided = "(unknown)";
274 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
275 if (abort_on_warn == -1)
277 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
278 else abort_on_warn = 0;
280 if (abort_on_warn == 1) abort();
285 _event_hook(Evas_Object *obj,
286 Evas_Object *src __UNUSED__,
287 Evas_Callback_Type type,
290 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
291 Evas_Event_Key_Down *ev = event_info;
292 Widget_Data *wd = elm_widget_data_get(obj);
293 Evas_Coord pan_max_x = 0, pan_max_y = 0;
294 if (!wd) return EINA_FALSE;
295 if (!wd->items) return EINA_FALSE;
296 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
297 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
299 Elm_Object_Item *it = NULL;
302 Evas_Coord step_x = 0;
303 Evas_Coord step_y = 0;
306 Evas_Coord page_x = 0;
307 Evas_Coord page_y = 0;
309 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
310 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
311 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
312 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
314 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
318 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
322 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
324 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
325 (_item_multi_select_up(wd)))
326 || (_item_single_select_up(wd)))
328 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
334 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
336 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
337 (_item_multi_select_down(wd)))
338 || (_item_single_select_down(wd)))
340 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
346 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
348 it = elm_genlist_first_item_get(obj);
349 elm_genlist_item_bring_in(it);
350 elm_genlist_item_selected_set(it, EINA_TRUE);
351 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
354 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
356 it = elm_genlist_last_item_get(obj);
357 elm_genlist_item_bring_in(it);
358 elm_genlist_item_selected_set(it, EINA_TRUE);
359 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
362 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
365 y -= -(page_y * v_h) / 100;
369 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
372 y += -(page_y * v_h) / 100;
376 else if (!strcmp(ev->keyname, "Escape"))
378 if (!_deselect_all_items(wd)) return EINA_FALSE;
379 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
382 else if (((!strcmp(ev->keyname, "Return")) ||
383 (!strcmp(ev->keyname, "KP_Enter")) ||
384 (!strcmp(ev->keyname, "space")))
385 && (!wd->multi) && (wd->selected))
387 it = elm_genlist_selected_item_get(obj);
388 elm_genlist_item_expanded_set(it,
389 !elm_genlist_item_expanded_get(it));
390 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
392 else return EINA_FALSE;
394 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
395 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
397 if (x > pan_max_x) x = pan_max_x;
399 if (y > pan_max_y) y = pan_max_y;
400 elm_smart_scroller_child_pos_set(wd->scr, x, y);
405 _deselect_all_items(Widget_Data *wd)
407 if (!wd->selected) return EINA_FALSE;
409 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
415 _item_multi_select_up(Widget_Data *wd)
417 if (!wd->selected) return EINA_FALSE;
418 if (!wd->multi) return EINA_FALSE;
420 Elm_Object_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
421 if (!prev) return EINA_TRUE;
423 if (elm_genlist_item_selected_get(prev))
425 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
426 wd->last_selected_item = prev;
427 elm_genlist_item_show(wd->last_selected_item);
431 elm_genlist_item_selected_set(prev, EINA_TRUE);
432 elm_genlist_item_show(prev);
438 _item_multi_select_down(Widget_Data *wd)
440 if (!wd->selected) return EINA_FALSE;
441 if (!wd->multi) return EINA_FALSE;
443 Elm_Object_Item *next;
444 next = elm_genlist_item_next_get(wd->last_selected_item);
445 if (!next) return EINA_TRUE;
447 if (elm_genlist_item_selected_get(next))
449 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
450 wd->last_selected_item = next;
451 elm_genlist_item_show(wd->last_selected_item);
455 elm_genlist_item_selected_set(next, EINA_TRUE);
456 elm_genlist_item_show(next);
462 _item_single_select_up(Widget_Data *wd)
467 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
468 while ((prev) && (prev->generation < wd->generation))
469 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
471 else prev = (Elm_Gen_Item *) elm_genlist_item_prev_get(wd->last_selected_item);
473 if (!prev) return EINA_FALSE;
475 _deselect_all_items(wd);
477 elm_genlist_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
478 elm_genlist_item_show((Elm_Object_Item *) prev);
483 _item_single_select_down(Widget_Data *wd)
488 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
489 while ((next) && (next->generation < wd->generation))
490 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
492 else next = (Elm_Gen_Item *) elm_genlist_item_next_get(wd->last_selected_item);
494 if (!next) return EINA_FALSE;
496 _deselect_all_items(wd);
498 elm_genlist_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
499 elm_genlist_item_show((Elm_Object_Item *) next);
504 _on_focus_hook(void *data __UNUSED__,
507 Widget_Data *wd = elm_widget_data_get(obj);
509 if (elm_widget_focus_get(obj))
511 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
512 evas_object_focus_set(wd->obj, EINA_TRUE);
513 if ((wd->selected) && (!wd->last_selected_item))
514 wd->last_selected_item = eina_list_data_get(wd->selected);
518 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
519 evas_object_focus_set(wd->obj, EINA_FALSE);
524 _del_hook(Evas_Object *obj)
526 Widget_Data *wd = elm_widget_data_get(obj);
528 _item_cache_zero(wd);
529 if (wd->calc_job) ecore_job_del(wd->calc_job);
530 if (wd->update_job) ecore_job_del(wd->update_job);
531 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
532 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
533 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
534 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
535 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
540 _del_pre_hook(Evas_Object *obj)
542 Widget_Data *wd = elm_widget_data_get(obj);
544 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
545 elm_genlist_clear(obj);
546 evas_object_del(wd->pan_smart);
547 wd->pan_smart = NULL;
551 _mirrored_set(Evas_Object *obj,
554 Widget_Data *wd = elm_widget_data_get(obj);
556 _item_cache_zero(wd);
557 elm_smart_scroller_mirrored_set(wd->scr, rtl);
561 _theme_hook(Evas_Object *obj)
563 Widget_Data *wd = elm_widget_data_get(obj);
566 evas_event_freeze(evas_object_evas_get(wd->obj));
567 _item_cache_zero(wd);
568 _elm_widget_mirrored_reload(obj);
569 _mirrored_set(obj, elm_widget_mirrored_get(obj));
570 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
571 elm_widget_style_get(obj));
572 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
573 wd->item_width = wd->item_height = 0;
574 wd->group_item_width = wd->group_item_height = 0;
575 wd->minw = wd->minh = wd->realminw = 0;
576 EINA_INLIST_FOREACH(wd->blocks, itb)
581 if (itb->realized) _item_block_unrealize(itb);
582 EINA_LIST_FOREACH(itb->items, l, it)
583 it->item->mincalcd = EINA_FALSE;
585 itb->changed = EINA_TRUE;
587 if (wd->calc_job) ecore_job_del(wd->calc_job);
588 wd->calc_job = ecore_job_add(_calc_job, wd);
590 evas_event_thaw(evas_object_evas_get(wd->obj));
591 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
595 _show_region_hook(void *data,
598 Widget_Data *wd = elm_widget_data_get(data);
599 Evas_Coord x, y, w, h;
601 elm_widget_show_region_get(obj, &x, &y, &w, &h);
602 //x & y are screen coordinates, Add with pan coordinates
605 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
609 _translate_hook(Evas_Object *obj)
611 evas_object_smart_callback_call(obj, "language,changed", NULL);
615 _sizing_eval(Evas_Object *obj)
617 Widget_Data *wd = elm_widget_data_get(obj);
618 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
620 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
621 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
623 if (wd->height_for_width)
627 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
628 if ((vw != 0) && (vw != wd->prev_viewport_w))
632 wd->prev_viewport_w = vw;
633 EINA_INLIST_FOREACH(wd->blocks, itb)
635 itb->must_recalc = EINA_TRUE;
637 if (wd->calc_job) ecore_job_del(wd->calc_job);
638 wd->calc_job = ecore_job_add(_calc_job, wd);
641 if (wd->mode == ELM_LIST_LIMIT)
647 elm_smart_scroller_child_viewport_size_get(wd->scr, &vmw, &vmh);
648 edje_object_size_min_calc
649 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
656 edje_object_size_min_calc
657 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
661 evas_object_size_hint_min_set(obj, minw, minh);
662 evas_object_size_hint_max_set(obj, maxw, maxh);
666 _signal_emit_hook(Evas_Object *obj,
667 const char *emission,
670 Widget_Data *wd = elm_widget_data_get(obj);
671 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
676 _item_highlight(Elm_Gen_Item *it)
678 const char *selectraise;
679 if ((it->wd->no_select) || (it->generation < it->wd->generation) ||
680 (it->highlighted) || elm_widget_item_disabled_get(it) ||
681 (it->display_only) || (it->item->mode_view))
683 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
684 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
685 selectraise = edje_object_data_get(VIEW(it), "selectraise");
686 if ((selectraise) && (!strcmp(selectraise, "on")))
688 if (it->edit_obj) evas_object_raise(it->edit_obj);
689 else evas_object_raise(VIEW(it));
690 if ((it->item->group_item) && (it->item->group_item->realized))
691 evas_object_raise(it->item->VIEW(group_item));
693 it->highlighted = EINA_TRUE;
697 _item_unhighlight(Elm_Gen_Item *it)
699 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
700 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
701 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
702 if (!it->item->nostacking)
704 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
706 if (it->edit_obj) evas_object_lower(it->edit_obj);
707 else evas_object_lower(VIEW(it));
711 if (it->edit_obj) evas_object_raise(it->edit_obj);
712 else evas_object_raise(VIEW(it));
715 it->highlighted = EINA_FALSE;
719 _item_block_position_update(Eina_Inlist *list, int idx)
723 EINA_INLIST_FOREACH(list, tmp)
725 tmp->position = idx++;
726 tmp->position_update = EINA_TRUE;
731 _item_position_update(Eina_List *list, int idx)
736 EINA_LIST_FOREACH(list, l, it)
738 it->position = idx++;
739 it->position_update = EINA_TRUE;
744 _item_block_del(Elm_Gen_Item *it)
747 Item_Block *itb = it->item->block;
749 itb->items = eina_list_remove(itb->items, it);
751 itb->changed = EINA_TRUE;
752 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
753 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
756 il = EINA_INLIST_GET(itb);
757 Item_Block *itbn = (Item_Block *)(il->next);
759 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
762 _item_block_position_update(il->next, itb->position);
763 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
766 if (itbn) itbn->changed = EINA_TRUE;
770 if (itb->count < itb->wd->max_items_per_block/2)
772 il = EINA_INLIST_GET(itb);
773 Item_Block *itbp = (Item_Block *)(il->prev);
774 Item_Block *itbn = (Item_Block *)(il->next);
775 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
779 EINA_LIST_FREE(itb->items, it2)
781 it2->item->block = itbp;
782 itbp->items = eina_list_append(itbp->items, it2);
784 itbp->changed = EINA_TRUE;
786 _item_block_position_update(EINA_INLIST_GET(itb)->next,
788 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
789 EINA_INLIST_GET(itb));
792 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
796 Eina_List *last = eina_list_last(itb->items);
797 Elm_Gen_Item *it2 = last->data;
799 it2->item->block = itbn;
800 itb->items = eina_list_remove_list(itb->items, last);
801 itbn->items = eina_list_prepend(itbn->items, it2);
803 itbn->changed = EINA_TRUE;
805 _item_block_position_update(EINA_INLIST_GET(itb)->next,
808 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
816 _item_del(Elm_Gen_Item *it)
818 Evas_Object *obj = WIDGET(it);
820 evas_event_freeze(evas_object_evas_get(obj));
821 elm_genlist_item_subitems_clear((Elm_Object_Item *) it);
822 if (it->wd->show_item == it) it->wd->show_item = NULL;
823 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
824 if (it->item->edit_mode_item_realized) _edit_mode_item_unrealize(it);
825 if (it->item->block) _item_block_del(it);
826 if (it->item->queued)
827 it->wd->queue = eina_list_remove(it->wd->queue, it);
828 if (it->wd->anchor_item == it)
830 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
831 if (!it->wd->anchor_item)
832 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
834 if (it->wd->expanded_item == it) it->wd->expanded_item = NULL;
836 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
837 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
838 _elm_genlist_item_del_serious(it);
839 elm_genlist_item_class_unref((Elm_Genlist_Item_Class *)it->itc);
840 evas_event_thaw(evas_object_evas_get(obj));
841 evas_event_thaw_eval(evas_object_evas_get(obj));
845 _clear_cb(Widget_Data *wd)
847 wd->anchor_item = NULL;
850 Item_Block *itb = (Item_Block *)(wd->blocks);
852 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
853 if (itb->items) eina_list_free(itb->items);
856 if (wd->queue_idle_enterer)
858 ecore_idle_enterer_del(wd->queue_idle_enterer);
859 wd->queue_idle_enterer = NULL;
861 if (wd->must_recalc_idler)
863 ecore_idler_del(wd->must_recalc_idler);
864 wd->must_recalc_idler = NULL;
866 if (wd->queue) wd->queue = eina_list_free(wd->queue);
867 if (wd->reorder_move_animator)
869 ecore_animator_del(wd->reorder_move_animator);
870 wd->reorder_move_animator = NULL;
872 wd->show_item = NULL;
873 wd->reorder_old_pan_y = 0;
877 _item_unselect(Elm_Gen_Item *it)
879 if ((it->generation < it->wd->generation) || (!it->selected)) return;
880 it->selected = EINA_FALSE;
881 it->wd->selected = eina_list_remove(it->wd->selected, it);
882 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
886 _mouse_move(void *data,
887 Evas *evas __UNUSED__,
891 Elm_Gen_Item *it = data;
892 Evas_Event_Mouse_Move *ev = event_info;
893 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
894 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
896 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
898 if (!it->wd->on_hold)
900 it->wd->on_hold = EINA_TRUE;
901 if (!it->wd->wasselected)
903 _item_unhighlight(it);
908 if (it->wd->multitouched)
910 it->wd->cur_x = ev->cur.canvas.x;
911 it->wd->cur_y = ev->cur.canvas.y;
914 if ((it->dragging) && (it->down))
916 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
919 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
920 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
921 if (abs((it->wd->history[it->wd->movements].x -
922 it->wd->history[0].x)) > 40)
923 it->wd->swipe = EINA_TRUE;
929 ecore_timer_del(it->long_timer);
930 it->long_timer = NULL;
932 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
935 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
939 ecore_timer_del(it->long_timer);
940 it->long_timer = NULL;
942 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
944 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
945 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
947 if (!it->wd->reorder_start_y)
948 it->wd->reorder_start_y = it->item->block->y + it->y;
952 else if (it_scrl_y + it->wd->reorder_it->item->h > oy + oh)
953 y_pos = oy + oh - it->wd->reorder_it->item->h;
958 _item_position(it, it->edit_obj, it->item->scrl_x, y_pos);
960 _item_position(it, VIEW(it), it->item->scrl_x, y_pos);
962 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
963 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
967 if (!it->display_only)
968 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
969 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
970 x = ev->cur.canvas.x - x;
971 y = ev->cur.canvas.y - y;
974 if (adx < 0) adx = -dx;
977 if (ady < 0) ady = -dy;
980 if ((adx > minw) || (ady > minh))
982 it->dragging = EINA_TRUE;
985 ecore_timer_del(it->long_timer);
986 it->long_timer = NULL;
988 if (!it->wd->wasselected)
990 _item_unhighlight(it);
996 evas_object_smart_callback_call(WIDGET(it),
997 SIG_DRAG_START_UP, it);
1001 evas_object_smart_callback_call(WIDGET(it),
1002 SIG_DRAG_START_LEFT, it);
1004 evas_object_smart_callback_call(WIDGET(it),
1005 SIG_DRAG_START_RIGHT, it);
1011 evas_object_smart_callback_call(WIDGET(it),
1012 SIG_DRAG_START_DOWN, it);
1016 evas_object_smart_callback_call(WIDGET(it),
1017 SIG_DRAG_START_LEFT, it);
1019 evas_object_smart_callback_call(WIDGET(it),
1020 SIG_DRAG_START_RIGHT, it);
1027 _long_press(void *data)
1029 Elm_Gen_Item *it = data, *it_tmp;
1030 Eina_List *list, *l;
1032 it->long_timer = NULL;
1033 if (elm_widget_item_disabled_get(it) || (it->dragging) || (it->display_only))
1034 return ECORE_CALLBACK_CANCEL;
1035 it->wd->longpressed = EINA_TRUE;
1036 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
1037 if ((it->wd->reorder_mode) && (!it->group))
1039 it->wd->reorder_it = it;
1040 it->wd->reorder_start_y = 0;
1042 evas_object_raise(it->edit_obj);
1044 evas_object_raise(VIEW(it));
1046 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1047 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1049 list = elm_genlist_realized_items_get(it->wd->obj);
1050 EINA_LIST_FOREACH(list, l, it_tmp)
1052 if (it != it_tmp) _item_unselect(it_tmp);
1054 if (elm_genlist_item_expanded_get((Elm_Object_Item *) it))
1056 elm_genlist_item_expanded_set((Elm_Object_Item *) it, EINA_FALSE);
1057 return ECORE_CALLBACK_RENEW;
1060 if (!it->wd->edit_mode)
1061 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
1063 return ECORE_CALLBACK_CANCEL;
1067 _swipe(Elm_Gen_Item *it)
1072 if ((it->display_only) || elm_widget_item_disabled_get(it)) return;
1073 it->wd->swipe = EINA_FALSE;
1074 for (i = 0; i < it->wd->movements; i++)
1076 sum += it->wd->history[i].x;
1077 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1080 sum /= it->wd->movements;
1081 if (abs(sum - it->wd->history[0].x) <= 10) return;
1082 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
1086 _swipe_cancel(void *data)
1088 Elm_Gen_Item *it = data;
1090 if (!it) return ECORE_CALLBACK_CANCEL;
1091 it->wd->swipe = EINA_FALSE;
1092 it->wd->movements = 0;
1093 return ECORE_CALLBACK_RENEW;
1097 _multi_cancel(void *data)
1099 Widget_Data *wd = data;
1101 if (!wd) return ECORE_CALLBACK_CANCEL;
1102 wd->multi_timeout = EINA_TRUE;
1103 return ECORE_CALLBACK_RENEW;
1107 _multi_touch_gesture_eval(void *data)
1109 Elm_Gen_Item *it = data;
1111 it->wd->multitouched = EINA_FALSE;
1112 if (it->wd->multi_timer)
1114 ecore_timer_del(it->wd->multi_timer);
1115 it->wd->multi_timer = NULL;
1117 if (it->wd->multi_timeout)
1119 it->wd->multi_timeout = EINA_FALSE;
1123 Evas_Coord minw = 0, minh = 0;
1124 Evas_Coord off_x, off_y, off_mx, off_my;
1126 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1127 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1128 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1129 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1130 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1132 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1134 if ((off_x + off_mx) > (off_y + off_my))
1136 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1137 evas_object_smart_callback_call(WIDGET(it),
1138 SIG_MULTI_SWIPE_RIGHT, it);
1139 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1140 evas_object_smart_callback_call(WIDGET(it),
1141 SIG_MULTI_SWIPE_LEFT, it);
1142 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1143 evas_object_smart_callback_call(WIDGET(it),
1144 SIG_MULTI_PINCH_OUT, it);
1146 evas_object_smart_callback_call(WIDGET(it),
1147 SIG_MULTI_PINCH_IN, it);
1151 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1152 evas_object_smart_callback_call(WIDGET(it),
1153 SIG_MULTI_SWIPE_DOWN, it);
1154 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1155 evas_object_smart_callback_call(WIDGET(it),
1156 SIG_MULTI_SWIPE_UP, it);
1157 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1158 evas_object_smart_callback_call(WIDGET(it),
1159 SIG_MULTI_PINCH_OUT, it);
1161 evas_object_smart_callback_call(WIDGET(it),
1162 SIG_MULTI_PINCH_IN, it);
1165 it->wd->multi_timeout = EINA_FALSE;
1169 _multi_down(void *data,
1170 Evas *evas __UNUSED__,
1171 Evas_Object *obj __UNUSED__,
1174 Elm_Gen_Item *it = data;
1175 Evas_Event_Multi_Down *ev = event_info;
1177 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1178 it->wd->multi_device = ev->device;
1179 it->wd->multi_down = EINA_TRUE;
1180 it->wd->multitouched = EINA_TRUE;
1181 it->wd->prev_mx = ev->canvas.x;
1182 it->wd->prev_my = ev->canvas.y;
1183 if (!it->wd->wasselected)
1185 _item_unhighlight(it);
1188 it->wd->wasselected = EINA_FALSE;
1189 it->wd->longpressed = EINA_FALSE;
1192 ecore_timer_del(it->long_timer);
1193 it->long_timer = NULL;
1197 it->dragging = EINA_FALSE;
1198 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1200 if (it->item->swipe_timer)
1202 ecore_timer_del(it->item->swipe_timer);
1203 it->item->swipe_timer = NULL;
1205 if (it->wd->on_hold)
1207 it->wd->swipe = EINA_FALSE;
1208 it->wd->movements = 0;
1209 it->wd->on_hold = EINA_FALSE;
1214 _multi_up(void *data,
1215 Evas *evas __UNUSED__,
1216 Evas_Object *obj __UNUSED__,
1219 Elm_Gen_Item *it = data;
1220 Evas_Event_Multi_Up *ev = event_info;
1222 if (it->wd->multi_device != ev->device) return;
1223 it->wd->multi_device = 0;
1224 it->wd->multi_down = EINA_FALSE;
1225 if (it->wd->mouse_down) return;
1226 _multi_touch_gesture_eval(data);
1230 _multi_move(void *data,
1231 Evas *evas __UNUSED__,
1232 Evas_Object *obj __UNUSED__,
1235 Elm_Gen_Item *it = data;
1236 Evas_Event_Multi_Move *ev = event_info;
1238 if (it->wd->multi_device != ev->device) return;
1239 it->wd->cur_mx = ev->cur.canvas.x;
1240 it->wd->cur_my = ev->cur.canvas.y;
1244 _mouse_down(void *data,
1245 Evas *evas __UNUSED__,
1249 Elm_Gen_Item *it = data;
1250 Evas_Event_Mouse_Down *ev = event_info;
1253 if (ev->button != 1) return;
1254 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1256 it->wd->on_hold = EINA_TRUE;
1259 it->down = EINA_TRUE;
1260 it->dragging = EINA_FALSE;
1261 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1262 it->dx = ev->canvas.x - x;
1263 it->dy = ev->canvas.y - y;
1264 it->wd->mouse_down = EINA_TRUE;
1265 if (!it->wd->multitouched)
1267 it->wd->prev_x = ev->canvas.x;
1268 it->wd->prev_y = ev->canvas.y;
1269 it->wd->multi_timeout = EINA_FALSE;
1270 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1271 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1273 it->wd->longpressed = EINA_FALSE;
1274 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1275 else it->wd->on_hold = EINA_FALSE;
1276 if (it->wd->on_hold) return;
1277 it->wd->wasselected = it->selected;
1278 _item_highlight(it);
1279 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1280 if ((!elm_widget_item_disabled_get(it)) && (!it->display_only))
1282 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1283 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
1285 if (it->long_timer) ecore_timer_del(it->long_timer);
1286 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
1287 it->item->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1289 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1292 it->long_timer = NULL;
1293 it->wd->swipe = EINA_FALSE;
1294 it->wd->movements = 0;
1298 _mouse_up(void *data,
1299 Evas *evas __UNUSED__,
1300 Evas_Object *obj __UNUSED__,
1303 Elm_Gen_Item *it = data;
1304 Evas_Event_Mouse_Up *ev = event_info;
1305 Eina_Bool dragged = EINA_FALSE;
1307 if (ev->button != 1) return;
1308 it->down = EINA_FALSE;
1309 it->wd->mouse_down = EINA_FALSE;
1310 if (it->wd->multitouched)
1312 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1313 if (it->wd->multi_down) return;
1314 _multi_touch_gesture_eval(data);
1317 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1318 else it->wd->on_hold = EINA_FALSE;
1321 ecore_timer_del(it->long_timer);
1322 it->long_timer = NULL;
1326 it->dragging = EINA_FALSE;
1327 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1330 if (it->item->swipe_timer)
1332 ecore_timer_del(it->item->swipe_timer);
1333 it->item->swipe_timer = NULL;
1335 if (it->wd->multi_timer)
1337 ecore_timer_del(it->wd->multi_timer);
1338 it->wd->multi_timer = NULL;
1339 it->wd->multi_timeout = EINA_FALSE;
1341 if (it->wd->on_hold)
1343 if (it->wd->swipe) _swipe(data);
1344 it->wd->longpressed = EINA_FALSE;
1345 it->wd->on_hold = EINA_FALSE;
1348 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1350 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1352 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1354 if (it_scrl_y <= it->wd->reorder_rel->item->scrl_y)
1355 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1357 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1361 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1362 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1364 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
1365 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1366 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1367 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
1369 if (it->wd->longpressed)
1371 it->wd->longpressed = EINA_FALSE;
1372 if (!it->wd->wasselected)
1374 _item_unhighlight(it);
1377 it->wd->wasselected = EINA_FALSE;
1382 if (it->want_unrealize)
1384 _elm_genlist_item_unrealize(it, EINA_FALSE);
1385 if (it->item->block->want_unrealize)
1386 _item_block_unrealize(it->item->block);
1389 if (elm_widget_item_disabled_get(it) || (dragged) || (it->display_only))
1391 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1396 _item_highlight(it);
1401 _item_unhighlight(it);
1409 Widget_Data *wd = it->wd;
1412 while (wd->selected)
1414 _item_unhighlight(wd->selected->data);
1415 _item_unselect(wd->selected->data);
1421 const Eina_List *l, *l_next;
1424 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1427 _item_unhighlight(it2);
1428 _item_unselect(it2);
1430 //_item_highlight(it);
1433 _item_highlight(it);
1439 _signal_expand_toggle(void *data,
1440 Evas_Object *obj __UNUSED__,
1441 const char *emission __UNUSED__,
1442 const char *source __UNUSED__)
1444 Elm_Gen_Item *it = data;
1446 if (it->item->expanded)
1447 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1449 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1453 _signal_expand(void *data,
1454 Evas_Object *obj __UNUSED__,
1455 const char *emission __UNUSED__,
1456 const char *source __UNUSED__)
1458 Elm_Gen_Item *it = data;
1460 if (!it->item->expanded)
1461 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1465 _signal_contract(void *data,
1466 Evas_Object *obj __UNUSED__,
1467 const char *emission __UNUSED__,
1468 const char *source __UNUSED__)
1470 Elm_Gen_Item *it = data;
1472 if (it->item->expanded)
1473 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1477 _scr_hold_timer_cb(void *data)
1479 if (!data) return ECORE_CALLBACK_CANCEL;
1480 Widget_Data *wd = data;
1481 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1482 wd->scr_hold_timer = NULL;
1483 return ECORE_CALLBACK_CANCEL;
1487 _mode_finished_signal_cb(void *data,
1489 const char *emission __UNUSED__,
1490 const char *source __UNUSED__)
1494 Elm_Gen_Item *it = data;
1495 if ((it->generation < it->wd->generation) || (!it->realized) || (!it->item->mode_view)) return;
1497 Evas *te = evas_object_evas_get(obj);
1499 evas_event_freeze(te);
1500 it->item->nocache = EINA_FALSE;
1501 _mode_item_unrealize(it);
1502 if (it->item->group_item)
1503 evas_object_raise(it->item->VIEW(group_item));
1504 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1505 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1506 evas_event_thaw(te);
1507 evas_event_thaw_eval(te);
1511 _item_cache_clean(Widget_Data *wd)
1513 evas_event_freeze(evas_object_evas_get(wd->obj));
1514 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1518 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1519 wd->item_cache = eina_inlist_remove(wd->item_cache,
1520 wd->item_cache->last);
1521 wd->item_cache_count--;
1522 if (itc->spacer) evas_object_del(itc->spacer);
1523 if (itc->base_view) evas_object_del(itc->base_view);
1524 if (itc->item_style) eina_stringshare_del(itc->item_style);
1527 evas_event_thaw(evas_object_evas_get(wd->obj));
1528 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1532 _item_cache_zero(Widget_Data *wd)
1534 int pmax = wd->item_cache_max;
1535 wd->item_cache_max = 0;
1536 _item_cache_clean(wd);
1537 wd->item_cache_max = pmax;
1541 _item_cache_add(Elm_Gen_Item *it)
1545 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1546 if (it->wd->item_cache_max <= 0)
1548 evas_object_del(VIEW(it));
1550 evas_object_del(it->spacer);
1552 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1553 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1557 it->wd->item_cache_count++;
1558 itc = calloc(1, sizeof(Item_Cache));
1561 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1562 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1565 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1566 EINA_INLIST_GET(itc));
1567 itc->spacer = it->spacer;
1569 itc->base_view = VIEW(it);
1571 edje_object_signal_emit(itc->base_view, "elm,state,unselected", "elm");
1572 evas_object_hide(itc->base_view);
1573 evas_object_move(itc->base_view, -9999, -9999);
1574 itc->item_style = eina_stringshare_add(it->itc->item_style);
1575 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1576 itc->compress = (it->wd->compress);
1577 itc->selected = it->selected;
1578 itc->disabled = elm_widget_item_disabled_get(it);
1579 itc->expanded = it->item->expanded;
1582 ecore_timer_del(it->long_timer);
1583 it->long_timer = NULL;
1585 if (it->item->swipe_timer)
1587 ecore_timer_del(it->item->swipe_timer);
1588 it->item->swipe_timer = NULL;
1590 // FIXME: other callbacks?
1591 edje_object_signal_callback_del_full(itc->base_view,
1592 "elm,action,expand,toggle",
1593 "elm", _signal_expand_toggle, it);
1594 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1596 _signal_expand, it);
1597 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1598 "elm", _signal_contract, it);
1599 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1601 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1603 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1605 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1607 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1609 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1611 _item_cache_clean(it->wd);
1612 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1613 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1617 _item_cache_find(Elm_Gen_Item *it)
1622 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1623 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1625 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1627 if ((itc->tree == tree) &&
1628 (itc->compress == it->wd->compress) &&
1629 (!strcmp(it->itc->item_style, itc->item_style)))
1631 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1632 EINA_INLIST_GET(itc));
1633 it->wd->item_cache_count--;
1641 _elm_genlist_item_index_update(Elm_Gen_Item *it)
1643 if (it->position_update || it->item->block->position_update)
1645 evas_object_smart_callback_call(WIDGET(it), SIG_INDEX_UPDATE, it);
1646 it->position_update = EINA_FALSE;
1651 _elm_genlist_item_odd_even_update(Elm_Gen_Item *it)
1653 if (!it->item->nostacking)
1655 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
1657 if (it->edit_obj) evas_object_lower(it->edit_obj);
1658 else evas_object_lower(VIEW(it));
1662 if (it->edit_obj) evas_object_raise(it->edit_obj);
1663 else evas_object_raise(VIEW(it));
1667 if (it->item->order_num_in & 0x1)
1669 edje_object_signal_emit(VIEW(it), "elm,state,odd", "elm");
1670 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,odd", "elm");
1674 edje_object_signal_emit(VIEW(it), "elm,state,even", "elm");
1675 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,even", "elm");
1680 _elm_genlist_item_state_update(Elm_Gen_Item *it, Item_Cache *itc)
1684 if (it->selected != itc->selected)
1687 edje_object_signal_emit(VIEW(it),
1688 "elm,state,selected", "elm");
1691 edje_object_signal_emit(it->edit_obj,
1692 "elm,state,selected", "elm");
1694 if (elm_widget_item_disabled_get(it) != itc->disabled)
1696 if (elm_widget_item_disabled_get(it))
1697 edje_object_signal_emit(VIEW(it),
1698 "elm,state,disabled", "elm");
1700 edje_object_signal_emit(it->edit_obj,
1701 "elm,state,disabled", "elm");
1703 if (it->item->expanded != itc->expanded)
1705 if (it->item->expanded)
1706 edje_object_signal_emit(VIEW(it),
1707 "elm,state,expanded", "elm");
1709 edje_object_signal_emit(it->edit_obj,
1710 "elm,state,expanded", "elm");
1717 edje_object_signal_emit(VIEW(it),
1718 "elm,state,selected", "elm");
1720 edje_object_signal_emit(it->edit_obj,
1721 "elm,state,selected", "elm");
1724 if (elm_widget_item_disabled_get(it))
1726 edje_object_signal_emit(VIEW(it),
1727 "elm,state,disabled", "elm");
1729 edje_object_signal_emit(it->edit_obj,
1730 "elm,state,disabled", "elm");
1732 if (it->item->expanded)
1734 edje_object_signal_emit(VIEW(it),
1735 "elm,state,expanded", "elm");
1737 edje_object_signal_emit(it->edit_obj,
1738 "elm,state,expanded", "elm");
1744 _item_cache_free(Item_Cache *itc)
1746 if (itc->spacer) evas_object_del(itc->spacer);
1747 if (itc->base_view) evas_object_del(itc->base_view);
1748 if (itc->item_style) eina_stringshare_del(itc->item_style);
1753 _item_text_realize(Elm_Gen_Item *it,
1754 Evas_Object *target,
1758 if (it->itc->func.text_get)
1763 *source = elm_widget_stringlist_get(edje_object_data_get(target, "texts"));
1764 EINA_LIST_FOREACH(*source, l, key)
1766 if (parts && fnmatch(parts, key, FNM_PERIOD))
1769 char *s = it->itc->func.text_get
1770 ((void *)it->base.data, WIDGET(it), key);
1774 edje_object_part_text_set(target, key, s);
1779 edje_object_part_text_set(target, key, "");
1786 _item_content_unrealize(Elm_Gen_Item *it,
1787 Evas_Object *target,
1791 Eina_List *res = it->content_objs;
1793 if (it->itc->func.content_get)
1797 Evas_Object *ic = NULL;
1799 EINA_LIST_FOREACH(*source, l, key)
1801 if (parts && fnmatch(parts, key, FNM_PERIOD))
1804 ic = edje_object_part_swallow_get(target, key);
1807 res = eina_list_remove(res, ic);
1808 edje_object_part_unswallow(target, ic);
1809 evas_object_del(ic);
1818 _item_content_realize(Elm_Gen_Item *it,
1819 Evas_Object *target,
1823 Eina_List *res = NULL;
1825 if (it->itc->func.content_get)
1829 Evas_Object *ic = NULL;
1831 *source = elm_widget_stringlist_get(edje_object_data_get(target, "contents"));
1833 if (parts && (eina_list_count(*source) != eina_list_count(it->content_objs)))
1834 res = it->content_objs;
1836 EINA_LIST_FOREACH(*source, l, key)
1838 if (parts && fnmatch(parts, key, FNM_PERIOD))
1841 if (it->itc->func.content_get)
1842 ic = it->itc->func.content_get
1843 ((void *)it->base.data, WIDGET(it), key);
1846 res = eina_list_append(res, ic);
1847 edje_object_part_swallow(target, key, ic);
1848 evas_object_show(ic);
1849 elm_widget_sub_object_add(WIDGET(it), ic);
1850 if (elm_widget_item_disabled_get(it))
1851 elm_widget_disabled_set(ic, EINA_TRUE);
1860 _item_state_realize(Elm_Gen_Item *it,
1861 Evas_Object *target,
1865 if (it->itc->func.state_get)
1871 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1872 EINA_LIST_FOREACH(*source, l, key)
1874 if (parts && fnmatch(parts, key, FNM_PERIOD))
1877 Eina_Bool on = it->itc->func.state_get
1878 ((void *)it->base.data, WIDGET(it), key);
1882 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1883 edje_object_signal_emit(target, buf, "elm");
1887 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1888 edje_object_signal_emit(target, buf, "elm");
1895 _item_realize(Elm_Gen_Item *it,
1899 const char *treesize;
1902 Item_Cache *itc = NULL;
1904 if (it->generation < it->wd->generation) return;
1905 //evas_event_freeze(evas_object_evas_get(it->wd->obj));
1908 if (it->item->order_num_in != in)
1910 it->item->order_num_in = in;
1911 _elm_genlist_item_odd_even_update(it);
1912 _elm_genlist_item_state_update(it, NULL);
1913 _elm_genlist_item_index_update(it);
1915 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1916 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1919 it->item->order_num_in = in;
1921 if (it->item->nocache)
1922 it->item->nocache = EINA_FALSE;
1924 itc = _item_cache_find(it);
1927 VIEW(it) = itc->base_view;
1928 itc->base_view = NULL;
1929 it->spacer = itc->spacer;
1934 const char *stacking_even;
1935 const char *stacking;
1937 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
1938 edje_object_scale_set(VIEW(it),
1939 elm_widget_scale_get(WIDGET(it)) *
1940 _elm_config->scale);
1941 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
1942 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
1944 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS)
1945 strncpy(buf, "tree", sizeof(buf));
1946 else strncpy(buf, "item", sizeof(buf));
1947 if (it->wd->compress)
1948 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1950 strncat(buf, "/", sizeof(buf) - strlen(buf));
1951 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1953 _elm_theme_object_set(WIDGET(it), VIEW(it), "genlist", buf,
1954 elm_widget_style_get(WIDGET(it)));
1956 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
1957 if (!stacking_even) stacking_even = "above";
1958 it->item->stacking_even = !!strcmp("above", stacking_even);
1960 stacking = edje_object_data_get(VIEW(it), "stacking");
1961 if (!stacking) stacking = "yes";
1962 it->item->nostacking = !!strcmp("yes", stacking);
1964 edje_object_mirrored_set(VIEW(it),
1965 elm_widget_mirrored_get(WIDGET(it)));
1967 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1968 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1969 elm_widget_sub_object_add(WIDGET(it), it->spacer);
1972 _elm_genlist_item_odd_even_update(it);
1974 treesize = edje_object_data_get(VIEW(it), "treesize");
1975 if (treesize) tsize = atoi(treesize);
1976 evas_object_size_hint_min_set(it->spacer,
1977 (it->item->expanded_depth * tsize) * _elm_config->scale, 1);
1978 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
1981 edje_object_signal_callback_add(VIEW(it),
1982 "elm,action,expand,toggle",
1983 "elm", _signal_expand_toggle, it);
1984 edje_object_signal_callback_add(VIEW(it), "elm,action,expand",
1985 "elm", _signal_expand, it);
1986 edje_object_signal_callback_add(VIEW(it), "elm,action,contract",
1987 "elm", _signal_contract, it);
1988 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1990 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1992 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1994 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_DOWN,
1996 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_UP,
1998 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_MOVE,
2001 if ((it->wd->edit_mode) && (!it->edit_obj) &&
2002 (it->item->flags != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
2003 _edit_mode_item_realize(it, EINA_FALSE);
2005 _elm_genlist_item_state_update(it, itc);
2006 _elm_genlist_item_index_update(it);
2009 if ((calc) && (it->wd->homogeneous) &&
2010 ((it->wd->item_width) ||
2011 ((it->wd->item_width) && (it->wd->group_item_width))))
2013 /* homogenous genlist shortcut */
2014 if (!it->item->mincalcd)
2018 it->item->w = it->item->minw = it->wd->group_item_width;
2019 it->item->h = it->item->minh = it->wd->group_item_height;
2023 it->item->w = it->item->minw = it->wd->item_width;
2024 it->item->h = it->item->minh = it->wd->item_height;
2026 it->item->mincalcd = EINA_TRUE;
2031 /* FIXME: If you see that assert, please notify us and we
2032 will clean our mess */
2033 assert(eina_list_count(it->content_objs) == 0);
2035 _item_text_realize(it, VIEW(it), &it->texts, NULL);
2036 it->content_objs = _item_content_realize(it, VIEW(it), &it->contents, NULL);
2037 _item_state_realize(it, VIEW(it), &it->states, NULL);
2039 if (!it->item->mincalcd)
2041 Evas_Coord mw = -1, mh = -1;
2043 if (!it->display_only)
2044 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2045 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2046 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
2048 if (!it->display_only)
2049 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2050 it->item->w = it->item->minw = mw;
2051 it->item->h = it->item->minh = mh;
2052 it->item->mincalcd = EINA_TRUE;
2054 if ((!it->wd->group_item_width) && (it->group))
2056 it->wd->group_item_width = mw;
2057 it->wd->group_item_height = mh;
2059 else if ((!it->wd->item_width) && (it->item->flags == ELM_GENLIST_ITEM_NONE))
2061 it->wd->item_width = mw;
2062 it->wd->item_height = mh;
2065 if (!calc) evas_object_show(VIEW(it));
2068 if (it->tooltip.content_cb)
2070 elm_widget_item_tooltip_content_cb_set(it,
2071 it->tooltip.content_cb,
2072 it->tooltip.data, NULL);
2073 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2074 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
2077 if (it->mouse_cursor)
2078 elm_widget_item_cursor_set(it, it->mouse_cursor);
2080 it->realized = EINA_TRUE;
2081 it->want_unrealize = EINA_FALSE;
2083 if (itc) _item_cache_free(itc);
2084 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
2085 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2087 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
2089 if ((!calc) && (it->wd->edit_mode) && (it->item->flags != ELM_GENLIST_ITEM_GROUP))
2091 if (it->itc->edit_item_style)
2093 if (!it->edit_obj) _edit_mode_item_realize(it, EINA_FALSE);
2094 edje_object_message_signal_process(it->edit_obj);
2097 edje_object_message_signal_process(VIEW(it));
2101 _item_unrealize_cb(Elm_Gen_Item *it)
2103 if (it->item->nocache)
2105 evas_object_del(VIEW(it));
2107 evas_object_del(it->spacer);
2112 edje_object_mirrored_set(VIEW(it),
2113 elm_widget_mirrored_get(WIDGET(it)));
2114 edje_object_scale_set(VIEW(it),
2115 elm_widget_scale_get(WIDGET(it))
2116 * _elm_config->scale);
2117 _item_cache_add(it);
2120 _mode_item_unrealize(it);
2122 it->realized = EINA_FALSE;
2123 it->want_unrealize = EINA_FALSE;
2124 if (it->wd->edit_mode) _edit_mode_item_unrealize(it);
2128 _item_block_recalc(Item_Block *itb,
2134 Evas_Coord minw = 0, minh = 0;
2135 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2138 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2140 EINA_LIST_FOREACH(itb->items, l, it)
2142 if (it->generation < it->wd->generation) continue;
2143 showme |= it->item->showme;
2148 if (!it->item->mincalcd) changed = EINA_TRUE;
2151 _item_realize(it, in, EINA_TRUE);
2152 _elm_genlist_item_unrealize(it, EINA_TRUE);
2157 _item_realize(it, in, EINA_TRUE);
2158 _elm_genlist_item_unrealize(it, EINA_TRUE);
2162 _item_realize(it, in, EINA_FALSE);
2163 minh += it->item->minh;
2164 if (minw < it->item->minw) minw = it->item->minw;
2172 itb->changed = EINA_FALSE;
2173 itb->position_update = EINA_FALSE;
2174 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2175 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2180 _item_block_realize(Item_Block *itb)
2182 if (itb->realized) return;
2183 itb->realized = EINA_TRUE;
2184 itb->want_unrealize = EINA_FALSE;
2188 _item_block_unrealize(Item_Block *itb)
2192 Eina_Bool dragging = EINA_FALSE;
2194 if (!itb->realized) return;
2195 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2196 EINA_LIST_FOREACH(itb->items, l, it)
2198 if (itb->must_recalc || !it->group)
2202 dragging = EINA_TRUE;
2203 it->want_unrealize = EINA_TRUE;
2206 _elm_genlist_item_unrealize(it, EINA_FALSE);
2211 itb->realized = EINA_FALSE;
2212 itb->want_unrealize = EINA_TRUE;
2215 itb->want_unrealize = EINA_FALSE;
2216 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2217 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2221 _get_space_for_reorder_item(Elm_Gen_Item *it)
2223 Evas_Coord rox, roy, row, roh, oy, oh;
2224 Eina_Bool top = EINA_FALSE;
2225 Elm_Gen_Item *reorder_it = it->wd->reorder_it;
2226 if (!reorder_it) return 0;
2228 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2229 evas_object_geometry_get(it->wd->VIEW(reorder_it), &rox, &roy, &row, &roh);
2231 if ((it->wd->reorder_start_y < it->item->block->y) &&
2232 (roy - oy + (roh / 2) >= it->item->block->y - it->wd->pan_y))
2234 it->item->block->reorder_offset = it->wd->reorder_it->item->h * -1;
2235 if (it->item->block->count == 1)
2236 it->wd->reorder_rel = it;
2238 else if ((it->wd->reorder_start_y >= it->item->block->y) &&
2239 (roy - oy + (roh / 2) <= it->item->block->y - it->wd->pan_y))
2241 it->item->block->reorder_offset = it->wd->reorder_it->item->h;
2244 it->item->block->reorder_offset = 0;
2246 it->item->scrl_y += it->item->block->reorder_offset;
2248 top = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2249 rox, roy + (roh / 2), row, 1));
2252 it->wd->reorder_rel = it;
2253 it->item->scrl_y += it->wd->reorder_it->item->h;
2254 return it->wd->reorder_it->item->h;
2261 _reorder_move_animator_cb(void *data)
2263 Elm_Gen_Item *it = data;
2264 Eina_Bool down = EINA_FALSE;
2266 int y, dy = it->item->h / 10 * _elm_config->scale, diff;
2268 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2270 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2273 diff = abs(it->item->old_scrl_y - it->item->scrl_y);
2274 if (diff > it->item->h) y = diff / 2;
2276 if (it->item->old_scrl_y < it->item->scrl_y)
2278 it->item->old_scrl_y += y;
2281 else if (it->item->old_scrl_y > it->item->scrl_y)
2283 it->item->old_scrl_y -= y;
2288 _item_position(it, it->edit_obj, it->item->scrl_x, it->item->old_scrl_y);
2290 _item_position(it, VIEW(it), it->item->scrl_x, it->item->old_scrl_y);
2291 _group_items_recalc(it->wd);
2293 if ((it->wd->reorder_pan_move) ||
2294 (down && it->item->old_scrl_y >= it->item->scrl_y) ||
2295 (!down && it->item->old_scrl_y <= it->item->scrl_y))
2297 it->item->old_scrl_y = it->item->scrl_y;
2298 it->item->move_effect_enabled = EINA_FALSE;
2299 it->wd->reorder_move_animator = NULL;
2300 return ECORE_CALLBACK_CANCEL;
2302 return ECORE_CALLBACK_RENEW;
2306 _item_position(Elm_Gen_Item *it,
2314 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2315 evas_object_resize(view, it->item->w, it->item->h);
2316 evas_object_move(view, it_x, it_y);
2317 evas_object_show(view);
2318 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2319 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2323 _item_block_position(Item_Block *itb,
2329 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2330 Eina_Bool vis = EINA_FALSE;
2332 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2333 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2334 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2336 EINA_LIST_FOREACH(itb->items, l, it)
2338 if (it->generation < it->wd->generation) continue;
2339 else if (it->wd->reorder_it == it) continue;
2342 it->item->w = itb->w;
2343 it->item->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2344 it->item->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2346 vis = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2347 cvx, cvy, cvw, cvh));
2350 if ((itb->realized) && (!it->realized))
2352 if (vis) _item_realize(it, in, EINA_FALSE);
2358 if (it->wd->reorder_mode)
2359 y += _get_space_for_reorder_item(it);
2360 git = it->item->group_item;
2363 if (git->item->scrl_y < oy)
2364 git->item->scrl_y = oy;
2365 if ((git->item->scrl_y + git->item->h) > (it->item->scrl_y + it->item->h))
2366 git->item->scrl_y = (it->item->scrl_y + it->item->h) - git->item->h;
2367 git->item->want_realize = EINA_TRUE;
2369 if ((it->wd->reorder_it) && (it->item->old_scrl_y != it->item->scrl_y))
2371 if (!it->item->move_effect_enabled)
2373 it->item->move_effect_enabled = EINA_TRUE;
2374 it->wd->reorder_move_animator =
2376 _reorder_move_animator_cb, it);
2379 if (!it->item->move_effect_enabled)
2381 if ((it->wd->edit_mode) && (it->itc->edit_item_style))
2382 _edit_mode_item_position(it, it->item->scrl_x,
2386 if (it->item->mode_view)
2387 _item_position(it, it->item->mode_view,
2391 _item_position(it, VIEW(it), it->item->scrl_x,
2394 it->item->old_scrl_y = it->item->scrl_y;
2399 if (!it->dragging) _elm_genlist_item_unrealize(it, EINA_FALSE);
2406 if (vis) it->item->want_realize = EINA_TRUE;
2410 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2411 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2415 _group_items_recalc(void *data)
2417 Widget_Data *wd = data;
2421 evas_event_freeze(evas_object_evas_get(wd->obj));
2422 EINA_LIST_FOREACH(wd->group_items, l, git)
2424 if (git->item->want_realize)
2427 _item_realize(git, 0, EINA_FALSE);
2428 evas_object_resize(VIEW(git), wd->minw, git->item->h);
2429 evas_object_move(VIEW(git), git->item->scrl_x, git->item->scrl_y);
2430 evas_object_show(VIEW(git));
2431 evas_object_raise(VIEW(git));
2433 else if (!git->item->want_realize && git->realized)
2436 _elm_genlist_item_unrealize(git, EINA_FALSE);
2439 evas_event_thaw(evas_object_evas_get(wd->obj));
2440 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2444 _must_recalc_idler(void *data)
2446 Widget_Data *wd = data;
2447 if (wd->calc_job) ecore_job_del(wd->calc_job);
2448 wd->calc_job = ecore_job_add(_calc_job, wd);
2449 wd->must_recalc_idler = NULL;
2450 return ECORE_CALLBACK_CANCEL;
2454 _scroll_item(Widget_Data *wd)
2456 Elm_Gen_Item *it = NULL;
2457 Evas_Coord gith = 0;
2458 Evas_Coord ow, oh, dx = 0, dy = 0, dw = 0, dh = 0;
2460 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
2462 dx = it->x + it->item->block->x;
2463 dy = it->y + it->item->block->y;
2464 dw = it->item->block->w;
2466 switch (wd->scrollto_type)
2468 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
2469 if (it->item->group_item) gith = it->item->group_item->item->h;
2472 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
2473 dy += (it->item->h / 2 - oh / 2);
2475 case ELM_GENLIST_ITEM_SCROLLTO_IN:
2477 if ((wd->expanded_item) &&
2478 ((wd->show_item->y + wd->show_item->item->block->y + wd->show_item->item->h)
2479 - (wd->expanded_item->y + wd->expanded_item->item->block->y) > oh))
2481 it = wd->expanded_item;
2482 if (it->item->group_item) gith = it->item->group_item->item->h;
2483 dx = it->x + it->item->block->x;
2484 dy = it->y + it->item->block->y - gith;
2485 dw = it->item->block->w;
2489 if ((it->item->group_item) && (wd->pan_y > (it->y + it->item->block->y)))
2490 gith = it->item->group_item->item->h;
2497 elm_smart_scroller_region_bring_in(wd->scr, dx, dy, dw, dh);
2499 elm_smart_scroller_child_region_show(wd->scr, dx, dy, dw, dh);
2501 it->item->showme = EINA_FALSE;
2502 wd->show_item = NULL;
2503 wd->auto_scroll_enabled = EINA_FALSE;
2504 wd->check_scroll = EINA_FALSE;
2508 _calc_job(void *data)
2510 Widget_Data *wd = data;
2511 Item_Block *itb, *chb = NULL;
2512 Evas_Coord minw = -1, minh = 0, y = 0, ow, dy = 0, vw;
2513 Evas_Coord pan_w = 0, pan_h = 0;
2515 Eina_Bool minw_change = EINA_FALSE;
2516 Eina_Bool did_must_recalc = EINA_FALSE;
2519 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2520 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, NULL);
2525 evas_event_freeze(evas_object_evas_get(wd->obj));
2526 EINA_INLIST_FOREACH(wd->blocks, itb)
2528 Eina_Bool showme = EINA_FALSE;
2531 showme = itb->showme;
2532 itb->showme = EINA_FALSE;
2535 if (itb->realized) _item_block_unrealize(itb);
2537 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2539 if (itb->must_recalc)
2543 EINA_LIST_FOREACH(itb->items, l, it)
2544 if (it->item->mincalcd) it->item->mincalcd = EINA_FALSE;
2545 itb->changed = EINA_TRUE;
2546 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2547 if (itb->realized) _item_block_unrealize(itb);
2548 itb->must_recalc = EINA_FALSE;
2550 showme = _item_block_recalc(itb, in, EINA_FALSE);
2556 if (minw == -1) minw = itb->minw;
2557 else if ((!itb->must_recalc) && (minw < itb->minw))
2560 minw_change = EINA_TRUE;
2565 minw_change = EINA_TRUE;
2571 if ((showme) && (wd->show_item) && (!wd->show_item->item->queued))
2572 wd->check_scroll = EINA_TRUE;
2576 EINA_INLIST_FOREACH(wd->blocks, itb)
2582 if ((chb) && (EINA_INLIST_GET(chb)->next))
2584 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2586 if (itb->realized) _item_block_unrealize(itb);
2589 wd->realminw = minw;
2590 if (minw < wd->w) minw = wd->w;
2591 if ((minw != wd->minw) || (minh != wd->minh))
2595 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2596 _sizing_eval(wd->obj);
2597 if ((wd->anchor_item) && (wd->anchor_item->item->block) && (!wd->auto_scroll_enabled))
2602 it = wd->anchor_item;
2603 it_y = wd->anchor_y;
2604 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2605 it->item->block->y + it->y + it_y);
2606 wd->anchor_item = it;
2607 wd->anchor_y = it_y;
2610 if (did_must_recalc)
2612 if (!wd->must_recalc_idler)
2613 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2615 if (wd->check_scroll)
2617 _pan_child_size_get(wd->pan_smart, &pan_w, &pan_h);
2618 if (EINA_INLIST_GET(wd->show_item) == wd->items->last)
2619 wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
2620 switch (wd->scrollto_type)
2622 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
2625 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
2628 case ELM_GENLIST_ITEM_SCROLLTO_IN:
2633 if ((pan_w > (wd->show_item->x + wd->show_item->item->block->x)) &&
2634 (pan_h > (wd->show_item->y + wd->show_item->item->block->y + dy)))
2639 wd->calc_job = NULL;
2640 evas_object_smart_changed(wd->pan_smart);
2641 evas_event_thaw(evas_object_evas_get(wd->obj));
2642 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2646 _update_job(void *data)
2648 Widget_Data *wd = data;
2652 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2654 wd->update_job = NULL;
2657 evas_event_freeze(evas_object_evas_get(wd->obj));
2658 EINA_INLIST_FOREACH(wd->blocks, itb)
2660 Evas_Coord itminw, itminh;
2667 _item_block_position(itb, num);
2671 recalc = EINA_FALSE;
2672 EINA_LIST_FOREACH(itb->items, l2, it)
2674 if (it->item->updateme)
2676 itminw = it->item->minw;
2677 itminh = it->item->minh;
2679 it->item->updateme = EINA_FALSE;
2682 _elm_genlist_item_unrealize(it, EINA_FALSE);
2683 _item_realize(it, num, EINA_FALSE);
2684 position = EINA_TRUE;
2688 _item_realize(it, num, EINA_TRUE);
2689 _elm_genlist_item_unrealize(it, EINA_TRUE);
2691 if ((it->item->minw != itminw) || (it->item->minh != itminh))
2696 itb->updateme = EINA_FALSE;
2699 position = EINA_TRUE;
2700 itb->changed = EINA_TRUE;
2701 _item_block_recalc(itb, num0, EINA_FALSE);
2702 _item_block_position(itb, num0);
2707 if (wd->calc_job) ecore_job_del(wd->calc_job);
2708 wd->calc_job = ecore_job_add(_calc_job, wd);
2710 evas_event_thaw(evas_object_evas_get(wd->obj));
2711 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2715 _pan_set(Evas_Object *obj,
2719 Pan *sd = evas_object_smart_data_get(obj);
2723 // Evas_Coord ow, oh;
2724 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2725 // ow = sd->wd->minw - ow;
2726 // if (ow < 0) ow = 0;
2727 // oh = sd->wd->minh - oh;
2728 // if (oh < 0) oh = 0;
2729 // if (x < 0) x = 0;
2730 // if (y < 0) y = 0;
2731 // if (x > ow) x = ow;
2732 // if (y > oh) y = oh;
2733 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2737 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2739 if ((itb->y + itb->h) > y)
2744 EINA_LIST_FOREACH(itb->items, l2, it)
2746 if ((itb->y + it->y) >= y)
2748 sd->wd->anchor_item = it;
2749 sd->wd->anchor_y = -(itb->y + it->y - y);
2756 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2760 _pan_get(Evas_Object *obj,
2764 Pan *sd = evas_object_smart_data_get(obj);
2767 if (x) *x = sd->wd->pan_x;
2768 if (y) *y = sd->wd->pan_y;
2772 _pan_max_get(Evas_Object *obj,
2776 Pan *sd = evas_object_smart_data_get(obj);
2780 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2781 ow = sd->wd->minw - ow;
2783 oh = sd->wd->minh - oh;
2790 _pan_min_get(Evas_Object *obj __UNUSED__,
2799 _pan_child_size_get(Evas_Object *obj,
2803 Pan *sd = evas_object_smart_data_get(obj);
2806 if (w) *w = sd->wd->minw;
2807 if (h) *h = sd->wd->minh;
2811 _pan_add(Evas_Object *obj)
2814 Evas_Object_Smart_Clipped_Data *cd;
2817 cd = evas_object_smart_data_get(obj);
2820 sd->__clipped_data = *cd;
2822 evas_object_smart_data_set(obj, sd);
2826 _pan_del(Evas_Object *obj)
2828 Pan *sd = evas_object_smart_data_get(obj);
2833 ecore_job_del(sd->resize_job);
2834 sd->resize_job = NULL;
2840 _pan_resize_job(void *data)
2844 _sizing_eval(sd->wd->obj);
2845 sd->resize_job = NULL;
2849 _pan_resize(Evas_Object *obj,
2853 Pan *sd = evas_object_smart_data_get(obj);
2857 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2858 if ((ow == w) && (oh == h)) return;
2859 if ((sd->wd->height_for_width) && (ow != w))
2862 if (sd->resize_job) ecore_job_del(sd->resize_job);
2863 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2865 sd->wd->pan_changed = EINA_TRUE;
2866 evas_object_smart_changed(obj);
2867 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2868 sd->wd->calc_job = NULL;
2870 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2871 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2876 _pan_calculate(Evas_Object *obj)
2878 Pan *sd = evas_object_smart_data_get(obj);
2880 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2886 evas_event_freeze(evas_object_evas_get(obj));
2888 if (sd->wd->pan_changed)
2891 sd->wd->pan_changed = EINA_FALSE;
2894 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2895 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2896 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2898 git->item->want_realize = EINA_FALSE;
2900 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2902 itb->w = sd->wd->minw;
2903 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2904 itb->y - sd->wd->pan_y + oy,
2906 cvx, cvy, cvw, cvh))
2908 if ((!itb->realized) || (itb->changed))
2909 _item_block_realize(itb);
2910 _item_block_position(itb, in);
2914 if (itb->realized) _item_block_unrealize(itb);
2918 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2919 _group_items_recalc(sd->wd);
2920 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2922 if (sd->wd->pan_y != sd->wd->reorder_old_pan_y)
2923 sd->wd->reorder_pan_move = EINA_TRUE;
2924 else sd->wd->reorder_pan_move = EINA_FALSE;
2925 evas_object_raise(sd->wd->VIEW(reorder_it));
2926 sd->wd->reorder_old_pan_y = sd->wd->pan_y;
2927 sd->wd->start_time = ecore_loop_time_get();
2929 _item_auto_scroll(sd->wd);
2930 evas_event_thaw(evas_object_evas_get(obj));
2931 evas_event_thaw_eval(evas_object_evas_get(obj));
2935 _pan_move(Evas_Object *obj,
2936 Evas_Coord x __UNUSED__,
2937 Evas_Coord y __UNUSED__)
2939 Pan *sd = evas_object_smart_data_get(obj);
2943 sd->wd->pan_changed = EINA_TRUE;
2944 evas_object_smart_changed(obj);
2945 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2946 sd->wd->calc_job = NULL;
2950 _hold_on(void *data __UNUSED__,
2952 void *event_info __UNUSED__)
2954 Widget_Data *wd = elm_widget_data_get(obj);
2956 elm_smart_scroller_hold_set(wd->scr, 1);
2960 _hold_off(void *data __UNUSED__,
2962 void *event_info __UNUSED__)
2964 Widget_Data *wd = elm_widget_data_get(obj);
2966 elm_smart_scroller_hold_set(wd->scr, 0);
2970 _freeze_on(void *data __UNUSED__,
2972 void *event_info __UNUSED__)
2974 Widget_Data *wd = elm_widget_data_get(obj);
2976 elm_smart_scroller_freeze_set(wd->scr, 1);
2980 _freeze_off(void *data __UNUSED__,
2982 void *event_info __UNUSED__)
2984 Widget_Data *wd = elm_widget_data_get(obj);
2986 elm_smart_scroller_freeze_set(wd->scr, 0);
2990 _scr_anim_start(void *data,
2991 Evas_Object *obj __UNUSED__,
2992 void *event_info __UNUSED__)
2994 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
2998 _scr_anim_stop(void *data,
2999 Evas_Object *obj __UNUSED__,
3000 void *event_info __UNUSED__)
3002 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
3006 _scr_drag_start(void *data,
3007 Evas_Object *obj __UNUSED__,
3008 void *event_info __UNUSED__)
3010 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
3014 _scr_drag_stop(void *data,
3015 Evas_Object *obj __UNUSED__,
3016 void *event_info __UNUSED__)
3018 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
3022 _edge_left(void *data,
3023 Evas_Object *scr __UNUSED__,
3024 void *event_info __UNUSED__)
3026 Evas_Object *obj = data;
3027 evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
3031 _edge_right(void *data,
3032 Evas_Object *scr __UNUSED__,
3033 void *event_info __UNUSED__)
3035 Evas_Object *obj = data;
3036 evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
3040 _edge_top(void *data,
3041 Evas_Object *scr __UNUSED__,
3042 void *event_info __UNUSED__)
3044 Evas_Object *obj = data;
3045 evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
3049 _edge_bottom(void *data,
3050 Evas_Object *scr __UNUSED__,
3051 void *event_info __UNUSED__)
3053 Evas_Object *obj = data;
3054 evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
3058 _mode_item_realize(Elm_Gen_Item *it)
3062 if ((it->item->mode_view) || (it->generation < it->wd->generation)) return;
3064 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3065 it->item->mode_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
3066 edje_object_scale_set(it->item->mode_view,
3067 elm_widget_scale_get(WIDGET(it)) *
3068 _elm_config->scale);
3069 evas_object_smart_member_add(it->item->mode_view, it->wd->pan_smart);
3070 elm_widget_sub_object_add(WIDGET(it), it->item->mode_view);
3072 strncpy(buf, "item", sizeof(buf));
3073 if (it->wd->compress)
3074 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3076 if (it->item->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3077 strncat(buf, "/", sizeof(buf) - strlen(buf));
3078 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3080 _elm_theme_object_set(WIDGET(it), it->item->mode_view, "genlist", buf,
3081 elm_widget_style_get(WIDGET(it)));
3082 edje_object_mirrored_set(it->item->mode_view,
3083 elm_widget_mirrored_get(WIDGET(it)));
3085 /* signal callback add */
3086 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3088 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_UP,
3090 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3093 /* text_get, content_get, state_get */
3094 /* FIXME: If you see that assert, please notify us and we
3095 will clean our mess */
3096 assert(eina_list_count(it->item->mode_content_objs) == 0);
3098 _item_text_realize(it, it->item->mode_view, &it->item->mode_texts, NULL);
3099 it->item->mode_content_objs =
3100 _item_content_realize(it, it->item->mode_view,
3101 &it->item->mode_contents, NULL);
3102 _item_state_realize(it, it->item->mode_view, &it->item->mode_states, NULL);
3104 edje_object_part_swallow(it->item->mode_view,
3105 edje_object_data_get(it->item->mode_view, "mode_part"),
3108 it->want_unrealize = EINA_FALSE;
3109 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3110 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3114 _mode_item_unrealize(Elm_Gen_Item *it)
3116 Widget_Data *wd = it->wd;
3117 Evas_Object *content;
3118 if (!it->item->mode_view) return;
3120 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3121 elm_widget_stringlist_free(it->item->mode_texts);
3122 it->item->mode_texts = NULL;
3123 elm_widget_stringlist_free(it->item->mode_contents);
3124 it->item->mode_contents = NULL;
3125 elm_widget_stringlist_free(it->item->mode_states);
3127 EINA_LIST_FREE(it->item->mode_content_objs, content)
3128 evas_object_del(content);
3130 edje_object_part_unswallow(it->item->mode_view, VIEW(it));
3131 evas_object_smart_member_add(VIEW(it), wd->pan_smart);
3132 evas_object_del(it->item->mode_view);
3133 it->item->mode_view = NULL;
3135 if (wd->mode_item == it)
3136 wd->mode_item = NULL;
3137 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3138 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3142 _item_mode_set(Elm_Gen_Item *it)
3145 Widget_Data *wd = it->wd;
3150 it->item->nocache = EINA_TRUE;
3152 if (wd->scr_hold_timer)
3154 ecore_timer_del(wd->scr_hold_timer);
3155 wd->scr_hold_timer = NULL;
3157 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3158 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3160 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3161 _mode_item_realize(it);
3162 if (it->item->group_item)
3163 evas_object_raise(it->item->VIEW(group_item));
3164 _item_position(it, it->item->mode_view, it->item->scrl_x, it->item->scrl_y);
3165 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3166 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3168 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3169 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3173 _item_mode_unset(Widget_Data *wd)
3176 if (!wd->mode_item) return;
3177 char buf[1024], buf2[1024];
3181 it->item->nocache = EINA_TRUE;
3183 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3184 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3186 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3187 edje_object_signal_callback_add(it->item->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3189 wd->mode_item = NULL;
3193 _edit_mode_item_position(Elm_Gen_Item *it, int itx, int ity)
3195 if ((!it) || (!it->wd->edit_mode)) return;
3196 evas_object_resize(it->edit_obj, it->item->w, it->item->h);
3197 evas_object_move(it->edit_obj, itx, ity);
3201 _edit_mode_item_realize(Elm_Gen_Item *it, Eina_Bool effect_on)
3204 const char *stacking_even;
3205 const char *stacking;
3207 if ((!it) || (it->item->edit_mode_item_realized) ||
3208 (it->generation < it->wd->generation))
3211 it->edit_obj = edje_object_add(evas_object_evas_get(WIDGET(it)));
3212 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(WIDGET(it)) *
3213 _elm_config->scale);
3214 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
3215 elm_widget_sub_object_add(WIDGET(it), it->edit_obj);
3217 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS)
3218 strncpy(buf, "tree", sizeof(buf));
3219 else strncpy(buf, "item", sizeof(buf));
3220 if (it->wd->compress)
3221 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3223 strncat(buf, "/", sizeof(buf) - strlen(buf));
3224 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
3226 _elm_theme_object_set(WIDGET(it), it->edit_obj, "genlist", buf,
3227 elm_widget_style_get(WIDGET(it)));
3229 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
3230 if (!stacking_even) stacking_even = "above";
3231 it->item->stacking_even = !!strcmp("above", stacking_even);
3233 stacking = edje_object_data_get(VIEW(it), "stacking");
3234 if (!stacking) stacking = "yes";
3235 it->item->nostacking = !!strcmp("yes", stacking);
3237 edje_object_mirrored_set(it->edit_obj,
3238 elm_widget_mirrored_get(WIDGET(it)));
3240 _elm_genlist_item_odd_even_update(it);
3241 _elm_genlist_item_state_update(it, NULL);
3243 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,edit,enabled,effect", "elm");
3244 else edje_object_signal_emit(it->edit_obj, "elm,state,edit,enabled", "elm");
3246 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
3248 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
3250 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
3252 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_DOWN,
3254 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_UP,
3256 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_MOVE,
3259 _item_text_realize(it, it->edit_obj, &it->item->edit_texts, NULL);
3260 it->item->edit_content_objs =
3261 _item_content_realize(it, it->edit_obj, &it->item->edit_contents, NULL);
3262 _item_state_realize(it, it->edit_obj, &it->item->edit_states, NULL);
3263 edje_object_part_swallow(it->edit_obj, "elm.swallow.edit.content", VIEW(it));
3265 _edit_mode_item_position(it, it->item->scrl_x, it->item->scrl_y);
3266 evas_object_show(it->edit_obj);
3268 it->item->edit_mode_item_realized = EINA_TRUE;
3269 it->want_unrealize = EINA_FALSE;
3273 _edit_mode_item_unrealize(Elm_Gen_Item *it)
3276 if ((!it) || (!it->item->edit_mode_item_realized)) return;
3278 edje_object_part_unswallow(it->edit_obj, VIEW(it));
3279 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
3280 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
3281 _elm_genlist_item_odd_even_update(it);
3282 _elm_genlist_item_state_update(it, NULL);
3284 evas_object_del(it->edit_obj);
3285 it->edit_obj = NULL;
3286 elm_widget_stringlist_free(it->item->edit_texts);
3287 it->item->edit_texts = NULL;
3288 elm_widget_stringlist_free(it->item->edit_contents);
3289 it->item->edit_contents = NULL;
3290 elm_widget_stringlist_free(it->item->edit_states);
3291 it->item->edit_states = NULL;
3292 EINA_LIST_FREE(it->item->edit_content_objs, icon)
3293 evas_object_del(icon);
3294 edje_object_message_signal_process(it->edit_obj);
3296 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
3298 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
3300 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
3302 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_DOWN,
3304 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_UP,
3306 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_MOVE,
3308 it->item->edit_mode_item_realized = EINA_FALSE;
3312 _item_auto_scroll(Widget_Data *wd)
3315 Elm_Gen_Item *tmp_item = NULL;
3317 if ((wd->expanded_item) && (wd->auto_scroll_enabled))
3319 tmp_item = eina_list_data_get(eina_list_last(wd->expanded_item->item->items));
3320 if (!tmp_item) return;
3321 wd->show_item = tmp_item;
3322 wd->bring_in = EINA_TRUE;
3323 wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
3324 if ((wd->show_item->item->queued) || (!wd->show_item->item->mincalcd))
3326 wd->show_item->item->showme = EINA_TRUE;
3327 wd->auto_scroll_enabled = EINA_FALSE;
3335 elm_genlist_add(Evas_Object *parent)
3340 Evas_Coord minw, minh;
3341 static Evas_Smart *smart = NULL;
3345 static Evas_Smart_Class sc;
3347 evas_object_smart_clipped_smart_set(&_pan_sc);
3349 sc.name = "elm_genlist_pan";
3350 sc.version = EVAS_SMART_CLASS_VERSION;
3353 sc.resize = _pan_resize;
3354 sc.move = _pan_move;
3355 sc.calculate = _pan_calculate;
3356 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3359 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3361 ELM_SET_WIDTYPE(widtype, "genlist");
3363 elm_widget_type_set(obj, "genlist");
3364 elm_widget_sub_object_add(parent, obj);
3365 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3366 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3367 elm_widget_data_set(obj, wd);
3368 elm_widget_del_hook_set(obj, _del_hook);
3369 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3370 elm_widget_theme_hook_set(obj, _theme_hook);
3371 elm_widget_can_focus_set(obj, EINA_TRUE);
3372 elm_widget_event_hook_set(obj, _event_hook);
3373 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3374 elm_widget_translate_hook_set(obj, _translate_hook);
3377 wd->scr = elm_smart_scroller_add(e);
3378 elm_smart_scroller_widget_set(wd->scr, obj);
3379 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3380 elm_widget_style_get(obj));
3381 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3382 _elm_config->thumbscroll_bounce_enable);
3383 elm_widget_resize_object_set(obj, wd->scr);
3385 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3386 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3387 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3388 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3389 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
3390 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
3391 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
3392 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
3395 wd->mode = ELM_LIST_SCROLL;
3396 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3397 wd->item_cache_max = wd->max_items_per_block * 2;
3398 wd->longpress_timeout = _elm_config->longpress_timeout;
3400 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3401 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3402 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3403 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3405 wd->pan_smart = evas_object_smart_add(e, smart);
3406 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3409 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3410 _pan_set, _pan_get, _pan_max_get,
3411 _pan_min_get, _pan_child_size_get);
3413 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3415 evas_object_size_hint_min_set(obj, minw, minh);
3417 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3419 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3425 _item_select(Elm_Gen_Item *it)
3427 if ((it->wd->no_select) || (it->generation < it->wd->generation) || (it->mode_set)) return;
3430 it->selected = EINA_TRUE;
3431 it->wd->selected = eina_list_append(it->wd->selected, it);
3433 else if (!it->wd->always_select) return;
3435 evas_object_ref(WIDGET(it));
3438 if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), it);
3439 if (it->generation == it->wd->generation)
3440 evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
3443 evas_object_unref(WIDGET(it));
3444 if ((it->wd->clear_me) && (!it->wd->walking))
3445 _elm_genlist_clear(WIDGET(it), EINA_TRUE);
3448 if ((!it->walking) && (it->generation < it->wd->generation))
3453 elm_widget_item_free(it);
3457 it->wd->last_selected_item = (Elm_Object_Item *) it;
3461 static Evas_Object *
3462 _item_content_get_hook(Elm_Gen_Item *it, const char *part)
3464 return edje_object_part_swallow_get(VIEW(it), part);
3468 _item_content_set_hook(Elm_Gen_Item *it, const char *part, Evas_Object *content)
3470 if (content && part)
3472 it->content_objs = eina_list_append(it->content_objs, content);
3473 edje_object_part_swallow(VIEW(it), part, content);
3477 static Evas_Object *
3478 _item_content_unset_hook(Elm_Gen_Item *it, const char *part)
3481 obj = edje_object_part_swallow_get(VIEW(it), part);
3482 if (!obj) return NULL;
3483 it->content_objs = eina_list_remove(it->content_objs, obj);
3484 edje_object_part_unswallow(VIEW(it), obj);
3489 _item_text_hook(Elm_Gen_Item *it, const char *part)
3491 if (!it->itc->func.text_get) return NULL;
3492 return edje_object_part_text_get(VIEW(it), part);
3496 _item_disable_hook(Elm_Object_Item *it)
3500 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
3502 if (_it->generation < _it->wd->generation) return;
3505 elm_genlist_item_selected_set(it, EINA_FALSE);
3509 if (elm_widget_item_disabled_get(it))
3511 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
3513 edje_object_signal_emit(_it->edit_obj, "elm,state,disabled", "elm");
3517 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
3519 edje_object_signal_emit(_it->edit_obj, "elm,state,enabled", "elm");
3521 EINA_LIST_FOREACH(_it->content_objs, l, obj)
3522 elm_widget_disabled_set(obj, elm_widget_item_disabled_get(_it));
3527 _item_del_pre_hook(Elm_Object_Item *it)
3529 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
3531 if ((_it->relcount > 0) || (_it->walking > 0))
3533 elm_genlist_item_subitems_clear(it);
3534 if (_it->wd->show_item == _it) _it->wd->show_item = NULL;
3535 _elm_genlist_item_del_notserious(_it);
3536 if (_it->item->block)
3538 if (_it->realized) _elm_genlist_item_unrealize(_it, EINA_FALSE);
3539 _it->item->block->changed = EINA_TRUE;
3540 if (_it->wd->calc_job) ecore_job_del(_it->wd->calc_job);
3541 _it->wd->calc_job = ecore_job_add(_calc_job, _it->wd);
3545 _it->parent->item->items =
3546 eina_list_remove(_it->parent->item->items, it);
3556 _elm_genlist_item_new(Widget_Data *wd,
3557 const Elm_Gen_Item_Class *itc,
3559 Elm_Gen_Item *parent,
3561 const void *func_data)
3565 it = elm_widget_item_new(wd->obj, Elm_Gen_Item);
3566 if (!it) return NULL;
3568 it->generation = wd->generation;
3570 elm_genlist_item_class_ref((Elm_Genlist_Item_Class *)itc);
3571 it->base.data = data;
3572 it->parent = parent;
3573 it->func.func = func;
3574 it->func.data = func_data;
3575 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
3576 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
3577 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
3578 elm_widget_item_text_get_hook_set(it, _item_text_hook);
3579 elm_widget_item_disable_hook_set(it, _item_disable_hook);
3580 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
3582 it->sel_cb = (Ecore_Cb)_item_select;
3587 static Elm_Gen_Item *
3588 _item_new(Widget_Data *wd,
3589 const Elm_Genlist_Item_Class *itc,
3591 Elm_Gen_Item *parent,
3592 Elm_Genlist_Item_Flags flags,
3594 const void *func_data)
3596 Elm_Gen_Item *it, *it2;
3599 it = _elm_genlist_item_new(wd, itc, data, parent, func, func_data);
3600 if (!it) return NULL;
3601 it->item = ELM_NEW(Elm_Gen_Item_Type);
3602 it->item->flags = flags;
3603 if (flags & ELM_GENLIST_ITEM_GROUP) it->group++;
3604 it->item->expanded_depth = 0;
3605 ELM_GEN_ITEM_SETUP(it);
3608 if (it->parent->group)
3609 it->item->group_item = parent;
3610 else if (it->parent->item->group_item)
3611 it->item->group_item = it->parent->item->group_item;
3613 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
3615 if (!it2->parent->group) depth += 1;
3617 it->item->expanded_depth = depth;
3623 _item_block_new(Widget_Data *wd, Eina_Bool prepend)
3627 itb = calloc(1, sizeof(Item_Block));
3628 if (!itb) return NULL;
3632 wd->blocks = eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3633 _item_block_position_update(wd->blocks, 0);
3637 wd->blocks = eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3638 itb->position_update = EINA_TRUE;
3639 if (wd->blocks != EINA_INLIST_GET(itb))
3641 itb->position = ((Item_Block *) (EINA_INLIST_GET(itb)->prev))->position + 1;
3652 _item_block_add(Widget_Data *wd,
3655 Item_Block *itb = NULL;
3662 itb = calloc(1, sizeof(Item_Block));
3663 if (!itb) return EINA_FALSE;
3665 if (!it->item->rel->item->block)
3668 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3669 itb->items = eina_list_append(itb->items, it);
3670 itb->position_update = EINA_TRUE;
3671 it->position = eina_list_count(itb->items);
3672 it->position_update = EINA_TRUE;
3674 if (wd->blocks != EINA_INLIST_GET(itb))
3676 itb->position = ((Item_Block *) (EINA_INLIST_GET(itb)->prev))->position + 1;
3687 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3688 if (it->item->before)
3690 wd->blocks = eina_inlist_prepend_relative
3691 (wd->blocks, EINA_INLIST_GET(itb),
3692 EINA_INLIST_GET(it->item->rel->item->block));
3694 eina_list_prepend_relative_list(itb->items, it, tmp);
3696 /* Update index from where we prepended */
3697 _item_position_update(eina_list_prev(tmp), it->item->rel->position);
3698 _item_block_position_update(EINA_INLIST_GET(itb),
3699 it->item->rel->item->block->position);
3703 wd->blocks = eina_inlist_append_relative
3704 (wd->blocks, EINA_INLIST_GET(itb),
3705 EINA_INLIST_GET(it->item->rel->item->block));
3707 eina_list_append_relative_list(itb->items, it, tmp);
3709 /* Update block index from where we appended */
3710 _item_position_update(eina_list_next(tmp), it->item->rel->position + 1);
3711 _item_block_position_update(EINA_INLIST_GET(itb),
3712 it->item->rel->item->block->position + 1);
3718 if (it->item->before)
3722 itb = (Item_Block *)(wd->blocks);
3723 if (itb->count >= wd->max_items_per_block)
3725 itb = _item_block_new(wd, EINA_TRUE);
3726 if (!itb) return EINA_FALSE;
3731 itb = _item_block_new(wd, EINA_TRUE);
3732 if (!itb) return EINA_FALSE;
3734 itb->items = eina_list_prepend(itb->items, it);
3736 _item_position_update(itb->items, 0);
3742 itb = (Item_Block *)(wd->blocks->last);
3743 if (itb->count >= wd->max_items_per_block)
3745 itb = _item_block_new(wd, EINA_FALSE);
3746 if (!itb) return EINA_FALSE;
3751 itb = _item_block_new(wd, EINA_FALSE);
3752 if (!itb) return EINA_FALSE;
3754 itb->items = eina_list_append(itb->items, it);
3755 it->position = eina_list_count(itb->items);
3763 if (it->item->rel->item->queued)
3765 /* NOTE: for a strange reason eina_list and eina_inlist don't have the same property
3766 on sorted insertion order, so the queue is not always ordered like the item list.
3767 This lead to issue where we depend on an item that is not yet created. As a quick
3768 work around, we reschedule the calc of the item and stop reordering the list to
3769 prevent any nasty issue to show up here.
3771 wd->queue = eina_list_append(wd->queue, it);
3772 wd->requeued = EINA_TRUE;
3773 it->item->queued = EINA_TRUE;
3776 itb = it->item->rel->item->block;
3777 if (!itb) goto newblock;
3778 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3779 if (it->item->before)
3781 itb->items = eina_list_prepend_relative_list(itb->items, it, tmp);
3782 _item_position_update(eina_list_prev(tmp), it->item->rel->position);
3786 itb->items = eina_list_append_relative_list(itb->items, it, tmp);
3787 _item_position_update(eina_list_next(tmp), it->item->rel->position + 1);
3791 itb->changed = EINA_TRUE;
3792 it->item->block = itb;
3793 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3794 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3797 it->item->rel->relcount--;
3798 if ((it->item->rel->generation < it->wd->generation) && (!it->item->rel->relcount))
3800 _item_del(it->item->rel);
3801 elm_widget_item_free(it->item->rel);
3803 it->item->rel = NULL;
3805 if (itb->count > itb->wd->max_items_per_block)
3810 Eina_Bool done = EINA_FALSE;
3812 newc = itb->count / 2;
3814 if (EINA_INLIST_GET(itb)->prev)
3816 Item_Block *itbp = (Item_Block *)(EINA_INLIST_GET(itb)->prev);
3818 if (itbp->count + newc < wd->max_items_per_block / 2)
3820 /* moving items to previous block */
3821 while ((itb->count > newc) && (itb->items))
3823 it2 = eina_list_data_get(itb->items);
3824 itb->items = eina_list_remove_list(itb->items, itb->items);
3827 itbp->items = eina_list_append(itbp->items, it2);
3828 it2->item->block = itbp;
3836 if (!done && EINA_INLIST_GET(itb)->next)
3838 Item_Block *itbn = (Item_Block *)(EINA_INLIST_GET(itb)->next);
3840 if (itbn->count + newc < wd->max_items_per_block / 2)
3842 /* moving items to next block */
3843 while ((itb->count > newc) && (itb->items))
3847 l = eina_list_last(itb->items);
3848 it2 = eina_list_data_get(l);
3849 itb->items = eina_list_remove_list(itb->items, l);
3852 itbn->items = eina_list_prepend(itbn->items, it2);
3853 it2->item->block = itbn;
3863 /* moving items to new block */
3864 itb2 = calloc(1, sizeof(Item_Block));
3865 if (!itb2) return EINA_FALSE;
3868 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3869 EINA_INLIST_GET(itb));
3870 itb2->changed = EINA_TRUE;
3871 while ((itb->count > newc) && (itb->items))
3875 l = eina_list_last(itb->items);
3877 itb->items = eina_list_remove_list(itb->items, l);
3880 itb2->items = eina_list_prepend(itb2->items, it2);
3881 it2->item->block = itb2;
3891 _queue_process(Widget_Data *wd)
3894 Eina_Bool showme = EINA_FALSE;
3897 t0 = ecore_loop_time_get();
3898 //evas_event_freeze(evas_object_evas_get(wd->obj));
3899 for (n = 0; (wd->queue) && (n < 128); n++)
3903 it = eina_list_data_get(wd->queue);
3904 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3905 it->item->queued = EINA_FALSE;
3906 if (!_item_block_add(wd, it)) continue;
3908 _item_block_realize(it->item->block);
3909 t = ecore_time_get();
3910 if (it->item->block->changed)
3912 showme = _item_block_recalc(it->item->block, it->item->block->num, EINA_TRUE);
3913 it->item->block->changed = 0;
3914 if (wd->pan_changed)
3916 if (wd->calc_job) ecore_job_del(wd->calc_job);
3917 wd->calc_job = NULL;
3919 wd->pan_changed = EINA_FALSE;
3922 if (showme) it->item->block->showme = EINA_TRUE;
3923 /* same as eina_inlist_count > 1 */
3924 if (wd->blocks && wd->blocks->next)
3926 if ((t - t0) > (ecore_animator_frametime_get())) break;
3929 //evas_event_thaw(evas_object_evas_get(wd->obj));
3930 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3935 _idle_process(void *data, Eina_Bool *wakeup)
3937 Widget_Data *wd = data;
3940 //static double q_start = 0.0;
3941 //if (q_start == 0.0) q_start = ecore_time_get();
3943 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3947 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3949 return ECORE_CALLBACK_CANCEL;
3951 return ECORE_CALLBACK_RENEW;
3955 _item_idle_enterer(void *data)
3957 Widget_Data *wd = data;
3958 Eina_Bool wakeup = EINA_FALSE;
3959 Eina_Bool ok = _idle_process(data, &wakeup);
3964 if (wd->calc_job) ecore_job_del(wd->calc_job);
3965 wd->calc_job = ecore_job_add(_calc_job, wd);
3967 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3972 _item_queue(Widget_Data *wd,
3976 if (it->item->queued) return;
3977 it->item->queued = EINA_TRUE;
3978 if (cb && !wd->requeued)
3979 wd->queue = eina_list_sorted_insert(wd->queue, cb, it);
3981 wd->queue = eina_list_append(wd->queue, it);
3982 // FIXME: why does a freeze then thaw here cause some genlist
3983 // elm_genlist_item_append() to be much much slower?
3984 // evas_event_freeze(evas_object_evas_get(wd->obj));
3985 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3987 if (wd->queue_idle_enterer)
3989 ecore_idle_enterer_del(wd->queue_idle_enterer);
3990 wd->queue_idle_enterer = NULL;
3994 // evas_event_thaw(evas_object_evas_get(wd->obj));
3995 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3996 if (!wd->queue_idle_enterer)
3997 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
4001 _elm_genlist_item_compare(const void *data, const void *data1)
4003 const Elm_Gen_Item *it, *item1;
4004 it = ELM_GEN_ITEM_FROM_INLIST(data);
4005 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
4006 return it->wd->item_compare_cb(it, item1);
4010 _elm_genlist_item_list_compare(const void *data, const void *data1)
4012 const Elm_Gen_Item *it = data;
4013 const Elm_Gen_Item *item1 = data1;
4014 return it->wd->item_compare_cb(it, item1);
4018 _item_move_after(Elm_Gen_Item *it, Elm_Gen_Item *after)
4023 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4024 _item_block_del(it);
4026 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
4027 it->item->rel = after;
4028 it->item->rel->relcount++;
4029 it->item->before = EINA_FALSE;
4030 if (after->item->group_item) it->item->group_item = after->item->group_item;
4031 _item_queue(it->wd, it, NULL);
4033 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
4037 _item_move_before(Elm_Gen_Item *it, Elm_Gen_Item *before)
4040 if (!before) return;
4042 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4043 _item_block_del(it);
4044 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
4045 it->item->rel = before;
4046 it->item->rel->relcount++;
4047 it->item->before = EINA_TRUE;
4048 if (before->item->group_item) it->item->group_item = before->item->group_item;
4049 _item_queue(it->wd, it, NULL);
4051 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
4055 elm_genlist_items_count(const Evas_Object *obj)
4057 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4058 Widget_Data *wd = elm_widget_data_get(obj);
4060 return wd->item_count;
4063 EAPI Elm_Object_Item *
4064 elm_genlist_item_append(Evas_Object *obj,
4065 const Elm_Genlist_Item_Class *itc,
4067 Elm_Object_Item *parent,
4068 Elm_Genlist_Item_Flags flags,
4070 const void *func_data)
4072 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4073 Widget_Data *wd = elm_widget_data_get(obj);
4074 if (!wd) return NULL;
4075 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, flags,
4077 if (!it) return NULL;
4081 wd->group_items = eina_list_append(wd->group_items, it);
4082 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
4083 it->item->rel = NULL;
4087 Elm_Gen_Item *it2 = NULL;
4088 Eina_List *ll = eina_list_last(it->parent->item->items);
4089 if (ll) it2 = ll->data;
4090 it->parent->item->items = eina_list_append(it->parent->item->items, it);
4091 if (!it2) it2 = it->parent;
4093 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
4094 EINA_INLIST_GET(it2));
4095 it->item->rel = it2;
4096 it->item->rel->relcount++;
4098 it->item->before = EINA_FALSE;
4099 _item_queue(wd, it, NULL);
4100 return (Elm_Object_Item *) it;
4103 EAPI Elm_Object_Item *
4104 elm_genlist_item_prepend(Evas_Object *obj,
4105 const Elm_Genlist_Item_Class *itc,
4107 Elm_Object_Item *parent,
4108 Elm_Genlist_Item_Flags flags,
4110 const void *func_data)
4112 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4113 Widget_Data *wd = elm_widget_data_get(obj);
4114 if (!wd) return NULL;
4115 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, flags,
4117 if (!it) return NULL;
4121 wd->group_items = eina_list_prepend(wd->group_items, it);
4122 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
4123 it->item->rel = NULL;
4127 Elm_Gen_Item *it2 = NULL;
4128 Eina_List *ll = it->parent->item->items;
4129 if (ll) it2 = ll->data;
4130 it->parent->item->items = eina_list_prepend(it->parent->item->items, it);
4131 if (!it2) it2 = it->parent;
4133 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4134 EINA_INLIST_GET(it2));
4135 it->item->rel = it2;
4136 it->item->rel->relcount++;
4138 it->item->before = EINA_TRUE;
4139 _item_queue(wd, it, NULL);
4140 return (Elm_Object_Item *) it;
4143 EAPI Elm_Object_Item *
4144 elm_genlist_item_insert_after(Evas_Object *obj,
4145 const Elm_Genlist_Item_Class *itc,
4147 Elm_Object_Item *parent,
4148 Elm_Object_Item *after,
4149 Elm_Genlist_Item_Flags flags,
4151 const void *func_data)
4153 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4154 ELM_OBJ_ITEM_CHECK_OR_RETURN(after, NULL);
4155 Widget_Data *wd = elm_widget_data_get(obj);
4156 Elm_Gen_Item *_after = (Elm_Gen_Item *) after;
4157 if (!wd) return NULL;
4158 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
4159 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4161 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, flags,
4163 if (!it) return NULL;
4166 if ((it->group) && (_after->group))
4167 wd->group_items = eina_list_append_relative(wd->group_items, it,
4172 it->parent->item->items =
4173 eina_list_append_relative(it->parent->item->items, it, _after);
4175 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
4176 EINA_INLIST_GET(_after));
4177 it->item->rel = _after;
4178 it->item->rel->relcount++;
4179 it->item->before = EINA_FALSE;
4180 _item_queue(wd, it, NULL);
4181 return (Elm_Object_Item *) it;
4184 EAPI Elm_Object_Item *
4185 elm_genlist_item_insert_before(Evas_Object *obj,
4186 const Elm_Genlist_Item_Class *itc,
4188 Elm_Object_Item *parent,
4189 Elm_Object_Item *before,
4190 Elm_Genlist_Item_Flags flags,
4192 const void *func_data)
4194 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4195 ELM_OBJ_ITEM_CHECK_OR_RETURN(before, NULL);
4196 Widget_Data *wd = elm_widget_data_get(obj);
4197 Elm_Gen_Item *_before = (Elm_Gen_Item *) before;
4198 if (!wd) return NULL;
4199 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
4200 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4202 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, flags,
4204 if (!it) return NULL;
4207 if (it->group && _before->group)
4208 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
4213 it->parent->item->items =
4214 eina_list_prepend_relative(it->parent->item->items, it, _before);
4216 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4217 EINA_INLIST_GET(_before));
4218 it->item->rel = _before;
4219 it->item->rel->relcount++;
4220 it->item->before = EINA_TRUE;
4221 _item_queue(wd, it, NULL);
4222 return (Elm_Object_Item *) it;
4225 EAPI Elm_Object_Item *
4226 elm_genlist_item_sorted_insert(Evas_Object *obj,
4227 const Elm_Genlist_Item_Class *itc,
4229 Elm_Object_Item *parent,
4230 Elm_Genlist_Item_Flags flags,
4231 Eina_Compare_Cb comp,
4233 const void *func_data)
4235 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4236 Widget_Data *wd = elm_widget_data_get(obj);
4237 if (!wd) return NULL;
4238 Elm_Gen_Item *rel = NULL;
4239 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, flags,
4241 if (!it) return NULL;
4243 wd->item_compare_cb = comp;
4250 l = eina_list_search_sorted_near_list(it->parent->item->items,
4251 _elm_genlist_item_list_compare,
4255 rel = eina_list_data_get(l);
4259 if (cmp_result >= 0)
4261 it->parent->item->items = eina_list_prepend_relative_list(it->parent->item->items, it, l);
4262 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
4263 it->item->before = EINA_FALSE;
4265 else if (cmp_result < 0)
4267 it->parent->item->items = eina_list_append_relative_list(it->parent->item->items, it, l);
4268 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
4269 it->item->before = EINA_TRUE;
4276 wd->state = eina_inlist_sorted_state_new();
4277 eina_inlist_sorted_state_init(wd->state, wd->items);
4278 wd->requeued = EINA_FALSE;
4282 wd->group_items = eina_list_append(wd->group_items, it);
4284 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
4285 _elm_genlist_item_compare, wd->state);
4287 if (EINA_INLIST_GET(it)->next)
4289 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4290 it->item->before = EINA_TRUE;
4292 else if (EINA_INLIST_GET(it)->prev)
4294 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4295 it->item->before = EINA_FALSE;
4301 it->item->rel = rel;
4302 it->item->rel->relcount++;
4305 _item_queue(wd, it, _elm_genlist_item_list_compare);
4307 return (Elm_Object_Item *) it;
4311 _elm_genlist_clear(Evas_Object *obj, Eina_Bool standby)
4313 Eina_Inlist *next, *l;
4315 ELM_CHECK_WIDTYPE(obj, widtype);
4316 Widget_Data *wd = elm_widget_data_get(obj);
4319 if (!standby) wd->generation++;
4323 eina_inlist_sorted_state_free(wd->state);
4327 if (wd->walking > 0)
4329 wd->clear_me = EINA_TRUE;
4332 evas_event_freeze(evas_object_evas_get(wd->obj));
4333 for (l = wd->items, next = l ? l->next : NULL;
4335 l = next, next = next ? next->next : NULL)
4337 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(l);
4339 if (it->generation < wd->generation)
4341 Elm_Gen_Item *itn = NULL;
4343 if (next) itn = ELM_GEN_ITEM_FROM_INLIST(next);
4344 if (itn) itn->walking++; /* prevent early death of subitem */
4346 elm_widget_item_free(it);
4347 if (itn) itn->walking--;
4350 wd->clear_me = EINA_FALSE;
4351 wd->pan_changed = EINA_TRUE;
4354 ecore_job_del(wd->calc_job);
4355 wd->calc_job = NULL;
4357 if (wd->selected) wd->selected = eina_list_free(wd->selected);
4358 if (wd->clear_cb) wd->clear_cb(wd);
4365 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4366 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4368 if (wd->sizing_cb) wd->sizing_cb(wd->obj);
4369 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
4370 evas_event_thaw(evas_object_evas_get(wd->obj));
4371 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4375 elm_genlist_clear(Evas_Object *obj)
4377 _elm_genlist_clear(obj, EINA_FALSE);
4381 elm_genlist_multi_select_set(Evas_Object *obj,
4384 ELM_CHECK_WIDTYPE(obj, widtype);
4385 Widget_Data *wd = elm_widget_data_get(obj);
4387 wd->multi = !!multi;
4391 elm_genlist_multi_select_get(const Evas_Object *obj)
4393 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4394 Widget_Data *wd = elm_widget_data_get(obj);
4395 if (!wd) return EINA_FALSE;
4399 EAPI Elm_Object_Item *
4400 elm_genlist_selected_item_get(const Evas_Object *obj)
4402 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4403 Widget_Data *wd = elm_widget_data_get(obj);
4404 if (!wd) return NULL;
4405 if (wd->selected) return wd->selected->data;
4409 EAPI const Eina_List *
4410 elm_genlist_selected_items_get(const Evas_Object *obj)
4412 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4413 Widget_Data *wd = elm_widget_data_get(obj);
4414 if (!wd) return NULL;
4415 return wd->selected;
4419 elm_genlist_realized_items_get(const Evas_Object *obj)
4421 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4422 Widget_Data *wd = elm_widget_data_get(obj);
4423 Eina_List *list = NULL;
4425 Eina_Bool done = EINA_FALSE;
4426 if (!wd) return NULL;
4427 EINA_INLIST_FOREACH(wd->blocks, itb)
4435 EINA_LIST_FOREACH(itb->items, l, it)
4437 if (it->realized) list = eina_list_append(list, it);
4448 EAPI Elm_Object_Item *
4449 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4454 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4455 Widget_Data *wd = elm_widget_data_get(obj);
4456 Evas_Coord ox, oy, ow, oh;
4459 if (!wd) return NULL;
4460 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4462 EINA_INLIST_FOREACH(wd->blocks, itb)
4467 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4468 oy + itb->y - itb->wd->pan_y,
4469 itb->w, itb->h, x, y, 1, 1))
4471 EINA_LIST_FOREACH(itb->items, l, it)
4473 Evas_Coord itx, ity;
4475 itx = ox + itb->x + it->x - itb->wd->pan_x;
4476 ity = oy + itb->y + it->y - itb->wd->pan_y;
4477 if (ELM_RECTS_INTERSECT(itx, ity, it->item->w, it->item->h, x, y, 1, 1))
4481 if (y <= (ity + (it->item->h / 4))) *posret = -1;
4482 else if (y >= (ity + it->item->h - (it->item->h / 4)))
4486 return (Elm_Object_Item *) it;
4488 lasty = ity + it->item->h;
4493 if (y > lasty) *posret = 1;
4499 EAPI Elm_Object_Item *
4500 elm_genlist_first_item_get(const Evas_Object *obj)
4502 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4503 Widget_Data *wd = elm_widget_data_get(obj);
4504 if (!wd) return NULL;
4505 if (!wd->items) return NULL;
4506 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
4507 while ((it) && (it->generation < wd->generation))
4508 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4509 return (Elm_Object_Item *) it;
4512 EAPI Elm_Object_Item *
4513 elm_genlist_last_item_get(const Evas_Object *obj)
4515 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4516 Widget_Data *wd = elm_widget_data_get(obj);
4517 if (!wd) return NULL;
4518 if (!wd->items) return NULL;
4519 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
4520 while ((it) && (it->generation < wd->generation))
4521 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4522 return (Elm_Object_Item *) it;
4525 EAPI Elm_Object_Item *
4526 elm_genlist_item_next_get(const Elm_Object_Item *it)
4528 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4529 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4532 _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->next);
4533 if ((_it) && (_it->generation == _it->wd->generation)) break;
4535 return (Elm_Object_Item *) _it;
4538 EAPI Elm_Object_Item *
4539 elm_genlist_item_prev_get(const Elm_Object_Item *it)
4541 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4542 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4545 _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->prev);
4546 if ((_it) && (_it->generation == _it->wd->generation)) break;
4548 return (Elm_Object_Item *) _it;
4551 EINA_DEPRECATED EAPI Evas_Object *
4552 elm_genlist_item_genlist_get(const Elm_Object_Item *it)
4554 return elm_object_item_widget_get(it);
4557 EAPI Elm_Object_Item *
4558 elm_genlist_item_parent_get(const Elm_Object_Item *it)
4560 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4561 return (Elm_Object_Item *) ((Elm_Gen_Item *) it)->parent;
4565 elm_genlist_item_subitems_clear(Elm_Object_Item *it)
4567 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4568 Eina_List *tl = NULL, *l;
4570 Elm_Object_Item *it2;
4571 _it = (Elm_Gen_Item *) it;
4573 EINA_LIST_FOREACH(_it->item->items, l, it2)
4574 tl = eina_list_append(tl, it2);
4575 EINA_LIST_FREE(tl, it2)
4576 elm_object_item_del(it2);
4580 elm_genlist_item_selected_set(Elm_Object_Item *it,
4583 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4584 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4585 Widget_Data *wd = _it->wd;
4587 if ((_it->generation < wd->generation) || elm_widget_item_disabled_get(_it))
4589 selected = !!selected;
4590 if (_it->selected == selected) return;
4596 while (wd->selected)
4598 if (_it->unhighlight_cb) _it->unhighlight_cb(wd->selected->data);
4599 _it->unsel_cb(wd->selected->data);
4602 _it->highlight_cb(_it);
4606 if (_it->unhighlight_cb) _it->unhighlight_cb(_it);
4611 elm_genlist_item_selected_get(const Elm_Object_Item *it)
4613 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4614 return ((Elm_Gen_Item *) it)->selected;
4618 elm_genlist_item_expanded_set(Elm_Object_Item *it,
4621 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4622 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4623 expanded = !!expanded;
4624 if (_it->item->expanded == expanded) return;
4625 _it->item->expanded = expanded;
4626 if (_it->item->expanded)
4629 edje_object_signal_emit(VIEW(_it), "elm,state,expanded", "elm");
4630 evas_object_smart_callback_call(WIDGET(_it), SIG_EXPANDED, _it);
4631 _it->wd->auto_scroll_enabled = EINA_TRUE;
4632 _it->wd->expanded_item = _it;
4637 edje_object_signal_emit(VIEW(_it), "elm,state,contracted", "elm");
4638 evas_object_smart_callback_call(WIDGET(_it), SIG_CONTRACTED, _it);
4639 _it->wd->auto_scroll_enabled = EINA_FALSE;
4640 _it->wd->expanded_item = NULL;
4645 elm_genlist_item_expanded_get(const Elm_Object_Item *it)
4647 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4648 return ((Elm_Gen_Item *) it)->item->expanded;
4652 elm_genlist_item_expanded_depth_get(const Elm_Object_Item *it)
4654 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, 0);
4655 return ((Elm_Gen_Item *) it)->item->expanded_depth;
4658 EINA_DEPRECATED EAPI void
4659 elm_genlist_item_disabled_set(Elm_Object_Item *it,
4662 elm_object_item_disabled_set(it, disabled);
4665 EINA_DEPRECATED EAPI Eina_Bool
4666 elm_genlist_item_disabled_get(const Elm_Object_Item *it)
4668 return elm_object_item_disabled_get(it);
4672 elm_genlist_item_display_only_set(Elm_Object_Item *it,
4673 Eina_Bool display_only)
4675 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4676 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4677 display_only = !!display_only;
4678 if (_it->display_only == display_only) return;
4679 if (_it->generation < _it->wd->generation) return;
4680 _it->display_only = display_only;
4681 _it->item->mincalcd = EINA_FALSE;
4682 _it->item->updateme = EINA_TRUE;
4683 if (_it->item->block) _it->item->block->updateme = EINA_TRUE;
4684 if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
4685 _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
4689 elm_genlist_item_display_only_get(const Elm_Object_Item *it)
4691 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4692 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4693 if (_it->generation < _it->wd->generation) return EINA_FALSE;
4694 return _it->display_only;
4698 elm_genlist_item_show(Elm_Object_Item *it)
4700 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4701 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4702 Evas_Coord gith = 0;
4703 if (_it->generation < _it->wd->generation) return;
4704 if ((_it->item->queued) || (!_it->item->mincalcd))
4706 _it->wd->show_item = _it;
4707 _it->wd->bring_in = EINA_FALSE;
4708 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
4709 _it->item->showme = EINA_TRUE;
4712 if (_it->wd->show_item)
4714 _it->wd->show_item->item->showme = EINA_FALSE;
4715 _it->wd->show_item = NULL;
4717 if ((_it->item->group_item) &&
4718 (_it->wd->pan_y > (_it->y + _it->item->block->y)))
4719 gith = _it->item->group_item->item->h;
4720 elm_smart_scroller_child_region_show(_it->wd->scr,
4721 _it->x + _it->item->block->x,
4722 _it->y + _it->item->block->y - gith,
4723 _it->item->block->w, _it->item->h);
4727 elm_genlist_item_promote(Elm_Object_Item *it)
4729 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4730 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4731 if (_it->generation < _it->wd->generation) return;
4732 _item_move_before(_it,
4733 (Elm_Gen_Item *) elm_genlist_first_item_get(WIDGET(_it)));
4737 elm_genlist_item_demote(Elm_Object_Item *it)
4739 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4740 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4741 if (_it->generation < _it->wd->generation) return;
4742 _item_move_after(_it,
4743 (Elm_Gen_Item *) elm_genlist_last_item_get(WIDGET(_it)));
4747 elm_genlist_item_bring_in(Elm_Object_Item *it)
4749 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4750 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4751 Evas_Coord gith = 0;
4752 if (_it->generation < _it->wd->generation) return;
4753 if ((_it->item->queued) || (!_it->item->mincalcd))
4755 _it->wd->show_item = _it;
4756 _it->wd->bring_in = EINA_TRUE;
4757 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
4758 _it->item->showme = EINA_TRUE;
4761 if (_it->wd->show_item)
4763 _it->wd->show_item->item->showme = EINA_FALSE;
4764 _it->wd->show_item = NULL;
4766 if ((_it->item->group_item) &&
4767 (_it->wd->pan_y > (_it->y + _it->item->block->y)))
4768 gith = _it->item->group_item->item->h;
4769 elm_smart_scroller_region_bring_in(_it->wd->scr,
4770 _it->x + _it->item->block->x,
4771 _it->y + _it->item->block->y - gith,
4772 _it->item->block->w, _it->item->h);
4776 elm_genlist_item_top_show(Elm_Object_Item *it)
4778 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4779 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4781 Evas_Coord gith = 0;
4783 if (_it->generation < _it->wd->generation) return;
4784 if ((_it->item->queued) || (!_it->item->mincalcd))
4786 _it->wd->show_item = _it;
4787 _it->wd->bring_in = EINA_FALSE;
4788 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_TOP;
4789 _it->item->showme = EINA_TRUE;
4792 if (_it->wd->show_item)
4794 _it->wd->show_item->item->showme = EINA_FALSE;
4795 _it->wd->show_item = NULL;
4797 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4798 if (_it->item->group_item) gith = _it->item->group_item->item->h;
4799 elm_smart_scroller_child_region_show(_it->wd->scr,
4800 _it->x + _it->item->block->x,
4801 _it->y + _it->item->block->y - gith,
4802 _it->item->block->w, oh);
4806 elm_genlist_item_top_bring_in(Elm_Object_Item *it)
4808 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4809 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4811 Evas_Coord gith = 0;
4813 if (_it->generation < _it->wd->generation) return;
4814 if ((_it->item->queued) || (!_it->item->mincalcd))
4816 _it->wd->show_item = _it;
4817 _it->wd->bring_in = EINA_TRUE;
4818 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_TOP;
4819 _it->item->showme = EINA_TRUE;
4822 if (_it->wd->show_item)
4824 _it->wd->show_item->item->showme = EINA_FALSE;
4825 _it->wd->show_item = NULL;
4827 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4828 if (_it->item->group_item) gith = _it->item->group_item->item->h;
4829 elm_smart_scroller_region_bring_in(_it->wd->scr,
4830 _it->x + _it->item->block->x,
4831 _it->y + _it->item->block->y - gith,
4832 _it->item->block->w, oh);
4836 elm_genlist_item_middle_show(Elm_Object_Item *it)
4838 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4839 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4842 if (_it->generation < _it->wd->generation) return;
4843 if ((_it->item->queued) || (!_it->item->mincalcd))
4845 _it->wd->show_item = _it;
4846 _it->wd->bring_in = EINA_FALSE;
4847 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_MIDDLE;
4848 _it->item->showme = EINA_TRUE;
4851 if (_it->wd->show_item)
4853 _it->wd->show_item->item->showme = EINA_FALSE;
4854 _it->wd->show_item = NULL;
4856 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4857 elm_smart_scroller_child_region_show(_it->wd->scr,
4858 _it->x + _it->item->block->x,
4859 _it->y + _it->item->block->y - oh / 2 +
4860 _it->item->h / 2, _it->item->block->w,
4865 elm_genlist_item_middle_bring_in(Elm_Object_Item *it)
4867 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4868 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4871 if (_it->generation < _it->wd->generation) return;
4872 if ((_it->item->queued) || (!_it->item->mincalcd))
4874 _it->wd->show_item = _it;
4875 _it->wd->bring_in = EINA_TRUE;
4876 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_MIDDLE;
4877 _it->item->showme = EINA_TRUE;
4880 if (_it->wd->show_item)
4882 _it->wd->show_item->item->showme = EINA_FALSE;
4883 _it->wd->show_item = NULL;
4885 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4886 elm_smart_scroller_region_bring_in(_it->wd->scr,
4887 _it->x + _it->item->block->x,
4888 _it->y + _it->item->block->y - oh / 2 +
4889 _it->item->h / 2, _it->item->block->w,
4894 elm_genlist_item_del(Elm_Object_Item *it)
4896 elm_object_item_del(it);
4900 elm_genlist_item_data_set(Elm_Object_Item *it,
4903 elm_object_item_data_set(it, (void *) data);
4907 elm_genlist_item_data_get(const Elm_Object_Item *it)
4909 return elm_object_item_data_get(it);
4913 elm_genlist_item_icons_orphan(Elm_Object_Item *it)
4915 elm_genlist_item_contents_orphan(it);
4919 elm_genlist_item_contents_orphan(Elm_Object_Item *it)
4921 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4923 Evas_Object *content;
4924 EINA_LIST_FREE(((Elm_Gen_Item *) it)->content_objs, content)
4926 elm_widget_sub_object_del(WIDGET(it), content);
4927 evas_object_smart_member_del(content);
4928 evas_object_hide(content);
4932 EINA_DEPRECATED EAPI const Evas_Object *
4933 elm_genlist_item_object_get(const Elm_Object_Item *it)
4935 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4940 elm_genlist_item_update(Elm_Object_Item *it)
4942 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4943 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4945 if (!_it->item->block) return;
4946 if (_it->generation < _it->wd->generation) return;
4947 _it->item->mincalcd = EINA_FALSE;
4948 _it->item->updateme = EINA_TRUE;
4949 _it->item->block->updateme = EINA_TRUE;
4950 if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
4951 _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
4955 elm_genlist_item_fields_update(Elm_Object_Item *it,
4957 Elm_Genlist_Item_Field_Flags itf)
4959 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4960 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4962 if (!_it->item->block) return;
4963 if (_it->generation < _it->wd->generation) return;
4965 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_TEXT))
4966 _item_text_realize(_it, VIEW(_it), &_it->texts, parts);
4967 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_CONTENT))
4969 _it->content_objs = _item_content_unrealize(_it, VIEW(_it),
4970 &_it->contents, parts);
4971 _it->content_objs = _item_content_realize(_it, VIEW(_it),
4972 &_it->contents, parts);
4974 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
4975 _item_state_realize(_it, VIEW(_it), &_it->states, parts);
4979 elm_genlist_item_item_class_update(Elm_Object_Item *it,
4980 const Elm_Genlist_Item_Class *itc)
4982 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4983 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4985 if (!_it->item->block) return;
4986 EINA_SAFETY_ON_NULL_RETURN(itc);
4987 if (_it->generation < _it->wd->generation) return;
4989 _it->item->nocache = EINA_TRUE;
4990 elm_genlist_item_update(it);
4993 EAPI const Elm_Genlist_Item_Class *
4994 elm_genlist_item_item_class_get(const Elm_Object_Item *it)
4996 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4997 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4998 if (_it->generation < _it->wd->generation) return NULL;
5002 static Evas_Object *
5003 _elm_genlist_item_label_create(void *data,
5004 Evas_Object *obj __UNUSED__,
5005 Evas_Object *tooltip,
5006 void *it __UNUSED__)
5008 Evas_Object *label = elm_label_add(tooltip);
5011 elm_object_style_set(label, "tooltip");
5012 elm_object_text_set(label, data);
5017 _elm_genlist_item_label_del_cb(void *data,
5018 Evas_Object *obj __UNUSED__,
5019 void *event_info __UNUSED__)
5021 eina_stringshare_del(data);
5025 elm_genlist_item_tooltip_text_set(Elm_Object_Item *it,
5028 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5029 text = eina_stringshare_add(text);
5030 elm_genlist_item_tooltip_content_cb_set(it, _elm_genlist_item_label_create,
5032 _elm_genlist_item_label_del_cb);
5036 elm_genlist_item_tooltip_content_cb_set(Elm_Object_Item *it,
5037 Elm_Tooltip_Item_Content_Cb func,
5039 Evas_Smart_Cb del_cb)
5041 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
5042 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5044 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
5047 if (_it->tooltip.del_cb)
5048 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(it), it);
5050 _it->tooltip.content_cb = func;
5051 _it->tooltip.data = data;
5052 _it->tooltip.del_cb = del_cb;
5056 elm_widget_item_tooltip_content_cb_set(_it,
5057 _it->tooltip.content_cb,
5058 _it->tooltip.data, NULL);
5059 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
5060 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
5066 if (del_cb) del_cb((void *)data, NULL, NULL);
5070 elm_genlist_item_tooltip_unset(Elm_Object_Item *it)
5072 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5073 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5075 if ((VIEW(_it)) && (_it->tooltip.content_cb))
5076 elm_widget_item_tooltip_unset(_it);
5078 if (_it->tooltip.del_cb)
5079 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
5080 _it->tooltip.del_cb = NULL;
5081 _it->tooltip.content_cb = NULL;
5082 _it->tooltip.data = NULL;
5083 _it->tooltip.free_size = EINA_FALSE;
5084 if (_it->tooltip.style)
5085 elm_genlist_item_tooltip_style_set(it, NULL);
5089 elm_genlist_item_tooltip_style_set(Elm_Object_Item *it,
5092 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5093 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5095 eina_stringshare_replace(&_it->tooltip.style, style);
5096 if (VIEW(_it)) elm_widget_item_tooltip_style_set(_it, style);
5100 elm_genlist_item_tooltip_style_get(const Elm_Object_Item *it)
5102 return elm_object_item_tooltip_style_get(it);
5106 elm_genlist_item_tooltip_window_mode_set(Elm_Object_Item *it,
5109 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
5110 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5112 _it->tooltip.free_size = disable;
5113 if (VIEW(_it)) return elm_widget_item_tooltip_window_mode_set(_it, disable);
5118 elm_genlist_item_tooltip_window_mode_get(const Elm_Object_Item *it)
5120 return elm_object_tooltip_window_mode_get(VIEW(it));
5124 elm_genlist_item_cursor_set(Elm_Object_Item *it,
5127 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5128 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5129 eina_stringshare_replace(&_it->mouse_cursor, cursor);
5130 if (VIEW(_it)) elm_widget_item_cursor_set(_it, cursor);
5134 elm_genlist_item_cursor_get(const Elm_Object_Item *it)
5136 return elm_widget_item_cursor_get(it);
5140 elm_genlist_item_cursor_unset(Elm_Object_Item *it)
5142 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5143 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5145 if (!_it->mouse_cursor) return;
5147 if (VIEW(_it)) elm_widget_item_cursor_unset(_it);
5149 eina_stringshare_del(_it->mouse_cursor);
5150 _it->mouse_cursor = NULL;
5154 elm_genlist_item_cursor_style_set(Elm_Object_Item *it,
5157 elm_widget_item_cursor_style_set(it, style);
5161 elm_genlist_item_cursor_style_get(const Elm_Object_Item *it)
5163 return elm_widget_item_cursor_style_get(it);
5167 elm_genlist_item_cursor_engine_only_set(Elm_Object_Item *it,
5168 Eina_Bool engine_only)
5170 elm_widget_item_cursor_engine_only_set(it, engine_only);
5174 elm_genlist_item_cursor_engine_only_get(const Elm_Object_Item *it)
5176 return elm_widget_item_cursor_engine_only_get(it);
5180 elm_genlist_item_index_get(const Elm_Object_Item *it)
5182 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, -1);
5183 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5185 if (_it->item->block)
5186 return _it->position + _it->item->block->position;
5191 elm_genlist_mode_set(Evas_Object *obj,
5194 ELM_CHECK_WIDTYPE(obj, widtype);
5195 Widget_Data *wd = elm_widget_data_get(obj);
5197 if (wd->mode == mode) return;
5203 elm_genlist_horizontal_set(Evas_Object *obj,
5206 elm_genlist_mode_set(obj, mode);
5210 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5213 elm_genlist_mode_set(obj, mode);
5217 elm_genlist_mode_get(const Evas_Object *obj)
5219 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5220 Widget_Data *wd = elm_widget_data_get(obj);
5221 if (!wd) return ELM_LIST_LAST;
5225 EINA_DEPRECATED EAPI Elm_List_Mode
5226 elm_genlist_horizontal_get(const Evas_Object *obj)
5228 return elm_genlist_mode_get(obj);
5231 EINA_DEPRECATED EAPI Elm_List_Mode
5232 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5234 return elm_genlist_mode_get(obj);
5238 elm_genlist_always_select_mode_set(Evas_Object *obj,
5239 Eina_Bool always_select)
5241 ELM_CHECK_WIDTYPE(obj, widtype);
5242 Widget_Data *wd = elm_widget_data_get(obj);
5244 wd->always_select = !!always_select;
5248 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5250 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5251 Widget_Data *wd = elm_widget_data_get(obj);
5252 if (!wd) return EINA_FALSE;
5253 return wd->always_select;
5257 elm_genlist_no_select_mode_set(Evas_Object *obj,
5258 Eina_Bool no_select)
5260 ELM_CHECK_WIDTYPE(obj, widtype);
5261 Widget_Data *wd = elm_widget_data_get(obj);
5263 wd->no_select = !!no_select;
5267 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5269 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5270 Widget_Data *wd = elm_widget_data_get(obj);
5271 if (!wd) return EINA_FALSE;
5272 return wd->no_select;
5276 elm_genlist_compress_mode_set(Evas_Object *obj,
5279 ELM_CHECK_WIDTYPE(obj, widtype);
5280 Widget_Data *wd = elm_widget_data_get(obj);
5282 wd->compress = !!compress;
5283 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
5287 elm_genlist_compress_mode_get(const Evas_Object *obj)
5289 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5290 Widget_Data *wd = elm_widget_data_get(obj);
5291 if (!wd) return EINA_FALSE;
5292 return wd->compress;
5296 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5297 Eina_Bool height_for_width)
5299 ELM_CHECK_WIDTYPE(obj, widtype);
5300 Widget_Data *wd = elm_widget_data_get(obj);
5302 wd->height_for_width = !!height_for_width;
5303 if (wd->height_for_width)
5305 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5306 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5311 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5313 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5314 Widget_Data *wd = elm_widget_data_get(obj);
5315 if (!wd) return EINA_FALSE;
5316 return wd->height_for_width;
5320 elm_genlist_bounce_set(Evas_Object *obj,
5324 ELM_CHECK_WIDTYPE(obj, widtype);
5325 Widget_Data *wd = elm_widget_data_get(obj);
5327 wd->h_bounce = !!h_bounce;
5328 wd->v_bounce = !!v_bounce;
5329 elm_smart_scroller_bounce_allow_set(wd->scr, wd->h_bounce, wd->v_bounce);
5333 elm_genlist_bounce_get(const Evas_Object *obj,
5334 Eina_Bool *h_bounce,
5335 Eina_Bool *v_bounce)
5337 ELM_CHECK_WIDTYPE(obj, widtype);
5338 Widget_Data *wd = elm_widget_data_get(obj);
5340 if (h_bounce) *h_bounce = wd->h_bounce;
5341 if (v_bounce) *v_bounce = wd->v_bounce;
5345 elm_genlist_homogeneous_set(Evas_Object *obj,
5346 Eina_Bool homogeneous)
5348 ELM_CHECK_WIDTYPE(obj, widtype);
5349 Widget_Data *wd = elm_widget_data_get(obj);
5351 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5352 wd->homogeneous = !!homogeneous;
5356 elm_genlist_homogeneous_get(const Evas_Object *obj)
5358 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5359 Widget_Data *wd = elm_widget_data_get(obj);
5360 if (!wd) return EINA_FALSE;
5361 return wd->homogeneous;
5365 elm_genlist_block_count_set(Evas_Object *obj,
5368 ELM_CHECK_WIDTYPE(obj, widtype);
5369 Widget_Data *wd = elm_widget_data_get(obj);
5371 wd->max_items_per_block = count;
5372 wd->item_cache_max = wd->max_items_per_block * 2;
5373 _item_cache_clean(wd);
5377 elm_genlist_block_count_get(const Evas_Object *obj)
5379 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5380 Widget_Data *wd = elm_widget_data_get(obj);
5382 return wd->max_items_per_block;
5386 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5389 ELM_CHECK_WIDTYPE(obj, widtype);
5390 Widget_Data *wd = elm_widget_data_get(obj);
5392 wd->longpress_timeout = timeout;
5396 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5398 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5399 Widget_Data *wd = elm_widget_data_get(obj);
5401 return wd->longpress_timeout;
5405 elm_genlist_scroller_policy_set(Evas_Object *obj,
5406 Elm_Scroller_Policy policy_h,
5407 Elm_Scroller_Policy policy_v)
5409 ELM_CHECK_WIDTYPE(obj, widtype);
5410 Widget_Data *wd = elm_widget_data_get(obj);
5411 if ((!wd) || (!wd->scr)) return;
5412 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5413 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5415 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5419 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5420 Elm_Scroller_Policy *policy_h,
5421 Elm_Scroller_Policy *policy_v)
5423 ELM_CHECK_WIDTYPE(obj, widtype);
5424 Widget_Data *wd = elm_widget_data_get(obj);
5425 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5426 if ((!wd) || (!wd->scr)) return;
5427 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5428 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5429 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5433 elm_genlist_realized_items_update(Evas_Object *obj)
5435 ELM_CHECK_WIDTYPE(obj, widtype);
5437 Eina_List *list, *l;
5438 Elm_Object_Item *it;
5440 list = elm_genlist_realized_items_get(obj);
5441 EINA_LIST_FOREACH(list, l, it)
5442 elm_genlist_item_update(it);
5446 elm_genlist_item_mode_set(Elm_Object_Item *it,
5447 const char *mode_type,
5450 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5451 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5453 Widget_Data *wd = _it->wd;
5455 Elm_Object_Item *it2;
5458 if (!mode_type) return;
5459 if ((_it->generation < _it->wd->generation) ||
5460 elm_widget_item_disabled_get(_it)) return;
5461 if (wd->edit_mode) return;
5463 if ((wd->mode_item == _it) &&
5464 (!strcmp(mode_type, wd->mode_type)) &&
5467 if (!_it->itc->mode_item_style) return;
5468 _it->mode_set = mode_set;
5472 EINA_LIST_FOREACH(wd->selected, l, it2)
5473 if (((Elm_Gen_Item *) it2)->realized)
5474 elm_genlist_item_selected_set(it2, EINA_FALSE);
5478 it2 = elm_genlist_selected_item_get(wd->obj);
5479 if ((it2) && (((Elm_Gen_Item *) it2)->realized))
5480 elm_genlist_item_selected_set(it2, EINA_FALSE);
5483 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5485 ((_it == wd->mode_item) && (!mode_set)))
5486 _item_mode_unset(wd);
5488 eina_stringshare_replace(&wd->mode_type, mode_type);
5489 if (mode_set) _item_mode_set(_it);
5493 elm_genlist_mode_item_style_get(const Evas_Object *obj)
5495 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5496 Widget_Data *wd = elm_widget_data_get(obj);
5497 if (!wd) return NULL;
5498 return wd->mode_item->itc->mode_item_style;
5502 elm_genlist_mode_item_style_set(Evas_Object *obj, const char *style)
5504 ELM_CHECK_WIDTYPE(obj, widtype);
5505 Widget_Data *wd = elm_widget_data_get(obj);
5507 if ((style == wd->mode_item->itc->mode_item_style) ||
5508 (style && wd->mode_item->itc->mode_item_style &&
5509 (!strcmp(style, wd->mode_item->itc->mode_item_style))))
5511 eina_stringshare_replace((const char**)&wd->mode_item->itc->mode_item_style, style);
5512 elm_genlist_realized_items_update(obj);
5516 elm_genlist_mode_type_get(const Evas_Object *obj)
5518 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5519 Widget_Data *wd = elm_widget_data_get(obj);
5520 if (!wd) return NULL;
5521 return wd->mode_type;
5524 EAPI const Elm_Object_Item *
5525 elm_genlist_mode_item_get(const Evas_Object *obj)
5527 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5528 Widget_Data *wd = elm_widget_data_get(obj);
5529 if (!wd) return NULL;
5530 return (Elm_Object_Item *) wd->mode_item;
5534 elm_genlist_edit_mode_get(const Evas_Object *obj)
5536 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5537 Widget_Data *wd = elm_widget_data_get(obj);
5538 if (!wd) return EINA_FALSE;
5540 return wd->edit_mode;
5544 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5546 ELM_CHECK_WIDTYPE(obj, widtype);
5547 Eina_List *list, *l;
5550 Widget_Data *wd = elm_widget_data_get(obj);
5552 edit_mode = !!edit_mode;
5553 if (wd->edit_mode == edit_mode) return;
5554 wd->edit_mode = edit_mode;
5556 list = elm_genlist_realized_items_get(obj);
5559 EINA_LIST_FOREACH(list, l, it)
5561 if (it->item->flags != ELM_GENLIST_ITEM_GROUP)
5562 _edit_mode_item_unrealize(it);
5564 _item_cache_zero(wd);
5568 EINA_LIST_FOREACH(list, l, it)
5570 if (it->item->flags != ELM_GENLIST_ITEM_GROUP)
5572 if (it->selected) _item_unselect(it);
5573 if (it->itc->edit_item_style)
5574 _edit_mode_item_realize(it, EINA_TRUE);
5578 if (wd->calc_job) ecore_job_del(wd->calc_job);
5579 wd->calc_job = ecore_job_add(_calc_job, wd);
5583 elm_genlist_reorder_mode_set(Evas_Object *obj,
5584 Eina_Bool reorder_mode)
5586 ELM_CHECK_WIDTYPE(obj, widtype);
5587 Widget_Data *wd = elm_widget_data_get(obj);
5589 wd->reorder_mode = !!reorder_mode;
5593 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5595 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5596 Widget_Data *wd = elm_widget_data_get(obj);
5597 if (!wd) return EINA_FALSE;
5598 return wd->reorder_mode;
5601 EAPI Elm_Genlist_Item_Flags
5602 elm_genlist_item_flags_get(const Elm_Object_Item *it)
5604 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ELM_GENLIST_ITEM_MAX);
5605 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5606 return _it->item->flags;
5609 EAPI Elm_Genlist_Item_Class *
5610 elm_genlist_item_class_new(void)
5612 Elm_Genlist_Item_Class *itc;
5614 itc = calloc(1, sizeof(Elm_Genlist_Item_Class));
5617 itc->version = ELM_GENLIST_ITEM_CLASS_VERSION;
5619 itc->delete_me = EINA_FALSE;
5625 elm_genlist_item_class_free(Elm_Genlist_Item_Class *itc)
5627 ELM_GENLIST_CHECK_ITC_VER(itc);
5628 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
5629 if (itc->refcount > 0) elm_genlist_item_class_unref(itc);
5638 elm_genlist_item_class_ref(Elm_Genlist_Item_Class *itc)
5640 ELM_GENLIST_CHECK_ITC_VER(itc);
5643 if (itc->refcount == 0) itc->refcount--;
5647 elm_genlist_item_class_unref(Elm_Genlist_Item_Class *itc)
5649 ELM_GENLIST_CHECK_ITC_VER(itc);
5651 if (itc->refcount > 0) itc->refcount--;
5652 if (itc->delete_me && (!itc->refcount))
5653 elm_genlist_item_class_free(itc);
5656 /* for gengrid as of now */
5658 _elm_genlist_page_relative_set(Evas_Object *obj,
5662 Evas_Coord pagesize_h;
5663 Evas_Coord pagesize_v;
5665 ELM_CHECK_WIDTYPE(obj, widtype);
5666 Widget_Data *wd = elm_widget_data_get(obj);
5669 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
5670 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
5674 /* for gengrid as of now */
5676 _elm_genlist_page_relative_get(const Evas_Object *obj,
5680 ELM_CHECK_WIDTYPE(obj, widtype);
5681 Widget_Data *wd = elm_widget_data_get(obj);
5684 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
5687 /* for gengrid as of now */
5689 _elm_genlist_page_size_set(Evas_Object *obj,
5690 Evas_Coord h_pagesize,
5691 Evas_Coord v_pagesize)
5696 ELM_CHECK_WIDTYPE(obj, widtype);
5697 Widget_Data *wd = elm_widget_data_get(obj);
5699 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
5700 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
5704 /* for gengrid as of now */
5706 _elm_genlist_current_page_get(const Evas_Object *obj,
5710 ELM_CHECK_WIDTYPE(obj, widtype);
5711 Widget_Data *wd = elm_widget_data_get(obj);
5713 elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber);
5716 /* for gengrid as of now */
5718 _elm_genlist_last_page_get(const Evas_Object *obj,
5722 ELM_CHECK_WIDTYPE(obj, widtype);
5723 Widget_Data *wd = elm_widget_data_get(obj);
5725 elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber);
5728 /* for gengrid as of now */
5730 _elm_genlist_page_show(const Evas_Object *obj,
5734 ELM_CHECK_WIDTYPE(obj, widtype);
5735 Widget_Data *wd = elm_widget_data_get(obj);
5737 elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber);
5740 /* for gengrid as of now */
5742 _elm_genlist_page_bring_in(const Evas_Object *obj,
5746 ELM_CHECK_WIDTYPE(obj, widtype);
5747 Widget_Data *wd = elm_widget_data_get(obj);
5749 elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber);
5753 _elm_genlist_item_unrealize(Elm_Gen_Item *it,
5756 Evas_Object *content;
5758 if (!it->realized) return;
5759 if (it->wd->reorder_it == it) return;
5761 evas_event_freeze(evas_object_evas_get(WIDGET(it)));
5763 evas_object_smart_callback_call(WIDGET(it), SIG_UNREALIZED, it);
5766 ecore_timer_del(it->long_timer);
5767 it->long_timer = NULL;
5770 elm_widget_stringlist_free(it->texts);
5772 elm_widget_stringlist_free(it->contents);
5773 it->contents = NULL;
5774 elm_widget_stringlist_free(it->states);
5777 EINA_LIST_FREE(it->content_objs, content)
5778 evas_object_del(content);
5780 it->unrealize_cb(it);
5782 it->realized = EINA_FALSE;
5783 it->want_unrealize = EINA_FALSE;
5784 evas_event_thaw(evas_object_evas_get(WIDGET(it)));
5785 evas_event_thaw_eval(evas_object_evas_get(WIDGET(it)));
5789 _elm_genlist_item_del_notserious(Elm_Gen_Item *it)
5791 elm_widget_item_pre_notify_del(it);
5792 it->generation = it->wd->generation - 1; /* This means that the item is deleted */
5793 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5795 if (it->itc->func.del)
5796 it->itc->func.del((void *)it->base.data, WIDGET(it));
5800 _elm_genlist_item_del_serious(Elm_Gen_Item *it)
5802 _elm_genlist_item_del_notserious(it);
5803 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5804 if (it->tooltip.del_cb)
5805 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
5806 it->wd->walking -= it->walking;
5807 if (it->long_timer) ecore_timer_del(it->long_timer);
5809 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
5813 eina_inlist_sorted_state_free(it->wd->state);
5814 it->wd->state = NULL;
5816 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5817 it->wd->calc_job = ecore_job_add(it->wd->calc_cb, it->wd);
5821 if (it->wd->last_selected_item == (Elm_Object_Item *) it)
5822 it->wd->last_selected_item = NULL;
5823 it->wd->item_count--;