3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
6 #include "els_scroller.h"
8 #include "elm_genlist.h"
10 #define SWIPE_MOVES 12
11 #define MAX_ITEMS_PER_BLOCK 32
12 #define REORDER_EFFECT_TIME 0.5
14 #define ELM_GEN_SETUP(wd) \
15 (wd)->calc_cb = (Ecore_Cb)_calc_job; \
16 (wd)->clear_cb = (Ecore_Cb)_clear_cb; \
17 (wd)->sizing_cb = (Ecore_Cb)_sizing_eval
19 #define ELM_GEN_ITEM_SETUP(it) \
20 (it)->del_cb = (Ecore_Cb)_item_del; \
21 (it)->highlight_cb = (Ecore_Cb)_item_highlight; \
22 (it)->unsel_cb = (Ecore_Cb)_item_unselect; \
23 (it)->unhighlight_cb = (Ecore_Cb)_item_unhighlight; \
24 (it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
26 typedef struct _Item_Block Item_Block;
27 typedef struct _Item_Cache Item_Cache;
29 struct Elm_Gen_Item_Type
34 Evas_Coord w, h, minw, minh;
35 Elm_Gen_Item *group_item;
36 Elm_Genlist_Item_Flags flags;
37 Eina_List *mode_labels, *mode_contents, *mode_states, *mode_content_objs;
38 Ecore_Timer *swipe_timer;
39 Evas_Coord scrl_x, scrl_y, old_scrl_y;
42 Evas_Object *mode_view;
48 Eina_Bool want_realize : 1;
49 Eina_Bool expanded : 1;
50 Eina_Bool mincalcd : 1;
53 Eina_Bool updateme : 1;
54 Eina_Bool nocache : 1;
55 Eina_Bool stacking_even : 1;
56 Eina_Bool nostacking : 1;
57 Eina_Bool move_effect_enabled : 1;
62 Eina_Inlist_Sorted_State *state;
63 Evas_Object *obj; /* the genlist object */
64 Evas_Object *scr; /* a smart scroller object which is used internally in genlist */
65 Evas_Object *pan_smart; /* "elm_genlist_pan" evas smart object. this is an extern pan of smart scroller(scr). */
67 Eina_List *group_items; /* list of groups index items */
68 Eina_Inlist *items; /* inlist of all items */
69 Elm_Gen_Item *reorder_it; /* item currently being repositioned */
70 Elm_Gen_Item *last_selected_item;
71 Pan *pan; /* pan_smart object's smart data */
74 int item_width, item_height;
75 int group_item_width, group_item_height;
78 Evas_Coord pan_x, pan_y;
79 Eina_Bool reorder_mode : 1; /* a flag for reorder mode enable/disable */
80 Eina_Bool on_hold : 1;
81 Eina_Bool multi : 1; /* a flag for item multi selection */
82 Eina_Bool no_select : 1;
83 Eina_Bool wasselected : 1;
84 Eina_Bool always_select : 1;
85 Eina_Bool clear_me : 1;
86 Eina_Bool h_bounce : 1;
87 Eina_Bool v_bounce : 1;
88 Ecore_Cb del_cb, calc_cb, sizing_cb;
90 ////////////////////////////////////
91 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'. */
92 Evas_Coord reorder_old_pan_y, w, h, realminw, prev_viewport_w;
93 Ecore_Job *update_job;
94 Ecore_Idle_Enterer *queue_idle_enterer;
95 Ecore_Idler *must_recalc_idler;
97 Elm_Gen_Item *show_item, *anchor_item, *mode_item, *reorder_rel, *expanded_item;
98 Eina_Inlist *item_cache; /* an inlist of edje object it cache. */
100 Evas_Coord reorder_start_y; /* reorder it's initial y coordinate in the pan. */
102 Ecore_Timer *multi_timer, *scr_hold_timer;
103 Ecore_Animator *reorder_move_animator;
104 const char *mode_type;
105 const char *mode_item_style;
106 unsigned int start_time;
107 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
108 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
109 Eina_Bool mouse_down : 1;
110 Eina_Bool multi_down : 1;
111 Eina_Bool multi_timeout : 1;
112 Eina_Bool multitouched : 1;
113 Eina_Bool longpressed : 1;
114 Eina_Bool bring_in : 1;
115 Eina_Bool compress : 1;
116 Eina_Bool height_for_width : 1;
117 Eina_Bool homogeneous : 1;
119 Eina_Bool reorder_pan_move : 1;
120 Eina_Bool auto_scroll_enabled : 1;
121 Eina_Bool pan_resized : 1;
125 } history[SWIPE_MOVES];
127 int item_cache_count;
128 int item_cache_max; /* maximum number of cached items */
130 int max_items_per_block; /* maximum number of items per block */
131 double longpress_timeout; /* longpress timeout. this value comes from _elm_config by default. this can be changed by elm_genlist_longpress_timeout_set() */
142 Evas_Coord x, y, w, h, minw, minh;
143 Eina_Bool want_unrealize : 1;
144 Eina_Bool realized : 1;
145 Eina_Bool changed : 1;
146 Eina_Bool updateme : 1;
147 Eina_Bool showme : 1;
148 Eina_Bool must_recalc : 1;
155 Evas_Object *base_view, *spacer;
157 const char *item_style; // it->itc->item_style
158 Eina_Bool tree : 1; // it->group
159 Eina_Bool compress : 1; // it->wd->compress
161 Eina_Bool selected : 1; // it->selected
162 Eina_Bool disabled : 1; // it->disabled
163 Eina_Bool expanded : 1; // it->item->expanded
166 static const char *widtype = NULL;
167 static void _item_cache_zero(Widget_Data *wd);
168 static void _del_hook(Evas_Object *obj);
169 static void _mirrored_set(Evas_Object *obj,
171 static void _theme_hook(Evas_Object *obj);
172 static void _show_region_hook(void *data,
174 static void _sizing_eval(Evas_Object *obj);
175 static void _item_realize(Elm_Gen_Item *it,
178 static void _item_unrealize_cb(Elm_Gen_Item *it);
179 static void _item_block_unrealize(Item_Block *itb);
180 static void _calc_job(void *data);
181 static void _on_focus_hook(void *data,
183 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
184 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
185 static Eina_Bool _item_single_select_up(Widget_Data *wd);
186 static Eina_Bool _item_single_select_down(Widget_Data *wd);
187 static Eina_Bool _event_hook(Evas_Object *obj,
189 Evas_Callback_Type type,
191 static void _signal_emit_hook(Evas_Object *obj,
192 const char *emission,
194 static Eina_Bool _deselect_all_items(Widget_Data *wd);
195 static void _pan_calculate(Evas_Object *obj);
196 static void _pan_max_get(Evas_Object *obj,
199 static void _item_position(Elm_Gen_Item *it,
203 static void _mode_item_realize(Elm_Gen_Item *it);
204 static void _mode_item_unrealize(Elm_Gen_Item *it);
205 static void _item_mode_set(Elm_Gen_Item *it);
206 static void _item_mode_unset(Widget_Data *wd);
207 static void _group_items_recalc(void *data);
208 static void _item_move_after(Elm_Gen_Item *it,
209 Elm_Gen_Item *after);
210 static void _item_move_before(Elm_Gen_Item *it,
211 Elm_Gen_Item *before);
212 static void _item_auto_scroll(Widget_Data *wd);
214 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
216 static const char SIG_ACTIVATED[] = "activated";
217 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
218 static const char SIG_SELECTED[] = "selected";
219 static const char SIG_UNSELECTED[] = "unselected";
220 static const char SIG_EXPANDED[] = "expanded";
221 static const char SIG_CONTRACTED[] = "contracted";
222 static const char SIG_EXPAND_REQUEST[] = "expand,request";
223 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
224 static const char SIG_REALIZED[] = "realized";
225 static const char SIG_UNREALIZED[] = "unrealized";
226 static const char SIG_DRAG_START_UP[] = "drag,start,up";
227 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
228 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
229 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
230 static const char SIG_DRAG_STOP[] = "drag,stop";
231 static const char SIG_DRAG[] = "drag";
232 static const char SIG_LONGPRESSED[] = "longpressed";
233 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
234 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
235 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
236 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
237 static const char SIG_EDGE_TOP[] = "edge,top";
238 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
239 static const char SIG_EDGE_LEFT[] = "edge,left";
240 static const char SIG_EDGE_RIGHT[] = "edge,right";
241 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
242 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
243 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
244 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
245 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
246 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
247 static const char SIG_SWIPE[] = "swipe";
248 static const char SIG_MOVED[] = "moved";
250 static const Evas_Smart_Cb_Description _signals[] = {
251 {SIG_CLICKED_DOUBLE, ""},
254 {SIG_UNSELECTED, ""},
256 {SIG_CONTRACTED, ""},
257 {SIG_EXPAND_REQUEST, ""},
258 {SIG_CONTRACT_REQUEST, ""},
260 {SIG_UNREALIZED, ""},
261 {SIG_DRAG_START_UP, ""},
262 {SIG_DRAG_START_DOWN, ""},
263 {SIG_DRAG_START_LEFT, ""},
264 {SIG_DRAG_START_RIGHT, ""},
267 {SIG_LONGPRESSED, ""},
268 {SIG_SCROLL_ANIM_START, ""},
269 {SIG_SCROLL_ANIM_STOP, ""},
270 {SIG_SCROLL_DRAG_START, ""},
271 {SIG_SCROLL_DRAG_STOP, ""},
273 {SIG_EDGE_BOTTOM, ""},
275 {SIG_EDGE_RIGHT, ""},
276 {SIG_MULTI_SWIPE_LEFT, ""},
277 {SIG_MULTI_SWIPE_RIGHT, ""},
278 {SIG_MULTI_SWIPE_UP, ""},
279 {SIG_MULTI_SWIPE_DOWN, ""},
280 {SIG_MULTI_PINCH_OUT, ""},
281 {SIG_MULTI_PINCH_IN, ""},
287 static Eina_Compare_Cb _elm_genlist_item_compare_cb;
288 static Eina_Compare_Cb _elm_genlist_item_compare_data_cb;
291 #undef ELM_CHECK_WIDTYPE
292 #define ELM_CHECK_WIDTYPE(obj, widtype) \
293 if ((!obj) || (!elm_genlist_type_check((obj), __func__))) return
294 #undef ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN
295 #define ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, ...) \
296 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
297 ELM_CHECK_WIDTYPE(WIDGET((it)), widtype) __VA_ARGS__;
299 static const char *_gengrid = NULL;
300 static const char *_genlist = NULL;
302 /* THIS FUNCTION IS HACKY AND TEMPORARY!!! */
304 elm_genlist_type_check(const Evas_Object *obj,
307 const char *provided, *expected = "(unknown)";
308 static int abort_on_warn = -1;
309 provided = elm_widget_type_get(obj);
310 if (!_genlist) _genlist = eina_stringshare_add("genlist");
311 if (!_gengrid) _gengrid = eina_stringshare_add("gengrid");
312 if (EINA_LIKELY(provided == _genlist) || EINA_LIKELY(provided == _gengrid))
314 if ((!provided) || (!provided[0]))
316 provided = evas_object_type_get(obj);
317 if ((!provided) || (!provided[0]))
318 provided = "(unknown)";
320 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
321 if (abort_on_warn == -1)
323 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
324 else abort_on_warn = 0;
326 if (abort_on_warn == 1) abort();
331 _event_hook(Evas_Object *obj,
332 Evas_Object *src __UNUSED__,
333 Evas_Callback_Type type,
336 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
337 Evas_Event_Key_Down *ev = event_info;
338 Widget_Data *wd = elm_widget_data_get(obj);
339 Evas_Coord pan_max_x = 0, pan_max_y = 0;
340 if (!wd) return EINA_FALSE;
341 if (!wd->items) return EINA_FALSE;
342 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
343 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
345 Elm_Gen_Item *it = NULL;
348 Evas_Coord step_x = 0;
349 Evas_Coord step_y = 0;
352 Evas_Coord page_x = 0;
353 Evas_Coord page_y = 0;
355 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
356 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
357 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
358 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
360 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
364 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
368 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
370 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
371 (_item_multi_select_up(wd)))
372 || (_item_single_select_up(wd)))
374 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
380 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
382 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
383 (_item_multi_select_down(wd)))
384 || (_item_single_select_down(wd)))
386 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
392 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
394 it = elm_genlist_first_item_get(obj);
395 elm_genlist_item_bring_in(it);
396 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
399 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
401 it = elm_genlist_last_item_get(obj);
402 elm_genlist_item_bring_in(it);
403 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
406 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
409 y -= -(page_y * v_h) / 100;
413 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
416 y += -(page_y * v_h) / 100;
420 else if (!strcmp(ev->keyname, "Escape"))
422 if (!_deselect_all_items(wd)) return EINA_FALSE;
423 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
426 else if (((!strcmp(ev->keyname, "Return")) ||
427 (!strcmp(ev->keyname, "KP_Enter")) ||
428 (!strcmp(ev->keyname, "space")))
429 && (!wd->multi) && (wd->selected))
431 it = elm_genlist_selected_item_get(obj);
432 elm_genlist_item_expanded_set(it,
433 !elm_genlist_item_expanded_get(it));
434 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
436 else return EINA_FALSE;
438 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
439 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
441 if (x > pan_max_x) x = pan_max_x;
443 if (y > pan_max_y) y = pan_max_y;
444 elm_smart_scroller_child_pos_set(wd->scr, x, y);
449 _deselect_all_items(Widget_Data *wd)
451 if (!wd->selected) return EINA_FALSE;
453 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
459 _item_multi_select_up(Widget_Data *wd)
461 if (!wd->selected) return EINA_FALSE;
462 if (!wd->multi) return EINA_FALSE;
464 Elm_Gen_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
465 if (!prev) return EINA_TRUE;
467 if (elm_genlist_item_selected_get(prev))
469 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
470 wd->last_selected_item = prev;
471 elm_genlist_item_show(wd->last_selected_item);
475 elm_genlist_item_selected_set(prev, EINA_TRUE);
476 elm_genlist_item_show(prev);
482 _item_multi_select_down(Widget_Data *wd)
484 if (!wd->selected) return EINA_FALSE;
485 if (!wd->multi) return EINA_FALSE;
487 Elm_Gen_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
488 if (!next) return EINA_TRUE;
490 if (elm_genlist_item_selected_get(next))
492 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
493 wd->last_selected_item = next;
494 elm_genlist_item_show(wd->last_selected_item);
498 elm_genlist_item_selected_set(next, EINA_TRUE);
499 elm_genlist_item_show(next);
505 _item_single_select_up(Widget_Data *wd)
510 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
511 while ((prev) && (prev->delete_me))
512 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
514 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
516 if (!prev) return EINA_FALSE;
518 _deselect_all_items(wd);
520 elm_genlist_item_selected_set(prev, EINA_TRUE);
521 elm_genlist_item_show(prev);
526 _item_single_select_down(Widget_Data *wd)
531 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
532 while ((next) && (next->delete_me))
533 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
535 else next = elm_genlist_item_next_get(wd->last_selected_item);
537 if (!next) return EINA_FALSE;
539 _deselect_all_items(wd);
541 elm_genlist_item_selected_set(next, EINA_TRUE);
542 elm_genlist_item_show(next);
547 _on_focus_hook(void *data __UNUSED__,
550 Widget_Data *wd = elm_widget_data_get(obj);
552 if (elm_widget_focus_get(obj))
554 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
555 evas_object_focus_set(wd->obj, EINA_TRUE);
556 if ((wd->selected) && (!wd->last_selected_item))
557 wd->last_selected_item = eina_list_data_get(wd->selected);
561 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
562 evas_object_focus_set(wd->obj, EINA_FALSE);
567 _del_hook(Evas_Object *obj)
569 Widget_Data *wd = elm_widget_data_get(obj);
571 _item_cache_zero(wd);
572 if (wd->calc_job) ecore_job_del(wd->calc_job);
573 if (wd->update_job) ecore_job_del(wd->update_job);
574 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
575 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
576 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
577 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
578 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
583 _del_pre_hook(Evas_Object *obj)
585 Widget_Data *wd = elm_widget_data_get(obj);
587 elm_genlist_clear(obj);
588 evas_object_del(wd->pan_smart);
589 wd->pan_smart = NULL;
593 _mirrored_set(Evas_Object *obj,
596 Widget_Data *wd = elm_widget_data_get(obj);
598 _item_cache_zero(wd);
599 elm_smart_scroller_mirrored_set(wd->scr, rtl);
603 _theme_hook(Evas_Object *obj)
605 Widget_Data *wd = elm_widget_data_get(obj);
608 evas_event_freeze(evas_object_evas_get(wd->obj));
609 _item_cache_zero(wd);
610 _elm_widget_mirrored_reload(obj);
611 _mirrored_set(obj, elm_widget_mirrored_get(obj));
612 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
613 elm_widget_style_get(obj));
614 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
615 wd->item_width = wd->item_height = 0;
616 wd->group_item_width = wd->group_item_height = 0;
617 wd->minw = wd->minh = wd->realminw = 0;
618 EINA_INLIST_FOREACH(wd->blocks, itb)
623 if (itb->realized) _item_block_unrealize(itb);
624 EINA_LIST_FOREACH(itb->items, l, it)
625 it->item->mincalcd = EINA_FALSE;
627 itb->changed = EINA_TRUE;
629 if (wd->calc_job) ecore_job_del(wd->calc_job);
630 wd->calc_job = ecore_job_add(_calc_job, wd);
632 evas_event_thaw(evas_object_evas_get(wd->obj));
633 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
637 _show_region_hook(void *data,
640 Widget_Data *wd = elm_widget_data_get(data);
641 Evas_Coord x, y, w, h;
643 elm_widget_show_region_get(obj, &x, &y, &w, &h);
644 //x & y are screen coordinates, Add with pan coordinates
647 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
651 _translate_hook(Evas_Object *obj)
653 evas_object_smart_callback_call(obj, "language,changed", NULL);
657 _sizing_eval(Evas_Object *obj)
659 Widget_Data *wd = elm_widget_data_get(obj);
660 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
662 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
663 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
665 if (wd->height_for_width)
669 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
670 if ((vw != 0) && (vw != wd->prev_viewport_w))
674 wd->prev_viewport_w = vw;
675 EINA_INLIST_FOREACH(wd->blocks, itb)
677 itb->must_recalc = EINA_TRUE;
679 if (wd->calc_job) ecore_job_del(wd->calc_job);
680 wd->calc_job = ecore_job_add(_calc_job, wd);
683 if (wd->mode == ELM_LIST_LIMIT)
689 edje_object_size_min_calc
690 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
697 edje_object_size_min_calc
698 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
702 evas_object_size_hint_min_set(obj, minw, minh);
703 evas_object_size_hint_max_set(obj, maxw, maxh);
707 _signal_emit_hook(Evas_Object *obj,
708 const char *emission,
711 Widget_Data *wd = elm_widget_data_get(obj);
712 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
717 _item_highlight(Elm_Gen_Item *it)
719 const char *selectraise;
720 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
721 (it->disabled) || (it->display_only) || (it->item->mode_view))
723 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
724 selectraise = edje_object_data_get(VIEW(it), "selectraise");
725 if ((selectraise) && (!strcmp(selectraise, "on")))
727 evas_object_raise(VIEW(it));
728 if ((it->item->group_item) && (it->item->group_item->realized))
729 evas_object_raise(it->item->VIEW(group_item));
731 it->highlighted = EINA_TRUE;
735 _item_unhighlight(Elm_Gen_Item *it)
737 if ((it->delete_me) || (!it->highlighted)) return;
738 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
739 if (!it->item->nostacking)
741 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even) evas_object_lower(VIEW(it));
742 else evas_object_raise(VIEW(it));
744 it->highlighted = EINA_FALSE;
748 _item_block_del(Elm_Gen_Item *it)
751 Item_Block *itb = it->item->block;
753 itb->items = eina_list_remove(itb->items, it);
755 itb->changed = EINA_TRUE;
756 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
757 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
760 il = EINA_INLIST_GET(itb);
761 Item_Block *itbn = (Item_Block *)(il->next);
763 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
765 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
767 if (itbn) itbn->changed = EINA_TRUE;
771 if (itb->count < itb->wd->max_items_per_block/2)
773 il = EINA_INLIST_GET(itb);
774 Item_Block *itbp = (Item_Block *)(il->prev);
775 Item_Block *itbn = (Item_Block *)(il->next);
776 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
780 EINA_LIST_FREE(itb->items, it2)
782 it2->item->block = itbp;
783 itbp->items = eina_list_append(itbp->items, it2);
785 itbp->changed = EINA_TRUE;
787 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
788 EINA_INLIST_GET(itb));
791 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
795 Eina_List *last = eina_list_last(itb->items);
796 Elm_Gen_Item *it2 = last->data;
798 it2->item->block = itbn;
799 itb->items = eina_list_remove_list(itb->items, last);
800 itbn->items = eina_list_prepend(itbn->items, it2);
802 itbn->changed = EINA_TRUE;
805 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
813 _item_del(Elm_Gen_Item *it)
815 Evas_Object *obj = WIDGET(it);
817 evas_event_freeze(evas_object_evas_get(obj));
818 elm_genlist_item_subitems_clear(it);
819 if (it->wd->show_item == it) it->wd->show_item = NULL;
820 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
821 if (it->item->block) _item_block_del(it);
822 if (it->item->queued)
823 it->wd->queue = eina_list_remove(it->wd->queue, it);
824 if (it->wd->anchor_item == it)
826 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
827 if (!it->wd->anchor_item)
828 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
831 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
832 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
833 _elm_genlist_item_del_serious(it);
834 evas_event_thaw(evas_object_evas_get(obj));
835 evas_event_thaw_eval(evas_object_evas_get(obj));
839 _clear_cb(Widget_Data *wd)
841 wd->anchor_item = NULL;
844 Item_Block *itb = (Item_Block *)(wd->blocks);
846 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
847 if (itb->items) eina_list_free(itb->items);
850 if (wd->queue_idle_enterer)
852 ecore_idle_enterer_del(wd->queue_idle_enterer);
853 wd->queue_idle_enterer = NULL;
855 if (wd->must_recalc_idler)
857 ecore_idler_del(wd->must_recalc_idler);
858 wd->must_recalc_idler = NULL;
860 if (wd->queue) wd->queue = eina_list_free(wd->queue);
861 if (wd->reorder_move_animator)
863 ecore_animator_del(wd->reorder_move_animator);
864 wd->reorder_move_animator = NULL;
866 wd->show_item = NULL;
867 wd->reorder_old_pan_y = 0;
871 _item_unselect(Elm_Gen_Item *it)
873 if ((it->delete_me) || (!it->selected)) return;
874 it->selected = EINA_FALSE;
875 it->wd->selected = eina_list_remove(it->wd->selected, it);
876 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
880 _mouse_move(void *data,
881 Evas *evas __UNUSED__,
885 Elm_Gen_Item *it = data;
886 Evas_Event_Mouse_Move *ev = event_info;
887 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
888 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
890 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
892 if (!it->wd->on_hold)
894 it->wd->on_hold = EINA_TRUE;
895 if (!it->wd->wasselected)
897 _item_unhighlight(it);
902 if (it->wd->multitouched)
904 it->wd->cur_x = ev->cur.canvas.x;
905 it->wd->cur_y = ev->cur.canvas.y;
908 if ((it->dragging) && (it->down))
910 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
913 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
914 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
915 if (abs((it->wd->history[it->wd->movements].x -
916 it->wd->history[0].x)) > 40)
917 it->wd->swipe = EINA_TRUE;
923 ecore_timer_del(it->long_timer);
924 it->long_timer = NULL;
926 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
929 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
933 ecore_timer_del(it->long_timer);
934 it->long_timer = NULL;
936 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
938 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
939 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
941 if (!it->wd->reorder_start_y)
942 it->wd->reorder_start_y = it->item->block->y + it->y;
946 else if (it_scrl_y + it->wd->reorder_it->item->h > oy + oh)
947 y_pos = oy + oh - it->wd->reorder_it->item->h;
951 _item_position(it, VIEW(it), it->item->scrl_x, y_pos);
953 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
954 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
958 if (!it->display_only)
959 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
960 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
961 x = ev->cur.canvas.x - x;
962 y = ev->cur.canvas.y - y;
965 if (adx < 0) adx = -dx;
968 if (ady < 0) ady = -dy;
971 if ((adx > minw) || (ady > minh))
973 it->dragging = EINA_TRUE;
976 ecore_timer_del(it->long_timer);
977 it->long_timer = NULL;
979 if (!it->wd->wasselected)
981 _item_unhighlight(it);
987 evas_object_smart_callback_call(WIDGET(it),
988 SIG_DRAG_START_UP, it);
992 evas_object_smart_callback_call(WIDGET(it),
993 SIG_DRAG_START_LEFT, it);
995 evas_object_smart_callback_call(WIDGET(it),
996 SIG_DRAG_START_RIGHT, it);
1002 evas_object_smart_callback_call(WIDGET(it),
1003 SIG_DRAG_START_DOWN, it);
1007 evas_object_smart_callback_call(WIDGET(it),
1008 SIG_DRAG_START_LEFT, it);
1010 evas_object_smart_callback_call(WIDGET(it),
1011 SIG_DRAG_START_RIGHT, it);
1018 _long_press(void *data)
1020 Elm_Gen_Item *it = data, *it_tmp;
1021 Eina_List *list, *l;
1023 it->long_timer = NULL;
1024 if ((it->disabled) || (it->dragging) || (it->display_only))
1025 return ECORE_CALLBACK_CANCEL;
1026 it->wd->longpressed = EINA_TRUE;
1027 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
1028 if ((it->wd->reorder_mode) && (!it->group))
1030 it->wd->reorder_it = it;
1031 it->wd->reorder_start_y = 0;
1033 evas_object_raise(VIEW(it));
1034 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1035 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1037 list = elm_genlist_realized_items_get(it->wd->obj);
1038 EINA_LIST_FOREACH(list, l, it_tmp)
1040 if (it != it_tmp) _item_unselect(it_tmp);
1042 if (elm_genlist_item_expanded_get(it))
1044 elm_genlist_item_expanded_set(it, EINA_FALSE);
1045 return ECORE_CALLBACK_RENEW;
1047 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
1049 return ECORE_CALLBACK_CANCEL;
1053 _swipe(Elm_Gen_Item *it)
1058 if ((it->display_only) || (it->disabled)) return;
1059 it->wd->swipe = EINA_FALSE;
1060 for (i = 0; i < it->wd->movements; i++)
1062 sum += it->wd->history[i].x;
1063 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1066 sum /= it->wd->movements;
1067 if (abs(sum - it->wd->history[0].x) <= 10) return;
1068 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
1072 _swipe_cancel(void *data)
1074 Elm_Gen_Item *it = data;
1076 if (!it) return ECORE_CALLBACK_CANCEL;
1077 it->wd->swipe = EINA_FALSE;
1078 it->wd->movements = 0;
1079 return ECORE_CALLBACK_RENEW;
1083 _multi_cancel(void *data)
1085 Widget_Data *wd = data;
1087 if (!wd) return ECORE_CALLBACK_CANCEL;
1088 wd->multi_timeout = EINA_TRUE;
1089 return ECORE_CALLBACK_RENEW;
1093 _multi_touch_gesture_eval(void *data)
1095 Elm_Gen_Item *it = data;
1097 it->wd->multitouched = EINA_FALSE;
1098 if (it->wd->multi_timer)
1100 ecore_timer_del(it->wd->multi_timer);
1101 it->wd->multi_timer = NULL;
1103 if (it->wd->multi_timeout)
1105 it->wd->multi_timeout = EINA_FALSE;
1109 Evas_Coord minw = 0, minh = 0;
1110 Evas_Coord off_x, off_y, off_mx, off_my;
1112 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1113 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1114 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1115 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1116 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1118 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1120 if ((off_x + off_mx) > (off_y + off_my))
1122 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1123 evas_object_smart_callback_call(WIDGET(it),
1124 SIG_MULTI_SWIPE_RIGHT, it);
1125 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1126 evas_object_smart_callback_call(WIDGET(it),
1127 SIG_MULTI_SWIPE_LEFT, it);
1128 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1129 evas_object_smart_callback_call(WIDGET(it),
1130 SIG_MULTI_PINCH_OUT, it);
1132 evas_object_smart_callback_call(WIDGET(it),
1133 SIG_MULTI_PINCH_IN, it);
1137 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1138 evas_object_smart_callback_call(WIDGET(it),
1139 SIG_MULTI_SWIPE_DOWN, it);
1140 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1141 evas_object_smart_callback_call(WIDGET(it),
1142 SIG_MULTI_SWIPE_UP, it);
1143 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1144 evas_object_smart_callback_call(WIDGET(it),
1145 SIG_MULTI_PINCH_OUT, it);
1147 evas_object_smart_callback_call(WIDGET(it),
1148 SIG_MULTI_PINCH_IN, it);
1151 it->wd->multi_timeout = EINA_FALSE;
1155 _multi_down(void *data,
1156 Evas *evas __UNUSED__,
1157 Evas_Object *obj __UNUSED__,
1160 Elm_Gen_Item *it = data;
1161 Evas_Event_Multi_Down *ev = event_info;
1163 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1164 it->wd->multi_device = ev->device;
1165 it->wd->multi_down = EINA_TRUE;
1166 it->wd->multitouched = EINA_TRUE;
1167 it->wd->prev_mx = ev->canvas.x;
1168 it->wd->prev_my = ev->canvas.y;
1169 if (!it->wd->wasselected)
1171 _item_unhighlight(it);
1174 it->wd->wasselected = EINA_FALSE;
1175 it->wd->longpressed = EINA_FALSE;
1178 ecore_timer_del(it->long_timer);
1179 it->long_timer = NULL;
1183 it->dragging = EINA_FALSE;
1184 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1186 if (it->item->swipe_timer)
1188 ecore_timer_del(it->item->swipe_timer);
1189 it->item->swipe_timer = NULL;
1191 if (it->wd->on_hold)
1193 it->wd->swipe = EINA_FALSE;
1194 it->wd->movements = 0;
1195 it->wd->on_hold = EINA_FALSE;
1200 _multi_up(void *data,
1201 Evas *evas __UNUSED__,
1202 Evas_Object *obj __UNUSED__,
1205 Elm_Gen_Item *it = data;
1206 Evas_Event_Multi_Up *ev = event_info;
1208 if (it->wd->multi_device != ev->device) return;
1209 it->wd->multi_device = 0;
1210 it->wd->multi_down = EINA_FALSE;
1211 if (it->wd->mouse_down) return;
1212 _multi_touch_gesture_eval(data);
1216 _multi_move(void *data,
1217 Evas *evas __UNUSED__,
1218 Evas_Object *obj __UNUSED__,
1221 Elm_Gen_Item *it = data;
1222 Evas_Event_Multi_Move *ev = event_info;
1224 if (it->wd->multi_device != ev->device) return;
1225 it->wd->cur_mx = ev->cur.canvas.x;
1226 it->wd->cur_my = ev->cur.canvas.y;
1230 _mouse_down(void *data,
1231 Evas *evas __UNUSED__,
1235 Elm_Gen_Item *it = data;
1236 Evas_Event_Mouse_Down *ev = event_info;
1239 if (ev->button != 1) return;
1240 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1242 it->wd->on_hold = EINA_TRUE;
1245 it->down = EINA_TRUE;
1246 it->dragging = EINA_FALSE;
1247 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1248 it->dx = ev->canvas.x - x;
1249 it->dy = ev->canvas.y - y;
1250 it->wd->mouse_down = EINA_TRUE;
1251 if (!it->wd->multitouched)
1253 it->wd->prev_x = ev->canvas.x;
1254 it->wd->prev_y = ev->canvas.y;
1255 it->wd->multi_timeout = EINA_FALSE;
1256 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1257 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1259 it->wd->longpressed = EINA_FALSE;
1260 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1261 else it->wd->on_hold = EINA_FALSE;
1262 if (it->wd->on_hold) return;
1263 it->wd->wasselected = it->selected;
1264 _item_highlight(it);
1265 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1266 if ((!it->disabled) && (!it->display_only))
1268 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1269 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
1271 if (it->long_timer) ecore_timer_del(it->long_timer);
1272 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
1273 it->item->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1275 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1278 it->long_timer = NULL;
1279 it->wd->swipe = EINA_FALSE;
1280 it->wd->movements = 0;
1284 _mouse_up(void *data,
1285 Evas *evas __UNUSED__,
1286 Evas_Object *obj __UNUSED__,
1289 Elm_Gen_Item *it = data;
1290 Evas_Event_Mouse_Up *ev = event_info;
1291 Eina_Bool dragged = EINA_FALSE;
1293 if (ev->button != 1) return;
1294 it->down = EINA_FALSE;
1295 it->wd->mouse_down = EINA_FALSE;
1296 if (it->wd->multitouched)
1298 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1299 if (it->wd->multi_down) return;
1300 _multi_touch_gesture_eval(data);
1303 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1304 else it->wd->on_hold = EINA_FALSE;
1307 ecore_timer_del(it->long_timer);
1308 it->long_timer = NULL;
1312 it->dragging = EINA_FALSE;
1313 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1316 if (it->item->swipe_timer)
1318 ecore_timer_del(it->item->swipe_timer);
1319 it->item->swipe_timer = NULL;
1321 if (it->wd->multi_timer)
1323 ecore_timer_del(it->wd->multi_timer);
1324 it->wd->multi_timer = NULL;
1325 it->wd->multi_timeout = EINA_FALSE;
1327 if (it->wd->on_hold)
1329 if (it->wd->swipe) _swipe(data);
1330 it->wd->longpressed = EINA_FALSE;
1331 it->wd->on_hold = EINA_FALSE;
1334 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1336 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1338 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1340 if (it_scrl_y <= it->wd->reorder_rel->item->scrl_y)
1341 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1343 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1347 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1348 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1350 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
1351 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1352 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1353 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
1355 if (it->wd->longpressed)
1357 it->wd->longpressed = EINA_FALSE;
1358 if (!it->wd->wasselected)
1360 _item_unhighlight(it);
1363 it->wd->wasselected = EINA_FALSE;
1368 if (it->want_unrealize)
1370 _elm_genlist_item_unrealize(it, EINA_FALSE);
1371 if (it->item->block->want_unrealize)
1372 _item_block_unrealize(it->item->block);
1375 if ((it->disabled) || (dragged) || (it->display_only)) return;
1376 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1381 _item_highlight(it);
1386 _item_unhighlight(it);
1394 Widget_Data *wd = it->wd;
1397 while (wd->selected)
1399 _item_unhighlight(wd->selected->data);
1400 _item_unselect(wd->selected->data);
1406 const Eina_List *l, *l_next;
1409 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1412 _item_unhighlight(it2);
1413 _item_unselect(it2);
1415 //_item_highlight(it);
1418 _item_highlight(it);
1424 _signal_expand_toggle(void *data,
1425 Evas_Object *obj __UNUSED__,
1426 const char *emission __UNUSED__,
1427 const char *source __UNUSED__)
1429 Elm_Gen_Item *it = data;
1431 if (it->item->expanded)
1432 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1434 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1438 _signal_expand(void *data,
1439 Evas_Object *obj __UNUSED__,
1440 const char *emission __UNUSED__,
1441 const char *source __UNUSED__)
1443 Elm_Gen_Item *it = data;
1445 if (!it->item->expanded)
1446 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1450 _signal_contract(void *data,
1451 Evas_Object *obj __UNUSED__,
1452 const char *emission __UNUSED__,
1453 const char *source __UNUSED__)
1455 Elm_Gen_Item *it = data;
1457 if (it->item->expanded)
1458 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1462 _scr_hold_timer_cb(void *data)
1464 if (!data) return ECORE_CALLBACK_CANCEL;
1465 Widget_Data *wd = data;
1466 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1467 wd->scr_hold_timer = NULL;
1468 return ECORE_CALLBACK_CANCEL;
1472 _mode_finished_signal_cb(void *data,
1474 const char *emission __UNUSED__,
1475 const char *source __UNUSED__)
1479 Elm_Gen_Item *it = data;
1480 if ((it->delete_me) || (!it->realized) || (!it->item->mode_view)) return;
1482 Evas *te = evas_object_evas_get(obj);
1484 evas_event_freeze(te);
1485 it->item->nocache = EINA_FALSE;
1486 _mode_item_unrealize(it);
1487 if (it->item->group_item)
1488 evas_object_raise(it->item->VIEW(group_item));
1489 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1490 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1491 evas_event_thaw(te);
1492 evas_event_thaw_eval(te);
1496 _item_cache_clean(Widget_Data *wd)
1498 evas_event_freeze(evas_object_evas_get(wd->obj));
1499 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1503 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1504 wd->item_cache = eina_inlist_remove(wd->item_cache,
1505 wd->item_cache->last);
1506 wd->item_cache_count--;
1507 if (itc->spacer) evas_object_del(itc->spacer);
1508 if (itc->base_view) evas_object_del(itc->base_view);
1509 if (itc->item_style) eina_stringshare_del(itc->item_style);
1512 evas_event_thaw(evas_object_evas_get(wd->obj));
1513 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1517 _item_cache_zero(Widget_Data *wd)
1519 int pmax = wd->item_cache_max;
1520 wd->item_cache_max = 0;
1521 _item_cache_clean(wd);
1522 wd->item_cache_max = pmax;
1526 _item_cache_add(Elm_Gen_Item *it)
1530 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1531 if (it->wd->item_cache_max <= 0)
1533 evas_object_del(VIEW(it));
1535 evas_object_del(it->spacer);
1537 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1538 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1542 it->wd->item_cache_count++;
1543 itc = calloc(1, sizeof(Item_Cache));
1544 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1545 EINA_INLIST_GET(itc));
1546 itc->spacer = it->spacer;
1548 itc->base_view = VIEW(it);
1550 evas_object_hide(itc->base_view);
1551 evas_object_move(itc->base_view, -9999, -9999);
1552 itc->item_style = eina_stringshare_add(it->itc->item_style);
1553 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1554 itc->compress = (it->wd->compress);
1555 itc->selected = it->selected;
1556 itc->disabled = it->disabled;
1557 itc->expanded = it->item->expanded;
1560 ecore_timer_del(it->long_timer);
1561 it->long_timer = NULL;
1563 if (it->item->swipe_timer)
1565 ecore_timer_del(it->item->swipe_timer);
1566 it->item->swipe_timer = NULL;
1568 // FIXME: other callbacks?
1569 edje_object_signal_callback_del_full(itc->base_view,
1570 "elm,action,expand,toggle",
1571 "elm", _signal_expand_toggle, it);
1572 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1574 _signal_expand, it);
1575 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1576 "elm", _signal_contract, it);
1577 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1579 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1581 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1583 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1585 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1587 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1589 _item_cache_clean(it->wd);
1590 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1591 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1595 _item_cache_find(Elm_Gen_Item *it)
1600 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1601 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1603 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1605 if ((itc->tree == tree) &&
1606 (itc->compress == it->wd->compress) &&
1607 (!strcmp(it->itc->item_style, itc->item_style)))
1609 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1610 EINA_INLIST_GET(itc));
1611 it->wd->item_cache_count--;
1619 _elm_genlist_item_odd_even_update(Elm_Gen_Item *it)
1621 if (!it->item->nostacking)
1623 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
1624 evas_object_lower(VIEW(it));
1626 evas_object_raise(VIEW(it));
1629 if (it->item->order_num_in & 0x1)
1630 edje_object_signal_emit(VIEW(it), "elm,state,odd", "elm");
1632 edje_object_signal_emit(VIEW(it), "elm,state,even", "elm");
1636 _elm_genlist_item_state_update(Elm_Gen_Item *it, Item_Cache *itc)
1640 if (it->selected != itc->selected)
1643 edje_object_signal_emit(VIEW(it),
1644 "elm,state,selected", "elm");
1646 if (it->disabled != itc->disabled)
1649 edje_object_signal_emit(VIEW(it),
1650 "elm,state,disabled", "elm");
1652 if (it->item->expanded != itc->expanded)
1654 if (it->item->expanded)
1655 edje_object_signal_emit(VIEW(it),
1656 "elm,state,expanded", "elm");
1662 edje_object_signal_emit(VIEW(it),
1663 "elm,state,selected", "elm");
1665 edje_object_signal_emit(VIEW(it),
1666 "elm,state,disabled", "elm");
1667 if (it->item->expanded)
1668 edje_object_signal_emit(VIEW(it),
1669 "elm,state,expanded", "elm");
1674 _item_cache_free(Item_Cache *itc)
1676 if (itc->spacer) evas_object_del(itc->spacer);
1677 if (itc->base_view) evas_object_del(itc->base_view);
1678 if (itc->item_style) eina_stringshare_del(itc->item_style);
1683 _item_del_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1685 Elm_Gen_Item *it = event_info;
1687 if (it->wd->last_selected_item == it)
1688 it->wd->last_selected_item = NULL;
1692 _item_label_realize(Elm_Gen_Item *it,
1693 Evas_Object *target,
1697 if (it->itc->func.text_get)
1702 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1703 EINA_LIST_FOREACH(*source, l, key)
1705 if (parts && fnmatch(parts, key, FNM_PERIOD))
1708 char *s = it->itc->func.text_get
1709 ((void *)it->base.data, WIDGET(it), key);
1713 edje_object_part_text_set(target, key, s);
1718 edje_object_part_text_set(target, key, "");
1725 _item_content_unrealize(Elm_Gen_Item *it,
1726 Evas_Object *target,
1730 Eina_List *res = it->content_objs;
1732 if (it->itc->func.content_get)
1736 Evas_Object *ic = NULL;
1738 EINA_LIST_FOREACH(*source, l, key)
1740 if (parts && fnmatch(parts, key, FNM_PERIOD))
1743 ic = edje_object_part_swallow_get(target, key);
1746 res = eina_list_remove(res, ic);
1747 edje_object_part_unswallow(target, ic);
1748 evas_object_del(ic);
1757 _item_content_realize(Elm_Gen_Item *it,
1758 Evas_Object *target,
1762 Eina_List *res = NULL;
1764 if (it->itc->func.content_get)
1768 Evas_Object *ic = NULL;
1770 *source = elm_widget_stringlist_get(edje_object_data_get(target, "contents"));
1772 if (parts && (eina_list_count(*source) != eina_list_count(it->content_objs)))
1773 res = it->content_objs;
1775 EINA_LIST_FOREACH(*source, l, key)
1777 if (parts && fnmatch(parts, key, FNM_PERIOD))
1780 if (it->itc->func.content_get)
1781 ic = it->itc->func.content_get
1782 ((void *)it->base.data, WIDGET(it), key);
1785 res = eina_list_append(res, ic);
1786 edje_object_part_swallow(target, key, ic);
1787 evas_object_show(ic);
1788 elm_widget_sub_object_add(WIDGET(it), ic);
1790 elm_widget_disabled_set(ic, EINA_TRUE);
1799 _item_state_realize(Elm_Gen_Item *it,
1800 Evas_Object *target,
1804 if (it->itc->func.state_get)
1810 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1811 EINA_LIST_FOREACH(*source, l, key)
1813 if (parts && fnmatch(parts, key, FNM_PERIOD))
1816 Eina_Bool on = it->itc->func.state_get
1817 ((void *)it->base.data, WIDGET(it), key);
1821 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1822 edje_object_signal_emit(target, buf, "elm");
1826 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1827 edje_object_signal_emit(target, buf, "elm");
1834 _item_realize(Elm_Gen_Item *it,
1839 const char *treesize;
1841 int depth, tsize = 20;
1842 Item_Cache *itc = NULL;
1844 if (it->delete_me) return;
1845 //evas_event_freeze(evas_object_evas_get(it->wd->obj));
1848 if (it->item->order_num_in != in)
1850 it->item->order_num_in = in;
1851 _elm_genlist_item_odd_even_update(it);
1852 _elm_genlist_item_state_update(it, NULL);
1854 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1855 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1858 it->item->order_num_in = in;
1860 if (it->item->nocache)
1861 it->item->nocache = EINA_FALSE;
1863 itc = _item_cache_find(it);
1866 VIEW(it) = itc->base_view;
1867 itc->base_view = NULL;
1868 it->spacer = itc->spacer;
1873 const char *stacking_even;
1874 const char *stacking;
1876 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
1877 edje_object_scale_set(VIEW(it),
1878 elm_widget_scale_get(WIDGET(it)) *
1879 _elm_config->scale);
1880 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
1881 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
1883 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS)
1884 strncpy(buf, "tree", sizeof(buf));
1885 else strncpy(buf, "item", sizeof(buf));
1886 if (it->wd->compress)
1887 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1889 strncat(buf, "/", sizeof(buf) - strlen(buf));
1890 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1892 _elm_theme_object_set(WIDGET(it), VIEW(it), "genlist", buf,
1893 elm_widget_style_get(WIDGET(it)));
1895 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
1896 if (!stacking_even) stacking_even = "above";
1897 it->item->stacking_even = !!strcmp("above", stacking_even);
1899 stacking = edje_object_data_get(VIEW(it), "stacking");
1900 if (!stacking) stacking = "yes";
1901 it->item->nostacking = !!strcmp("yes", stacking);
1903 edje_object_mirrored_set(VIEW(it),
1904 elm_widget_mirrored_get(WIDGET(it)));
1906 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1907 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1908 elm_widget_sub_object_add(WIDGET(it), it->spacer);
1911 _elm_genlist_item_odd_even_update(it);
1913 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1915 if (!it2->parent->group) depth += 1;
1917 it->item->expanded_depth = depth;
1918 treesize = edje_object_data_get(VIEW(it), "treesize");
1919 if (treesize) tsize = atoi(treesize);
1920 evas_object_size_hint_min_set(it->spacer,
1921 (depth * tsize) * _elm_config->scale, 1);
1922 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
1925 edje_object_signal_callback_add(VIEW(it),
1926 "elm,action,expand,toggle",
1927 "elm", _signal_expand_toggle, it);
1928 edje_object_signal_callback_add(VIEW(it), "elm,action,expand",
1929 "elm", _signal_expand, it);
1930 edje_object_signal_callback_add(VIEW(it), "elm,action,contract",
1931 "elm", _signal_contract, it);
1932 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1934 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1936 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1938 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_DOWN,
1940 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_UP,
1942 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_MOVE,
1945 _elm_genlist_item_state_update(it, itc);
1948 if ((calc) && (it->wd->homogeneous) &&
1949 ((it->wd->item_width) ||
1950 ((it->wd->item_width) && (it->wd->group_item_width))))
1952 /* homogenous genlist shortcut */
1953 if (!it->item->mincalcd)
1957 it->item->w = it->item->minw = it->wd->group_item_width;
1958 it->item->h = it->item->minh = it->wd->group_item_height;
1962 it->item->w = it->item->minw = it->wd->item_width;
1963 it->item->h = it->item->minh = it->wd->item_height;
1965 it->item->mincalcd = EINA_TRUE;
1970 /* FIXME: If you see that assert, please notify us and we
1971 will clean our mess */
1972 assert(eina_list_count(it->content_objs) == 0);
1974 _item_label_realize(it, VIEW(it), &it->labels, NULL);
1975 it->content_objs = _item_content_realize(it, VIEW(it), &it->contents, NULL);
1976 _item_state_realize(it, VIEW(it), &it->states, NULL);
1978 if (!it->item->mincalcd)
1980 Evas_Coord mw = -1, mh = -1;
1982 if (!it->display_only)
1983 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1984 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1985 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
1987 if (!it->display_only)
1988 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1989 it->item->w = it->item->minw = mw;
1990 it->item->h = it->item->minh = mh;
1991 it->item->mincalcd = EINA_TRUE;
1993 if ((!it->wd->group_item_width) && (it->group))
1995 it->wd->group_item_width = mw;
1996 it->wd->group_item_height = mh;
1998 else if ((!it->wd->item_width) && (it->item->flags == ELM_GENLIST_ITEM_NONE))
2000 it->wd->item_width = mw;
2001 it->wd->item_height = mh;
2004 if (!calc) evas_object_show(VIEW(it));
2007 if (it->tooltip.content_cb)
2009 elm_widget_item_tooltip_content_cb_set(it,
2010 it->tooltip.content_cb,
2011 it->tooltip.data, NULL);
2012 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2013 elm_widget_item_tooltip_size_restrict_disable(it, it->tooltip.free_size);
2016 if (it->mouse_cursor)
2017 elm_widget_item_cursor_set(it, it->mouse_cursor);
2019 it->realized = EINA_TRUE;
2020 it->want_unrealize = EINA_FALSE;
2022 if (itc) _item_cache_free(itc);
2023 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
2024 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2026 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
2027 edje_object_message_signal_process(VIEW(it));
2031 _item_unrealize_cb(Elm_Gen_Item *it)
2033 if (it->item->nocache)
2035 evas_object_del(VIEW(it));
2037 evas_object_del(it->spacer);
2042 edje_object_mirrored_set(VIEW(it),
2043 elm_widget_mirrored_get(WIDGET(it)));
2044 edje_object_scale_set(VIEW(it),
2045 elm_widget_scale_get(WIDGET(it))
2046 * _elm_config->scale);
2047 _item_cache_add(it);
2050 _mode_item_unrealize(it);
2052 it->realized = EINA_FALSE;
2053 it->want_unrealize = EINA_FALSE;
2057 _item_block_recalc(Item_Block *itb,
2063 Evas_Coord minw = 0, minh = 0;
2064 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2067 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2069 EINA_LIST_FOREACH(itb->items, l, it)
2071 if (it->delete_me) continue;
2072 showme |= it->item->showme;
2077 if (!it->item->mincalcd) changed = EINA_TRUE;
2080 _item_realize(it, in, EINA_TRUE);
2081 _elm_genlist_item_unrealize(it, EINA_TRUE);
2086 _item_realize(it, in, EINA_TRUE);
2087 _elm_genlist_item_unrealize(it, EINA_TRUE);
2091 _item_realize(it, in, EINA_FALSE);
2092 minh += it->item->minh;
2093 if (minw < it->item->minw) minw = it->item->minw;
2101 itb->changed = EINA_FALSE;
2102 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2103 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2108 _item_block_realize(Item_Block *itb)
2110 if (itb->realized) return;
2111 itb->realized = EINA_TRUE;
2112 itb->want_unrealize = EINA_FALSE;
2116 _item_block_unrealize(Item_Block *itb)
2120 Eina_Bool dragging = EINA_FALSE;
2122 if (!itb->realized) return;
2123 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2124 EINA_LIST_FOREACH(itb->items, l, it)
2130 dragging = EINA_TRUE;
2131 it->want_unrealize = EINA_TRUE;
2134 _elm_genlist_item_unrealize(it, EINA_FALSE);
2139 itb->realized = EINA_FALSE;
2140 itb->want_unrealize = EINA_TRUE;
2143 itb->want_unrealize = EINA_FALSE;
2144 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2145 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2149 _get_space_for_reorder_item(Elm_Gen_Item *it)
2151 Evas_Coord rox, roy, row, roh, oy, oh;
2152 Eina_Bool top = EINA_FALSE;
2153 Elm_Gen_Item *reorder_it = it->wd->reorder_it;
2154 if (!reorder_it) return 0;
2156 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2157 evas_object_geometry_get(it->wd->VIEW(reorder_it), &rox, &roy, &row, &roh);
2159 if ((it->wd->reorder_start_y < it->item->block->y) &&
2160 (roy - oy + (roh / 2) >= it->item->block->y - it->wd->pan_y))
2162 it->item->block->reorder_offset = it->wd->reorder_it->item->h * -1;
2163 if (it->item->block->count == 1)
2164 it->wd->reorder_rel = it;
2166 else if ((it->wd->reorder_start_y >= it->item->block->y) &&
2167 (roy - oy + (roh / 2) <= it->item->block->y - it->wd->pan_y))
2169 it->item->block->reorder_offset = it->wd->reorder_it->item->h;
2172 it->item->block->reorder_offset = 0;
2174 it->item->scrl_y += it->item->block->reorder_offset;
2176 top = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2177 rox, roy + (roh / 2), row, 1));
2180 it->wd->reorder_rel = it;
2181 it->item->scrl_y += it->wd->reorder_it->item->h;
2182 return it->wd->reorder_it->item->h;
2189 _reorder_move_animator_cb(void *data)
2191 Elm_Gen_Item *it = data;
2192 Eina_Bool down = EINA_FALSE;
2194 int y, dy = it->item->h / 10 * _elm_config->scale, diff;
2196 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2198 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2201 diff = abs(it->item->old_scrl_y - it->item->scrl_y);
2202 if (diff > it->item->h) y = diff / 2;
2204 if (it->item->old_scrl_y < it->item->scrl_y)
2206 it->item->old_scrl_y += y;
2209 else if (it->item->old_scrl_y > it->item->scrl_y)
2211 it->item->old_scrl_y -= y;
2214 _item_position(it, VIEW(it), it->item->scrl_x, it->item->old_scrl_y);
2215 _group_items_recalc(it->wd);
2217 if ((it->wd->reorder_pan_move) ||
2218 (down && it->item->old_scrl_y >= it->item->scrl_y) ||
2219 (!down && it->item->old_scrl_y <= it->item->scrl_y))
2221 it->item->old_scrl_y = it->item->scrl_y;
2222 it->item->move_effect_enabled = EINA_FALSE;
2223 it->wd->reorder_move_animator = NULL;
2224 return ECORE_CALLBACK_CANCEL;
2226 return ECORE_CALLBACK_RENEW;
2230 _item_position(Elm_Gen_Item *it,
2238 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2239 evas_object_resize(view, it->item->w, it->item->h);
2240 evas_object_move(view, it_x, it_y);
2241 evas_object_show(view);
2242 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2243 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2247 _item_block_position(Item_Block *itb,
2253 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2254 Eina_Bool vis = EINA_FALSE;
2256 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2257 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2258 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2260 EINA_LIST_FOREACH(itb->items, l, it)
2262 if (it->delete_me) continue;
2263 else if (it->wd->reorder_it == it) continue;
2266 it->item->w = itb->w;
2267 it->item->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2268 it->item->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2270 vis = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2271 cvx, cvy, cvw, cvh));
2274 if ((itb->realized) && (!it->realized))
2276 if (vis) _item_realize(it, in, EINA_FALSE);
2282 if (it->wd->reorder_mode)
2283 y += _get_space_for_reorder_item(it);
2284 git = it->item->group_item;
2287 if (git->item->scrl_y < oy)
2288 git->item->scrl_y = oy;
2289 if ((git->item->scrl_y + git->item->h) > (it->item->scrl_y + it->item->h))
2290 git->item->scrl_y = (it->item->scrl_y + it->item->h) - git->item->h;
2291 git->item->want_realize = EINA_TRUE;
2293 if ((it->wd->reorder_it) && (it->item->old_scrl_y != it->item->scrl_y))
2295 if (!it->item->move_effect_enabled)
2297 it->item->move_effect_enabled = EINA_TRUE;
2298 it->wd->reorder_move_animator =
2300 _reorder_move_animator_cb, it);
2303 if (!it->item->move_effect_enabled)
2305 if (it->item->mode_view)
2306 _item_position(it, it->item->mode_view, it->item->scrl_x,
2309 _item_position(it, VIEW(it), it->item->scrl_x,
2311 it->item->old_scrl_y = it->item->scrl_y;
2316 if (!it->dragging) _elm_genlist_item_unrealize(it, EINA_FALSE);
2323 if (vis) it->item->want_realize = EINA_TRUE;
2327 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2328 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2332 _group_items_recalc(void *data)
2334 Widget_Data *wd = data;
2338 evas_event_freeze(evas_object_evas_get(wd->obj));
2339 EINA_LIST_FOREACH(wd->group_items, l, git)
2341 if (git->item->want_realize)
2344 _item_realize(git, 0, EINA_FALSE);
2345 evas_object_resize(VIEW(git), wd->minw, git->item->h);
2346 evas_object_move(VIEW(git), git->item->scrl_x, git->item->scrl_y);
2347 evas_object_show(VIEW(git));
2348 evas_object_raise(VIEW(git));
2350 else if (!git->item->want_realize && git->realized)
2353 _elm_genlist_item_unrealize(git, EINA_FALSE);
2356 evas_event_thaw(evas_object_evas_get(wd->obj));
2357 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2361 _must_recalc_idler(void *data)
2363 Widget_Data *wd = data;
2364 if (wd->calc_job) ecore_job_del(wd->calc_job);
2365 wd->calc_job = ecore_job_add(_calc_job, wd);
2366 wd->must_recalc_idler = NULL;
2367 return ECORE_CALLBACK_CANCEL;
2371 _calc_job(void *data)
2373 Widget_Data *wd = data;
2374 Item_Block *itb, *chb = NULL;
2375 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2377 Eina_Bool minw_change = EINA_FALSE;
2378 Eina_Bool did_must_recalc = EINA_FALSE;
2381 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2385 evas_event_freeze(evas_object_evas_get(wd->obj));
2386 EINA_INLIST_FOREACH(wd->blocks, itb)
2388 Eina_Bool showme = EINA_FALSE;
2391 showme = itb->showme;
2392 itb->showme = EINA_FALSE;
2395 if (itb->realized) _item_block_unrealize(itb);
2397 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2399 if (itb->must_recalc)
2403 EINA_LIST_FOREACH(itb->items, l, it)
2404 if (it->item->mincalcd) it->item->mincalcd = EINA_FALSE;
2405 itb->changed = EINA_TRUE;
2406 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2407 itb->must_recalc = EINA_FALSE;
2409 if (itb->realized) _item_block_unrealize(itb);
2410 showme = _item_block_recalc(itb, in, EINA_FALSE);
2416 if (minw == -1) minw = itb->minw;
2417 else if ((!itb->must_recalc) && (minw < itb->minw))
2420 minw_change = EINA_TRUE;
2426 if ((showme) && (wd->show_item) && (!wd->show_item->item->queued))
2428 wd->show_item->item->showme = EINA_FALSE;
2430 elm_smart_scroller_region_bring_in(wd->scr,
2432 wd->show_item->item->block->x,
2434 wd->show_item->item->block->y,
2435 wd->show_item->item->block->w,
2436 wd->show_item->item->h);
2438 elm_smart_scroller_child_region_show(wd->scr,
2440 wd->show_item->item->block->x,
2442 wd->show_item->item->block->y,
2443 wd->show_item->item->block->w,
2444 wd->show_item->item->h);
2445 wd->show_item = NULL;
2450 EINA_INLIST_FOREACH(wd->blocks, itb)
2456 if ((chb) && (EINA_INLIST_GET(chb)->next))
2458 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2460 if (itb->realized) _item_block_unrealize(itb);
2463 wd->realminw = minw;
2464 if (minw < wd->w) minw = wd->w;
2465 if ((minw != wd->minw) || (minh != wd->minh))
2469 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2470 _sizing_eval(wd->obj);
2471 if ((wd->anchor_item) && (wd->anchor_item->item->block) && (!wd->auto_scroll_enabled))
2476 it = wd->anchor_item;
2477 it_y = wd->anchor_y;
2478 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2479 it->item->block->y + it->y + it_y);
2480 wd->anchor_item = it;
2481 wd->anchor_y = it_y;
2484 if (did_must_recalc)
2486 if (!wd->must_recalc_idler)
2487 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2489 wd->calc_job = NULL;
2490 evas_object_smart_changed(wd->pan_smart);
2491 evas_event_thaw(evas_object_evas_get(wd->obj));
2492 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2496 _update_job(void *data)
2498 Widget_Data *wd = data;
2502 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2504 wd->update_job = NULL;
2507 evas_event_freeze(evas_object_evas_get(wd->obj));
2508 EINA_INLIST_FOREACH(wd->blocks, itb)
2510 Evas_Coord itminw, itminh;
2517 _item_block_position(itb, num);
2521 recalc = EINA_FALSE;
2522 EINA_LIST_FOREACH(itb->items, l2, it)
2524 if (it->item->updateme)
2526 itminw = it->item->minw;
2527 itminh = it->item->minh;
2529 it->item->updateme = EINA_FALSE;
2532 _elm_genlist_item_unrealize(it, EINA_FALSE);
2533 _item_realize(it, num, EINA_FALSE);
2534 position = EINA_TRUE;
2538 _item_realize(it, num, EINA_TRUE);
2539 _elm_genlist_item_unrealize(it, EINA_TRUE);
2541 if ((it->item->minw != itminw) || (it->item->minh != itminh))
2546 itb->updateme = EINA_FALSE;
2549 position = EINA_TRUE;
2550 itb->changed = EINA_TRUE;
2551 _item_block_recalc(itb, num0, EINA_FALSE);
2552 _item_block_position(itb, num0);
2557 if (wd->calc_job) ecore_job_del(wd->calc_job);
2558 wd->calc_job = ecore_job_add(_calc_job, wd);
2560 evas_event_thaw(evas_object_evas_get(wd->obj));
2561 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2565 _pan_set(Evas_Object *obj,
2569 Pan *sd = evas_object_smart_data_get(obj);
2573 // Evas_Coord ow, oh;
2574 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2575 // ow = sd->wd->minw - ow;
2576 // if (ow < 0) ow = 0;
2577 // oh = sd->wd->minh - oh;
2578 // if (oh < 0) oh = 0;
2579 // if (x < 0) x = 0;
2580 // if (y < 0) y = 0;
2581 // if (x > ow) x = ow;
2582 // if (y > oh) y = oh;
2583 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2587 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2589 if ((itb->y + itb->h) > y)
2594 EINA_LIST_FOREACH(itb->items, l2, it)
2596 if ((itb->y + it->y) >= y)
2598 sd->wd->anchor_item = it;
2599 sd->wd->anchor_y = -(itb->y + it->y - y);
2606 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2610 _pan_get(Evas_Object *obj,
2614 Pan *sd = evas_object_smart_data_get(obj);
2617 if (x) *x = sd->wd->pan_x;
2618 if (y) *y = sd->wd->pan_y;
2622 _pan_max_get(Evas_Object *obj,
2626 Pan *sd = evas_object_smart_data_get(obj);
2630 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2631 ow = sd->wd->minw - ow;
2633 oh = sd->wd->minh - oh;
2640 _pan_min_get(Evas_Object *obj __UNUSED__,
2649 _pan_child_size_get(Evas_Object *obj,
2653 Pan *sd = evas_object_smart_data_get(obj);
2656 if (w) *w = sd->wd->minw;
2657 if (h) *h = sd->wd->minh;
2661 _pan_add(Evas_Object *obj)
2664 Evas_Object_Smart_Clipped_Data *cd;
2667 cd = evas_object_smart_data_get(obj);
2670 sd->__clipped_data = *cd;
2672 evas_object_smart_data_set(obj, sd);
2676 _pan_del(Evas_Object *obj)
2678 Pan *sd = evas_object_smart_data_get(obj);
2683 ecore_job_del(sd->resize_job);
2684 sd->resize_job = NULL;
2690 _pan_resize_job(void *data)
2694 _sizing_eval(sd->wd->obj);
2695 sd->resize_job = NULL;
2699 _pan_resize(Evas_Object *obj,
2703 Pan *sd = evas_object_smart_data_get(obj);
2707 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2708 if ((ow == w) && (oh == h)) return;
2709 if ((sd->wd->height_for_width) && (ow != w))
2712 if (sd->resize_job) ecore_job_del(sd->resize_job);
2713 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2715 sd->wd->pan_resized = EINA_TRUE;
2716 evas_object_smart_changed(obj);
2717 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2718 sd->wd->calc_job = NULL;
2720 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2721 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2726 _pan_calculate(Evas_Object *obj)
2728 Pan *sd = evas_object_smart_data_get(obj);
2730 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2736 evas_event_freeze(evas_object_evas_get(obj));
2738 if (sd->wd->pan_resized)
2741 sd->wd->pan_resized = EINA_FALSE;
2744 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2745 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2746 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2748 git->item->want_realize = EINA_FALSE;
2750 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2752 itb->w = sd->wd->minw;
2753 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2754 itb->y - sd->wd->pan_y + oy,
2756 cvx, cvy, cvw, cvh))
2758 if ((!itb->realized) || (itb->changed))
2759 _item_block_realize(itb);
2760 _item_block_position(itb, in);
2764 if (itb->realized) _item_block_unrealize(itb);
2768 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2769 _group_items_recalc(sd->wd);
2770 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2772 if (sd->wd->pan_y != sd->wd->reorder_old_pan_y)
2773 sd->wd->reorder_pan_move = EINA_TRUE;
2774 else sd->wd->reorder_pan_move = EINA_FALSE;
2775 evas_object_raise(sd->wd->VIEW(reorder_it));
2776 sd->wd->reorder_old_pan_y = sd->wd->pan_y;
2777 sd->wd->start_time = ecore_loop_time_get();
2779 _item_auto_scroll(sd->wd);
2780 evas_event_thaw(evas_object_evas_get(obj));
2781 evas_event_thaw_eval(evas_object_evas_get(obj));
2785 _pan_move(Evas_Object *obj,
2786 Evas_Coord x __UNUSED__,
2787 Evas_Coord y __UNUSED__)
2789 Pan *sd = evas_object_smart_data_get(obj);
2792 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2793 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2797 _hold_on(void *data __UNUSED__,
2799 void *event_info __UNUSED__)
2801 Widget_Data *wd = elm_widget_data_get(obj);
2803 elm_smart_scroller_hold_set(wd->scr, 1);
2807 _hold_off(void *data __UNUSED__,
2809 void *event_info __UNUSED__)
2811 Widget_Data *wd = elm_widget_data_get(obj);
2813 elm_smart_scroller_hold_set(wd->scr, 0);
2817 _freeze_on(void *data __UNUSED__,
2819 void *event_info __UNUSED__)
2821 Widget_Data *wd = elm_widget_data_get(obj);
2823 elm_smart_scroller_freeze_set(wd->scr, 1);
2827 _freeze_off(void *data __UNUSED__,
2829 void *event_info __UNUSED__)
2831 Widget_Data *wd = elm_widget_data_get(obj);
2833 elm_smart_scroller_freeze_set(wd->scr, 0);
2837 _scr_anim_start(void *data,
2838 Evas_Object *obj __UNUSED__,
2839 void *event_info __UNUSED__)
2841 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
2845 _scr_anim_stop(void *data,
2846 Evas_Object *obj __UNUSED__,
2847 void *event_info __UNUSED__)
2849 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
2853 _scr_drag_start(void *data,
2854 Evas_Object *obj __UNUSED__,
2855 void *event_info __UNUSED__)
2857 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
2861 _scr_drag_stop(void *data,
2862 Evas_Object *obj __UNUSED__,
2863 void *event_info __UNUSED__)
2865 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
2869 _edge_left(void *data,
2870 Evas_Object *scr __UNUSED__,
2871 void *event_info __UNUSED__)
2873 Evas_Object *obj = data;
2874 evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
2878 _edge_right(void *data,
2879 Evas_Object *scr __UNUSED__,
2880 void *event_info __UNUSED__)
2882 Evas_Object *obj = data;
2883 evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
2887 _edge_top(void *data,
2888 Evas_Object *scr __UNUSED__,
2889 void *event_info __UNUSED__)
2891 Evas_Object *obj = data;
2892 evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
2896 _edge_bottom(void *data,
2897 Evas_Object *scr __UNUSED__,
2898 void *event_info __UNUSED__)
2900 Evas_Object *obj = data;
2901 evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
2905 _mode_item_realize(Elm_Gen_Item *it)
2909 if ((it->item->mode_view) || (it->delete_me)) return;
2911 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2912 it->item->mode_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
2913 edje_object_scale_set(it->item->mode_view,
2914 elm_widget_scale_get(WIDGET(it)) *
2915 _elm_config->scale);
2916 evas_object_smart_member_add(it->item->mode_view, it->wd->pan_smart);
2917 elm_widget_sub_object_add(WIDGET(it), it->item->mode_view);
2919 strncpy(buf, "item", sizeof(buf));
2920 if (it->wd->compress)
2921 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2923 if (it->item->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2924 strncat(buf, "/", sizeof(buf) - strlen(buf));
2925 strncat(buf, it->wd->mode_item_style, sizeof(buf) - strlen(buf));
2927 _elm_theme_object_set(WIDGET(it), it->item->mode_view, "genlist", buf,
2928 elm_widget_style_get(WIDGET(it)));
2929 edje_object_mirrored_set(it->item->mode_view,
2930 elm_widget_mirrored_get(WIDGET(it)));
2932 /* signal callback add */
2933 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2935 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_UP,
2937 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2940 /* text_get, content_get, state_get */
2941 /* FIXME: If you see that assert, please notify us and we
2942 will clean our mess */
2943 assert(eina_list_count(it->item->mode_content_objs) == 0);
2945 _item_label_realize(it, it->item->mode_view, &it->item->mode_labels, NULL);
2946 it->item->mode_content_objs =
2947 _item_content_realize(it, it->item->mode_view,
2948 &it->item->mode_contents, NULL);
2949 _item_state_realize(it, it->item->mode_view, &it->item->mode_states, NULL);
2951 edje_object_part_swallow(it->item->mode_view,
2952 edje_object_data_get(it->item->mode_view, "mode_part"),
2955 it->want_unrealize = EINA_FALSE;
2956 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2957 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2961 _mode_item_unrealize(Elm_Gen_Item *it)
2963 Widget_Data *wd = it->wd;
2964 Evas_Object *content;
2965 if (!it->item->mode_view) return;
2967 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2968 elm_widget_stringlist_free(it->item->mode_labels);
2969 it->item->mode_labels = NULL;
2970 elm_widget_stringlist_free(it->item->mode_contents);
2971 it->item->mode_contents = NULL;
2972 elm_widget_stringlist_free(it->item->mode_states);
2974 EINA_LIST_FREE(it->item->mode_content_objs, content)
2975 evas_object_del(content);
2977 edje_object_part_unswallow(it->item->mode_view, VIEW(it));
2978 evas_object_smart_member_add(VIEW(it), wd->pan_smart);
2979 evas_object_del(it->item->mode_view);
2980 it->item->mode_view = NULL;
2982 if (wd->mode_item == it)
2983 wd->mode_item = NULL;
2984 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2985 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2989 _item_mode_set(Elm_Gen_Item *it)
2992 Widget_Data *wd = it->wd;
2997 it->item->nocache = EINA_TRUE;
2999 if (wd->scr_hold_timer)
3001 ecore_timer_del(wd->scr_hold_timer);
3002 wd->scr_hold_timer = NULL;
3004 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3005 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3007 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3008 _mode_item_realize(it);
3009 if (it->item->group_item)
3010 evas_object_raise(it->item->VIEW(group_item));
3011 _item_position(it, it->item->mode_view, it->item->scrl_x, it->item->scrl_y);
3012 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3013 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3015 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3016 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3020 _item_mode_unset(Widget_Data *wd)
3023 if (!wd->mode_item) return;
3024 char buf[1024], buf2[1024];
3028 it->item->nocache = EINA_TRUE;
3030 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3031 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3033 edje_object_signal_emit(it->item->mode_view, buf, "elm");
3034 edje_object_signal_callback_add(it->item->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3036 wd->mode_item = NULL;
3040 _item_auto_scroll(Widget_Data *wd)
3045 Evas_Coord ox, oy, ow, oh;
3047 if ((wd->expanded_item) && (wd->auto_scroll_enabled))
3049 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3050 if (wd->expanded_item->item->scrl_y > (oh + oy) / 2)
3052 EINA_LIST_FOREACH(wd->expanded_item->item->items, l, it)
3053 elm_genlist_item_bring_in(it);
3055 wd->auto_scroll_enabled = EINA_FALSE;
3060 elm_genlist_add(Evas_Object *parent)
3065 Evas_Coord minw, minh;
3066 static Evas_Smart *smart = NULL;
3070 static Evas_Smart_Class sc;
3072 evas_object_smart_clipped_smart_set(&_pan_sc);
3074 sc.name = "elm_genlist_pan";
3075 sc.version = EVAS_SMART_CLASS_VERSION;
3078 sc.resize = _pan_resize;
3079 sc.move = _pan_move;
3080 sc.calculate = _pan_calculate;
3081 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3084 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3086 ELM_SET_WIDTYPE(widtype, "genlist");
3088 elm_widget_type_set(obj, "genlist");
3089 elm_widget_sub_object_add(parent, obj);
3090 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3091 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3092 elm_widget_data_set(obj, wd);
3093 elm_widget_del_hook_set(obj, _del_hook);
3094 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3095 elm_widget_theme_hook_set(obj, _theme_hook);
3096 elm_widget_can_focus_set(obj, EINA_TRUE);
3097 elm_widget_event_hook_set(obj, _event_hook);
3098 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3099 elm_widget_translate_hook_set(obj, _translate_hook);
3101 wd->scr = elm_smart_scroller_add(e);
3102 elm_smart_scroller_widget_set(wd->scr, obj);
3103 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3104 elm_widget_style_get(obj));
3105 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3106 _elm_config->thumbscroll_bounce_enable);
3107 elm_widget_resize_object_set(obj, wd->scr);
3109 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3110 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3111 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3112 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3113 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
3114 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
3115 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
3116 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
3119 wd->mode = ELM_LIST_SCROLL;
3120 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3121 wd->item_cache_max = wd->max_items_per_block * 2;
3122 wd->longpress_timeout = _elm_config->longpress_timeout;
3124 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3125 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3126 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3127 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3129 wd->pan_smart = evas_object_smart_add(e, smart);
3130 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3133 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3134 _pan_set, _pan_get, _pan_max_get,
3135 _pan_min_get, _pan_child_size_get);
3137 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3139 evas_object_size_hint_min_set(obj, minw, minh);
3141 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3143 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3149 _item_select(Elm_Gen_Item *it)
3151 if ((it->wd->no_select) || (it->delete_me) || (it->mode_set)) return;
3154 it->selected = EINA_TRUE;
3155 it->wd->selected = eina_list_append(it->wd->selected, it);
3157 else if (!it->wd->always_select) return;
3159 evas_object_ref(WIDGET(it));
3162 if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), it);
3164 evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
3167 evas_object_unref(WIDGET(it));
3168 if ((it->wd->clear_me) && (!it->wd->walking))
3169 elm_genlist_clear(WIDGET(it));
3172 if ((!it->walking) && (it->delete_me))
3174 if (!it->relcount) it->del_cb(it);
3177 it->wd->last_selected_item = it;
3181 static Evas_Object *
3182 _item_content_get_hook(Elm_Gen_Item *it, const char *part)
3184 return edje_object_part_swallow_get(VIEW(it), part);
3188 _item_content_set_hook(Elm_Gen_Item *it, const char *part, Evas_Object *content)
3190 edje_object_part_swallow(VIEW(it), part, content);
3193 static Evas_Object *
3194 _item_content_unset_hook(Elm_Gen_Item *it, const char *part)
3198 obj = edje_object_part_swallow_get(VIEW(it), part);
3199 if (!obj) return NULL;
3200 edje_object_part_unswallow(VIEW(it), obj);
3205 _item_label_hook(Elm_Gen_Item *it, const char *part)
3207 if (!it->itc->func.text_get) return NULL;
3208 return edje_object_part_text_get(VIEW(it), part);
3212 _elm_genlist_item_new(Widget_Data *wd,
3213 const Elm_Gen_Item_Class *itc,
3215 Elm_Gen_Item *parent,
3217 const void *func_data)
3221 it = elm_widget_item_new(wd->obj, Elm_Gen_Item);
3222 if (!it) return NULL;
3225 it->base.data = data;
3226 it->parent = parent;
3227 it->func.func = func;
3228 it->func.data = func_data;
3229 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
3230 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
3231 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
3233 it->sel_cb = (Ecore_Cb)_item_select;
3235 elm_widget_item_text_get_hook_set(it, _item_label_hook);
3239 static Elm_Gen_Item *
3240 _item_new(Widget_Data *wd,
3241 const Elm_Genlist_Item_Class *itc,
3243 Elm_Gen_Item *parent,
3244 Elm_Genlist_Item_Flags flags,
3246 const void *func_data)
3250 it = _elm_genlist_item_new(wd, itc, data, parent, func, func_data);
3251 if (!it) return NULL;
3252 it->item = ELM_NEW(Elm_Gen_Item_Type);
3253 it->item->flags = flags;
3254 if (flags & ELM_GENLIST_ITEM_GROUP) it->group++;
3255 it->item->expanded_depth = 0;
3256 elm_widget_item_del_cb_set(it, _item_del_hook);
3257 ELM_GEN_ITEM_SETUP(it);
3260 if (it->parent->group)
3261 it->item->group_item = parent;
3262 else if (it->parent->item->group_item)
3263 it->item->group_item = it->parent->item->group_item;
3269 _item_block_add(Widget_Data *wd,
3272 Item_Block *itb = NULL;
3279 itb = calloc(1, sizeof(Item_Block));
3282 if (!it->item->rel->item->block)
3285 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3286 itb->items = eina_list_append(itb->items, it);
3290 if (it->item->before)
3292 wd->blocks = eina_inlist_prepend_relative
3293 (wd->blocks, EINA_INLIST_GET(itb),
3294 EINA_INLIST_GET(it->item->rel->item->block));
3296 eina_list_prepend_relative(itb->items, it, it->item->rel);
3300 wd->blocks = eina_inlist_append_relative
3301 (wd->blocks, EINA_INLIST_GET(itb),
3302 EINA_INLIST_GET(it->item->rel->item->block));
3304 eina_list_append_relative(itb->items, it, it->item->rel);
3310 if (it->item->before)
3314 itb = (Item_Block *)(wd->blocks);
3315 if (itb->count >= wd->max_items_per_block)
3317 itb = calloc(1, sizeof(Item_Block));
3321 eina_inlist_prepend(wd->blocks,
3322 EINA_INLIST_GET(itb));
3327 itb = calloc(1, sizeof(Item_Block));
3331 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3333 itb->items = eina_list_prepend(itb->items, it);
3339 itb = (Item_Block *)(wd->blocks->last);
3340 if (itb->count >= wd->max_items_per_block)
3342 itb = calloc(1, sizeof(Item_Block));
3346 eina_inlist_append(wd->blocks,
3347 EINA_INLIST_GET(itb));
3352 itb = calloc(1, sizeof(Item_Block));
3356 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3358 itb->items = eina_list_append(itb->items, it);
3364 itb = it->item->rel->item->block;
3365 if (!itb) goto newblock;
3366 if (it->item->before)
3367 itb->items = eina_list_prepend_relative(itb->items, it, it->item->rel);
3369 itb->items = eina_list_append_relative(itb->items, it, it->item->rel);
3372 itb->changed = EINA_TRUE;
3373 it->item->block = itb;
3374 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3375 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3378 it->item->rel->relcount--;
3379 if ((it->item->rel->delete_me) && (!it->item->rel->relcount))
3380 _item_del(it->item->rel);
3381 it->item->rel = NULL;
3383 if (itb->count > itb->wd->max_items_per_block)
3389 newc = itb->count / 2;
3390 itb2 = calloc(1, sizeof(Item_Block));
3394 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3395 EINA_INLIST_GET(itb));
3396 itb2->changed = EINA_TRUE;
3397 while ((itb->count > newc) && (itb->items))
3401 l = eina_list_last(itb->items);
3403 itb->items = eina_list_remove_list(itb->items, l);
3406 itb2->items = eina_list_prepend(itb2->items, it2);
3407 it2->item->block = itb2;
3414 _queue_process(Widget_Data *wd)
3417 Eina_Bool showme = EINA_FALSE;
3420 t0 = ecore_time_get();
3421 //evas_event_freeze(evas_object_evas_get(wd->obj));
3422 for (n = 0; (wd->queue) && (n < 128); n++)
3426 it = wd->queue->data;
3427 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3428 it->item->queued = EINA_FALSE;
3429 _item_block_add(wd, it);
3431 _item_block_realize(it->item->block);
3432 t = ecore_time_get();
3433 if (it->item->block->changed)
3435 showme = _item_block_recalc(it->item->block, it->item->block->num, EINA_TRUE);
3436 it->item->block->changed = 0;
3438 if (showme) it->item->block->showme = EINA_TRUE;
3439 if (eina_inlist_count(wd->blocks) > 1)
3441 if ((t - t0) > (ecore_animator_frametime_get())) break;
3444 //evas_event_thaw(evas_object_evas_get(wd->obj));
3445 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3450 _idle_process(void *data, Eina_Bool *wakeup)
3452 Widget_Data *wd = data;
3455 //static double q_start = 0.0;
3456 //if (q_start == 0.0) q_start = ecore_time_get();
3458 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3462 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3464 return ECORE_CALLBACK_CANCEL;
3466 return ECORE_CALLBACK_RENEW;
3470 _item_idle_enterer(void *data)
3472 Widget_Data *wd = data;
3473 Eina_Bool wakeup = EINA_FALSE;
3474 Eina_Bool ok = _idle_process(data, &wakeup);
3479 if (wd->calc_job) ecore_job_del(wd->calc_job);
3480 wd->calc_job = ecore_job_add(_calc_job, wd);
3482 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3487 _item_queue(Widget_Data *wd,
3490 if (it->item->queued) return;
3491 it->item->queued = EINA_TRUE;
3492 wd->queue = eina_list_append(wd->queue, it);
3493 // FIXME: why does a freeze then thaw here cause some genlist
3494 // elm_genlist_item_append() to be much much slower?
3495 // evas_event_freeze(evas_object_evas_get(wd->obj));
3496 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3498 if (wd->queue_idle_enterer)
3500 ecore_idle_enterer_del(wd->queue_idle_enterer);
3501 wd->queue_idle_enterer = NULL;
3505 // evas_event_thaw(evas_object_evas_get(wd->obj));
3506 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3507 if (!wd->queue_idle_enterer)
3508 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3512 _elm_genlist_item_compare_data(const void *data, const void *data1)
3514 const Elm_Gen_Item *it = data;
3515 const Elm_Gen_Item *item1 = data1;
3517 return _elm_genlist_item_compare_data_cb(it->base.data, item1->base.data);
3521 _elm_genlist_item_compare(const void *data, const void *data1)
3523 const Elm_Gen_Item *it, *item1;
3524 it = ELM_GEN_ITEM_FROM_INLIST(data);
3525 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
3526 return _elm_genlist_item_compare_cb(it, item1);
3530 _elm_genlist_item_list_compare(const void *data, const void *data1)
3532 const Elm_Gen_Item *it = data;
3533 const Elm_Gen_Item *item1 = data1;
3534 return _elm_genlist_item_compare_cb(it, item1);
3538 _item_move_after(Elm_Gen_Item *it, Elm_Gen_Item *after)
3543 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3544 _item_block_del(it);
3546 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3547 it->item->rel = after;
3548 it->item->rel->relcount++;
3549 it->item->before = EINA_FALSE;
3550 if (after->item->group_item) it->item->group_item = after->item->group_item;
3551 _item_queue(it->wd, it);
3553 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
3557 _item_move_before(Elm_Gen_Item *it, Elm_Gen_Item *before)
3560 if (!before) return;
3562 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3563 _item_block_del(it);
3564 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3565 it->item->rel = before;
3566 it->item->rel->relcount++;
3567 it->item->before = EINA_TRUE;
3568 if (before->item->group_item) it->item->group_item = before->item->group_item;
3569 _item_queue(it->wd, it);
3571 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
3575 elm_genlist_item_append(Evas_Object *obj,
3576 const Elm_Genlist_Item_Class *itc,
3578 Elm_Gen_Item *parent,
3579 Elm_Genlist_Item_Flags flags,
3581 const void *func_data)
3583 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3584 Widget_Data *wd = elm_widget_data_get(obj);
3585 if (!wd) return NULL;
3586 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3588 if (!it) return NULL;
3592 wd->group_items = eina_list_append(wd->group_items, it);
3593 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3594 it->item->rel = NULL;
3598 Elm_Gen_Item *it2 = NULL;
3599 Eina_List *ll = eina_list_last(it->parent->item->items);
3600 if (ll) it2 = ll->data;
3601 it->parent->item->items = eina_list_append(it->parent->item->items, it);
3602 if (!it2) it2 = it->parent;
3604 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3605 EINA_INLIST_GET(it2));
3606 it->item->rel = it2;
3607 it->item->rel->relcount++;
3609 it->item->before = EINA_FALSE;
3610 _item_queue(wd, it);
3615 elm_genlist_item_prepend(Evas_Object *obj,
3616 const Elm_Genlist_Item_Class *itc,
3618 Elm_Gen_Item *parent,
3619 Elm_Genlist_Item_Flags flags,
3621 const void *func_data)
3623 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3624 Widget_Data *wd = elm_widget_data_get(obj);
3625 if (!wd) return NULL;
3626 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3628 if (!it) return NULL;
3632 wd->group_items = eina_list_prepend(wd->group_items, it);
3633 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3634 it->item->rel = NULL;
3638 Elm_Gen_Item *it2 = NULL;
3639 Eina_List *ll = it->parent->item->items;
3640 if (ll) it2 = ll->data;
3641 it->parent->item->items = eina_list_prepend(it->parent->item->items, it);
3642 if (!it2) it2 = it->parent;
3644 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3645 EINA_INLIST_GET(it2));
3646 it->item->rel = it2;
3647 it->item->rel->relcount++;
3649 it->item->before = EINA_TRUE;
3650 _item_queue(wd, it);
3655 elm_genlist_item_insert_after(Evas_Object *obj,
3656 const Elm_Genlist_Item_Class *itc,
3658 Elm_Gen_Item *parent,
3659 Elm_Gen_Item *after,
3660 Elm_Genlist_Item_Flags flags,
3662 const void *func_data)
3664 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3665 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3666 Widget_Data *wd = elm_widget_data_get(obj);
3667 if (!wd) return NULL;
3668 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3669 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3671 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3673 if (!it) return NULL;
3678 wd->group_items = eina_list_append_relative(wd->group_items, it,
3683 it->parent->item->items = eina_list_append_relative(it->parent->item->items, it,
3686 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3687 EINA_INLIST_GET(after));
3688 it->item->rel = after;
3689 it->item->rel->relcount++;
3690 it->item->before = EINA_FALSE;
3691 _item_queue(wd, it);
3696 elm_genlist_item_insert_before(Evas_Object *obj,
3697 const Elm_Genlist_Item_Class *itc,
3699 Elm_Gen_Item *parent,
3700 Elm_Gen_Item *before,
3701 Elm_Genlist_Item_Flags flags,
3703 const void *func_data)
3705 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3706 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3707 Widget_Data *wd = elm_widget_data_get(obj);
3708 if (!wd) return NULL;
3709 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
3710 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3712 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3714 if (!it) return NULL;
3717 if (it->group && before->group)
3718 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
3723 it->parent->item->items = eina_list_prepend_relative(it->parent->item->items, it,
3726 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3727 EINA_INLIST_GET(before));
3728 it->item->rel = before;
3729 it->item->rel->relcount++;
3730 it->item->before = EINA_TRUE;
3731 _item_queue(wd, it);
3736 elm_genlist_item_direct_sorted_insert(Evas_Object *obj,
3737 const Elm_Genlist_Item_Class *itc,
3739 Elm_Gen_Item *parent,
3740 Elm_Genlist_Item_Flags flags,
3741 Eina_Compare_Cb comp,
3743 const void *func_data)
3745 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3746 Widget_Data *wd = elm_widget_data_get(obj);
3747 if (!wd) return NULL;
3748 Elm_Gen_Item *rel = NULL;
3749 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3751 if (!it) return NULL;
3753 _elm_genlist_item_compare_cb = comp;
3760 l = eina_list_search_sorted_near_list(it->parent->item->items,
3761 _elm_genlist_item_list_compare, it,
3764 rel = eina_list_data_get(l);
3768 if (cmp_result >= 0)
3770 it->parent->item->items = eina_list_prepend_relative_list(it->parent->item->items, it, l);
3771 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
3772 it->item->before = EINA_FALSE;
3774 else if (cmp_result < 0)
3776 it->parent->item->items = eina_list_append_relative_list(it->parent->item->items, it, l);
3777 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
3778 it->item->before = EINA_TRUE;
3785 wd->state = eina_inlist_sorted_state_new();
3786 eina_inlist_sorted_state_init(wd->state, wd->items);
3790 wd->group_items = eina_list_append(wd->group_items, it);
3792 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
3793 _elm_genlist_item_compare, wd->state);
3795 if (EINA_INLIST_GET(it)->next)
3797 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3798 it->item->before = EINA_TRUE;
3800 else if (EINA_INLIST_GET(it)->prev)
3802 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3803 it->item->before = EINA_FALSE;
3809 it->item->rel = rel;
3810 it->item->rel->relcount++;
3813 _item_queue(wd, it);
3819 elm_genlist_item_sorted_insert(Evas_Object *obj,
3820 const Elm_Genlist_Item_Class *itc,
3822 Elm_Gen_Item *parent,
3823 Elm_Genlist_Item_Flags flags,
3824 Eina_Compare_Cb comp,
3826 const void *func_data)
3828 _elm_genlist_item_compare_data_cb = comp;
3830 return elm_genlist_item_direct_sorted_insert(obj, itc, data, parent, flags,
3831 _elm_genlist_item_compare_data, func, func_data);
3835 elm_genlist_clear(Evas_Object *obj)
3837 ELM_CHECK_WIDTYPE(obj, widtype);
3838 Widget_Data *wd = elm_widget_data_get(obj);
3843 eina_inlist_sorted_state_free(wd->state);
3847 if (wd->walking > 0)
3851 EINA_INLIST_FOREACH(wd->items, it)
3855 evas_event_freeze(evas_object_evas_get(wd->obj));
3858 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
3864 ecore_job_del(wd->calc_job);
3865 wd->calc_job = NULL;
3867 if (wd->selected) wd->selected = eina_list_free(wd->selected);
3868 if (wd->clear_cb) wd->clear_cb(wd);
3876 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3877 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3879 if (wd->sizing_cb) wd->sizing_cb(wd->obj);
3880 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
3881 evas_event_thaw(evas_object_evas_get(wd->obj));
3882 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3886 elm_genlist_multi_select_set(Evas_Object *obj,
3889 ELM_CHECK_WIDTYPE(obj, widtype);
3890 Widget_Data *wd = elm_widget_data_get(obj);
3896 elm_genlist_multi_select_get(const Evas_Object *obj)
3898 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3899 Widget_Data *wd = elm_widget_data_get(obj);
3900 if (!wd) return EINA_FALSE;
3905 elm_genlist_selected_item_get(const Evas_Object *obj)
3907 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3908 Widget_Data *wd = elm_widget_data_get(obj);
3909 if (!wd) return NULL;
3910 if (wd->selected) return wd->selected->data;
3914 EAPI const Eina_List *
3915 elm_genlist_selected_items_get(const Evas_Object *obj)
3917 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3918 Widget_Data *wd = elm_widget_data_get(obj);
3919 if (!wd) return NULL;
3920 return wd->selected;
3924 elm_genlist_realized_items_get(const Evas_Object *obj)
3926 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3927 Widget_Data *wd = elm_widget_data_get(obj);
3928 Eina_List *list = NULL;
3930 Eina_Bool done = EINA_FALSE;
3931 if (!wd) return NULL;
3932 EINA_INLIST_FOREACH(wd->blocks, itb)
3940 EINA_LIST_FOREACH(itb->items, l, it)
3942 if (it->realized) list = eina_list_append(list, it);
3954 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3959 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3960 Widget_Data *wd = elm_widget_data_get(obj);
3961 Evas_Coord ox, oy, ow, oh;
3964 if (!wd) return NULL;
3965 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3967 EINA_INLIST_FOREACH(wd->blocks, itb)
3972 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3973 oy + itb->y - itb->wd->pan_y,
3974 itb->w, itb->h, x, y, 1, 1))
3976 EINA_LIST_FOREACH(itb->items, l, it)
3978 Evas_Coord itx, ity;
3980 itx = ox + itb->x + it->x - itb->wd->pan_x;
3981 ity = oy + itb->y + it->y - itb->wd->pan_y;
3982 if (ELM_RECTS_INTERSECT(itx, ity, it->item->w, it->item->h, x, y, 1, 1))
3986 if (y <= (ity + (it->item->h / 4))) *posret = -1;
3987 else if (y >= (ity + it->item->h - (it->item->h / 4)))
3993 lasty = ity + it->item->h;
3998 if (y > lasty) *posret = 1;
4005 elm_genlist_first_item_get(const Evas_Object *obj)
4007 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4008 Widget_Data *wd = elm_widget_data_get(obj);
4009 if (!wd) return NULL;
4010 if (!wd->items) return NULL;
4011 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
4012 while ((it) && (it->delete_me))
4013 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4018 elm_genlist_last_item_get(const Evas_Object *obj)
4020 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4021 Widget_Data *wd = elm_widget_data_get(obj);
4022 if (!wd) return NULL;
4023 if (!wd->items) return NULL;
4024 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
4025 while ((it) && (it->delete_me))
4026 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4031 elm_genlist_item_next_get(const Elm_Gen_Item *it)
4033 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4036 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4037 if ((it) && (!it->delete_me)) break;
4039 return (Elm_Gen_Item *)it;
4043 elm_genlist_item_prev_get(const Elm_Gen_Item *it)
4045 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4048 it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4049 if ((it) && (!it->delete_me)) break;
4051 return (Elm_Gen_Item *)it;
4055 elm_genlist_item_genlist_get(const Elm_Gen_Item *it)
4057 return _elm_genlist_item_widget_get(it);
4061 elm_genlist_item_parent_get(const Elm_Gen_Item *it)
4063 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4068 elm_genlist_item_subitems_clear(Elm_Gen_Item *it)
4070 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4071 Eina_List *tl = NULL, *l;
4074 EINA_LIST_FOREACH(it->item->items, l, it2)
4075 tl = eina_list_append(tl, it2);
4076 EINA_LIST_FREE(tl, it2)
4077 elm_genlist_item_del(it2);
4081 elm_genlist_item_selected_set(Elm_Gen_Item *it,
4084 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4085 Widget_Data *wd = it->wd;
4087 if ((it->delete_me) || (it->disabled)) return;
4088 selected = !!selected;
4089 if (it->selected == selected) return;
4095 while (wd->selected)
4097 if (it->unhighlight_cb) it->unhighlight_cb(wd->selected->data);
4098 it->unsel_cb(wd->selected->data);
4101 it->highlight_cb(it);
4105 if (it->unhighlight_cb) it->unhighlight_cb(it);
4110 elm_genlist_item_selected_get(const Elm_Gen_Item *it)
4112 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4113 return it->selected;
4117 elm_genlist_item_expanded_set(Elm_Gen_Item *it,
4120 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4121 if (it->item->expanded == expanded) return;
4122 it->item->expanded = expanded;
4123 it->wd->expanded_item = it;
4124 if (it->item->expanded)
4127 edje_object_signal_emit(VIEW(it), "elm,state,expanded", "elm");
4128 evas_object_smart_callback_call(WIDGET(it), SIG_EXPANDED, it);
4129 it->wd->auto_scroll_enabled = EINA_TRUE;
4134 edje_object_signal_emit(VIEW(it), "elm,state,contracted", "elm");
4135 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACTED, it);
4136 it->wd->auto_scroll_enabled = EINA_FALSE;
4141 elm_genlist_item_expanded_get(const Elm_Gen_Item *it)
4143 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4144 return it->item->expanded;
4148 elm_genlist_item_expanded_depth_get(const Elm_Gen_Item *it)
4150 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4151 return it->item->expanded_depth;
4155 elm_genlist_item_disabled_set(Elm_Gen_Item *it,
4158 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4161 if (it->disabled == disabled) return;
4162 if (it->delete_me) return;
4163 it->disabled = !!disabled;
4165 elm_genlist_item_selected_set(it, EINA_FALSE);
4169 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
4171 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
4172 EINA_LIST_FOREACH(it->content_objs, l, obj)
4173 elm_widget_disabled_set(obj, disabled);
4178 elm_genlist_item_disabled_get(const Elm_Gen_Item *it)
4180 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4181 if (it->delete_me) return EINA_FALSE;
4182 return it->disabled;
4186 elm_genlist_item_display_only_set(Elm_Gen_Item *it,
4187 Eina_Bool display_only)
4189 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4190 if (it->display_only == display_only) return;
4191 if (it->delete_me) return;
4192 it->display_only = display_only;
4193 it->item->mincalcd = EINA_FALSE;
4194 it->item->updateme = EINA_TRUE;
4195 if (it->item->block) it->item->block->updateme = EINA_TRUE;
4196 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4197 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4201 elm_genlist_item_display_only_get(const Elm_Gen_Item *it)
4203 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4204 if (it->delete_me) return EINA_FALSE;
4205 return it->display_only;
4209 elm_genlist_item_show(Elm_Gen_Item *it)
4211 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4212 Evas_Coord gith = 0;
4213 if (it->delete_me) return;
4214 if ((it->item->queued) || (!it->item->mincalcd))
4216 it->wd->show_item = it;
4217 it->wd->bring_in = EINA_TRUE;
4218 it->item->showme = EINA_TRUE;
4221 if (it->wd->show_item)
4223 it->wd->show_item->item->showme = EINA_FALSE;
4224 it->wd->show_item = NULL;
4226 if ((it->item->group_item) && (it->wd->pan_y > (it->y + it->item->block->y)))
4227 gith = it->item->group_item->item->h;
4228 elm_smart_scroller_child_region_show(it->wd->scr,
4229 it->x + it->item->block->x,
4230 it->y + it->item->block->y - gith,
4231 it->item->block->w, it->item->h);
4235 elm_genlist_item_promote(Elm_Gen_Item *it)
4237 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4238 if (it->delete_me) return;
4239 _item_move_before(it, elm_genlist_first_item_get(WIDGET(it)));
4243 elm_genlist_item_demote(Elm_Gen_Item *it)
4245 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4246 if (it->delete_me) return;
4247 _item_move_after(it, elm_genlist_last_item_get(WIDGET(it)));
4251 elm_genlist_item_bring_in(Elm_Gen_Item *it)
4253 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4254 Evas_Coord gith = 0;
4255 if (it->delete_me) return;
4256 if ((it->item->queued) || (!it->item->mincalcd))
4258 it->wd->show_item = it;
4259 it->wd->bring_in = EINA_TRUE;
4260 it->item->showme = EINA_TRUE;
4263 if (it->wd->show_item)
4265 it->wd->show_item->item->showme = EINA_FALSE;
4266 it->wd->show_item = NULL;
4268 if ((it->item->group_item) && (it->wd->pan_y > (it->y + it->item->block->y)))
4269 gith = it->item->group_item->item->h;
4270 elm_smart_scroller_region_bring_in(it->wd->scr,
4271 it->x + it->item->block->x,
4272 it->y + it->item->block->y - gith,
4273 it->item->block->w, it->item->h);
4277 elm_genlist_item_top_show(Elm_Gen_Item *it)
4279 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4281 Evas_Coord gith = 0;
4283 if (it->delete_me) return;
4284 if ((it->item->queued) || (!it->item->mincalcd))
4286 it->wd->show_item = it;
4287 it->wd->bring_in = EINA_TRUE;
4288 it->item->showme = EINA_TRUE;
4291 if (it->wd->show_item)
4293 it->wd->show_item->item->showme = EINA_FALSE;
4294 it->wd->show_item = NULL;
4296 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4297 if (it->item->group_item) gith = it->item->group_item->item->h;
4298 elm_smart_scroller_child_region_show(it->wd->scr,
4299 it->x + it->item->block->x,
4300 it->y + it->item->block->y - gith,
4301 it->item->block->w, oh);
4305 elm_genlist_item_top_bring_in(Elm_Gen_Item *it)
4307 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4309 Evas_Coord gith = 0;
4311 if (it->delete_me) return;
4312 if ((it->item->queued) || (!it->item->mincalcd))
4314 it->wd->show_item = it;
4315 it->wd->bring_in = EINA_TRUE;
4316 it->item->showme = EINA_TRUE;
4319 if (it->wd->show_item)
4321 it->wd->show_item->item->showme = EINA_FALSE;
4322 it->wd->show_item = NULL;
4324 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4325 if (it->item->group_item) gith = it->item->group_item->item->h;
4326 elm_smart_scroller_region_bring_in(it->wd->scr,
4327 it->x + it->item->block->x,
4328 it->y + it->item->block->y - gith,
4329 it->item->block->w, oh);
4333 elm_genlist_item_middle_show(Elm_Gen_Item *it)
4335 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4338 if (it->delete_me) return;
4339 if ((it->item->queued) || (!it->item->mincalcd))
4341 it->wd->show_item = it;
4342 it->wd->bring_in = EINA_TRUE;
4343 it->item->showme = EINA_TRUE;
4346 if (it->wd->show_item)
4348 it->wd->show_item->item->showme = EINA_FALSE;
4349 it->wd->show_item = NULL;
4351 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4352 elm_smart_scroller_child_region_show(it->wd->scr,
4353 it->x + it->item->block->x,
4354 it->y + it->item->block->y - oh / 2 +
4355 it->item->h / 2, it->item->block->w, oh);
4359 elm_genlist_item_middle_bring_in(Elm_Gen_Item *it)
4361 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4364 if (it->delete_me) return;
4365 if ((it->item->queued) || (!it->item->mincalcd))
4367 it->wd->show_item = it;
4368 it->wd->bring_in = EINA_TRUE;
4369 it->item->showme = EINA_TRUE;
4372 if (it->wd->show_item)
4374 it->wd->show_item->item->showme = EINA_FALSE;
4375 it->wd->show_item = NULL;
4377 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4378 elm_smart_scroller_region_bring_in(it->wd->scr,
4379 it->x + it->item->block->x,
4380 it->y + it->item->block->y - oh / 2 + it->item->h / 2,
4381 it->item->block->w, oh);
4385 elm_genlist_item_del(Elm_Gen_Item *it)
4387 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4388 if ((it->relcount > 0) || (it->walking > 0))
4390 elm_genlist_item_subitems_clear(it);
4391 if (it->wd->show_item == it) it->wd->show_item = NULL;
4392 _elm_genlist_item_del_notserious(it);
4393 if (it->item->block)
4395 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
4396 it->item->block->changed = EINA_TRUE;
4397 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4398 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4406 elm_genlist_item_data_set(Elm_Gen_Item *it,
4409 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4410 elm_widget_item_data_set(it, data);
4414 elm_genlist_item_data_get(const Elm_Gen_Item *it)
4416 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4417 return elm_widget_item_data_get(it);
4421 elm_genlist_item_icons_orphan(Elm_Gen_Item *it)
4423 elm_genlist_item_contents_orphan(it);
4427 elm_genlist_item_contents_orphan(Elm_Gen_Item *it)
4429 Evas_Object *content;
4430 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4431 EINA_LIST_FREE(it->content_objs, content)
4433 elm_widget_sub_object_del(WIDGET(it), content);
4434 evas_object_smart_member_del(content);
4435 evas_object_hide(content);
4439 EAPI const Evas_Object *
4440 elm_genlist_item_object_get(const Elm_Gen_Item *it)
4442 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4447 elm_genlist_item_update(Elm_Gen_Item *it)
4449 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4450 if (!it->item->block) return;
4451 if (it->delete_me) return;
4452 it->item->mincalcd = EINA_FALSE;
4453 it->item->updateme = EINA_TRUE;
4454 it->item->block->updateme = EINA_TRUE;
4455 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4456 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4460 elm_genlist_item_fields_update(Elm_Genlist_Item *it,
4462 Elm_Genlist_Item_Field_Flags itf)
4464 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4465 if (!it->item->block) return;
4466 if (it->delete_me) return;
4468 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_LABEL))
4469 _item_label_realize(it, it->base.view, &it->labels, parts);
4470 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_CONTENT))
4472 it->content_objs = _item_content_unrealize(it, it->base.view,
4473 &it->contents, parts);
4474 it->content_objs = _item_content_realize(it, it->base.view,
4475 &it->contents, parts);
4477 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
4478 _item_state_realize(it, it->base.view, &it->states, parts);
4482 elm_genlist_item_item_class_update(Elm_Gen_Item *it,
4483 const Elm_Genlist_Item_Class *itc)
4485 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4486 if (!it->item->block) return;
4487 EINA_SAFETY_ON_NULL_RETURN(itc);
4488 if (it->delete_me) return;
4490 it->item->nocache = EINA_TRUE;
4491 elm_genlist_item_update(it);
4494 EAPI const Elm_Genlist_Item_Class *
4495 elm_genlist_item_item_class_get(const Elm_Gen_Item *it)
4497 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4498 if (it->delete_me) return NULL;
4502 static Evas_Object *
4503 _elm_genlist_item_label_create(void *data,
4504 Evas_Object *obj __UNUSED__,
4505 Evas_Object *tooltip,
4506 void *it __UNUSED__)
4508 Evas_Object *label = elm_label_add(tooltip);
4511 elm_object_style_set(label, "tooltip");
4512 elm_object_text_set(label, data);
4517 _elm_genlist_item_label_del_cb(void *data,
4518 Evas_Object *obj __UNUSED__,
4519 void *event_info __UNUSED__)
4521 eina_stringshare_del(data);
4525 elm_genlist_item_tooltip_text_set(Elm_Gen_Item *it,
4528 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4529 text = eina_stringshare_add(text);
4530 elm_genlist_item_tooltip_content_cb_set(it, _elm_genlist_item_label_create,
4532 _elm_genlist_item_label_del_cb);
4536 elm_genlist_item_tooltip_content_cb_set(Elm_Gen_Item *it,
4537 Elm_Tooltip_Item_Content_Cb func,
4539 Evas_Smart_Cb del_cb)
4541 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(it, error);
4543 if ((it->tooltip.content_cb == func) && (it->tooltip.data == data))
4546 if (it->tooltip.del_cb)
4547 it->tooltip.del_cb((void *)it->tooltip.data,
4550 it->tooltip.content_cb = func;
4551 it->tooltip.data = data;
4552 it->tooltip.del_cb = del_cb;
4556 elm_widget_item_tooltip_content_cb_set(it,
4557 it->tooltip.content_cb,
4558 it->tooltip.data, NULL);
4559 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
4560 elm_widget_item_tooltip_size_restrict_disable(it, it->tooltip.free_size);
4566 if (del_cb) del_cb((void *)data, NULL, NULL);
4570 elm_genlist_item_tooltip_unset(Elm_Gen_Item *it)
4572 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4573 if ((VIEW(it)) && (it->tooltip.content_cb))
4574 elm_widget_item_tooltip_unset(it);
4576 if (it->tooltip.del_cb)
4577 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
4578 it->tooltip.del_cb = NULL;
4579 it->tooltip.content_cb = NULL;
4580 it->tooltip.data = NULL;
4581 it->tooltip.free_size = EINA_FALSE;
4582 if (it->tooltip.style)
4583 elm_genlist_item_tooltip_style_set(it, NULL);
4587 elm_genlist_item_tooltip_style_set(Elm_Gen_Item *it,
4590 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4591 eina_stringshare_replace(&it->tooltip.style, style);
4592 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
4596 elm_genlist_item_tooltip_style_get(const Elm_Gen_Item *it)
4598 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4599 return it->tooltip.style;
4603 elm_genlist_item_tooltip_size_restrict_disable(Elm_Gen_Item *it, Eina_Bool disable)
4605 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4606 it->tooltip.free_size = disable;
4607 if (VIEW(it)) return elm_widget_item_tooltip_size_restrict_disable(it, disable);
4612 elm_genlist_item_tooltip_size_restrict_disabled_get(const Elm_Gen_Item *it)
4614 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4615 return it->tooltip.free_size;
4619 elm_genlist_item_cursor_set(Elm_Gen_Item *it,
4622 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4623 eina_stringshare_replace(&it->mouse_cursor, cursor);
4624 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
4628 elm_genlist_item_cursor_get(const Elm_Gen_Item *it)
4630 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4631 return elm_widget_item_cursor_get(it);
4635 elm_genlist_item_cursor_unset(Elm_Gen_Item *it)
4637 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4638 if (!it->mouse_cursor)
4642 elm_widget_item_cursor_unset(it);
4644 eina_stringshare_del(it->mouse_cursor);
4645 it->mouse_cursor = NULL;
4649 elm_genlist_item_cursor_style_set(Elm_Gen_Item *it,
4652 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4653 elm_widget_item_cursor_style_set(it, style);
4657 elm_genlist_item_cursor_style_get(const Elm_Gen_Item *it)
4659 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4660 return elm_widget_item_cursor_style_get(it);
4664 elm_genlist_item_cursor_engine_only_set(Elm_Gen_Item *it,
4665 Eina_Bool engine_only)
4667 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4668 elm_widget_item_cursor_engine_only_set(it, engine_only);
4672 elm_genlist_item_cursor_engine_only_get(const Elm_Gen_Item *it)
4674 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4675 return elm_widget_item_cursor_engine_only_get(it);
4679 elm_genlist_horizontal_set(Evas_Object *obj,
4682 ELM_CHECK_WIDTYPE(obj, widtype);
4683 Widget_Data *wd = elm_widget_data_get(obj);
4685 if (wd->mode == mode) return;
4691 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4694 elm_genlist_horizontal_set(obj, mode);
4698 elm_genlist_horizontal_get(const Evas_Object *obj)
4700 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4701 Widget_Data *wd = elm_widget_data_get(obj);
4702 if (!wd) return ELM_LIST_LAST;
4707 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4709 return elm_genlist_horizontal_get(obj);
4713 elm_genlist_always_select_mode_set(Evas_Object *obj,
4714 Eina_Bool always_select)
4716 ELM_CHECK_WIDTYPE(obj, widtype);
4717 Widget_Data *wd = elm_widget_data_get(obj);
4719 wd->always_select = always_select;
4723 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4725 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4726 Widget_Data *wd = elm_widget_data_get(obj);
4727 if (!wd) return EINA_FALSE;
4728 return wd->always_select;
4732 elm_genlist_no_select_mode_set(Evas_Object *obj,
4733 Eina_Bool no_select)
4735 ELM_CHECK_WIDTYPE(obj, widtype);
4736 Widget_Data *wd = elm_widget_data_get(obj);
4738 wd->no_select = no_select;
4742 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4744 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4745 Widget_Data *wd = elm_widget_data_get(obj);
4746 if (!wd) return EINA_FALSE;
4747 return wd->no_select;
4751 elm_genlist_compress_mode_set(Evas_Object *obj,
4754 ELM_CHECK_WIDTYPE(obj, widtype);
4755 Widget_Data *wd = elm_widget_data_get(obj);
4757 wd->compress = compress;
4758 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
4762 elm_genlist_compress_mode_get(const Evas_Object *obj)
4764 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4765 Widget_Data *wd = elm_widget_data_get(obj);
4766 if (!wd) return EINA_FALSE;
4767 return wd->compress;
4771 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4772 Eina_Bool height_for_width)
4774 ELM_CHECK_WIDTYPE(obj, widtype);
4775 Widget_Data *wd = elm_widget_data_get(obj);
4777 wd->height_for_width = !!height_for_width;
4778 if (wd->height_for_width)
4780 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4781 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4786 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4788 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4789 Widget_Data *wd = elm_widget_data_get(obj);
4790 if (!wd) return EINA_FALSE;
4791 return wd->height_for_width;
4795 elm_genlist_bounce_set(Evas_Object *obj,
4799 ELM_CHECK_WIDTYPE(obj, widtype);
4800 Widget_Data *wd = elm_widget_data_get(obj);
4802 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4803 wd->h_bounce = h_bounce;
4804 wd->v_bounce = v_bounce;
4808 elm_genlist_bounce_get(const Evas_Object *obj,
4809 Eina_Bool *h_bounce,
4810 Eina_Bool *v_bounce)
4812 ELM_CHECK_WIDTYPE(obj, widtype);
4813 Widget_Data *wd = elm_widget_data_get(obj);
4815 if (h_bounce) *h_bounce = wd->h_bounce;
4816 if (v_bounce) *v_bounce = wd->v_bounce;
4820 elm_genlist_homogeneous_set(Evas_Object *obj,
4821 Eina_Bool homogeneous)
4823 ELM_CHECK_WIDTYPE(obj, widtype);
4824 Widget_Data *wd = elm_widget_data_get(obj);
4826 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4827 wd->homogeneous = homogeneous;
4831 elm_genlist_homogeneous_get(const Evas_Object *obj)
4833 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4834 Widget_Data *wd = elm_widget_data_get(obj);
4835 if (!wd) return EINA_FALSE;
4836 return wd->homogeneous;
4840 elm_genlist_block_count_set(Evas_Object *obj,
4843 ELM_CHECK_WIDTYPE(obj, widtype);
4844 Widget_Data *wd = elm_widget_data_get(obj);
4846 wd->max_items_per_block = n;
4847 wd->item_cache_max = wd->max_items_per_block * 2;
4848 _item_cache_clean(wd);
4852 elm_genlist_block_count_get(const Evas_Object *obj)
4854 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4855 Widget_Data *wd = elm_widget_data_get(obj);
4857 return wd->max_items_per_block;
4861 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4864 ELM_CHECK_WIDTYPE(obj, widtype);
4865 Widget_Data *wd = elm_widget_data_get(obj);
4867 wd->longpress_timeout = timeout;
4871 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4873 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4874 Widget_Data *wd = elm_widget_data_get(obj);
4876 return wd->longpress_timeout;
4880 elm_genlist_scroller_policy_set(Evas_Object *obj,
4881 Elm_Scroller_Policy policy_h,
4882 Elm_Scroller_Policy policy_v)
4884 ELM_CHECK_WIDTYPE(obj, widtype);
4885 Widget_Data *wd = elm_widget_data_get(obj);
4886 if ((!wd) || (!wd->scr)) return;
4887 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4888 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4890 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4894 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4895 Elm_Scroller_Policy *policy_h,
4896 Elm_Scroller_Policy *policy_v)
4898 ELM_CHECK_WIDTYPE(obj, widtype);
4899 Widget_Data *wd = elm_widget_data_get(obj);
4900 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4901 if ((!wd) || (!wd->scr)) return;
4902 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4903 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4904 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
4908 elm_genlist_realized_items_update(Evas_Object *obj)
4910 ELM_CHECK_WIDTYPE(obj, widtype);
4912 Eina_List *list, *l;
4915 list = elm_genlist_realized_items_get(obj);
4916 EINA_LIST_FOREACH(list, l, it)
4917 elm_genlist_item_update(it);
4921 elm_genlist_item_mode_set(Elm_Gen_Item *it,
4922 const char *mode_type,
4925 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4926 Widget_Data *wd = it->wd;
4931 if (!mode_type) return;
4932 if ((it->delete_me) || (it->disabled)) return;
4934 if ((wd->mode_item == it) &&
4935 (!strcmp(mode_type, wd->mode_type)) &&
4938 if (!wd->mode_item_style) return;
4939 it->mode_set = mode_set;
4943 EINA_LIST_FOREACH(wd->selected, l, it2)
4945 elm_genlist_item_selected_set(it2, EINA_FALSE);
4949 it2 = elm_genlist_selected_item_get(wd->obj);
4950 if ((it2) && (it2->realized))
4951 elm_genlist_item_selected_set(it2, EINA_FALSE);
4954 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
4956 ((it == wd->mode_item) && (!mode_set)))
4957 _item_mode_unset(wd);
4959 eina_stringshare_replace(&wd->mode_type, mode_type);
4960 if (mode_set) _item_mode_set(it);
4965 elm_genlist_mode_item_style_get(const Evas_Object *obj)
4967 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4968 Widget_Data *wd = elm_widget_data_get(obj);
4969 if (!wd) return NULL;
4970 return wd->mode_item_style;
4974 elm_genlist_mode_item_style_set(Evas_Object *obj, const char *style)
4976 ELM_CHECK_WIDTYPE(obj, widtype);
4977 Widget_Data *wd = elm_widget_data_get(obj);
4979 if ((style == wd->mode_item_style) || (style && wd->mode_item_style &&
4980 (!strcmp(style, wd->mode_item_style))))
4982 eina_stringshare_replace(&wd->mode_item_style, style);
4983 elm_genlist_realized_items_update(obj);
4987 elm_genlist_mode_get(const Evas_Object *obj)
4989 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4990 Widget_Data *wd = elm_widget_data_get(obj);
4991 if (!wd) return NULL;
4992 return wd->mode_type;
4995 EAPI const Elm_Gen_Item *
4996 elm_genlist_mode_item_get(const Evas_Object *obj)
4998 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4999 Widget_Data *wd = elm_widget_data_get(obj);
5000 if (!wd) return NULL;
5001 return wd->mode_item;
5005 elm_genlist_reorder_mode_set(Evas_Object *obj,
5006 Eina_Bool reorder_mode)
5008 ELM_CHECK_WIDTYPE(obj, widtype);
5009 Widget_Data *wd = elm_widget_data_get(obj);
5011 wd->reorder_mode = reorder_mode;
5015 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5017 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5018 Widget_Data *wd = elm_widget_data_get(obj);
5019 if (!wd) return EINA_FALSE;
5020 return wd->reorder_mode;
5023 /* for gengrid as of now */
5025 _elm_genlist_page_relative_set(Evas_Object *obj,
5029 Evas_Coord pagesize_h;
5030 Evas_Coord pagesize_v;
5032 ELM_CHECK_WIDTYPE(obj, widtype);
5033 Widget_Data *wd = elm_widget_data_get(obj);
5036 elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
5037 elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
5041 /* for gengrid as of now */
5043 _elm_genlist_page_relative_get(const Evas_Object *obj,
5047 ELM_CHECK_WIDTYPE(obj, widtype);
5048 Widget_Data *wd = elm_widget_data_get(obj);
5051 elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
5054 /* for gengrid as of now */
5056 _elm_genlist_page_size_set(Evas_Object *obj,
5057 Evas_Coord h_pagesize,
5058 Evas_Coord v_pagesize)
5063 ELM_CHECK_WIDTYPE(obj, widtype);
5064 Widget_Data *wd = elm_widget_data_get(obj);
5066 elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
5067 elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
5071 /* for gengrid as of now */
5073 _elm_genlist_current_page_get(const Evas_Object *obj,
5077 ELM_CHECK_WIDTYPE(obj, widtype);
5078 Widget_Data *wd = elm_widget_data_get(obj);
5081 elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber);
5084 /* for gengrid as of now */
5086 _elm_genlist_last_page_get(const Evas_Object *obj,
5090 ELM_CHECK_WIDTYPE(obj, widtype);
5091 Widget_Data *wd = elm_widget_data_get(obj);
5094 elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber);
5097 /* for gengrid as of now */
5099 _elm_genlist_page_show(const Evas_Object *obj,
5103 ELM_CHECK_WIDTYPE(obj, widtype);
5104 Widget_Data *wd = elm_widget_data_get(obj);
5107 elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber);
5110 /* for gengrid as of now */
5112 _elm_genlist_page_bring_in(const Evas_Object *obj,
5116 ELM_CHECK_WIDTYPE(obj, widtype);
5117 Widget_Data *wd = elm_widget_data_get(obj);
5120 elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber);
5124 _elm_genlist_item_widget_get(const Elm_Gen_Item *it)
5126 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
5131 _elm_genlist_item_unrealize(Elm_Gen_Item *it,
5134 Evas_Object *content;
5136 if (!it->realized) return;
5137 if (it->wd->reorder_it == it) return;
5138 evas_event_freeze(evas_object_evas_get(WIDGET(it)));
5140 evas_object_smart_callback_call(WIDGET(it), SIG_UNREALIZED, it);
5143 ecore_timer_del(it->long_timer);
5144 it->long_timer = NULL;
5147 elm_widget_stringlist_free(it->labels);
5149 elm_widget_stringlist_free(it->contents);
5150 it->contents = NULL;
5151 elm_widget_stringlist_free(it->states);
5154 EINA_LIST_FREE(it->content_objs, content)
5155 evas_object_del(content);
5157 it->unrealize_cb(it);
5159 it->realized = EINA_FALSE;
5160 it->want_unrealize = EINA_FALSE;
5161 evas_event_thaw(evas_object_evas_get(WIDGET(it)));
5162 evas_event_thaw_eval(evas_object_evas_get(WIDGET(it)));
5166 _elm_genlist_item_del_notserious(Elm_Gen_Item *it)
5168 elm_widget_item_pre_notify_del(it);
5169 it->delete_me = EINA_TRUE;
5170 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5172 if (it->itc->func.del)
5173 it->itc->func.del((void *)it->base.data, WIDGET(it));
5177 _elm_genlist_item_del_serious(Elm_Gen_Item *it)
5179 _elm_genlist_item_del_notserious(it);
5180 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5181 if (it->tooltip.del_cb)
5182 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
5183 it->wd->walking -= it->walking;
5184 if (it->long_timer) ecore_timer_del(it->long_timer);
5186 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
5188 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5189 it->wd->calc_job = ecore_job_add(it->wd->calc_cb, it->wd);
5192 elm_widget_item_del(it);