3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
6 #include "els_scroller.h"
10 #define MAX_ITEMS_PER_BLOCK 32
11 #define REORDER_EFFECT_TIME 0.5
13 typedef struct _Item_Block Item_Block;
14 typedef struct _Pan Pan;
15 typedef struct _Item_Cache Item_Cache;
17 struct Elm_Gen_Item_Type
22 Evas_Coord w, h, minw, minh;
23 Elm_Gen_Item *group_item;
24 Elm_Genlist_Item_Flags flags;
25 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
26 Ecore_Timer *swipe_timer;
27 Evas_Coord scrl_x, scrl_y, old_scrl_y;
30 Evas_Object *mode_view;
36 Eina_Bool want_realize : 1;
37 Eina_Bool expanded : 1;
38 Eina_Bool mincalcd : 1;
41 Eina_Bool updateme : 1;
42 Eina_Bool nocache : 1;
43 Eina_Bool stacking_even : 1;
44 Eina_Bool nostacking : 1;
45 Eina_Bool move_effect_enabled : 1;
50 Eina_Inlist_Sorted_State *state;
51 Evas_Object *obj; /* the genlist object */
53 Eina_List *group_items; /* list of groups index items */
54 Eina_Inlist *items; /* inlist of all items */
55 Elm_Gen_Item *reorder_it; /* item currently being repositioned */
58 Eina_Bool reorder_mode : 1;
59 Eina_Bool on_hold : 1;
61 Eina_Bool no_select : 1;
62 Eina_Bool wasselected : 1;
63 Eina_Bool always_select : 1;
64 ////////////////////////////////////
65 Evas_Object *scr; /* a smart scroller object which is used internally in genlist */
66 Evas_Object *pan_smart; /* "elm_genlist_pan" evas smart object. this is an extern pan of smart scroller(scr). */
67 Eina_Inlist *blocks; /* inlist of all blocks. a block consists of a certain number of items. maximum number of items in a block is 'max_items_per_block'. */
68 Pan *pan; /* pan_smart object's smart data */
69 Evas_Coord pan_x, pan_y, reorder_old_pan_y, w, h, minw, minh, realminw, prev_viewport_w;
70 Ecore_Job *update_job;
71 Ecore_Idle_Enterer *queue_idle_enterer;
72 Ecore_Idler *must_recalc_idler;
74 Elm_Gen_Item *show_item, *anchor_item, *mode_item, *reorder_rel, *expanded_item;
75 Elm_Gen_Item *last_selected_item; /* the last selected it. */
76 Eina_Inlist *item_cache; /* an inlist of edje object it cache. */
78 Evas_Coord reorder_start_y; /* reorder it's initial y coordinate in the pan. */
80 Ecore_Timer *multi_timer, *scr_hold_timer;
81 Ecore_Animator *reorder_move_animator;
82 const char *mode_type;
83 const char *mode_item_style;
84 unsigned int start_time;
85 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
86 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
87 Eina_Bool mouse_down : 1;
88 Eina_Bool multi_down : 1;
89 Eina_Bool multi_timeout : 1;
90 Eina_Bool multitouched : 1;
91 Eina_Bool longpressed : 1;
92 Eina_Bool bring_in : 1;
93 Eina_Bool compress : 1;
94 Eina_Bool height_for_width : 1;
95 Eina_Bool homogeneous : 1;
96 Eina_Bool clear_me : 1;
98 Eina_Bool reorder_pan_move : 1;
99 Eina_Bool auto_scroll_enabled : 1;
100 Eina_Bool pan_resized : 1;
104 } history[SWIPE_MOVES];
106 int item_cache_count;
107 int item_cache_max; /* maximum number of cached items */
111 int group_item_width;
112 int group_item_height;
113 int max_items_per_block; /* maximum number of items per block */
114 double longpress_timeout; /* longpress timeout. this value comes from _elm_config by default. this can be changed by elm_genlist_longpress_timeout_set() */
125 Evas_Coord x, y, w, h, minw, minh;
126 Eina_Bool want_unrealize : 1;
127 Eina_Bool realized : 1;
128 Eina_Bool changed : 1;
129 Eina_Bool updateme : 1;
130 Eina_Bool showme : 1;
131 Eina_Bool must_recalc : 1;
138 Evas_Object *base_view, *spacer;
140 const char *item_style; // it->itc->item_style
141 Eina_Bool tree : 1; // it->group
142 Eina_Bool compress : 1; // it->wd->compress
144 Eina_Bool selected : 1; // it->selected
145 Eina_Bool disabled : 1; // it->disabled
146 Eina_Bool expanded : 1; // it->item->expanded
149 #define ELM_GENLIST_ITEM_FROM_INLIST(it) \
150 ((it) ? EINA_INLIST_CONTAINER_GET(it, Elm_Gen_Item) : NULL)
154 Evas_Object_Smart_Clipped_Data __clipped_data;
156 Ecore_Job *resize_job;
159 static const char *widtype = NULL;
160 static void _item_cache_zero(Widget_Data *wd);
161 static void _del_hook(Evas_Object *obj);
162 static void _mirrored_set(Evas_Object *obj,
164 static void _theme_hook(Evas_Object *obj);
165 static void _show_region_hook(void *data,
167 static void _sizing_eval(Evas_Object *obj);
168 static void _item_realize(Elm_Gen_Item *it,
171 static void _item_unrealize_cb(Elm_Gen_Item *it);
172 static void _item_block_unrealize(Item_Block *itb);
173 static void _calc_job(void *data);
174 static void _on_focus_hook(void *data,
176 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
177 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
178 static Eina_Bool _item_single_select_up(Widget_Data *wd);
179 static Eina_Bool _item_single_select_down(Widget_Data *wd);
180 static Eina_Bool _event_hook(Evas_Object *obj,
182 Evas_Callback_Type type,
184 static void _signal_emit_hook(Evas_Object *obj,
185 const char *emission,
187 static Eina_Bool _deselect_all_items(Widget_Data *wd);
188 static void _pan_calculate(Evas_Object *obj);
189 static void _pan_max_get(Evas_Object *obj,
192 static void _item_position(Elm_Gen_Item *it,
196 static void _mode_item_realize(Elm_Gen_Item *it);
197 static void _mode_item_unrealize(Elm_Gen_Item *it);
198 static void _item_mode_set(Elm_Gen_Item *it);
199 static void _item_mode_unset(Widget_Data *wd);
200 static void _group_items_recalc(void *data);
201 static void _item_move_after(Elm_Gen_Item *it,
202 Elm_Gen_Item *after);
203 static void _item_move_before(Elm_Gen_Item *it,
204 Elm_Gen_Item *before);
205 static void _item_auto_scroll(Widget_Data *wd);
207 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
209 static const char SIG_ACTIVATED[] = "activated";
210 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
211 static const char SIG_SELECTED[] = "selected";
212 static const char SIG_UNSELECTED[] = "unselected";
213 static const char SIG_EXPANDED[] = "expanded";
214 static const char SIG_CONTRACTED[] = "contracted";
215 static const char SIG_EXPAND_REQUEST[] = "expand,request";
216 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
217 static const char SIG_REALIZED[] = "realized";
218 static const char SIG_UNREALIZED[] = "unrealized";
219 static const char SIG_DRAG_START_UP[] = "drag,start,up";
220 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
221 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
222 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
223 static const char SIG_DRAG_STOP[] = "drag,stop";
224 static const char SIG_DRAG[] = "drag";
225 static const char SIG_LONGPRESSED[] = "longpressed";
226 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
227 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
228 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
229 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
230 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top"; // TODO : remove this
231 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom"; // TODO : remove this
232 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left"; // TODO : remove this
233 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right"; // TODO : remove this
234 static const char SIG_EDGE_TOP[] = "edge,top";
235 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
236 static const char SIG_EDGE_LEFT[] = "edge,left";
237 static const char SIG_EDGE_RIGHT[] = "edge,right";
238 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
239 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
240 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
241 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
242 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
243 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
244 static const char SIG_SWIPE[] = "swipe";
245 static const char SIG_MOVED[] = "moved";
247 static const Evas_Smart_Cb_Description _signals[] = {
248 {SIG_CLICKED_DOUBLE, ""},
251 {SIG_UNSELECTED, ""},
253 {SIG_CONTRACTED, ""},
254 {SIG_EXPAND_REQUEST, ""},
255 {SIG_CONTRACT_REQUEST, ""},
257 {SIG_UNREALIZED, ""},
258 {SIG_DRAG_START_UP, ""},
259 {SIG_DRAG_START_DOWN, ""},
260 {SIG_DRAG_START_LEFT, ""},
261 {SIG_DRAG_START_RIGHT, ""},
264 {SIG_LONGPRESSED, ""},
265 {SIG_SCROLL_ANIM_START, ""},
266 {SIG_SCROLL_ANIM_STOP, ""},
267 {SIG_SCROLL_DRAG_START, ""},
268 {SIG_SCROLL_DRAG_STOP, ""},
269 {SIG_SCROLL_EDGE_TOP, ""},
270 {SIG_SCROLL_EDGE_BOTTOM, ""},
271 {SIG_SCROLL_EDGE_LEFT, ""},
272 {SIG_SCROLL_EDGE_RIGHT, ""},
274 {SIG_EDGE_BOTTOM, ""},
276 {SIG_EDGE_RIGHT, ""},
277 {SIG_MULTI_SWIPE_LEFT, ""},
278 {SIG_MULTI_SWIPE_RIGHT, ""},
279 {SIG_MULTI_SWIPE_UP, ""},
280 {SIG_MULTI_SWIPE_DOWN, ""},
281 {SIG_MULTI_PINCH_OUT, ""},
282 {SIG_MULTI_PINCH_IN, ""},
288 static Eina_Compare_Cb _elm_genlist_item_compare_cb;
289 static Eina_Compare_Cb _elm_genlist_item_compare_data_cb;
292 _event_hook(Evas_Object *obj,
293 Evas_Object *src __UNUSED__,
294 Evas_Callback_Type type,
297 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
298 Evas_Event_Key_Down *ev = event_info;
299 Widget_Data *wd = elm_widget_data_get(obj);
300 Evas_Coord pan_max_x = 0, pan_max_y = 0;
301 if (!wd) return EINA_FALSE;
302 if (!wd->items) return EINA_FALSE;
303 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
304 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
306 Elm_Gen_Item *it = NULL;
309 Evas_Coord step_x = 0;
310 Evas_Coord step_y = 0;
313 Evas_Coord page_x = 0;
314 Evas_Coord page_y = 0;
316 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
317 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
318 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
319 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
321 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
325 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
329 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
331 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
332 (_item_multi_select_up(wd)))
333 || (_item_single_select_up(wd)))
335 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
341 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
343 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
344 (_item_multi_select_down(wd)))
345 || (_item_single_select_down(wd)))
347 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
353 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
355 it = elm_genlist_first_item_get(obj);
356 elm_genlist_item_bring_in(it);
357 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
360 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
362 it = elm_genlist_last_item_get(obj);
363 elm_genlist_item_bring_in(it);
364 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
367 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
370 y -= -(page_y * v_h) / 100;
374 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
377 y += -(page_y * v_h) / 100;
381 else if (!strcmp(ev->keyname, "Escape"))
383 if (!_deselect_all_items(wd)) return EINA_FALSE;
384 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
387 else if (((!strcmp(ev->keyname, "Return")) ||
388 (!strcmp(ev->keyname, "KP_Enter")) ||
389 (!strcmp(ev->keyname, "space")))
390 && (!wd->multi) && (wd->selected))
392 it = elm_genlist_selected_item_get(obj);
393 elm_genlist_item_expanded_set(it,
394 !elm_genlist_item_expanded_get(it));
395 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
397 else return EINA_FALSE;
399 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
400 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
402 if (x > pan_max_x) x = pan_max_x;
404 if (y > pan_max_y) y = pan_max_y;
405 elm_smart_scroller_child_pos_set(wd->scr, x, y);
410 _deselect_all_items(Widget_Data *wd)
412 if (!wd->selected) return EINA_FALSE;
414 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
420 _item_multi_select_up(Widget_Data *wd)
422 if (!wd->selected) return EINA_FALSE;
423 if (!wd->multi) return EINA_FALSE;
425 Elm_Gen_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
426 if (!prev) return EINA_TRUE;
428 if (elm_genlist_item_selected_get(prev))
430 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
431 wd->last_selected_item = prev;
432 elm_genlist_item_show(wd->last_selected_item);
436 elm_genlist_item_selected_set(prev, EINA_TRUE);
437 elm_genlist_item_show(prev);
443 _item_multi_select_down(Widget_Data *wd)
445 if (!wd->selected) return EINA_FALSE;
446 if (!wd->multi) return EINA_FALSE;
448 Elm_Gen_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
449 if (!next) return EINA_TRUE;
451 if (elm_genlist_item_selected_get(next))
453 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
454 wd->last_selected_item = next;
455 elm_genlist_item_show(wd->last_selected_item);
459 elm_genlist_item_selected_set(next, EINA_TRUE);
460 elm_genlist_item_show(next);
466 _item_single_select_up(Widget_Data *wd)
471 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
472 while ((prev) && (prev->delete_me))
473 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
475 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
477 if (!prev) return EINA_FALSE;
479 _deselect_all_items(wd);
481 elm_genlist_item_selected_set(prev, EINA_TRUE);
482 elm_genlist_item_show(prev);
487 _item_single_select_down(Widget_Data *wd)
492 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
493 while ((next) && (next->delete_me))
494 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
496 else next = elm_genlist_item_next_get(wd->last_selected_item);
498 if (!next) return EINA_FALSE;
500 _deselect_all_items(wd);
502 elm_genlist_item_selected_set(next, EINA_TRUE);
503 elm_genlist_item_show(next);
508 _on_focus_hook(void *data __UNUSED__,
511 Widget_Data *wd = elm_widget_data_get(obj);
513 if (elm_widget_focus_get(obj))
515 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
516 evas_object_focus_set(wd->obj, EINA_TRUE);
517 if ((wd->selected) && (!wd->last_selected_item))
518 wd->last_selected_item = eina_list_data_get(wd->selected);
522 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
523 evas_object_focus_set(wd->obj, EINA_FALSE);
528 _del_hook(Evas_Object *obj)
530 Widget_Data *wd = elm_widget_data_get(obj);
532 _item_cache_zero(wd);
533 if (wd->calc_job) ecore_job_del(wd->calc_job);
534 if (wd->update_job) ecore_job_del(wd->update_job);
535 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
536 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
537 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
538 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
539 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
544 _del_pre_hook(Evas_Object *obj)
546 Widget_Data *wd = elm_widget_data_get(obj);
548 elm_genlist_clear(obj);
549 evas_object_del(wd->pan_smart);
550 wd->pan_smart = NULL;
554 _mirrored_set(Evas_Object *obj,
557 Widget_Data *wd = elm_widget_data_get(obj);
559 _item_cache_zero(wd);
560 elm_smart_scroller_mirrored_set(wd->scr, rtl);
564 _theme_hook(Evas_Object *obj)
566 Widget_Data *wd = elm_widget_data_get(obj);
569 evas_event_freeze(evas_object_evas_get(wd->obj));
570 _item_cache_zero(wd);
571 _elm_widget_mirrored_reload(obj);
572 _mirrored_set(obj, elm_widget_mirrored_get(obj));
573 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
574 elm_widget_style_get(obj));
575 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
576 wd->item_width = wd->item_height = 0;
577 wd->group_item_width = wd->group_item_height = 0;
578 wd->minw = wd->minh = wd->realminw = 0;
579 EINA_INLIST_FOREACH(wd->blocks, itb)
584 if (itb->realized) _item_block_unrealize(itb);
585 EINA_LIST_FOREACH(itb->items, l, it)
586 it->item->mincalcd = EINA_FALSE;
588 itb->changed = EINA_TRUE;
590 if (wd->calc_job) ecore_job_del(wd->calc_job);
591 wd->calc_job = ecore_job_add(_calc_job, wd);
593 evas_event_thaw(evas_object_evas_get(wd->obj));
594 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
598 _show_region_hook(void *data,
601 Widget_Data *wd = elm_widget_data_get(data);
602 Evas_Coord x, y, w, h;
604 elm_widget_show_region_get(obj, &x, &y, &w, &h);
605 //x & y are screen coordinates, Add with pan coordinates
608 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
612 _translate_hook(Evas_Object *obj)
614 evas_object_smart_callback_call(obj, "language,changed", NULL);
618 _sizing_eval(Evas_Object *obj)
620 Widget_Data *wd = elm_widget_data_get(obj);
621 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
623 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
624 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
626 if (wd->height_for_width)
630 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
631 if ((vw != 0) && (vw != wd->prev_viewport_w))
635 wd->prev_viewport_w = vw;
636 EINA_INLIST_FOREACH(wd->blocks, itb)
638 itb->must_recalc = EINA_TRUE;
640 if (wd->calc_job) ecore_job_del(wd->calc_job);
641 wd->calc_job = ecore_job_add(_calc_job, wd);
644 if (wd->mode == ELM_LIST_LIMIT)
646 Evas_Coord vmw, vmh, vw, vh;
650 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
651 if ((minw > 0) && (vw < minw)) vw = minw;
652 else if ((maxw > 0) && (vw > maxw))
654 edje_object_size_min_calc
655 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
662 edje_object_size_min_calc
663 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
667 evas_object_size_hint_min_set(obj, minw, minh);
668 evas_object_size_hint_max_set(obj, maxw, maxh);
672 _signal_emit_hook(Evas_Object *obj,
673 const char *emission,
676 Widget_Data *wd = elm_widget_data_get(obj);
677 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
682 _item_highlight(Elm_Gen_Item *it)
684 const char *selectraise;
685 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
686 (it->disabled) || (it->display_only) || (it->item->mode_view))
688 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
689 selectraise = edje_object_data_get(VIEW(it), "selectraise");
690 if ((selectraise) && (!strcmp(selectraise, "on")))
692 evas_object_raise(VIEW(it));
693 if ((it->item->group_item) && (it->item->group_item->realized))
694 evas_object_raise(it->item->VIEW(group_item));
696 it->highlighted = EINA_TRUE;
700 _item_unhighlight(Elm_Gen_Item *it)
702 const char *stacking, *selectraise;
703 if ((it->delete_me) || (!it->highlighted)) return;
704 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
705 stacking = edje_object_data_get(VIEW(it), "stacking");
706 selectraise = edje_object_data_get(VIEW(it), "selectraise");
707 if (!it->item->nostacking)
709 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even) evas_object_lower(VIEW(it));
710 else evas_object_raise(VIEW(it));
712 it->highlighted = EINA_FALSE;
716 _item_block_del(Elm_Gen_Item *it)
719 Item_Block *itb = it->item->block;
721 itb->items = eina_list_remove(itb->items, it);
723 itb->changed = EINA_TRUE;
724 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
725 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
728 il = EINA_INLIST_GET(itb);
729 Item_Block *itbn = (Item_Block *)(il->next);
731 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
733 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
735 if (itbn) itbn->changed = EINA_TRUE;
739 if (itb->count < itb->wd->max_items_per_block/2)
741 il = EINA_INLIST_GET(itb);
742 Item_Block *itbp = (Item_Block *)(il->prev);
743 Item_Block *itbn = (Item_Block *)(il->next);
744 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
748 EINA_LIST_FREE(itb->items, it2)
750 it2->item->block = itbp;
751 itbp->items = eina_list_append(itbp->items, it2);
753 itbp->changed = EINA_TRUE;
755 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
756 EINA_INLIST_GET(itb));
759 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
763 Eina_List *last = eina_list_last(itb->items);
764 Elm_Gen_Item *it2 = last->data;
766 it2->item->block = itbn;
767 itb->items = eina_list_remove_list(itb->items, last);
768 itbn->items = eina_list_prepend(itbn->items, it2);
770 itbn->changed = EINA_TRUE;
773 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
781 _item_del(Elm_Gen_Item *it)
783 Evas_Object *obj = WIDGET(it);
785 evas_event_freeze(evas_object_evas_get(obj));
786 elm_genlist_item_subitems_clear(it);
787 if (it->wd->show_item == it) it->wd->show_item = NULL;
788 if (it->realized) elm_gen_item_unrealize(it, EINA_FALSE, (Ecore_Cb)_item_unrealize_cb);
789 if (it->item->block) _item_block_del(it);
790 if (it->item->queued)
791 it->wd->queue = eina_list_remove(it->wd->queue, it);
792 if (it->wd->anchor_item == it)
794 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
795 if (!it->wd->anchor_item)
796 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
799 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
800 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
801 elm_gen_item_del_serious(it, (Ecore_Cb)_calc_job);
802 evas_event_thaw(evas_object_evas_get(obj));
803 evas_event_thaw_eval(evas_object_evas_get(obj));
807 _item_select(Elm_Gen_Item *it)
809 Evas_Object *parent = WIDGET(it);
811 if ((it->wd->no_select) || (it->delete_me) || (it->item->mode_view)) return;
814 if (it->wd->always_select) goto call;
817 it->selected = EINA_TRUE;
818 it->wd->selected = eina_list_append(it->wd->selected, it);
820 evas_object_ref(parent);
823 if (it->func.func) it->func.func((void *)it->func.data, parent, it);
825 evas_object_smart_callback_call(parent, SIG_SELECTED, it);
828 if ((it->wd->clear_me) && (!it->wd->walking))
830 elm_genlist_clear(parent);
835 if ((!it->walking) && (it->delete_me))
837 if (!it->relcount) _item_del(it);
841 it->wd->last_selected_item = it;
844 evas_object_unref(parent);
848 _item_unselect(Elm_Gen_Item *it)
850 if ((it->delete_me) || (!it->selected)) return;
851 it->selected = EINA_FALSE;
852 it->wd->selected = eina_list_remove(it->wd->selected, it);
853 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
857 _mouse_move(void *data,
858 Evas *evas __UNUSED__,
862 Elm_Gen_Item *it = data;
863 Evas_Event_Mouse_Move *ev = event_info;
864 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
865 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
867 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
869 if (!it->wd->on_hold)
871 it->wd->on_hold = EINA_TRUE;
872 if (!it->wd->wasselected)
874 _item_unhighlight(it);
879 if (it->wd->multitouched)
881 it->wd->cur_x = ev->cur.canvas.x;
882 it->wd->cur_y = ev->cur.canvas.y;
885 if ((it->dragging) && (it->down))
887 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
890 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
891 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
892 if (abs((it->wd->history[it->wd->movements].x -
893 it->wd->history[0].x)) > 40)
894 it->wd->swipe = EINA_TRUE;
900 ecore_timer_del(it->long_timer);
901 it->long_timer = NULL;
903 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
906 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
910 ecore_timer_del(it->long_timer);
911 it->long_timer = NULL;
913 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
915 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
916 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
918 if (!it->wd->reorder_start_y)
919 it->wd->reorder_start_y = it->item->block->y + it->y;
923 else if (it_scrl_y + it->wd->reorder_it->item->h > oy + oh)
924 y_pos = oy + oh - it->wd->reorder_it->item->h;
928 _item_position(it, VIEW(it), it->item->scrl_x, y_pos);
930 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
931 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
935 if (!it->display_only)
936 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
937 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
938 x = ev->cur.canvas.x - x;
939 y = ev->cur.canvas.y - y;
942 if (adx < 0) adx = -dx;
945 if (ady < 0) ady = -dy;
948 if ((adx > minw) || (ady > minh))
950 it->dragging = EINA_TRUE;
953 ecore_timer_del(it->long_timer);
954 it->long_timer = NULL;
956 if (!it->wd->wasselected)
958 _item_unhighlight(it);
964 evas_object_smart_callback_call(WIDGET(it),
965 SIG_DRAG_START_UP, it);
969 evas_object_smart_callback_call(WIDGET(it),
970 SIG_DRAG_START_LEFT, it);
972 evas_object_smart_callback_call(WIDGET(it),
973 SIG_DRAG_START_RIGHT, it);
979 evas_object_smart_callback_call(WIDGET(it),
980 SIG_DRAG_START_DOWN, it);
984 evas_object_smart_callback_call(WIDGET(it),
985 SIG_DRAG_START_LEFT, it);
987 evas_object_smart_callback_call(WIDGET(it),
988 SIG_DRAG_START_RIGHT, it);
995 _long_press(void *data)
997 Elm_Gen_Item *it = data, *it_tmp;
1000 it->long_timer = NULL;
1001 if ((it->disabled) || (it->dragging) || (it->display_only))
1002 return ECORE_CALLBACK_CANCEL;
1003 it->wd->longpressed = EINA_TRUE;
1004 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
1005 if ((it->wd->reorder_mode) && (it->item->flags != ELM_GENLIST_ITEM_GROUP))
1007 it->wd->reorder_it = it;
1008 it->wd->reorder_start_y = 0;
1010 evas_object_raise(VIEW(it));
1011 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1012 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1014 list = elm_genlist_realized_items_get(it->wd->obj);
1015 EINA_LIST_FOREACH(list, l, it_tmp)
1017 if (it != it_tmp) _item_unselect(it_tmp);
1019 if (elm_genlist_item_expanded_get(it))
1021 elm_genlist_item_expanded_set(it, EINA_FALSE);
1022 return ECORE_CALLBACK_RENEW;
1024 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
1026 return ECORE_CALLBACK_CANCEL;
1030 _swipe(Elm_Gen_Item *it)
1035 if ((it->display_only) || (it->disabled)) return;
1036 it->wd->swipe = EINA_FALSE;
1037 for (i = 0; i < it->wd->movements; i++)
1039 sum += it->wd->history[i].x;
1040 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1043 sum /= it->wd->movements;
1044 if (abs(sum - it->wd->history[0].x) <= 10) return;
1045 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
1049 _swipe_cancel(void *data)
1051 Elm_Gen_Item *it = data;
1053 if (!it) return ECORE_CALLBACK_CANCEL;
1054 it->wd->swipe = EINA_FALSE;
1055 it->wd->movements = 0;
1056 return ECORE_CALLBACK_RENEW;
1060 _multi_cancel(void *data)
1062 Widget_Data *wd = data;
1064 if (!wd) return ECORE_CALLBACK_CANCEL;
1065 wd->multi_timeout = EINA_TRUE;
1066 return ECORE_CALLBACK_RENEW;
1070 _multi_touch_gesture_eval(void *data)
1072 Elm_Gen_Item *it = data;
1074 it->wd->multitouched = EINA_FALSE;
1075 if (it->wd->multi_timer)
1077 ecore_timer_del(it->wd->multi_timer);
1078 it->wd->multi_timer = NULL;
1080 if (it->wd->multi_timeout)
1082 it->wd->multi_timeout = EINA_FALSE;
1086 Evas_Coord minw = 0, minh = 0;
1087 Evas_Coord off_x, off_y, off_mx, off_my;
1089 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1090 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1091 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1092 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1093 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1095 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1097 if ((off_x + off_mx) > (off_y + off_my))
1099 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1100 evas_object_smart_callback_call(WIDGET(it),
1101 SIG_MULTI_SWIPE_RIGHT, it);
1102 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1103 evas_object_smart_callback_call(WIDGET(it),
1104 SIG_MULTI_SWIPE_LEFT, it);
1105 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1106 evas_object_smart_callback_call(WIDGET(it),
1107 SIG_MULTI_PINCH_OUT, it);
1109 evas_object_smart_callback_call(WIDGET(it),
1110 SIG_MULTI_PINCH_IN, it);
1114 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1115 evas_object_smart_callback_call(WIDGET(it),
1116 SIG_MULTI_SWIPE_DOWN, it);
1117 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1118 evas_object_smart_callback_call(WIDGET(it),
1119 SIG_MULTI_SWIPE_UP, it);
1120 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1121 evas_object_smart_callback_call(WIDGET(it),
1122 SIG_MULTI_PINCH_OUT, it);
1124 evas_object_smart_callback_call(WIDGET(it),
1125 SIG_MULTI_PINCH_IN, it);
1128 it->wd->multi_timeout = EINA_FALSE;
1132 _multi_down(void *data,
1133 Evas *evas __UNUSED__,
1134 Evas_Object *obj __UNUSED__,
1137 Elm_Gen_Item *it = data;
1138 Evas_Event_Multi_Down *ev = event_info;
1140 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1141 it->wd->multi_device = ev->device;
1142 it->wd->multi_down = EINA_TRUE;
1143 it->wd->multitouched = EINA_TRUE;
1144 it->wd->prev_mx = ev->canvas.x;
1145 it->wd->prev_my = ev->canvas.y;
1146 if (!it->wd->wasselected)
1148 _item_unhighlight(it);
1151 it->wd->wasselected = EINA_FALSE;
1152 it->wd->longpressed = EINA_FALSE;
1155 ecore_timer_del(it->long_timer);
1156 it->long_timer = NULL;
1160 it->dragging = EINA_FALSE;
1161 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1163 if (it->item->swipe_timer)
1165 ecore_timer_del(it->item->swipe_timer);
1166 it->item->swipe_timer = NULL;
1168 if (it->wd->on_hold)
1170 it->wd->swipe = EINA_FALSE;
1171 it->wd->movements = 0;
1172 it->wd->on_hold = EINA_FALSE;
1177 _multi_up(void *data,
1178 Evas *evas __UNUSED__,
1179 Evas_Object *obj __UNUSED__,
1182 Elm_Gen_Item *it = data;
1183 Evas_Event_Multi_Up *ev = event_info;
1185 if (it->wd->multi_device != ev->device) return;
1186 it->wd->multi_device = 0;
1187 it->wd->multi_down = EINA_FALSE;
1188 if (it->wd->mouse_down) return;
1189 _multi_touch_gesture_eval(data);
1193 _multi_move(void *data,
1194 Evas *evas __UNUSED__,
1195 Evas_Object *obj __UNUSED__,
1198 Elm_Gen_Item *it = data;
1199 Evas_Event_Multi_Move *ev = event_info;
1201 if (it->wd->multi_device != ev->device) return;
1202 it->wd->cur_mx = ev->cur.canvas.x;
1203 it->wd->cur_my = ev->cur.canvas.y;
1207 _mouse_down(void *data,
1208 Evas *evas __UNUSED__,
1212 Elm_Gen_Item *it = data;
1213 Evas_Event_Mouse_Down *ev = event_info;
1216 if (ev->button != 1) return;
1217 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1219 it->wd->on_hold = EINA_TRUE;
1222 it->down = EINA_TRUE;
1223 it->dragging = EINA_FALSE;
1224 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1225 it->dx = ev->canvas.x - x;
1226 it->dy = ev->canvas.y - y;
1227 it->wd->mouse_down = EINA_TRUE;
1228 if (!it->wd->multitouched)
1230 it->wd->prev_x = ev->canvas.x;
1231 it->wd->prev_y = ev->canvas.y;
1232 it->wd->multi_timeout = EINA_FALSE;
1233 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1234 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1236 it->wd->longpressed = EINA_FALSE;
1237 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1238 else it->wd->on_hold = EINA_FALSE;
1239 if (it->wd->on_hold) return;
1240 it->wd->wasselected = it->selected;
1241 _item_highlight(it);
1242 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1243 if ((!it->disabled) && (!it->display_only))
1245 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1246 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
1248 if (it->long_timer) ecore_timer_del(it->long_timer);
1249 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
1250 it->item->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1252 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1255 it->long_timer = NULL;
1256 it->wd->swipe = EINA_FALSE;
1257 it->wd->movements = 0;
1261 _mouse_up(void *data,
1262 Evas *evas __UNUSED__,
1263 Evas_Object *obj __UNUSED__,
1266 Elm_Gen_Item *it = data;
1267 Evas_Event_Mouse_Up *ev = event_info;
1268 Eina_Bool dragged = EINA_FALSE;
1270 if (ev->button != 1) return;
1271 it->down = EINA_FALSE;
1272 it->wd->mouse_down = EINA_FALSE;
1273 if (it->wd->multitouched)
1275 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1276 if (it->wd->multi_down) return;
1277 _multi_touch_gesture_eval(data);
1280 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1281 else it->wd->on_hold = EINA_FALSE;
1284 ecore_timer_del(it->long_timer);
1285 it->long_timer = NULL;
1289 it->dragging = EINA_FALSE;
1290 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1293 if (it->item->swipe_timer)
1295 ecore_timer_del(it->item->swipe_timer);
1296 it->item->swipe_timer = NULL;
1298 if (it->wd->multi_timer)
1300 ecore_timer_del(it->wd->multi_timer);
1301 it->wd->multi_timer = NULL;
1302 it->wd->multi_timeout = EINA_FALSE;
1304 if (it->wd->on_hold)
1306 if (it->wd->swipe) _swipe(data);
1307 it->wd->longpressed = EINA_FALSE;
1308 it->wd->on_hold = EINA_FALSE;
1311 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1313 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1315 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1317 if (it_scrl_y <= it->wd->reorder_rel->item->scrl_y)
1318 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1320 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1324 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1325 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1327 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
1328 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1329 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1330 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1332 if (it->wd->longpressed)
1334 it->wd->longpressed = EINA_FALSE;
1335 if (!it->wd->wasselected)
1337 _item_unhighlight(it);
1340 it->wd->wasselected = EINA_FALSE;
1345 if (it->want_unrealize)
1347 elm_gen_item_unrealize(it, EINA_FALSE, (Ecore_Cb)_item_unrealize_cb);
1348 if (it->item->block->want_unrealize)
1349 _item_block_unrealize(it->item->block);
1352 if ((it->disabled) || (dragged) || (it->display_only)) return;
1353 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1358 _item_highlight(it);
1363 _item_unhighlight(it);
1371 Widget_Data *wd = it->wd;
1374 while (wd->selected)
1376 _item_unhighlight(wd->selected->data);
1377 _item_unselect(wd->selected->data);
1383 const Eina_List *l, *l_next;
1386 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1389 _item_unhighlight(it2);
1390 _item_unselect(it2);
1392 //_item_highlight(it);
1395 _item_highlight(it);
1401 _signal_expand_toggle(void *data,
1402 Evas_Object *obj __UNUSED__,
1403 const char *emission __UNUSED__,
1404 const char *source __UNUSED__)
1406 Elm_Gen_Item *it = data;
1408 if (it->item->expanded)
1409 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1411 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1415 _signal_expand(void *data,
1416 Evas_Object *obj __UNUSED__,
1417 const char *emission __UNUSED__,
1418 const char *source __UNUSED__)
1420 Elm_Gen_Item *it = data;
1422 if (!it->item->expanded)
1423 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1427 _signal_contract(void *data,
1428 Evas_Object *obj __UNUSED__,
1429 const char *emission __UNUSED__,
1430 const char *source __UNUSED__)
1432 Elm_Gen_Item *it = data;
1434 if (it->item->expanded)
1435 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1439 _scr_hold_timer_cb(void *data)
1441 if (!data) return ECORE_CALLBACK_CANCEL;
1442 Widget_Data *wd = data;
1443 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1444 wd->scr_hold_timer = NULL;
1445 return ECORE_CALLBACK_CANCEL;
1449 _mode_finished_signal_cb(void *data,
1451 const char *emission __UNUSED__,
1452 const char *source __UNUSED__)
1456 Elm_Gen_Item *it = data;
1457 if ((it->delete_me) || (!it->realized) || (!it->item->mode_view)) return;
1459 Evas *te = evas_object_evas_get(obj);
1461 evas_event_freeze(te);
1462 it->item->nocache = EINA_FALSE;
1463 _mode_item_unrealize(it);
1464 if (it->item->group_item)
1465 evas_object_raise(it->item->VIEW(group_item));
1466 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1467 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1468 evas_event_thaw(te);
1469 evas_event_thaw_eval(te);
1473 _item_cache_clean(Widget_Data *wd)
1475 evas_event_freeze(evas_object_evas_get(wd->obj));
1476 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1480 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1481 wd->item_cache = eina_inlist_remove(wd->item_cache,
1482 wd->item_cache->last);
1483 wd->item_cache_count--;
1484 if (itc->spacer) evas_object_del(itc->spacer);
1485 if (itc->base_view) evas_object_del(itc->base_view);
1486 if (itc->item_style) eina_stringshare_del(itc->item_style);
1489 evas_event_thaw(evas_object_evas_get(wd->obj));
1490 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1494 _item_cache_zero(Widget_Data *wd)
1496 int pmax = wd->item_cache_max;
1497 wd->item_cache_max = 0;
1498 _item_cache_clean(wd);
1499 wd->item_cache_max = pmax;
1503 _item_cache_add(Elm_Gen_Item *it)
1507 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1508 if (it->wd->item_cache_max <= 0)
1510 evas_object_del(VIEW(it));
1512 evas_object_del(it->spacer);
1514 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1515 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1519 it->wd->item_cache_count++;
1520 itc = calloc(1, sizeof(Item_Cache));
1521 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1522 EINA_INLIST_GET(itc));
1523 itc->spacer = it->spacer;
1525 itc->base_view = VIEW(it);
1527 evas_object_hide(itc->base_view);
1528 evas_object_move(itc->base_view, -9999, -9999);
1529 itc->item_style = eina_stringshare_add(it->itc->item_style);
1530 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1531 itc->compress = (it->wd->compress);
1532 itc->selected = it->selected;
1533 itc->disabled = it->disabled;
1534 itc->expanded = it->item->expanded;
1537 ecore_timer_del(it->long_timer);
1538 it->long_timer = NULL;
1540 if (it->item->swipe_timer)
1542 ecore_timer_del(it->item->swipe_timer);
1543 it->item->swipe_timer = NULL;
1545 // FIXME: other callbacks?
1546 edje_object_signal_callback_del_full(itc->base_view,
1547 "elm,action,expand,toggle",
1548 "elm", _signal_expand_toggle, it);
1549 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1551 _signal_expand, it);
1552 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1553 "elm", _signal_contract, it);
1554 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1556 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1558 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1560 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1562 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1564 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1566 _item_cache_clean(it->wd);
1567 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1568 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1572 _item_cache_find(Elm_Gen_Item *it)
1577 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1578 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1580 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1582 if ((itc->tree == tree) &&
1583 (itc->compress == it->wd->compress) &&
1584 (!strcmp(it->itc->item_style, itc->item_style)))
1586 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1587 EINA_INLIST_GET(itc));
1588 it->wd->item_cache_count--;
1596 _elm_genlist_item_odd_even_update(Elm_Gen_Item *it)
1598 if (!it->item->nostacking)
1600 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
1601 evas_object_lower(VIEW(it));
1603 evas_object_raise(VIEW(it));
1606 if (it->item->order_num_in & 0x1)
1607 edje_object_signal_emit(VIEW(it), "elm,state,odd", "elm");
1609 edje_object_signal_emit(VIEW(it), "elm,state,even", "elm");
1613 _elm_genlist_item_state_update(Elm_Gen_Item *it, Item_Cache *itc)
1617 if (it->selected != itc->selected)
1620 edje_object_signal_emit(VIEW(it),
1621 "elm,state,selected", "elm");
1623 if (it->disabled != itc->disabled)
1626 edje_object_signal_emit(VIEW(it),
1627 "elm,state,disabled", "elm");
1629 if (it->item->expanded != itc->expanded)
1631 if (it->item->expanded)
1632 edje_object_signal_emit(VIEW(it),
1633 "elm,state,expanded", "elm");
1639 edje_object_signal_emit(VIEW(it),
1640 "elm,state,selected", "elm");
1642 edje_object_signal_emit(VIEW(it),
1643 "elm,state,disabled", "elm");
1644 if (it->item->expanded)
1645 edje_object_signal_emit(VIEW(it),
1646 "elm,state,expanded", "elm");
1651 _item_cache_free(Item_Cache *itc)
1653 if (itc->spacer) evas_object_del(itc->spacer);
1654 if (itc->base_view) evas_object_del(itc->base_view);
1655 if (itc->item_style) eina_stringshare_del(itc->item_style);
1660 _item_del_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1662 Elm_Gen_Item *it = event_info;
1664 if (it->wd->last_selected_item == it)
1665 it->wd->last_selected_item = NULL;
1669 _item_label_realize(Elm_Gen_Item *it,
1670 Evas_Object *target,
1673 if (it->itc->func.label_get)
1678 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1679 EINA_LIST_FOREACH(*source, l, key)
1681 char *s = it->itc->func.label_get
1682 ((void *)it->base.data, WIDGET(it), key);
1686 edje_object_part_text_set(target, key, s);
1691 edje_object_part_text_set(target, key, "");
1698 _item_icon_realize(Elm_Gen_Item *it,
1699 Evas_Object *target,
1702 Eina_List *res = NULL;
1704 if (it->itc->func.icon_get)
1709 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1710 EINA_LIST_FOREACH(*source, l, key)
1712 Evas_Object *ic = it->itc->func.icon_get
1713 ((void *)it->base.data, WIDGET(it), key);
1717 res = eina_list_append(res, ic);
1718 edje_object_part_swallow(target, key, ic);
1719 evas_object_show(ic);
1720 elm_widget_sub_object_add(WIDGET(it), ic);
1722 elm_widget_disabled_set(ic, EINA_TRUE);
1731 _item_state_realize(Elm_Gen_Item *it,
1732 Evas_Object *target,
1735 if (it->itc->func.state_get)
1741 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1742 EINA_LIST_FOREACH(*source, l, key)
1744 Eina_Bool on = it->itc->func.state_get
1745 ((void *)it->base.data, WIDGET(it), key);
1749 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1750 edje_object_signal_emit(target, buf, "elm");
1754 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1755 edje_object_signal_emit(target, buf, "elm");
1762 _item_realize(Elm_Gen_Item *it,
1767 const char *treesize;
1769 int depth, tsize = 20;
1770 Item_Cache *itc = NULL;
1772 if (it->delete_me) return;
1773 //evas_event_freeze(evas_object_evas_get(it->wd->obj));
1776 if (it->item->order_num_in != in)
1778 it->item->order_num_in = in;
1779 _elm_genlist_item_odd_even_update(it);
1780 _elm_genlist_item_state_update(it, NULL);
1782 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1783 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1786 it->item->order_num_in = in;
1788 if (it->item->nocache)
1789 it->item->nocache = EINA_FALSE;
1791 itc = _item_cache_find(it);
1794 VIEW(it) = itc->base_view;
1795 itc->base_view = NULL;
1796 it->spacer = itc->spacer;
1801 const char *stacking_even;
1802 const char *stacking;
1804 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
1805 edje_object_scale_set(VIEW(it),
1806 elm_widget_scale_get(WIDGET(it)) *
1807 _elm_config->scale);
1808 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
1809 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
1811 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS)
1812 strncpy(buf, "tree", sizeof(buf));
1813 else strncpy(buf, "item", sizeof(buf));
1814 if (it->wd->compress)
1815 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1817 strncat(buf, "/", sizeof(buf) - strlen(buf));
1818 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1820 _elm_theme_object_set(WIDGET(it), VIEW(it), "genlist", buf,
1821 elm_widget_style_get(WIDGET(it)));
1823 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
1824 if (!stacking_even) stacking_even = "above";
1825 it->item->stacking_even = !!strcmp("above", stacking_even);
1827 stacking = edje_object_data_get(VIEW(it), "stacking");
1828 if (!stacking) stacking = "yes";
1829 it->item->nostacking = !!strcmp("yes", stacking);
1831 edje_object_mirrored_set(VIEW(it),
1832 elm_widget_mirrored_get(WIDGET(it)));
1834 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1835 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1836 elm_widget_sub_object_add(WIDGET(it), it->spacer);
1839 _elm_genlist_item_odd_even_update(it);
1841 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1843 if (it2->parent->item->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1845 it->item->expanded_depth = depth;
1846 treesize = edje_object_data_get(VIEW(it), "treesize");
1847 if (treesize) tsize = atoi(treesize);
1848 evas_object_size_hint_min_set(it->spacer,
1849 (depth * tsize) * _elm_config->scale, 1);
1850 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
1853 edje_object_signal_callback_add(VIEW(it),
1854 "elm,action,expand,toggle",
1855 "elm", _signal_expand_toggle, it);
1856 edje_object_signal_callback_add(VIEW(it), "elm,action,expand",
1857 "elm", _signal_expand, it);
1858 edje_object_signal_callback_add(VIEW(it), "elm,action,contract",
1859 "elm", _signal_contract, it);
1860 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1862 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1864 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1866 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_DOWN,
1868 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_UP,
1870 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_MOVE,
1873 _elm_genlist_item_state_update(it, itc);
1876 if ((calc) && (it->wd->homogeneous) &&
1877 ((it->wd->item_width) ||
1878 ((it->wd->item_width) && (it->wd->group_item_width))))
1880 /* homogenous genlist shortcut */
1881 if (!it->item->mincalcd)
1883 if (it->item->flags & ELM_GENLIST_ITEM_GROUP)
1885 it->item->w = it->item->minw = it->wd->group_item_width;
1886 it->item->h = it->item->minh = it->wd->group_item_height;
1890 it->item->w = it->item->minw = it->wd->item_width;
1891 it->item->h = it->item->minh = it->wd->item_height;
1893 it->item->mincalcd = EINA_TRUE;
1898 /* FIXME: If you see that assert, please notify us and we
1899 will clean our mess */
1900 assert(eina_list_count(it->icon_objs) == 0);
1902 _item_label_realize(it, VIEW(it), &it->labels);
1903 it->icon_objs = _item_icon_realize(it, VIEW(it), &it->icons);
1904 _item_state_realize(it, VIEW(it), &it->states);
1906 if (!it->item->mincalcd)
1908 Evas_Coord mw = -1, mh = -1;
1910 if (!it->display_only)
1911 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1912 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1913 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
1915 if (!it->display_only)
1916 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1917 it->item->w = it->item->minw = mw;
1918 it->item->h = it->item->minh = mh;
1919 it->item->mincalcd = EINA_TRUE;
1921 if ((!it->wd->group_item_width) && (it->item->flags == ELM_GENLIST_ITEM_GROUP))
1923 it->wd->group_item_width = mw;
1924 it->wd->group_item_height = mh;
1926 else if ((!it->wd->item_width) && (it->item->flags == ELM_GENLIST_ITEM_NONE))
1928 it->wd->item_width = mw;
1929 it->wd->item_height = mh;
1932 if (!calc) evas_object_show(VIEW(it));
1935 if (it->tooltip.content_cb)
1937 elm_widget_item_tooltip_content_cb_set(it,
1938 it->tooltip.content_cb,
1939 it->tooltip.data, NULL);
1940 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1941 elm_widget_item_tooltip_size_restrict_disable(it, it->tooltip.free_size);
1944 if (it->mouse_cursor)
1945 elm_widget_item_cursor_set(it, it->mouse_cursor);
1947 it->realized = EINA_TRUE;
1948 it->want_unrealize = EINA_FALSE;
1950 if (itc) _item_cache_free(itc);
1951 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1952 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1954 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1955 edje_object_message_signal_process(VIEW(it));
1959 _item_unrealize_cb(Elm_Gen_Item *it)
1961 if (it->item->nocache)
1963 evas_object_del(VIEW(it));
1965 evas_object_del(it->spacer);
1970 edje_object_mirrored_set(VIEW(it),
1971 elm_widget_mirrored_get(WIDGET(it)));
1972 edje_object_scale_set(VIEW(it),
1973 elm_widget_scale_get(WIDGET(it))
1974 * _elm_config->scale);
1975 _item_cache_add(it);
1978 _mode_item_unrealize(it);
1980 it->realized = EINA_FALSE;
1981 it->want_unrealize = EINA_FALSE;
1985 _item_block_recalc(Item_Block *itb,
1991 Evas_Coord minw = 0, minh = 0;
1992 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1995 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
1997 EINA_LIST_FOREACH(itb->items, l, it)
1999 if (it->delete_me) continue;
2000 showme |= it->item->showme;
2005 if (!it->item->mincalcd) changed = EINA_TRUE;
2008 _item_realize(it, in, EINA_TRUE);
2009 elm_gen_item_unrealize(it, EINA_TRUE, (Ecore_Cb)_item_unrealize_cb);
2014 _item_realize(it, in, EINA_TRUE);
2015 elm_gen_item_unrealize(it, EINA_TRUE, (Ecore_Cb)_item_unrealize_cb);
2019 _item_realize(it, in, EINA_FALSE);
2020 minh += it->item->minh;
2021 if (minw < it->item->minw) minw = it->item->minw;
2029 itb->changed = EINA_FALSE;
2030 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2031 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2036 _item_block_realize(Item_Block *itb)
2038 if (itb->realized) return;
2039 itb->realized = EINA_TRUE;
2040 itb->want_unrealize = EINA_FALSE;
2044 _item_block_unrealize(Item_Block *itb)
2048 Eina_Bool dragging = EINA_FALSE;
2050 if (!itb->realized) return;
2051 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2052 EINA_LIST_FOREACH(itb->items, l, it)
2054 if (it->item->flags != ELM_GENLIST_ITEM_GROUP)
2058 dragging = EINA_TRUE;
2059 it->want_unrealize = EINA_TRUE;
2062 elm_gen_item_unrealize(it, EINA_FALSE, (Ecore_Cb)_item_unrealize_cb);
2067 itb->realized = EINA_FALSE;
2068 itb->want_unrealize = EINA_TRUE;
2071 itb->want_unrealize = EINA_FALSE;
2072 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2073 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2077 _get_space_for_reorder_item(Elm_Gen_Item *it)
2079 Evas_Coord rox, roy, row, roh, oy, oh;
2080 Eina_Bool top = EINA_FALSE;
2081 Elm_Gen_Item *reorder_it = it->wd->reorder_it;
2082 if (!reorder_it) return 0;
2084 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2085 evas_object_geometry_get(it->wd->VIEW(reorder_it), &rox, &roy, &row, &roh);
2087 if ((it->wd->reorder_start_y < it->item->block->y) &&
2088 (roy - oy + (roh / 2) >= it->item->block->y - it->wd->pan_y))
2090 it->item->block->reorder_offset = it->wd->reorder_it->item->h * -1;
2091 if (it->item->block->count == 1)
2092 it->wd->reorder_rel = it;
2094 else if ((it->wd->reorder_start_y >= it->item->block->y) &&
2095 (roy - oy + (roh / 2) <= it->item->block->y - it->wd->pan_y))
2097 it->item->block->reorder_offset = it->wd->reorder_it->item->h;
2100 it->item->block->reorder_offset = 0;
2102 it->item->scrl_y += it->item->block->reorder_offset;
2104 top = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2105 rox, roy + (roh / 2), row, 1));
2108 it->wd->reorder_rel = it;
2109 it->item->scrl_y += it->wd->reorder_it->item->h;
2110 return it->wd->reorder_it->item->h;
2117 _reorder_move_animator_cb(void *data)
2119 Elm_Gen_Item *it = data;
2120 Eina_Bool down = EINA_FALSE;
2122 int y, dy = it->item->h / 10 * _elm_config->scale, diff;
2124 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2126 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2129 diff = abs(it->item->old_scrl_y - it->item->scrl_y);
2130 if (diff > it->item->h) y = diff / 2;
2132 if (it->item->old_scrl_y < it->item->scrl_y)
2134 it->item->old_scrl_y += y;
2137 else if (it->item->old_scrl_y > it->item->scrl_y)
2139 it->item->old_scrl_y -= y;
2142 _item_position(it, VIEW(it), it->item->scrl_x, it->item->old_scrl_y);
2143 _group_items_recalc(it->wd);
2145 if ((it->wd->reorder_pan_move) ||
2146 (down && it->item->old_scrl_y >= it->item->scrl_y) ||
2147 (!down && it->item->old_scrl_y <= it->item->scrl_y))
2149 it->item->old_scrl_y = it->item->scrl_y;
2150 it->item->move_effect_enabled = EINA_FALSE;
2151 it->wd->reorder_move_animator = NULL;
2152 return ECORE_CALLBACK_CANCEL;
2154 return ECORE_CALLBACK_RENEW;
2158 _item_position(Elm_Gen_Item *it,
2166 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2167 evas_object_resize(view, it->item->w, it->item->h);
2168 evas_object_move(view, it_x, it_y);
2169 evas_object_show(view);
2170 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2171 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2175 _item_block_position(Item_Block *itb,
2181 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2184 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2185 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2186 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2188 EINA_LIST_FOREACH(itb->items, l, it)
2190 if (it->delete_me) continue;
2191 else if (it->wd->reorder_it == it) continue;
2194 it->item->w = itb->w;
2195 it->item->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2196 it->item->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2198 vis = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2199 cvx, cvy, cvw, cvh));
2200 if (it->item->flags != ELM_GENLIST_ITEM_GROUP)
2202 if ((itb->realized) && (!it->realized))
2204 if (vis) _item_realize(it, in, EINA_FALSE);
2210 if (it->wd->reorder_mode)
2211 y += _get_space_for_reorder_item(it);
2212 git = it->item->group_item;
2215 if (git->item->scrl_y < oy)
2216 git->item->scrl_y = oy;
2217 if ((git->item->scrl_y + git->item->h) > (it->item->scrl_y + it->item->h))
2218 git->item->scrl_y = (it->item->scrl_y + it->item->h) - git->item->h;
2219 git->item->want_realize = EINA_TRUE;
2221 if ((it->wd->reorder_it) && (it->item->old_scrl_y != it->item->scrl_y))
2223 if (!it->item->move_effect_enabled)
2225 it->item->move_effect_enabled = EINA_TRUE;
2226 it->wd->reorder_move_animator =
2228 _reorder_move_animator_cb, it);
2231 if (!it->item->move_effect_enabled)
2233 if (it->item->mode_view)
2234 _item_position(it, it->item->mode_view, it->item->scrl_x,
2237 _item_position(it, VIEW(it), it->item->scrl_x,
2239 it->item->old_scrl_y = it->item->scrl_y;
2244 if (!it->dragging) elm_gen_item_unrealize(it, EINA_FALSE, (Ecore_Cb)_item_unrealize_cb);
2251 if (vis) it->item->want_realize = EINA_TRUE;
2255 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2256 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2260 _group_items_recalc(void *data)
2262 Widget_Data *wd = data;
2266 evas_event_freeze(evas_object_evas_get(wd->obj));
2267 EINA_LIST_FOREACH(wd->group_items, l, git)
2269 if (git->item->want_realize)
2272 _item_realize(git, 0, EINA_FALSE);
2273 evas_object_resize(VIEW(git), wd->minw, git->item->h);
2274 evas_object_move(VIEW(git), git->item->scrl_x, git->item->scrl_y);
2275 evas_object_show(VIEW(git));
2276 evas_object_raise(VIEW(git));
2278 else if (!git->item->want_realize && git->realized)
2281 elm_gen_item_unrealize(git, EINA_FALSE, (Ecore_Cb)_item_unrealize_cb);
2284 evas_event_thaw(evas_object_evas_get(wd->obj));
2285 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2289 _must_recalc_idler(void *data)
2291 Widget_Data *wd = data;
2292 if (wd->calc_job) ecore_job_del(wd->calc_job);
2293 wd->calc_job = ecore_job_add(_calc_job, wd);
2294 wd->must_recalc_idler = NULL;
2295 return ECORE_CALLBACK_CANCEL;
2299 _calc_job(void *data)
2301 Widget_Data *wd = data;
2302 Item_Block *itb, *chb = NULL;
2303 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2306 Eina_Bool minw_change = EINA_FALSE;
2307 Eina_Bool did_must_recalc = EINA_FALSE;
2310 t0 = ecore_time_get();
2311 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2315 evas_event_freeze(evas_object_evas_get(wd->obj));
2316 EINA_INLIST_FOREACH(wd->blocks, itb)
2318 Eina_Bool showme = EINA_FALSE;
2321 showme = itb->showme;
2322 itb->showme = EINA_FALSE;
2325 if (itb->realized) _item_block_unrealize(itb);
2327 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2329 if (itb->must_recalc)
2333 EINA_LIST_FOREACH(itb->items, l, it)
2334 if (it->item->mincalcd) it->item->mincalcd = EINA_FALSE;
2335 itb->changed = EINA_TRUE;
2336 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2337 itb->must_recalc = EINA_FALSE;
2339 if (itb->realized) _item_block_unrealize(itb);
2340 showme = _item_block_recalc(itb, in, EINA_FALSE);
2346 if (minw == -1) minw = itb->minw;
2347 else if ((!itb->must_recalc) && (minw < itb->minw))
2350 minw_change = EINA_TRUE;
2356 if ((showme) && (wd->show_item) && (!wd->show_item->item->queued))
2358 wd->show_item->item->showme = EINA_FALSE;
2360 elm_smart_scroller_region_bring_in(wd->scr,
2362 wd->show_item->item->block->x,
2364 wd->show_item->item->block->y,
2365 wd->show_item->item->block->w,
2366 wd->show_item->item->h);
2368 elm_smart_scroller_child_region_show(wd->scr,
2370 wd->show_item->item->block->x,
2372 wd->show_item->item->block->y,
2373 wd->show_item->item->block->w,
2374 wd->show_item->item->h);
2375 wd->show_item = NULL;
2380 EINA_INLIST_FOREACH(wd->blocks, itb)
2386 if ((chb) && (EINA_INLIST_GET(chb)->next))
2388 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2390 if (itb->realized) _item_block_unrealize(itb);
2393 wd->realminw = minw;
2394 if (minw < wd->w) minw = wd->w;
2395 if ((minw != wd->minw) || (minh != wd->minh))
2399 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2400 _sizing_eval(wd->obj);
2401 if ((wd->anchor_item) && (wd->anchor_item->item->block) && (!wd->auto_scroll_enabled))
2406 it = wd->anchor_item;
2407 it_y = wd->anchor_y;
2408 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2409 it->item->block->y + it->y + it_y);
2410 wd->anchor_item = it;
2411 wd->anchor_y = it_y;
2414 t = ecore_time_get();
2415 if (did_must_recalc)
2417 if (!wd->must_recalc_idler)
2418 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2420 wd->calc_job = NULL;
2421 evas_object_smart_changed(wd->pan_smart);
2422 evas_event_thaw(evas_object_evas_get(wd->obj));
2423 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2427 _update_job(void *data)
2429 Widget_Data *wd = data;
2433 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2435 wd->update_job = NULL;
2438 evas_event_freeze(evas_object_evas_get(wd->obj));
2439 EINA_INLIST_FOREACH(wd->blocks, itb)
2441 Evas_Coord itminw, itminh;
2448 _item_block_position(itb, num);
2452 recalc = EINA_FALSE;
2453 EINA_LIST_FOREACH(itb->items, l2, it)
2455 if (it->item->updateme)
2457 itminw = it->item->minw;
2458 itminh = it->item->minh;
2460 it->item->updateme = EINA_FALSE;
2463 elm_gen_item_unrealize(it, EINA_FALSE, (Ecore_Cb)_item_unrealize_cb);
2464 _item_realize(it, num, EINA_FALSE);
2465 position = EINA_TRUE;
2469 _item_realize(it, num, EINA_TRUE);
2470 elm_gen_item_unrealize(it, EINA_TRUE, (Ecore_Cb)_item_unrealize_cb);
2472 if ((it->item->minw != itminw) || (it->item->minh != itminh))
2477 itb->updateme = EINA_FALSE;
2480 position = EINA_TRUE;
2481 itb->changed = EINA_TRUE;
2482 _item_block_recalc(itb, num0, EINA_FALSE);
2483 _item_block_position(itb, num0);
2488 if (wd->calc_job) ecore_job_del(wd->calc_job);
2489 wd->calc_job = ecore_job_add(_calc_job, wd);
2491 evas_event_thaw(evas_object_evas_get(wd->obj));
2492 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2496 _pan_set(Evas_Object *obj,
2500 Pan *sd = evas_object_smart_data_get(obj);
2504 // Evas_Coord ow, oh;
2505 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2506 // ow = sd->wd->minw - ow;
2507 // if (ow < 0) ow = 0;
2508 // oh = sd->wd->minh - oh;
2509 // if (oh < 0) oh = 0;
2510 // if (x < 0) x = 0;
2511 // if (y < 0) y = 0;
2512 // if (x > ow) x = ow;
2513 // if (y > oh) y = oh;
2514 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2518 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2520 if ((itb->y + itb->h) > y)
2525 EINA_LIST_FOREACH(itb->items, l2, it)
2527 if ((itb->y + it->y) >= y)
2529 sd->wd->anchor_item = it;
2530 sd->wd->anchor_y = -(itb->y + it->y - y);
2537 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2541 _pan_get(Evas_Object *obj,
2545 Pan *sd = evas_object_smart_data_get(obj);
2548 if (x) *x = sd->wd->pan_x;
2549 if (y) *y = sd->wd->pan_y;
2553 _pan_max_get(Evas_Object *obj,
2557 Pan *sd = evas_object_smart_data_get(obj);
2561 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2562 ow = sd->wd->minw - ow;
2564 oh = sd->wd->minh - oh;
2571 _pan_min_get(Evas_Object *obj __UNUSED__,
2580 _pan_child_size_get(Evas_Object *obj,
2584 Pan *sd = evas_object_smart_data_get(obj);
2587 if (w) *w = sd->wd->minw;
2588 if (h) *h = sd->wd->minh;
2592 _pan_add(Evas_Object *obj)
2595 Evas_Object_Smart_Clipped_Data *cd;
2598 cd = evas_object_smart_data_get(obj);
2601 sd->__clipped_data = *cd;
2603 evas_object_smart_data_set(obj, sd);
2607 _pan_del(Evas_Object *obj)
2609 Pan *sd = evas_object_smart_data_get(obj);
2614 ecore_job_del(sd->resize_job);
2615 sd->resize_job = NULL;
2621 _pan_resize_job(void *data)
2625 _sizing_eval(sd->wd->obj);
2626 sd->resize_job = NULL;
2630 _pan_resize(Evas_Object *obj,
2634 Pan *sd = evas_object_smart_data_get(obj);
2638 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2639 if ((ow == w) && (oh == h)) return;
2640 if ((sd->wd->height_for_width) && (ow != w))
2643 if (sd->resize_job) ecore_job_del(sd->resize_job);
2644 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2646 sd->wd->pan_resized = EINA_TRUE;
2647 evas_object_smart_changed(obj);
2648 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2649 sd->wd->calc_job = NULL;
2651 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2652 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2657 _pan_calculate(Evas_Object *obj)
2659 Pan *sd = evas_object_smart_data_get(obj);
2661 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2667 evas_event_freeze(evas_object_evas_get(obj));
2669 if (sd->wd->pan_resized)
2672 sd->wd->pan_resized = EINA_FALSE;
2675 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2676 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2677 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2679 git->item->want_realize = EINA_FALSE;
2681 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2683 itb->w = sd->wd->minw;
2684 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2685 itb->y - sd->wd->pan_y + oy,
2687 cvx, cvy, cvw, cvh))
2689 if ((!itb->realized) || (itb->changed))
2690 _item_block_realize(itb);
2691 _item_block_position(itb, in);
2695 if (itb->realized) _item_block_unrealize(itb);
2699 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2700 _group_items_recalc(sd->wd);
2701 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2703 if (sd->wd->pan_y != sd->wd->reorder_old_pan_y)
2704 sd->wd->reorder_pan_move = EINA_TRUE;
2705 else sd->wd->reorder_pan_move = EINA_FALSE;
2706 evas_object_raise(sd->wd->VIEW(reorder_it));
2707 sd->wd->reorder_old_pan_y = sd->wd->pan_y;
2708 sd->wd->start_time = ecore_loop_time_get();
2710 _item_auto_scroll(sd->wd);
2711 evas_event_thaw(evas_object_evas_get(obj));
2712 evas_event_thaw_eval(evas_object_evas_get(obj));
2716 _pan_move(Evas_Object *obj,
2717 Evas_Coord x __UNUSED__,
2718 Evas_Coord y __UNUSED__)
2720 Pan *sd = evas_object_smart_data_get(obj);
2723 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2724 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2728 _hold_on(void *data __UNUSED__,
2730 void *event_info __UNUSED__)
2732 Widget_Data *wd = elm_widget_data_get(obj);
2734 elm_smart_scroller_hold_set(wd->scr, 1);
2738 _hold_off(void *data __UNUSED__,
2740 void *event_info __UNUSED__)
2742 Widget_Data *wd = elm_widget_data_get(obj);
2744 elm_smart_scroller_hold_set(wd->scr, 0);
2748 _freeze_on(void *data __UNUSED__,
2750 void *event_info __UNUSED__)
2752 Widget_Data *wd = elm_widget_data_get(obj);
2754 elm_smart_scroller_freeze_set(wd->scr, 1);
2758 _freeze_off(void *data __UNUSED__,
2760 void *event_info __UNUSED__)
2762 Widget_Data *wd = elm_widget_data_get(obj);
2764 elm_smart_scroller_freeze_set(wd->scr, 0);
2768 _scr_anim_start(void *data,
2769 Evas_Object *obj __UNUSED__,
2770 void *event_info __UNUSED__)
2772 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
2776 _scr_anim_stop(void *data,
2777 Evas_Object *obj __UNUSED__,
2778 void *event_info __UNUSED__)
2780 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
2784 _scr_drag_start(void *data,
2785 Evas_Object *obj __UNUSED__,
2786 void *event_info __UNUSED__)
2788 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
2792 _scr_drag_stop(void *data,
2793 Evas_Object *obj __UNUSED__,
2794 void *event_info __UNUSED__)
2796 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
2800 _edge_left(void *data,
2801 Evas_Object *scr __UNUSED__,
2802 void *event_info __UNUSED__)
2804 Evas_Object *obj = data;
2805 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
2806 evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
2810 _edge_right(void *data,
2811 Evas_Object *scr __UNUSED__,
2812 void *event_info __UNUSED__)
2814 Evas_Object *obj = data;
2815 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
2816 evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
2820 _edge_top(void *data,
2821 Evas_Object *scr __UNUSED__,
2822 void *event_info __UNUSED__)
2824 Evas_Object *obj = data;
2825 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
2826 evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
2830 _edge_bottom(void *data,
2831 Evas_Object *scr __UNUSED__,
2832 void *event_info __UNUSED__)
2834 Evas_Object *obj = data;
2835 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
2836 evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
2840 _mode_item_realize(Elm_Gen_Item *it)
2844 if ((it->item->mode_view) || (it->delete_me)) return;
2846 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2847 it->item->mode_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
2848 edje_object_scale_set(it->item->mode_view,
2849 elm_widget_scale_get(WIDGET(it)) *
2850 _elm_config->scale);
2851 evas_object_smart_member_add(it->item->mode_view, it->wd->pan_smart);
2852 elm_widget_sub_object_add(WIDGET(it), it->item->mode_view);
2854 strncpy(buf, "item", sizeof(buf));
2855 if (it->wd->compress)
2856 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2858 if (it->item->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2859 strncat(buf, "/", sizeof(buf) - strlen(buf));
2860 strncat(buf, it->wd->mode_item_style, sizeof(buf) - strlen(buf));
2862 _elm_theme_object_set(WIDGET(it), it->item->mode_view, "genlist", buf,
2863 elm_widget_style_get(WIDGET(it)));
2864 edje_object_mirrored_set(it->item->mode_view,
2865 elm_widget_mirrored_get(WIDGET(it)));
2867 /* signal callback add */
2868 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2870 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_UP,
2872 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2875 /* label_get, icon_get, state_get */
2876 /* FIXME: If you see that assert, please notify us and we
2877 will clean our mess */
2878 assert(eina_list_count(it->item->mode_icon_objs) == 0);
2880 _item_label_realize(it, it->item->mode_view, &it->item->mode_labels);
2881 it->item->mode_icon_objs = _item_icon_realize(it,
2882 it->item->mode_view,
2883 &it->item->mode_icons);
2884 _item_state_realize(it, it->item->mode_view, &it->item->mode_states);
2886 edje_object_part_swallow(it->item->mode_view,
2887 edje_object_data_get(it->item->mode_view, "mode_part"),
2890 it->want_unrealize = EINA_FALSE;
2891 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2892 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2896 _mode_item_unrealize(Elm_Gen_Item *it)
2898 Widget_Data *wd = it->wd;
2900 if (!it->item->mode_view) return;
2902 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2903 elm_widget_stringlist_free(it->item->mode_labels);
2904 it->item->mode_labels = NULL;
2905 elm_widget_stringlist_free(it->item->mode_icons);
2906 it->item->mode_icons = NULL;
2907 elm_widget_stringlist_free(it->item->mode_states);
2909 EINA_LIST_FREE(it->item->mode_icon_objs, icon)
2910 evas_object_del(icon);
2912 edje_object_part_unswallow(it->item->mode_view, VIEW(it));
2913 evas_object_smart_member_add(VIEW(it), wd->pan_smart);
2914 evas_object_del(it->item->mode_view);
2915 it->item->mode_view = NULL;
2917 if (wd->mode_item == it)
2918 wd->mode_item = NULL;
2919 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2920 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2924 _item_mode_set(Elm_Gen_Item *it)
2927 Widget_Data *wd = it->wd;
2932 it->item->nocache = EINA_TRUE;
2934 if (wd->scr_hold_timer)
2936 ecore_timer_del(wd->scr_hold_timer);
2937 wd->scr_hold_timer = NULL;
2939 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2940 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2942 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2943 _mode_item_realize(it);
2944 if (it->item->group_item)
2945 evas_object_raise(it->item->VIEW(group_item));
2946 _item_position(it, it->item->mode_view, it->item->scrl_x, it->item->scrl_y);
2947 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2948 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2950 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2951 edje_object_signal_emit(it->item->mode_view, buf, "elm");
2955 _item_mode_unset(Widget_Data *wd)
2958 if (!wd->mode_item) return;
2959 char buf[1024], buf2[1024];
2963 it->item->nocache = EINA_TRUE;
2965 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2966 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2968 edje_object_signal_emit(it->item->mode_view, buf, "elm");
2969 edje_object_signal_callback_add(it->item->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2971 wd->mode_item = NULL;
2975 _item_auto_scroll(Widget_Data *wd)
2980 Evas_Coord ox, oy, ow, oh;
2982 if ((wd->expanded_item) && (wd->auto_scroll_enabled))
2984 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
2985 if (wd->expanded_item->item->scrl_y > (oh + oy) / 2)
2987 EINA_LIST_FOREACH(wd->expanded_item->item->items, l, it)
2988 elm_genlist_item_bring_in(it);
2990 wd->auto_scroll_enabled = EINA_FALSE;
2995 elm_genlist_add(Evas_Object *parent)
3000 Evas_Coord minw, minh;
3001 static Evas_Smart *smart = NULL;
3005 static Evas_Smart_Class sc;
3007 evas_object_smart_clipped_smart_set(&_pan_sc);
3009 sc.name = "elm_genlist_pan";
3010 sc.version = EVAS_SMART_CLASS_VERSION;
3013 sc.resize = _pan_resize;
3014 sc.move = _pan_move;
3015 sc.calculate = _pan_calculate;
3016 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3019 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3021 ELM_SET_WIDTYPE(widtype, "genlist");
3022 elm_widget_type_set(obj, "genlist");
3023 elm_widget_sub_object_add(parent, obj);
3024 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3025 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3026 elm_widget_data_set(obj, wd);
3027 elm_widget_del_hook_set(obj, _del_hook);
3028 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3029 elm_widget_theme_hook_set(obj, _theme_hook);
3030 elm_widget_can_focus_set(obj, EINA_TRUE);
3031 elm_widget_event_hook_set(obj, _event_hook);
3032 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3033 elm_widget_translate_hook_set(obj, _translate_hook);
3035 wd->scr = elm_smart_scroller_add(e);
3036 elm_smart_scroller_widget_set(wd->scr, obj);
3037 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3038 elm_widget_style_get(obj));
3039 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3040 _elm_config->thumbscroll_bounce_enable);
3041 elm_widget_resize_object_set(obj, wd->scr);
3043 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3044 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3045 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3046 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3047 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
3048 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
3049 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
3050 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
3053 wd->mode = ELM_LIST_SCROLL;
3054 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3055 wd->item_cache_max = wd->max_items_per_block * 2;
3056 wd->longpress_timeout = _elm_config->longpress_timeout;
3058 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3059 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3060 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3061 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3063 wd->pan_smart = evas_object_smart_add(e, smart);
3064 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3067 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3068 _pan_set, _pan_get, _pan_max_get,
3069 _pan_min_get, _pan_child_size_get);
3071 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3073 evas_object_size_hint_min_set(obj, minw, minh);
3075 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3077 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3082 static Elm_Gen_Item *
3083 _item_new(Widget_Data *wd,
3084 const Elm_Genlist_Item_Class *itc,
3086 Elm_Gen_Item *parent,
3087 Elm_Genlist_Item_Flags flags,
3089 const void *func_data)
3093 it = elm_gen_item_new(wd, itc, data, parent, func, func_data);
3094 if (!it) return NULL;
3095 it->item = ELM_NEW(Elm_Gen_Item_Type);
3096 it->item->flags = flags;
3097 if (flags & ELM_GENLIST_ITEM_GROUP) it->group++;
3098 it->item->expanded_depth = 0;
3099 elm_widget_item_del_cb_set(it, _item_del_hook);
3102 if (it->parent->group)
3103 it->item->group_item = parent;
3104 else if (it->parent->item->group_item)
3105 it->item->group_item = it->parent->item->group_item;
3111 _item_block_add(Widget_Data *wd,
3114 Item_Block *itb = NULL;
3121 itb = calloc(1, sizeof(Item_Block));
3124 if (!it->item->rel->item->block)
3127 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3128 itb->items = eina_list_append(itb->items, it);
3132 if (it->item->before)
3134 wd->blocks = eina_inlist_prepend_relative
3135 (wd->blocks, EINA_INLIST_GET(itb),
3136 EINA_INLIST_GET(it->item->rel->item->block));
3138 eina_list_prepend_relative(itb->items, it, it->item->rel);
3142 wd->blocks = eina_inlist_append_relative
3143 (wd->blocks, EINA_INLIST_GET(itb),
3144 EINA_INLIST_GET(it->item->rel->item->block));
3146 eina_list_append_relative(itb->items, it, it->item->rel);
3152 if (it->item->before)
3156 itb = (Item_Block *)(wd->blocks);
3157 if (itb->count >= wd->max_items_per_block)
3159 itb = calloc(1, sizeof(Item_Block));
3163 eina_inlist_prepend(wd->blocks,
3164 EINA_INLIST_GET(itb));
3169 itb = calloc(1, sizeof(Item_Block));
3173 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3175 itb->items = eina_list_prepend(itb->items, it);
3181 itb = (Item_Block *)(wd->blocks->last);
3182 if (itb->count >= wd->max_items_per_block)
3184 itb = calloc(1, sizeof(Item_Block));
3188 eina_inlist_append(wd->blocks,
3189 EINA_INLIST_GET(itb));
3194 itb = calloc(1, sizeof(Item_Block));
3198 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3200 itb->items = eina_list_append(itb->items, it);
3206 itb = it->item->rel->item->block;
3207 if (!itb) goto newblock;
3208 if (it->item->before)
3209 itb->items = eina_list_prepend_relative(itb->items, it, it->item->rel);
3211 itb->items = eina_list_append_relative(itb->items, it, it->item->rel);
3214 itb->changed = EINA_TRUE;
3215 it->item->block = itb;
3216 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3217 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3220 it->item->rel->relcount--;
3221 if ((it->item->rel->delete_me) && (!it->item->rel->relcount))
3222 _item_del(it->item->rel);
3223 it->item->rel = NULL;
3225 if (itb->count > itb->wd->max_items_per_block)
3231 newc = itb->count / 2;
3232 itb2 = calloc(1, sizeof(Item_Block));
3236 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3237 EINA_INLIST_GET(itb));
3238 itb2->changed = EINA_TRUE;
3239 while ((itb->count > newc) && (itb->items))
3243 l = eina_list_last(itb->items);
3245 itb->items = eina_list_remove_list(itb->items, l);
3248 itb2->items = eina_list_prepend(itb2->items, it2);
3249 it2->item->block = itb2;
3256 _queue_process(Widget_Data *wd)
3259 Eina_Bool showme = EINA_FALSE;
3262 t0 = ecore_time_get();
3263 //evas_event_freeze(evas_object_evas_get(wd->obj));
3264 for (n = 0; (wd->queue) && (n < 128); n++)
3268 it = wd->queue->data;
3269 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3270 it->item->queued = EINA_FALSE;
3271 _item_block_add(wd, it);
3272 t = ecore_time_get();
3273 if (it->item->block->changed)
3275 showme = _item_block_recalc(it->item->block, it->item->block->num, EINA_TRUE);
3276 it->item->block->changed = 0;
3278 if (showme) it->item->block->showme = EINA_TRUE;
3279 if (eina_inlist_count(wd->blocks) > 1)
3281 if ((t - t0) > (ecore_animator_frametime_get())) break;
3284 //evas_event_thaw(evas_object_evas_get(wd->obj));
3285 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3290 _idle_process(void *data, Eina_Bool *wakeup)
3292 Widget_Data *wd = data;
3295 //static double q_start = 0.0;
3296 //if (q_start == 0.0) q_start = ecore_time_get();
3298 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3302 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3304 return ECORE_CALLBACK_CANCEL;
3306 return ECORE_CALLBACK_RENEW;
3310 _item_idle_enterer(void *data)
3312 Widget_Data *wd = data;
3313 Eina_Bool wakeup = EINA_FALSE;
3314 Eina_Bool ok = _idle_process(data, &wakeup);
3319 if (wd->calc_job) ecore_job_del(wd->calc_job);
3320 wd->calc_job = ecore_job_add(_calc_job, wd);
3322 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3327 _item_queue(Widget_Data *wd,
3330 if (it->item->queued) return;
3331 it->item->queued = EINA_TRUE;
3332 wd->queue = eina_list_append(wd->queue, it);
3333 // FIXME: why does a freeze then thaw here cause some genlist
3334 // elm_genlist_item_append() to be much much slower?
3335 // evas_event_freeze(evas_object_evas_get(wd->obj));
3336 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3338 if (wd->queue_idle_enterer)
3340 ecore_idle_enterer_del(wd->queue_idle_enterer);
3341 wd->queue_idle_enterer = NULL;
3345 // evas_event_thaw(evas_object_evas_get(wd->obj));
3346 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3347 if (!wd->queue_idle_enterer)
3348 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3352 _elm_genlist_item_compare_data(const void *data, const void *data1)
3354 const Elm_Gen_Item *it = data;
3355 const Elm_Gen_Item *item1 = data1;
3357 return _elm_genlist_item_compare_data_cb(it->base.data, item1->base.data);
3361 _elm_genlist_item_compare(const void *data, const void *data1)
3363 const Elm_Gen_Item *it, *item1;
3364 it = ELM_GENLIST_ITEM_FROM_INLIST(data);
3365 item1 = ELM_GENLIST_ITEM_FROM_INLIST(data1);
3366 return _elm_genlist_item_compare_cb(it, item1);
3370 _elm_genlist_item_list_compare(const void *data, const void *data1)
3372 const Elm_Gen_Item *it = data;
3373 const Elm_Gen_Item *item1 = data1;
3374 return _elm_genlist_item_compare_cb(it, item1);
3378 _item_move_after(Elm_Gen_Item *it, Elm_Gen_Item *after)
3383 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3384 _item_block_del(it);
3386 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3387 it->item->rel = after;
3388 it->item->rel->relcount++;
3389 it->item->before = EINA_FALSE;
3390 if (after->item->group_item) it->item->group_item = after->item->group_item;
3391 _item_queue(it->wd, it);
3393 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
3397 _item_move_before(Elm_Gen_Item *it, Elm_Gen_Item *before)
3400 if (!before) return;
3402 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3403 _item_block_del(it);
3404 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3405 it->item->rel = before;
3406 it->item->rel->relcount++;
3407 it->item->before = EINA_TRUE;
3408 if (before->item->group_item) it->item->group_item = before->item->group_item;
3409 _item_queue(it->wd, it);
3411 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
3415 elm_genlist_item_append(Evas_Object *obj,
3416 const Elm_Genlist_Item_Class *itc,
3418 Elm_Gen_Item *parent,
3419 Elm_Genlist_Item_Flags flags,
3421 const void *func_data)
3423 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3424 Widget_Data *wd = elm_widget_data_get(obj);
3425 if (!wd) return NULL;
3426 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3428 if (!it) return NULL;
3431 if (flags & ELM_GENLIST_ITEM_GROUP)
3432 wd->group_items = eina_list_append(wd->group_items, it);
3433 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3434 it->item->rel = NULL;
3438 Elm_Gen_Item *it2 = NULL;
3439 Eina_List *ll = eina_list_last(it->parent->item->items);
3440 if (ll) it2 = ll->data;
3441 it->parent->item->items = eina_list_append(it->parent->item->items, it);
3442 if (!it2) it2 = it->parent;
3444 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3445 EINA_INLIST_GET(it2));
3446 it->item->rel = it2;
3447 it->item->rel->relcount++;
3449 it->item->before = EINA_FALSE;
3450 _item_queue(wd, it);
3455 elm_genlist_item_prepend(Evas_Object *obj,
3456 const Elm_Genlist_Item_Class *itc,
3458 Elm_Gen_Item *parent,
3459 Elm_Genlist_Item_Flags flags,
3461 const void *func_data)
3463 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3464 Widget_Data *wd = elm_widget_data_get(obj);
3465 if (!wd) return NULL;
3466 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3468 if (!it) return NULL;
3471 if (flags & ELM_GENLIST_ITEM_GROUP)
3472 wd->group_items = eina_list_prepend(wd->group_items, it);
3473 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3474 it->item->rel = NULL;
3478 Elm_Gen_Item *it2 = NULL;
3479 Eina_List *ll = it->parent->item->items;
3480 if (ll) it2 = ll->data;
3481 it->parent->item->items = eina_list_prepend(it->parent->item->items, it);
3482 if (!it2) it2 = it->parent;
3484 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3485 EINA_INLIST_GET(it2));
3486 it->item->rel = it2;
3487 it->item->rel->relcount++;
3489 it->item->before = EINA_TRUE;
3490 _item_queue(wd, it);
3495 elm_genlist_item_insert_after(Evas_Object *obj,
3496 const Elm_Genlist_Item_Class *itc,
3498 Elm_Gen_Item *parent,
3499 Elm_Gen_Item *after,
3500 Elm_Genlist_Item_Flags flags,
3502 const void *func_data)
3504 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3505 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3506 Widget_Data *wd = elm_widget_data_get(obj);
3507 if (!wd) return NULL;
3508 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3510 if (!it) return NULL;
3511 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3512 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3516 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3517 (after->item->flags & ELM_GENLIST_ITEM_GROUP))
3518 wd->group_items = eina_list_append_relative(wd->group_items, it,
3523 it->parent->item->items = eina_list_append_relative(it->parent->item->items, it,
3526 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3527 EINA_INLIST_GET(after));
3528 it->item->rel = after;
3529 it->item->rel->relcount++;
3530 it->item->before = EINA_FALSE;
3531 _item_queue(wd, it);
3536 elm_genlist_item_insert_before(Evas_Object *obj,
3537 const Elm_Genlist_Item_Class *itc,
3539 Elm_Gen_Item *parent,
3540 Elm_Gen_Item *before,
3541 Elm_Genlist_Item_Flags flags,
3543 const void *func_data)
3545 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3546 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3547 Widget_Data *wd = elm_widget_data_get(obj);
3548 if (!wd) return NULL;
3549 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3551 if (!it) return NULL;
3552 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
3553 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3557 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3558 (before->item->flags & ELM_GENLIST_ITEM_GROUP))
3559 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
3564 it->parent->item->items = eina_list_prepend_relative(it->parent->item->items, it,
3567 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3568 EINA_INLIST_GET(before));
3569 it->item->rel = before;
3570 it->item->rel->relcount++;
3571 it->item->before = EINA_TRUE;
3572 _item_queue(wd, it);
3577 elm_genlist_item_direct_sorted_insert(Evas_Object *obj,
3578 const Elm_Genlist_Item_Class *itc,
3580 Elm_Gen_Item *parent,
3581 Elm_Genlist_Item_Flags flags,
3582 Eina_Compare_Cb comp,
3584 const void *func_data)
3586 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3587 Widget_Data *wd = elm_widget_data_get(obj);
3588 if (!wd) return NULL;
3589 Elm_Gen_Item *rel = NULL;
3590 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3592 if (!it) return NULL;
3594 _elm_genlist_item_compare_cb = comp;
3601 l = eina_list_search_sorted_near_list(it->parent->item->items,
3602 _elm_genlist_item_list_compare, it,
3605 rel = eina_list_data_get(l);
3609 if (cmp_result >= 0)
3611 it->parent->item->items = eina_list_prepend_relative_list(it->parent->item->items, it, l);
3612 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
3613 it->item->before = EINA_FALSE;
3615 else if (cmp_result < 0)
3617 it->parent->item->items = eina_list_append_relative_list(it->parent->item->items, it, l);
3618 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
3619 it->item->before = EINA_TRUE;
3626 wd->state = eina_inlist_sorted_state_new();
3629 if (flags & ELM_GENLIST_ITEM_GROUP)
3630 wd->group_items = eina_list_append(wd->group_items, it);
3632 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
3633 _elm_genlist_item_compare, wd->state);
3635 if (EINA_INLIST_GET(it)->next)
3637 rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3638 it->item->before = EINA_TRUE;
3640 else if (EINA_INLIST_GET(it)->prev)
3642 rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3643 it->item->before = EINA_FALSE;
3649 it->item->rel = rel;
3650 it->item->rel->relcount++;
3653 _item_queue(wd, it);
3659 elm_genlist_item_sorted_insert(Evas_Object *obj,
3660 const Elm_Genlist_Item_Class *itc,
3662 Elm_Gen_Item *parent,
3663 Elm_Genlist_Item_Flags flags,
3664 Eina_Compare_Cb comp,
3666 const void *func_data)
3668 _elm_genlist_item_compare_data_cb = comp;
3670 return elm_genlist_item_direct_sorted_insert(obj, itc, data, parent, flags,
3671 _elm_genlist_item_compare_data, func, func_data);
3675 elm_genlist_clear(Evas_Object *obj)
3677 ELM_CHECK_WIDTYPE(obj, widtype);
3678 Widget_Data *wd = elm_widget_data_get(obj);
3682 eina_inlist_sorted_state_free(wd->state);
3685 if (wd->walking > 0)
3689 wd->clear_me = EINA_TRUE;
3690 EINA_INLIST_FOREACH(wd->items, it)
3692 it->delete_me = EINA_TRUE;
3696 evas_event_freeze(evas_object_evas_get(wd->obj));
3699 Elm_Gen_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3701 if (wd->anchor_item == it)
3703 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3704 if (!wd->anchor_item)
3706 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3708 wd->items = eina_inlist_remove(wd->items, wd->items);
3709 if (it->item->flags & ELM_GENLIST_ITEM_GROUP)
3710 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3711 elm_widget_item_pre_notify_del(it);
3712 if (it->realized) elm_gen_item_unrealize(it, EINA_FALSE, (Ecore_Cb)_item_unrealize_cb);
3713 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3714 it->itc->func.del((void *)it->base.data, WIDGET(it));
3715 if (it->long_timer) ecore_timer_del(it->long_timer);
3716 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
3718 elm_widget_item_del(it);
3720 wd->clear_me = EINA_FALSE;
3721 wd->anchor_item = NULL;
3724 Item_Block *itb = (Item_Block *)(wd->blocks);
3726 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3727 if (itb->items) eina_list_free(itb->items);
3732 ecore_job_del(wd->calc_job);
3733 wd->calc_job = NULL;
3735 if (wd->queue_idle_enterer)
3737 ecore_idle_enterer_del(wd->queue_idle_enterer);
3738 wd->queue_idle_enterer = NULL;
3740 if (wd->must_recalc_idler)
3742 ecore_idler_del(wd->must_recalc_idler);
3743 wd->must_recalc_idler = NULL;
3747 eina_list_free(wd->queue);
3752 eina_list_free(wd->selected);
3753 wd->selected = NULL;
3755 if (wd->reorder_move_animator)
3757 ecore_animator_del(wd->reorder_move_animator);
3758 wd->reorder_move_animator = NULL;
3760 wd->show_item = NULL;
3763 wd->reorder_old_pan_y = 0;
3768 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3769 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3772 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
3773 evas_event_thaw(evas_object_evas_get(wd->obj));
3774 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3778 elm_genlist_multi_select_set(Evas_Object *obj,
3781 ELM_CHECK_WIDTYPE(obj, widtype);
3782 Widget_Data *wd = elm_widget_data_get(obj);
3788 elm_genlist_multi_select_get(const Evas_Object *obj)
3790 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3791 Widget_Data *wd = elm_widget_data_get(obj);
3792 if (!wd) return EINA_FALSE;
3797 elm_genlist_selected_item_get(const Evas_Object *obj)
3799 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3800 Widget_Data *wd = elm_widget_data_get(obj);
3801 if (!wd) return NULL;
3802 if (wd->selected) return wd->selected->data;
3806 EAPI const Eina_List *
3807 elm_genlist_selected_items_get(const Evas_Object *obj)
3809 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3810 Widget_Data *wd = elm_widget_data_get(obj);
3811 if (!wd) return NULL;
3812 return wd->selected;
3816 elm_genlist_realized_items_get(const Evas_Object *obj)
3818 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3819 Widget_Data *wd = elm_widget_data_get(obj);
3820 Eina_List *list = NULL;
3822 Eina_Bool done = EINA_FALSE;
3823 if (!wd) return NULL;
3824 EINA_INLIST_FOREACH(wd->blocks, itb)
3832 EINA_LIST_FOREACH(itb->items, l, it)
3834 if (it->realized) list = eina_list_append(list, it);
3846 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3851 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3852 Widget_Data *wd = elm_widget_data_get(obj);
3853 Evas_Coord ox, oy, ow, oh;
3856 if (!wd) return NULL;
3857 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3859 EINA_INLIST_FOREACH(wd->blocks, itb)
3864 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3865 oy + itb->y - itb->wd->pan_y,
3866 itb->w, itb->h, x, y, 1, 1))
3868 EINA_LIST_FOREACH(itb->items, l, it)
3870 Evas_Coord itx, ity;
3872 itx = ox + itb->x + it->x - itb->wd->pan_x;
3873 ity = oy + itb->y + it->y - itb->wd->pan_y;
3874 if (ELM_RECTS_INTERSECT(itx, ity, it->item->w, it->item->h, x, y, 1, 1))
3878 if (y <= (ity + (it->item->h / 4))) *posret = -1;
3879 else if (y >= (ity + it->item->h - (it->item->h / 4)))
3885 lasty = ity + it->item->h;
3890 if (y > lasty) *posret = 1;
3897 elm_genlist_first_item_get(const Evas_Object *obj)
3899 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3900 Widget_Data *wd = elm_widget_data_get(obj);
3901 if (!wd) return NULL;
3902 if (!wd->items) return NULL;
3903 Elm_Gen_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3904 while ((it) && (it->delete_me))
3905 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3910 elm_genlist_last_item_get(const Evas_Object *obj)
3912 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3913 Widget_Data *wd = elm_widget_data_get(obj);
3914 if (!wd) return NULL;
3915 if (!wd->items) return NULL;
3916 Elm_Gen_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3917 while ((it) && (it->delete_me))
3918 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3923 elm_genlist_item_next_get(const Elm_Gen_Item *it)
3925 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3928 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3929 if ((it) && (!it->delete_me)) break;
3931 return (Elm_Gen_Item *)it;
3935 elm_genlist_item_prev_get(const Elm_Gen_Item *it)
3937 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3940 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3941 if ((it) && (!it->delete_me)) break;
3943 return (Elm_Gen_Item *)it;
3947 elm_genlist_item_genlist_get(const Elm_Gen_Item *it)
3949 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3954 elm_genlist_item_parent_get(const Elm_Gen_Item *it)
3956 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3961 elm_genlist_item_subitems_clear(Elm_Gen_Item *it)
3963 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3964 Eina_List *tl = NULL, *l;
3967 EINA_LIST_FOREACH(it->item->items, l, it2)
3968 tl = eina_list_append(tl, it2);
3969 EINA_LIST_FREE(tl, it2)
3970 elm_genlist_item_del(it2);
3974 elm_genlist_item_selected_set(Elm_Gen_Item *it,
3977 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3978 Widget_Data *wd = it->wd;
3980 if ((it->delete_me) || (it->disabled)) return;
3981 selected = !!selected;
3982 if (it->selected == selected) return;
3988 while (wd->selected)
3990 _item_unhighlight(wd->selected->data);
3991 _item_unselect(wd->selected->data);
3994 _item_highlight(it);
3999 _item_unhighlight(it);
4005 elm_genlist_item_selected_get(const Elm_Gen_Item *it)
4007 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4008 return it->selected;
4012 elm_genlist_item_expanded_set(Elm_Gen_Item *it,
4015 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4016 if (it->item->expanded == expanded) return;
4017 it->item->expanded = expanded;
4018 it->wd->expanded_item = it;
4019 if (it->item->expanded)
4022 edje_object_signal_emit(VIEW(it), "elm,state,expanded", "elm");
4023 evas_object_smart_callback_call(WIDGET(it), SIG_EXPANDED, it);
4024 it->wd->auto_scroll_enabled = EINA_TRUE;
4029 edje_object_signal_emit(VIEW(it), "elm,state,contracted", "elm");
4030 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACTED, it);
4031 it->wd->auto_scroll_enabled = EINA_FALSE;
4036 elm_genlist_item_expanded_get(const Elm_Gen_Item *it)
4038 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4039 return it->item->expanded;
4043 elm_genlist_item_expanded_depth_get(const Elm_Gen_Item *it)
4045 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4046 return it->item->expanded_depth;
4050 elm_genlist_item_disabled_set(Elm_Gen_Item *it,
4053 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4056 if (it->disabled == disabled) return;
4057 if (it->delete_me) return;
4058 it->disabled = !!disabled;
4060 elm_genlist_item_selected_set(it, EINA_FALSE);
4064 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
4066 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
4067 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4068 elm_widget_disabled_set(obj, disabled);
4073 elm_genlist_item_disabled_get(const Elm_Gen_Item *it)
4075 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4076 if (it->delete_me) return EINA_FALSE;
4077 return it->disabled;
4081 elm_genlist_item_display_only_set(Elm_Gen_Item *it,
4082 Eina_Bool display_only)
4084 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4085 if (it->display_only == display_only) return;
4086 if (it->delete_me) return;
4087 it->display_only = display_only;
4088 it->item->mincalcd = EINA_FALSE;
4089 it->item->updateme = EINA_TRUE;
4090 if (it->item->block) it->item->block->updateme = EINA_TRUE;
4091 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4092 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4096 elm_genlist_item_display_only_get(const Elm_Gen_Item *it)
4098 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4099 if (it->delete_me) return EINA_FALSE;
4100 return it->display_only;
4104 elm_genlist_item_show(Elm_Gen_Item *it)
4106 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4107 Evas_Coord gith = 0;
4108 if (it->delete_me) return;
4109 if ((it->item->queued) || (!it->item->mincalcd))
4111 it->wd->show_item = it;
4112 it->wd->bring_in = EINA_TRUE;
4113 it->item->showme = EINA_TRUE;
4116 if (it->wd->show_item)
4118 it->wd->show_item->item->showme = EINA_FALSE;
4119 it->wd->show_item = NULL;
4121 if ((it->item->group_item) && (it->wd->pan_y > (it->y + it->item->block->y)))
4122 gith = it->item->group_item->item->h;
4123 elm_smart_scroller_child_region_show(it->wd->scr,
4124 it->x + it->item->block->x,
4125 it->y + it->item->block->y - gith,
4126 it->item->block->w, it->item->h);
4130 elm_genlist_item_bring_in(Elm_Gen_Item *it)
4132 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4133 Evas_Coord gith = 0;
4134 if (it->delete_me) return;
4135 if ((it->item->queued) || (!it->item->mincalcd))
4137 it->wd->show_item = it;
4138 it->wd->bring_in = EINA_TRUE;
4139 it->item->showme = EINA_TRUE;
4142 if (it->wd->show_item)
4144 it->wd->show_item->item->showme = EINA_FALSE;
4145 it->wd->show_item = NULL;
4147 if ((it->item->group_item) && (it->wd->pan_y > (it->y + it->item->block->y)))
4148 gith = it->item->group_item->item->h;
4149 elm_smart_scroller_region_bring_in(it->wd->scr,
4150 it->x + it->item->block->x,
4151 it->y + it->item->block->y - gith,
4152 it->item->block->w, it->item->h);
4156 elm_genlist_item_top_show(Elm_Gen_Item *it)
4158 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4160 Evas_Coord gith = 0;
4162 if (it->delete_me) return;
4163 if ((it->item->queued) || (!it->item->mincalcd))
4165 it->wd->show_item = it;
4166 it->wd->bring_in = EINA_TRUE;
4167 it->item->showme = EINA_TRUE;
4170 if (it->wd->show_item)
4172 it->wd->show_item->item->showme = EINA_FALSE;
4173 it->wd->show_item = NULL;
4175 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4176 if (it->item->group_item) gith = it->item->group_item->item->h;
4177 elm_smart_scroller_child_region_show(it->wd->scr,
4178 it->x + it->item->block->x,
4179 it->y + it->item->block->y - gith,
4180 it->item->block->w, oh);
4184 elm_genlist_item_top_bring_in(Elm_Gen_Item *it)
4186 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4188 Evas_Coord gith = 0;
4190 if (it->delete_me) return;
4191 if ((it->item->queued) || (!it->item->mincalcd))
4193 it->wd->show_item = it;
4194 it->wd->bring_in = EINA_TRUE;
4195 it->item->showme = EINA_TRUE;
4198 if (it->wd->show_item)
4200 it->wd->show_item->item->showme = EINA_FALSE;
4201 it->wd->show_item = NULL;
4203 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4204 if (it->item->group_item) gith = it->item->group_item->item->h;
4205 elm_smart_scroller_region_bring_in(it->wd->scr,
4206 it->x + it->item->block->x,
4207 it->y + it->item->block->y - gith,
4208 it->item->block->w, oh);
4212 elm_genlist_item_middle_show(Elm_Gen_Item *it)
4214 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4217 if (it->delete_me) return;
4218 if ((it->item->queued) || (!it->item->mincalcd))
4220 it->wd->show_item = it;
4221 it->wd->bring_in = EINA_TRUE;
4222 it->item->showme = EINA_TRUE;
4225 if (it->wd->show_item)
4227 it->wd->show_item->item->showme = EINA_FALSE;
4228 it->wd->show_item = NULL;
4230 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4231 elm_smart_scroller_child_region_show(it->wd->scr,
4232 it->x + it->item->block->x,
4233 it->y + it->item->block->y - oh / 2 +
4234 it->item->h / 2, it->item->block->w, oh);
4238 elm_genlist_item_middle_bring_in(Elm_Gen_Item *it)
4240 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4243 if (it->delete_me) return;
4244 if ((it->item->queued) || (!it->item->mincalcd))
4246 it->wd->show_item = it;
4247 it->wd->bring_in = EINA_TRUE;
4248 it->item->showme = EINA_TRUE;
4251 if (it->wd->show_item)
4253 it->wd->show_item->item->showme = EINA_FALSE;
4254 it->wd->show_item = NULL;
4256 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4257 elm_smart_scroller_region_bring_in(it->wd->scr,
4258 it->x + it->item->block->x,
4259 it->y + it->item->block->y - oh / 2 + it->item->h / 2,
4260 it->item->block->w, oh);
4264 elm_genlist_item_del(Elm_Gen_Item *it)
4266 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4267 if ((it->relcount > 0) || (it->walking > 0))
4269 elm_genlist_item_subitems_clear(it);
4270 if (it->wd->show_item == it) it->wd->show_item = NULL;
4271 elm_gen_item_del_notserious(it);
4272 if (it->item->block)
4274 if (it->realized) elm_gen_item_unrealize(it, EINA_FALSE, (Ecore_Cb)_item_unrealize_cb);
4275 it->item->block->changed = EINA_TRUE;
4276 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4277 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4285 elm_genlist_item_data_set(Elm_Gen_Item *it,
4288 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4289 elm_widget_item_data_set(it, data);
4293 elm_genlist_item_data_get(const Elm_Gen_Item *it)
4295 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4296 return elm_widget_item_data_get(it);
4300 elm_genlist_item_icons_orphan(Elm_Gen_Item *it)
4303 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4304 EINA_LIST_FREE(it->icon_objs, icon)
4306 elm_widget_sub_object_del(WIDGET(it), icon);
4307 evas_object_smart_member_del(icon);
4308 evas_object_hide(icon);
4312 EAPI const Evas_Object *
4313 elm_genlist_item_object_get(const Elm_Gen_Item *it)
4315 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4320 elm_genlist_item_update(Elm_Gen_Item *it)
4322 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4323 if (!it->item->block) return;
4324 if (it->delete_me) return;
4325 it->item->mincalcd = EINA_FALSE;
4326 it->item->updateme = EINA_TRUE;
4327 it->item->block->updateme = EINA_TRUE;
4328 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4329 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4333 elm_genlist_item_item_class_update(Elm_Gen_Item *it,
4334 const Elm_Genlist_Item_Class *itc)
4336 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4337 if (!it->item->block) return;
4338 EINA_SAFETY_ON_NULL_RETURN(itc);
4339 if (it->delete_me) return;
4341 it->item->nocache = EINA_TRUE;
4342 elm_genlist_item_update(it);
4345 EAPI const Elm_Genlist_Item_Class *
4346 elm_genlist_item_item_class_get(const Elm_Gen_Item *it)
4348 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4349 if (it->delete_me) return NULL;
4353 static Evas_Object *
4354 _elm_genlist_item_label_create(void *data,
4355 Evas_Object *obj __UNUSED__,
4356 Evas_Object *tooltip,
4357 void *it __UNUSED__)
4359 Evas_Object *label = elm_label_add(tooltip);
4362 elm_object_style_set(label, "tooltip");
4363 elm_object_text_set(label, data);
4368 _elm_genlist_item_label_del_cb(void *data,
4369 Evas_Object *obj __UNUSED__,
4370 void *event_info __UNUSED__)
4372 eina_stringshare_del(data);
4376 elm_genlist_item_tooltip_text_set(Elm_Gen_Item *it,
4379 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4380 text = eina_stringshare_add(text);
4381 elm_genlist_item_tooltip_content_cb_set(it, _elm_genlist_item_label_create,
4383 _elm_genlist_item_label_del_cb);
4387 elm_genlist_item_tooltip_content_cb_set(Elm_Gen_Item *it,
4388 Elm_Tooltip_Item_Content_Cb func,
4390 Evas_Smart_Cb del_cb)
4392 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(it, error);
4394 if ((it->tooltip.content_cb == func) && (it->tooltip.data == data))
4397 if (it->tooltip.del_cb)
4398 it->tooltip.del_cb((void *)it->tooltip.data,
4401 it->tooltip.content_cb = func;
4402 it->tooltip.data = data;
4403 it->tooltip.del_cb = del_cb;
4407 elm_widget_item_tooltip_content_cb_set(it,
4408 it->tooltip.content_cb,
4409 it->tooltip.data, NULL);
4410 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
4411 elm_widget_item_tooltip_size_restrict_disable(it, it->tooltip.free_size);
4417 if (del_cb) del_cb((void *)data, NULL, NULL);
4421 elm_genlist_item_tooltip_unset(Elm_Gen_Item *it)
4423 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4424 if ((VIEW(it)) && (it->tooltip.content_cb))
4425 elm_widget_item_tooltip_unset(it);
4427 if (it->tooltip.del_cb)
4428 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
4429 it->tooltip.del_cb = NULL;
4430 it->tooltip.content_cb = NULL;
4431 it->tooltip.data = NULL;
4432 it->tooltip.free_size = EINA_FALSE;
4433 if (it->tooltip.style)
4434 elm_genlist_item_tooltip_style_set(it, NULL);
4438 elm_genlist_item_tooltip_style_set(Elm_Gen_Item *it,
4441 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4442 eina_stringshare_replace(&it->tooltip.style, style);
4443 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
4447 elm_genlist_item_tooltip_style_get(const Elm_Gen_Item *it)
4449 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4450 return it->tooltip.style;
4454 elm_genlist_item_tooltip_size_restrict_disable(Elm_Gen_Item *it, Eina_Bool disable)
4456 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4457 it->tooltip.free_size = disable;
4458 if (VIEW(it)) return elm_widget_item_tooltip_size_restrict_disable(it, disable);
4463 elm_genlist_item_tooltip_size_restrict_disabled_get(const Elm_Gen_Item *it)
4465 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4466 return it->tooltip.free_size;
4470 elm_genlist_item_cursor_set(Elm_Gen_Item *it,
4473 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4474 eina_stringshare_replace(&it->mouse_cursor, cursor);
4475 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
4479 elm_genlist_item_cursor_get(const Elm_Gen_Item *it)
4481 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4482 return elm_widget_item_cursor_get(it);
4486 elm_genlist_item_cursor_unset(Elm_Gen_Item *it)
4488 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4489 if (!it->mouse_cursor)
4493 elm_widget_item_cursor_unset(it);
4495 eina_stringshare_del(it->mouse_cursor);
4496 it->mouse_cursor = NULL;
4500 elm_genlist_item_cursor_style_set(Elm_Gen_Item *it,
4503 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4504 elm_widget_item_cursor_style_set(it, style);
4508 elm_genlist_item_cursor_style_get(const Elm_Gen_Item *it)
4510 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4511 return elm_widget_item_cursor_style_get(it);
4515 elm_genlist_item_cursor_engine_only_set(Elm_Gen_Item *it,
4516 Eina_Bool engine_only)
4518 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4519 elm_widget_item_cursor_engine_only_set(it, engine_only);
4523 elm_genlist_item_cursor_engine_only_get(const Elm_Gen_Item *it)
4525 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4526 return elm_widget_item_cursor_engine_only_get(it);
4530 elm_genlist_horizontal_set(Evas_Object *obj,
4533 ELM_CHECK_WIDTYPE(obj, widtype);
4534 Widget_Data *wd = elm_widget_data_get(obj);
4536 if (wd->mode == mode) return;
4542 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4545 elm_genlist_horizontal_set(obj, mode);
4549 elm_genlist_horizontal_get(const Evas_Object *obj)
4551 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4552 Widget_Data *wd = elm_widget_data_get(obj);
4553 if (!wd) return ELM_LIST_LAST;
4558 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4560 return elm_genlist_horizontal_get(obj);
4564 elm_genlist_always_select_mode_set(Evas_Object *obj,
4565 Eina_Bool always_select)
4567 ELM_CHECK_WIDTYPE(obj, widtype);
4568 Widget_Data *wd = elm_widget_data_get(obj);
4570 wd->always_select = always_select;
4574 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4576 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4577 Widget_Data *wd = elm_widget_data_get(obj);
4578 if (!wd) return EINA_FALSE;
4579 return wd->always_select;
4583 elm_genlist_no_select_mode_set(Evas_Object *obj,
4584 Eina_Bool no_select)
4586 ELM_CHECK_WIDTYPE(obj, widtype);
4587 Widget_Data *wd = elm_widget_data_get(obj);
4589 wd->no_select = no_select;
4593 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4595 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4596 Widget_Data *wd = elm_widget_data_get(obj);
4597 if (!wd) return EINA_FALSE;
4598 return wd->no_select;
4602 elm_genlist_compress_mode_set(Evas_Object *obj,
4605 ELM_CHECK_WIDTYPE(obj, widtype);
4606 Widget_Data *wd = elm_widget_data_get(obj);
4608 wd->compress = compress;
4609 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
4613 elm_genlist_compress_mode_get(const Evas_Object *obj)
4615 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4616 Widget_Data *wd = elm_widget_data_get(obj);
4617 if (!wd) return EINA_FALSE;
4618 return wd->compress;
4622 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4623 Eina_Bool height_for_width)
4625 ELM_CHECK_WIDTYPE(obj, widtype);
4626 Widget_Data *wd = elm_widget_data_get(obj);
4628 wd->height_for_width = !!height_for_width;
4629 if (wd->height_for_width)
4631 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4632 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4637 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4639 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4640 Widget_Data *wd = elm_widget_data_get(obj);
4641 if (!wd) return EINA_FALSE;
4642 return wd->height_for_width;
4646 elm_genlist_bounce_set(Evas_Object *obj,
4650 ELM_CHECK_WIDTYPE(obj, widtype);
4651 Widget_Data *wd = elm_widget_data_get(obj);
4653 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4657 elm_genlist_bounce_get(const Evas_Object *obj,
4658 Eina_Bool *h_bounce,
4659 Eina_Bool *v_bounce)
4661 ELM_CHECK_WIDTYPE(obj, widtype);
4662 Widget_Data *wd = elm_widget_data_get(obj);
4664 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
4668 elm_genlist_homogeneous_set(Evas_Object *obj,
4669 Eina_Bool homogeneous)
4671 ELM_CHECK_WIDTYPE(obj, widtype);
4672 Widget_Data *wd = elm_widget_data_get(obj);
4674 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4675 wd->homogeneous = homogeneous;
4679 elm_genlist_homogeneous_get(const Evas_Object *obj)
4681 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4682 Widget_Data *wd = elm_widget_data_get(obj);
4683 if (!wd) return EINA_FALSE;
4684 return wd->homogeneous;
4688 elm_genlist_block_count_set(Evas_Object *obj,
4691 ELM_CHECK_WIDTYPE(obj, widtype);
4692 Widget_Data *wd = elm_widget_data_get(obj);
4694 wd->max_items_per_block = n;
4695 wd->item_cache_max = wd->max_items_per_block * 2;
4696 _item_cache_clean(wd);
4700 elm_genlist_block_count_get(const Evas_Object *obj)
4702 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4703 Widget_Data *wd = elm_widget_data_get(obj);
4705 return wd->max_items_per_block;
4709 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4712 ELM_CHECK_WIDTYPE(obj, widtype);
4713 Widget_Data *wd = elm_widget_data_get(obj);
4715 wd->longpress_timeout = timeout;
4719 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4721 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4722 Widget_Data *wd = elm_widget_data_get(obj);
4724 return wd->longpress_timeout;
4728 elm_genlist_scroller_policy_set(Evas_Object *obj,
4729 Elm_Scroller_Policy policy_h,
4730 Elm_Scroller_Policy policy_v)
4732 ELM_CHECK_WIDTYPE(obj, widtype);
4733 Widget_Data *wd = elm_widget_data_get(obj);
4734 if ((!wd) || (!wd->scr)) return;
4735 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4736 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4738 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4742 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4743 Elm_Scroller_Policy *policy_h,
4744 Elm_Scroller_Policy *policy_v)
4746 ELM_CHECK_WIDTYPE(obj, widtype);
4747 Widget_Data *wd = elm_widget_data_get(obj);
4748 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4749 if ((!wd) || (!wd->scr)) return;
4750 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4751 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4752 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
4756 elm_genlist_realized_items_update(Evas_Object *obj)
4758 ELM_CHECK_WIDTYPE(obj, widtype);
4760 Eina_List *list, *l;
4763 list = elm_genlist_realized_items_get(obj);
4764 EINA_LIST_FOREACH(list, l, it)
4765 elm_genlist_item_update(it);
4769 elm_genlist_item_mode_set(Elm_Gen_Item *it,
4770 const char *mode_type,
4773 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4774 Widget_Data *wd = it->wd;
4779 if (!mode_type) return;
4780 if ((it->delete_me) || (it->disabled)) return;
4782 if ((wd->mode_item == it) &&
4783 (!strcmp(mode_type, wd->mode_type)) &&
4786 if (!wd->mode_item_style) return;
4790 EINA_LIST_FOREACH(wd->selected, l, it2)
4792 elm_genlist_item_selected_set(it2, EINA_FALSE);
4796 it2 = elm_genlist_selected_item_get(wd->obj);
4797 if ((it2) && (it2->realized))
4798 elm_genlist_item_selected_set(it2, EINA_FALSE);
4801 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
4803 ((it == wd->mode_item) && (!mode_set)))
4804 _item_mode_unset(wd);
4806 eina_stringshare_replace(&wd->mode_type, mode_type);
4807 if (mode_set) _item_mode_set(it);
4812 elm_genlist_mode_item_style_get(const Evas_Object *obj)
4814 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4815 Widget_Data *wd = elm_widget_data_get(obj);
4816 if (!wd) return NULL;
4817 return wd->mode_item_style;
4821 elm_genlist_mode_item_style_set(Evas_Object *obj, const char *style)
4823 ELM_CHECK_WIDTYPE(obj, widtype);
4824 Widget_Data *wd = elm_widget_data_get(obj);
4826 if ((style == wd->mode_item_style) || (style && wd->mode_item_style &&
4827 (!strcmp(style, wd->mode_item_style))))
4829 eina_stringshare_replace(&wd->mode_item_style, style);
4830 elm_genlist_realized_items_update(obj);
4834 elm_genlist_mode_get(const Evas_Object *obj)
4836 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4837 Widget_Data *wd = elm_widget_data_get(obj);
4838 if (!wd) return NULL;
4839 return wd->mode_type;
4842 EAPI const Elm_Gen_Item *
4843 elm_genlist_mode_item_get(const Evas_Object *obj)
4845 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4846 Widget_Data *wd = elm_widget_data_get(obj);
4847 if (!wd) return NULL;
4848 return wd->mode_item;
4852 elm_genlist_reorder_mode_set(Evas_Object *obj,
4853 Eina_Bool reorder_mode)
4855 ELM_CHECK_WIDTYPE(obj, widtype);
4856 Widget_Data *wd = elm_widget_data_get(obj);
4858 wd->reorder_mode = reorder_mode;
4862 elm_genlist_reorder_mode_get(const Evas_Object *obj)
4864 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4865 Widget_Data *wd = elm_widget_data_get(obj);
4866 if (!wd) return EINA_FALSE;
4867 return wd->reorder_mode;