3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
6 #include "els_scroller.h"
7 #include "elm_gen_common.h"
9 #define MAX_ITEMS_PER_BLOCK 32
10 #define REORDER_EFFECT_TIME 0.5
12 #define ELM_GEN_SETUP(wd) \
13 (wd)->calc_cb = (Ecore_Cb)_calc_job; \
14 (wd)->clear_cb = (Ecore_Cb)_clear_cb; \
15 (wd)->sizing_cb = (Ecore_Cb)_sizing_eval
17 #define ELM_GEN_ITEM_SETUP(it) \
18 (it)->del_cb = (Ecore_Cb)_item_del; \
19 (it)->highlight_cb = (Ecore_Cb)_item_highlight; \
20 (it)->unsel_cb = (Ecore_Cb)_item_unselect; \
21 (it)->unhighlight_cb = (Ecore_Cb)_item_unhighlight; \
22 (it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
24 #define ELM_GENLIST_CHECK_ITC_VER(itc) \
29 ERR("Genlist_Item_Class(itc) is NULL"); \
32 if (itc->version != ELM_GENLIST_ITEM_CLASS_VERSION) \
34 ERR("Genlist_Item_Class version mismatched! required = (%d), current = (%d)", itc->version, ELM_GENLIST_ITEM_CLASS_VERSION); \
40 typedef struct _Item_Block Item_Block;
41 typedef struct _Item_Cache Item_Cache;
43 struct Elm_Gen_Item_Type
48 Evas_Coord w, h, minw, minh;
49 Elm_Gen_Item *group_item;
50 Elm_Genlist_Item_Flags flags;
51 Eina_List *mode_texts, *mode_contents, *mode_states, *mode_content_objs;
52 Eina_List *edit_texts, *edit_contents, *edit_states, *edit_content_objs;
53 Ecore_Timer *swipe_timer;
54 Evas_Coord scrl_x, scrl_y, old_scrl_y;
57 Evas_Object *mode_view;
63 Eina_Bool want_realize : 1;
64 Eina_Bool expanded : 1;
65 Eina_Bool mincalcd : 1;
68 Eina_Bool updateme : 1;
69 Eina_Bool nocache : 1;
70 Eina_Bool stacking_even : 1;
71 Eina_Bool nostacking : 1;
72 Eina_Bool move_effect_enabled : 1;
73 Eina_Bool edit_mode_item_realized : 1;
84 Evas_Coord x, y, w, h, minw, minh;
86 int item_position_stamp;
88 Eina_Bool position_update : 1;
89 Eina_Bool want_unrealize : 1;
90 Eina_Bool realized : 1;
91 Eina_Bool changed : 1;
92 Eina_Bool updateme : 1;
94 Eina_Bool must_recalc : 1;
101 Evas_Object *base_view, *spacer;
103 const char *item_style; // it->itc->item_style
104 Eina_Bool tree : 1; // it->group
105 Eina_Bool compress : 1; // it->wd->compress
107 Eina_Bool selected : 1; // it->selected
108 Eina_Bool disabled : 1; // it->disabled
109 Eina_Bool expanded : 1; // it->item->expanded
112 static const char *widtype = NULL;
113 static void _item_cache_zero(Widget_Data *wd);
114 static void _del_hook(Evas_Object *obj);
115 static void _mirrored_set(Evas_Object *obj,
117 static void _theme_hook(Evas_Object *obj);
118 static void _show_region_hook(void *data,
120 static void _sizing_eval(Evas_Object *obj);
121 static void _item_realize(Elm_Gen_Item *it,
124 static void _item_unrealize_cb(Elm_Gen_Item *it);
125 static void _item_block_unrealize(Item_Block *itb);
126 static void _calc_job(void *data);
127 static void _on_focus_hook(void *data,
129 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
130 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
131 static Eina_Bool _item_single_select_up(Widget_Data *wd);
132 static Eina_Bool _item_single_select_down(Widget_Data *wd);
133 static Eina_Bool _event_hook(Evas_Object *obj,
135 Evas_Callback_Type type,
137 static void _signal_emit_hook(Evas_Object *obj,
138 const char *emission,
140 static Eina_Bool _deselect_all_items(Widget_Data *wd);
141 static void _pan_calculate(Evas_Object *obj);
142 static void _pan_max_get(Evas_Object *obj,
145 static void _item_position(Elm_Gen_Item *it,
149 static void _mode_item_realize(Elm_Gen_Item *it);
150 static void _mode_item_unrealize(Elm_Gen_Item *it);
151 static void _item_mode_set(Elm_Gen_Item *it);
152 static void _item_mode_unset(Widget_Data *wd);
153 static void _edit_mode_item_position(Elm_Gen_Item *it, int itx, int ity);
154 static void _edit_mode_item_realize(Elm_Gen_Item *it, Eina_Bool effect_on);
155 static void _edit_mode_item_unrealize(Elm_Gen_Item *it);
156 static void _group_items_recalc(void *data);
157 static void _item_move_after(Elm_Gen_Item *it,
158 Elm_Gen_Item *after);
159 static void _item_move_before(Elm_Gen_Item *it,
160 Elm_Gen_Item *before);
161 static void _item_auto_scroll(Widget_Data *wd);
162 static void _elm_genlist_clear(Evas_Object *obj,
164 static void _pan_child_size_get(Evas_Object *obj,
168 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
170 static const char SIG_ACTIVATED[] = "activated";
171 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
172 static const char SIG_SELECTED[] = "selected";
173 static const char SIG_UNSELECTED[] = "unselected";
174 static const char SIG_EXPANDED[] = "expanded";
175 static const char SIG_CONTRACTED[] = "contracted";
176 static const char SIG_EXPAND_REQUEST[] = "expand,request";
177 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
178 static const char SIG_REALIZED[] = "realized";
179 static const char SIG_UNREALIZED[] = "unrealized";
180 static const char SIG_DRAG_START_UP[] = "drag,start,up";
181 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
182 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
183 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
184 static const char SIG_DRAG_STOP[] = "drag,stop";
185 static const char SIG_DRAG[] = "drag";
186 static const char SIG_LONGPRESSED[] = "longpressed";
187 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
188 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
189 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
190 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
191 static const char SIG_EDGE_TOP[] = "edge,top";
192 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
193 static const char SIG_EDGE_LEFT[] = "edge,left";
194 static const char SIG_EDGE_RIGHT[] = "edge,right";
195 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
196 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
197 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
198 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
199 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
200 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
201 static const char SIG_SWIPE[] = "swipe";
202 static const char SIG_MOVED[] = "moved";
203 static const char SIG_INDEX_UPDATE[] = "index,update";
205 static const Evas_Smart_Cb_Description _signals[] = {
206 {SIG_CLICKED_DOUBLE, ""},
209 {SIG_UNSELECTED, ""},
211 {SIG_CONTRACTED, ""},
212 {SIG_EXPAND_REQUEST, ""},
213 {SIG_CONTRACT_REQUEST, ""},
215 {SIG_UNREALIZED, ""},
216 {SIG_DRAG_START_UP, ""},
217 {SIG_DRAG_START_DOWN, ""},
218 {SIG_DRAG_START_LEFT, ""},
219 {SIG_DRAG_START_RIGHT, ""},
222 {SIG_LONGPRESSED, ""},
223 {SIG_SCROLL_ANIM_START, ""},
224 {SIG_SCROLL_ANIM_STOP, ""},
225 {SIG_SCROLL_DRAG_START, ""},
226 {SIG_SCROLL_DRAG_STOP, ""},
228 {SIG_EDGE_BOTTOM, ""},
230 {SIG_EDGE_RIGHT, ""},
231 {SIG_MULTI_SWIPE_LEFT, ""},
232 {SIG_MULTI_SWIPE_RIGHT, ""},
233 {SIG_MULTI_SWIPE_UP, ""},
234 {SIG_MULTI_SWIPE_DOWN, ""},
235 {SIG_MULTI_PINCH_OUT, ""},
236 {SIG_MULTI_PINCH_IN, ""},
243 #undef ELM_CHECK_WIDTYPE
244 #define ELM_CHECK_WIDTYPE(obj, widtype) \
245 if ((!obj) || (!elm_genlist_type_check((obj), __func__))) return
246 #undef ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN
247 #define ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, ...) \
248 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
249 ELM_CHECK_WIDTYPE(WIDGET((it)), widtype) __VA_ARGS__;
251 static const char *_gengrid = NULL;
252 static const char *_genlist = NULL;
254 /* THIS FUNCTION IS HACKY AND TEMPORARY!!! */
256 elm_genlist_type_check(const Evas_Object *obj,
259 const char *provided, *expected = "(unknown)";
260 static int abort_on_warn = -1;
261 provided = elm_widget_type_get(obj);
262 if (!_genlist) _genlist = eina_stringshare_add("genlist");
263 if (!_gengrid) _gengrid = eina_stringshare_add("gengrid");
264 if (EINA_LIKELY(provided == _genlist) || EINA_LIKELY(provided == _gengrid))
266 if ((!provided) || (!provided[0]))
268 provided = evas_object_type_get(obj);
269 if ((!provided) || (!provided[0]))
270 provided = "(unknown)";
272 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
273 if (abort_on_warn == -1)
275 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
276 else abort_on_warn = 0;
278 if (abort_on_warn == 1) abort();
283 _event_hook(Evas_Object *obj,
284 Evas_Object *src __UNUSED__,
285 Evas_Callback_Type type,
288 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
289 Evas_Event_Key_Down *ev = event_info;
290 Widget_Data *wd = elm_widget_data_get(obj);
291 Evas_Coord pan_max_x = 0, pan_max_y = 0;
292 if (!wd) return EINA_FALSE;
293 if (!wd->items) return EINA_FALSE;
294 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
295 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
297 Elm_Object_Item *it = NULL;
300 Evas_Coord step_x = 0;
301 Evas_Coord step_y = 0;
304 Evas_Coord page_x = 0;
305 Evas_Coord page_y = 0;
307 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
308 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
309 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
310 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
312 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
316 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
320 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
322 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
323 (_item_multi_select_up(wd)))
324 || (_item_single_select_up(wd)))
326 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
332 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
334 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
335 (_item_multi_select_down(wd)))
336 || (_item_single_select_down(wd)))
338 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
344 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
346 it = elm_genlist_first_item_get(obj);
347 elm_genlist_item_bring_in(it);
348 elm_genlist_item_selected_set(it, EINA_TRUE);
349 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
352 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
354 it = elm_genlist_last_item_get(obj);
355 elm_genlist_item_bring_in(it);
356 elm_genlist_item_selected_set(it, EINA_TRUE);
357 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
360 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
363 y -= -(page_y * v_h) / 100;
367 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
370 y += -(page_y * v_h) / 100;
374 else if (!strcmp(ev->keyname, "Escape"))
376 if (!_deselect_all_items(wd)) return EINA_FALSE;
377 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
380 else if (((!strcmp(ev->keyname, "Return")) ||
381 (!strcmp(ev->keyname, "KP_Enter")) ||
382 (!strcmp(ev->keyname, "space")))
383 && (!wd->multi) && (wd->selected))
385 it = elm_genlist_selected_item_get(obj);
386 elm_genlist_item_expanded_set(it,
387 !elm_genlist_item_expanded_get(it));
388 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
390 else return EINA_FALSE;
392 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
393 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
395 if (x > pan_max_x) x = pan_max_x;
397 if (y > pan_max_y) y = pan_max_y;
398 elm_smart_scroller_child_pos_set(wd->scr, x, y);
403 _deselect_all_items(Widget_Data *wd)
405 if (!wd->selected) return EINA_FALSE;
407 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
413 _item_multi_select_up(Widget_Data *wd)
415 if (!wd->selected) return EINA_FALSE;
416 if (!wd->multi) return EINA_FALSE;
418 Elm_Object_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
419 if (!prev) return EINA_TRUE;
421 if (elm_genlist_item_selected_get(prev))
423 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
424 wd->last_selected_item = prev;
425 elm_genlist_item_show(wd->last_selected_item);
429 elm_genlist_item_selected_set(prev, EINA_TRUE);
430 elm_genlist_item_show(prev);
436 _item_multi_select_down(Widget_Data *wd)
438 if (!wd->selected) return EINA_FALSE;
439 if (!wd->multi) return EINA_FALSE;
441 Elm_Object_Item *next;
442 next = elm_genlist_item_next_get(wd->last_selected_item);
443 if (!next) return EINA_TRUE;
445 if (elm_genlist_item_selected_get(next))
447 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
448 wd->last_selected_item = next;
449 elm_genlist_item_show(wd->last_selected_item);
453 elm_genlist_item_selected_set(next, EINA_TRUE);
454 elm_genlist_item_show(next);
460 _item_single_select_up(Widget_Data *wd)
465 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
466 while ((prev) && (prev->generation < wd->generation))
467 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
469 else prev = (Elm_Gen_Item *) elm_genlist_item_prev_get(wd->last_selected_item);
471 if (!prev) return EINA_FALSE;
473 _deselect_all_items(wd);
475 elm_genlist_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
476 elm_genlist_item_show((Elm_Object_Item *) prev);
481 _item_single_select_down(Widget_Data *wd)
486 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
487 while ((next) && (next->generation < wd->generation))
488 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
490 else next = (Elm_Gen_Item *) elm_genlist_item_next_get(wd->last_selected_item);
492 if (!next) return EINA_FALSE;
494 _deselect_all_items(wd);
496 elm_genlist_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
497 elm_genlist_item_show((Elm_Object_Item *) next);
502 _on_focus_hook(void *data __UNUSED__,
505 Widget_Data *wd = elm_widget_data_get(obj);
507 if (elm_widget_focus_get(obj))
509 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
510 evas_object_focus_set(wd->obj, EINA_TRUE);
511 if ((wd->selected) && (!wd->last_selected_item))
512 wd->last_selected_item = eina_list_data_get(wd->selected);
516 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
517 evas_object_focus_set(wd->obj, EINA_FALSE);
522 _del_hook(Evas_Object *obj)
524 Widget_Data *wd = elm_widget_data_get(obj);
526 _item_cache_zero(wd);
527 if (wd->calc_job) ecore_job_del(wd->calc_job);
528 if (wd->update_job) ecore_job_del(wd->update_job);
529 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
530 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
531 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
532 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
533 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
538 _del_pre_hook(Evas_Object *obj)
540 Widget_Data *wd = elm_widget_data_get(obj);
542 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
543 elm_genlist_clear(obj);
544 evas_object_del(wd->pan_smart);
545 wd->pan_smart = NULL;
549 _mirrored_set(Evas_Object *obj,
552 Widget_Data *wd = elm_widget_data_get(obj);
554 _item_cache_zero(wd);
555 elm_smart_scroller_mirrored_set(wd->scr, rtl);
559 _theme_hook(Evas_Object *obj)
561 Widget_Data *wd = elm_widget_data_get(obj);
564 evas_event_freeze(evas_object_evas_get(wd->obj));
565 _item_cache_zero(wd);
566 _elm_widget_mirrored_reload(obj);
567 _mirrored_set(obj, elm_widget_mirrored_get(obj));
568 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
569 elm_widget_style_get(obj));
570 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
571 wd->item_width = wd->item_height = 0;
572 wd->group_item_width = wd->group_item_height = 0;
573 wd->minw = wd->minh = wd->realminw = 0;
574 EINA_INLIST_FOREACH(wd->blocks, itb)
579 if (itb->realized) _item_block_unrealize(itb);
580 EINA_LIST_FOREACH(itb->items, l, it)
581 it->item->mincalcd = EINA_FALSE;
583 itb->changed = EINA_TRUE;
585 if (wd->calc_job) ecore_job_del(wd->calc_job);
586 wd->calc_job = ecore_job_add(_calc_job, wd);
588 evas_event_thaw(evas_object_evas_get(wd->obj));
589 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
593 _show_region_hook(void *data,
596 Widget_Data *wd = elm_widget_data_get(data);
597 Evas_Coord x, y, w, h;
599 elm_widget_show_region_get(obj, &x, &y, &w, &h);
600 //x & y are screen coordinates, Add with pan coordinates
603 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
607 _translate_hook(Evas_Object *obj)
609 evas_object_smart_callback_call(obj, "language,changed", NULL);
613 _sizing_eval(Evas_Object *obj)
615 Widget_Data *wd = elm_widget_data_get(obj);
616 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
618 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
619 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
621 if (wd->height_for_width)
625 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
626 if ((vw != 0) && (vw != wd->prev_viewport_w))
630 wd->prev_viewport_w = vw;
631 EINA_INLIST_FOREACH(wd->blocks, itb)
633 itb->must_recalc = EINA_TRUE;
635 if (wd->calc_job) ecore_job_del(wd->calc_job);
636 wd->calc_job = ecore_job_add(_calc_job, wd);
639 if (wd->mode == ELM_LIST_LIMIT)
645 elm_smart_scroller_child_viewport_size_get(wd->scr, &vmw, &vmh);
646 edje_object_size_min_calc
647 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
654 edje_object_size_min_calc
655 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
659 evas_object_size_hint_min_set(obj, minw, minh);
660 evas_object_size_hint_max_set(obj, maxw, maxh);
664 _signal_emit_hook(Evas_Object *obj,
665 const char *emission,
668 Widget_Data *wd = elm_widget_data_get(obj);
669 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
674 _item_highlight(Elm_Gen_Item *it)
676 const char *selectraise;
677 if ((it->wd->no_select) || (it->generation < it->wd->generation) ||
678 (it->highlighted) || elm_widget_item_disabled_get(it) ||
679 (it->display_only) || (it->item->mode_view))
681 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
682 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
683 selectraise = edje_object_data_get(VIEW(it), "selectraise");
684 if ((selectraise) && (!strcmp(selectraise, "on")))
686 if (it->edit_obj) evas_object_raise(it->edit_obj);
687 else evas_object_raise(VIEW(it));
688 if ((it->item->group_item) && (it->item->group_item->realized))
689 evas_object_raise(it->item->VIEW(group_item));
691 it->highlighted = EINA_TRUE;
695 _item_unhighlight(Elm_Gen_Item *it)
697 if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
698 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
699 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
700 if (!it->item->nostacking)
702 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
704 if (it->edit_obj) evas_object_lower(it->edit_obj);
705 else evas_object_lower(VIEW(it));
709 if (it->edit_obj) evas_object_raise(it->edit_obj);
710 else evas_object_raise(VIEW(it));
713 it->highlighted = EINA_FALSE;
717 _item_block_position_update(Eina_Inlist *list, int idx)
721 EINA_INLIST_FOREACH(list, tmp)
723 tmp->position = idx++;
724 tmp->position_update = EINA_TRUE;
729 _item_position_update(Eina_List *list, int idx)
734 EINA_LIST_FOREACH(list, l, it)
736 it->position = idx++;
737 it->position_update = EINA_TRUE;
742 _item_block_del(Elm_Gen_Item *it)
745 Item_Block *itb = it->item->block;
747 itb->items = eina_list_remove(itb->items, it);
749 itb->changed = EINA_TRUE;
750 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
751 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
754 il = EINA_INLIST_GET(itb);
755 Item_Block *itbn = (Item_Block *)(il->next);
757 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
760 _item_block_position_update(il->next, itb->position);
761 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
764 if (itbn) itbn->changed = EINA_TRUE;
768 if (itb->count < itb->wd->max_items_per_block/2)
770 il = EINA_INLIST_GET(itb);
771 Item_Block *itbp = (Item_Block *)(il->prev);
772 Item_Block *itbn = (Item_Block *)(il->next);
773 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
777 EINA_LIST_FREE(itb->items, it2)
779 it2->item->block = itbp;
780 itbp->items = eina_list_append(itbp->items, it2);
782 itbp->changed = EINA_TRUE;
784 _item_block_position_update(EINA_INLIST_GET(itb)->next,
786 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
787 EINA_INLIST_GET(itb));
790 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
794 Eina_List *last = eina_list_last(itb->items);
795 Elm_Gen_Item *it2 = last->data;
797 it2->item->block = itbn;
798 itb->items = eina_list_remove_list(itb->items, last);
799 itbn->items = eina_list_prepend(itbn->items, it2);
801 itbn->changed = EINA_TRUE;
803 _item_block_position_update(EINA_INLIST_GET(itb)->next,
806 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
814 _item_del(Elm_Gen_Item *it)
816 Evas_Object *obj = WIDGET(it);
818 evas_event_freeze(evas_object_evas_get(obj));
819 elm_genlist_item_subitems_clear((Elm_Object_Item *) it);
820 if (it->wd->show_item == it) it->wd->show_item = NULL;
821 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
822 if (it->item->edit_mode_item_realized) _edit_mode_item_unrealize(it);
823 if (it->item->block) _item_block_del(it);
824 if (it->item->queued)
825 it->wd->queue = eina_list_remove(it->wd->queue, it);
826 if (it->wd->anchor_item == it)
828 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
829 if (!it->wd->anchor_item)
830 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
832 if (it->wd->expanded_item == it) it->wd->expanded_item = NULL;
834 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
835 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
836 _elm_genlist_item_del_serious(it);
837 elm_genlist_item_class_unref((Elm_Genlist_Item_Class *)it->itc);
838 evas_event_thaw(evas_object_evas_get(obj));
839 evas_event_thaw_eval(evas_object_evas_get(obj));
843 _clear_cb(Widget_Data *wd)
845 wd->anchor_item = NULL;
848 Item_Block *itb = (Item_Block *)(wd->blocks);
850 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
851 if (itb->items) eina_list_free(itb->items);
854 if (wd->queue_idle_enterer)
856 ecore_idle_enterer_del(wd->queue_idle_enterer);
857 wd->queue_idle_enterer = NULL;
859 if (wd->must_recalc_idler)
861 ecore_idler_del(wd->must_recalc_idler);
862 wd->must_recalc_idler = NULL;
864 if (wd->queue) wd->queue = eina_list_free(wd->queue);
865 if (wd->reorder_move_animator)
867 ecore_animator_del(wd->reorder_move_animator);
868 wd->reorder_move_animator = NULL;
870 wd->show_item = NULL;
871 wd->reorder_old_pan_y = 0;
875 _item_unselect(Elm_Gen_Item *it)
877 if ((it->generation < it->wd->generation) || (!it->selected)) return;
878 it->selected = EINA_FALSE;
879 it->wd->selected = eina_list_remove(it->wd->selected, it);
880 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
884 _mouse_move(void *data,
885 Evas *evas __UNUSED__,
889 Elm_Gen_Item *it = data;
890 Evas_Event_Mouse_Move *ev = event_info;
891 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
892 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
894 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
896 if (!it->wd->on_hold)
898 it->wd->on_hold = EINA_TRUE;
899 if (!it->wd->wasselected)
901 _item_unhighlight(it);
906 if (it->wd->multitouched)
908 it->wd->cur_x = ev->cur.canvas.x;
909 it->wd->cur_y = ev->cur.canvas.y;
912 if ((it->dragging) && (it->down))
914 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
917 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
918 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
919 if (abs((it->wd->history[it->wd->movements].x -
920 it->wd->history[0].x)) > 40)
921 it->wd->swipe = EINA_TRUE;
927 ecore_timer_del(it->long_timer);
928 it->long_timer = NULL;
930 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
933 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
937 ecore_timer_del(it->long_timer);
938 it->long_timer = NULL;
940 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
942 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
943 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
945 if (!it->wd->reorder_start_y)
946 it->wd->reorder_start_y = it->item->block->y + it->y;
950 else if (it_scrl_y + it->wd->reorder_it->item->h > oy + oh)
951 y_pos = oy + oh - it->wd->reorder_it->item->h;
956 _item_position(it, it->edit_obj, it->item->scrl_x, y_pos);
958 _item_position(it, VIEW(it), it->item->scrl_x, y_pos);
960 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
961 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
965 if (!it->display_only)
966 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
967 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
968 x = ev->cur.canvas.x - x;
969 y = ev->cur.canvas.y - y;
972 if (adx < 0) adx = -dx;
975 if (ady < 0) ady = -dy;
978 if ((adx > minw) || (ady > minh))
980 it->dragging = EINA_TRUE;
983 ecore_timer_del(it->long_timer);
984 it->long_timer = NULL;
986 if (!it->wd->wasselected)
988 _item_unhighlight(it);
994 evas_object_smart_callback_call(WIDGET(it),
995 SIG_DRAG_START_UP, it);
999 evas_object_smart_callback_call(WIDGET(it),
1000 SIG_DRAG_START_LEFT, it);
1002 evas_object_smart_callback_call(WIDGET(it),
1003 SIG_DRAG_START_RIGHT, it);
1009 evas_object_smart_callback_call(WIDGET(it),
1010 SIG_DRAG_START_DOWN, it);
1014 evas_object_smart_callback_call(WIDGET(it),
1015 SIG_DRAG_START_LEFT, it);
1017 evas_object_smart_callback_call(WIDGET(it),
1018 SIG_DRAG_START_RIGHT, it);
1025 _long_press(void *data)
1027 Elm_Gen_Item *it = data, *it_tmp;
1028 Eina_List *list, *l;
1030 it->long_timer = NULL;
1031 if (elm_widget_item_disabled_get(it) || (it->dragging) || (it->display_only))
1032 return ECORE_CALLBACK_CANCEL;
1033 it->wd->longpressed = EINA_TRUE;
1034 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
1035 if ((it->wd->reorder_mode) && (!it->group))
1037 it->wd->reorder_it = it;
1038 it->wd->reorder_start_y = 0;
1040 evas_object_raise(it->edit_obj);
1042 evas_object_raise(VIEW(it));
1044 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1045 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1047 list = elm_genlist_realized_items_get(it->wd->obj);
1048 EINA_LIST_FOREACH(list, l, it_tmp)
1050 if (it != it_tmp) _item_unselect(it_tmp);
1052 if (elm_genlist_item_expanded_get((Elm_Object_Item *) it))
1054 elm_genlist_item_expanded_set((Elm_Object_Item *) it, EINA_FALSE);
1055 return ECORE_CALLBACK_RENEW;
1058 if (!it->wd->edit_mode)
1059 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
1061 return ECORE_CALLBACK_CANCEL;
1065 _swipe(Elm_Gen_Item *it)
1070 if ((it->display_only) || elm_widget_item_disabled_get(it)) return;
1071 it->wd->swipe = EINA_FALSE;
1072 for (i = 0; i < it->wd->movements; i++)
1074 sum += it->wd->history[i].x;
1075 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1078 sum /= it->wd->movements;
1079 if (abs(sum - it->wd->history[0].x) <= 10) return;
1080 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
1084 _swipe_cancel(void *data)
1086 Elm_Gen_Item *it = data;
1088 if (!it) return ECORE_CALLBACK_CANCEL;
1089 it->wd->swipe = EINA_FALSE;
1090 it->wd->movements = 0;
1091 return ECORE_CALLBACK_RENEW;
1095 _multi_cancel(void *data)
1097 Widget_Data *wd = data;
1099 if (!wd) return ECORE_CALLBACK_CANCEL;
1100 wd->multi_timeout = EINA_TRUE;
1101 return ECORE_CALLBACK_RENEW;
1105 _multi_touch_gesture_eval(void *data)
1107 Elm_Gen_Item *it = data;
1109 it->wd->multitouched = EINA_FALSE;
1110 if (it->wd->multi_timer)
1112 ecore_timer_del(it->wd->multi_timer);
1113 it->wd->multi_timer = NULL;
1115 if (it->wd->multi_timeout)
1117 it->wd->multi_timeout = EINA_FALSE;
1121 Evas_Coord minw = 0, minh = 0;
1122 Evas_Coord off_x, off_y, off_mx, off_my;
1124 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1125 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1126 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1127 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1128 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1130 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1132 if ((off_x + off_mx) > (off_y + off_my))
1134 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1135 evas_object_smart_callback_call(WIDGET(it),
1136 SIG_MULTI_SWIPE_RIGHT, it);
1137 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1138 evas_object_smart_callback_call(WIDGET(it),
1139 SIG_MULTI_SWIPE_LEFT, it);
1140 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1141 evas_object_smart_callback_call(WIDGET(it),
1142 SIG_MULTI_PINCH_OUT, it);
1144 evas_object_smart_callback_call(WIDGET(it),
1145 SIG_MULTI_PINCH_IN, it);
1149 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1150 evas_object_smart_callback_call(WIDGET(it),
1151 SIG_MULTI_SWIPE_DOWN, it);
1152 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1153 evas_object_smart_callback_call(WIDGET(it),
1154 SIG_MULTI_SWIPE_UP, it);
1155 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1156 evas_object_smart_callback_call(WIDGET(it),
1157 SIG_MULTI_PINCH_OUT, it);
1159 evas_object_smart_callback_call(WIDGET(it),
1160 SIG_MULTI_PINCH_IN, it);
1163 it->wd->multi_timeout = EINA_FALSE;
1167 _multi_down(void *data,
1168 Evas *evas __UNUSED__,
1169 Evas_Object *obj __UNUSED__,
1172 Elm_Gen_Item *it = data;
1173 Evas_Event_Multi_Down *ev = event_info;
1175 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1176 it->wd->multi_device = ev->device;
1177 it->wd->multi_down = EINA_TRUE;
1178 it->wd->multitouched = EINA_TRUE;
1179 it->wd->prev_mx = ev->canvas.x;
1180 it->wd->prev_my = ev->canvas.y;
1181 if (!it->wd->wasselected)
1183 _item_unhighlight(it);
1186 it->wd->wasselected = EINA_FALSE;
1187 it->wd->longpressed = EINA_FALSE;
1190 ecore_timer_del(it->long_timer);
1191 it->long_timer = NULL;
1195 it->dragging = EINA_FALSE;
1196 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1198 if (it->item->swipe_timer)
1200 ecore_timer_del(it->item->swipe_timer);
1201 it->item->swipe_timer = NULL;
1203 if (it->wd->on_hold)
1205 it->wd->swipe = EINA_FALSE;
1206 it->wd->movements = 0;
1207 it->wd->on_hold = EINA_FALSE;
1212 _multi_up(void *data,
1213 Evas *evas __UNUSED__,
1214 Evas_Object *obj __UNUSED__,
1217 Elm_Gen_Item *it = data;
1218 Evas_Event_Multi_Up *ev = event_info;
1220 if (it->wd->multi_device != ev->device) return;
1221 it->wd->multi_device = 0;
1222 it->wd->multi_down = EINA_FALSE;
1223 if (it->wd->mouse_down) return;
1224 _multi_touch_gesture_eval(data);
1228 _multi_move(void *data,
1229 Evas *evas __UNUSED__,
1230 Evas_Object *obj __UNUSED__,
1233 Elm_Gen_Item *it = data;
1234 Evas_Event_Multi_Move *ev = event_info;
1236 if (it->wd->multi_device != ev->device) return;
1237 it->wd->cur_mx = ev->cur.canvas.x;
1238 it->wd->cur_my = ev->cur.canvas.y;
1242 _mouse_down(void *data,
1243 Evas *evas __UNUSED__,
1247 Elm_Gen_Item *it = data;
1248 Evas_Event_Mouse_Down *ev = event_info;
1251 if (ev->button != 1) return;
1252 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1254 it->wd->on_hold = EINA_TRUE;
1257 it->down = EINA_TRUE;
1258 it->dragging = EINA_FALSE;
1259 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1260 it->dx = ev->canvas.x - x;
1261 it->dy = ev->canvas.y - y;
1262 it->wd->mouse_down = EINA_TRUE;
1263 if (!it->wd->multitouched)
1265 it->wd->prev_x = ev->canvas.x;
1266 it->wd->prev_y = ev->canvas.y;
1267 it->wd->multi_timeout = EINA_FALSE;
1268 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1269 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1271 it->wd->longpressed = EINA_FALSE;
1272 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1273 else it->wd->on_hold = EINA_FALSE;
1274 if (it->wd->on_hold) return;
1275 it->wd->wasselected = it->selected;
1276 _item_highlight(it);
1277 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1278 if ((!elm_widget_item_disabled_get(it)) && (!it->display_only))
1280 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1281 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
1283 if (it->long_timer) ecore_timer_del(it->long_timer);
1284 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
1285 it->item->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1287 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1290 it->long_timer = NULL;
1291 it->wd->swipe = EINA_FALSE;
1292 it->wd->movements = 0;
1296 _mouse_up(void *data,
1297 Evas *evas __UNUSED__,
1298 Evas_Object *obj __UNUSED__,
1301 Elm_Gen_Item *it = data;
1302 Evas_Event_Mouse_Up *ev = event_info;
1303 Eina_Bool dragged = EINA_FALSE;
1305 if (ev->button != 1) return;
1306 it->down = EINA_FALSE;
1307 it->wd->mouse_down = EINA_FALSE;
1308 if (it->wd->multitouched)
1310 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1311 if (it->wd->multi_down) return;
1312 _multi_touch_gesture_eval(data);
1315 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1316 else it->wd->on_hold = EINA_FALSE;
1319 ecore_timer_del(it->long_timer);
1320 it->long_timer = NULL;
1324 it->dragging = EINA_FALSE;
1325 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1328 if (it->item->swipe_timer)
1330 ecore_timer_del(it->item->swipe_timer);
1331 it->item->swipe_timer = NULL;
1333 if (it->wd->multi_timer)
1335 ecore_timer_del(it->wd->multi_timer);
1336 it->wd->multi_timer = NULL;
1337 it->wd->multi_timeout = EINA_FALSE;
1339 if (it->wd->on_hold)
1341 if (it->wd->swipe) _swipe(data);
1342 it->wd->longpressed = EINA_FALSE;
1343 it->wd->on_hold = EINA_FALSE;
1346 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1348 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1350 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1352 if (it_scrl_y <= it->wd->reorder_rel->item->scrl_y)
1353 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1355 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1359 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1360 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1362 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
1363 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1364 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1365 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
1367 if (it->wd->longpressed)
1369 it->wd->longpressed = EINA_FALSE;
1370 if (!it->wd->wasselected)
1372 _item_unhighlight(it);
1375 it->wd->wasselected = EINA_FALSE;
1380 if (it->want_unrealize)
1382 _elm_genlist_item_unrealize(it, EINA_FALSE);
1383 if (it->item->block->want_unrealize)
1384 _item_block_unrealize(it->item->block);
1387 if (elm_widget_item_disabled_get(it) || (dragged) || (it->display_only))
1389 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1394 _item_highlight(it);
1399 _item_unhighlight(it);
1407 Widget_Data *wd = it->wd;
1410 while (wd->selected)
1412 _item_unhighlight(wd->selected->data);
1413 _item_unselect(wd->selected->data);
1419 const Eina_List *l, *l_next;
1422 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1425 _item_unhighlight(it2);
1426 _item_unselect(it2);
1428 //_item_highlight(it);
1431 _item_highlight(it);
1437 _signal_expand_toggle(void *data,
1438 Evas_Object *obj __UNUSED__,
1439 const char *emission __UNUSED__,
1440 const char *source __UNUSED__)
1442 Elm_Gen_Item *it = data;
1444 if (it->item->expanded)
1445 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1447 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1451 _signal_expand(void *data,
1452 Evas_Object *obj __UNUSED__,
1453 const char *emission __UNUSED__,
1454 const char *source __UNUSED__)
1456 Elm_Gen_Item *it = data;
1458 if (!it->item->expanded)
1459 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1463 _signal_contract(void *data,
1464 Evas_Object *obj __UNUSED__,
1465 const char *emission __UNUSED__,
1466 const char *source __UNUSED__)
1468 Elm_Gen_Item *it = data;
1470 if (it->item->expanded)
1471 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1475 _scr_hold_timer_cb(void *data)
1477 if (!data) return ECORE_CALLBACK_CANCEL;
1478 Widget_Data *wd = data;
1479 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1480 wd->scr_hold_timer = NULL;
1481 return ECORE_CALLBACK_CANCEL;
1485 _mode_finished_signal_cb(void *data,
1487 const char *emission __UNUSED__,
1488 const char *source __UNUSED__)
1492 Elm_Gen_Item *it = data;
1493 if ((it->generation < it->wd->generation) || (!it->realized) || (!it->item->mode_view)) return;
1495 Evas *te = evas_object_evas_get(obj);
1497 evas_event_freeze(te);
1498 it->item->nocache = EINA_FALSE;
1499 _mode_item_unrealize(it);
1500 if (it->item->group_item)
1501 evas_object_raise(it->item->VIEW(group_item));
1502 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1503 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1504 evas_event_thaw(te);
1505 evas_event_thaw_eval(te);
1509 _item_cache_clean(Widget_Data *wd)
1511 evas_event_freeze(evas_object_evas_get(wd->obj));
1512 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1516 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1517 wd->item_cache = eina_inlist_remove(wd->item_cache,
1518 wd->item_cache->last);
1519 wd->item_cache_count--;
1520 if (itc->spacer) evas_object_del(itc->spacer);
1521 if (itc->base_view) evas_object_del(itc->base_view);
1522 eina_stringshare_del(itc->item_style);
1525 evas_event_thaw(evas_object_evas_get(wd->obj));
1526 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1530 _item_cache_zero(Widget_Data *wd)
1532 int pmax = wd->item_cache_max;
1533 wd->item_cache_max = 0;
1534 _item_cache_clean(wd);
1535 wd->item_cache_max = pmax;
1539 _item_cache_add(Elm_Gen_Item *it)
1543 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1544 if (it->wd->item_cache_max <= 0)
1546 evas_object_del(VIEW(it));
1548 evas_object_del(it->spacer);
1550 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1551 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1555 it->wd->item_cache_count++;
1556 itc = calloc(1, sizeof(Item_Cache));
1559 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1560 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1563 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1564 EINA_INLIST_GET(itc));
1565 itc->spacer = it->spacer;
1567 itc->base_view = VIEW(it);
1569 edje_object_signal_emit(itc->base_view, "elm,state,unselected", "elm");
1570 evas_object_hide(itc->base_view);
1571 evas_object_move(itc->base_view, -9999, -9999);
1572 itc->item_style = eina_stringshare_add(it->itc->item_style);
1573 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1574 itc->compress = (it->wd->compress);
1575 itc->selected = it->selected;
1576 itc->disabled = elm_widget_item_disabled_get(it);
1577 itc->expanded = it->item->expanded;
1580 ecore_timer_del(it->long_timer);
1581 it->long_timer = NULL;
1583 if (it->item->swipe_timer)
1585 ecore_timer_del(it->item->swipe_timer);
1586 it->item->swipe_timer = NULL;
1588 // FIXME: other callbacks?
1589 edje_object_signal_callback_del_full(itc->base_view,
1590 "elm,action,expand,toggle",
1591 "elm", _signal_expand_toggle, it);
1592 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1594 _signal_expand, it);
1595 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1596 "elm", _signal_contract, it);
1597 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1599 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1601 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1603 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1605 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1607 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1609 _item_cache_clean(it->wd);
1610 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1611 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1615 _item_cache_find(Elm_Gen_Item *it)
1620 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1621 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1623 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1625 if ((itc->tree == tree) &&
1626 (itc->compress == it->wd->compress) &&
1627 (((!it->itc->item_style) && (!itc->item_style)) ||
1628 (it->itc->item_style && itc->item_style &&
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 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 snprintf(buf, sizeof(buf), "tree%s/%s", it->wd->compress ? "_compress" : "", it->itc->item_style ?: "default");
1947 snprintf(buf, sizeof(buf), "item%s/%s", it->wd->compress ? "_compress" : "", it->itc->item_style ?: "default");
1949 _elm_theme_object_set(WIDGET(it), VIEW(it), "genlist", buf,
1950 elm_widget_style_get(WIDGET(it)));
1952 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
1953 if (!stacking_even) stacking_even = "above";
1954 it->item->stacking_even = !!strcmp("above", stacking_even);
1956 stacking = edje_object_data_get(VIEW(it), "stacking");
1957 if (!stacking) stacking = "yes";
1958 it->item->nostacking = !!strcmp("yes", stacking);
1960 edje_object_mirrored_set(VIEW(it),
1961 elm_widget_mirrored_get(WIDGET(it)));
1963 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1964 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1965 elm_widget_sub_object_add(WIDGET(it), it->spacer);
1968 _elm_genlist_item_odd_even_update(it);
1970 treesize = edje_object_data_get(VIEW(it), "treesize");
1971 if (treesize) tsize = atoi(treesize);
1972 evas_object_size_hint_min_set(it->spacer,
1973 (it->item->expanded_depth * tsize) * _elm_config->scale, 1);
1974 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
1977 edje_object_signal_callback_add(VIEW(it),
1978 "elm,action,expand,toggle",
1979 "elm", _signal_expand_toggle, it);
1980 edje_object_signal_callback_add(VIEW(it), "elm,action,expand",
1981 "elm", _signal_expand, it);
1982 edje_object_signal_callback_add(VIEW(it), "elm,action,contract",
1983 "elm", _signal_contract, it);
1984 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1986 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1988 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1990 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_DOWN,
1992 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_UP,
1994 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_MOVE,
1997 if ((it->wd->edit_mode) && (!it->edit_obj) &&
1998 (it->item->flags != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
1999 _edit_mode_item_realize(it, EINA_FALSE);
2001 _elm_genlist_item_state_update(it, itc);
2002 _elm_genlist_item_index_update(it);
2005 if ((calc) && (it->wd->homogeneous) &&
2006 ((it->wd->item_width) ||
2007 ((it->wd->item_width) && (it->wd->group_item_width))))
2009 /* homogenous genlist shortcut */
2010 if (!it->item->mincalcd)
2014 it->item->w = it->item->minw = it->wd->group_item_width;
2015 it->item->h = it->item->minh = it->wd->group_item_height;
2019 it->item->w = it->item->minw = it->wd->item_width;
2020 it->item->h = it->item->minh = it->wd->item_height;
2022 it->item->mincalcd = EINA_TRUE;
2027 /* FIXME: If you see that assert, please notify us and we
2028 will clean our mess */
2029 assert(eina_list_count(it->content_objs) == 0);
2031 _item_text_realize(it, VIEW(it), &it->texts, NULL);
2032 it->content_objs = _item_content_realize(it, VIEW(it), &it->contents, NULL);
2033 _item_state_realize(it, VIEW(it), &it->states, NULL);
2035 if (!it->item->mincalcd)
2037 Evas_Coord mw = -1, mh = -1;
2039 if (!it->display_only)
2040 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2041 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2042 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
2044 if (!it->display_only)
2045 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2046 it->item->w = it->item->minw = mw;
2047 it->item->h = it->item->minh = mh;
2048 it->item->mincalcd = EINA_TRUE;
2050 if ((!it->wd->group_item_width) && (it->group))
2052 it->wd->group_item_width = mw;
2053 it->wd->group_item_height = mh;
2055 else if ((!it->wd->item_width) && (it->item->flags == ELM_GENLIST_ITEM_NONE))
2057 it->wd->item_width = mw;
2058 it->wd->item_height = mh;
2061 if (!calc) evas_object_show(VIEW(it));
2064 if (it->tooltip.content_cb)
2066 elm_widget_item_tooltip_content_cb_set(it,
2067 it->tooltip.content_cb,
2068 it->tooltip.data, NULL);
2069 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2070 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
2073 if (it->mouse_cursor)
2074 elm_widget_item_cursor_set(it, it->mouse_cursor);
2076 it->realized = EINA_TRUE;
2077 it->want_unrealize = EINA_FALSE;
2079 if (itc) _item_cache_free(itc);
2080 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
2081 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2083 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
2085 if ((!calc) && (it->wd->edit_mode) && (it->item->flags != ELM_GENLIST_ITEM_GROUP))
2087 if (it->itc->edit_item_style)
2089 if (!it->edit_obj) _edit_mode_item_realize(it, EINA_FALSE);
2090 edje_object_message_signal_process(it->edit_obj);
2093 edje_object_message_signal_process(VIEW(it));
2097 _item_unrealize_cb(Elm_Gen_Item *it)
2099 if (it->item->nocache)
2101 evas_object_del(VIEW(it));
2103 evas_object_del(it->spacer);
2108 edje_object_mirrored_set(VIEW(it),
2109 elm_widget_mirrored_get(WIDGET(it)));
2110 edje_object_scale_set(VIEW(it),
2111 elm_widget_scale_get(WIDGET(it))
2112 * _elm_config->scale);
2113 _item_cache_add(it);
2116 _mode_item_unrealize(it);
2118 it->realized = EINA_FALSE;
2119 it->want_unrealize = EINA_FALSE;
2120 if (it->wd->edit_mode) _edit_mode_item_unrealize(it);
2124 _item_block_recalc(Item_Block *itb,
2130 Evas_Coord minw = 0, minh = 0;
2131 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2134 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2136 EINA_LIST_FOREACH(itb->items, l, it)
2138 if (it->generation < it->wd->generation) continue;
2139 showme |= it->item->showme;
2144 if (!it->item->mincalcd) changed = EINA_TRUE;
2147 _item_realize(it, in, EINA_TRUE);
2148 _elm_genlist_item_unrealize(it, EINA_TRUE);
2153 _item_realize(it, in, EINA_TRUE);
2154 _elm_genlist_item_unrealize(it, EINA_TRUE);
2158 _item_realize(it, in, EINA_FALSE);
2159 minh += it->item->minh;
2160 if (minw < it->item->minw) minw = it->item->minw;
2168 itb->changed = EINA_FALSE;
2169 itb->position_update = EINA_FALSE;
2170 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2171 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2176 _item_block_realize(Item_Block *itb)
2178 if (itb->realized) return;
2179 itb->realized = EINA_TRUE;
2180 itb->want_unrealize = EINA_FALSE;
2184 _item_block_unrealize(Item_Block *itb)
2188 Eina_Bool dragging = EINA_FALSE;
2190 if (!itb->realized) return;
2191 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2192 EINA_LIST_FOREACH(itb->items, l, it)
2194 if (itb->must_recalc || !it->group)
2198 dragging = EINA_TRUE;
2199 it->want_unrealize = EINA_TRUE;
2202 _elm_genlist_item_unrealize(it, EINA_FALSE);
2207 itb->realized = EINA_FALSE;
2208 itb->want_unrealize = EINA_TRUE;
2211 itb->want_unrealize = EINA_FALSE;
2212 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2213 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2217 _get_space_for_reorder_item(Elm_Gen_Item *it)
2219 Evas_Coord rox, roy, row, roh, oy, oh;
2220 Eina_Bool top = EINA_FALSE;
2221 Elm_Gen_Item *reorder_it = it->wd->reorder_it;
2222 if (!reorder_it) return 0;
2224 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2225 evas_object_geometry_get(it->wd->VIEW(reorder_it), &rox, &roy, &row, &roh);
2227 if ((it->wd->reorder_start_y < it->item->block->y) &&
2228 (roy - oy + (roh / 2) >= it->item->block->y - it->wd->pan_y))
2230 it->item->block->reorder_offset = it->wd->reorder_it->item->h * -1;
2231 if (it->item->block->count == 1)
2232 it->wd->reorder_rel = it;
2234 else if ((it->wd->reorder_start_y >= it->item->block->y) &&
2235 (roy - oy + (roh / 2) <= it->item->block->y - it->wd->pan_y))
2237 it->item->block->reorder_offset = it->wd->reorder_it->item->h;
2240 it->item->block->reorder_offset = 0;
2242 it->item->scrl_y += it->item->block->reorder_offset;
2244 top = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2245 rox, roy + (roh / 2), row, 1));
2248 it->wd->reorder_rel = it;
2249 it->item->scrl_y += it->wd->reorder_it->item->h;
2250 return it->wd->reorder_it->item->h;
2257 _reorder_move_animator_cb(void *data)
2259 Elm_Gen_Item *it = data;
2260 Eina_Bool down = EINA_FALSE;
2262 int y, dy = it->item->h / 10 * _elm_config->scale, diff;
2264 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2266 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2269 diff = abs(it->item->old_scrl_y - it->item->scrl_y);
2270 if (diff > it->item->h) y = diff / 2;
2272 if (it->item->old_scrl_y < it->item->scrl_y)
2274 it->item->old_scrl_y += y;
2277 else if (it->item->old_scrl_y > it->item->scrl_y)
2279 it->item->old_scrl_y -= y;
2284 _item_position(it, it->edit_obj, it->item->scrl_x, it->item->old_scrl_y);
2286 _item_position(it, VIEW(it), it->item->scrl_x, it->item->old_scrl_y);
2287 _group_items_recalc(it->wd);
2289 if ((it->wd->reorder_pan_move) ||
2290 (down && it->item->old_scrl_y >= it->item->scrl_y) ||
2291 (!down && it->item->old_scrl_y <= it->item->scrl_y))
2293 it->item->old_scrl_y = it->item->scrl_y;
2294 it->item->move_effect_enabled = EINA_FALSE;
2295 it->wd->reorder_move_animator = NULL;
2296 return ECORE_CALLBACK_CANCEL;
2298 return ECORE_CALLBACK_RENEW;
2302 _item_position(Elm_Gen_Item *it,
2310 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2311 evas_object_resize(view, it->item->w, it->item->h);
2312 evas_object_move(view, it_x, it_y);
2313 evas_object_show(view);
2314 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2315 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2319 _item_block_position(Item_Block *itb,
2325 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2326 Eina_Bool vis = EINA_FALSE;
2328 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2329 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2330 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2332 EINA_LIST_FOREACH(itb->items, l, it)
2334 if (it->generation < it->wd->generation) continue;
2335 else if (it->wd->reorder_it == it) continue;
2338 it->item->w = itb->w;
2339 it->item->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2340 it->item->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2342 vis = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2343 cvx, cvy, cvw, cvh));
2346 if ((itb->realized) && (!it->realized))
2348 if (vis) _item_realize(it, in, EINA_FALSE);
2354 if (it->wd->reorder_mode)
2355 y += _get_space_for_reorder_item(it);
2356 git = it->item->group_item;
2359 if (git->item->scrl_y < oy)
2360 git->item->scrl_y = oy;
2361 if ((git->item->scrl_y + git->item->h) > (it->item->scrl_y + it->item->h))
2362 git->item->scrl_y = (it->item->scrl_y + it->item->h) - git->item->h;
2363 git->item->want_realize = EINA_TRUE;
2365 if ((it->wd->reorder_it) && (it->item->old_scrl_y != it->item->scrl_y))
2367 if (!it->item->move_effect_enabled)
2369 it->item->move_effect_enabled = EINA_TRUE;
2370 it->wd->reorder_move_animator =
2372 _reorder_move_animator_cb, it);
2375 if (!it->item->move_effect_enabled)
2377 if ((it->wd->edit_mode) && (it->itc->edit_item_style))
2378 _edit_mode_item_position(it, it->item->scrl_x,
2382 if (it->item->mode_view)
2383 _item_position(it, it->item->mode_view,
2387 _item_position(it, VIEW(it), it->item->scrl_x,
2390 it->item->old_scrl_y = it->item->scrl_y;
2395 if (!it->dragging) _elm_genlist_item_unrealize(it, EINA_FALSE);
2402 if (vis) it->item->want_realize = EINA_TRUE;
2406 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2407 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2411 _group_items_recalc(void *data)
2413 Widget_Data *wd = data;
2417 evas_event_freeze(evas_object_evas_get(wd->obj));
2418 EINA_LIST_FOREACH(wd->group_items, l, git)
2420 if (git->item->want_realize)
2423 _item_realize(git, 0, EINA_FALSE);
2424 evas_object_resize(VIEW(git), wd->minw, git->item->h);
2425 evas_object_move(VIEW(git), git->item->scrl_x, git->item->scrl_y);
2426 evas_object_show(VIEW(git));
2427 evas_object_raise(VIEW(git));
2429 else if (!git->item->want_realize && git->realized)
2432 _elm_genlist_item_unrealize(git, EINA_FALSE);
2435 evas_event_thaw(evas_object_evas_get(wd->obj));
2436 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2440 _must_recalc_idler(void *data)
2442 Widget_Data *wd = data;
2443 if (wd->calc_job) ecore_job_del(wd->calc_job);
2444 wd->calc_job = ecore_job_add(_calc_job, wd);
2445 wd->must_recalc_idler = NULL;
2446 return ECORE_CALLBACK_CANCEL;
2450 _scroll_item(Widget_Data *wd)
2452 Elm_Gen_Item *it = NULL;
2453 Evas_Coord gith = 0;
2454 Evas_Coord ow, oh, dx = 0, dy = 0, dw = 0, dh = 0;
2456 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
2458 dx = it->x + it->item->block->x;
2459 dy = it->y + it->item->block->y;
2460 dw = it->item->block->w;
2462 switch (wd->scrollto_type)
2464 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
2465 if (it->item->group_item) gith = it->item->group_item->item->h;
2468 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
2469 dy += (it->item->h / 2 - oh / 2);
2471 case ELM_GENLIST_ITEM_SCROLLTO_IN:
2473 if ((wd->expanded_item) &&
2474 ((wd->show_item->y + wd->show_item->item->block->y + wd->show_item->item->h)
2475 - (wd->expanded_item->y + wd->expanded_item->item->block->y) > oh))
2477 it = wd->expanded_item;
2478 if (it->item->group_item) gith = it->item->group_item->item->h;
2479 dx = it->x + it->item->block->x;
2480 dy = it->y + it->item->block->y - gith;
2481 dw = it->item->block->w;
2485 if ((it->item->group_item) && (wd->pan_y > (it->y + it->item->block->y)))
2486 gith = it->item->group_item->item->h;
2493 elm_smart_scroller_region_bring_in(wd->scr, dx, dy, dw, dh);
2495 elm_smart_scroller_child_region_show(wd->scr, dx, dy, dw, dh);
2497 it->item->showme = EINA_FALSE;
2498 wd->show_item = NULL;
2499 wd->auto_scroll_enabled = EINA_FALSE;
2500 wd->check_scroll = EINA_FALSE;
2504 _calc_job(void *data)
2506 Widget_Data *wd = data;
2507 Item_Block *itb, *chb = NULL;
2508 Evas_Coord minw = -1, minh = 0, y = 0, ow, dy = 0, vw;
2509 Evas_Coord pan_w = 0, pan_h = 0;
2511 Eina_Bool minw_change = EINA_FALSE;
2512 Eina_Bool did_must_recalc = EINA_FALSE;
2515 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2516 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, NULL);
2521 evas_event_freeze(evas_object_evas_get(wd->obj));
2522 EINA_INLIST_FOREACH(wd->blocks, itb)
2524 Eina_Bool showme = EINA_FALSE;
2527 showme = itb->showme;
2528 itb->showme = EINA_FALSE;
2531 if (itb->realized) _item_block_unrealize(itb);
2533 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2535 if (itb->must_recalc)
2539 EINA_LIST_FOREACH(itb->items, l, it)
2540 if (it->item->mincalcd) it->item->mincalcd = EINA_FALSE;
2541 itb->changed = EINA_TRUE;
2542 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2543 if (itb->realized) _item_block_unrealize(itb);
2544 itb->must_recalc = EINA_FALSE;
2546 showme = _item_block_recalc(itb, in, EINA_FALSE);
2552 if (minw == -1) minw = itb->minw;
2553 else if ((!itb->must_recalc) && (minw < itb->minw))
2556 minw_change = EINA_TRUE;
2561 minw_change = EINA_TRUE;
2567 if ((showme) && (wd->show_item) && (!wd->show_item->item->queued))
2568 wd->check_scroll = EINA_TRUE;
2572 EINA_INLIST_FOREACH(wd->blocks, itb)
2578 if ((chb) && (EINA_INLIST_GET(chb)->next))
2580 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2582 if (itb->realized) _item_block_unrealize(itb);
2585 wd->realminw = minw;
2586 if (minw < wd->w) minw = wd->w;
2587 if ((minw != wd->minw) || (minh != wd->minh))
2591 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2592 _sizing_eval(wd->obj);
2593 if ((wd->anchor_item) && (wd->anchor_item->item->block) && (!wd->auto_scroll_enabled))
2598 it = wd->anchor_item;
2599 it_y = wd->anchor_y;
2600 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2601 it->item->block->y + it->y + it_y);
2602 wd->anchor_item = it;
2603 wd->anchor_y = it_y;
2606 if (did_must_recalc)
2608 if (!wd->must_recalc_idler)
2609 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2611 if (wd->check_scroll)
2613 _pan_child_size_get(wd->pan_smart, &pan_w, &pan_h);
2614 if (EINA_INLIST_GET(wd->show_item) == wd->items->last)
2615 wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
2616 switch (wd->scrollto_type)
2618 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
2621 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
2624 case ELM_GENLIST_ITEM_SCROLLTO_IN:
2629 if ((pan_w > (wd->show_item->x + wd->show_item->item->block->x)) &&
2630 (pan_h > (wd->show_item->y + wd->show_item->item->block->y + dy)))
2635 wd->calc_job = NULL;
2636 evas_object_smart_changed(wd->pan_smart);
2637 evas_event_thaw(evas_object_evas_get(wd->obj));
2638 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2642 _update_job(void *data)
2644 Widget_Data *wd = data;
2648 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2650 wd->update_job = NULL;
2653 evas_event_freeze(evas_object_evas_get(wd->obj));
2654 EINA_INLIST_FOREACH(wd->blocks, itb)
2656 Evas_Coord itminw, itminh;
2663 _item_block_position(itb, num);
2667 recalc = EINA_FALSE;
2668 EINA_LIST_FOREACH(itb->items, l2, it)
2670 if (it->item->updateme)
2672 itminw = it->item->minw;
2673 itminh = it->item->minh;
2675 it->item->updateme = EINA_FALSE;
2678 _elm_genlist_item_unrealize(it, EINA_FALSE);
2679 _item_realize(it, num, EINA_FALSE);
2680 position = EINA_TRUE;
2684 _item_realize(it, num, EINA_TRUE);
2685 _elm_genlist_item_unrealize(it, EINA_TRUE);
2687 if ((it->item->minw != itminw) || (it->item->minh != itminh))
2692 itb->updateme = EINA_FALSE;
2695 position = EINA_TRUE;
2696 itb->changed = EINA_TRUE;
2697 _item_block_recalc(itb, num0, EINA_FALSE);
2698 _item_block_position(itb, num0);
2703 if (wd->calc_job) ecore_job_del(wd->calc_job);
2704 wd->calc_job = ecore_job_add(_calc_job, wd);
2706 evas_event_thaw(evas_object_evas_get(wd->obj));
2707 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2711 _pan_set(Evas_Object *obj,
2715 Pan *sd = evas_object_smart_data_get(obj);
2719 // Evas_Coord ow, oh;
2720 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2721 // ow = sd->wd->minw - ow;
2722 // if (ow < 0) ow = 0;
2723 // oh = sd->wd->minh - oh;
2724 // if (oh < 0) oh = 0;
2725 // if (x < 0) x = 0;
2726 // if (y < 0) y = 0;
2727 // if (x > ow) x = ow;
2728 // if (y > oh) y = oh;
2729 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2733 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2735 if ((itb->y + itb->h) > y)
2740 EINA_LIST_FOREACH(itb->items, l2, it)
2742 if ((itb->y + it->y) >= y)
2744 sd->wd->anchor_item = it;
2745 sd->wd->anchor_y = -(itb->y + it->y - y);
2752 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2756 _pan_get(Evas_Object *obj,
2760 Pan *sd = evas_object_smart_data_get(obj);
2763 if (x) *x = sd->wd->pan_x;
2764 if (y) *y = sd->wd->pan_y;
2768 _pan_max_get(Evas_Object *obj,
2772 Pan *sd = evas_object_smart_data_get(obj);
2776 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2777 ow = sd->wd->minw - ow;
2779 oh = sd->wd->minh - oh;
2786 _pan_min_get(Evas_Object *obj __UNUSED__,
2795 _pan_child_size_get(Evas_Object *obj,
2799 Pan *sd = evas_object_smart_data_get(obj);
2802 if (w) *w = sd->wd->minw;
2803 if (h) *h = sd->wd->minh;
2807 _pan_add(Evas_Object *obj)
2810 Evas_Object_Smart_Clipped_Data *cd;
2813 cd = evas_object_smart_data_get(obj);
2816 sd->__clipped_data = *cd;
2818 evas_object_smart_data_set(obj, sd);
2822 _pan_del(Evas_Object *obj)
2824 Pan *sd = evas_object_smart_data_get(obj);
2829 ecore_job_del(sd->resize_job);
2830 sd->resize_job = NULL;
2836 _pan_resize_job(void *data)
2840 _sizing_eval(sd->wd->obj);
2841 sd->resize_job = NULL;
2845 _pan_resize(Evas_Object *obj,
2849 Pan *sd = evas_object_smart_data_get(obj);
2853 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2854 if ((ow == w) && (oh == h)) return;
2855 if ((sd->wd->height_for_width) && (ow != w))
2858 if (sd->resize_job) ecore_job_del(sd->resize_job);
2859 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2861 sd->wd->pan_changed = EINA_TRUE;
2862 evas_object_smart_changed(obj);
2863 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2864 sd->wd->calc_job = NULL;
2866 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2867 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2872 _pan_calculate(Evas_Object *obj)
2874 Pan *sd = evas_object_smart_data_get(obj);
2876 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2882 evas_event_freeze(evas_object_evas_get(obj));
2884 if (sd->wd->pan_changed)
2887 sd->wd->pan_changed = EINA_FALSE;
2890 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2891 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2892 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2894 git->item->want_realize = EINA_FALSE;
2896 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2898 itb->w = sd->wd->minw;
2899 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2900 itb->y - sd->wd->pan_y + oy,
2902 cvx, cvy, cvw, cvh))
2904 if ((!itb->realized) || (itb->changed))
2905 _item_block_realize(itb);
2906 _item_block_position(itb, in);
2910 if (itb->realized) _item_block_unrealize(itb);
2914 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2915 _group_items_recalc(sd->wd);
2916 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2918 if (sd->wd->pan_y != sd->wd->reorder_old_pan_y)
2919 sd->wd->reorder_pan_move = EINA_TRUE;
2920 else sd->wd->reorder_pan_move = EINA_FALSE;
2921 evas_object_raise(sd->wd->VIEW(reorder_it));
2922 sd->wd->reorder_old_pan_y = sd->wd->pan_y;
2923 sd->wd->start_time = ecore_loop_time_get();
2925 _item_auto_scroll(sd->wd);
2926 evas_event_thaw(evas_object_evas_get(obj));
2927 evas_event_thaw_eval(evas_object_evas_get(obj));
2931 _pan_move(Evas_Object *obj,
2932 Evas_Coord x __UNUSED__,
2933 Evas_Coord y __UNUSED__)
2935 Pan *sd = evas_object_smart_data_get(obj);
2939 sd->wd->pan_changed = EINA_TRUE;
2940 evas_object_smart_changed(obj);
2941 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2942 sd->wd->calc_job = NULL;
2946 _hold_on(void *data __UNUSED__,
2948 void *event_info __UNUSED__)
2950 Widget_Data *wd = elm_widget_data_get(obj);
2952 elm_smart_scroller_hold_set(wd->scr, 1);
2956 _hold_off(void *data __UNUSED__,
2958 void *event_info __UNUSED__)
2960 Widget_Data *wd = elm_widget_data_get(obj);
2962 elm_smart_scroller_hold_set(wd->scr, 0);
2966 _freeze_on(void *data __UNUSED__,
2968 void *event_info __UNUSED__)
2970 Widget_Data *wd = elm_widget_data_get(obj);
2972 elm_smart_scroller_freeze_set(wd->scr, 1);
2976 _freeze_off(void *data __UNUSED__,
2978 void *event_info __UNUSED__)
2980 Widget_Data *wd = elm_widget_data_get(obj);
2982 elm_smart_scroller_freeze_set(wd->scr, 0);
2986 _scr_anim_start(void *data,
2987 Evas_Object *obj __UNUSED__,
2988 void *event_info __UNUSED__)
2990 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
2994 _scr_anim_stop(void *data,
2995 Evas_Object *obj __UNUSED__,
2996 void *event_info __UNUSED__)
2998 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
3002 _scr_drag_start(void *data,
3003 Evas_Object *obj __UNUSED__,
3004 void *event_info __UNUSED__)
3006 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
3010 _scr_drag_stop(void *data,
3011 Evas_Object *obj __UNUSED__,
3012 void *event_info __UNUSED__)
3014 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
3018 _edge_left(void *data,
3019 Evas_Object *scr __UNUSED__,
3020 void *event_info __UNUSED__)
3022 Evas_Object *obj = data;
3023 evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
3027 _edge_right(void *data,
3028 Evas_Object *scr __UNUSED__,
3029 void *event_info __UNUSED__)
3031 Evas_Object *obj = data;
3032 evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
3036 _edge_top(void *data,
3037 Evas_Object *scr __UNUSED__,
3038 void *event_info __UNUSED__)
3040 Evas_Object *obj = data;
3041 evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
3045 _edge_bottom(void *data,
3046 Evas_Object *scr __UNUSED__,
3047 void *event_info __UNUSED__)
3049 Evas_Object *obj = data;
3050 evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
3054 _mode_item_realize(Elm_Gen_Item *it)
3058 if ((it->item->mode_view) || (it->generation < it->wd->generation)) return;
3060 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3061 it->item->mode_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
3062 edje_object_scale_set(it->item->mode_view,
3063 elm_widget_scale_get(WIDGET(it)) *
3064 _elm_config->scale);
3065 evas_object_smart_member_add(it->item->mode_view, it->wd->pan_smart);
3066 elm_widget_sub_object_add(WIDGET(it), it->item->mode_view);
3068 strncpy(buf, "item", sizeof(buf));
3069 if (it->wd->compress)
3070 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3072 if (it->item->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3073 strncat(buf, "/", sizeof(buf) - strlen(buf));
3074 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3076 _elm_theme_object_set(WIDGET(it), it->item->mode_view, "genlist", buf,
3077 elm_widget_style_get(WIDGET(it)));
3078 edje_object_mirrored_set(it->item->mode_view,
3079 elm_widget_mirrored_get(WIDGET(it)));
3081 /* signal callback add */
3082 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3084 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_UP,
3086 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3089 /* text_get, content_get, state_get */
3090 /* FIXME: If you see that assert, please notify us and we
3091 will clean our mess */
3092 assert(eina_list_count(it->item->mode_content_objs) == 0);
3094 _item_text_realize(it, it->item->mode_view, &it->item->mode_texts, NULL);
3095 it->item->mode_content_objs =
3096 _item_content_realize(it, it->item->mode_view,
3097 &it->item->mode_contents, NULL);
3098 _item_state_realize(it, it->item->mode_view, &it->item->mode_states, NULL);
3100 edje_object_part_swallow(it->item->mode_view,
3101 edje_object_data_get(it->item->mode_view, "mode_part"),
3104 it->want_unrealize = EINA_FALSE;
3105 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3106 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3110 _mode_item_unrealize(Elm_Gen_Item *it)
3112 Widget_Data *wd = it->wd;
3113 Evas_Object *content;
3114 if (!it->item->mode_view) return;
3116 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3117 elm_widget_stringlist_free(it->item->mode_texts);
3118 it->item->mode_texts = NULL;
3119 elm_widget_stringlist_free(it->item->mode_contents);
3120 it->item->mode_contents = NULL;
3121 elm_widget_stringlist_free(it->item->mode_states);
3123 EINA_LIST_FREE(it->item->mode_content_objs, content)
3124 evas_object_del(content);
3126 edje_object_part_unswallow(it->item->mode_view, VIEW(it));
3127 evas_object_smart_member_add(VIEW(it), wd->pan_smart);
3128 evas_object_del(it->item->mode_view);
3129 it->item->mode_view = NULL;
3131 if (wd->mode_item == it)
3132 wd->mode_item = NULL;
3133 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3134 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3138 _item_mode_set(Elm_Gen_Item *it)
3141 Widget_Data *wd = it->wd;
3146 it->item->nocache = EINA_TRUE;
3148 if (wd->scr_hold_timer)
3150 ecore_timer_del(wd->scr_hold_timer);
3151 wd->scr_hold_timer = NULL;
3153 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3154 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3156 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3157 _mode_item_realize(it);
3158 if (it->item->group_item)
3159 evas_object_raise(it->item->VIEW(group_item));
3160 _item_position(it, it->item->mode_view, it->item->scrl_x, it->item->scrl_y);
3161 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3162 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3164 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3165 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3169 _item_mode_unset(Widget_Data *wd)
3172 if (!wd->mode_item) return;
3173 char buf[1024], buf2[1024];
3177 it->item->nocache = EINA_TRUE;
3179 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3180 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3182 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3183 edje_object_signal_callback_add(it->item->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3185 wd->mode_item = NULL;
3189 _edit_mode_item_position(Elm_Gen_Item *it, int itx, int ity)
3191 if ((!it) || (!it->wd->edit_mode)) return;
3192 evas_object_resize(it->edit_obj, it->item->w, it->item->h);
3193 evas_object_move(it->edit_obj, itx, ity);
3197 _edit_mode_item_realize(Elm_Gen_Item *it, Eina_Bool effect_on)
3200 const char *stacking_even;
3201 const char *stacking;
3203 if ((!it) || (it->item->edit_mode_item_realized) ||
3204 (it->generation < it->wd->generation))
3207 it->edit_obj = edje_object_add(evas_object_evas_get(WIDGET(it)));
3208 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(WIDGET(it)) *
3209 _elm_config->scale);
3210 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
3211 elm_widget_sub_object_add(WIDGET(it), it->edit_obj);
3213 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS)
3214 strncpy(buf, "tree", sizeof(buf));
3215 else strncpy(buf, "item", sizeof(buf));
3216 if (it->wd->compress)
3217 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3219 strncat(buf, "/", sizeof(buf) - strlen(buf));
3220 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
3222 _elm_theme_object_set(WIDGET(it), it->edit_obj, "genlist", buf,
3223 elm_widget_style_get(WIDGET(it)));
3225 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
3226 if (!stacking_even) stacking_even = "above";
3227 it->item->stacking_even = !!strcmp("above", stacking_even);
3229 stacking = edje_object_data_get(VIEW(it), "stacking");
3230 if (!stacking) stacking = "yes";
3231 it->item->nostacking = !!strcmp("yes", stacking);
3233 edje_object_mirrored_set(it->edit_obj,
3234 elm_widget_mirrored_get(WIDGET(it)));
3236 _elm_genlist_item_odd_even_update(it);
3237 _elm_genlist_item_state_update(it, NULL);
3239 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,edit,enabled,effect", "elm");
3240 else edje_object_signal_emit(it->edit_obj, "elm,state,edit,enabled", "elm");
3242 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
3244 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
3246 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
3248 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_DOWN,
3250 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_UP,
3252 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MULTI_MOVE,
3255 _item_text_realize(it, it->edit_obj, &it->item->edit_texts, NULL);
3256 it->item->edit_content_objs =
3257 _item_content_realize(it, it->edit_obj, &it->item->edit_contents, NULL);
3258 _item_state_realize(it, it->edit_obj, &it->item->edit_states, NULL);
3259 edje_object_part_swallow(it->edit_obj, "elm.swallow.edit.content", VIEW(it));
3261 _edit_mode_item_position(it, it->item->scrl_x, it->item->scrl_y);
3262 evas_object_show(it->edit_obj);
3264 it->item->edit_mode_item_realized = EINA_TRUE;
3265 it->want_unrealize = EINA_FALSE;
3269 _edit_mode_item_unrealize(Elm_Gen_Item *it)
3272 if ((!it) || (!it->item->edit_mode_item_realized)) return;
3274 edje_object_part_unswallow(it->edit_obj, VIEW(it));
3275 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
3276 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
3277 _elm_genlist_item_odd_even_update(it);
3278 _elm_genlist_item_state_update(it, NULL);
3280 evas_object_del(it->edit_obj);
3281 it->edit_obj = NULL;
3282 elm_widget_stringlist_free(it->item->edit_texts);
3283 it->item->edit_texts = NULL;
3284 elm_widget_stringlist_free(it->item->edit_contents);
3285 it->item->edit_contents = NULL;
3286 elm_widget_stringlist_free(it->item->edit_states);
3287 it->item->edit_states = NULL;
3288 EINA_LIST_FREE(it->item->edit_content_objs, icon)
3289 evas_object_del(icon);
3290 edje_object_message_signal_process(it->edit_obj);
3292 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
3294 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
3296 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
3298 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_DOWN,
3300 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_UP,
3302 evas_object_event_callback_del_full(it->edit_obj, EVAS_CALLBACK_MULTI_MOVE,
3304 it->item->edit_mode_item_realized = EINA_FALSE;
3308 _item_auto_scroll(Widget_Data *wd)
3311 Elm_Gen_Item *tmp_item = NULL;
3313 if ((wd->expanded_item) && (wd->auto_scroll_enabled))
3315 tmp_item = eina_list_data_get(eina_list_last(wd->expanded_item->item->items));
3316 if (!tmp_item) return;
3317 wd->show_item = tmp_item;
3318 wd->bring_in = EINA_TRUE;
3319 wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
3320 if ((wd->show_item->item->queued) || (!wd->show_item->item->mincalcd))
3322 wd->show_item->item->showme = EINA_TRUE;
3323 wd->auto_scroll_enabled = EINA_FALSE;
3331 elm_genlist_add(Evas_Object *parent)
3336 Evas_Coord minw, minh;
3337 static Evas_Smart *smart = NULL;
3341 static Evas_Smart_Class sc;
3343 evas_object_smart_clipped_smart_set(&_pan_sc);
3345 sc.name = "elm_genlist_pan";
3346 sc.version = EVAS_SMART_CLASS_VERSION;
3349 sc.resize = _pan_resize;
3350 sc.move = _pan_move;
3351 sc.calculate = _pan_calculate;
3352 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3355 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3357 ELM_SET_WIDTYPE(widtype, "genlist");
3359 elm_widget_type_set(obj, "genlist");
3360 elm_widget_sub_object_add(parent, obj);
3361 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3362 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3363 elm_widget_data_set(obj, wd);
3364 elm_widget_del_hook_set(obj, _del_hook);
3365 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3366 elm_widget_theme_hook_set(obj, _theme_hook);
3367 elm_widget_can_focus_set(obj, EINA_TRUE);
3368 elm_widget_event_hook_set(obj, _event_hook);
3369 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3370 elm_widget_translate_hook_set(obj, _translate_hook);
3373 wd->scr = elm_smart_scroller_add(e);
3374 elm_smart_scroller_widget_set(wd->scr, obj);
3375 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3376 elm_widget_style_get(obj));
3377 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3378 _elm_config->thumbscroll_bounce_enable);
3379 elm_widget_resize_object_set(obj, wd->scr);
3381 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3382 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3383 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3384 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3385 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
3386 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
3387 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
3388 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
3391 wd->mode = ELM_LIST_SCROLL;
3392 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3393 wd->item_cache_max = wd->max_items_per_block * 2;
3394 wd->longpress_timeout = _elm_config->longpress_timeout;
3396 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3397 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3398 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3399 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3401 wd->pan_smart = evas_object_smart_add(e, smart);
3402 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3405 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3406 _pan_set, _pan_get, _pan_max_get,
3407 _pan_min_get, _pan_child_size_get);
3409 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3411 evas_object_size_hint_min_set(obj, minw, minh);
3413 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3415 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3421 _item_select(Elm_Gen_Item *it)
3423 if ((it->wd->no_select) || (it->generation < it->wd->generation) || (it->mode_set)) return;
3426 it->selected = EINA_TRUE;
3427 it->wd->selected = eina_list_append(it->wd->selected, it);
3429 else if (!it->wd->always_select) return;
3431 evas_object_ref(WIDGET(it));
3434 if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), it);
3435 if (it->generation == it->wd->generation)
3436 evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
3439 evas_object_unref(WIDGET(it));
3440 if ((it->wd->clear_me) && (!it->wd->walking))
3441 _elm_genlist_clear(WIDGET(it), EINA_TRUE);
3444 if ((!it->walking) && (it->generation < it->wd->generation))
3449 elm_widget_item_free(it);
3453 it->wd->last_selected_item = (Elm_Object_Item *) it;
3457 static Evas_Object *
3458 _item_content_get_hook(Elm_Gen_Item *it, const char *part)
3460 return edje_object_part_swallow_get(VIEW(it), part);
3464 _item_content_set_hook(Elm_Gen_Item *it, const char *part, Evas_Object *content)
3466 if (content && part)
3468 it->content_objs = eina_list_append(it->content_objs, content);
3469 edje_object_part_swallow(VIEW(it), part, content);
3473 static Evas_Object *
3474 _item_content_unset_hook(Elm_Gen_Item *it, const char *part)
3477 obj = edje_object_part_swallow_get(VIEW(it), part);
3478 if (!obj) return NULL;
3479 it->content_objs = eina_list_remove(it->content_objs, obj);
3480 edje_object_part_unswallow(VIEW(it), obj);
3485 _item_text_hook(Elm_Gen_Item *it, const char *part)
3487 if (!it->itc->func.text_get) return NULL;
3488 return edje_object_part_text_get(VIEW(it), part);
3492 _item_disable_hook(Elm_Object_Item *it)
3496 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
3498 if (_it->generation < _it->wd->generation) return;
3501 elm_genlist_item_selected_set(it, EINA_FALSE);
3505 if (elm_widget_item_disabled_get(it))
3507 edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
3509 edje_object_signal_emit(_it->edit_obj, "elm,state,disabled", "elm");
3513 edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
3515 edje_object_signal_emit(_it->edit_obj, "elm,state,enabled", "elm");
3517 EINA_LIST_FOREACH(_it->content_objs, l, obj)
3518 elm_widget_disabled_set(obj, elm_widget_item_disabled_get(_it));
3523 _item_del_pre_hook(Elm_Object_Item *it)
3525 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
3527 if ((_it->relcount > 0) || (_it->walking > 0))
3529 elm_genlist_item_subitems_clear(it);
3530 if (_it->wd->show_item == _it) _it->wd->show_item = NULL;
3531 _elm_genlist_item_del_notserious(_it);
3532 if (_it->item->block)
3534 if (_it->realized) _elm_genlist_item_unrealize(_it, EINA_FALSE);
3535 _it->item->block->changed = EINA_TRUE;
3536 if (_it->wd->calc_job) ecore_job_del(_it->wd->calc_job);
3537 _it->wd->calc_job = ecore_job_add(_calc_job, _it->wd);
3541 _it->parent->item->items =
3542 eina_list_remove(_it->parent->item->items, it);
3552 _elm_genlist_item_new(Widget_Data *wd,
3553 const Elm_Gen_Item_Class *itc,
3555 Elm_Gen_Item *parent,
3557 const void *func_data)
3561 it = elm_widget_item_new(wd->obj, Elm_Gen_Item);
3562 if (!it) return NULL;
3564 it->generation = wd->generation;
3566 elm_genlist_item_class_ref((Elm_Genlist_Item_Class *)itc);
3567 it->base.data = data;
3568 it->parent = parent;
3569 it->func.func = func;
3570 it->func.data = func_data;
3571 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
3572 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
3573 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
3574 elm_widget_item_text_get_hook_set(it, _item_text_hook);
3575 elm_widget_item_disable_hook_set(it, _item_disable_hook);
3576 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
3578 it->sel_cb = (Ecore_Cb)_item_select;
3583 static Elm_Gen_Item *
3584 _item_new(Widget_Data *wd,
3585 const Elm_Genlist_Item_Class *itc,
3587 Elm_Gen_Item *parent,
3588 Elm_Genlist_Item_Flags flags,
3590 const void *func_data)
3592 Elm_Gen_Item *it, *it2;
3595 it = _elm_genlist_item_new(wd, itc, data, parent, func, func_data);
3596 if (!it) return NULL;
3597 it->item = ELM_NEW(Elm_Gen_Item_Type);
3598 it->item->flags = flags;
3599 if (flags & ELM_GENLIST_ITEM_GROUP) it->group++;
3600 it->item->expanded_depth = 0;
3601 ELM_GEN_ITEM_SETUP(it);
3604 if (it->parent->group)
3605 it->item->group_item = parent;
3606 else if (it->parent->item->group_item)
3607 it->item->group_item = it->parent->item->group_item;
3609 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
3611 if (!it2->parent->group) depth += 1;
3613 it->item->expanded_depth = depth;
3619 _item_block_new(Widget_Data *wd, Eina_Bool prepend)
3623 itb = calloc(1, sizeof(Item_Block));
3624 if (!itb) return NULL;
3628 wd->blocks = eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3629 _item_block_position_update(wd->blocks, 0);
3633 wd->blocks = eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3634 itb->position_update = EINA_TRUE;
3635 if (wd->blocks != EINA_INLIST_GET(itb))
3637 itb->position = ((Item_Block *) (EINA_INLIST_GET(itb)->prev))->position + 1;
3648 _item_block_add(Widget_Data *wd,
3651 Item_Block *itb = NULL;
3658 itb = calloc(1, sizeof(Item_Block));
3659 if (!itb) return EINA_FALSE;
3661 if (!it->item->rel->item->block)
3664 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3665 itb->items = eina_list_append(itb->items, it);
3666 itb->position_update = EINA_TRUE;
3667 it->position = eina_list_count(itb->items);
3668 it->position_update = EINA_TRUE;
3670 if (wd->blocks != EINA_INLIST_GET(itb))
3672 itb->position = ((Item_Block *) (EINA_INLIST_GET(itb)->prev))->position + 1;
3683 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3684 if (it->item->before)
3686 wd->blocks = eina_inlist_prepend_relative
3687 (wd->blocks, EINA_INLIST_GET(itb),
3688 EINA_INLIST_GET(it->item->rel->item->block));
3690 eina_list_prepend_relative_list(itb->items, it, tmp);
3692 /* Update index from where we prepended */
3693 _item_position_update(eina_list_prev(tmp), it->item->rel->position);
3694 _item_block_position_update(EINA_INLIST_GET(itb),
3695 it->item->rel->item->block->position);
3699 wd->blocks = eina_inlist_append_relative
3700 (wd->blocks, EINA_INLIST_GET(itb),
3701 EINA_INLIST_GET(it->item->rel->item->block));
3703 eina_list_append_relative_list(itb->items, it, tmp);
3705 /* Update block index from where we appended */
3706 _item_position_update(eina_list_next(tmp), it->item->rel->position + 1);
3707 _item_block_position_update(EINA_INLIST_GET(itb),
3708 it->item->rel->item->block->position + 1);
3714 if (it->item->before)
3718 itb = (Item_Block *)(wd->blocks);
3719 if (itb->count >= wd->max_items_per_block)
3721 itb = _item_block_new(wd, EINA_TRUE);
3722 if (!itb) return EINA_FALSE;
3727 itb = _item_block_new(wd, EINA_TRUE);
3728 if (!itb) return EINA_FALSE;
3730 itb->items = eina_list_prepend(itb->items, it);
3732 _item_position_update(itb->items, 0);
3738 itb = (Item_Block *)(wd->blocks->last);
3739 if (itb->count >= wd->max_items_per_block)
3741 itb = _item_block_new(wd, EINA_FALSE);
3742 if (!itb) return EINA_FALSE;
3747 itb = _item_block_new(wd, EINA_FALSE);
3748 if (!itb) return EINA_FALSE;
3750 itb->items = eina_list_append(itb->items, it);
3751 it->position = eina_list_count(itb->items);
3759 if (it->item->rel->item->queued)
3761 /* NOTE: for a strange reason eina_list and eina_inlist don't have the same property
3762 on sorted insertion order, so the queue is not always ordered like the item list.
3763 This lead to issue where we depend on an item that is not yet created. As a quick
3764 work around, we reschedule the calc of the item and stop reordering the list to
3765 prevent any nasty issue to show up here.
3767 wd->queue = eina_list_append(wd->queue, it);
3768 wd->requeued = EINA_TRUE;
3769 it->item->queued = EINA_TRUE;
3772 itb = it->item->rel->item->block;
3773 if (!itb) goto newblock;
3774 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3775 if (it->item->before)
3777 itb->items = eina_list_prepend_relative_list(itb->items, it, tmp);
3778 _item_position_update(eina_list_prev(tmp), it->item->rel->position);
3782 itb->items = eina_list_append_relative_list(itb->items, it, tmp);
3783 _item_position_update(eina_list_next(tmp), it->item->rel->position + 1);
3787 itb->changed = EINA_TRUE;
3788 it->item->block = itb;
3789 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3790 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3793 it->item->rel->relcount--;
3794 if ((it->item->rel->generation < it->wd->generation) && (!it->item->rel->relcount))
3796 _item_del(it->item->rel);
3797 elm_widget_item_free(it->item->rel);
3799 it->item->rel = NULL;
3801 if (itb->count > itb->wd->max_items_per_block)
3806 Eina_Bool done = EINA_FALSE;
3808 newc = itb->count / 2;
3810 if (EINA_INLIST_GET(itb)->prev)
3812 Item_Block *itbp = (Item_Block *)(EINA_INLIST_GET(itb)->prev);
3814 if (itbp->count + newc < wd->max_items_per_block / 2)
3816 /* moving items to previous block */
3817 while ((itb->count > newc) && (itb->items))
3819 it2 = eina_list_data_get(itb->items);
3820 itb->items = eina_list_remove_list(itb->items, itb->items);
3823 itbp->items = eina_list_append(itbp->items, it2);
3824 it2->item->block = itbp;
3832 if (!done && EINA_INLIST_GET(itb)->next)
3834 Item_Block *itbn = (Item_Block *)(EINA_INLIST_GET(itb)->next);
3836 if (itbn->count + newc < wd->max_items_per_block / 2)
3838 /* moving items to next block */
3839 while ((itb->count > newc) && (itb->items))
3843 l = eina_list_last(itb->items);
3844 it2 = eina_list_data_get(l);
3845 itb->items = eina_list_remove_list(itb->items, l);
3848 itbn->items = eina_list_prepend(itbn->items, it2);
3849 it2->item->block = itbn;
3859 /* moving items to new block */
3860 itb2 = calloc(1, sizeof(Item_Block));
3861 if (!itb2) return EINA_FALSE;
3864 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3865 EINA_INLIST_GET(itb));
3866 itb2->changed = EINA_TRUE;
3867 while ((itb->count > newc) && (itb->items))
3871 l = eina_list_last(itb->items);
3873 itb->items = eina_list_remove_list(itb->items, l);
3876 itb2->items = eina_list_prepend(itb2->items, it2);
3877 it2->item->block = itb2;
3887 _queue_process(Widget_Data *wd)
3890 Eina_Bool showme = EINA_FALSE;
3893 t0 = ecore_loop_time_get();
3894 //evas_event_freeze(evas_object_evas_get(wd->obj));
3895 for (n = 0; (wd->queue) && (n < 128); n++)
3899 it = eina_list_data_get(wd->queue);
3900 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3901 it->item->queued = EINA_FALSE;
3902 if (!_item_block_add(wd, it)) continue;
3904 _item_block_realize(it->item->block);
3905 t = ecore_time_get();
3906 if (it->item->block->changed)
3908 showme = _item_block_recalc(it->item->block, it->item->block->num, EINA_TRUE);
3909 it->item->block->changed = 0;
3910 if (wd->pan_changed)
3912 if (wd->calc_job) ecore_job_del(wd->calc_job);
3913 wd->calc_job = NULL;
3915 wd->pan_changed = EINA_FALSE;
3918 if (showme) it->item->block->showme = EINA_TRUE;
3919 /* same as eina_inlist_count > 1 */
3920 if (wd->blocks && wd->blocks->next)
3922 if ((t - t0) > (ecore_animator_frametime_get())) break;
3925 //evas_event_thaw(evas_object_evas_get(wd->obj));
3926 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3931 _idle_process(void *data, Eina_Bool *wakeup)
3933 Widget_Data *wd = data;
3936 //static double q_start = 0.0;
3937 //if (q_start == 0.0) q_start = ecore_time_get();
3939 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3943 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3945 return ECORE_CALLBACK_CANCEL;
3947 return ECORE_CALLBACK_RENEW;
3951 _item_idle_enterer(void *data)
3953 Widget_Data *wd = data;
3954 Eina_Bool wakeup = EINA_FALSE;
3955 Eina_Bool ok = _idle_process(data, &wakeup);
3960 if (wd->calc_job) ecore_job_del(wd->calc_job);
3961 wd->calc_job = ecore_job_add(_calc_job, wd);
3963 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3968 _item_queue(Widget_Data *wd,
3972 if (it->item->queued) return;
3973 it->item->queued = EINA_TRUE;
3974 if (cb && !wd->requeued)
3975 wd->queue = eina_list_sorted_insert(wd->queue, cb, it);
3977 wd->queue = eina_list_append(wd->queue, it);
3978 // FIXME: why does a freeze then thaw here cause some genlist
3979 // elm_genlist_item_append() to be much much slower?
3980 // evas_event_freeze(evas_object_evas_get(wd->obj));
3981 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3983 if (wd->queue_idle_enterer)
3985 ecore_idle_enterer_del(wd->queue_idle_enterer);
3986 wd->queue_idle_enterer = NULL;
3990 // evas_event_thaw(evas_object_evas_get(wd->obj));
3991 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3992 if (!wd->queue_idle_enterer)
3993 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3997 _elm_genlist_item_compare(const void *data, const void *data1)
3999 const Elm_Gen_Item *it, *item1;
4000 it = ELM_GEN_ITEM_FROM_INLIST(data);
4001 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
4002 return it->wd->item_compare_cb(it, item1);
4006 _elm_genlist_item_list_compare(const void *data, const void *data1)
4008 const Elm_Gen_Item *it = data;
4009 const Elm_Gen_Item *item1 = data1;
4010 return it->wd->item_compare_cb(it, item1);
4014 _item_move_after(Elm_Gen_Item *it, Elm_Gen_Item *after)
4019 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4020 _item_block_del(it);
4022 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
4023 it->item->rel = after;
4024 it->item->rel->relcount++;
4025 it->item->before = EINA_FALSE;
4026 if (after->item->group_item) it->item->group_item = after->item->group_item;
4027 _item_queue(it->wd, it, NULL);
4029 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
4033 _item_move_before(Elm_Gen_Item *it, Elm_Gen_Item *before)
4036 if (!before) return;
4038 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4039 _item_block_del(it);
4040 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
4041 it->item->rel = before;
4042 it->item->rel->relcount++;
4043 it->item->before = EINA_TRUE;
4044 if (before->item->group_item) it->item->group_item = before->item->group_item;
4045 _item_queue(it->wd, it, NULL);
4047 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
4051 elm_genlist_items_count(const Evas_Object *obj)
4053 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4054 Widget_Data *wd = elm_widget_data_get(obj);
4056 return wd->item_count;
4059 EAPI Elm_Object_Item *
4060 elm_genlist_item_append(Evas_Object *obj,
4061 const Elm_Genlist_Item_Class *itc,
4063 Elm_Object_Item *parent,
4064 Elm_Genlist_Item_Flags flags,
4066 const void *func_data)
4068 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4069 Widget_Data *wd = elm_widget_data_get(obj);
4070 if (!wd) return NULL;
4071 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, flags,
4073 if (!it) return NULL;
4077 wd->group_items = eina_list_append(wd->group_items, it);
4078 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
4079 it->item->rel = NULL;
4083 Elm_Gen_Item *it2 = NULL;
4084 Eina_List *ll = eina_list_last(it->parent->item->items);
4085 if (ll) it2 = ll->data;
4086 it->parent->item->items = eina_list_append(it->parent->item->items, it);
4087 if (!it2) it2 = it->parent;
4089 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
4090 EINA_INLIST_GET(it2));
4091 it->item->rel = it2;
4092 it->item->rel->relcount++;
4094 it->item->before = EINA_FALSE;
4095 _item_queue(wd, it, NULL);
4096 return (Elm_Object_Item *) it;
4099 EAPI Elm_Object_Item *
4100 elm_genlist_item_prepend(Evas_Object *obj,
4101 const Elm_Genlist_Item_Class *itc,
4103 Elm_Object_Item *parent,
4104 Elm_Genlist_Item_Flags flags,
4106 const void *func_data)
4108 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4109 Widget_Data *wd = elm_widget_data_get(obj);
4110 if (!wd) return NULL;
4111 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, flags,
4113 if (!it) return NULL;
4117 wd->group_items = eina_list_prepend(wd->group_items, it);
4118 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
4119 it->item->rel = NULL;
4123 Elm_Gen_Item *it2 = NULL;
4124 Eina_List *ll = it->parent->item->items;
4125 if (ll) it2 = ll->data;
4126 it->parent->item->items = eina_list_prepend(it->parent->item->items, it);
4127 if (!it2) it2 = it->parent;
4129 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4130 EINA_INLIST_GET(it2));
4131 it->item->rel = it2;
4132 it->item->rel->relcount++;
4134 it->item->before = EINA_TRUE;
4135 _item_queue(wd, it, NULL);
4136 return (Elm_Object_Item *) it;
4139 EAPI Elm_Object_Item *
4140 elm_genlist_item_insert_after(Evas_Object *obj,
4141 const Elm_Genlist_Item_Class *itc,
4143 Elm_Object_Item *parent,
4144 Elm_Object_Item *after,
4145 Elm_Genlist_Item_Flags flags,
4147 const void *func_data)
4149 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4150 ELM_OBJ_ITEM_CHECK_OR_RETURN(after, NULL);
4151 Widget_Data *wd = elm_widget_data_get(obj);
4152 Elm_Gen_Item *_after = (Elm_Gen_Item *) after;
4153 if (!wd) return NULL;
4154 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
4155 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4157 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, flags,
4159 if (!it) return NULL;
4162 if ((it->group) && (_after->group))
4163 wd->group_items = eina_list_append_relative(wd->group_items, it,
4168 it->parent->item->items =
4169 eina_list_append_relative(it->parent->item->items, it, _after);
4171 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
4172 EINA_INLIST_GET(_after));
4173 it->item->rel = _after;
4174 it->item->rel->relcount++;
4175 it->item->before = EINA_FALSE;
4176 _item_queue(wd, it, NULL);
4177 return (Elm_Object_Item *) it;
4180 EAPI Elm_Object_Item *
4181 elm_genlist_item_insert_before(Evas_Object *obj,
4182 const Elm_Genlist_Item_Class *itc,
4184 Elm_Object_Item *parent,
4185 Elm_Object_Item *before,
4186 Elm_Genlist_Item_Flags flags,
4188 const void *func_data)
4190 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4191 ELM_OBJ_ITEM_CHECK_OR_RETURN(before, NULL);
4192 Widget_Data *wd = elm_widget_data_get(obj);
4193 Elm_Gen_Item *_before = (Elm_Gen_Item *) before;
4194 if (!wd) return NULL;
4195 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
4196 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4198 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, flags,
4200 if (!it) return NULL;
4203 if (it->group && _before->group)
4204 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
4209 it->parent->item->items =
4210 eina_list_prepend_relative(it->parent->item->items, it, _before);
4212 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4213 EINA_INLIST_GET(_before));
4214 it->item->rel = _before;
4215 it->item->rel->relcount++;
4216 it->item->before = EINA_TRUE;
4217 _item_queue(wd, it, NULL);
4218 return (Elm_Object_Item *) it;
4221 EAPI Elm_Object_Item *
4222 elm_genlist_item_sorted_insert(Evas_Object *obj,
4223 const Elm_Genlist_Item_Class *itc,
4225 Elm_Object_Item *parent,
4226 Elm_Genlist_Item_Flags flags,
4227 Eina_Compare_Cb comp,
4229 const void *func_data)
4231 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4232 Widget_Data *wd = elm_widget_data_get(obj);
4233 if (!wd) return NULL;
4234 Elm_Gen_Item *rel = NULL;
4235 Elm_Gen_Item *it = _item_new(wd, itc, data, (Elm_Gen_Item *) parent, flags,
4237 if (!it) return NULL;
4239 wd->item_compare_cb = comp;
4246 l = eina_list_search_sorted_near_list(it->parent->item->items,
4247 _elm_genlist_item_list_compare,
4251 rel = eina_list_data_get(l);
4255 if (cmp_result >= 0)
4257 it->parent->item->items = eina_list_prepend_relative_list(it->parent->item->items, it, l);
4258 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
4259 it->item->before = EINA_FALSE;
4261 else if (cmp_result < 0)
4263 it->parent->item->items = eina_list_append_relative_list(it->parent->item->items, it, l);
4264 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
4265 it->item->before = EINA_TRUE;
4272 wd->state = eina_inlist_sorted_state_new();
4273 eina_inlist_sorted_state_init(wd->state, wd->items);
4274 wd->requeued = EINA_FALSE;
4278 wd->group_items = eina_list_append(wd->group_items, it);
4280 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
4281 _elm_genlist_item_compare, wd->state);
4283 if (EINA_INLIST_GET(it)->next)
4285 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4286 it->item->before = EINA_TRUE;
4288 else if (EINA_INLIST_GET(it)->prev)
4290 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4291 it->item->before = EINA_FALSE;
4297 it->item->rel = rel;
4298 it->item->rel->relcount++;
4301 _item_queue(wd, it, _elm_genlist_item_list_compare);
4303 return (Elm_Object_Item *) it;
4307 _elm_genlist_clear(Evas_Object *obj, Eina_Bool standby)
4309 Eina_Inlist *next, *l;
4311 ELM_CHECK_WIDTYPE(obj, widtype);
4312 Widget_Data *wd = elm_widget_data_get(obj);
4315 if (!standby) wd->generation++;
4319 eina_inlist_sorted_state_free(wd->state);
4323 if (wd->walking > 0)
4325 wd->clear_me = EINA_TRUE;
4328 evas_event_freeze(evas_object_evas_get(wd->obj));
4329 for (l = wd->items, next = l ? l->next : NULL;
4331 l = next, next = next ? next->next : NULL)
4333 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(l);
4335 if (it->generation < wd->generation)
4337 Elm_Gen_Item *itn = NULL;
4339 if (next) itn = ELM_GEN_ITEM_FROM_INLIST(next);
4340 if (itn) itn->walking++; /* prevent early death of subitem */
4342 elm_widget_item_free(it);
4343 if (itn) itn->walking--;
4346 wd->clear_me = EINA_FALSE;
4347 wd->pan_changed = EINA_TRUE;
4350 ecore_job_del(wd->calc_job);
4351 wd->calc_job = NULL;
4353 if (wd->selected) wd->selected = eina_list_free(wd->selected);
4354 if (wd->clear_cb) wd->clear_cb(wd);
4361 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4362 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4364 if (wd->sizing_cb) wd->sizing_cb(wd->obj);
4365 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
4366 evas_event_thaw(evas_object_evas_get(wd->obj));
4367 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4371 elm_genlist_clear(Evas_Object *obj)
4373 _elm_genlist_clear(obj, EINA_FALSE);
4377 elm_genlist_multi_select_set(Evas_Object *obj,
4380 ELM_CHECK_WIDTYPE(obj, widtype);
4381 Widget_Data *wd = elm_widget_data_get(obj);
4383 wd->multi = !!multi;
4387 elm_genlist_multi_select_get(const Evas_Object *obj)
4389 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4390 Widget_Data *wd = elm_widget_data_get(obj);
4391 if (!wd) return EINA_FALSE;
4395 EAPI Elm_Object_Item *
4396 elm_genlist_selected_item_get(const Evas_Object *obj)
4398 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4399 Widget_Data *wd = elm_widget_data_get(obj);
4400 if (!wd) return NULL;
4401 if (wd->selected) return wd->selected->data;
4405 EAPI const Eina_List *
4406 elm_genlist_selected_items_get(const Evas_Object *obj)
4408 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4409 Widget_Data *wd = elm_widget_data_get(obj);
4410 if (!wd) return NULL;
4411 return wd->selected;
4415 elm_genlist_realized_items_get(const Evas_Object *obj)
4417 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4418 Widget_Data *wd = elm_widget_data_get(obj);
4419 Eina_List *list = NULL;
4421 Eina_Bool done = EINA_FALSE;
4422 if (!wd) return NULL;
4423 EINA_INLIST_FOREACH(wd->blocks, itb)
4431 EINA_LIST_FOREACH(itb->items, l, it)
4433 if (it->realized) list = eina_list_append(list, it);
4444 EAPI Elm_Object_Item *
4445 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4450 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4451 Widget_Data *wd = elm_widget_data_get(obj);
4452 Evas_Coord ox, oy, ow, oh;
4455 if (!wd) return NULL;
4456 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4458 EINA_INLIST_FOREACH(wd->blocks, itb)
4463 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4464 oy + itb->y - itb->wd->pan_y,
4465 itb->w, itb->h, x, y, 1, 1))
4467 EINA_LIST_FOREACH(itb->items, l, it)
4469 Evas_Coord itx, ity;
4471 itx = ox + itb->x + it->x - itb->wd->pan_x;
4472 ity = oy + itb->y + it->y - itb->wd->pan_y;
4473 if (ELM_RECTS_INTERSECT(itx, ity, it->item->w, it->item->h, x, y, 1, 1))
4477 if (y <= (ity + (it->item->h / 4))) *posret = -1;
4478 else if (y >= (ity + it->item->h - (it->item->h / 4)))
4482 return (Elm_Object_Item *) it;
4484 lasty = ity + it->item->h;
4489 if (y > lasty) *posret = 1;
4495 EAPI Elm_Object_Item *
4496 elm_genlist_first_item_get(const Evas_Object *obj)
4498 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4499 Widget_Data *wd = elm_widget_data_get(obj);
4500 if (!wd) return NULL;
4501 if (!wd->items) return NULL;
4502 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
4503 while ((it) && (it->generation < wd->generation))
4504 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4505 return (Elm_Object_Item *) it;
4508 EAPI Elm_Object_Item *
4509 elm_genlist_last_item_get(const Evas_Object *obj)
4511 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4512 Widget_Data *wd = elm_widget_data_get(obj);
4513 if (!wd) return NULL;
4514 if (!wd->items) return NULL;
4515 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
4516 while ((it) && (it->generation < wd->generation))
4517 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4518 return (Elm_Object_Item *) it;
4521 EAPI Elm_Object_Item *
4522 elm_genlist_item_next_get(const Elm_Object_Item *it)
4524 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4525 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4528 _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->next);
4529 if ((_it) && (_it->generation == _it->wd->generation)) break;
4531 return (Elm_Object_Item *) _it;
4534 EAPI Elm_Object_Item *
4535 elm_genlist_item_prev_get(const Elm_Object_Item *it)
4537 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4538 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4541 _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->prev);
4542 if ((_it) && (_it->generation == _it->wd->generation)) break;
4544 return (Elm_Object_Item *) _it;
4547 EINA_DEPRECATED EAPI Evas_Object *
4548 elm_genlist_item_genlist_get(const Elm_Object_Item *it)
4550 return elm_object_item_widget_get(it);
4553 EAPI Elm_Object_Item *
4554 elm_genlist_item_parent_get(const Elm_Object_Item *it)
4556 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4557 return (Elm_Object_Item *) ((Elm_Gen_Item *) it)->parent;
4561 elm_genlist_item_subitems_clear(Elm_Object_Item *it)
4563 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4564 Eina_List *tl = NULL, *l;
4566 Elm_Object_Item *it2;
4567 _it = (Elm_Gen_Item *) it;
4569 EINA_LIST_FOREACH(_it->item->items, l, it2)
4570 tl = eina_list_append(tl, it2);
4571 EINA_LIST_FREE(tl, it2)
4572 elm_object_item_del(it2);
4576 elm_genlist_item_selected_set(Elm_Object_Item *it,
4579 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4580 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4581 Widget_Data *wd = _it->wd;
4583 if ((_it->generation < wd->generation) || elm_widget_item_disabled_get(_it))
4585 selected = !!selected;
4586 if (_it->selected == selected) return;
4592 while (wd->selected)
4594 if (_it->unhighlight_cb) _it->unhighlight_cb(wd->selected->data);
4595 _it->unsel_cb(wd->selected->data);
4598 _it->highlight_cb(_it);
4602 if (_it->unhighlight_cb) _it->unhighlight_cb(_it);
4607 elm_genlist_item_selected_get(const Elm_Object_Item *it)
4609 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4610 return ((Elm_Gen_Item *) it)->selected;
4614 elm_genlist_item_expanded_set(Elm_Object_Item *it,
4617 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4618 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4619 expanded = !!expanded;
4620 if (_it->item->expanded == expanded) return;
4621 _it->item->expanded = expanded;
4622 if (_it->item->expanded)
4625 edje_object_signal_emit(VIEW(_it), "elm,state,expanded", "elm");
4626 evas_object_smart_callback_call(WIDGET(_it), SIG_EXPANDED, _it);
4627 _it->wd->auto_scroll_enabled = EINA_TRUE;
4628 _it->wd->expanded_item = _it;
4633 edje_object_signal_emit(VIEW(_it), "elm,state,contracted", "elm");
4634 evas_object_smart_callback_call(WIDGET(_it), SIG_CONTRACTED, _it);
4635 _it->wd->auto_scroll_enabled = EINA_FALSE;
4636 _it->wd->expanded_item = NULL;
4641 elm_genlist_item_expanded_get(const Elm_Object_Item *it)
4643 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4644 return ((Elm_Gen_Item *) it)->item->expanded;
4648 elm_genlist_item_expanded_depth_get(const Elm_Object_Item *it)
4650 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, 0);
4651 return ((Elm_Gen_Item *) it)->item->expanded_depth;
4654 EINA_DEPRECATED EAPI void
4655 elm_genlist_item_disabled_set(Elm_Object_Item *it,
4658 elm_object_item_disabled_set(it, disabled);
4661 EINA_DEPRECATED EAPI Eina_Bool
4662 elm_genlist_item_disabled_get(const Elm_Object_Item *it)
4664 return elm_object_item_disabled_get(it);
4668 elm_genlist_item_display_only_set(Elm_Object_Item *it,
4669 Eina_Bool display_only)
4671 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4672 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4673 display_only = !!display_only;
4674 if (_it->display_only == display_only) return;
4675 if (_it->generation < _it->wd->generation) return;
4676 _it->display_only = display_only;
4677 _it->item->mincalcd = EINA_FALSE;
4678 _it->item->updateme = EINA_TRUE;
4679 if (_it->item->block) _it->item->block->updateme = EINA_TRUE;
4680 if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
4681 _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
4685 elm_genlist_item_display_only_get(const Elm_Object_Item *it)
4687 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
4688 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4689 if (_it->generation < _it->wd->generation) return EINA_FALSE;
4690 return _it->display_only;
4694 elm_genlist_item_show(Elm_Object_Item *it)
4696 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4697 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4698 Evas_Coord gith = 0;
4699 if (_it->generation < _it->wd->generation) return;
4700 if ((_it->item->queued) || (!_it->item->mincalcd))
4702 _it->wd->show_item = _it;
4703 _it->wd->bring_in = EINA_FALSE;
4704 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
4705 _it->item->showme = EINA_TRUE;
4708 if (_it->wd->show_item)
4710 _it->wd->show_item->item->showme = EINA_FALSE;
4711 _it->wd->show_item = NULL;
4713 if ((_it->item->group_item) &&
4714 (_it->wd->pan_y > (_it->y + _it->item->block->y)))
4715 gith = _it->item->group_item->item->h;
4716 elm_smart_scroller_child_region_show(_it->wd->scr,
4717 _it->x + _it->item->block->x,
4718 _it->y + _it->item->block->y - gith,
4719 _it->item->block->w, _it->item->h);
4723 elm_genlist_item_promote(Elm_Object_Item *it)
4725 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4726 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4727 if (_it->generation < _it->wd->generation) return;
4728 _item_move_before(_it,
4729 (Elm_Gen_Item *) elm_genlist_first_item_get(WIDGET(_it)));
4733 elm_genlist_item_demote(Elm_Object_Item *it)
4735 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4736 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4737 if (_it->generation < _it->wd->generation) return;
4738 _item_move_after(_it,
4739 (Elm_Gen_Item *) elm_genlist_last_item_get(WIDGET(_it)));
4743 elm_genlist_item_bring_in(Elm_Object_Item *it)
4745 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4746 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4747 Evas_Coord gith = 0;
4748 if (_it->generation < _it->wd->generation) return;
4749 if ((_it->item->queued) || (!_it->item->mincalcd))
4751 _it->wd->show_item = _it;
4752 _it->wd->bring_in = EINA_TRUE;
4753 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
4754 _it->item->showme = EINA_TRUE;
4757 if (_it->wd->show_item)
4759 _it->wd->show_item->item->showme = EINA_FALSE;
4760 _it->wd->show_item = NULL;
4762 if ((_it->item->group_item) &&
4763 (_it->wd->pan_y > (_it->y + _it->item->block->y)))
4764 gith = _it->item->group_item->item->h;
4765 elm_smart_scroller_region_bring_in(_it->wd->scr,
4766 _it->x + _it->item->block->x,
4767 _it->y + _it->item->block->y - gith,
4768 _it->item->block->w, _it->item->h);
4772 elm_genlist_item_top_show(Elm_Object_Item *it)
4774 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4775 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4777 Evas_Coord gith = 0;
4779 if (_it->generation < _it->wd->generation) return;
4780 if ((_it->item->queued) || (!_it->item->mincalcd))
4782 _it->wd->show_item = _it;
4783 _it->wd->bring_in = EINA_FALSE;
4784 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_TOP;
4785 _it->item->showme = EINA_TRUE;
4788 if (_it->wd->show_item)
4790 _it->wd->show_item->item->showme = EINA_FALSE;
4791 _it->wd->show_item = NULL;
4793 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4794 if (_it->item->group_item) gith = _it->item->group_item->item->h;
4795 elm_smart_scroller_child_region_show(_it->wd->scr,
4796 _it->x + _it->item->block->x,
4797 _it->y + _it->item->block->y - gith,
4798 _it->item->block->w, oh);
4802 elm_genlist_item_top_bring_in(Elm_Object_Item *it)
4804 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4805 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4807 Evas_Coord gith = 0;
4809 if (_it->generation < _it->wd->generation) return;
4810 if ((_it->item->queued) || (!_it->item->mincalcd))
4812 _it->wd->show_item = _it;
4813 _it->wd->bring_in = EINA_TRUE;
4814 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_TOP;
4815 _it->item->showme = EINA_TRUE;
4818 if (_it->wd->show_item)
4820 _it->wd->show_item->item->showme = EINA_FALSE;
4821 _it->wd->show_item = NULL;
4823 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4824 if (_it->item->group_item) gith = _it->item->group_item->item->h;
4825 elm_smart_scroller_region_bring_in(_it->wd->scr,
4826 _it->x + _it->item->block->x,
4827 _it->y + _it->item->block->y - gith,
4828 _it->item->block->w, oh);
4832 elm_genlist_item_middle_show(Elm_Object_Item *it)
4834 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4835 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4838 if (_it->generation < _it->wd->generation) return;
4839 if ((_it->item->queued) || (!_it->item->mincalcd))
4841 _it->wd->show_item = _it;
4842 _it->wd->bring_in = EINA_FALSE;
4843 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_MIDDLE;
4844 _it->item->showme = EINA_TRUE;
4847 if (_it->wd->show_item)
4849 _it->wd->show_item->item->showme = EINA_FALSE;
4850 _it->wd->show_item = NULL;
4852 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4853 elm_smart_scroller_child_region_show(_it->wd->scr,
4854 _it->x + _it->item->block->x,
4855 _it->y + _it->item->block->y - oh / 2 +
4856 _it->item->h / 2, _it->item->block->w,
4861 elm_genlist_item_middle_bring_in(Elm_Object_Item *it)
4863 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4864 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4867 if (_it->generation < _it->wd->generation) return;
4868 if ((_it->item->queued) || (!_it->item->mincalcd))
4870 _it->wd->show_item = _it;
4871 _it->wd->bring_in = EINA_TRUE;
4872 _it->wd->scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_MIDDLE;
4873 _it->item->showme = EINA_TRUE;
4876 if (_it->wd->show_item)
4878 _it->wd->show_item->item->showme = EINA_FALSE;
4879 _it->wd->show_item = NULL;
4881 evas_object_geometry_get(_it->wd->pan_smart, NULL, NULL, &ow, &oh);
4882 elm_smart_scroller_region_bring_in(_it->wd->scr,
4883 _it->x + _it->item->block->x,
4884 _it->y + _it->item->block->y - oh / 2 +
4885 _it->item->h / 2, _it->item->block->w,
4890 elm_genlist_item_del(Elm_Object_Item *it)
4892 elm_object_item_del(it);
4896 elm_genlist_item_data_set(Elm_Object_Item *it,
4899 elm_object_item_data_set(it, (void *) data);
4903 elm_genlist_item_data_get(const Elm_Object_Item *it)
4905 return elm_object_item_data_get(it);
4909 elm_genlist_item_icons_orphan(Elm_Object_Item *it)
4911 elm_genlist_item_contents_orphan(it);
4915 elm_genlist_item_contents_orphan(Elm_Object_Item *it)
4917 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4919 Evas_Object *content;
4920 EINA_LIST_FREE(((Elm_Gen_Item *) it)->content_objs, content)
4922 elm_widget_sub_object_del(WIDGET(it), content);
4923 evas_object_smart_member_del(content);
4924 evas_object_hide(content);
4928 EINA_DEPRECATED EAPI const Evas_Object *
4929 elm_genlist_item_object_get(const Elm_Object_Item *it)
4931 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4936 elm_genlist_item_update(Elm_Object_Item *it)
4938 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4939 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4941 if (!_it->item->block) return;
4942 if (_it->generation < _it->wd->generation) return;
4943 _it->item->mincalcd = EINA_FALSE;
4944 _it->item->updateme = EINA_TRUE;
4945 _it->item->block->updateme = EINA_TRUE;
4946 if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
4947 _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
4951 elm_genlist_item_fields_update(Elm_Object_Item *it,
4953 Elm_Genlist_Item_Field_Flags itf)
4955 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4956 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4958 if (!_it->item->block) return;
4959 if (_it->generation < _it->wd->generation) return;
4961 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_TEXT))
4962 _item_text_realize(_it, VIEW(_it), &_it->texts, parts);
4963 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_CONTENT))
4965 _it->content_objs = _item_content_unrealize(_it, VIEW(_it),
4966 &_it->contents, parts);
4967 _it->content_objs = _item_content_realize(_it, VIEW(_it),
4968 &_it->contents, parts);
4970 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
4971 _item_state_realize(_it, VIEW(_it), &_it->states, parts);
4975 elm_genlist_item_item_class_update(Elm_Object_Item *it,
4976 const Elm_Genlist_Item_Class *itc)
4978 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
4979 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4981 if (!_it->item->block) return;
4982 EINA_SAFETY_ON_NULL_RETURN(itc);
4983 if (_it->generation < _it->wd->generation) return;
4985 _it->item->nocache = EINA_TRUE;
4986 elm_genlist_item_update(it);
4989 EAPI const Elm_Genlist_Item_Class *
4990 elm_genlist_item_item_class_get(const Elm_Object_Item *it)
4992 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
4993 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
4994 if (_it->generation < _it->wd->generation) return NULL;
4998 static Evas_Object *
4999 _elm_genlist_item_label_create(void *data,
5000 Evas_Object *obj __UNUSED__,
5001 Evas_Object *tooltip,
5002 void *it __UNUSED__)
5004 Evas_Object *label = elm_label_add(tooltip);
5007 elm_object_style_set(label, "tooltip");
5008 elm_object_text_set(label, data);
5013 _elm_genlist_item_label_del_cb(void *data,
5014 Evas_Object *obj __UNUSED__,
5015 void *event_info __UNUSED__)
5017 eina_stringshare_del(data);
5021 elm_genlist_item_tooltip_text_set(Elm_Object_Item *it,
5024 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5025 text = eina_stringshare_add(text);
5026 elm_genlist_item_tooltip_content_cb_set(it, _elm_genlist_item_label_create,
5028 _elm_genlist_item_label_del_cb);
5032 elm_genlist_item_tooltip_content_cb_set(Elm_Object_Item *it,
5033 Elm_Tooltip_Item_Content_Cb func,
5035 Evas_Smart_Cb del_cb)
5037 ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
5038 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5040 if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
5043 if (_it->tooltip.del_cb)
5044 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(it), it);
5046 _it->tooltip.content_cb = func;
5047 _it->tooltip.data = data;
5048 _it->tooltip.del_cb = del_cb;
5052 elm_widget_item_tooltip_content_cb_set(_it,
5053 _it->tooltip.content_cb,
5054 _it->tooltip.data, NULL);
5055 elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
5056 elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
5062 if (del_cb) del_cb((void *)data, NULL, NULL);
5066 elm_genlist_item_tooltip_unset(Elm_Object_Item *it)
5068 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5069 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5071 if ((VIEW(_it)) && (_it->tooltip.content_cb))
5072 elm_widget_item_tooltip_unset(_it);
5074 if (_it->tooltip.del_cb)
5075 _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
5076 _it->tooltip.del_cb = NULL;
5077 _it->tooltip.content_cb = NULL;
5078 _it->tooltip.data = NULL;
5079 _it->tooltip.free_size = EINA_FALSE;
5080 if (_it->tooltip.style)
5081 elm_genlist_item_tooltip_style_set(it, NULL);
5085 elm_genlist_item_tooltip_style_set(Elm_Object_Item *it,
5088 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5089 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5091 eina_stringshare_replace(&_it->tooltip.style, style);
5092 if (VIEW(_it)) elm_widget_item_tooltip_style_set(_it, style);
5096 elm_genlist_item_tooltip_style_get(const Elm_Object_Item *it)
5098 return elm_object_item_tooltip_style_get(it);
5102 elm_genlist_item_tooltip_window_mode_set(Elm_Object_Item *it,
5105 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
5106 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5108 _it->tooltip.free_size = disable;
5109 if (VIEW(_it)) return elm_widget_item_tooltip_window_mode_set(_it, disable);
5114 elm_genlist_item_tooltip_window_mode_get(const Elm_Object_Item *it)
5116 return elm_object_tooltip_window_mode_get(VIEW(it));
5120 elm_genlist_item_cursor_set(Elm_Object_Item *it,
5123 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5124 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5125 eina_stringshare_replace(&_it->mouse_cursor, cursor);
5126 if (VIEW(_it)) elm_widget_item_cursor_set(_it, cursor);
5130 elm_genlist_item_cursor_get(const Elm_Object_Item *it)
5132 return elm_widget_item_cursor_get(it);
5136 elm_genlist_item_cursor_unset(Elm_Object_Item *it)
5138 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5139 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5141 if (!_it->mouse_cursor) return;
5143 if (VIEW(_it)) elm_widget_item_cursor_unset(_it);
5145 eina_stringshare_del(_it->mouse_cursor);
5146 _it->mouse_cursor = NULL;
5150 elm_genlist_item_cursor_style_set(Elm_Object_Item *it,
5153 elm_widget_item_cursor_style_set(it, style);
5157 elm_genlist_item_cursor_style_get(const Elm_Object_Item *it)
5159 return elm_widget_item_cursor_style_get(it);
5163 elm_genlist_item_cursor_engine_only_set(Elm_Object_Item *it,
5164 Eina_Bool engine_only)
5166 elm_widget_item_cursor_engine_only_set(it, engine_only);
5170 elm_genlist_item_cursor_engine_only_get(const Elm_Object_Item *it)
5172 return elm_widget_item_cursor_engine_only_get(it);
5176 elm_genlist_item_index_get(const Elm_Object_Item *it)
5178 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, -1);
5179 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5181 if (_it->item->block)
5182 return _it->position + _it->item->block->position;
5187 elm_genlist_mode_set(Evas_Object *obj,
5190 ELM_CHECK_WIDTYPE(obj, widtype);
5191 Widget_Data *wd = elm_widget_data_get(obj);
5193 if (wd->mode == mode) return;
5199 elm_genlist_horizontal_set(Evas_Object *obj,
5202 elm_genlist_mode_set(obj, mode);
5206 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5209 elm_genlist_mode_set(obj, mode);
5213 elm_genlist_mode_get(const Evas_Object *obj)
5215 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5216 Widget_Data *wd = elm_widget_data_get(obj);
5217 if (!wd) return ELM_LIST_LAST;
5221 EINA_DEPRECATED EAPI Elm_List_Mode
5222 elm_genlist_horizontal_get(const Evas_Object *obj)
5224 return elm_genlist_mode_get(obj);
5227 EINA_DEPRECATED EAPI Elm_List_Mode
5228 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5230 return elm_genlist_mode_get(obj);
5234 elm_genlist_always_select_mode_set(Evas_Object *obj,
5235 Eina_Bool always_select)
5237 ELM_CHECK_WIDTYPE(obj, widtype);
5238 Widget_Data *wd = elm_widget_data_get(obj);
5240 wd->always_select = !!always_select;
5244 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5246 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5247 Widget_Data *wd = elm_widget_data_get(obj);
5248 if (!wd) return EINA_FALSE;
5249 return wd->always_select;
5253 elm_genlist_no_select_mode_set(Evas_Object *obj,
5254 Eina_Bool no_select)
5256 ELM_CHECK_WIDTYPE(obj, widtype);
5257 Widget_Data *wd = elm_widget_data_get(obj);
5259 wd->no_select = !!no_select;
5263 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5265 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5266 Widget_Data *wd = elm_widget_data_get(obj);
5267 if (!wd) return EINA_FALSE;
5268 return wd->no_select;
5272 elm_genlist_compress_mode_set(Evas_Object *obj,
5275 ELM_CHECK_WIDTYPE(obj, widtype);
5276 Widget_Data *wd = elm_widget_data_get(obj);
5278 wd->compress = !!compress;
5279 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
5283 elm_genlist_compress_mode_get(const Evas_Object *obj)
5285 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5286 Widget_Data *wd = elm_widget_data_get(obj);
5287 if (!wd) return EINA_FALSE;
5288 return wd->compress;
5292 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5293 Eina_Bool height_for_width)
5295 ELM_CHECK_WIDTYPE(obj, widtype);
5296 Widget_Data *wd = elm_widget_data_get(obj);
5298 wd->height_for_width = !!height_for_width;
5299 if (wd->height_for_width)
5301 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5302 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5307 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5309 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5310 Widget_Data *wd = elm_widget_data_get(obj);
5311 if (!wd) return EINA_FALSE;
5312 return wd->height_for_width;
5316 elm_genlist_bounce_set(Evas_Object *obj,
5320 ELM_CHECK_WIDTYPE(obj, widtype);
5321 Widget_Data *wd = elm_widget_data_get(obj);
5323 wd->h_bounce = !!h_bounce;
5324 wd->v_bounce = !!v_bounce;
5325 elm_smart_scroller_bounce_allow_set(wd->scr, wd->h_bounce, wd->v_bounce);
5329 elm_genlist_bounce_get(const Evas_Object *obj,
5330 Eina_Bool *h_bounce,
5331 Eina_Bool *v_bounce)
5333 ELM_CHECK_WIDTYPE(obj, widtype);
5334 Widget_Data *wd = elm_widget_data_get(obj);
5336 if (h_bounce) *h_bounce = wd->h_bounce;
5337 if (v_bounce) *v_bounce = wd->v_bounce;
5341 elm_genlist_homogeneous_set(Evas_Object *obj,
5342 Eina_Bool homogeneous)
5344 ELM_CHECK_WIDTYPE(obj, widtype);
5345 Widget_Data *wd = elm_widget_data_get(obj);
5347 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5348 wd->homogeneous = !!homogeneous;
5352 elm_genlist_homogeneous_get(const Evas_Object *obj)
5354 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5355 Widget_Data *wd = elm_widget_data_get(obj);
5356 if (!wd) return EINA_FALSE;
5357 return wd->homogeneous;
5361 elm_genlist_block_count_set(Evas_Object *obj,
5364 ELM_CHECK_WIDTYPE(obj, widtype);
5365 Widget_Data *wd = elm_widget_data_get(obj);
5367 wd->max_items_per_block = count;
5368 wd->item_cache_max = wd->max_items_per_block * 2;
5369 _item_cache_clean(wd);
5373 elm_genlist_block_count_get(const Evas_Object *obj)
5375 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5376 Widget_Data *wd = elm_widget_data_get(obj);
5378 return wd->max_items_per_block;
5382 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5385 ELM_CHECK_WIDTYPE(obj, widtype);
5386 Widget_Data *wd = elm_widget_data_get(obj);
5388 wd->longpress_timeout = timeout;
5392 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5394 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5395 Widget_Data *wd = elm_widget_data_get(obj);
5397 return wd->longpress_timeout;
5401 elm_genlist_scroller_policy_set(Evas_Object *obj,
5402 Elm_Scroller_Policy policy_h,
5403 Elm_Scroller_Policy policy_v)
5405 ELM_CHECK_WIDTYPE(obj, widtype);
5406 Widget_Data *wd = elm_widget_data_get(obj);
5407 if ((!wd) || (!wd->scr)) return;
5408 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5409 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5411 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5415 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5416 Elm_Scroller_Policy *policy_h,
5417 Elm_Scroller_Policy *policy_v)
5419 ELM_CHECK_WIDTYPE(obj, widtype);
5420 Widget_Data *wd = elm_widget_data_get(obj);
5421 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5422 if ((!wd) || (!wd->scr)) return;
5423 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5424 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5425 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5429 elm_genlist_realized_items_update(Evas_Object *obj)
5431 ELM_CHECK_WIDTYPE(obj, widtype);
5433 Eina_List *list, *l;
5434 Elm_Object_Item *it;
5436 list = elm_genlist_realized_items_get(obj);
5437 EINA_LIST_FOREACH(list, l, it)
5438 elm_genlist_item_update(it);
5442 elm_genlist_item_mode_set(Elm_Object_Item *it,
5443 const char *mode_type,
5446 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
5447 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5449 Widget_Data *wd = _it->wd;
5451 Elm_Object_Item *it2;
5454 if (!mode_type) return;
5455 if ((_it->generation < _it->wd->generation) ||
5456 elm_widget_item_disabled_get(_it)) return;
5457 if (wd->edit_mode) return;
5459 if ((wd->mode_item == _it) &&
5460 (!strcmp(mode_type, wd->mode_type)) &&
5463 if (!_it->itc->mode_item_style) return;
5464 _it->mode_set = mode_set;
5468 EINA_LIST_FOREACH(wd->selected, l, it2)
5469 if (((Elm_Gen_Item *) it2)->realized)
5470 elm_genlist_item_selected_set(it2, EINA_FALSE);
5474 it2 = elm_genlist_selected_item_get(wd->obj);
5475 if ((it2) && (((Elm_Gen_Item *) it2)->realized))
5476 elm_genlist_item_selected_set(it2, EINA_FALSE);
5479 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5481 ((_it == wd->mode_item) && (!mode_set)))
5482 _item_mode_unset(wd);
5484 eina_stringshare_replace(&wd->mode_type, mode_type);
5485 if (mode_set) _item_mode_set(_it);
5489 elm_genlist_mode_item_style_get(const Evas_Object *obj)
5491 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5492 Widget_Data *wd = elm_widget_data_get(obj);
5493 if (!wd) return NULL;
5494 return wd->mode_item->itc->mode_item_style;
5498 elm_genlist_mode_item_style_set(Evas_Object *obj, const char *style)
5500 ELM_CHECK_WIDTYPE(obj, widtype);
5501 Widget_Data *wd = elm_widget_data_get(obj);
5503 if ((style == wd->mode_item->itc->mode_item_style) ||
5504 (style && wd->mode_item->itc->mode_item_style &&
5505 (!strcmp(style, wd->mode_item->itc->mode_item_style))))
5507 eina_stringshare_replace((const char**)&wd->mode_item->itc->mode_item_style, style);
5508 elm_genlist_realized_items_update(obj);
5512 elm_genlist_mode_type_get(const Evas_Object *obj)
5514 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5515 Widget_Data *wd = elm_widget_data_get(obj);
5516 if (!wd) return NULL;
5517 return wd->mode_type;
5520 EAPI const Elm_Object_Item *
5521 elm_genlist_mode_item_get(const Evas_Object *obj)
5523 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5524 Widget_Data *wd = elm_widget_data_get(obj);
5525 if (!wd) return NULL;
5526 return (Elm_Object_Item *) wd->mode_item;
5530 elm_genlist_edit_mode_get(const Evas_Object *obj)
5532 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5533 Widget_Data *wd = elm_widget_data_get(obj);
5534 if (!wd) return EINA_FALSE;
5536 return wd->edit_mode;
5540 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5542 ELM_CHECK_WIDTYPE(obj, widtype);
5543 Eina_List *list, *l;
5546 Widget_Data *wd = elm_widget_data_get(obj);
5548 edit_mode = !!edit_mode;
5549 if (wd->edit_mode == edit_mode) return;
5550 wd->edit_mode = edit_mode;
5552 list = elm_genlist_realized_items_get(obj);
5555 EINA_LIST_FOREACH(list, l, it)
5557 if (it->item->flags != ELM_GENLIST_ITEM_GROUP)
5558 _edit_mode_item_unrealize(it);
5560 _item_cache_zero(wd);
5564 EINA_LIST_FOREACH(list, l, it)
5566 if (it->item->flags != ELM_GENLIST_ITEM_GROUP)
5568 if (it->selected) _item_unselect(it);
5569 if (it->itc->edit_item_style)
5570 _edit_mode_item_realize(it, EINA_TRUE);
5574 if (wd->calc_job) ecore_job_del(wd->calc_job);
5575 wd->calc_job = ecore_job_add(_calc_job, wd);
5579 elm_genlist_reorder_mode_set(Evas_Object *obj,
5580 Eina_Bool reorder_mode)
5582 ELM_CHECK_WIDTYPE(obj, widtype);
5583 Widget_Data *wd = elm_widget_data_get(obj);
5585 wd->reorder_mode = !!reorder_mode;
5589 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5591 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5592 Widget_Data *wd = elm_widget_data_get(obj);
5593 if (!wd) return EINA_FALSE;
5594 return wd->reorder_mode;
5597 EAPI Elm_Genlist_Item_Flags
5598 elm_genlist_item_flags_get(const Elm_Object_Item *it)
5600 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ELM_GENLIST_ITEM_MAX);
5601 Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
5602 return _it->item->flags;
5605 EAPI Elm_Genlist_Item_Class *
5606 elm_genlist_item_class_new(void)
5608 Elm_Genlist_Item_Class *itc;
5610 itc = calloc(1, sizeof(Elm_Genlist_Item_Class));
5613 itc->version = ELM_GENLIST_ITEM_CLASS_VERSION;
5615 itc->delete_me = EINA_FALSE;
5621 elm_genlist_item_class_free(Elm_Genlist_Item_Class *itc)
5623 ELM_GENLIST_CHECK_ITC_VER(itc);
5624 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
5625 if (itc->refcount > 0) elm_genlist_item_class_unref(itc);
5634 elm_genlist_item_class_ref(Elm_Genlist_Item_Class *itc)
5636 ELM_GENLIST_CHECK_ITC_VER(itc);
5639 if (itc->refcount == 0) itc->refcount--;
5643 elm_genlist_item_class_unref(Elm_Genlist_Item_Class *itc)
5645 ELM_GENLIST_CHECK_ITC_VER(itc);
5647 if (itc->refcount > 0) itc->refcount--;
5648 if (itc->delete_me && (!itc->refcount))
5649 elm_genlist_item_class_free(itc);
5652 /* for gengrid as of now */
5654 _elm_genlist_page_relative_set(Evas_Object *obj,
5658 Evas_Coord pagesize_h;
5659 Evas_Coord pagesize_v;
5661 ELM_CHECK_WIDTYPE(obj, widtype);
5662 Widget_Data *wd = elm_widget_data_get(obj);
5665 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
5666 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
5670 /* for gengrid as of now */
5672 _elm_genlist_page_relative_get(const Evas_Object *obj,
5676 ELM_CHECK_WIDTYPE(obj, widtype);
5677 Widget_Data *wd = elm_widget_data_get(obj);
5680 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
5683 /* for gengrid as of now */
5685 _elm_genlist_page_size_set(Evas_Object *obj,
5686 Evas_Coord h_pagesize,
5687 Evas_Coord v_pagesize)
5692 ELM_CHECK_WIDTYPE(obj, widtype);
5693 Widget_Data *wd = elm_widget_data_get(obj);
5695 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
5696 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
5700 /* for gengrid as of now */
5702 _elm_genlist_current_page_get(const Evas_Object *obj,
5706 ELM_CHECK_WIDTYPE(obj, widtype);
5707 Widget_Data *wd = elm_widget_data_get(obj);
5709 elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber);
5712 /* for gengrid as of now */
5714 _elm_genlist_last_page_get(const Evas_Object *obj,
5718 ELM_CHECK_WIDTYPE(obj, widtype);
5719 Widget_Data *wd = elm_widget_data_get(obj);
5721 elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber);
5724 /* for gengrid as of now */
5726 _elm_genlist_page_show(const Evas_Object *obj,
5730 ELM_CHECK_WIDTYPE(obj, widtype);
5731 Widget_Data *wd = elm_widget_data_get(obj);
5733 elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber);
5736 /* for gengrid as of now */
5738 _elm_genlist_page_bring_in(const Evas_Object *obj,
5742 ELM_CHECK_WIDTYPE(obj, widtype);
5743 Widget_Data *wd = elm_widget_data_get(obj);
5745 elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber);
5749 _elm_genlist_item_unrealize(Elm_Gen_Item *it,
5752 Evas_Object *content;
5754 if (!it->realized) return;
5755 if (it->wd->reorder_it == it) return;
5757 evas_event_freeze(evas_object_evas_get(WIDGET(it)));
5759 evas_object_smart_callback_call(WIDGET(it), SIG_UNREALIZED, it);
5762 ecore_timer_del(it->long_timer);
5763 it->long_timer = NULL;
5766 elm_widget_stringlist_free(it->texts);
5768 elm_widget_stringlist_free(it->contents);
5769 it->contents = NULL;
5770 elm_widget_stringlist_free(it->states);
5773 EINA_LIST_FREE(it->content_objs, content)
5774 evas_object_del(content);
5776 it->unrealize_cb(it);
5778 it->realized = EINA_FALSE;
5779 it->want_unrealize = EINA_FALSE;
5780 evas_event_thaw(evas_object_evas_get(WIDGET(it)));
5781 evas_event_thaw_eval(evas_object_evas_get(WIDGET(it)));
5785 _elm_genlist_item_del_notserious(Elm_Gen_Item *it)
5787 elm_widget_item_pre_notify_del(it);
5788 it->generation = it->wd->generation - 1; /* This means that the item is deleted */
5789 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5791 if (it->itc->func.del)
5792 it->itc->func.del((void *)it->base.data, WIDGET(it));
5796 _elm_genlist_item_del_serious(Elm_Gen_Item *it)
5798 _elm_genlist_item_del_notserious(it);
5799 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5800 if (it->tooltip.del_cb)
5801 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
5802 it->wd->walking -= it->walking;
5803 if (it->long_timer) ecore_timer_del(it->long_timer);
5805 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
5809 eina_inlist_sorted_state_free(it->wd->state);
5810 it->wd->state = NULL;
5812 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5813 it->wd->calc_job = ecore_job_add(it->wd->calc_cb, it->wd);
5817 if (it->wd->last_selected_item == (Elm_Object_Item *) it)
5818 it->wd->last_selected_item = NULL;
5819 it->wd->item_count--;