2 #include <Elementary.h>
3 #include <Elementary_Cursor.h>
5 #include "elm_widget_genlist.h"
7 // internally allocated
8 #define CLASS_ALLOCATED 0x3a70f11f
10 #define MAX_ITEMS_PER_BLOCK 32
11 #define REORDER_EFFECT_TIME 0.1
13 EAPI const char ELM_GENLIST_SMART_NAME[] = "elm_genlist";
14 EAPI const char ELM_GENLIST_PAN_SMART_NAME[] = "elm_genlist_pan";
16 #define ERR_ABORT(_msg) \
18 if (getenv("ELM_ERROR_ABORT")) abort();
20 #define GL_IT(_it) (_it->item)
22 static const Evas_Smart_Interface *_smart_interfaces[] =
24 (Evas_Smart_Interface *)&ELM_SCROLLABLE_IFACE, NULL
27 static const char SIG_ACTIVATED[] = "activated";
28 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
29 static const char SIG_SELECTED[] = "selected";
30 static const char SIG_UNSELECTED[] = "unselected";
31 static const char SIG_EXPANDED[] = "expanded";
32 static const char SIG_CONTRACTED[] = "contracted";
33 static const char SIG_EXPAND_REQUEST[] = "expand,request";
34 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
35 static const char SIG_REALIZED[] = "realized";
36 static const char SIG_UNREALIZED[] = "unrealized";
37 static const char SIG_DRAG_START_UP[] = "drag,start,up";
38 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
39 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
40 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
41 static const char SIG_DRAG_STOP[] = "drag,stop";
42 static const char SIG_DRAG[] = "drag";
43 static const char SIG_LONGPRESSED[] = "longpressed";
44 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
45 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
46 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
47 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
48 static const char SIG_EDGE_TOP[] = "edge,top";
49 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
50 static const char SIG_EDGE_LEFT[] = "edge,left";
51 static const char SIG_EDGE_RIGHT[] = "edge,right";
52 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
53 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
54 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
55 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
56 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
57 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
58 static const char SIG_SWIPE[] = "swipe";
59 static const char SIG_MOVED[] = "moved";
60 static const char SIG_MOVED_AFTER[] = "moved,after";
61 static const char SIG_MOVED_BEFORE[] = "moved,before";
62 static const char SIG_INDEX_UPDATE[] = "index,update";
63 static const char SIG_TREE_EFFECT_FINISHED [] = "tree,effect,finished";
64 static const char SIG_HIGHLIGHTED[] = "highlighted";
65 static const char SIG_UNHIGHLIGHTED[] = "unhighlighted";
67 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
68 {SIG_CLICKED_DOUBLE, ""},
74 {SIG_EXPAND_REQUEST, ""},
75 {SIG_CONTRACT_REQUEST, ""},
78 {SIG_DRAG_START_UP, ""},
79 {SIG_DRAG_START_DOWN, ""},
80 {SIG_DRAG_START_LEFT, ""},
81 {SIG_DRAG_START_RIGHT, ""},
84 {SIG_LONGPRESSED, ""},
85 {SIG_SCROLL_ANIM_START, ""},
86 {SIG_SCROLL_ANIM_STOP, ""},
87 {SIG_SCROLL_DRAG_START, ""},
88 {SIG_SCROLL_DRAG_STOP, ""},
90 {SIG_EDGE_BOTTOM, ""},
93 {SIG_MULTI_SWIPE_LEFT, ""},
94 {SIG_MULTI_SWIPE_RIGHT, ""},
95 {SIG_MULTI_SWIPE_UP, ""},
96 {SIG_MULTI_SWIPE_DOWN, ""},
97 {SIG_MULTI_PINCH_OUT, ""},
98 {SIG_MULTI_PINCH_IN, ""},
101 {SIG_MOVED_AFTER, ""},
102 {SIG_MOVED_BEFORE, ""},
103 {SIG_TREE_EFFECT_FINISHED, ""},
104 {SIG_HIGHLIGHTED, ""},
105 {SIG_UNHIGHLIGHTED, ""},
109 EVAS_SMART_SUBCLASS_IFACE_NEW
110 (ELM_GENLIST_SMART_NAME, _elm_genlist, Elm_Genlist_Smart_Class,
111 Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks,
114 ELM_INTERNAL_SMART_SUBCLASS_NEW
115 (ELM_GENLIST_PAN_SMART_NAME, _elm_genlist_pan, Elm_Genlist_Pan_Smart_Class,
116 Elm_Pan_Smart_Class, elm_pan_smart_class_get, NULL);
118 static void _calc_job(void *);
119 static Eina_Bool _item_block_recalc(Item_Block *, int, Eina_Bool);
120 static void _item_mouse_callbacks_add(Elm_Gen_Item *, Evas_Object *);
121 static void _item_mouse_callbacks_del(Elm_Gen_Item *, Evas_Object *);
122 static void _access_activate_cb(void *data __UNUSED__,
123 Evas_Object *part_obj __UNUSED__,
124 Elm_Object_Item *item);
125 static void _item_select(Elm_Gen_Item *it);
127 static void _expand_toggle_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__);
128 static void _expand_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__);
129 static void _contract_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__);
130 static void _elm_genlist_item_state_update(Elm_Gen_Item *it, Item_Cache *ic);
131 static void _decorate_item_unrealize(Elm_Gen_Item *it);
132 static void _decorate_all_item_unrealize(Elm_Gen_Item *it);
135 _item_cache_all_free(Elm_Genlist_Smart_Data *sd)
137 // It would be better not to use
138 // EINA_INLIST_FOREACH or EINA_INLIST_FOREACH_SAFE
139 while (sd->item_cache)
141 Item_Cache *ic = EINA_INLIST_CONTAINER_GET(sd->item_cache->last, Item_Cache);
142 if (ic->spacer) evas_object_del(ic->spacer);
143 if (ic->base_view) evas_object_del(ic->base_view);
144 if (ic->item_style) eina_stringshare_del(ic->item_style);
145 sd->item_cache = eina_inlist_remove(sd->item_cache, EINA_INLIST_GET(ic));
146 // Free should be performed after inlist is poped
149 sd->item_cache = NULL;
150 sd->item_cache_count = 0;
154 _item_cache_push(Elm_Gen_Item *it)
156 Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
157 Item_Cache *ic = NULL;
159 if (sd->item_cache_count >= sd->item_cache_max)
161 ic = EINA_INLIST_CONTAINER_GET(sd->item_cache->last, Item_Cache);
162 if (ic->spacer) evas_object_del(ic->spacer);
163 if (ic->base_view) evas_object_del(ic->base_view);
164 eina_stringshare_del(ic->item_style);
165 sd->item_cache = eina_inlist_remove(sd->item_cache,
166 sd->item_cache->last);
167 sd->item_cache_count--;
168 // Free should be performed after inlist is poped
171 //evas_event_freeze(evas_object_evas_get(obj));
173 edje_object_mirrored_set(VIEW(it),
174 elm_widget_mirrored_get(WIDGET(it)));
175 edje_object_scale_set(VIEW(it),
176 elm_widget_scale_get(WIDGET(it))
177 * elm_config_scale_get());
179 // FIXME: other callbacks?
180 edje_object_signal_callback_del_full(VIEW(it), "elm,action,expand,toggle",
181 "elm", _expand_toggle_signal_cb, it);
182 edje_object_signal_callback_del_full(VIEW(it), "elm,action,expand", "elm",
183 _expand_signal_cb, it);
184 edje_object_signal_callback_del_full(VIEW(it), "elm,action,contract", "elm",
185 _contract_signal_cb, it);
186 _item_mouse_callbacks_del(it, VIEW(it));
188 if ((it->item->nocache_once) || (it->item->nocache))
190 if (VIEW(it)) evas_object_del(VIEW(it));
191 if (it->spacer) evas_object_del(it->spacer);
194 ic = ELM_NEW(Item_Cache);
197 if (VIEW(it)) evas_object_del(VIEW(it));
198 if (it->spacer) evas_object_del(it->spacer);
203 ecore_timer_del(it->long_timer);
204 it->long_timer = NULL;
206 if (it->item->swipe_timer)
208 ecore_timer_del(it->item->swipe_timer);
209 it->item->swipe_timer = NULL;
212 ic->base_view = VIEW(it);
213 ic->spacer = it->spacer;
214 ic->item_style = eina_stringshare_add(it->itc->item_style);
215 if (it->item->type & ELM_GENLIST_ITEM_TREE) ic->tree = 1;
217 ic->selected = it->selected;
218 ic->disabled = elm_widget_item_disabled_get(it);
219 ic->expanded = it->item->expanded;
220 if (it->item->type & ELM_GENLIST_ITEM_TREE) ic->tree = 1;
222 edje_object_signal_emit(ic->base_view, "elm,state,unselected", "elm");
223 evas_object_hide(ic->base_view);
225 sd->item_cache = eina_inlist_prepend(sd->item_cache, EINA_INLIST_GET(ic));
226 sd->item_cache_count++;
232 it->realized = EINA_FALSE;
233 it->want_unrealize = EINA_FALSE;
235 //evas_event_thaw(evas_object_evas_get(obj));
236 //evas_event_thaw_eval(evas_object_evas_get(obj));
240 _item_cache_pop(Elm_Gen_Item *it)
242 Item_Cache *ic = NULL;
245 Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
247 if (it->item->nocache_once) {
248 it->item->nocache_once = EINA_FALSE;
251 if (it->item->nocache) return EINA_FALSE;
253 if (it->item->type & ELM_GENLIST_ITEM_TREE) tree = 1;
254 EINA_INLIST_FOREACH_SAFE(sd->item_cache, l, ic)
256 if ((ic->selected) || (ic->disabled) || (ic->expanded))
259 if ((ic->tree == tree) &&
260 (((!it->itc->item_style) && (!ic->item_style)) ||
261 (it->itc->item_style && ic->item_style &&
262 (!strcmp(it->itc->item_style, ic->item_style)))))
265 eina_inlist_remove(sd->item_cache, EINA_INLIST_GET(ic));
266 sd->item_cache_count--;
268 VIEW(it) = ic->base_view;
269 it->spacer = ic->spacer;
271 edje_object_signal_callback_add
272 (VIEW(it), "elm,action,expand,toggle", "elm",
273 _expand_toggle_signal_cb, it);
274 edje_object_signal_callback_add
275 (VIEW(it), "elm,action,expand", "elm", _expand_signal_cb, it);
276 edje_object_signal_callback_add
277 (VIEW(it), "elm,action,contract", "elm", _contract_signal_cb, it);
278 _item_mouse_callbacks_add(it, VIEW(it));
280 eina_stringshare_del(ic->item_style);
290 _elm_genlist_pan_smart_pos_set(Evas_Object *obj,
296 ELM_GENLIST_PAN_DATA_GET(obj, psd);
298 if ((x == psd->wsd->pan_x) && (y == psd->wsd->pan_y)) return;
302 EINA_INLIST_FOREACH(psd->wsd->blocks, itb)
304 if ((itb->y + itb->h) > y)
309 EINA_LIST_FOREACH(itb->items, l2, it)
311 if ((itb->y + it->y) >= y)
313 psd->wsd->anchor_item = it;
314 psd->wsd->anchor_y = -(itb->y + it->y - y);
321 if (!psd->wsd->reorder_move_animator) evas_object_smart_changed(obj);
325 _elm_genlist_pan_smart_pos_get(const Evas_Object *obj,
329 ELM_GENLIST_PAN_DATA_GET(obj, psd);
331 if (x) *x = psd->wsd->pan_x;
332 if (y) *y = psd->wsd->pan_y;
336 _elm_genlist_pan_smart_pos_max_get(const Evas_Object *obj,
342 ELM_GENLIST_PAN_DATA_GET(obj, psd);
344 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
345 ow = psd->wsd->minw - ow;
347 oh = psd->wsd->minh - oh;
354 _elm_genlist_pan_smart_pos_min_get(const Evas_Object *obj __UNUSED__,
363 _elm_genlist_pan_smart_content_size_get(const Evas_Object *obj,
367 ELM_GENLIST_PAN_DATA_GET(obj, psd);
369 if (w) *w = psd->wsd->minw;
370 if (h) *h = psd->wsd->minh;
374 _elm_genlist_pan_smart_add(Evas_Object *obj)
376 /* here just to allocate our extended data */
377 EVAS_SMART_DATA_ALLOC(obj, Elm_Genlist_Pan_Smart_Data);
379 ELM_PAN_CLASS(_elm_genlist_pan_parent_sc)->base.add(obj);
383 _elm_genlist_pan_smart_del(Evas_Object *obj)
385 ELM_GENLIST_PAN_DATA_GET(obj, psd);
389 ecore_job_del(psd->resize_job);
390 psd->resize_job = NULL;
393 _elm_genlist_pan_parent_sc->base.del(obj);
397 _elm_genlist_pan_smart_move(Evas_Object *obj,
398 Evas_Coord x __UNUSED__,
399 Evas_Coord y __UNUSED__)
401 ELM_GENLIST_PAN_DATA_GET(obj, psd);
403 psd->wsd->pan_changed = EINA_TRUE;
404 evas_object_smart_changed(obj);
405 if (psd->wsd->calc_job) ecore_job_del(psd->wsd->calc_job);
406 psd->wsd->calc_job = NULL;
410 _elm_genlist_pan_smart_resize_job(void *data)
412 Elm_Genlist_Pan_Smart_Data *psd = data;
414 elm_layout_sizing_eval(ELM_WIDGET_DATA(psd->wsd)->obj);
415 psd->resize_job = NULL;
419 _elm_genlist_pan_smart_resize(Evas_Object *obj,
425 ELM_GENLIST_PAN_DATA_GET(obj, psd);
427 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
428 if ((ow == w) && (oh == h)) return;
429 if ((psd->wsd->mode == ELM_LIST_COMPRESS) && (ow != w))
432 if (psd->resize_job) ecore_job_del(psd->resize_job);
434 ecore_job_add(_elm_genlist_pan_smart_resize_job, psd);
436 psd->wsd->pan_changed = EINA_TRUE;
437 evas_object_smart_changed(obj);
438 if (psd->wsd->calc_job) ecore_job_del(psd->wsd->calc_job);
439 // if the widht changed we may have to resize content if scrollbar went
440 // away or appesared to queue a job to deal with it. it should settle in
441 // the end to a steady-state
443 psd->wsd->calc_job = ecore_job_add(_calc_job, psd->wsd);
445 psd->wsd->calc_job = NULL;
449 _item_scroll(Elm_Genlist_Smart_Data *sd)
452 Elm_Gen_Item *it = NULL;
453 Evas_Coord ow, oh, dx = 0, dy = 0, dw = 0, dh = 0;
455 if (!sd->show_item) return;
457 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &ow, &oh);
459 dx = it->x + it->item->block->x;
460 dy = it->y + it->item->block->y;
461 dw = it->item->block->w;
464 switch (sd->scroll_to_type)
466 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
467 if (it->item->group_item) gith = it->item->group_item->item->h;
471 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
472 dy += ((it->item->h / 2) - (oh / 2));
475 case ELM_GENLIST_ITEM_SCROLLTO_IN:
477 if ((sd->expanded_item) &&
478 ((sd->show_item->y + sd->show_item->item->block->y
479 + sd->show_item->item->h) -
480 (sd->expanded_item->y + sd->expanded_item->item->block->y) > oh))
482 it = sd->expanded_item;
483 if (it->item->group_item) gith = it->item->group_item->item->h;
484 dx = it->x + it->item->block->x;
485 dy = it->y + it->item->block->y - gith;
486 dw = it->item->block->w;
490 if ((it->item->group_item) &&
491 (sd->pan_y > (it->y + it->item->block->y)))
492 gith = it->item->group_item->item->h;
499 sd->s_iface->region_bring_in(ELM_WIDGET_DATA(sd)->obj, dx, dy, dw, dh);
501 sd->s_iface->content_region_show
502 (ELM_WIDGET_DATA(sd)->obj, dx, dy, dw, dh);
504 it->item->show_me = EINA_FALSE;
505 sd->show_item = NULL;
506 sd->auto_scroll_enabled = EINA_FALSE;
507 sd->check_scroll = EINA_FALSE;
511 _item_unrealize(Elm_Gen_Item *it,
514 Evas_Object *content;
518 if (!it->realized) return;
519 if (GL_IT(it)->wsd->reorder_it == it) return;
520 #if GENLIST_ENTRY_SUPPORT
521 if (it->item->unrealize_disabled)
523 evas_object_hide(VIEW(it));
528 //evas_event_freeze(evas_object_evas_get(WIDGET(it)));
530 evas_object_smart_callback_call(WIDGET(it), SIG_UNREALIZED, it);
533 ecore_timer_del(it->long_timer);
534 it->long_timer = NULL;
536 if (it->item->swipe_timer)
538 ecore_timer_del(it->item->swipe_timer);
539 it->item->swipe_timer = NULL;
543 EINA_LIST_FOREACH(it->texts, l, part)
544 edje_object_part_text_set(VIEW(it), part, NULL);
546 elm_widget_stringlist_free(it->texts);
548 elm_widget_stringlist_free(it->contents);
550 elm_widget_stringlist_free(it->states);
552 EINA_LIST_FREE(it->content_objs, content)
554 // FIXME: If parent-child relationship was broken before 'ic'
555 // is deleted, freeze_pop will not be called. ex) elm_slider
556 // If layout is used instead of edje, this problme can be
558 if (0 != elm_widget_scroll_freeze_get(content))
559 elm_widget_scroll_freeze_pop(content);
560 evas_object_del(content);
564 elm_widget_stringlist_free(it->item->flip_contents);
565 it->item->flip_contents = NULL;
566 EINA_LIST_FREE(it->item->flip_content_objs, content)
567 evas_object_del(content);
570 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
571 _elm_access_widget_item_unregister((Elm_Widget_Item *)it);
573 // unswallow VIEW(it) first then manipulate VIEW(it)
574 _decorate_item_unrealize(it);
575 _decorate_all_item_unrealize(it);
577 it->realized = EINA_FALSE;
578 _item_cache_push(it);
580 #if GENLIST_ENTRY_SUPPORT
581 it->item->unrealize_disabled = EINA_FALSE;
583 it->want_unrealize = EINA_FALSE;
584 //evas_event_thaw(evas_object_evas_get(WIDGET(it)));
585 //evas_event_thaw_eval(evas_object_evas_get(WIDGET(it)));
589 _item_block_unrealize(Item_Block *itb)
593 Eina_Bool dragging = EINA_FALSE;
595 if (!itb->realized) return;
596 //evas_event_freeze(evas_object_evas_get(ELM_WIDGET_DATA(itb->sd)->obj));
598 EINA_LIST_FOREACH(itb->items, l, it)
600 if (itb->must_recalc || !it->group)
604 dragging = EINA_TRUE;
605 it->want_unrealize = EINA_TRUE;
608 _item_unrealize(it, EINA_FALSE);
613 itb->realized = EINA_FALSE;
614 itb->want_unrealize = EINA_TRUE;
617 itb->want_unrealize = EINA_FALSE;
618 //evas_event_thaw(evas_object_evas_get(ELM_WIDGET_DATA(itb->sd)->obj));
619 //evas_event_thaw_eval(evas_object_evas_get(ELM_WIDGET_DATA(itb->sd)->obj));
623 _must_recalc_idler(void *data)
625 Elm_Genlist_Smart_Data *sd = data;
627 if (sd->calc_job) ecore_job_del(sd->calc_job);
628 sd->calc_job = ecore_job_add(_calc_job, sd);
629 sd->must_recalc_idler = NULL;
630 return ECORE_CALLBACK_CANCEL;
634 _calc_job(void *data)
637 Item_Block *itb, *chb = NULL;
638 Evas_Coord pan_w = 0, pan_h = 0;
639 Elm_Genlist_Smart_Data *sd = data;
640 Eina_Bool minw_change = EINA_FALSE;
641 Eina_Bool did_must_recalc = EINA_FALSE;
642 Evas_Coord minw = -1, minh = 0, y = 0, ow, dy = 0, vw = 0;
644 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &ow, &sd->h);
645 if (sd->mode == ELM_LIST_COMPRESS)
646 sd->s_iface->content_viewport_size_get(ELM_WIDGET_DATA(sd)->obj, &vw, NULL);
648 if (sd->w != ow) sd->w = ow;
650 //evas_event_freeze(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
651 EINA_INLIST_FOREACH(sd->blocks, itb)
653 Eina_Bool show_me = EINA_FALSE;
656 show_me = itb->show_me;
657 itb->show_me = EINA_FALSE;
660 if (itb->realized) _item_block_unrealize(itb);
662 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
664 if (itb->must_recalc)
669 EINA_LIST_FOREACH(itb->items, l, it)
670 if (it->item->mincalcd) it->item->mincalcd = EINA_FALSE;
671 itb->changed = EINA_TRUE;
672 did_must_recalc = EINA_TRUE;
673 if (itb->realized) _item_block_unrealize(itb);
674 itb->must_recalc = EINA_FALSE;
676 show_me = _item_block_recalc(itb, in, EINA_FALSE);
682 if (minw == -1) minw = itb->minw;
683 else if ((!itb->must_recalc) && (minw < itb->minw))
686 minw_change = EINA_TRUE;
688 if ((sd->mode == ELM_LIST_COMPRESS) && (minw > vw))
691 minw_change = EINA_TRUE;
697 if ((show_me) && (sd->show_item) && (!sd->show_item->item->queued))
698 sd->check_scroll = EINA_TRUE;
702 EINA_INLIST_FOREACH(sd->blocks, itb)
708 if ((chb) && (EINA_INLIST_GET(chb)->next))
710 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
712 if (itb->realized) _item_block_unrealize(itb);
716 if (minw < sd->w) minw = sd->w;
717 if ((minw != sd->minw) || (minh != sd->minh))
721 evas_object_smart_callback_call(sd->pan_obj, "changed", NULL);
722 elm_layout_sizing_eval(ELM_WIDGET_DATA(sd)->obj);
729 if ((sd->anchor_item) && (sd->anchor_item->item->block)
730 && (!sd->auto_scroll_enabled))
735 it = sd->anchor_item;
737 sd->s_iface->content_pos_set
738 (ELM_WIDGET_DATA(sd)->obj, sd->pan_x, it->item->block->y
740 sd->anchor_item = it;
746 if (!sd->must_recalc_idler)
747 sd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, sd);
749 if (sd->check_scroll)
751 _elm_genlist_pan_smart_content_size_get(sd->pan_obj, &pan_w, &pan_h);
752 if (EINA_INLIST_GET(sd->show_item) == sd->items->last)
753 sd->scroll_to_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
755 switch (sd->scroll_to_type)
757 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
761 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
765 case ELM_GENLIST_ITEM_SCROLLTO_IN:
770 if ((sd->show_item) && (sd->show_item->item->block))
772 if ((pan_w > (sd->show_item->x + sd->show_item->item->block->x))
773 && (pan_h > (sd->show_item->y + sd->show_item->item->block->y
782 evas_object_smart_changed(sd->pan_obj);
783 //evas_event_thaw(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
784 //evas_event_thaw_eval(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
788 _elm_genlist_smart_sizing_eval(Evas_Object *obj)
790 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
791 Evas_Coord vmw = 0, vmh = 0;
793 ELM_GENLIST_DATA_GET(obj, sd);
795 /* parent class' early call */
796 if (!sd->s_iface) return;
798 if (sd->on_sub_del) return;;
800 evas_object_size_hint_min_get(obj, &minw, NULL);
801 evas_object_size_hint_max_get(obj, &maxw, &maxh);
803 edje_object_size_min_calc(ELM_WIDGET_DATA(sd)->resize_obj, &vmw, &vmh);
805 if (sd->mode == ELM_LIST_COMPRESS)
809 sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
810 if ((vw != 0) && (vw != sd->prev_viewport_w))
814 sd->prev_viewport_w = vw;
816 EINA_INLIST_FOREACH(sd->blocks, itb)
818 itb->must_recalc = EINA_TRUE;
820 if (sd->calc_job) ecore_job_del(sd->calc_job);
821 sd->calc_job = ecore_job_add(_calc_job, sd);
826 else if (sd->mode == ELM_LIST_LIMIT)
829 minw = vmw + sd->realminw;
837 evas_object_size_hint_min_set(obj, minw, minh);
838 evas_object_size_hint_max_set(obj, maxw, maxh);
842 _item_contract_emit(Elm_Gen_Item *it)
847 edje_object_signal_emit(VIEW(it), "elm,state,contract_flip", "");
848 it->item->tree_effect_finished = EINA_FALSE;
850 EINA_LIST_FOREACH(it->item->items, l, it2)
851 if (it2) _item_contract_emit(it2);
855 _item_tree_effect_before(Elm_Gen_Item *it)
860 EINA_LIST_FOREACH(it->item->items, l, it2)
862 if (it2->parent && (it == it2->parent))
865 it2->item->tree_effect_hide_me = EINA_TRUE;
866 if (GL_IT(it)->wsd->move_effect_mode ==
867 ELM_GENLIST_TREE_EFFECT_EXPAND)
868 edje_object_signal_emit(VIEW(it2), "elm,state,hide", "");
869 else if (GL_IT(it)->wsd->move_effect_mode ==
870 ELM_GENLIST_TREE_EFFECT_CONTRACT)
871 _item_contract_emit(it2);
874 return ECORE_CALLBACK_CANCEL;
878 _item_position(Elm_Gen_Item *it,
886 //evas_event_freeze(evas_object_evas_get(ELM_WIDGET_DATA(GL_IT(it)->wsd)->obj));
887 evas_object_resize(view, it->item->w, it->item->h);
888 evas_object_move(view, it_x, it_y);
889 evas_object_show(view);
890 //evas_event_thaw(evas_object_evas_get(ELM_WIDGET_DATA(GL_IT(it)->wsd)->obj));
891 //evas_event_thaw_eval(evas_object_evas_get(ELM_WIDGET_DATA(GL_IT(it)->wsd)->obj));
895 _item_tree_effect(Elm_Genlist_Smart_Data *sd,
898 Elm_Gen_Item *it = NULL, *expanded_next_it;
900 expanded_next_it = sd->expanded_next_item;
902 if (sd->move_effect_mode == ELM_GENLIST_TREE_EFFECT_EXPAND)
904 it = (Elm_Gen_Item *)elm_genlist_item_prev_get
905 ((Elm_Object_Item *)expanded_next_it);
908 if (it->item->expanded_depth <=
909 expanded_next_it->item->expanded_depth) break;
910 if (it->item->scrl_y &&
911 (it->item->scrl_y <= expanded_next_it->item->old_scrl_y + y)
912 && (it->item->expanded_depth >
913 expanded_next_it->item->expanded_depth))
915 if (!it->item->tree_effect_finished)
917 edje_object_signal_emit(VIEW(it), "flip_item", "");
919 (it, VIEW(it), it->item->scrl_x, it->item->scrl_y);
920 it->item->tree_effect_finished = EINA_TRUE;
923 it = (Elm_Gen_Item *)elm_genlist_item_prev_get
924 ((Elm_Object_Item *)it);
927 else if (sd->move_effect_mode == ELM_GENLIST_TREE_EFFECT_CONTRACT)
929 it = (Elm_Gen_Item *)elm_genlist_item_prev_get
930 ((Elm_Object_Item *)expanded_next_it);
933 if ((it->item->scrl_y > expanded_next_it->item->old_scrl_y + y) &&
934 (it->item->expanded_depth >
935 expanded_next_it->item->expanded_depth))
937 if (!it->item->tree_effect_finished)
939 edje_object_signal_emit(VIEW(it), "elm,state,hide", "");
940 it->item->tree_effect_finished = EINA_TRUE;
945 it = (Elm_Gen_Item *)elm_genlist_item_prev_get
946 ((Elm_Object_Item *)it);
952 _item_sub_items_clear(Elm_Gen_Item *it)
955 Elm_Object_Item *it2;
957 EINA_LIST_FOREACH_SAFE(it->item->items, l, ll, it2)
958 elm_widget_item_del(it2);
962 _item_auto_scroll(Elm_Genlist_Smart_Data *sd)
964 Elm_Gen_Item *tmp_item = NULL;
966 if ((sd->expanded_item) && (sd->auto_scroll_enabled))
968 tmp_item = eina_list_data_get
969 (eina_list_last(sd->expanded_item->item->items));
970 if (!tmp_item) return;
971 sd->show_item = tmp_item;
972 sd->bring_in = EINA_TRUE;
973 sd->scroll_to_type = ELM_GENLIST_ITEM_SCROLLTO_IN;
974 if ((sd->show_item->item->queued) || (!sd->show_item->item->mincalcd))
976 sd->show_item->item->show_me = EINA_TRUE;
977 sd->auto_scroll_enabled = EINA_FALSE;
985 _item_tree_effect_finish(Elm_Genlist_Smart_Data *sd)
987 Elm_Gen_Item *it = NULL;
990 if (sd->tree_effect_animator)
992 if (sd->move_effect_mode == ELM_GENLIST_TREE_EFFECT_CONTRACT)
993 _item_sub_items_clear(sd->expanded_item);
995 EINA_LIST_FOREACH(sd->expanded_item->item->items, l, it)
997 it->item->tree_effect_finished = EINA_TRUE;
998 it->item->old_scrl_y = it->item->scrl_y;
999 if (GL_IT(it)->wsd->move_effect_mode ==
1000 ELM_GENLIST_TREE_EFFECT_EXPAND)
1001 edje_object_signal_emit(VIEW(it), "elm,state,show", "");
1005 _item_auto_scroll(sd);
1006 evas_object_lower(sd->alpha_bg);
1007 evas_object_hide(sd->alpha_bg);
1008 sd->move_effect_mode = ELM_GENLIST_TREE_EFFECT_NONE;
1009 if (sd->move_items) sd->move_items = eina_list_free(sd->move_items);
1011 evas_object_smart_callback_call(sd->pan_obj, "changed", NULL);
1012 evas_object_smart_callback_call
1013 (ELM_WIDGET_DATA(sd)->obj, SIG_TREE_EFFECT_FINISHED, NULL);
1014 evas_object_smart_changed(sd->pan_obj);
1016 sd->tree_effect_animator = NULL;
1020 _elm_genlist_item_odd_even_update(Elm_Gen_Item *it)
1022 if (!it->item->nostacking)
1024 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
1026 if (it->deco_all_view) evas_object_lower(it->deco_all_view);
1027 else evas_object_lower(VIEW(it));
1031 if (it->deco_all_view) evas_object_raise(it->deco_all_view);
1032 else evas_object_raise(VIEW(it));
1036 if (it->item->order_num_in & 0x1)
1038 edje_object_signal_emit(VIEW(it), "elm,state,odd", "elm");
1039 if (it->deco_all_view)
1040 edje_object_signal_emit(it->deco_all_view, "elm,state,odd", "elm");
1044 edje_object_signal_emit(VIEW(it), "elm,state,even", "elm");
1045 if (it->deco_all_view)
1046 edje_object_signal_emit(it->deco_all_view, "elm,state,even", "elm");
1051 _item_order_update(const Eina_Inlist *l,
1054 Elm_Gen_Item *it, *it2;
1056 for (it = ELM_GEN_ITEM_FROM_INLIST(l); l; l = l->next,
1057 it = ELM_GEN_ITEM_FROM_INLIST(l))
1059 it->item->order_num_in = start++;
1060 _elm_genlist_item_odd_even_update(it);
1061 it2 = ELM_GEN_ITEM_FROM_INLIST(l->next);
1062 if (it2 && (it->item->order_num_in != it2->item->order_num_in))
1068 _elm_genlist_item_state_update(Elm_Gen_Item *it,
1073 if (it->selected != itc->selected)
1077 if (it->deco_all_view)
1078 edje_object_signal_emit
1079 (it->deco_all_view, "elm,state,selected", "elm");
1080 edje_object_signal_emit
1081 (VIEW(it), "elm,state,selected", "elm");
1082 evas_object_smart_callback_call(WIDGET(it), SIG_HIGHLIGHTED, it);
1085 if (elm_widget_item_disabled_get(it) != itc->disabled)
1087 if (elm_widget_item_disabled_get(it))
1088 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1089 if (it->deco_all_view)
1090 edje_object_signal_emit
1091 (it->deco_all_view, "elm,state,disabled", "elm");
1093 if (it->item->expanded != itc->expanded)
1095 if (it->item->expanded)
1096 edje_object_signal_emit(VIEW(it), "elm,state,expanded", "elm");
1097 if (it->deco_all_view)
1098 edje_object_signal_emit
1099 (it->deco_all_view, "elm,state,expanded", "elm");
1106 if (it->deco_all_view)
1107 edje_object_signal_emit
1108 (it->deco_all_view, "elm,state,selected", "elm");
1109 edje_object_signal_emit
1110 (VIEW(it), "elm,state,selected", "elm");
1111 evas_object_smart_callback_call(WIDGET(it), SIG_HIGHLIGHTED, it);
1113 if (elm_widget_item_disabled_get(it))
1115 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1116 if (it->deco_all_view)
1117 edje_object_signal_emit
1118 (it->deco_all_view, "elm,state,disabled", "elm");
1120 if (it->item->expanded)
1122 edje_object_signal_emit(VIEW(it), "elm,state,expanded", "elm");
1123 if (it->deco_all_view)
1124 edje_object_signal_emit
1125 (it->deco_all_view, "elm,state,expanded", "elm");
1131 _elm_genlist_item_index_update(Elm_Gen_Item *it)
1133 if (it->position_update || it->item->block->position_update)
1135 evas_object_smart_callback_call(WIDGET(it), SIG_INDEX_UPDATE, it);
1136 it->position_update = EINA_FALSE;
1141 _item_text_realize(Elm_Gen_Item *it,
1142 Evas_Object *target,
1146 if (it->itc->func.text_get)
1152 *source = elm_widget_stringlist_get
1153 (edje_object_data_get(target, "texts"));
1154 EINA_LIST_FOREACH(*source, l, key)
1156 if (parts && fnmatch(parts, key, FNM_PERIOD))
1159 char *s = it->itc->func.text_get
1160 ((void *)it->base.data, WIDGET(it), key);
1164 edje_object_part_text_escaped_set(target, key, s);
1169 edje_object_part_text_set(target, key, "");
1176 // FIXME: difference from upstream
1178 _content_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1180 Elm_Gen_Item *it = data;
1181 if (it) it->defer_unrealize = EINA_TRUE;
1185 _content_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1187 Elm_Gen_Item *it = data;
1188 if (it) it->defer_unrealize = EINA_FALSE;
1193 _item_mode_content_realize(Elm_Gen_Item *it,
1194 Evas_Object *target,
1197 Eina_List **contents_list)
1199 Eina_List *res = *contents_list;
1201 if (it->itc->func.content_get)
1207 EINA_LIST_FOREACH(*source, l, key)
1209 if (parts && fnmatch(parts, key, FNM_PERIOD))
1212 ic = it->itc->func.content_get
1213 ((void *)it->base.data, WIDGET(it), key);
1217 res = eina_list_append(res, ic);
1218 edje_object_part_swallow(target, key, ic);
1219 evas_object_show(ic);
1220 #if GENLIST_ENTRY_SUPPORT
1223 // For entry or editfield
1224 // 1. Add resize callback for multiline entry.
1225 // 2. Do not unrealize it for focus issue
1226 // ps. Only for entry because of performnace
1227 if (!strcmp("elm_layout", evas_object_type_get(ic)))
1229 // If editfield style, it can have entry.
1231 edje_object_file_get(elm_layout_edje_get(ic), NULL, &group);
1232 if (group && !strncmp("elm/layout/editfield/", group, 20))
1233 it->item->unrealize_disabled = EINA_TRUE;
1235 else if (!strcmp("elm_entry", evas_object_type_get(ic)))
1236 it->item->unrealize_disabled = EINA_TRUE;
1240 // FIXME: difference from upstream
1243 // FIXME: if entry calcuates its cursor position correctly and conformant works,
1244 // genlist does not need to handle this focus thing.
1245 evas_object_smart_callback_add(ic, "focused", _content_focused, it);
1246 evas_object_smart_callback_add(ic, "unfocused", _content_unfocused, it);
1249 if (elm_widget_item_disabled_get(it))
1250 elm_widget_disabled_set(ic, EINA_TRUE);
1259 _item_state_realize(Elm_Gen_Item *it,
1260 Evas_Object *target,
1264 if (it->itc->func.state_get)
1271 *source = elm_widget_stringlist_get
1272 (edje_object_data_get(target, "states"));
1273 EINA_LIST_FOREACH(*source, l, key)
1275 if (parts && fnmatch(parts, key, FNM_PERIOD))
1278 Eina_Bool on = it->itc->func.state_get
1279 ((void *)it->base.data, WIDGET(it), key);
1283 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1284 edje_object_signal_emit(target, buf, "elm");
1288 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1289 edje_object_signal_emit(target, buf, "elm");
1296 _decorate_item_unrealize(Elm_Gen_Item *it)
1298 Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
1299 Evas_Object *content;
1301 if (!it->item->deco_it_view) return;
1303 //evas_event_freeze(evas_object_evas_get(obj));
1304 elm_widget_stringlist_free(it->item->deco_it_texts);
1305 it->item->deco_it_texts = NULL;
1306 elm_widget_stringlist_free(it->item->deco_it_contents);
1307 it->item->deco_it_contents = NULL;
1308 elm_widget_stringlist_free(it->item->deco_it_states);
1310 EINA_LIST_FREE (it->item->deco_it_content_objs, content)
1311 evas_object_del(content);
1313 edje_object_part_unswallow(it->item->deco_it_view, VIEW(it));
1314 evas_object_smart_member_add(VIEW(it), sd->pan_obj);
1315 evas_object_del(it->item->deco_it_view);
1316 it->item->deco_it_view = NULL;
1318 if (sd->mode_item == it) sd->mode_item = NULL;
1319 //evas_event_thaw(evas_object_evas_get(obj));
1320 //evas_event_thaw_eval(evas_object_evas_get(obj));
1325 _decorate_all_item_position(Elm_Gen_Item *it,
1329 evas_object_resize(it->deco_all_view, it->item->w, it->item->h);
1330 evas_object_move(it->deco_all_view, itx, ity);
1334 _decorate_all_item_realize(Elm_Gen_Item *it,
1335 Eina_Bool effect_on)
1338 const char *stacking;
1339 const char *stacking_even;
1341 if ((!it) || (it->item->decorate_all_item_realized)) return;
1343 if (it->item->deco_it_view) _decorate_item_unrealize(it);
1345 it->deco_all_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
1346 edje_object_scale_set(it->deco_all_view, elm_widget_scale_get(WIDGET(it)) *
1347 elm_config_scale_get());
1348 evas_object_smart_member_add(it->deco_all_view, GL_IT(it)->wsd->pan_obj);
1349 elm_widget_sub_object_add(WIDGET(it), it->deco_all_view);
1351 if (it->item->type & ELM_GENLIST_ITEM_TREE)
1352 strncpy(buf, "tree", sizeof(buf));
1353 else strncpy(buf, "item", sizeof(buf));
1354 if (GL_IT(it)->wsd->mode == ELM_LIST_COMPRESS)
1355 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1357 strncat(buf, "/", sizeof(buf) - strlen(buf));
1358 strncat(buf, it->itc->decorate_all_item_style, sizeof(buf) - strlen(buf));
1360 elm_widget_theme_object_set(WIDGET(it), it->deco_all_view, "genlist", buf,
1361 elm_widget_style_get(WIDGET(it)));
1363 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
1364 if (!stacking_even) stacking_even = "above";
1365 it->item->stacking_even = !!strcmp("above", stacking_even);
1367 stacking = edje_object_data_get(VIEW(it), "stacking");
1368 if (!stacking) stacking = "yes";
1369 it->item->nostacking = !!strcmp("yes", stacking);
1371 edje_object_mirrored_set
1372 (it->deco_all_view, elm_widget_mirrored_get(WIDGET(it)));
1374 _elm_genlist_item_odd_even_update(it);
1375 _elm_genlist_item_state_update(it, NULL);
1379 edje_object_signal_emit
1380 (it->deco_all_view, "elm,state,decorate,enabled,effect", "elm");
1381 edje_object_signal_emit
1382 (VIEW(it), "elm,state,decorate,enabled,effect", "elm");
1386 edje_object_signal_emit
1387 (it->deco_all_view, "elm,state,decorate,enabled", "elm");
1388 edje_object_signal_emit
1389 (VIEW(it), "elm,state,decorate,enabled", "elm");
1391 #if 1 // FIXME: difference from upstream
1392 if (GL_IT(it)->wsd->reorder_mode)
1394 edje_object_signal_emit
1395 (VIEW(it), "elm,state,reorder,mode_unset", "elm");
1396 edje_object_signal_emit
1397 (it->deco_all_view, "elm,state,reorder,mode_set", "elm");
1400 edje_object_signal_emit
1401 (it->deco_all_view, "elm,state,reorder,mode_unset", "elm");
1404 _item_mouse_callbacks_del(it, VIEW(it));
1405 _item_mouse_callbacks_add(it, it->deco_all_view);
1407 _item_text_realize(it, it->deco_all_view, &it->item->deco_all_texts, NULL);
1409 edje_object_signal_emit
1410 (it->deco_all_view, "elm,state,flip,enabled", "elm");
1411 if (!it->item->deco_all_contents)
1412 it->item->deco_all_contents = elm_widget_stringlist_get
1413 (edje_object_data_get(it->deco_all_view, "contents"));
1414 it->item->deco_all_content_objs =
1415 _item_mode_content_realize(it, it->deco_all_view,
1416 &it->item->deco_all_contents, NULL,
1417 &it->item->deco_all_content_objs);
1419 (it, it->deco_all_view, &it->item->deco_all_states, NULL);
1420 edje_object_part_swallow
1421 (it->deco_all_view, "elm.swallow.decorate.content", VIEW(it));
1423 _decorate_all_item_position(it, it->item->scrl_x, it->item->scrl_y);
1424 evas_object_show(it->deco_all_view);
1428 edje_object_signal_emit(it->deco_all_view, "elm,state,selected", "elm");
1429 evas_object_smart_callback_call(WIDGET(it), SIG_HIGHLIGHTED, it);
1432 it->item->decorate_all_item_realized = EINA_TRUE;
1433 it->want_unrealize = EINA_FALSE;
1437 _expand_toggle_signal_cb(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 _expand_signal_cb(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 _contract_signal_cb(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);
1474 #if GENLIST_ENTRY_SUPPORT
1476 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1478 Elm_Gen_Item *it = data;
1480 if (it->want_unrealize) return;
1481 it->item->mincalcd = EINA_FALSE;
1482 it->item->block->changeme = EINA_TRUE;
1483 GL_IT(it)->wsd->size_changed = EINA_TRUE;
1484 evas_object_smart_changed(GL_IT(it)->wsd->pan_obj);
1489 _item_content_realize(Elm_Gen_Item *it,
1490 Evas_Object *target,
1494 Eina_List *res = it->content_objs;
1496 if (it->itc->func.content_get)
1500 Evas_Object *ic = NULL;
1503 *source = elm_widget_stringlist_get
1504 (edje_object_data_get(target, "contents"));
1506 EINA_LIST_FOREACH(*source, l, key)
1508 if (parts && fnmatch(parts, key, FNM_PERIOD))
1511 if (it->itc->func.content_get)
1512 ic = it->itc->func.content_get
1513 ((void *)it->base.data, WIDGET(it), key);
1516 res = eina_list_append(res, ic);
1517 edje_object_part_swallow(target, key, ic);
1518 evas_object_show(ic);
1520 #if GENLIST_ENTRY_SUPPORT
1521 // For entry or editfield
1522 // 1. Add resize callback for multiline entry.
1523 // 2. Do not unrealize it for focus issue
1524 // ps. Only for entry because of performnace
1525 if (!strcmp("elm_layout", evas_object_type_get(ic)))
1527 // If editfield style, it can have entry.
1529 edje_object_file_get(elm_layout_edje_get(ic), NULL, &group);
1530 if (group && !strncmp("elm/layout/editfield/", group, 20))
1532 evas_object_event_callback_add
1533 (ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1534 _changed_size_hints, it);
1535 it->item->unrealize_disabled = EINA_TRUE;
1539 else if (!strcmp("elm_entry", evas_object_type_get(ic)))
1541 evas_object_event_callback_add
1542 (ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1543 _changed_size_hints, it);
1544 it->item->unrealize_disabled = EINA_TRUE;
1547 #if 0 // FIXME: difference from upstream
1550 // FIXME: if entry calcuates its cursor position correctly and conformant works,
1551 // genlist does not need to handle this focus thing.
1552 evas_object_smart_callback_add(ic, "focused", _content_focused, it);
1553 evas_object_smart_callback_add(ic, "unfocused", _content_unfocused, it);
1556 if (elm_widget_item_disabled_get(it))
1557 elm_widget_disabled_set(ic, EINA_TRUE);
1566 _access_info_cb(void *data, Evas_Object *obj __UNUSED__)
1568 Elm_Gen_Item *it = (Elm_Gen_Item *)data;
1569 ELM_GENLIST_ITEM_CHECK_OR_RETURN(it, NULL);
1571 if (it->itc->func.text_get)
1576 if (!(it->texts)) it->texts =
1577 elm_widget_stringlist_get(edje_object_data_get(VIEW(it), "texts"));
1579 EINA_LIST_FOREACH(it->texts, l, key)
1581 char *s = it->itc->func.text_get
1582 ((void *)it->base.data, WIDGET(it), key);
1591 _access_state_cb(void *data, Evas_Object *obj __UNUSED__)
1593 Elm_Gen_Item *it = (Elm_Gen_Item *)data;
1594 ELM_GENLIST_ITEM_CHECK_OR_RETURN(it, NULL);
1596 if (it->base.disabled)
1597 return strdup(E_("State: Disabled"));
1603 _access_on_highlight_cb(void *data)
1605 Evas_Coord x, y, w, h;
1606 Evas_Coord sx, sy, sw, sh;
1607 Elm_Gen_Item *it = (Elm_Gen_Item *)data;
1608 ELM_GENLIST_ITEM_CHECK_OR_RETURN(it);
1610 ELM_GENLIST_DATA_GET(it->base.widget, sd);
1612 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
1613 // XXX There would be a reason.
1614 if ((w == 0) && (h == 0)) return;
1616 evas_object_geometry_get(ELM_WIDGET_DATA(sd)->obj, &sx, &sy, &sw, &sh);
1617 if ((x < sx) || (y < sy) || ((x + w) > (sx + sw)) || ((y + h) > (sy + sh)))
1618 elm_genlist_item_bring_in((Elm_Object_Item *)it,
1619 ELM_GENLIST_ITEM_SCROLLTO_IN);
1623 _access_widget_item_register(Elm_Gen_Item *it)
1625 Elm_Access_Info *ai;
1627 _elm_access_widget_item_register((Elm_Widget_Item *)it);
1629 ai = _elm_access_object_get(it->base.access_obj);
1631 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Genlist Item"));
1632 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it);
1633 _elm_access_callback_set(ai, ELM_ACCESS_STATE, _access_state_cb, it);
1634 _elm_access_on_highlight_hook_set(ai, _access_on_highlight_cb, it);
1635 _elm_access_activate_callback_set(ai, _access_activate_cb, it);
1639 _item_realize(Elm_Gen_Item *it,
1643 Item_Cache *itc = NULL;
1644 const char *treesize;
1650 if (it->item->order_num_in != in)
1652 _item_order_update(EINA_INLIST_GET(it), in);
1653 _elm_genlist_item_state_update(it, NULL);
1654 _elm_genlist_item_index_update(it);
1658 it->item->order_num_in = in;
1660 if (it->item->nocache_once | it->item->nocache ||
1661 GL_IT(it)->wsd->tree_effect_enabled ||
1662 it->item->type == ELM_GENLIST_ITEM_TREE || it->parent ||
1663 !_item_cache_pop(it))
1665 const char *stacking_even;
1666 const char *stacking;
1668 it->item->nocache_once = EINA_FALSE;
1670 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
1671 edje_object_scale_set(VIEW(it),
1672 elm_widget_scale_get(WIDGET(it)) *
1673 elm_config_scale_get());
1674 evas_object_smart_member_add(VIEW(it), GL_IT(it)->wsd->pan_obj);
1675 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
1677 if (it->item->type & ELM_GENLIST_ITEM_TREE)
1678 snprintf(buf, sizeof(buf), "tree%s/%s",
1679 GL_IT(it)->wsd->mode == ELM_LIST_COMPRESS ? "_compress" :
1680 "", it->itc->item_style ? : "default");
1682 snprintf(buf, sizeof(buf), "item%s/%s",
1683 GL_IT(it)->wsd->mode == ELM_LIST_COMPRESS ? "_compress" :
1684 "", it->itc->item_style ? : "default");
1686 elm_widget_theme_object_set
1687 (WIDGET(it), VIEW(it), "genlist", buf,
1688 elm_widget_style_get(WIDGET(it)));
1690 if (it->item->expanded_depth > 0)
1691 edje_object_signal_emit(VIEW(it), "bg_color_change", "");
1693 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
1694 if (!stacking_even) stacking_even = "above";
1695 it->item->stacking_even = !!strcmp("above", stacking_even);
1697 stacking = edje_object_data_get(VIEW(it), "stacking");
1698 if (!stacking) stacking = "yes";
1699 it->item->nostacking = !!strcmp("yes", stacking);
1701 edje_object_mirrored_set
1702 (VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
1704 edje_object_signal_callback_add
1705 (VIEW(it), "elm,action,expand,toggle", "elm",
1706 _expand_toggle_signal_cb, it);
1707 edje_object_signal_callback_add
1708 (VIEW(it), "elm,action,expand", "elm", _expand_signal_cb, it);
1709 edje_object_signal_callback_add
1710 (VIEW(it), "elm,action,contract", "elm", _contract_signal_cb, it);
1711 _item_mouse_callbacks_add(it, VIEW(it));
1715 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
1716 _access_widget_item_register(it);
1718 _item_order_update(EINA_INLIST_GET(it), in);
1719 #if 1 // FIXME: difference from upstream
1720 if (!(it->deco_all_view) && (it->item->type != ELM_GENLIST_ITEM_GROUP))
1722 if (GL_IT(it)->wsd->reorder_mode)
1723 edje_object_signal_emit
1724 (VIEW(it), "elm,state,reorder,mode_set", "elm");
1726 edje_object_signal_emit
1727 (VIEW(it), "elm,state,reorder,mode_unset", "elm");
1730 treesize = edje_object_data_get(VIEW(it), "treesize");
1731 if (treesize) tsize = atoi(treesize);
1732 if (!it->spacer && treesize)
1735 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1736 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1740 evas_object_size_hint_min_set
1741 (it->spacer, (it->item->expanded_depth * tsize) *
1742 elm_config_scale_get(), 1);
1743 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
1747 if ((GL_IT(it)->wsd->decorate_all_mode) && (!it->deco_all_view) &&
1748 (it->item->type != ELM_GENLIST_ITEM_GROUP) &&
1749 (it->itc->decorate_all_item_style))
1750 _decorate_all_item_realize(it, EINA_FALSE);
1752 _elm_genlist_item_state_update(it, itc);
1753 _elm_genlist_item_index_update(it);
1756 /* homogenous genlist shortcut */
1757 if ((calc) && (GL_IT(it)->wsd->homogeneous) && (!it->item->mincalcd) &&
1758 ((it->group && GL_IT(it)->wsd->group_item_width) ||
1759 (!it->group && GL_IT(it)->wsd->item_width)))
1763 it->item->w = it->item->minw = GL_IT(it)->wsd->group_item_width;
1764 it->item->h = it->item->minh = GL_IT(it)->wsd->group_item_height;
1768 it->item->w = it->item->minw = GL_IT(it)->wsd->item_width;
1769 it->item->h = it->item->minh = GL_IT(it)->wsd->item_height;
1771 it->item->mincalcd = EINA_TRUE;
1775 if (eina_list_count(it->content_objs) != 0)
1776 ERR_ABORT("If you see this error, please notify us and we"
1779 _item_text_realize(it, VIEW(it), &it->texts, NULL);
1781 _item_content_realize(it, VIEW(it), &it->contents, NULL);
1782 _item_state_realize(it, VIEW(it), &it->states, NULL);
1785 edje_object_signal_emit
1786 (VIEW(it), "elm,state,flip,enabled", "elm");
1787 if (!(it->item->flip_contents))
1788 it->item->flip_contents = elm_widget_stringlist_get
1789 (edje_object_data_get(VIEW(it), "flips"));
1790 it->item->flip_content_objs = _item_mode_content_realize
1791 (it, VIEW(it), &it->item->flip_contents, NULL,
1792 &it->item->flip_content_objs);
1796 // FIXME: difference from upstream
1797 if (!it->item->mincalcd || ((GL_IT(it)->wsd->mode == ELM_LIST_COMPRESS) && (it->item->w != it->item->minw)))
1799 if (!it->item->mincalcd)
1802 Evas_Coord mw = -1, mh = -1;
1804 if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
1805 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1806 if (GL_IT(it)->wsd->mode == ELM_LIST_COMPRESS)
1807 mw = GL_IT(it)->wsd->prev_viewport_w;
1808 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
1810 it->item->w = it->item->minw = mw;
1811 it->item->h = it->item->minh = mh;
1812 it->item->mincalcd = EINA_TRUE;
1814 if ((!GL_IT(it)->wsd->group_item_width) && (it->group))
1816 GL_IT(it)->wsd->group_item_width = mw;
1817 GL_IT(it)->wsd->group_item_height = mh;
1819 else if ((!GL_IT(it)->wsd->item_width) &&
1820 (it->item->type == ELM_GENLIST_ITEM_NONE))
1822 GL_IT(it)->wsd->item_width = mw;
1823 GL_IT(it)->wsd->item_height = mh;
1826 if (!calc) evas_object_show(VIEW(it));
1829 if (it->tooltip.content_cb)
1831 elm_widget_item_tooltip_content_cb_set
1832 (it, it->tooltip.content_cb, it->tooltip.data, NULL);
1833 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1834 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
1837 if (it->mouse_cursor)
1838 elm_widget_item_cursor_set(it, it->mouse_cursor);
1840 it->realized = EINA_TRUE;
1841 it->want_unrealize = EINA_FALSE;
1843 if (!calc || it->item->unrealize_disabled)
1845 if (it->item->tree_effect_hide_me)
1847 if (GL_IT(it)->wsd->move_effect_mode
1848 != ELM_GENLIST_TREE_EFFECT_NONE)
1849 edje_object_signal_emit(VIEW(it), "elm,state,hide", "");
1850 it->item->tree_effect_hide_me = EINA_FALSE;
1852 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1855 if ((!calc) && (GL_IT(it)->wsd->decorate_all_mode) &&
1856 (it->item->type != ELM_GENLIST_ITEM_GROUP))
1858 if (it->itc->decorate_all_item_style)
1860 if (!it->deco_all_view)
1861 _decorate_all_item_realize(it, EINA_FALSE);
1862 edje_object_message_signal_process(it->deco_all_view);
1865 edje_object_message_signal_process(VIEW(it));
1869 _tree_effect_animator_cb(void *data)
1873 int y = 0, dy = 0, dh = 0;
1874 double effect_duration = 0.3, t;
1875 Elm_Genlist_Smart_Data *sd = data;
1876 Eina_Bool end = EINA_FALSE, vis = EINA_TRUE;
1877 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1878 Elm_Gen_Item *it = NULL, *it2, *expanded_next_it;
1880 t = ((0.0 > (t = ecore_time_get() - sd->start_time)) ? 0.0 : t);
1881 evas_object_geometry_get(sd->pan_obj, &ox, &oy, &ow, &oh);
1882 evas_output_viewport_get
1883 (evas_object_evas_get(sd->pan_obj), &cvx, &cvy, &cvw, &cvh);
1884 if (t > effect_duration) end = EINA_TRUE;
1886 // Below while statement is needed, when the genlist is resized.
1887 it2 = sd->expanded_item;
1890 evas_object_move(VIEW(it2), it2->item->scrl_x, it2->item->scrl_y);
1891 vis = (ELM_RECTS_INTERSECT(it2->item->scrl_x, it2->item->scrl_y,
1892 it2->item->w, it2->item->h, cvx, cvy, cvw,
1895 (Elm_Gen_Item *)elm_genlist_item_prev_get((Elm_Object_Item *)it2);
1898 if (sd->expanded_next_item)
1900 expanded_next_it = sd->expanded_next_item;
1903 EINA_LIST_FOREACH(sd->move_items, l, it)
1905 if (sd->move_effect_mode == ELM_GENLIST_TREE_EFFECT_EXPAND)
1907 expanded_next_it->item->old_scrl_y =
1908 sd->expanded_item->item->old_scrl_y
1909 + sd->expanded_item->item->h;
1910 if (expanded_next_it->item->scrl_y <=
1911 expanded_next_it->item->old_scrl_y) /* did not
1915 expanded_next_it->item->scrl_y = cvy + cvh;
1917 dy = ((expanded_next_it->item->scrl_y >= (cvy + cvh)) ?
1918 cvy + cvh : expanded_next_it->item->scrl_y) -
1919 expanded_next_it->item->old_scrl_y;
1921 else if (sd->move_effect_mode == ELM_GENLIST_TREE_EFFECT_CONTRACT)
1923 if (expanded_next_it->item->scrl_y >
1924 expanded_next_it->item->old_scrl_y) /* did not
1928 expanded_next_it->item->old_scrl_y = cvy + cvh;
1930 if (expanded_next_it->item->old_scrl_y > (cvy + cvh))
1932 dy = (sd->expanded_item->item->scrl_y +
1933 sd->expanded_item->item->h) - cvy + cvh;
1934 expanded_next_it->item->old_scrl_y = cvy + cvh;
1938 dy = (sd->expanded_item->item->scrl_y +
1939 sd->expanded_item->item->h) -
1940 expanded_next_it->item->old_scrl_y;
1944 if (t <= effect_duration)
1946 y = ((1 - (1 - (t / effect_duration)) *
1947 (1 - (t / effect_duration))) * dy);
1955 if (!it->realized && !it->item->queued)
1956 _item_realize(it, in, 0);
1959 if (it != expanded_next_it)
1961 it->item->old_scrl_y =
1962 expanded_next_it->item->old_scrl_y +
1963 expanded_next_it->item->h + dh;
1968 if ((it->item->old_scrl_y + y) < (cvy + cvh))
1969 _item_position(it, VIEW(it), it->item->scrl_x,
1970 it->item->old_scrl_y + y);
1973 _item_tree_effect(sd, y);
1977 int expanded_item_num = 0;
1980 if (sd->expanded_item)
1981 it = (Elm_Gen_Item *)elm_genlist_item_next_get
1982 ((Elm_Object_Item *)sd->expanded_item);
1987 expanded_item_num++;
1988 it2 = (Elm_Gen_Item *)elm_genlist_item_next_get
1989 ((Elm_Object_Item *)it2);
1995 if (sd->expanded_item->item->expanded_depth >=
1996 it->item->expanded_depth) break;
1997 if (sd->move_effect_mode == ELM_GENLIST_TREE_EFFECT_EXPAND)
1999 if (!it->item->tree_effect_finished)
2001 if (t >= (((num - 1) * effect_duration) /
2004 edje_object_signal_emit(VIEW(it), "flip_item", "");
2005 _item_position(it, VIEW(it), it->item->scrl_x,
2007 it->item->tree_effect_finished = EINA_TRUE;
2011 it = (Elm_Gen_Item *)elm_genlist_item_next_get
2012 ((Elm_Object_Item *)it);
2018 _item_tree_effect_finish(sd);
2019 return ECORE_CALLBACK_CANCEL;
2022 return ECORE_CALLBACK_RENEW;
2026 _group_items_recalc(void *data)
2030 Elm_Genlist_Smart_Data *sd = data;
2032 //evas_event_freeze(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
2033 EINA_LIST_FOREACH(sd->group_items, l, git)
2035 if (git->item->want_realize)
2037 if (!git->realized) _item_realize(git, 0, EINA_FALSE);
2038 evas_object_resize(VIEW(git), sd->minw, git->item->h);
2039 evas_object_move(VIEW(git), git->item->scrl_x, git->item->scrl_y);
2040 evas_object_show(VIEW(git));
2041 evas_object_raise(VIEW(git));
2043 else if (!git->item->want_realize)
2046 _item_unrealize(git, EINA_FALSE);
2049 //evas_event_thaw(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
2050 //evas_event_thaw_eval(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
2054 _reorder_move_animator_cb(void *data)
2057 Elm_Gen_Item *it = data;
2058 Eina_Bool down = EINA_FALSE;
2061 dy = 6 * elm_config_scale_get();
2062 t = ((0.0 > (t = ecore_loop_time_get()
2063 - GL_IT(it)->wsd->start_time)) ? 0.0 : t);
2065 if (t <= REORDER_EFFECT_TIME)
2066 y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2069 diff = abs(it->item->old_scrl_y - it->item->scrl_y);
2070 if (diff < dy) y = diff;
2072 if (it->item->old_scrl_y < it->item->scrl_y)
2074 it->item->old_scrl_y += y;
2077 else if (it->item->old_scrl_y > it->item->scrl_y)
2079 it->item->old_scrl_y -= y;
2083 if (it->deco_all_view)
2085 (it, it->deco_all_view, it->item->scrl_x, it->item->old_scrl_y);
2086 else if (it->item->deco_it_view)
2088 (it, it->item->deco_it_view, it->item->scrl_x, it->item->old_scrl_y);
2090 _item_position(it, VIEW(it), it->item->scrl_x, it->item->old_scrl_y);
2092 if ((GL_IT(it)->wsd->reorder_pan_move) ||
2093 (down && it->item->old_scrl_y >= it->item->scrl_y) ||
2094 (!down && it->item->old_scrl_y <= it->item->scrl_y))
2096 it->item->old_scrl_y = it->item->scrl_y;
2097 it->item->move_effect_enabled = EINA_FALSE;
2098 GL_IT(it)->wsd->reorder_move_animator = NULL;
2099 return ECORE_CALLBACK_CANCEL;
2102 return ECORE_CALLBACK_RENEW;
2106 _reorder_item_space_get(Elm_Gen_Item *it)
2108 Elm_Gen_Item *reorder_it = GL_IT(it)->wsd->reorder_it;
2109 Evas_Coord rox, roy, row, roh, oy, oh;
2110 Eina_Bool top = EINA_FALSE;
2112 if (!reorder_it) return 0;
2113 if(it->deco_all_view) evas_object_lower(it->deco_all_view);
2115 evas_object_geometry_get(GL_IT(it)->wsd->pan_obj, NULL, &oy, NULL, &oh);
2116 evas_object_geometry_get
2117 (GL_IT(it)->wsd->VIEW(reorder_it), &rox, &roy, &row, &roh);
2119 if ((GL_IT(it)->wsd->reorder_start_y < it->item->block->y) &&
2120 (roy - oy + (roh / 2) >= it->item->block->y - GL_IT(it)->wsd->pan_y))
2122 it->item->block->reorder_offset =
2123 GL_IT(it)->wsd->reorder_it->item->h * -1;
2124 if (it->item->block->count == 1)
2125 GL_IT(it)->wsd->reorder_rel = it;
2127 else if ((GL_IT(it)->wsd->reorder_start_y >= it->item->block->y) &&
2128 (roy - oy + (roh / 2) <= it->item->block->y -
2129 GL_IT(it)->wsd->pan_y))
2131 it->item->block->reorder_offset = GL_IT(it)->wsd->reorder_it->item->h;
2134 it->item->block->reorder_offset = 0;
2136 it->item->scrl_y += it->item->block->reorder_offset;
2138 top = (ELM_RECTS_INTERSECT
2139 (it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2140 rox, roy + (roh / 2), row, 1));
2143 GL_IT(it)->wsd->reorder_rel = it;
2144 it->item->scrl_y += GL_IT(it)->wsd->reorder_it->item->h;
2145 return GL_IT(it)->wsd->reorder_it->item->h;
2152 _item_block_position(Item_Block *itb,
2158 Eina_Bool vis = EINA_FALSE;
2159 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2161 //evas_event_freeze(evas_object_evas_get(ELM_WIDGET_DATA(itb->sd)->obj));
2162 evas_object_geometry_get(itb->sd->pan_obj, &ox, &oy, &ow, &oh);
2163 evas_output_viewport_get
2164 (evas_object_evas_get(ELM_WIDGET_DATA(itb->sd)->obj),
2165 &cvx, &cvy, &cvw, &cvh);
2167 EINA_LIST_FOREACH(itb->items, l, it)
2169 if ((GL_IT(it)->wsd->reorder_it == it) && it->highlighted) continue;
2173 it->item->w = itb->w;
2174 it->item->scrl_x = itb->x + it->x - GL_IT(it)->wsd->pan_x + ox;
2175 it->item->scrl_y = itb->y + it->y - GL_IT(it)->wsd->pan_y + oy;
2177 vis = (ELM_RECTS_INTERSECT
2178 (it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2179 cvx, cvy, cvw, cvh));
2182 if ((itb->realized) && (!it->realized))
2184 if (vis) _item_realize(it, in, EINA_FALSE);
2188 if (vis || it->dragging)
2190 #if GENLIST_ENTRY_SUPPORT
2191 evas_object_show(VIEW(it));
2193 if (GL_IT(it)->wsd->reorder_mode &&
2194 GL_IT(it)->wsd->reorder_it &&
2195 GL_IT(it)->wsd->reorder_it->highlighted)
2196 y += _reorder_item_space_get(it);
2197 git = it->item->group_item;
2200 if (git->item->scrl_y < oy)
2201 git->item->scrl_y = oy;
2202 if ((git->item->scrl_y + git->item->h) >
2203 (it->item->scrl_y + it->item->h))
2204 git->item->scrl_y = (it->item->scrl_y +
2205 it->item->h) - git->item->h;
2206 git->item->scrl_x = it->item->scrl_x;
2207 git->item->want_realize = EINA_TRUE;
2209 if ((GL_IT(it)->wsd->reorder_it) &&
2210 GL_IT(it)->wsd->reorder_it->highlighted &&
2211 (it->item->old_scrl_y != it->item->scrl_y))
2213 if (!it->item->move_effect_enabled)
2215 it->item->move_effect_enabled = EINA_TRUE;
2216 GL_IT(it)->wsd->reorder_move_animator =
2218 _reorder_move_animator_cb, it);
2221 if (!it->item->move_effect_enabled)
2223 if ((GL_IT(it)->wsd->decorate_all_mode) &&
2224 (it->itc->decorate_all_item_style))
2225 _decorate_all_item_position
2226 (it, it->item->scrl_x, it->item->scrl_y);
2229 if (!GL_IT(it)->wsd->tree_effect_enabled ||
2230 (GL_IT(it)->wsd->move_effect_mode ==
2231 ELM_GENLIST_TREE_EFFECT_NONE) ||
2232 ((GL_IT(it)->wsd->move_effect_mode !=
2233 ELM_GENLIST_TREE_EFFECT_NONE) &&
2234 (it->item->old_scrl_y ==
2237 if (it->item->deco_it_view)
2239 (it, it->item->deco_it_view,
2244 (it, VIEW(it), it->item->scrl_x,
2248 it->item->old_scrl_y = it->item->scrl_y;
2253 if (!GL_IT(it)->wsd->tree_effect_animator)
2254 _item_unrealize(it, EINA_FALSE);
2261 if (vis) it->item->want_realize = EINA_TRUE;
2265 // FIXME: diffrence from upstream
2266 minh += it->item->minh;
2270 //evas_event_thaw(evas_object_evas_get(ELM_WIDGET_DATA(itb->sd)->obj));
2271 //evas_event_thaw_eval(evas_object_evas_get(ELM_WIDGET_DATA(itb->sd)->obj));
2275 _item_block_realize(Item_Block *itb)
2277 if (itb->realized) return;
2279 itb->realized = EINA_TRUE;
2280 itb->want_unrealize = EINA_FALSE;
2283 #if GENLIST_ENTRY_SUPPORT
2285 _changed_job(Elm_Genlist_Smart_Data *sd)
2291 Eina_Bool anything_changed = EINA_FALSE;
2292 Eina_Bool width_changed = EINA_FALSE;
2293 Eina_Bool height_changed = EINA_FALSE;
2294 sd->size_changed = EINA_FALSE;
2296 EINA_INLIST_FOREACH(sd->blocks, itb)
2303 if (anything_changed)
2304 _item_block_position(itb, num);
2308 width_changed = height_changed = EINA_FALSE;
2309 EINA_LIST_FOREACH(itb->items, l2, it)
2311 if ((!it->item->mincalcd) && (it->realized))
2313 Evas_Coord fw = -1, fh = -1;
2314 Evas_Coord mw = -1, mh = -1;
2316 if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
2317 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
2319 // FIXME: why compressmode do this?
2320 if (sd->mode == ELM_LIST_COMPRESS) mw = sd->prev_viewport_w;
2322 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, fw, fh);
2324 if (it->item->w != mw)
2326 it->item->w = it->item->minw = mw;
2327 width_changed = EINA_TRUE;
2329 if (it->item->h != mh)
2331 it->item->h = it->item->minh = mh;
2332 height_changed = EINA_TRUE;
2339 it->item->mincalcd = EINA_TRUE;
2341 if ((!sd->group_item_width) && (it->group))
2343 sd->group_item_width = mw;
2344 sd->group_item_height = mh;
2346 else if ((!sd->item_width) && (it->item->type == ELM_GENLIST_ITEM_NONE))
2348 sd->item_width = mw;
2349 sd->item_height = mh;
2354 itb->changeme = EINA_FALSE;
2357 anything_changed = EINA_TRUE;
2358 itb->changed = EINA_TRUE;
2359 _item_block_recalc(itb, num0, 0);
2360 _item_block_position(itb, num0);
2362 else if (width_changed)
2364 _item_block_position(itb, num0);
2367 if (anything_changed)
2369 if (sd->calc_job) ecore_job_del(sd->calc_job);
2370 sd->calc_job = ecore_job_add(_calc_job, sd);
2376 _elm_genlist_pan_smart_calculate(Evas_Object *obj)
2378 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2379 Evas_Coord vx = 0, vy = 0, vw = 0, vh = 0;
2385 ELM_GENLIST_PAN_DATA_GET(obj, psd);
2387 //evas_event_freeze(evas_object_evas_get(obj));
2389 if (psd->wsd->pan_changed)
2391 _calc_job(psd->wsd);
2392 psd->wsd->pan_changed = EINA_FALSE;
2395 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2396 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2397 EINA_LIST_FOREACH(psd->wsd->group_items, l, git)
2399 git->item->want_realize = EINA_FALSE;
2402 if (psd->wsd->tree_effect_enabled &&
2403 (psd->wsd->move_effect_mode != ELM_GENLIST_TREE_EFFECT_NONE))
2405 if (!psd->wsd->tree_effect_animator)
2407 _item_tree_effect_before(psd->wsd->expanded_item);
2408 evas_object_raise(psd->wsd->alpha_bg);
2409 evas_object_show(psd->wsd->alpha_bg);
2410 psd->wsd->start_time = ecore_time_get();
2411 psd->wsd->tree_effect_animator =
2412 ecore_animator_add(_tree_effect_animator_cb, psd->wsd);
2416 EINA_INLIST_FOREACH(psd->wsd->blocks, itb)
2418 itb->w = psd->wsd->minw;
2419 if (ELM_RECTS_INTERSECT(itb->x - psd->wsd->pan_x + ox,
2420 itb->y - psd->wsd->pan_y + oy,
2422 cvx, cvy, cvw, cvh))
2424 if ((!itb->realized) || (itb->changed))
2426 _item_block_realize(itb);
2428 // FIXME: difference from opensource
2429 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2430 sd->wd->calc_job = NULL;
2434 _item_block_position(itb, in);
2438 if (itb->realized) _item_block_unrealize(itb);
2442 #if 0 // FIXME: difference from upstream
2443 // Disable shift movement of group items.
2444 if ((!psd->wsd->reorder_it) || (psd->wsd->reorder_pan_move))
2445 _group_items_recalc(psd->wsd);
2447 if ((psd->wsd->reorder_mode) && (psd->wsd->reorder_it))
2449 if (psd->wsd->pan_y != psd->wsd->reorder_old_pan_y)
2450 psd->wsd->reorder_pan_move = EINA_TRUE;
2451 else psd->wsd->reorder_pan_move = EINA_FALSE;
2453 evas_object_raise(psd->wsd->VIEW(reorder_it));
2454 psd->wsd->reorder_old_pan_y = psd->wsd->pan_y;
2455 psd->wsd->start_time = ecore_loop_time_get();
2458 if (!psd->wsd->tree_effect_enabled ||
2459 (psd->wsd->move_effect_mode == ELM_GENLIST_TREE_EFFECT_NONE))
2460 _item_auto_scroll(psd->wsd);
2462 psd->wsd->s_iface->content_pos_get(ELM_WIDGET_DATA(psd->wsd)->obj, &vx, &vy);
2463 psd->wsd->s_iface->content_viewport_size_get(ELM_WIDGET_DATA(psd->wsd)->obj,
2466 if (psd->wsd->reorder_fast == 1)
2467 psd->wsd->s_iface->content_region_show(ELM_WIDGET_DATA(psd->wsd)->obj,
2468 vx,vy - 10, vw, vh);
2469 else if (psd->wsd->reorder_fast == -1)
2470 psd->wsd->s_iface->content_region_show(ELM_WIDGET_DATA(psd->wsd)->obj,
2471 vx, vy + 10, vw, vh);
2473 #if GENLIST_ENTRY_SUPPORT
2474 if (psd->wsd->size_changed) _changed_job(psd->wsd);
2476 //evas_event_thaw(evas_object_evas_get(obj));
2477 //evas_event_thaw_eval(evas_object_evas_get(obj));
2481 _elm_genlist_pan_smart_set_user(Elm_Genlist_Pan_Smart_Class *sc)
2483 ELM_PAN_CLASS(sc)->base.add = _elm_genlist_pan_smart_add;
2484 ELM_PAN_CLASS(sc)->base.del = _elm_genlist_pan_smart_del;
2485 ELM_PAN_CLASS(sc)->base.move = _elm_genlist_pan_smart_move;
2486 ELM_PAN_CLASS(sc)->base.resize = _elm_genlist_pan_smart_resize;
2487 ELM_PAN_CLASS(sc)->base.calculate = _elm_genlist_pan_smart_calculate;
2489 ELM_PAN_CLASS(sc)->pos_set = _elm_genlist_pan_smart_pos_set;
2490 ELM_PAN_CLASS(sc)->pos_get = _elm_genlist_pan_smart_pos_get;
2491 ELM_PAN_CLASS(sc)->pos_max_get = _elm_genlist_pan_smart_pos_max_get;
2492 ELM_PAN_CLASS(sc)->pos_min_get = _elm_genlist_pan_smart_pos_min_get;
2493 ELM_PAN_CLASS(sc)->content_size_get =
2494 _elm_genlist_pan_smart_content_size_get;
2498 _item_multi_select_up(Elm_Genlist_Smart_Data *sd)
2500 Elm_Object_Item *prev;
2502 if (!sd->selected) return EINA_FALSE;
2503 if (!sd->multi) return EINA_FALSE;
2505 prev = elm_genlist_item_prev_get(sd->last_selected_item);
2506 if (!prev) return EINA_TRUE;
2508 if (elm_genlist_item_selected_get(prev))
2510 elm_genlist_item_selected_set(sd->last_selected_item, EINA_FALSE);
2511 sd->last_selected_item = prev;
2512 elm_genlist_item_show
2513 (sd->last_selected_item, ELM_GENLIST_ITEM_SCROLLTO_IN);
2517 elm_genlist_item_selected_set(prev, EINA_TRUE);
2518 elm_genlist_item_show(prev, ELM_GENLIST_ITEM_SCROLLTO_IN);
2524 _item_multi_select_down(Elm_Genlist_Smart_Data *sd)
2526 Elm_Object_Item *next;
2528 if (!sd->selected) return EINA_FALSE;
2529 if (!sd->multi) return EINA_FALSE;
2531 next = elm_genlist_item_next_get(sd->last_selected_item);
2532 if (!next) return EINA_TRUE;
2534 if (elm_genlist_item_selected_get(next))
2536 elm_genlist_item_selected_set(sd->last_selected_item, EINA_FALSE);
2537 sd->last_selected_item = next;
2538 elm_genlist_item_show
2539 (sd->last_selected_item, ELM_GENLIST_ITEM_SCROLLTO_IN);
2543 elm_genlist_item_selected_set(next, EINA_TRUE);
2544 elm_genlist_item_show(next, ELM_GENLIST_ITEM_SCROLLTO_IN);
2551 _all_items_deselect(Elm_Genlist_Smart_Data *sd)
2553 if (!sd->selected) return EINA_FALSE;
2555 while (sd->selected)
2556 elm_genlist_item_selected_set(sd->selected->data, EINA_FALSE);
2562 _item_single_select_up(Elm_Genlist_Smart_Data *sd)
2568 prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
2570 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
2573 prev = (Elm_Gen_Item *)elm_genlist_item_prev_get
2574 (sd->last_selected_item);
2576 if (!prev) return EINA_FALSE;
2578 _all_items_deselect(sd);
2580 elm_genlist_item_selected_set((Elm_Object_Item *)prev, EINA_TRUE);
2581 elm_genlist_item_show((Elm_Object_Item *)prev, ELM_GENLIST_ITEM_SCROLLTO_IN);
2586 _item_single_select_down(Elm_Genlist_Smart_Data *sd)
2592 next = ELM_GEN_ITEM_FROM_INLIST(sd->items);
2594 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
2597 next = (Elm_Gen_Item *)elm_genlist_item_next_get
2598 (sd->last_selected_item);
2600 if (!next) return EINA_FALSE;
2602 _all_items_deselect(sd);
2604 elm_genlist_item_selected_set((Elm_Object_Item *)next, EINA_TRUE);
2605 elm_genlist_item_show
2606 ((Elm_Object_Item *)next, ELM_GENLIST_ITEM_SCROLLTO_IN);
2612 _elm_genlist_smart_event(Evas_Object *obj,
2613 Evas_Object *src __UNUSED__,
2614 Evas_Callback_Type type,
2621 Evas_Coord step_x = 0;
2622 Evas_Coord step_y = 0;
2623 Evas_Coord page_x = 0;
2624 Evas_Coord page_y = 0;
2625 Elm_Object_Item *it;
2626 Evas_Event_Key_Down *ev = event_info;
2627 Evas_Coord pan_max_x = 0, pan_max_y = 0;
2629 ELM_GENLIST_DATA_GET(obj, sd);
2631 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
2632 if (!sd->items) return EINA_FALSE;
2633 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
2634 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
2636 sd->s_iface->content_pos_get(obj, &x, &y);
2637 sd->s_iface->step_size_get(obj, &step_x, &step_y);
2638 sd->s_iface->page_size_get(obj, &page_x, &page_y);
2639 sd->s_iface->content_viewport_size_get(obj, &v_w, &v_h);
2641 if ((!strcmp(ev->keyname, "Left")) ||
2642 ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string)))
2646 else if ((!strcmp(ev->keyname, "Right")) ||
2647 ((!strcmp(ev->keyname, "KP_Right")) && (!ev->string)))
2651 else if ((!strcmp(ev->keyname, "Up")) ||
2652 ((!strcmp(ev->keyname, "KP_Up")) && (!ev->string)))
2654 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
2655 (_item_multi_select_up(sd)))
2656 || (_item_single_select_up(sd)))
2658 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2664 else if ((!strcmp(ev->keyname, "Down")) ||
2665 ((!strcmp(ev->keyname, "KP_Down")) && (!ev->string)))
2667 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
2668 (_item_multi_select_down(sd)))
2669 || (_item_single_select_down(sd)))
2671 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2677 else if ((!strcmp(ev->keyname, "Home")) ||
2678 ((!strcmp(ev->keyname, "KP_Home")) && (!ev->string)))
2680 it = elm_genlist_first_item_get(obj);
2681 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
2682 elm_genlist_item_selected_set(it, EINA_TRUE);
2683 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2686 else if ((!strcmp(ev->keyname, "End")) ||
2687 ((!strcmp(ev->keyname, "KP_End")) && (!ev->string)))
2689 it = elm_genlist_last_item_get(obj);
2690 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
2691 elm_genlist_item_selected_set(it, EINA_TRUE);
2692 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2695 else if ((!strcmp(ev->keyname, "Prior")) ||
2696 ((!strcmp(ev->keyname, "KP_Prior")) && (!ev->string)))
2699 y -= -(page_y * v_h) / 100;
2703 else if ((!strcmp(ev->keyname, "Next")) ||
2704 ((!strcmp(ev->keyname, "KP_Next")) && (!ev->string)))
2707 y += -(page_y * v_h) / 100;
2711 else if (!strcmp(ev->keyname, "Escape"))
2713 if (!_all_items_deselect(sd)) return EINA_FALSE;
2714 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2717 else if (((!strcmp(ev->keyname, "Return")) ||
2718 (!strcmp(ev->keyname, "KP_Enter")) ||
2719 (!strcmp(ev->keyname, "space")))
2720 && (!sd->multi) && (sd->selected))
2722 it = elm_genlist_selected_item_get(obj);
2723 elm_genlist_item_expanded_set(it, !elm_genlist_item_expanded_get(it));
2724 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
2726 else return EINA_FALSE;
2728 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2729 _elm_genlist_pan_smart_pos_max_get(sd->pan_obj, &pan_max_x, &pan_max_y);
2731 if (x > pan_max_x) x = pan_max_x;
2733 if (y > pan_max_y) y = pan_max_y;
2735 sd->s_iface->content_pos_set(obj, x, y);
2741 _elm_genlist_smart_sub_object_add(Evas_Object *obj,
2744 Elm_Widget_Smart_Class *parent_parent;
2746 parent_parent = (Elm_Widget_Smart_Class *)((Evas_Smart_Class *)
2747 _elm_genlist_parent_sc)->parent;
2749 /* skipping layout's code, which registers size hint changing
2750 * callback on sub objects. this is here because items'
2751 * content_get() routines may change hints on the objects after
2752 * creation, thus issuing TOO MANY sizing_eval()'s here. they are
2753 * not needed at here anyway, so let's skip listening to those
2755 if (!parent_parent->sub_object_add(obj, sobj))
2762 _elm_genlist_smart_sub_object_del(Evas_Object *obj,
2765 ELM_GENLIST_DATA_GET(obj, sd);
2767 /* XXX: hack -- also skipping sizing recalculation on
2768 * sub-object-del. genlist's crazy code paths (like groups and
2769 * such) seem to issue a whole lot of deletions and Evas bitches
2770 * about too many recalculations */
2771 sd->on_sub_del = EINA_TRUE;
2773 if (!ELM_WIDGET_CLASS(_elm_genlist_parent_sc)->sub_object_del(obj, sobj))
2776 sd->on_sub_del = EINA_FALSE;
2782 _elm_genlist_smart_on_focus(Evas_Object *obj)
2784 ELM_GENLIST_DATA_GET(obj, sd);
2786 if (!ELM_WIDGET_CLASS(_elm_genlist_parent_sc)->on_focus(obj))
2789 if (elm_widget_focus_get(obj) && (sd->items) && (sd->selected) &&
2790 (!sd->last_selected_item))
2791 sd->last_selected_item = eina_list_data_get(sd->selected);
2797 _elm_genlist_smart_focus_next(const Evas_Object *obj,
2798 Elm_Focus_Direction dir,
2801 Evas_Coord x, y, w, h;
2802 Evas_Coord sx, sy, sw, sh;
2804 Eina_List *items = NULL;
2805 Eina_Bool done = EINA_FALSE;
2807 ELM_GENLIST_CHECK(obj) EINA_FALSE;
2808 ELM_GENLIST_DATA_GET(obj, sd);
2810 evas_object_geometry_get(ELM_WIDGET_DATA(sd)->obj, &sx, &sy, &sw, &sh);
2812 EINA_INLIST_FOREACH(sd->blocks, itb)
2820 EINA_LIST_FOREACH(itb->items, l, it)
2824 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
2826 /* check item which displays more than half of its size */
2827 if (ELM_RECTS_INTERSECT
2828 (x + (w / 2), y + (h / 2), 0, 0, sx, sy, sw, sh))
2829 items = eina_list_append(items, it->base.access_obj);
2833 else if (done) break;
2836 return elm_widget_focus_list_next_get
2837 (obj, items, eina_list_data_get, dir, next);
2841 _mirrored_set(Evas_Object *obj,
2844 ELM_GENLIST_DATA_GET(obj, sd);
2846 sd->s_iface->mirrored_set(obj, rtl);
2850 _elm_genlist_smart_theme(Evas_Object *obj)
2854 ELM_GENLIST_DATA_GET(obj, sd);
2856 if (!ELM_WIDGET_CLASS(_elm_genlist_parent_sc)->theme(obj))
2859 //evas_event_freeze(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
2860 _item_cache_all_free(sd);
2861 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2864 // FIXME: difference from opensource
2865 elm_layout_theme_set(obj, "genlist", "base", elm_widget_style_get(obj));
2868 sd->item_width = sd->item_height = 0;
2869 sd->group_item_width = sd->group_item_height = 0;
2870 sd->minw = sd->minh = sd->realminw = 0;
2871 EINA_INLIST_FOREACH(sd->blocks, itb)
2876 if (itb->realized) _item_block_unrealize(itb);
2877 EINA_LIST_FOREACH(itb->items, l, it)
2878 it->item->mincalcd = EINA_FALSE;
2880 itb->changed = EINA_TRUE;
2882 if (sd->calc_job) ecore_job_del(sd->calc_job);
2883 sd->calc_job = NULL;
2884 elm_layout_sizing_eval(obj);
2885 sd->pan_changed = EINA_TRUE;
2886 evas_object_smart_changed(sd->pan_obj);
2887 //evas_event_thaw(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
2888 //evas_event_thaw_eval(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
2893 /* FIXME: take off later. maybe this show region coords belong in the
2894 * interface (new api functions, set/get)? */
2896 _show_region_hook(void *data,
2899 Evas_Coord x, y, w, h;
2901 ELM_GENLIST_DATA_GET(data, sd);
2903 elm_widget_show_region_get(obj, &x, &y, &w, &h);
2904 //x & y are screen coordinates, Add with pan coordinates
2907 sd->s_iface->content_region_show(obj, x, y, w, h);
2911 _elm_genlist_smart_translate(Evas_Object *obj)
2913 evas_object_smart_callback_call(obj, "language,changed", NULL);
2919 _item_highlight(Elm_Gen_Item *it)
2921 const char *selectraise;
2922 Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
2924 if (elm_widget_item_disabled_get(it)) return;
2925 if ((sd->select_mode == ELM_OBJECT_SELECT_MODE_NONE) ||
2926 (sd->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY ) ||
2927 (it->select_mode == ELM_OBJECT_SELECT_MODE_NONE) ||
2928 (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY ))
2931 if (!sd->highlight || it->highlighted) return;
2933 selectraise = edje_object_data_get(VIEW(it), "selectraise");
2934 if ((selectraise) && (!strcmp(selectraise, "on")))
2936 if (it->deco_all_view) evas_object_raise(it->deco_all_view);
2937 else evas_object_raise(VIEW(it));
2938 if ((it->item->group_item) && (it->item->group_item->realized))
2939 evas_object_raise(it->item->VIEW(group_item));
2941 it->highlighted = EINA_TRUE;
2943 if (it->deco_all_view)
2944 edje_object_signal_emit(it->deco_all_view, "elm,state,selected", "elm");
2945 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
2946 evas_object_smart_callback_call(WIDGET(it), SIG_HIGHLIGHTED, it);
2950 _item_unhighlight(Elm_Gen_Item *it)
2952 if (!it->highlighted) return;
2954 if (!it->item->nostacking)
2956 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
2958 if (it->deco_all_view) evas_object_lower(it->deco_all_view);
2959 else evas_object_lower(VIEW(it));
2963 if (it->deco_all_view) evas_object_raise(it->deco_all_view);
2964 else evas_object_raise(VIEW(it));
2967 it->highlighted = EINA_FALSE;
2969 if (it->deco_all_view)
2970 edje_object_signal_emit(it->deco_all_view, "elm,state,unselected", "elm");
2971 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
2972 evas_object_smart_callback_call(WIDGET(it), SIG_UNHIGHLIGHTED, it);
2976 _item_unselect(Elm_Gen_Item *it)
2978 Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
2979 _item_unhighlight(it);
2980 if (!it->selected) return;
2982 it->selected = EINA_FALSE;
2983 sd->selected = eina_list_remove(sd->selected, it);
2984 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
2988 _item_select(Elm_Gen_Item *it)
2990 Evas_Object *obj = WIDGET(it);
2991 Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
2992 if (elm_widget_item_disabled_get(it)) return;
2993 if ((sd->select_mode == ELM_OBJECT_SELECT_MODE_NONE) ||
2994 (sd->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) ||
2995 (it->select_mode == ELM_OBJECT_SELECT_MODE_NONE) ||
2996 (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY))
3000 // FIXME: difference from upstream
3001 if ((GL_IT(it)->wsd->last_selected_item) &&
3002 (it != (Elm_Gen_Item *) GL_IT(it)->wsd->last_selected_item))
3003 _item_unfocusable_set
3004 ((Elm_Gen_Item *)GL_IT(it)->wsd->last_selected_item, EINA_TRUE);
3007 // Do not check selected because always select mode can be used
3008 _item_highlight(it);
3009 it->selected = EINA_TRUE;
3010 sd->selected = eina_list_append(sd->selected, it);
3011 sd->last_selected_item = (Elm_Object_Item *)it;
3013 if (it->func.func) it->func.func((void *)it->func.data, obj, it);
3014 if (!EINA_MAGIC_CHECK((Elm_Widget_Item *)it, ELM_WIDGET_ITEM_MAGIC))
3016 evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
3020 _item_select_unselect(Elm_Gen_Item *it, Eina_Bool selected)
3022 Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
3023 Evas_Object *obj = ELM_WIDGET_DATA(sd)->obj;
3024 if (elm_widget_item_disabled_get(it)) return;
3026 evas_object_ref(obj);
3029 const Eina_List *l, *ll;
3031 EINA_LIST_FOREACH_SAFE(sd->selected, l, ll, it2)
3032 if (it2 != it) _item_unselect(it2);
3034 if (selected) _item_select(it);
3035 else _item_unselect(it);
3036 evas_object_unref(obj);
3040 _item_block_position_update(Eina_Inlist *list,
3045 EINA_INLIST_FOREACH(list, tmp)
3047 tmp->position = idx++;
3048 tmp->position_update = EINA_TRUE;
3053 _item_position_update(Eina_List *list,
3059 EINA_LIST_FOREACH(list, l, it)
3061 it->position = idx++;
3062 it->position_update = EINA_TRUE;
3067 _item_block_merge(Item_Block *left,
3073 EINA_LIST_FOREACH(right->items, l, it2)
3075 it2->item->block = left;
3077 left->changed = EINA_TRUE;
3079 left->items = eina_list_merge(left->items, right->items);
3083 _item_block_del(Elm_Gen_Item *it)
3086 Item_Block *itb = it->item->block;
3087 Eina_Bool block_changed = EINA_FALSE;
3089 itb->items = eina_list_remove(itb->items, it);
3091 itb->changed = EINA_TRUE;
3092 if (GL_IT(it)->wsd->calc_job) ecore_job_del(GL_IT(it)->wsd->calc_job);
3093 GL_IT(it)->wsd->calc_job = ecore_job_add(_calc_job, GL_IT(it)->wsd);
3098 il = EINA_INLIST_GET(itb);
3099 itbn = (Item_Block *)(il->next);
3101 it->parent->item->items =
3102 eina_list_remove(it->parent->item->items, it);
3105 _item_block_position_update(il->next, itb->position);
3107 GL_IT(it)->wsd->blocks =
3108 eina_inlist_remove(GL_IT(it)->wsd->blocks, il);
3111 if (itbn) itbn->changed = EINA_TRUE;
3115 if (itb->count < (itb->sd->max_items_per_block / 2))
3120 il = EINA_INLIST_GET(itb);
3121 itbp = (Item_Block *)(il->prev);
3122 itbn = (Item_Block *)(il->next);
3124 /* merge block with previous */
3126 ((itbp->count + itb->count) <
3127 (itb->sd->max_items_per_block +
3128 (itb->sd->max_items_per_block / 2))))
3130 _item_block_merge(itbp, itb);
3131 _item_block_position_update
3132 (EINA_INLIST_GET(itb)->next, itb->position);
3133 GL_IT(it)->wsd->blocks = eina_inlist_remove
3134 (GL_IT(it)->wsd->blocks, EINA_INLIST_GET(itb));
3136 block_changed = EINA_TRUE;
3138 /* merge block with next */
3140 ((itbn->count + itb->count) <
3141 (itb->sd->max_items_per_block +
3142 (itb->sd->max_items_per_block / 2))))
3144 _item_block_merge(itb, itbn);
3145 _item_block_position_update
3146 (EINA_INLIST_GET(itbn)->next, itbn->position);
3147 GL_IT(it)->wsd->blocks =
3148 eina_inlist_remove(GL_IT(it)->wsd->blocks,
3149 EINA_INLIST_GET(itbn));
3151 block_changed = EINA_TRUE;
3158 GL_IT(it)->wsd->pan_changed = EINA_TRUE;
3159 evas_object_smart_changed(GL_IT(it)->wsd->pan_obj);
3160 if (GL_IT(it)->wsd->calc_job) ecore_job_del(GL_IT(it)->wsd->calc_job);
3161 GL_IT(it)->wsd->calc_job = NULL;
3166 _decorate_all_item_unrealize(Elm_Gen_Item *it)
3170 if ((!it) || (!it->item->decorate_all_item_realized)) return;
3172 edje_object_part_unswallow(it->deco_all_view, VIEW(it));
3173 evas_object_smart_member_add(VIEW(it), GL_IT(it)->wsd->pan_obj);
3174 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
3175 _elm_genlist_item_odd_even_update(it);
3176 _elm_genlist_item_state_update(it, NULL);
3178 edje_object_signal_emit
3179 (it->deco_all_view, "elm,state,decorate,disabled,effect", "elm");
3180 edje_object_signal_emit
3181 (VIEW(it), "elm,state,decorate,disabled", "elm");
3182 edje_object_message_signal_process(VIEW(it));
3183 edje_object_message_signal_process(it->deco_all_view);
3185 evas_object_del(it->deco_all_view);
3186 it->deco_all_view = NULL;
3187 elm_widget_stringlist_free(it->item->deco_all_texts);
3188 it->item->deco_all_texts = NULL;
3189 elm_widget_stringlist_free(it->item->deco_all_contents);
3190 it->item->deco_all_contents = NULL;
3191 elm_widget_stringlist_free(it->item->deco_all_states);
3192 it->item->deco_all_states = NULL;
3193 EINA_LIST_FREE (it->item->deco_all_content_objs, icon)
3194 evas_object_del(icon);
3196 _item_mouse_callbacks_del(it, it->deco_all_view);
3197 _item_mouse_callbacks_add(it, VIEW(it));
3199 it->item->decorate_all_item_realized = EINA_FALSE;
3203 _item_subitems_clear(Elm_Gen_Item *it)
3205 Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
3207 if (!sd->tree_effect_enabled || !sd->move_effect_mode)
3208 _item_sub_items_clear(it);
3211 if (!sd->tree_effect_animator)
3213 sd->expanded_item = it;
3214 _item_tree_effect_before(it);
3215 evas_object_raise(sd->alpha_bg);
3216 evas_object_show(sd->alpha_bg);
3217 sd->start_time = ecore_time_get();
3218 sd->tree_effect_animator =
3219 ecore_animator_add(_tree_effect_animator_cb, sd);
3222 _item_sub_items_clear(it);
3227 _item_free(Elm_Gen_Item *it)
3229 Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
3231 elm_widget_item_pre_notify_del(it);
3232 if (it->itc->func.del)
3233 it->itc->func.del((void *)it->base.data, WIDGET(it));
3234 if (it->tooltip.del_cb)
3235 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
3237 if (it->item->block) _item_block_del(it);
3240 it->parent->item->items =
3241 eina_list_remove(it->parent->item->items, it);
3242 if (it->item->queued) sd->queue = eina_list_remove(sd->queue, it);
3243 if (it->group) sd->group_items = eina_list_remove(sd->group_items, it);
3245 // FIXME: relative will be better to be fixed. it is too harsh.
3247 it->item->rel->item->rel_revs =
3248 eina_list_remove(it->item->rel->item->rel_revs, it);
3249 if (it->item->rel_revs)
3252 EINA_LIST_FREE(it->item->rel_revs, tmp) tmp->item->rel = NULL;
3254 _item_subitems_clear(it);
3255 #if GENLIST_ENTRY_SUPPORT
3256 it->item->unrealize_disabled = EINA_FALSE;
3258 _item_unrealize(it, EINA_FALSE);
3259 elm_genlist_item_class_unref((Elm_Genlist_Item_Class *)it->itc);
3260 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
3263 if (it->selected) sd->selected = eina_list_remove(sd->selected, it);
3264 if (sd->show_item == it) sd->show_item = NULL;
3265 if (sd->anchor_item == it)
3268 ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3269 if (!sd->anchor_item) sd->anchor_item =
3270 ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3272 if (sd->expanded_item == it)
3274 if (sd->tree_effect_animator)
3276 _item_tree_effect_finish(sd);
3277 ecore_animator_del(sd->tree_effect_animator);
3278 sd->tree_effect_animator = NULL;
3280 sd->expanded_item = NULL;
3281 sd->move_effect_mode = ELM_GENLIST_TREE_EFFECT_NONE;
3283 if (sd->expanded_next_item == it) sd->expanded_next_item = NULL;
3285 sd->move_items = eina_list_remove(sd->move_items, it);
3286 if (sd->state) eina_inlist_sorted_state_free(sd->state);
3288 if (sd->last_selected_item == (Elm_Object_Item *)it)
3289 sd->last_selected_item = NULL;
3293 ecore_timer_del(it->long_timer);
3294 it->long_timer = NULL;
3297 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(it));
3300 if (sd->calc_job) ecore_job_del(sd->calc_job);
3301 sd->calc_job = ecore_job_add(_calc_job, sd);
3305 _item_mouse_move_cb(void *data,
3306 Evas *evas __UNUSED__,
3310 EINA_SAFETY_ON_NULL_RETURN(data);
3311 Elm_Gen_Item *it = data;
3312 Elm_Genlist_Smart_Data *sd;
3313 Evas_Event_Mouse_Move *ev = event_info;
3314 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
3315 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
3317 sd = GL_IT(it)->wsd;
3319 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
3321 if (!sd->on_hold) _item_unselect(it);
3322 sd->on_hold = EINA_TRUE;
3324 if (sd->multi_touched)
3326 sd->cur_x = ev->cur.canvas.x;
3327 sd->cur_y = ev->cur.canvas.y;
3330 if ((it->dragging) && (it->down))
3332 if (sd->movements == SWIPE_MOVES)
3333 sd->swipe = EINA_TRUE;
3336 sd->history[sd->movements].x = ev->cur.canvas.x;
3337 sd->history[sd->movements].y = ev->cur.canvas.y;
3338 if (abs((sd->history[sd->movements].x -
3339 sd->history[0].x)) > 40)
3340 sd->swipe = EINA_TRUE;
3346 ecore_timer_del(it->long_timer);
3347 it->long_timer = NULL;
3349 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
3352 if ((!it->down) || (sd->longpressed))
3356 ecore_timer_del(it->long_timer);
3357 it->long_timer = NULL;
3359 if ((sd->reorder_mode) && (sd->reorder_it))
3361 evas_object_geometry_get(sd->pan_obj, &ox, &oy, &ow, &oh);
3363 if (ev->cur.canvas.y < (oy + (sd->reorder_it->item->h / 2)))
3364 sd->reorder_fast = 1;
3365 else if (ev->cur.canvas.y > (oy + oh - (sd->reorder_it->item->h / 2)))
3366 sd->reorder_fast = -1;
3367 else sd->reorder_fast = 0;
3369 it_scrl_y = ev->cur.canvas.y - sd->reorder_it->dy;
3371 if (!sd->reorder_start_y)
3372 sd->reorder_start_y = it->item->block->y + it->y;
3376 else if (it_scrl_y + sd->reorder_it->item->h > oy + oh)
3377 y_pos = oy + oh - sd->reorder_it->item->h;
3381 if (it->deco_all_view)
3382 _item_position(it, it->deco_all_view, it->item->scrl_x, y_pos);
3383 else if (it->item->deco_it_view)
3385 (it, it->item->deco_it_view, it->item->scrl_x, y_pos);
3387 _item_position(it, VIEW(it), it->item->scrl_x, y_pos);
3389 if (sd->calc_job) ecore_job_del(sd->calc_job);
3390 sd->calc_job = ecore_job_add(_calc_job, sd);
3394 if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
3395 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
3397 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
3398 x = ev->cur.canvas.x - x;
3399 y = ev->cur.canvas.y - y;
3402 if (adx < 0) adx = -dx;
3406 if (ady < 0) ady = -dy;
3410 if ((adx > minw) || (ady > minh))
3412 it->dragging = EINA_TRUE;
3415 ecore_timer_del(it->long_timer);
3416 it->long_timer = NULL;
3421 evas_object_smart_callback_call
3422 (WIDGET(it), SIG_DRAG_START_UP, it);
3426 evas_object_smart_callback_call
3427 (WIDGET(it), SIG_DRAG_START_LEFT, it);
3429 evas_object_smart_callback_call
3430 (WIDGET(it), SIG_DRAG_START_RIGHT, it);
3436 evas_object_smart_callback_call
3437 (WIDGET(it), SIG_DRAG_START_DOWN, it);
3441 evas_object_smart_callback_call
3442 (WIDGET(it), SIG_DRAG_START_LEFT, it);
3444 evas_object_smart_callback_call
3445 (WIDGET(it), SIG_DRAG_START_RIGHT, it);
3452 _long_press_cb(void *data)
3454 Elm_Gen_Item *it = data, *it2;
3455 Elm_Genlist_Smart_Data *sd;
3458 sd = GL_IT(it)->wsd;
3460 it->long_timer = NULL;
3461 if (elm_widget_item_disabled_get(it) || (it->dragging) ||
3462 (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY))
3463 return ECORE_CALLBACK_CANCEL;
3465 GL_IT(it)->wsd->longpressed = EINA_TRUE;
3466 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
3467 if ((GL_IT(it)->wsd->reorder_mode) && (!it->group))
3469 GL_IT(it)->wsd->reorder_it = it;
3470 GL_IT(it)->wsd->reorder_start_y = 0;
3471 if (it->deco_all_view)
3472 evas_object_raise(it->deco_all_view);
3474 evas_object_raise(VIEW(it));
3476 sd->s_iface->hold_set(ELM_WIDGET_DATA(sd)->obj, EINA_TRUE);
3477 sd->s_iface->bounce_allow_set
3478 (ELM_WIDGET_DATA(sd)->obj, EINA_FALSE, EINA_FALSE);
3480 EINA_LIST_FOREACH_SAFE(sd->selected, l, ll, it2)
3482 if (it != it2) _item_unselect(it2);
3485 // FIXME: difference from opensource
3486 if (it->item->items)
3488 EINA_LIST_FOREACH(it->item->items, l, it_tmp)
3490 if (elm_genlist_item_expanded_get((Elm_Object_Item *) it_tmp))
3492 elm_genlist_item_expanded_set((Elm_Object_Item *)it_tmp,
3494 return ECORE_CALLBACK_RENEW;
3499 if (elm_genlist_item_expanded_get((Elm_Object_Item *)it))
3501 elm_genlist_item_expanded_set((Elm_Object_Item *)it, EINA_FALSE);
3502 return ECORE_CALLBACK_RENEW;
3505 if (!GL_IT(it)->wsd->decorate_all_mode)
3506 edje_object_signal_emit
3507 (VIEW(it), "elm,state,reorder,enabled", "elm");
3510 return ECORE_CALLBACK_CANCEL;
3514 _swipe_do(Elm_Gen_Item *it)
3519 if ((it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) ||
3520 elm_widget_item_disabled_get(it)) return;
3522 GL_IT(it)->wsd->swipe = EINA_FALSE;
3523 for (i = 0; i < GL_IT(it)->wsd->movements; i++)
3525 sum += GL_IT(it)->wsd->history[i].x;
3526 if (abs(GL_IT(it)->wsd->history[0].y -
3527 GL_IT(it)->wsd->history[i].y) > 10) return;
3530 sum /= GL_IT(it)->wsd->movements;
3531 if (abs(sum - GL_IT(it)->wsd->history[0].x) <= 10) return;
3532 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
3536 _swipe_cancel(void *data)
3538 Elm_Gen_Item *it = data;
3540 if (!it) return ECORE_CALLBACK_CANCEL;
3541 GL_IT(it)->wsd->swipe = EINA_FALSE;
3542 GL_IT(it)->wsd->movements = 0;
3544 return ECORE_CALLBACK_RENEW;
3548 _multi_cancel(void *data)
3550 Elm_Genlist_Smart_Data *sd = data;
3552 if (!sd) return ECORE_CALLBACK_CANCEL;
3553 sd->multi_timeout = EINA_TRUE;
3555 return ECORE_CALLBACK_RENEW;
3559 _multi_touch_gesture_eval(void *data)
3561 Elm_Gen_Item *it = data;
3562 Evas_Coord minw = 0, minh = 0;
3563 Evas_Coord off_x, off_y, off_mx, off_my;
3565 GL_IT(it)->wsd->multi_touched = EINA_FALSE;
3566 if (GL_IT(it)->wsd->multi_timer)
3568 ecore_timer_del(GL_IT(it)->wsd->multi_timer);
3569 GL_IT(it)->wsd->multi_timer = NULL;
3571 if (GL_IT(it)->wsd->multi_timeout)
3573 GL_IT(it)->wsd->multi_timeout = EINA_FALSE;
3577 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
3578 off_x = abs(GL_IT(it)->wsd->cur_x - GL_IT(it)->wsd->prev_x);
3579 off_y = abs(GL_IT(it)->wsd->cur_y - GL_IT(it)->wsd->prev_y);
3580 off_mx = abs(GL_IT(it)->wsd->cur_mx - GL_IT(it)->wsd->prev_mx);
3581 off_my = abs(GL_IT(it)->wsd->cur_my - GL_IT(it)->wsd->prev_my);
3583 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw)
3584 || (off_my > minh)))
3586 if ((off_x + off_mx) > (off_y + off_my))
3588 if ((GL_IT(it)->wsd->cur_x > GL_IT(it)->wsd->prev_x)
3589 && (GL_IT(it)->wsd->cur_mx > GL_IT(it)->wsd->prev_mx))
3590 evas_object_smart_callback_call
3591 (WIDGET(it), SIG_MULTI_SWIPE_RIGHT, it);
3592 else if ((GL_IT(it)->wsd->cur_x < GL_IT(it)->wsd->prev_x)
3593 && (GL_IT(it)->wsd->cur_mx < GL_IT(it)->wsd->prev_mx))
3594 evas_object_smart_callback_call
3595 (WIDGET(it), SIG_MULTI_SWIPE_LEFT, it);
3596 else if (abs(GL_IT(it)->wsd->cur_x - GL_IT(it)->wsd->cur_mx) >
3597 abs(GL_IT(it)->wsd->prev_x - GL_IT(it)->wsd->prev_mx))
3598 evas_object_smart_callback_call
3599 (WIDGET(it), SIG_MULTI_PINCH_OUT, it);
3601 evas_object_smart_callback_call
3602 (WIDGET(it), SIG_MULTI_PINCH_IN, it);
3606 if ((GL_IT(it)->wsd->cur_y > GL_IT(it)->wsd->prev_y)
3607 && (GL_IT(it)->wsd->cur_my > GL_IT(it)->wsd->prev_my))
3608 evas_object_smart_callback_call
3609 (WIDGET(it), SIG_MULTI_SWIPE_DOWN, it);
3610 else if ((GL_IT(it)->wsd->cur_y < GL_IT(it)->wsd->prev_y)
3611 && (GL_IT(it)->wsd->cur_my < GL_IT(it)->wsd->prev_my))
3612 evas_object_smart_callback_call
3613 (WIDGET(it), SIG_MULTI_SWIPE_UP, it);
3614 else if (abs(GL_IT(it)->wsd->cur_y - GL_IT(it)->wsd->cur_my) >
3615 abs(GL_IT(it)->wsd->prev_y - GL_IT(it)->wsd->prev_my))
3616 evas_object_smart_callback_call
3617 (WIDGET(it), SIG_MULTI_PINCH_OUT, it);
3619 evas_object_smart_callback_call
3620 (WIDGET(it), SIG_MULTI_PINCH_IN, it);
3624 GL_IT(it)->wsd->multi_timeout = EINA_FALSE;
3628 _item_multi_down_cb(void *data,
3629 Evas *evas __UNUSED__,
3630 Evas_Object *obj __UNUSED__,
3633 Elm_Gen_Item *it = data;
3634 Evas_Event_Multi_Down *ev = event_info;
3636 if ((GL_IT(it)->wsd->multi_device != 0) || (GL_IT(it)->wsd->multi_touched)
3637 || (GL_IT(it)->wsd->multi_timeout))
3640 GL_IT(it)->wsd->multi_device = ev->device;
3641 GL_IT(it)->wsd->multi_down = EINA_TRUE;
3642 GL_IT(it)->wsd->multi_touched = EINA_TRUE;
3643 GL_IT(it)->wsd->prev_mx = ev->canvas.x;
3644 GL_IT(it)->wsd->prev_my = ev->canvas.y;
3646 if (!GL_IT(it)->wsd->wasselected)
3648 GL_IT(it)->wsd->wasselected = EINA_FALSE;
3652 ecore_timer_del(it->long_timer);
3653 it->long_timer = NULL;
3657 it->dragging = EINA_FALSE;
3658 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
3660 if (it->item->swipe_timer)
3662 ecore_timer_del(it->item->swipe_timer);
3663 it->item->swipe_timer = NULL;
3665 GL_IT(it)->wsd->longpressed = EINA_FALSE;
3666 if (GL_IT(it)->wsd->on_hold)
3668 GL_IT(it)->wsd->swipe = EINA_FALSE;
3669 GL_IT(it)->wsd->movements = 0;
3670 GL_IT(it)->wsd->on_hold = EINA_FALSE;
3675 _item_multi_up_cb(void *data,
3676 Evas *evas __UNUSED__,
3677 Evas_Object *obj __UNUSED__,
3680 Elm_Gen_Item *it = data;
3681 Evas_Event_Multi_Up *ev = event_info;
3683 if (GL_IT(it)->wsd->multi_device != ev->device) return;
3684 GL_IT(it)->wsd->multi_device = 0;
3685 GL_IT(it)->wsd->multi_down = EINA_FALSE;
3686 if (GL_IT(it)->wsd->mouse_down) return;
3687 _multi_touch_gesture_eval(data);
3691 _item_multi_move_cb(void *data,
3692 Evas *evas __UNUSED__,
3693 Evas_Object *obj __UNUSED__,
3696 Elm_Gen_Item *it = data;
3697 Evas_Event_Multi_Move *ev = event_info;
3699 if (GL_IT(it)->wsd->multi_device != ev->device) return;
3700 GL_IT(it)->wsd->cur_mx = ev->cur.canvas.x;
3701 GL_IT(it)->wsd->cur_my = ev->cur.canvas.y;
3705 // FIXME: difference from upstream
3707 _item_unfocusable_set(Elm_Gen_Item *it, Eina_Bool unfocus)
3710 Evas_Object *item_obj;
3711 Evas_Object *obj = WIDGET(it);
3715 EINA_LIST_FOREACH(it->content_objs, l, item_obj)
3717 if (unfocus) elm_widget_focused_object_clear(item_obj);
3718 elm_widget_tree_unfocusable_set(item_obj, unfocus);
3720 EINA_LIST_FOREACH(it->item->flip_content_objs, l, item_obj)
3722 if (unfocus) elm_widget_focused_object_clear(item_obj);
3723 elm_widget_tree_unfocusable_set(item_obj, unfocus);
3725 EINA_LIST_FOREACH(it->item->deco_all_content_objs, l, item_obj)
3727 if (unfocus) elm_widget_focused_object_clear(item_obj);
3728 elm_widget_tree_unfocusable_set(item_obj, unfocus);
3730 it->can_focus = !unfocus;
3736 _item_mouse_down_cb(void *data,
3737 Evas *evas __UNUSED__,
3741 Evas_Event_Mouse_Down *ev = event_info;
3742 Elm_Gen_Item *it = data;
3743 Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
3746 if (ev->button != 1) return;
3748 _item_unfocusable_set(it, EINA_FALSE);
3750 it->down = EINA_TRUE;
3751 it->dragging = EINA_FALSE;
3752 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
3753 it->dx = ev->canvas.x - x;
3754 it->dy = ev->canvas.y - y;
3755 sd->mouse_down = EINA_TRUE;
3756 if (!sd->multi_touched)
3758 sd->prev_x = ev->canvas.x;
3759 sd->prev_y = ev->canvas.y;
3760 sd->multi_timeout = EINA_FALSE;
3761 if (sd->multi_timer) ecore_timer_del(sd->multi_timer);
3762 sd->multi_timer = ecore_timer_add(1, _multi_cancel, sd);
3764 sd->longpressed = EINA_FALSE;
3765 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
3767 sd->on_hold = EINA_TRUE;
3770 else sd->on_hold = EINA_FALSE;
3771 _item_highlight(it);
3772 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
3773 if ((!elm_widget_item_disabled_get(it)) &&
3774 (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY))
3776 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
3777 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
3779 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
3780 it->item->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
3781 if (it->long_timer) ecore_timer_del(it->long_timer);
3783 it->long_timer = ecore_timer_add
3784 (sd->longpress_timeout, _long_press_cb, it);
3786 it->long_timer = NULL;
3787 sd->swipe = EINA_FALSE;
3792 _item_block_new(Elm_Genlist_Smart_Data *sd,
3797 itb = calloc(1, sizeof(Item_Block));
3798 if (!itb) return NULL;
3802 sd->blocks = eina_inlist_prepend(sd->blocks, EINA_INLIST_GET(itb));
3803 _item_block_position_update(sd->blocks, 0);
3807 sd->blocks = eina_inlist_append(sd->blocks, EINA_INLIST_GET(itb));
3808 itb->position_update = EINA_TRUE;
3809 if (sd->blocks != EINA_INLIST_GET(itb))
3812 ((Item_Block *)(EINA_INLIST_GET(itb)->prev))->position + 1;
3824 _item_block_add(Elm_Genlist_Smart_Data *sd,
3827 Item_Block *itb = NULL;
3834 itb = calloc(1, sizeof(Item_Block));
3835 if (!itb) return EINA_FALSE;
3837 if (!it->item->rel->item->block)
3840 eina_inlist_append(sd->blocks, EINA_INLIST_GET(itb));
3841 itb->items = eina_list_append(itb->items, it);
3842 itb->position_update = EINA_TRUE;
3843 it->position = eina_list_count(itb->items);
3844 it->position_update = EINA_TRUE;
3846 if (sd->blocks != EINA_INLIST_GET(itb))
3850 (EINA_INLIST_GET(itb)->prev))->position + 1;
3861 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3862 if (it->item->before)
3864 sd->blocks = eina_inlist_prepend_relative
3865 (sd->blocks, EINA_INLIST_GET(itb),
3866 EINA_INLIST_GET(it->item->rel->item->block));
3868 eina_list_prepend_relative_list(itb->items, it, tmp);
3870 /* Update index from where we prepended */
3871 _item_position_update
3872 (eina_list_prev(tmp), it->item->rel->position);
3873 _item_block_position_update
3874 (EINA_INLIST_GET(itb),
3875 it->item->rel->item->block->position);
3879 sd->blocks = eina_inlist_append_relative
3880 (sd->blocks, EINA_INLIST_GET(itb),
3881 EINA_INLIST_GET(it->item->rel->item->block));
3883 eina_list_append_relative_list(itb->items, it, tmp);
3885 /* Update block index from where we appended */
3886 _item_position_update
3887 (eina_list_next(tmp), it->item->rel->position + 1);
3888 _item_block_position_update
3889 (EINA_INLIST_GET(itb),
3890 it->item->rel->item->block->position + 1);
3896 if (it->item->before)
3900 itb = (Item_Block *)(sd->blocks);
3901 if (itb->count >= sd->max_items_per_block)
3903 itb = _item_block_new(sd, EINA_TRUE);
3904 if (!itb) return EINA_FALSE;
3909 itb = _item_block_new(sd, EINA_TRUE);
3910 if (!itb) return EINA_FALSE;
3912 itb->items = eina_list_prepend(itb->items, it);
3914 _item_position_update(itb->items, 0);
3920 itb = (Item_Block *)(sd->blocks->last);
3921 if (itb->count >= sd->max_items_per_block)
3923 itb = _item_block_new(sd, EINA_FALSE);
3924 if (!itb) return EINA_FALSE;
3929 itb = _item_block_new(sd, EINA_FALSE);
3930 if (!itb) return EINA_FALSE;
3932 itb->items = eina_list_append(itb->items, it);
3933 it->position = eina_list_count(itb->items);
3941 if (it->item->rel->item->queued)
3943 /* NOTE: for a strange reason eina_list and eina_inlist
3944 don't have the same property on sorted insertion
3945 order, so the queue is not always ordered like the
3946 item list. This lead to issue where we depend on an
3947 item that is not yet created. As a quick work around,
3948 we reschedule the calc of the item and stop reordering
3949 the list to prevent any nasty issue to show up here.
3951 sd->queue = eina_list_append(sd->queue, it);
3952 sd->requeued = EINA_TRUE;
3953 it->item->queued = EINA_TRUE;
3957 itb = it->item->rel->item->block;
3958 if (!itb) goto newblock;
3959 tmp = eina_list_data_find_list(itb->items, it->item->rel);
3960 if (it->item->before)
3962 itb->items = eina_list_prepend_relative_list(itb->items, it, tmp);
3963 _item_position_update
3964 (eina_list_prev(tmp), it->item->rel->position);
3968 itb->items = eina_list_append_relative_list(itb->items, it, tmp);
3969 _item_position_update
3970 (eina_list_next(tmp), it->item->rel->position + 1);
3975 itb->changed = EINA_TRUE;
3976 it->item->block = itb;
3977 if (itb->sd->calc_job) ecore_job_del(itb->sd->calc_job);
3978 itb->sd->calc_job = ecore_job_add(_calc_job, itb->sd);
3982 it->item->rel->relcount--;
3983 // FIXME: relcount should be removed.
3984 if (((Elm_Widget_Item *)it->item->rel)->on_deletion &&
3985 (!it->item->rel->relcount))
3987 elm_widget_item_del(it->item->rel);
3989 it->item->rel = NULL;
3992 if (itb->count > itb->sd->max_items_per_block)
3997 Eina_Bool done = EINA_FALSE;
3999 newc = itb->count / 2;
4001 if (EINA_INLIST_GET(itb)->prev)
4003 Item_Block *itbp = (Item_Block *)(EINA_INLIST_GET(itb)->prev);
4005 if (itbp->count + newc < sd->max_items_per_block / 2)
4007 /* moving items to previous block */
4008 while ((itb->count > newc) && (itb->items))
4010 it2 = eina_list_data_get(itb->items);
4011 itb->items = eina_list_remove_list
4012 (itb->items, itb->items);
4015 itbp->items = eina_list_append(itbp->items, it2);
4016 it2->item->block = itbp;
4024 if (!done && EINA_INLIST_GET(itb)->next)
4026 Item_Block *itbn = (Item_Block *)(EINA_INLIST_GET(itb)->next);
4028 if (itbn->count + newc < sd->max_items_per_block / 2)
4030 /* moving items to next block */
4031 while ((itb->count > newc) && (itb->items))
4035 l = eina_list_last(itb->items);
4036 it2 = eina_list_data_get(l);
4037 itb->items = eina_list_remove_list(itb->items, l);
4040 itbn->items = eina_list_prepend(itbn->items, it2);
4041 it2->item->block = itbn;
4051 /* moving items to new block */
4052 itb2 = calloc(1, sizeof(Item_Block));
4053 if (!itb2) return EINA_FALSE;
4056 eina_inlist_append_relative(sd->blocks, EINA_INLIST_GET(itb2),
4057 EINA_INLIST_GET(itb));
4058 itb2->changed = EINA_TRUE;
4059 while ((itb->count > newc) && (itb->items))
4063 l = eina_list_last(itb->items);
4065 itb->items = eina_list_remove_list(itb->items, l);
4068 itb2->items = eina_list_prepend(itb2->items, it2);
4069 it2->item->block = itb2;
4079 _item_process(Elm_Genlist_Smart_Data *sd,
4082 if (!_item_block_add(sd, it)) return 1;
4084 _item_block_realize(it->item->block);
4090 _item_process_post(Elm_Genlist_Smart_Data *sd,
4094 Eina_Bool show_me = EINA_FALSE;
4096 if (it->item->block->changed)
4098 show_me = _item_block_recalc
4099 (it->item->block, it->item->block->num, qadd);
4100 it->item->block->changed = 0;
4101 if (sd->pan_changed)
4103 if (sd->calc_job) ecore_job_del(sd->calc_job);
4104 sd->calc_job = NULL;
4106 sd->pan_changed = EINA_FALSE;
4109 if (show_me) it->item->block->show_me = EINA_TRUE;
4111 /* when prepending, move the scroller along with the first selected
4112 * item to create the illusion that we're watching the selected
4113 * item this prevents the selected item being scrolled off the
4116 if (sd->selected && it->item->before)
4121 it2 = sd->selected->data;
4122 if (!it2->item->block) return;
4123 sd->s_iface->content_pos_get(ELM_WIDGET_DATA(sd)->obj, NULL, &y);
4124 evas_object_geometry_get(sd->pan_obj, NULL, NULL, NULL, &h);
4125 if ((it->y + it->item->block->y > y + h) ||
4126 (it->y + it->item->block->y + it->item->h < y))
4127 /* offscreen, just update */
4128 sd->s_iface->content_region_show
4129 (ELM_WIDGET_DATA(sd)->obj, it2->x + it2->item->block->x, y,
4130 it2->item->block->w, h);
4132 sd->s_iface->content_region_show
4133 (ELM_WIDGET_DATA(sd)->obj, it->x + it->item->block->x,
4134 y + it->item->h, it->item->block->w, h);
4139 _queue_process(Elm_Genlist_Smart_Data *sd)
4144 t0 = ecore_loop_time_get();
4145 for (n = 0; (sd->queue) && (n < 128); n++)
4149 it = eina_list_data_get(sd->queue);
4150 sd->queue = eina_list_remove_list(sd->queue, sd->queue);
4151 it->item->queued = EINA_FALSE;
4152 if (_item_process(sd, it)) continue;
4153 t = ecore_time_get();
4154 _item_process_post(sd, it, EINA_TRUE);
4155 /* same as eina_inlist_count > 1 */
4156 if (sd->blocks && sd->blocks->next)
4158 if ((t - t0) > (ecore_animator_frametime_get())) break;
4165 _idle_process(void *data,
4168 Elm_Genlist_Smart_Data *sd = data;
4170 if (_queue_process(sd) > 0) *wakeup = EINA_TRUE;
4173 return ECORE_CALLBACK_CANCEL;
4175 return ECORE_CALLBACK_RENEW;
4179 _item_idle_enterer(void *data)
4181 Eina_Bool wakeup = EINA_FALSE;
4182 Elm_Genlist_Smart_Data *sd = data;
4183 Eina_Bool ok = _idle_process(data, &wakeup);
4188 if (sd->calc_job) ecore_job_del(sd->calc_job);
4189 sd->calc_job = ecore_job_add(_calc_job, sd);
4191 if (ok == ECORE_CALLBACK_CANCEL) sd->queue_idle_enterer = NULL;
4197 _item_queue(Elm_Genlist_Smart_Data *sd,
4201 if (it->item->queued) return;
4202 it->item->queued = EINA_TRUE;
4203 if (cb && !sd->requeued)
4204 sd->queue = eina_list_sorted_insert(sd->queue, cb, it);
4206 sd->queue = eina_list_append(sd->queue, it);
4207 // FIXME: why does a freeze then thaw here cause some genlist
4208 // elm_genlist_item_append() to be much much slower?
4209 // evas_event_freeze(evas_object_evas_get(sd->obj));
4210 while ((sd->queue) && ((!sd->blocks) || (!sd->blocks->next)))
4212 if (sd->queue_idle_enterer)
4214 ecore_idle_enterer_del(sd->queue_idle_enterer);
4215 sd->queue_idle_enterer = NULL;
4219 while ((sd->queue) && (sd->blocks) &&
4220 (sd->homogeneous) && (sd->mode == ELM_LIST_COMPRESS))
4222 if (sd->queue_idle_enterer)
4224 ecore_idle_enterer_del(sd->queue_idle_enterer);
4225 sd->queue_idle_enterer = NULL;
4230 // evas_event_thaw(evas_object_evas_get(sd->obj));
4231 // evas_event_thaw_eval(evas_object_evas_get(sd->obj));
4232 if (!sd->queue_idle_enterer)
4233 sd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, sd);
4236 /* If the application wants to know the relative item, use
4237 * elm_genlist_item_prev_get(it)*/
4239 _item_move_after(Elm_Gen_Item *it,
4240 Elm_Gen_Item *after)
4244 if (it == after) return;
4246 GL_IT(it)->wsd->items =
4247 eina_inlist_remove(GL_IT(it)->wsd->items, EINA_INLIST_GET(it));
4248 if (it->item->block) _item_block_del(it);
4250 GL_IT(it)->wsd->items = eina_inlist_append_relative
4251 (GL_IT(it)->wsd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
4252 it->item->rel = after;
4253 after->item->rel_revs = eina_list_append(after->item->rel_revs, it);
4254 it->item->before = EINA_FALSE;
4255 if (after->item->group_item) it->item->group_item = after->item->group_item;
4256 _item_queue(GL_IT(it)->wsd, it, NULL);
4258 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED_AFTER, it);
4262 _access_activate_cb(void *data __UNUSED__,
4263 Evas_Object *part_obj __UNUSED__,
4264 Elm_Object_Item *item)
4266 _item_select_unselect((Elm_Gen_Item *)item, EINA_TRUE);
4269 /* If the application wants to know the relative item, use
4270 * elm_genlist_item_next_get(it)*/
4272 _item_move_before(Elm_Gen_Item *it,
4273 Elm_Gen_Item *before)
4276 if (!before) return;
4277 if (it == before) return;
4279 GL_IT(it)->wsd->items =
4280 eina_inlist_remove(GL_IT(it)->wsd->items, EINA_INLIST_GET(it));
4281 if (it->item->block) _item_block_del(it);
4282 GL_IT(it)->wsd->items = eina_inlist_prepend_relative
4283 (GL_IT(it)->wsd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
4284 it->item->rel = before;
4285 before->item->rel_revs = eina_list_append(before->item->rel_revs, it);
4286 it->item->before = EINA_TRUE;
4287 if (before->item->group_item)
4288 it->item->group_item = before->item->group_item;
4289 _item_queue(GL_IT(it)->wsd, it, NULL);
4291 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED_BEFORE, it);
4295 _item_mouse_up_cb(void *data,
4296 Evas *evas __UNUSED__,
4297 Evas_Object *obj __UNUSED__,
4300 Evas_Event_Mouse_Up *ev = event_info;
4301 Eina_Bool dragged = EINA_FALSE;
4302 Elm_Genlist_Smart_Data *sd;
4303 Elm_Gen_Item *it = data;
4305 if (ev->button != 1) return;
4306 it->down = EINA_FALSE;
4307 sd = GL_IT(it)->wsd;
4309 sd->mouse_down = EINA_FALSE;
4310 if (sd->multi_touched)
4312 if ((!sd->multi) && (!it->selected) && (it->highlighted))
4313 _item_unhighlight(it);
4314 if (sd->multi_down) return;
4315 _multi_touch_gesture_eval(data);
4320 ecore_timer_del(it->long_timer);
4321 it->long_timer = NULL;
4325 it->dragging = EINA_FALSE;
4326 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
4329 if (it->item->swipe_timer)
4331 ecore_timer_del(it->item->swipe_timer);
4332 it->item->swipe_timer = NULL;
4334 if (sd->multi_timer)
4336 ecore_timer_del(sd->multi_timer);
4337 sd->multi_timer = NULL;
4338 sd->multi_timeout = EINA_FALSE;
4340 sd->on_hold = EINA_FALSE;
4341 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
4343 if (sd->swipe) _swipe_do(data);
4344 sd->longpressed = EINA_FALSE;
4347 if ((sd->reorder_mode) && (sd->reorder_it))
4349 Evas_Coord it_scrl_y = ev->canvas.y - sd->reorder_it->dy;
4350 sd->reorder_fast = 0;
4352 if (sd->reorder_rel &&
4353 (sd->reorder_it->parent == sd->reorder_rel->parent))
4355 if (it_scrl_y <= sd->reorder_rel->item->scrl_y)
4356 _item_move_before(sd->reorder_it, sd->reorder_rel);
4358 _item_move_after(sd->reorder_it, sd->reorder_rel);
4359 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
4363 if (sd->calc_job) ecore_job_del(sd->calc_job);
4364 sd->calc_job = ecore_job_add(_calc_job, sd);
4366 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
4367 sd->reorder_it = sd->reorder_rel = NULL;
4368 sd->s_iface->hold_set(ELM_WIDGET_DATA(sd)->obj, EINA_FALSE);
4369 sd->s_iface->bounce_allow_set
4370 (ELM_WIDGET_DATA(sd)->obj, sd->h_bounce, sd->v_bounce);
4374 if (it->want_unrealize && !(it->item->unrealize_disabled))
4376 _item_unrealize(it, EINA_FALSE);
4377 if (it->item->block->want_unrealize)
4378 _item_block_unrealize(it->item->block);
4383 if (!sd->longpressed)
4384 if ((sd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS) ||
4385 (it->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS))
4386 _item_select_unselect(it, EINA_TRUE);
4387 else _item_select_unselect(it, !it->selected);
4389 _item_unhighlight(it);
4393 _item_mouse_callbacks_add(Elm_Gen_Item *it,
4396 evas_object_event_callback_add
4397 (view, EVAS_CALLBACK_MOUSE_DOWN, _item_mouse_down_cb, it);
4398 evas_object_event_callback_add
4399 (view, EVAS_CALLBACK_MOUSE_UP, _item_mouse_up_cb, it);
4400 evas_object_event_callback_add
4401 (view, EVAS_CALLBACK_MOUSE_MOVE, _item_mouse_move_cb, it);
4402 evas_object_event_callback_add
4403 (view, EVAS_CALLBACK_MULTI_DOWN, _item_multi_down_cb, it);
4404 evas_object_event_callback_add
4405 (view, EVAS_CALLBACK_MULTI_UP, _item_multi_up_cb, it);
4406 evas_object_event_callback_add
4407 (view, EVAS_CALLBACK_MULTI_MOVE, _item_multi_move_cb, it);
4411 _item_mouse_callbacks_del(Elm_Gen_Item *it,
4414 evas_object_event_callback_del_full
4415 (view, EVAS_CALLBACK_MOUSE_DOWN, _item_mouse_down_cb, it);
4416 evas_object_event_callback_del_full
4417 (view, EVAS_CALLBACK_MOUSE_UP, _item_mouse_up_cb, it);
4418 evas_object_event_callback_del_full
4419 (view, EVAS_CALLBACK_MOUSE_MOVE, _item_mouse_move_cb, it);
4420 evas_object_event_callback_del_full
4421 (view, EVAS_CALLBACK_MULTI_DOWN, _item_multi_down_cb, it);
4422 evas_object_event_callback_del_full
4423 (view, EVAS_CALLBACK_MULTI_UP, _item_multi_up_cb, it);
4424 evas_object_event_callback_del_full
4425 (view, EVAS_CALLBACK_MULTI_MOVE, _item_multi_move_cb, it);
4429 _scroll_hold_timer_cb(void *data)
4431 Elm_Genlist_Smart_Data *sd = data;
4433 if (!data) return ECORE_CALLBACK_CANCEL;
4435 sd->s_iface->hold_set(ELM_WIDGET_DATA(sd)->obj, EINA_FALSE);
4436 sd->scr_hold_timer = NULL;
4438 return ECORE_CALLBACK_CANCEL;
4442 _decorate_item_finished_signal_cb(void *data,
4444 const char *emission __UNUSED__,
4445 const char *source __UNUSED__)
4447 Elm_Gen_Item *it = data;
4450 if (!data || !obj) return;
4451 if ((!it->realized) || (!it->item->deco_it_view)) return;
4453 it->item->nocache_once = EINA_FALSE;
4454 _decorate_item_unrealize(it);
4455 if (it->item->group_item)
4456 evas_object_raise(it->item->VIEW(group_item));
4458 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished",
4459 GL_IT(it)->wsd->decorate_it_type);
4460 edje_object_signal_callback_del_full
4461 (obj, buf, "elm", _decorate_item_finished_signal_cb, it);
4465 _item_mode_content_unrealize(Elm_Gen_Item *it,
4466 Evas_Object *target,
4469 Eina_List **contents_list)
4471 Eina_List *res = *contents_list;
4473 if (it->itc->func.content_get)
4477 Evas_Object *ic = NULL;
4479 EINA_LIST_FOREACH(*source, l, key)
4481 if (parts && fnmatch(parts, key, FNM_PERIOD))
4484 ic = edje_object_part_swallow_get(target, key);
4487 res = eina_list_remove(res, ic);
4488 edje_object_part_unswallow(target, ic);
4489 evas_object_del(ic);
4498 _item_content_unrealize(Elm_Gen_Item *it,
4499 Evas_Object *target,
4503 Eina_List *res = it->content_objs;
4505 if (it->itc->func.content_get)
4509 Evas_Object *ic = NULL;
4511 EINA_LIST_FOREACH(*source, l, key)
4513 if (parts && fnmatch(parts, key, FNM_PERIOD))
4516 ic = edje_object_part_swallow_get(target, key);
4519 res = eina_list_remove(res, ic);
4520 edje_object_part_unswallow(target, ic);
4521 // FIXME: If parent-child relationship was broken before 'ic'
4522 // is deleted, freeze_pop will not be called. ex) elm_slider
4523 // If layout is used instead of edje, this problme can be
4525 if (0 != elm_widget_scroll_freeze_get(ic))
4526 elm_widget_scroll_freeze_pop(ic);
4527 evas_object_del(ic);
4536 _item_block_recalc(Item_Block *itb,
4540 const Eina_List *l, *ll;
4542 Evas_Coord minw = 0, minh = 0;
4543 Eina_Bool show_me = EINA_FALSE, changed = EINA_FALSE;
4547 EINA_LIST_FOREACH_SAFE(itb->items, l, ll, it)
4549 show_me |= it->item->show_me;
4554 if (!it->item->mincalcd) changed = EINA_TRUE;
4557 _item_realize(it, in, EINA_TRUE);
4558 _item_unrealize(it, EINA_TRUE);
4563 if ((itb->sd->homogeneous) &&
4564 (itb->sd->mode == ELM_LIST_COMPRESS))
4568 it->item->w = it->item->minw =
4569 GL_IT(it)->wsd->group_item_width;
4570 it->item->h = it->item->minh =
4571 GL_IT(it)->wsd->group_item_height;
4575 it->item->w = it->item->minw =
4576 GL_IT(it)->wsd->item_width;
4577 it->item->h = it->item->minh =
4578 GL_IT(it)->wsd->item_height;
4583 _item_realize(it, in, EINA_TRUE);
4584 _item_unrealize(it, EINA_TRUE);
4590 if (!it->item->mincalcd) changed = EINA_TRUE;
4591 _item_realize(it, in, EINA_FALSE);
4593 minh += it->item->minh;
4594 if (minw < it->item->minw) minw = it->item->minw;
4600 if (changed) itb->sd->pan_changed = changed;
4603 itb->changed = EINA_FALSE;
4604 itb->position_update = EINA_FALSE;
4610 _update_job(void *data)
4612 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
4613 Elm_Genlist_Smart_Data *sd = data;
4618 sd->update_job = NULL;
4621 //evas_event_freeze(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
4622 EINA_INLIST_FOREACH(sd->blocks, itb)
4624 Evas_Coord itminw, itminh;
4631 _item_block_position(itb, num);
4635 recalc = EINA_FALSE;
4636 EINA_LIST_FOREACH(itb->items, l2, it)
4638 if (it->item->updateme)
4640 itminw = it->item->minw;
4641 itminh = it->item->minh;
4643 it->item->updateme = EINA_FALSE;
4646 _item_unrealize(it, EINA_FALSE);
4647 _item_realize(it, num, EINA_FALSE);
4648 position = EINA_TRUE;
4652 _item_realize(it, num, EINA_TRUE);
4653 _item_unrealize(it, EINA_TRUE);
4655 if ((it->item->minw != itminw) || (it->item->minh != itminh))
4660 itb->updateme = EINA_FALSE;
4663 position = EINA_TRUE;
4664 itb->changed = EINA_TRUE;
4665 _item_block_recalc(itb, num0, EINA_FALSE);
4666 _item_block_position(itb, num0);
4671 if (sd->calc_job) ecore_job_del(sd->calc_job);
4672 sd->calc_job = ecore_job_add(_calc_job, sd);
4674 //evas_event_thaw(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
4675 //evas_event_thaw_eval(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
4679 _scroll_animate_start_cb(Evas_Object *obj,
4680 void *data __UNUSED__)
4682 evas_object_smart_callback_call(obj, SIG_SCROLL_ANIM_START, NULL);
4686 _scroll_animate_stop_cb(Evas_Object *obj,
4687 void *data __UNUSED__)
4689 evas_object_smart_callback_call(obj, SIG_SCROLL_ANIM_STOP, NULL);
4693 _scroll_drag_start_cb(Evas_Object *obj,
4694 void *data __UNUSED__)
4696 evas_object_smart_callback_call(obj, SIG_SCROLL_DRAG_START, NULL);
4700 _scroll_drag_stop_cb(Evas_Object *obj,
4701 void *data __UNUSED__)
4703 evas_object_smart_callback_call(obj, SIG_SCROLL_DRAG_STOP, NULL);
4707 _edge_left_cb(Evas_Object *obj,
4708 void *data __UNUSED__)
4710 evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
4714 _edge_right_cb(Evas_Object *obj,
4715 void *data __UNUSED__)
4717 evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
4721 _edge_top_cb(Evas_Object *obj,
4722 void *data __UNUSED__)
4724 evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
4728 _edge_bottom_cb(Evas_Object *obj,
4729 void *data __UNUSED__)
4731 evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
4735 _decorate_item_realize(Elm_Gen_Item *it)
4738 if (it->item->deco_it_view) return;
4740 //evas_event_freeze(evas_object_evas_get(obj));
4741 it->item->deco_it_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
4742 edje_object_scale_set
4743 (it->item->deco_it_view, elm_widget_scale_get(WIDGET(it)) *
4744 elm_config_scale_get());
4745 evas_object_smart_member_add
4746 (it->item->deco_it_view, GL_IT(it)->wsd->pan_obj);
4747 elm_widget_sub_object_add(WIDGET(it), it->item->deco_it_view);
4749 strncpy(buf, "item", sizeof(buf));
4750 if (GL_IT(it)->wsd->mode == ELM_LIST_COMPRESS)
4751 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
4753 if (it->item->order_num_in & 0x1)
4754 strncat(buf, "_odd", sizeof(buf) - strlen(buf));
4755 strncat(buf, "/", sizeof(buf) - strlen(buf));
4756 strncat(buf, it->itc->decorate_item_style, sizeof(buf) - strlen(buf));
4758 elm_widget_theme_object_set
4759 (WIDGET(it), it->item->deco_it_view, "genlist", buf,
4760 elm_widget_style_get(WIDGET(it)));
4761 edje_object_mirrored_set
4762 (it->item->deco_it_view, elm_widget_mirrored_get(WIDGET(it)));
4764 /* signal callback add */
4765 evas_object_event_callback_add
4766 (it->item->deco_it_view, EVAS_CALLBACK_MOUSE_DOWN, _item_mouse_down_cb,
4768 evas_object_event_callback_add
4769 (it->item->deco_it_view, EVAS_CALLBACK_MOUSE_UP, _item_mouse_up_cb, it);
4770 evas_object_event_callback_add
4771 (it->item->deco_it_view, EVAS_CALLBACK_MOUSE_MOVE, _item_mouse_move_cb,
4774 if (eina_list_count(it->item->deco_it_content_objs) != 0)
4775 ERR_ABORT("If you see this error, please notify us and we"
4778 /* text_get, content_get, state_get */
4780 (it, it->item->deco_it_view, &it->item->deco_it_texts, NULL);
4781 if (!it->item->deco_it_contents)
4782 it->item->deco_it_contents =
4783 elm_widget_stringlist_get
4784 (edje_object_data_get(it->item->deco_it_view, "contents"));
4785 it->item->deco_it_content_objs =
4786 _item_mode_content_realize
4787 (it, it->item->deco_it_view, &it->item->deco_it_contents, NULL,
4788 &it->item->deco_it_content_objs);
4790 (it, it->item->deco_it_view, &it->item->deco_it_states, NULL);
4791 edje_object_part_swallow
4792 (it->item->deco_it_view,
4793 edje_object_data_get(it->item->deco_it_view, "mode_part"), VIEW(it));
4795 it->want_unrealize = EINA_FALSE;
4796 //evas_event_thaw(evas_object_evas_get(obj));
4797 //evas_event_thaw_eval(evas_object_evas_get(obj));
4801 _decorate_item_set(Elm_Gen_Item *it)
4803 Elm_Genlist_Smart_Data *sd;
4808 sd = GL_IT(it)->wsd;
4811 it->item->nocache_once = EINA_TRUE;
4813 if (sd->scr_hold_timer)
4815 ecore_timer_del(sd->scr_hold_timer);
4816 sd->scr_hold_timer = NULL;
4818 sd->s_iface->hold_set(ELM_WIDGET_DATA(sd)->obj, EINA_TRUE);
4819 sd->scr_hold_timer = ecore_timer_add(0.1, _scroll_hold_timer_cb, sd);
4821 //evas_event_freeze(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
4822 _decorate_item_realize(it);
4823 if (it->item->group_item)
4824 evas_object_raise(it->item->VIEW(group_item));
4826 (it, it->item->deco_it_view, it->item->scrl_x, it->item->scrl_y);
4827 //evas_event_thaw(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
4828 //evas_event_thaw_eval(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
4830 snprintf(buf, sizeof(buf), "elm,state,%s,active", sd->decorate_it_type);
4831 edje_object_signal_emit(it->item->deco_it_view, buf, "elm");
4835 _decorate_item_unset(Elm_Genlist_Smart_Data *sd)
4837 char buf[1024], buf2[1024];
4840 if (!sd->mode_item) return;
4843 it->item->nocache_once = EINA_TRUE;
4845 snprintf(buf, sizeof(buf), "elm,state,%s,passive", sd->decorate_it_type);
4846 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished",
4847 sd->decorate_it_type);
4848 edje_object_signal_emit(it->item->deco_it_view, buf, "elm");
4849 edje_object_signal_callback_add
4850 (it->item->deco_it_view, buf2, "elm", _decorate_item_finished_signal_cb,
4852 sd->mode_item = NULL;
4856 // FIXME: difference from upstream
4858 _mouse_down_scroller(void *data,
4859 Evas *evas __UNUSED__,
4860 Evas_Object *obj __UNUSED__,
4861 void *event_info __UNUSED__)
4863 Widget_Data *wd = elm_widget_data_get(data);
4866 wd->drag_started = EINA_FALSE;
4870 _mouse_up_scroller(void *data,
4871 Evas *evas __UNUSED__,
4872 Evas_Object *obj __UNUSED__,
4873 void *event_info __UNUSED__)
4875 Widget_Data *wd = elm_widget_data_get(data);
4878 wd->drag_started = EINA_FALSE;
4882 _mouse_move_scroller(void *data,
4883 Evas *evas __UNUSED__,
4884 Evas_Object *obj __UNUSED__,
4887 Widget_Data *wd = elm_widget_data_get(data);
4888 Evas_Event_Mouse_Move *ev = event_info;
4889 Evas_Coord minw = 0, minh = 0, dx, dy, adx, ady;
4892 if (wd->drag_started) return;
4894 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
4895 dx = ev->cur.canvas.x - ev->prev.canvas.x;
4896 dy = ev->cur.canvas.y - ev->prev.canvas.y;
4899 if (adx < 0) adx = -dx;
4900 if (ady < 0) ady = -dy;
4901 if (((ady < minh) && (ady > minh / 2)) && (ady > adx))
4905 evas_object_smart_callback_call(data, SIG_DRAG_START_UP, NULL);
4906 wd->drag_started = EINA_TRUE;
4910 evas_object_smart_callback_call(data, SIG_DRAG_START_DOWN, NULL);
4911 wd->drag_started = EINA_TRUE;
4918 _elm_genlist_smart_add(Evas_Object *obj)
4920 Evas_Coord minw, minh;
4921 Elm_Genlist_Pan_Smart_Data *pan_data;
4923 EVAS_SMART_DATA_ALLOC(obj, Elm_Genlist_Smart_Data);
4925 ELM_WIDGET_CLASS(_elm_genlist_parent_sc)->base.add(obj);
4927 priv->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
4928 evas_object_smart_member_add(priv->hit_rect, obj);
4929 elm_widget_sub_object_add(obj, priv->hit_rect);
4931 /* common scroller hit rectangle setup */
4932 evas_object_color_set(priv->hit_rect, 0, 0, 0, 0);
4933 evas_object_show(priv->hit_rect);
4934 evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
4936 elm_widget_can_focus_set(obj, EINA_TRUE);
4937 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
4939 elm_layout_theme_set(obj, "genlist", "base", elm_widget_style_get(obj));
4941 /* interface's add() routine issued AFTER the object's smart_add() */
4942 priv->s_iface = evas_object_smart_interface_get
4943 (obj, ELM_SCROLLABLE_IFACE_NAME);
4945 priv->s_iface->objects_set
4946 (obj, ELM_WIDGET_DATA(priv)->resize_obj, priv->hit_rect);
4948 priv->s_iface->bounce_allow_set
4949 (obj, EINA_FALSE, _elm_config->thumbscroll_bounce_enable);
4950 priv->v_bounce = _elm_config->thumbscroll_bounce_enable;
4952 priv->s_iface->animate_start_cb_set(obj, _scroll_animate_start_cb);
4953 priv->s_iface->animate_stop_cb_set(obj, _scroll_animate_stop_cb);
4954 priv->s_iface->drag_start_cb_set(obj, _scroll_drag_start_cb);
4955 priv->s_iface->drag_stop_cb_set(obj, _scroll_drag_stop_cb);
4956 priv->s_iface->edge_left_cb_set(obj, _edge_left_cb);
4957 priv->s_iface->edge_right_cb_set(obj, _edge_right_cb);
4958 priv->s_iface->edge_top_cb_set(obj, _edge_top_cb);
4959 priv->s_iface->edge_bottom_cb_set(obj, _edge_bottom_cb);
4961 priv->mode = ELM_LIST_SCROLL;
4962 priv->max_items_per_block = MAX_ITEMS_PER_BLOCK;
4963 priv->item_cache_max = priv->max_items_per_block * 2;
4964 priv->longpress_timeout = _elm_config->longpress_timeout;
4965 priv->highlight = EINA_TRUE;
4967 priv->pan_obj = evas_object_smart_add
4968 (evas_object_evas_get(obj), _elm_genlist_pan_smart_class_new());
4969 pan_data = evas_object_smart_data_get(priv->pan_obj);
4970 pan_data->wsd = priv;
4973 // FIXME: difference from upstream
4974 evas_object_event_callback_add(pan_obj, EVAS_CALLBACK_MOUSE_DOWN,
4975 _mouse_down_scroller, obj);
4976 evas_object_event_callback_add(pan_obj, EVAS_CALLBACK_MOUSE_UP,
4977 _mouse_up_scroller, obj);
4978 evas_object_event_callback_add(pan_obj, EVAS_CALLBACK_MOUSE_MOVE,
4979 _mouse_move_scroller, obj);
4982 priv->s_iface->extern_pan_set(obj, priv->pan_obj);
4984 edje_object_size_min_calc(ELM_WIDGET_DATA(priv)->resize_obj, &minw, &minh);
4985 evas_object_size_hint_min_set(obj, minw, minh);
4987 _item_cache_all_free(priv);
4988 _mirrored_set(obj, elm_widget_mirrored_get(obj));
4990 elm_layout_sizing_eval(obj);
4994 _elm_genlist_smart_del(Evas_Object *obj)
4996 ELM_GENLIST_DATA_GET(obj, sd);
4998 elm_genlist_clear(obj);
4999 if (sd->calc_job) ecore_job_del(sd->calc_job);
5000 if (sd->update_job) ecore_job_del(sd->update_job);
5001 if (sd->queue_idle_enterer) ecore_idle_enterer_del(sd->queue_idle_enterer);
5002 if (sd->must_recalc_idler) ecore_idler_del(sd->must_recalc_idler);
5003 if (sd->multi_timer) ecore_timer_del(sd->multi_timer);
5004 if (sd->decorate_it_type) eina_stringshare_del(sd->decorate_it_type);
5005 if (sd->scr_hold_timer) ecore_timer_del(sd->scr_hold_timer);
5006 if (sd->tree_effect_animator) ecore_animator_del(sd->tree_effect_animator);
5008 evas_object_del(sd->pan_obj);
5009 ELM_WIDGET_CLASS(_elm_genlist_parent_sc)->base.del(obj);
5013 _elm_genlist_smart_move(Evas_Object *obj,
5017 ELM_GENLIST_DATA_GET(obj, sd);
5019 ELM_WIDGET_CLASS(_elm_genlist_parent_sc)->base.move(obj, x, y);
5021 evas_object_move(sd->hit_rect, x, y);
5025 _elm_genlist_smart_resize(Evas_Object *obj,
5029 ELM_GENLIST_DATA_GET(obj, sd);
5031 ELM_WIDGET_CLASS(_elm_genlist_parent_sc)->base.resize(obj, w, h);
5033 evas_object_resize(sd->hit_rect, w, h);
5037 _elm_genlist_smart_member_add(Evas_Object *obj,
5038 Evas_Object *member)
5040 ELM_GENLIST_DATA_GET(obj, sd);
5042 ELM_WIDGET_CLASS(_elm_genlist_parent_sc)->base.member_add(obj, member);
5045 evas_object_raise(sd->hit_rect);
5049 _access_obj_process(Elm_Genlist_Smart_Data *sd, Eina_Bool is_access)
5052 Eina_Bool done = EINA_FALSE;
5054 EINA_INLIST_FOREACH(sd->blocks, itb)
5062 EINA_LIST_FOREACH(itb->items, l, it)
5064 if (!it->realized) continue;
5065 if (is_access) _access_widget_item_register(it);
5067 _elm_access_widget_item_unregister((Elm_Widget_Item *)it);
5070 else if (done) break;
5075 _elm_genlist_smart_access(Evas_Object *obj, Eina_Bool is_access)
5077 ELM_GENLIST_CHECK(obj);
5078 ELM_GENLIST_DATA_GET(obj, sd);
5081 ELM_WIDGET_CLASS(ELM_WIDGET_DATA(sd)->api)->focus_next =
5082 _elm_genlist_smart_focus_next;
5084 ELM_WIDGET_CLASS(ELM_WIDGET_DATA(sd)->api)->focus_next = NULL;
5085 _access_obj_process(sd, is_access);
5089 _elm_genlist_smart_set_user(Elm_Genlist_Smart_Class *sc)
5091 ELM_WIDGET_CLASS(sc)->base.add = _elm_genlist_smart_add;
5092 ELM_WIDGET_CLASS(sc)->base.del = _elm_genlist_smart_del;
5093 ELM_WIDGET_CLASS(sc)->base.move = _elm_genlist_smart_move;
5094 ELM_WIDGET_CLASS(sc)->base.resize = _elm_genlist_smart_resize;
5095 ELM_WIDGET_CLASS(sc)->base.member_add = _elm_genlist_smart_member_add;
5097 ELM_WIDGET_CLASS(sc)->sub_object_add = _elm_genlist_smart_sub_object_add;
5098 ELM_WIDGET_CLASS(sc)->sub_object_del = _elm_genlist_smart_sub_object_del;
5099 ELM_WIDGET_CLASS(sc)->on_focus = _elm_genlist_smart_on_focus;
5100 ELM_WIDGET_CLASS(sc)->theme = _elm_genlist_smart_theme;
5101 ELM_WIDGET_CLASS(sc)->event = _elm_genlist_smart_event;
5102 ELM_WIDGET_CLASS(sc)->translate = _elm_genlist_smart_translate;
5104 /* not a 'focus chain manager' */
5105 ELM_WIDGET_CLASS(sc)->focus_next = NULL;
5106 ELM_WIDGET_CLASS(sc)->focus_direction = NULL;
5108 ELM_LAYOUT_CLASS(sc)->sizing_eval = _elm_genlist_smart_sizing_eval;
5111 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
5112 ELM_WIDGET_CLASS(sc)->focus_next = _elm_genlist_smart_focus_next;
5114 ELM_WIDGET_CLASS(sc)->access = _elm_genlist_smart_access;
5117 EAPI const Elm_Genlist_Smart_Class *
5118 elm_genlist_smart_class_get(void)
5120 static Elm_Genlist_Smart_Class _sc =
5121 ELM_GENLIST_SMART_CLASS_INIT_NAME_VERSION(ELM_GENLIST_SMART_NAME);
5122 static const Elm_Genlist_Smart_Class *class = NULL;
5123 Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
5128 _elm_genlist_smart_set(&_sc);
5129 esc->callbacks = _smart_callbacks;
5136 elm_genlist_add(Evas_Object *parent)
5140 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
5142 obj = elm_widget_add(_elm_genlist_smart_class_new(), parent);
5143 if (!obj) return NULL;
5145 if (!elm_widget_sub_object_add(parent, obj))
5146 ERR("could not add %p as sub object of %p", obj, parent);
5152 static Evas_Object *
5153 _item_content_get_hook(Elm_Gen_Item *it,
5156 return edje_object_part_swallow_get(VIEW(it), part);
5160 _item_text_get_hook(Elm_Gen_Item *it,
5163 if (!it->itc->func.text_get) return NULL;
5164 return edje_object_part_text_get(VIEW(it), part);
5168 _item_disable_hook(Elm_Object_Item *item)
5172 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
5175 elm_genlist_item_selected_set(item, EINA_FALSE);
5179 if (elm_widget_item_disabled_get(it))
5181 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
5182 if (it->deco_all_view)
5183 edje_object_signal_emit
5184 (it->deco_all_view, "elm,state,disabled", "elm");
5188 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
5189 if (it->deco_all_view)
5190 edje_object_signal_emit
5191 (it->deco_all_view, "elm,state,enabled", "elm");
5193 EINA_LIST_FOREACH(it->content_objs, l, obj)
5194 elm_widget_disabled_set(obj, elm_widget_item_disabled_get(it));
5199 _item_del_pre_hook(Elm_Object_Item *item)
5201 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
5207 _item_signal_emit_hook(Elm_Object_Item *it,
5208 const char *emission,
5211 edje_object_signal_emit(VIEW(it), emission, source);
5214 static Elm_Gen_Item *
5215 _elm_genlist_item_new(Elm_Genlist_Smart_Data *sd,
5216 const Elm_Genlist_Item_Class *itc,
5218 Elm_Gen_Item *parent,
5219 Elm_Genlist_Item_Type type,
5221 const void *func_data)
5223 Elm_Gen_Item *it, *it2;
5226 if (!itc) return NULL;
5228 it = elm_widget_item_new(ELM_WIDGET_DATA(sd)->obj, Elm_Gen_Item);
5229 if (!it) return NULL;
5232 elm_genlist_item_class_ref((Elm_Genlist_Item_Class *)itc);
5234 it->base.data = data;
5235 it->parent = parent;
5236 it->func.func = func;
5237 it->func.data = func_data;
5239 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
5240 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
5241 elm_widget_item_disable_hook_set(it, _item_disable_hook);
5242 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
5243 elm_widget_item_signal_emit_hook_set(it, _item_signal_emit_hook);
5245 #if 0 // FIXME: difference from upstream
5246 it->can_focus = EINA_TRUE;
5248 //it->del_cb = (Ecore_Cb)_item_free;
5249 //it->highlight_cb = (Ecore_Cb)_item_highlight;
5250 //it->unhighlight_cb = (Ecore_Cb)_item_unhighlight;
5251 //it->sel_cb = (Ecore_Cb)_item_select;
5252 //it->unsel_cb = (Ecore_Cb)_item_unselect;
5253 //it->unrealize_cb = (Ecore_Cb)_item_unrealize_cb;
5255 GL_IT(it) = ELM_NEW(Elm_Gen_Item_Type);
5256 GL_IT(it)->wsd = sd;
5257 GL_IT(it)->type = type;
5258 if (type & ELM_GENLIST_ITEM_GROUP) it->group++;
5262 if (it->parent->group)
5263 GL_IT(it)->group_item = parent;
5264 else if (GL_IT(it->parent)->group_item)
5265 GL_IT(it)->group_item = GL_IT(it->parent)->group_item;
5267 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
5269 if (!it2->parent->group) depth += 1;
5271 GL_IT(it)->expanded_depth = depth;
5278 _elm_genlist_item_compare(const void *data,
5281 const Elm_Gen_Item *it, *item1;
5283 it = ELM_GEN_ITEM_FROM_INLIST(data);
5284 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
5285 return GL_IT(it)->wsd->item_compare_cb(it, item1);
5289 _elm_genlist_item_list_compare(const void *data,
5292 const Elm_Gen_Item *it = data;
5293 const Elm_Gen_Item *item1 = data1;
5295 return GL_IT(it)->wsd->item_compare_cb(it, item1);
5299 elm_genlist_items_count(const Evas_Object *obj)
5301 ELM_GENLIST_CHECK(obj) 0;
5302 ELM_GENLIST_DATA_GET(obj, sd);
5304 return sd->item_count;
5307 EAPI Elm_Object_Item *
5308 elm_genlist_item_append(Evas_Object *obj,
5309 const Elm_Genlist_Item_Class *itc,
5311 Elm_Object_Item *parent,
5312 Elm_Genlist_Item_Type type,
5314 const void *func_data)
5318 ELM_GENLIST_CHECK(obj) NULL;
5319 ELM_GENLIST_DATA_GET(obj, sd);
5321 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(((Elm_Widget_Item *)parent),NULL);
5323 it = _elm_genlist_item_new
5324 (sd, itc, data, (Elm_Gen_Item *)parent, type, func, func_data);
5325 if (!it) return NULL;
5330 sd->group_items = eina_list_append(sd->group_items, it);
5331 sd->items = eina_inlist_append(sd->items, EINA_INLIST_GET(it));
5332 it->item->rel = NULL;
5336 Elm_Gen_Item *it2 = NULL;
5337 Eina_List *ll = eina_list_last(it->parent->item->items);
5339 if (ll) it2 = ll->data;
5340 it->parent->item->items =
5341 eina_list_append(it->parent->item->items, it);
5342 if (!it2) it2 = it->parent;
5343 sd->items = eina_inlist_append_relative
5344 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(it2));
5345 it->item->rel = it2;
5346 it2->item->rel_revs = eina_list_append(it2->item->rel_revs, it);
5348 it->item->before = EINA_FALSE;
5349 _item_queue(sd, it, NULL);
5351 return (Elm_Object_Item *)it;
5354 EAPI Elm_Object_Item *
5355 elm_genlist_item_prepend(Evas_Object *obj,
5356 const Elm_Genlist_Item_Class *itc,
5358 Elm_Object_Item *parent,
5359 Elm_Genlist_Item_Type type,
5361 const void *func_data)
5365 ELM_GENLIST_CHECK(obj) NULL;
5366 ELM_GENLIST_DATA_GET(obj, sd);
5367 it = _elm_genlist_item_new
5368 (sd, itc, data, (Elm_Gen_Item *)parent, type, func, func_data);
5369 if (!it) return NULL;
5374 sd->group_items = eina_list_prepend(sd->group_items, it);
5375 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(it));
5376 it->item->rel = NULL;
5380 Elm_Gen_Item *it2 = NULL;
5381 Eina_List *ll = it->parent->item->items;
5383 if (ll) it2 = ll->data;
5384 it->parent->item->items =
5385 eina_list_prepend(it->parent->item->items, it);
5386 if (!it2) it2 = it->parent;
5387 sd->items = eina_inlist_prepend_relative
5388 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(it2));
5389 it->item->rel = it2;
5390 it2->item->rel_revs = eina_list_append(it2->item->rel_revs, it);
5392 it->item->before = EINA_TRUE;
5393 _item_queue(sd, it, NULL);
5395 return (Elm_Object_Item *)it;
5398 EAPI Elm_Object_Item *
5399 elm_genlist_item_insert_after(Evas_Object *obj,
5400 const Elm_Genlist_Item_Class *itc,
5402 Elm_Object_Item *parent,
5403 Elm_Object_Item *after_it,
5404 Elm_Genlist_Item_Type type,
5406 const void *func_data)
5408 Elm_Gen_Item *after = (Elm_Gen_Item *)after_it;
5411 ELM_GENLIST_CHECK(obj) NULL;
5412 ELM_GENLIST_ITEM_CHECK_OR_RETURN(after_it, NULL);
5413 ELM_GENLIST_DATA_GET(obj, sd);
5415 /* It makes no sense to insert after in an empty list with after !=
5416 * NULL, something really bad is happening in your app. */
5417 EINA_SAFETY_ON_NULL_RETURN_VAL(sd->items, NULL);
5419 it = _elm_genlist_item_new
5420 (sd, itc, data, (Elm_Gen_Item *)parent, type, func, func_data);
5421 if (!it) return NULL;
5425 if ((it->group) && (after->group))
5426 sd->group_items = eina_list_append_relative
5427 (sd->group_items, it, after);
5431 it->parent->item->items =
5432 eina_list_append_relative(it->parent->item->items, it, after);
5434 sd->items = eina_inlist_append_relative
5435 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5437 it->item->rel = after;
5438 after->item->rel_revs = eina_list_append(after->item->rel_revs, it);
5439 it->item->before = EINA_FALSE;
5440 _item_queue(sd, it, NULL);
5442 return (Elm_Object_Item *)it;
5445 EAPI Elm_Object_Item *
5446 elm_genlist_item_insert_before(Evas_Object *obj,
5447 const Elm_Genlist_Item_Class *itc,
5449 Elm_Object_Item *parent,
5450 Elm_Object_Item *before_it,
5451 Elm_Genlist_Item_Type type,
5453 const void *func_data)
5455 Elm_Gen_Item *before = (Elm_Gen_Item *)before_it;
5458 ELM_GENLIST_CHECK(obj) NULL;
5459 ELM_GENLIST_ITEM_CHECK_OR_RETURN(before_it, NULL);
5460 ELM_GENLIST_DATA_GET(obj, sd);
5462 /* It makes no sense to insert before in an empty list with before
5463 * != NULL, something really bad is happening in your app. */
5464 EINA_SAFETY_ON_NULL_RETURN_VAL(sd->items, NULL);
5466 it = _elm_genlist_item_new
5467 (sd, itc, data, (Elm_Gen_Item *)parent, type, func, func_data);
5468 if (!it) return NULL;
5472 if (it->group && before->group)
5474 eina_list_prepend_relative(sd->group_items, it, before);
5478 it->parent->item->items =
5479 eina_list_prepend_relative(it->parent->item->items, it, before);
5481 sd->items = eina_inlist_prepend_relative
5482 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5484 it->item->rel = before;
5485 before->item->rel_revs = eina_list_append(before->item->rel_revs, it);
5486 it->item->before = EINA_TRUE;
5487 _item_queue(sd, it, NULL);
5489 return (Elm_Object_Item *)it;
5492 EAPI Elm_Object_Item *
5493 elm_genlist_item_sorted_insert(Evas_Object *obj,
5494 const Elm_Genlist_Item_Class *itc,
5496 Elm_Object_Item *parent,
5497 Elm_Genlist_Item_Type type,
5498 Eina_Compare_Cb comp,
5500 const void *func_data)
5502 Elm_Gen_Item *rel = NULL;
5505 ELM_GENLIST_CHECK(obj) NULL;
5506 ELM_GENLIST_DATA_GET(obj, sd);
5508 it = _elm_genlist_item_new
5509 (sd, itc, data, (Elm_Gen_Item *)parent, type, func, func_data);
5510 if (!it) return NULL;
5512 sd->item_compare_cb = comp;
5519 l = eina_list_search_sorted_near_list
5520 (it->parent->item->items, _elm_genlist_item_list_compare, it,
5524 rel = eina_list_data_get(l);
5528 if (cmp_result >= 0)
5530 it->parent->item->items = eina_list_prepend_relative_list
5531 (it->parent->item->items, it, l);
5532 sd->items = eina_inlist_prepend_relative
5533 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
5534 it->item->before = EINA_FALSE;
5536 else if (cmp_result < 0)
5538 it->parent->item->items = eina_list_append_relative_list
5539 (it->parent->item->items, it, l);
5540 sd->items = eina_inlist_append_relative
5541 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
5542 it->item->before = EINA_TRUE;
5549 sd->state = eina_inlist_sorted_state_new();
5550 eina_inlist_sorted_state_init(sd->state, sd->items);
5551 sd->requeued = EINA_FALSE;
5555 sd->group_items = eina_list_append(sd->group_items, it);
5557 sd->items = eina_inlist_sorted_state_insert
5558 (sd->items, EINA_INLIST_GET(it), _elm_genlist_item_compare,
5561 if (EINA_INLIST_GET(it)->next)
5563 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
5564 it->item->before = EINA_TRUE;
5566 else if (EINA_INLIST_GET(it)->prev)
5568 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
5569 it->item->before = EINA_FALSE;
5575 it->item->rel = rel;
5576 rel->item->rel_revs = eina_list_append(rel->item->rel_revs, it);
5579 _item_queue(sd, it, _elm_genlist_item_list_compare);
5581 return (Elm_Object_Item *)it;
5585 elm_genlist_clear(Evas_Object *obj)
5587 ELM_GENLIST_CHECK(obj);
5588 ELM_GENLIST_DATA_GET(obj, sd);
5592 eina_inlist_sorted_state_free(sd->state);
5596 //evas_event_freeze(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
5598 // Do not use EINA_INLIST_FOREACH or EINA_INLIST_FOREACH_SAFE
5599 // because sd->items can be modified inside elm_widget_item_del()
5603 EINA_INLIST_CONTAINER_GET(sd->items->last, Elm_Gen_Item);
5604 elm_widget_item_del(it);
5608 _item_cache_all_free(sd);
5610 sd->pan_changed = EINA_TRUE;
5611 if (sd->selected) sd->selected = eina_list_free(sd->selected);
5612 sd->selected = NULL;
5614 sd->anchor_item = NULL;
5615 if (sd->tree_effect_animator)
5617 ecore_animator_del(sd->tree_effect_animator);
5618 sd->tree_effect_animator = NULL;
5620 if (sd->multi_timer)
5622 ecore_timer_del(sd->multi_timer);
5623 sd->multi_timer = NULL;
5627 ecore_job_del(sd->update_job);
5628 sd->update_job = NULL;
5632 ecore_job_del(sd->calc_job);
5633 sd->calc_job = NULL;
5635 if (sd->queue_idle_enterer)
5637 ecore_idle_enterer_del(sd->queue_idle_enterer);
5638 sd->queue_idle_enterer = NULL;
5640 if (sd->must_recalc_idler)
5642 ecore_idler_del(sd->must_recalc_idler);
5643 sd->must_recalc_idler = NULL;
5645 if (sd->queue) sd->queue = eina_list_free(sd->queue);
5646 if (sd->reorder_move_animator)
5648 ecore_animator_del(sd->reorder_move_animator);
5649 sd->reorder_move_animator = NULL;
5651 sd->show_item = NULL;
5652 sd->reorder_old_pan_y = 0;
5659 if (sd->alpha_bg) evas_object_del(sd->alpha_bg);
5660 sd->alpha_bg = NULL;
5664 evas_object_size_hint_min_set(sd->pan_obj, sd->minw, sd->minh);
5665 evas_object_smart_callback_call(sd->pan_obj, "changed", NULL);
5667 elm_layout_sizing_eval(ELM_WIDGET_DATA(sd)->obj);
5668 sd->s_iface->content_region_show(obj, 0, 0, 0, 0);
5669 //evas_event_thaw(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
5670 //evas_event_thaw_eval(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
5674 elm_genlist_multi_select_set(Evas_Object *obj,
5677 ELM_GENLIST_CHECK(obj);
5678 ELM_GENLIST_DATA_GET(obj, sd);
5680 sd->multi = !!multi;
5684 elm_genlist_multi_select_get(const Evas_Object *obj)
5686 ELM_GENLIST_CHECK(obj) EINA_FALSE;
5687 ELM_GENLIST_DATA_GET(obj, sd);
5692 EAPI Elm_Object_Item *
5693 elm_genlist_selected_item_get(const Evas_Object *obj)
5695 ELM_GENLIST_CHECK(obj) NULL;
5696 ELM_GENLIST_DATA_GET(obj, sd);
5699 return sd->selected->data;
5705 elm_genlist_selected_items_get(const Evas_Object *obj)
5707 ELM_GENLIST_CHECK(obj) NULL;
5708 ELM_GENLIST_DATA_GET(obj, sd);
5710 return sd->selected;
5714 elm_genlist_realized_items_get(const Evas_Object *obj)
5717 Eina_List *list = NULL;
5718 Eina_Bool done = EINA_FALSE;
5720 ELM_GENLIST_CHECK(obj) NULL;
5721 ELM_GENLIST_DATA_GET(obj, sd);
5723 EINA_INLIST_FOREACH(sd->blocks, itb)
5731 EINA_LIST_FOREACH(itb->items, l, it)
5733 if (it->realized) list = eina_list_append(list, it);
5744 EAPI Elm_Object_Item *
5745 elm_genlist_at_xy_item_get(const Evas_Object *obj,
5750 Evas_Coord ox, oy, ow, oh;
5754 ELM_GENLIST_CHECK(obj) NULL;
5755 ELM_GENLIST_DATA_GET(obj, sd);
5757 evas_object_geometry_get(sd->pan_obj, &ox, &oy, &ow, &oh);
5759 EINA_INLIST_FOREACH(sd->blocks, itb)
5764 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->sd->pan_x,
5765 oy + itb->y - itb->sd->pan_y,
5766 itb->w, itb->h, x, y, 1, 1))
5768 EINA_LIST_FOREACH(itb->items, l, it)
5770 Evas_Coord itx, ity;
5772 itx = ox + itb->x + it->x - itb->sd->pan_x;
5773 ity = oy + itb->y + it->y - itb->sd->pan_y;
5774 if (ELM_RECTS_INTERSECT
5775 (itx, ity, it->item->w, it->item->h, x, y, 1, 1))
5779 if (y <= (ity + (it->item->h / 4))) *posret = -1;
5780 else if (y >= (ity + it->item->h - (it->item->h / 4)))
5785 return (Elm_Object_Item *)it;
5787 lasty = ity + it->item->h;
5792 if (y > lasty) *posret = 1;
5799 EAPI Elm_Object_Item *
5800 elm_genlist_first_item_get(const Evas_Object *obj)
5802 Elm_Gen_Item *tit, *it = NULL;
5804 ELM_GENLIST_CHECK(obj) NULL;
5805 ELM_GENLIST_DATA_GET(obj, sd);
5807 EINA_INLIST_REVERSE_FOREACH(sd->items, tit) it = tit;
5809 return (Elm_Object_Item *)it;
5812 EAPI Elm_Object_Item *
5813 elm_genlist_last_item_get(const Evas_Object *obj)
5817 ELM_GENLIST_CHECK(obj) NULL;
5818 ELM_GENLIST_DATA_GET(obj, sd);
5819 if (!sd->items) return NULL;
5821 it = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
5822 return (Elm_Object_Item *)it;
5825 EAPI Elm_Object_Item *
5826 elm_genlist_item_next_get(const Elm_Object_Item *item)
5830 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item, NULL);
5832 it = (Elm_Gen_Item *)item;
5835 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
5839 return (Elm_Object_Item *)it;
5842 EAPI Elm_Object_Item *
5843 elm_genlist_item_prev_get(const Elm_Object_Item *item)
5847 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item, NULL);
5849 it = (Elm_Gen_Item *)item;
5852 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
5856 return (Elm_Object_Item *)it;
5859 EAPI Elm_Object_Item *
5860 elm_genlist_item_parent_get(const Elm_Object_Item *it)
5862 ELM_GENLIST_ITEM_CHECK_OR_RETURN(it, NULL);
5864 return (Elm_Object_Item *)((Elm_Gen_Item *)it)->parent;
5868 elm_genlist_item_subitems_clear(Elm_Object_Item *item)
5870 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
5872 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
5873 _item_subitems_clear(it);
5877 elm_genlist_item_selected_set(Elm_Object_Item *item,
5880 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
5881 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
5883 if (elm_widget_item_disabled_get(it)) return;
5884 selected = !!selected;
5885 if (it->selected == selected) return;
5887 _item_select_unselect(it, selected);
5891 elm_genlist_item_selected_get(const Elm_Object_Item *it)
5893 ELM_GENLIST_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
5895 return ((Elm_Gen_Item *)it)->selected;
5898 static Elm_Gen_Item *
5899 _elm_genlist_expanded_next_item_get(Elm_Gen_Item *it)
5903 if (it->item->expanded)
5905 it2 = (Elm_Gen_Item *)elm_genlist_item_next_get((Elm_Object_Item *)it);
5909 it2 = (Elm_Gen_Item *)elm_genlist_item_next_get((Elm_Object_Item *)it);
5912 if (it->item->expanded_depth >= it2->item->expanded_depth) break;
5913 it2 = (Elm_Gen_Item *)
5914 elm_genlist_item_next_get((Elm_Object_Item *)it2);
5921 _elm_genlist_move_items_set(Elm_Gen_Item *it)
5924 Elm_Gen_Item *it2 = NULL;
5925 Evas_Coord ox, oy, ow, oh, dh = 0;
5927 GL_IT(it)->wsd->expanded_next_item =
5928 _elm_genlist_expanded_next_item_get(it);
5930 if (it->item->expanded)
5932 GL_IT(it)->wsd->move_items = elm_genlist_realized_items_get
5933 (ELM_WIDGET_DATA(GL_IT(it)->wsd)->obj);
5935 EINA_LIST_FOREACH_SAFE(GL_IT(it)->wsd->move_items, l, ll, it2)
5937 if (it2 == GL_IT(it)->wsd->expanded_next_item) break;
5938 GL_IT(it)->wsd->move_items =
5939 eina_list_remove(GL_IT(it)->wsd->move_items, it2);
5944 evas_object_geometry_get(GL_IT(it)->wsd->pan_obj, &ox, &oy, &ow, &oh);
5945 it2 = GL_IT(it)->wsd->expanded_next_item;
5947 while (it2 && (dh < oy + oh))
5950 GL_IT(it)->wsd->move_items =
5951 eina_list_append(GL_IT(it)->wsd->move_items, it2);
5952 it2 = (Elm_Gen_Item *)
5953 elm_genlist_item_next_get((Elm_Object_Item *)it2);
5958 static Evas_Object *
5959 _tray_alpha_bg_create(const Evas_Object *obj)
5961 Evas_Object *bg = NULL;
5962 Evas_Coord ox, oy, ow, oh;
5964 ELM_GENLIST_CHECK(obj) NULL;
5965 ELM_GENLIST_DATA_GET(obj, sd);
5967 evas_object_geometry_get(sd->pan_obj, &ox, &oy, &ow, &oh);
5968 bg = evas_object_rectangle_add
5969 (evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
5970 evas_object_color_set(bg, 0, 0, 0, 0);
5971 evas_object_resize(bg, ow, oh);
5972 evas_object_move(bg, ox, oy);
5978 elm_genlist_item_expanded_set(Elm_Object_Item *item,
5981 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
5983 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
5985 expanded = !!expanded;
5986 if (it->item->expanded == expanded) return;
5987 if (it->item->type != ELM_GENLIST_ITEM_TREE) return;
5988 it->item->expanded = expanded;
5989 GL_IT(it)->wsd->expanded_item = it;
5990 _elm_genlist_move_items_set(it);
5992 if (GL_IT(it)->wsd->tree_effect_enabled && !GL_IT(it)->wsd->alpha_bg)
5993 GL_IT(it)->wsd->alpha_bg = _tray_alpha_bg_create(WIDGET(it));
5995 if (it->item->expanded)
5997 GL_IT(it)->wsd->move_effect_mode = ELM_GENLIST_TREE_EFFECT_EXPAND;
5999 edje_object_signal_emit(VIEW(it), "elm,state,expanded", "elm");
6000 evas_object_smart_callback_call(WIDGET(it), SIG_EXPANDED, it);
6001 GL_IT(it)->wsd->auto_scroll_enabled = EINA_TRUE;
6005 GL_IT(it)->wsd->move_effect_mode = ELM_GENLIST_TREE_EFFECT_CONTRACT;
6007 edje_object_signal_emit(VIEW(it), "elm,state,contracted", "elm");
6008 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACTED, it);
6009 GL_IT(it)->wsd->auto_scroll_enabled = EINA_FALSE;
6014 elm_genlist_item_expanded_get(const Elm_Object_Item *it)
6016 ELM_GENLIST_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
6018 return ((Elm_Gen_Item *)it)->item->expanded;
6022 elm_genlist_item_expanded_depth_get(const Elm_Object_Item *it)
6024 ELM_GENLIST_ITEM_CHECK_OR_RETURN(it, 0);
6026 return ((Elm_Gen_Item *)it)->item->expanded_depth;
6030 _elm_genlist_item_coordinates_calc(Elm_Object_Item *item,
6031 Elm_Genlist_Item_Scrollto_Type type,
6038 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6039 Evas_Coord gith = 0;
6041 if (!((GL_IT(it)->wsd->homogeneous) &&
6042 (GL_IT(it)->wsd->mode == ELM_LIST_COMPRESS)))
6044 if ((it->item->queued) || (!it->item->mincalcd))
6046 GL_IT(it)->wsd->show_item = it;
6047 GL_IT(it)->wsd->bring_in = bring_in;
6048 GL_IT(it)->wsd->scroll_to_type = type;
6049 it->item->show_me = EINA_TRUE;
6053 if (GL_IT(it)->wsd->show_item)
6055 GL_IT(it)->wsd->show_item->item->show_me = EINA_FALSE;
6056 GL_IT(it)->wsd->show_item = NULL;
6059 evas_object_geometry_get(GL_IT(it)->wsd->pan_obj, NULL, NULL, w, h);
6062 case ELM_GENLIST_ITEM_SCROLLTO_IN:
6063 if ((it->item->group_item) &&
6064 (GL_IT(it)->wsd->pan_y > (it->y + it->item->block->y)))
6065 gith = it->item->group_item->item->h;
6067 *y = it->y + it->item->block->y - gith;
6070 case ELM_GENLIST_ITEM_SCROLLTO_TOP:
6071 if (it->item->group_item) gith = it->item->group_item->item->h;
6072 *y = it->y + it->item->block->y - gith;
6075 case ELM_GENLIST_ITEM_SCROLLTO_MIDDLE:
6076 *y = it->y + it->item->block->y - (*h / 2) + (it->item->h / 2);
6083 *x = it->x + it->item->block->x;
6084 *w = it->item->block->w;
6090 elm_genlist_item_promote(Elm_Object_Item *item)
6092 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6093 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6095 (it, (Elm_Gen_Item *)elm_genlist_first_item_get(WIDGET(it)));
6099 elm_genlist_item_demote(Elm_Object_Item *item)
6101 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6102 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6103 _item_move_after(it, (Elm_Gen_Item *)elm_genlist_last_item_get(WIDGET(it)));
6107 elm_genlist_item_show(Elm_Object_Item *item,
6108 Elm_Genlist_Item_Scrollto_Type type)
6110 Evas_Coord x, y, w, h;
6111 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6112 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6114 if (_elm_genlist_item_coordinates_calc
6115 (item, type, EINA_FALSE, &x, &y, &w, &h))
6116 GL_IT(it)->wsd->s_iface->content_region_show(WIDGET(item), x, y, w, h);
6120 elm_genlist_item_bring_in(Elm_Object_Item *item,
6121 Elm_Genlist_Item_Scrollto_Type type)
6123 Evas_Coord x, y, w, h;
6124 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6125 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6127 if (_elm_genlist_item_coordinates_calc
6128 (item, type, EINA_TRUE, &x, &y, &w, &h))
6129 GL_IT(it)->wsd->s_iface->region_bring_in(WIDGET(item), x, y, w, h);
6133 elm_genlist_item_all_contents_unset(Elm_Object_Item *item,
6136 Evas_Object *content;
6138 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6139 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6141 EINA_LIST_FREE (it->content_objs, content)
6143 evas_object_smart_member_del(content);
6144 evas_object_hide(content);
6145 if (l) *l = eina_list_append(*l, content);
6150 elm_genlist_item_update(Elm_Object_Item *item)
6152 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6153 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6155 if (!it->item->block) return;
6156 it->item->mincalcd = EINA_FALSE;
6157 it->item->updateme = EINA_TRUE;
6158 it->item->block->updateme = EINA_TRUE;
6159 #if GENLIST_ENTRY_SUPPORT
6160 it->item->unrealize_disabled = EINA_FALSE;
6162 if (GL_IT(it)->wsd->update_job) ecore_job_del(GL_IT(it)->wsd->update_job);
6163 GL_IT(it)->wsd->update_job = ecore_job_add(_update_job, GL_IT(it)->wsd);
6167 elm_genlist_item_fields_update(Elm_Object_Item *item,
6169 Elm_Genlist_Item_Field_Type itf)
6171 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6172 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6174 if (!it->item->block) return;
6176 #if GENLIST_ENTRY_SUPPORT
6177 it->item->unrealize_disabled = EINA_FALSE;
6179 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_TEXT))
6181 _item_text_realize(it, VIEW(it), &it->texts, parts);
6183 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_CONTENT))
6185 it->content_objs = _item_content_unrealize(it, VIEW(it),
6186 &it->contents, parts);
6187 it->content_objs = _item_content_realize(it, VIEW(it),
6188 &it->contents, parts);
6192 it->item->flip_content_objs =
6193 _item_mode_content_unrealize(it, VIEW(it),
6194 &it->item->flip_contents, parts,
6195 &it->item->flip_content_objs);
6196 it->item->flip_content_objs =
6197 _item_mode_content_realize(it, VIEW(it),
6198 &it->item->flip_contents, parts,
6199 &it->item->flip_content_objs);
6201 if (it->item->deco_it_view)
6203 it->item->deco_it_content_objs =
6204 _item_mode_content_unrealize(it, it->item->deco_it_view,
6205 &it->item->deco_it_contents, parts,
6206 &it->item->deco_it_content_objs);
6207 it->item->deco_it_content_objs =
6208 _item_mode_content_realize(it, it->item->deco_it_view,
6209 &it->item->deco_it_contents, parts,
6210 &it->item->deco_it_content_objs);
6212 if (GL_IT(it)->wsd->decorate_all_mode)
6214 it->item->deco_all_content_objs =
6215 _item_mode_content_unrealize
6216 (it, it->deco_all_view, &it->item->deco_all_contents, parts,
6217 &it->item->deco_all_content_objs);
6218 it->item->deco_all_content_objs =
6219 _item_mode_content_realize(it, it->deco_all_view,
6220 &it->item->deco_all_contents, parts,
6221 &it->item->deco_all_content_objs);
6225 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
6226 _item_state_realize(it, VIEW(it), &it->states, parts);
6230 elm_genlist_item_item_class_update(Elm_Object_Item *item,
6231 const Elm_Genlist_Item_Class *itc)
6233 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6234 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6236 if (!it->item->block) return;
6237 EINA_SAFETY_ON_NULL_RETURN(itc);
6239 it->item->nocache_once = EINA_TRUE;
6241 elm_widget_stringlist_free(it->texts);
6243 elm_widget_stringlist_free(it->contents);
6244 it->contents = NULL;
6245 elm_widget_stringlist_free(it->states);
6250 elm_widget_stringlist_free(it->item->flip_contents);
6251 it->item->flip_contents = NULL;
6253 if (it->item->deco_it_view)
6255 elm_widget_stringlist_free(it->item->deco_it_texts);
6256 it->item->deco_it_texts = NULL;
6257 elm_widget_stringlist_free(it->item->deco_it_contents);
6258 it->item->deco_it_contents = NULL;
6260 if (GL_IT(it)->wsd->decorate_all_mode)
6262 elm_widget_stringlist_free(it->item->deco_all_texts);
6263 it->item->deco_all_texts = NULL;
6264 elm_widget_stringlist_free(it->item->deco_all_contents);
6265 it->item->deco_all_contents = NULL;
6268 elm_genlist_item_update(item);
6271 EAPI const Elm_Genlist_Item_Class *
6272 elm_genlist_item_item_class_get(const Elm_Object_Item *item)
6274 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item, NULL);
6275 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6279 static Evas_Object *
6280 _elm_genlist_item_label_create(void *data,
6281 Evas_Object *obj __UNUSED__,
6282 Evas_Object *tooltip,
6283 void *it __UNUSED__)
6285 Evas_Object *label = elm_label_add(tooltip);
6290 elm_object_style_set(label, "tooltip");
6291 elm_object_text_set(label, data);
6297 _elm_genlist_item_label_del_cb(void *data,
6298 Evas_Object *obj __UNUSED__,
6299 void *event_info __UNUSED__)
6301 eina_stringshare_del(data);
6305 elm_genlist_item_tooltip_text_set(Elm_Object_Item *it,
6308 ELM_GENLIST_ITEM_CHECK_OR_RETURN(it);
6310 text = eina_stringshare_add(text);
6311 elm_genlist_item_tooltip_content_cb_set
6312 (it, _elm_genlist_item_label_create, text,
6313 _elm_genlist_item_label_del_cb);
6317 elm_genlist_item_tooltip_content_cb_set(Elm_Object_Item *item,
6318 Elm_Tooltip_Item_Content_Cb func,
6320 Evas_Smart_Cb del_cb)
6322 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6324 ELM_GENLIST_ITEM_CHECK_OR_GOTO(item, error);
6326 if ((it->tooltip.content_cb == func) && (it->tooltip.data == data))
6329 if (it->tooltip.del_cb)
6330 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
6332 it->tooltip.content_cb = func;
6333 it->tooltip.data = data;
6334 it->tooltip.del_cb = del_cb;
6338 elm_widget_item_tooltip_content_cb_set
6339 (it, it->tooltip.content_cb, it->tooltip.data, NULL);
6340 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
6341 elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
6347 if (del_cb) del_cb((void *)data, NULL, NULL);
6351 elm_genlist_item_tooltip_unset(Elm_Object_Item *item)
6353 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6355 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6357 if ((VIEW(it)) && (it->tooltip.content_cb))
6358 elm_widget_item_tooltip_unset(it);
6360 if (it->tooltip.del_cb)
6361 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
6362 it->tooltip.del_cb = NULL;
6363 it->tooltip.content_cb = NULL;
6364 it->tooltip.data = NULL;
6365 it->tooltip.free_size = EINA_FALSE;
6366 if (it->tooltip.style)
6367 elm_genlist_item_tooltip_style_set(item, NULL);
6371 elm_genlist_item_tooltip_style_set(Elm_Object_Item *item,
6374 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6376 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6378 eina_stringshare_replace(&it->tooltip.style, style);
6379 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
6383 elm_genlist_item_tooltip_style_get(const Elm_Object_Item *it)
6385 return elm_object_item_tooltip_style_get(it);
6389 elm_genlist_item_tooltip_window_mode_set(Elm_Object_Item *item,
6392 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6394 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
6396 it->tooltip.free_size = disable;
6397 if (VIEW(it)) return elm_widget_item_tooltip_window_mode_set(it, disable);
6403 elm_genlist_item_tooltip_window_mode_get(const Elm_Object_Item *it)
6405 return elm_object_tooltip_window_mode_get(VIEW(it));
6409 elm_genlist_item_cursor_set(Elm_Object_Item *item,
6412 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6414 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6415 eina_stringshare_replace(&it->mouse_cursor, cursor);
6416 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
6420 elm_genlist_item_cursor_get(const Elm_Object_Item *it)
6422 return elm_widget_item_cursor_get(it);
6426 elm_genlist_item_cursor_unset(Elm_Object_Item *item)
6428 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6430 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6432 if (!it->mouse_cursor) return;
6434 if (VIEW(it)) elm_widget_item_cursor_unset(it);
6436 eina_stringshare_del(it->mouse_cursor);
6437 it->mouse_cursor = NULL;
6441 elm_genlist_item_cursor_style_set(Elm_Object_Item *it,
6444 elm_widget_item_cursor_style_set(it, style);
6448 elm_genlist_item_cursor_style_get(const Elm_Object_Item *it)
6450 return elm_widget_item_cursor_style_get(it);
6454 elm_genlist_item_cursor_engine_only_set(Elm_Object_Item *it,
6455 Eina_Bool engine_only)
6457 elm_widget_item_cursor_engine_only_set(it, engine_only);
6461 elm_genlist_item_cursor_engine_only_get(const Elm_Object_Item *it)
6463 return elm_widget_item_cursor_engine_only_get(it);
6467 elm_genlist_item_index_get(const Elm_Object_Item *item)
6469 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6471 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item, -1);
6473 if (it->item->block)
6474 return it->position + (it->item->block->position *
6475 GL_IT(it)->wsd->max_items_per_block);
6480 elm_genlist_mode_set(Evas_Object *obj,
6483 ELM_GENLIST_CHECK(obj);
6484 ELM_GENLIST_DATA_GET(obj, sd);
6486 if (sd->mode == mode) return;
6488 elm_layout_sizing_eval(obj);
6492 elm_genlist_mode_get(const Evas_Object *obj)
6494 ELM_GENLIST_CHECK(obj) ELM_LIST_LAST;
6495 ELM_GENLIST_DATA_GET(obj, sd);
6501 elm_genlist_bounce_set(Evas_Object *obj,
6505 ELM_GENLIST_CHECK(obj);
6506 ELM_GENLIST_DATA_GET(obj, sd);
6508 sd->h_bounce = !!h_bounce;
6509 sd->v_bounce = !!v_bounce;
6510 sd->s_iface->bounce_allow_set(obj, sd->h_bounce, sd->v_bounce);
6514 elm_genlist_bounce_get(const Evas_Object *obj,
6515 Eina_Bool *h_bounce,
6516 Eina_Bool *v_bounce)
6518 ELM_GENLIST_CHECK(obj);
6519 ELM_GENLIST_DATA_GET(obj, sd);
6521 if (h_bounce) *h_bounce = sd->h_bounce;
6522 if (v_bounce) *v_bounce = sd->v_bounce;
6526 elm_genlist_homogeneous_set(Evas_Object *obj,
6527 Eina_Bool homogeneous)
6529 ELM_GENLIST_CHECK(obj);
6530 ELM_GENLIST_DATA_GET(obj, sd);
6532 sd->homogeneous = !!homogeneous;
6536 elm_genlist_homogeneous_get(const Evas_Object *obj)
6538 ELM_GENLIST_CHECK(obj) EINA_FALSE;
6539 ELM_GENLIST_DATA_GET(obj, sd);
6541 return sd->homogeneous;
6545 elm_genlist_block_count_set(Evas_Object *obj,
6548 ELM_GENLIST_CHECK(obj);
6549 ELM_GENLIST_DATA_GET(obj, sd);
6550 EINA_SAFETY_ON_TRUE_RETURN(count < 1);
6552 sd->max_items_per_block = count;
6553 sd->item_cache_max = sd->max_items_per_block * 2;
6554 _item_cache_all_free(sd);
6558 elm_genlist_block_count_get(const Evas_Object *obj)
6560 ELM_GENLIST_CHECK(obj) 0;
6561 ELM_GENLIST_DATA_GET(obj, sd);
6563 return sd->max_items_per_block;
6567 elm_genlist_longpress_timeout_set(Evas_Object *obj,
6570 ELM_GENLIST_CHECK(obj);
6571 ELM_GENLIST_DATA_GET(obj, sd);
6573 sd->longpress_timeout = timeout;
6577 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
6579 ELM_GENLIST_CHECK(obj) 0;
6580 ELM_GENLIST_DATA_GET(obj, sd);
6582 return sd->longpress_timeout;
6586 elm_genlist_scroller_policy_set(Evas_Object *obj,
6587 Elm_Scroller_Policy policy_h,
6588 Elm_Scroller_Policy policy_v)
6590 ELM_GENLIST_CHECK(obj);
6591 ELM_GENLIST_DATA_GET(obj, sd);
6593 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
6594 (policy_v >= ELM_SCROLLER_POLICY_LAST))
6597 sd->s_iface->policy_set(obj, policy_h, policy_v);
6601 elm_genlist_scroller_policy_get(const Evas_Object *obj,
6602 Elm_Scroller_Policy *policy_h,
6603 Elm_Scroller_Policy *policy_v)
6605 Elm_Scroller_Policy s_policy_h, s_policy_v;
6607 ELM_GENLIST_CHECK(obj);
6608 ELM_GENLIST_DATA_GET(obj, sd);
6610 sd->s_iface->policy_get(obj, &s_policy_h, &s_policy_v);
6611 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
6612 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
6616 elm_genlist_realized_items_update(Evas_Object *obj)
6618 Eina_List *list, *l;
6619 Elm_Object_Item *it;
6621 ELM_GENLIST_CHECK(obj);
6623 list = elm_genlist_realized_items_get(obj);
6624 EINA_LIST_FOREACH(list, l, it)
6625 elm_genlist_item_update(it);
6629 elm_genlist_item_decorate_mode_set(Elm_Object_Item *item,
6630 const char *decorate_it_type,
6631 Eina_Bool decorate_it_set)
6633 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6634 Elm_Genlist_Smart_Data *sd;
6636 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6637 sd = GL_IT(it)->wsd;
6639 if (elm_widget_item_disabled_get(it)) return;
6640 if (!decorate_it_type) return;
6641 if (sd->decorate_all_mode) return;
6643 if ((sd->mode_item == it) &&
6644 (!strcmp(decorate_it_type, sd->decorate_it_type)) &&
6647 if (!it->itc->decorate_item_style) return;
6648 it->decorate_it_set = decorate_it_set;
6651 if (((sd->decorate_it_type)
6652 && (strcmp(decorate_it_type, sd->decorate_it_type))) ||
6653 (decorate_it_set) || ((it == sd->mode_item) && (!decorate_it_set)))
6654 _decorate_item_unset(sd);
6656 eina_stringshare_replace(&sd->decorate_it_type, decorate_it_type);
6657 if (decorate_it_set) _decorate_item_set(it);
6661 elm_genlist_item_decorate_mode_get(const Elm_Object_Item *item)
6663 Elm_Gen_Item *i = (Elm_Gen_Item *)item;
6665 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item, NULL);
6666 return GL_IT(i)->wsd->decorate_it_type;
6669 EAPI Elm_Object_Item *
6670 elm_genlist_decorated_item_get(const Evas_Object *obj)
6672 ELM_GENLIST_CHECK(obj) NULL;
6673 ELM_GENLIST_DATA_GET(obj, sd);
6675 return (Elm_Object_Item *)sd->mode_item;
6679 elm_genlist_decorate_mode_get(const Evas_Object *obj)
6681 ELM_GENLIST_CHECK(obj) EINA_FALSE;
6682 ELM_GENLIST_DATA_GET(obj, sd);
6684 return sd->decorate_all_mode;
6688 elm_genlist_decorate_mode_set(Evas_Object *obj,
6689 Eina_Bool decorated)
6692 Eina_List *list, *l;
6694 ELM_GENLIST_CHECK(obj);
6695 ELM_GENLIST_DATA_GET(obj, sd);
6697 decorated = !!decorated;
6698 if (sd->decorate_all_mode == decorated) return;
6699 // decorate_all_mode should be set first
6700 // because content_get func. will be called after this
6701 // and user can check whether deocrate_all_mode is enabeld.
6702 sd->decorate_all_mode = decorated;
6704 if (sd->tree_effect_animator)
6706 ecore_animator_del(sd->tree_effect_animator);
6707 sd->tree_effect_animator = NULL;
6709 sd->move_effect_mode = ELM_GENLIST_TREE_EFFECT_NONE;
6711 list = elm_genlist_realized_items_get(obj);
6712 if (!sd->decorate_all_mode)
6714 EINA_LIST_FOREACH(list, l, it)
6716 if (it->item->type != ELM_GENLIST_ITEM_GROUP)
6717 _decorate_all_item_unrealize(it);
6719 _item_cache_all_free(sd);
6723 EINA_LIST_FOREACH(list, l, it)
6725 if (it->item->type != ELM_GENLIST_ITEM_GROUP)
6727 if (it->itc->decorate_all_item_style)
6728 _decorate_all_item_realize(it, EINA_TRUE);
6732 if (sd->calc_job) ecore_job_del(sd->calc_job);
6733 sd->calc_job = ecore_job_add(_calc_job, sd);
6737 elm_genlist_reorder_mode_set(Evas_Object *obj,
6738 Eina_Bool reorder_mode)
6740 #if 1 // FIXME: difference from upstream
6741 Eina_List *list, *l;
6744 ELM_GENLIST_CHECK(obj);
6745 ELM_GENLIST_DATA_GET(obj, sd);
6747 sd->reorder_mode = !!reorder_mode;
6748 #if 1 // FIXME: difference from upstream
6749 list = elm_genlist_realized_items_get(obj);
6750 EINA_LIST_FOREACH(list, l, it)
6752 if (it->item->type != ELM_GENLIST_ITEM_GROUP)
6755 if (it->deco_all_view) view = it->deco_all_view;
6756 else view = VIEW(it);
6758 if (sd->reorder_mode)
6759 edje_object_signal_emit
6760 (view, "elm,state,reorder,mode_set", "elm");
6762 edje_object_signal_emit
6763 (view, "elm,state,reorder,mode_unset", "elm");
6766 eina_list_free(list);
6771 elm_genlist_reorder_mode_get(const Evas_Object *obj)
6773 ELM_GENLIST_CHECK(obj) EINA_FALSE;
6774 ELM_GENLIST_DATA_GET(obj, sd);
6776 return sd->reorder_mode;
6779 EAPI Elm_Genlist_Item_Type
6780 elm_genlist_item_type_get(const Elm_Object_Item *item)
6782 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6784 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item, ELM_GENLIST_ITEM_MAX);
6786 return it->item->type;
6789 EAPI Elm_Genlist_Item_Class *
6790 elm_genlist_item_class_new(void)
6792 Elm_Genlist_Item_Class *itc = ELM_NEW(Elm_Genlist_Item_Class);
6793 EINA_SAFETY_ON_NULL_RETURN_VAL(itc, NULL);
6795 itc->version = CLASS_ALLOCATED;
6797 itc->delete_me = EINA_FALSE;
6803 elm_genlist_item_class_free(Elm_Genlist_Item_Class *itc)
6805 if (itc && (itc->version == CLASS_ALLOCATED))
6807 if (!itc->delete_me) itc->delete_me = EINA_TRUE;
6808 if (itc->refcount > 0) elm_genlist_item_class_unref(itc);
6818 elm_genlist_item_class_ref(Elm_Genlist_Item_Class *itc)
6820 if (itc && (itc->version == CLASS_ALLOCATED))
6823 if (itc->refcount == 0) itc->refcount--;
6828 elm_genlist_item_class_unref(Elm_Genlist_Item_Class *itc)
6830 if (itc && (itc->version == CLASS_ALLOCATED))
6832 if (itc->refcount > 0) itc->refcount--;
6833 if (itc->delete_me && (!itc->refcount))
6834 elm_genlist_item_class_free(itc);
6839 elm_genlist_item_flip_set(Elm_Object_Item *item,
6842 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6843 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6844 Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
6847 if (it->flipped == flip) return;
6849 it->item->unrealize_disabled = EINA_FALSE;
6853 _item_unrealize(it, EINA_FALSE);
6854 it->flipped = EINA_TRUE;
6855 it->item->nocache = EINA_TRUE;
6859 _item_unrealize(it, EINA_FALSE);
6860 it->flipped = EINA_FALSE;
6861 it->item->nocache = EINA_FALSE;
6863 if (sd->calc_job) ecore_job_del(sd->calc_job);
6864 sd->calc_job = ecore_job_add(_calc_job, sd);
6868 elm_genlist_item_flip_get(const Elm_Object_Item *item)
6870 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6872 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
6878 elm_genlist_select_mode_set(Evas_Object *obj,
6879 Elm_Object_Select_Mode mode)
6881 ELM_GENLIST_CHECK(obj);
6882 ELM_GENLIST_DATA_GET(obj, sd);
6884 if (mode >= ELM_OBJECT_SELECT_MODE_MAX || (sd->select_mode == mode))
6887 sd->select_mode = mode;
6888 if ((sd->select_mode == ELM_OBJECT_SELECT_MODE_NONE) ||
6889 (sd->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY ))
6893 EINA_LIST_FOREACH_SAFE(sd->selected, l, ll, it)
6898 EAPI Elm_Object_Select_Mode
6899 elm_genlist_select_mode_get(const Evas_Object *obj)
6901 ELM_GENLIST_CHECK(obj) ELM_OBJECT_SELECT_MODE_MAX;
6902 ELM_GENLIST_DATA_GET(obj, sd);
6904 return sd->select_mode;
6908 elm_genlist_highlight_mode_set(Evas_Object *obj,
6909 Eina_Bool highlight)
6911 ELM_GENLIST_CHECK(obj);
6912 ELM_GENLIST_DATA_GET(obj, sd);
6914 sd->highlight = !!highlight;
6918 elm_genlist_highlight_mode_get(const Evas_Object *obj)
6920 ELM_GENLIST_CHECK(obj) EINA_FALSE;
6921 ELM_GENLIST_DATA_GET(obj, sd);
6923 return sd->highlight;
6927 elm_genlist_item_select_mode_set(Elm_Object_Item *item,
6928 Elm_Object_Select_Mode mode)
6930 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6932 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item);
6934 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
6936 if (it->select_mode != mode)
6937 it->select_mode = mode;
6939 if ((it->select_mode == ELM_OBJECT_SELECT_MODE_NONE) ||
6940 (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY ))
6943 if (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
6945 it->item->mincalcd = EINA_FALSE;
6946 it->item->updateme = EINA_TRUE;
6947 if (it->item->block) it->item->block->updateme = EINA_TRUE;
6948 if (GL_IT(it)->wsd->update_job)
6949 ecore_job_del(GL_IT(it)->wsd->update_job);
6950 GL_IT(it)->wsd->update_job =
6951 ecore_job_add(_update_job, GL_IT(it)->wsd);
6953 // reset homogeneous item size
6954 if (GL_IT(it)->wsd->homogeneous)
6957 GL_IT(it)->wsd->group_item_width =
6958 GL_IT(it)->wsd->group_item_height = 0;
6960 GL_IT(it)->wsd->item_width = GL_IT(it)->wsd->item_height = 0;
6965 EAPI Elm_Object_Select_Mode
6966 elm_genlist_item_select_mode_get(const Elm_Object_Item *item)
6968 Elm_Gen_Item *it = (Elm_Gen_Item *)item;
6970 ELM_GENLIST_ITEM_CHECK_OR_RETURN(item, ELM_OBJECT_SELECT_MODE_MAX);
6972 if (!it) return ELM_OBJECT_SELECT_MODE_MAX;
6974 return it->select_mode;
6978 elm_genlist_tree_effect_enabled_set(Evas_Object *obj __UNUSED__,
6979 Eina_Bool enabled __UNUSED__)
6981 ELM_GENLIST_CHECK(obj);
6982 //ELM_GENLIST_DATA_GET(obj, sd);
6984 // FIXME: this is disabed temporarily because of tree animation bug
6985 //sd->tree_effect_enabled = !!enabled;
6989 elm_genlist_tree_effect_enabled_get(const Evas_Object *obj)
6991 ELM_GENLIST_CHECK(obj) EINA_FALSE;
6992 ELM_GENLIST_DATA_GET(obj, sd);
6994 return sd->tree_effect_enabled;
6997 EAPI Elm_Object_Item *
6998 elm_genlist_nth_item_get(const Evas_Object *obj, unsigned int nth)
7000 Elm_Gen_Item *it = NULL;
7004 ELM_GENLIST_CHECK(obj) NULL;
7005 ELM_GENLIST_DATA_GET(obj, sd);
7007 if (!sd->items) return NULL;
7009 a = eina_inlist_accessor_new(sd->items);
7010 if (!a) return NULL;
7011 if (eina_accessor_data_get(a, nth, &data))
7012 it = ELM_GEN_ITEM_FROM_INLIST(data);
7013 eina_accessor_free(a);
7014 return (Elm_Object_Item *)it;