3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
8 #define MAX_ITEMS_PER_BLOCK 32
9 #define REORDER_EFFECT_TIME 0.5
11 typedef struct _Widget_Data Widget_Data;
12 typedef struct _Item_Block Item_Block;
13 typedef struct _Pan Pan;
14 typedef struct _Item_Cache Item_Cache;
18 Evas_Object *obj, *scr, *pan_smart;
19 Eina_Inlist *items, *blocks;
20 Eina_List *group_items;
22 Evas_Coord pan_x, pan_y, old_pan_y, w, h, minw, minh, realminw, prev_viewport_w;
23 Ecore_Job *calc_job, *update_job;
24 Ecore_Idle_Enterer *queue_idle_enterer;
25 Ecore_Idler *must_recalc_idler;
26 Eina_List *queue, *selected;
27 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item, *reorder_it, *reorder_rel, *expanded_item;
28 Eina_Inlist *item_cache;
29 Evas_Coord anchor_y, reorder_start_y;
31 Ecore_Timer *multi_timer, *scr_hold_timer;
32 Ecore_Animator *reorder_move_animator;
33 const char *mode_type;
34 unsigned int start_time;
35 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
36 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
37 Eina_Bool mouse_down : 1;
38 Eina_Bool multi_down : 1;
39 Eina_Bool multi_timeout : 1;
40 Eina_Bool multitouched : 1;
41 Eina_Bool on_hold : 1;
43 Eina_Bool always_select : 1;
44 Eina_Bool longpressed : 1;
45 Eina_Bool wasselected : 1;
46 Eina_Bool no_select : 1;
47 Eina_Bool bring_in : 1;
48 Eina_Bool compress : 1;
49 Eina_Bool height_for_width : 1;
50 Eina_Bool homogeneous : 1;
51 Eina_Bool clear_me : 1;
53 Eina_Bool reorder_mode : 1;
54 Eina_Bool reorder_pan_move : 1;
55 Eina_Bool auto_scroll_enabled : 1;
59 } history[SWIPE_MOVES];
68 int group_item_height;
69 int max_items_per_block;
70 double longpress_timeout;
81 Evas_Coord x, y, w, h, minw, minh;
82 Eina_Bool want_unrealize : 1;
83 Eina_Bool realized : 1;
84 Eina_Bool changed : 1;
85 Eina_Bool updateme : 1;
87 Eina_Bool must_recalc : 1;
90 struct _Elm_Genlist_Item
97 Evas_Coord x, y, w, h, minw, minh;
98 const Elm_Genlist_Item_Class *itc;
99 Elm_Genlist_Item *parent;
100 Elm_Genlist_Item *group_item;
101 Elm_Genlist_Item_Flags flags;
109 Eina_List *labels, *icons, *states, *icon_objs;
110 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
111 Ecore_Timer *long_timer;
112 Ecore_Timer *swipe_timer;
114 Evas_Coord scrl_x, scrl_y, old_scrl_y;
116 Elm_Genlist_Item *rel;
117 Evas_Object *mode_view;
122 Elm_Tooltip_Item_Content_Cb content_cb;
123 Evas_Smart_Cb del_cb;
125 Eina_Bool free_size : 1;
128 const char *mouse_cursor;
135 Eina_Bool before : 1;
137 Eina_Bool want_unrealize : 1;
138 Eina_Bool want_realize : 1;
139 Eina_Bool realized : 1;
140 Eina_Bool selected : 1;
141 Eina_Bool highlighted : 1;
142 Eina_Bool expanded : 1;
143 Eina_Bool disabled : 1;
144 Eina_Bool display_only : 1;
145 Eina_Bool mincalcd : 1;
146 Eina_Bool queued : 1;
147 Eina_Bool showme : 1;
148 Eina_Bool delete_me : 1;
150 Eina_Bool dragging : 1;
151 Eina_Bool updateme : 1;
152 Eina_Bool nocache : 1;
153 Eina_Bool stacking_even : 1;
154 Eina_Bool nostacking : 1;
155 Eina_Bool move_effect_enabled : 1;
162 Evas_Object *base_view, *spacer;
164 const char *item_style; // it->itc->item_style
165 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
166 Eina_Bool compress : 1; // it->wd->compress
168 Eina_Bool selected : 1; // it->selected
169 Eina_Bool disabled : 1; // it->disabled
170 Eina_Bool expanded : 1; // it->expanded
173 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
174 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
178 Evas_Object_Smart_Clipped_Data __clipped_data;
180 Ecore_Job *resize_job;
183 static const char *widtype = NULL;
184 static void _item_cache_zero(Widget_Data *wd);
185 static void _del_hook(Evas_Object *obj);
186 static void _mirrored_set(Evas_Object *obj,
188 static void _theme_hook(Evas_Object *obj);
189 static void _show_region_hook(void *data,
191 static void _sizing_eval(Evas_Object *obj);
192 static void _item_realize(Elm_Genlist_Item *it,
195 static void _item_unrealize(Elm_Genlist_Item *it,
197 static void _item_block_unrealize(Item_Block *itb);
198 static void _calc_job(void *data);
199 static void _on_focus_hook(void *data,
201 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
202 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
203 static Eina_Bool _item_single_select_up(Widget_Data *wd);
204 static Eina_Bool _item_single_select_down(Widget_Data *wd);
205 static Eina_Bool _event_hook(Evas_Object *obj,
207 Evas_Callback_Type type,
209 static void _signal_emit_hook(Evas_Object *obj,
210 const char *emission,
212 static Eina_Bool _deselect_all_items(Widget_Data *wd);
213 static void _pan_calculate(Evas_Object *obj);
214 static void _item_position(Elm_Genlist_Item *it,
218 static void _mode_item_realize(Elm_Genlist_Item *it);
219 static void _mode_item_unrealize(Elm_Genlist_Item *it);
220 static void _item_mode_set(Elm_Genlist_Item *it);
221 static void _item_mode_unset(Widget_Data *wd);
222 static void _group_items_recalc(void *data);
223 static void _item_move_after(Elm_Genlist_Item *it,
224 Elm_Genlist_Item *after);
225 static void _item_move_before(Elm_Genlist_Item *it,
226 Elm_Genlist_Item *before);
227 static void _item_auto_scroll(Widget_Data *wd);
229 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
231 static const char SIG_ACTIVATED[] = "activated";
232 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
233 static const char SIG_SELECTED[] = "selected";
234 static const char SIG_UNSELECTED[] = "unselected";
235 static const char SIG_EXPANDED[] = "expanded";
236 static const char SIG_CONTRACTED[] = "contracted";
237 static const char SIG_EXPAND_REQUEST[] = "expand,request";
238 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
239 static const char SIG_REALIZED[] = "realized";
240 static const char SIG_UNREALIZED[] = "unrealized";
241 static const char SIG_DRAG_START_UP[] = "drag,start,up";
242 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
243 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
244 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
245 static const char SIG_DRAG_STOP[] = "drag,stop";
246 static const char SIG_DRAG[] = "drag";
247 static const char SIG_LONGPRESSED[] = "longpressed";
248 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
249 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
250 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
251 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
252 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
253 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
254 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
255 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
256 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
257 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
258 static const char SIG_SWIPE[] = "swipe";
260 static const Evas_Smart_Cb_Description _signals[] = {
261 {SIG_CLICKED_DOUBLE, ""},
264 {SIG_UNSELECTED, ""},
266 {SIG_CONTRACTED, ""},
267 {SIG_EXPAND_REQUEST, ""},
268 {SIG_CONTRACT_REQUEST, ""},
270 {SIG_UNREALIZED, ""},
271 {SIG_DRAG_START_UP, ""},
272 {SIG_DRAG_START_DOWN, ""},
273 {SIG_DRAG_START_LEFT, ""},
274 {SIG_DRAG_START_RIGHT, ""},
277 {SIG_LONGPRESSED, ""},
278 {SIG_SCROLL_EDGE_TOP, ""},
279 {SIG_SCROLL_EDGE_BOTTOM, ""},
280 {SIG_SCROLL_EDGE_LEFT, ""},
281 {SIG_SCROLL_EDGE_RIGHT, ""},
282 {SIG_MULTI_SWIPE_LEFT, ""},
283 {SIG_MULTI_SWIPE_RIGHT, ""},
284 {SIG_MULTI_SWIPE_UP, ""},
285 {SIG_MULTI_SWIPE_DOWN, ""},
286 {SIG_MULTI_PINCH_OUT, ""},
287 {SIG_MULTI_PINCH_IN, ""},
292 static Eina_Compare_Cb _elm_genlist_item_compare_cb;
293 static Eina_Compare_Cb _elm_genlist_item_compare_data_cb;
296 _event_hook(Evas_Object *obj,
297 Evas_Object *src __UNUSED__,
298 Evas_Callback_Type type,
301 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
302 Evas_Event_Key_Down *ev = event_info;
303 Widget_Data *wd = elm_widget_data_get(obj);
304 if (!wd) return EINA_FALSE;
305 if (!wd->items) return EINA_FALSE;
306 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
307 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
309 Elm_Genlist_Item *it = NULL;
312 Evas_Coord step_x = 0;
313 Evas_Coord step_y = 0;
316 Evas_Coord page_x = 0;
317 Evas_Coord page_y = 0;
319 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
320 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
321 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
322 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
324 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
328 else if ((!strcmp(ev->keyname, "Right")) ||
329 (!strcmp(ev->keyname, "KP_Right")))
333 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
335 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
336 (_item_multi_select_up(wd)))
337 || (_item_single_select_up(wd)))
339 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
345 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
347 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
348 (_item_multi_select_down(wd)))
349 || (_item_single_select_down(wd)))
351 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
357 else if ((!strcmp(ev->keyname, "Home")) ||
358 (!strcmp(ev->keyname, "KP_Home")))
360 it = elm_genlist_first_item_get(obj);
361 elm_genlist_item_bring_in(it);
362 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
365 else if ((!strcmp(ev->keyname, "End")) ||
366 (!strcmp(ev->keyname, "KP_End")))
368 it = elm_genlist_last_item_get(obj);
369 elm_genlist_item_bring_in(it);
370 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
373 else if ((!strcmp(ev->keyname, "Prior")) ||
374 (!strcmp(ev->keyname, "KP_Prior")))
377 y -= -(page_y * v_h) / 100;
381 else if ((!strcmp(ev->keyname, "Next")) ||
382 (!strcmp(ev->keyname, "KP_Next")))
385 y += -(page_y * v_h) / 100;
389 else if (((!strcmp(ev->keyname, "Return")) ||
390 (!strcmp(ev->keyname, "KP_Enter")) ||
391 (!strcmp(ev->keyname, "space")))
392 && (!wd->multi) && (wd->selected))
394 it = elm_genlist_selected_item_get(obj);
395 elm_genlist_item_expanded_set(it,
396 !elm_genlist_item_expanded_get(it));
397 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
399 else if (!strcmp(ev->keyname, "Escape"))
401 if (!_deselect_all_items(wd)) return EINA_FALSE;
402 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
405 else return EINA_FALSE;
407 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
408 elm_smart_scroller_child_pos_set(wd->scr, x, y);
413 _deselect_all_items(Widget_Data *wd)
415 if (!wd->selected) return EINA_FALSE;
417 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
423 _item_multi_select_up(Widget_Data *wd)
425 if (!wd->selected) return EINA_FALSE;
426 if (!wd->multi) return EINA_FALSE;
428 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
429 if (!prev) return EINA_TRUE;
431 if (elm_genlist_item_selected_get(prev))
433 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
434 wd->last_selected_item = prev;
435 elm_genlist_item_show(wd->last_selected_item);
439 elm_genlist_item_selected_set(prev, EINA_TRUE);
440 elm_genlist_item_show(prev);
446 _item_multi_select_down(Widget_Data *wd)
448 if (!wd->selected) return EINA_FALSE;
449 if (!wd->multi) return EINA_FALSE;
451 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
452 if (!next) return EINA_TRUE;
454 if (elm_genlist_item_selected_get(next))
456 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
457 wd->last_selected_item = next;
458 elm_genlist_item_show(wd->last_selected_item);
462 elm_genlist_item_selected_set(next, EINA_TRUE);
463 elm_genlist_item_show(next);
469 _item_single_select_up(Widget_Data *wd)
471 Elm_Genlist_Item *prev;
474 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
475 while ((prev) && (prev->delete_me))
476 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
478 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
480 if (!prev) return EINA_FALSE;
482 _deselect_all_items(wd);
484 elm_genlist_item_selected_set(prev, EINA_TRUE);
485 elm_genlist_item_show(prev);
490 _item_single_select_down(Widget_Data *wd)
492 Elm_Genlist_Item *next;
495 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
496 while ((next) && (next->delete_me))
497 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
499 else next = elm_genlist_item_next_get(wd->last_selected_item);
501 if (!next) return EINA_FALSE;
503 _deselect_all_items(wd);
505 elm_genlist_item_selected_set(next, EINA_TRUE);
506 elm_genlist_item_show(next);
511 _on_focus_hook(void *data __UNUSED__,
514 Widget_Data *wd = elm_widget_data_get(obj);
516 if (elm_widget_focus_get(obj))
518 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
519 evas_object_focus_set(wd->obj, EINA_TRUE);
520 if ((wd->selected) && (!wd->last_selected_item))
521 wd->last_selected_item = eina_list_data_get(wd->selected);
525 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
526 evas_object_focus_set(wd->obj, EINA_FALSE);
531 _del_hook(Evas_Object *obj)
533 Widget_Data *wd = elm_widget_data_get(obj);
535 _item_cache_zero(wd);
536 if (wd->calc_job) ecore_job_del(wd->calc_job);
537 if (wd->update_job) ecore_job_del(wd->update_job);
538 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
539 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
540 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
541 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
542 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
547 _del_pre_hook(Evas_Object *obj)
549 Widget_Data *wd = elm_widget_data_get(obj);
551 evas_object_del(wd->pan_smart);
552 wd->pan_smart = NULL;
553 elm_genlist_clear(obj);
557 _mirrored_set(Evas_Object *obj,
560 Widget_Data *wd = elm_widget_data_get(obj);
562 _item_cache_zero(wd);
563 elm_smart_scroller_mirrored_set(wd->scr, rtl);
567 _theme_hook(Evas_Object *obj)
569 Widget_Data *wd = elm_widget_data_get(obj);
572 evas_event_freeze(evas_object_evas_get(wd->obj));
573 _item_cache_zero(wd);
574 _elm_widget_mirrored_reload(obj);
575 _mirrored_set(obj, elm_widget_mirrored_get(obj));
576 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
577 elm_widget_style_get(obj));
578 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
579 wd->item_width = wd->item_height = 0;
580 wd->group_item_width = wd->group_item_height = 0;
581 wd->minw = wd->minh = wd->realminw = 0;
582 EINA_INLIST_FOREACH(wd->blocks, itb)
585 Elm_Genlist_Item *it;
587 if (itb->realized) _item_block_unrealize(itb);
588 EINA_LIST_FOREACH(itb->items, l, it)
589 it->mincalcd = EINA_FALSE;
591 itb->changed = EINA_TRUE;
593 if (wd->calc_job) ecore_job_del(wd->calc_job);
594 wd->calc_job = ecore_job_add(_calc_job, wd);
596 evas_event_thaw(evas_object_evas_get(wd->obj));
597 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
601 _show_region_hook(void *data,
604 Widget_Data *wd = elm_widget_data_get(data);
605 Evas_Coord x, y, w, h;
607 elm_widget_show_region_get(obj, &x, &y, &w, &h);
608 //x & y are screen coordinates, Add with pan coordinates
611 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
615 _sizing_eval(Evas_Object *obj)
617 Widget_Data *wd = elm_widget_data_get(obj);
618 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
620 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
621 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
623 if (wd->height_for_width)
627 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
628 if ((vw != 0) && (vw != wd->prev_viewport_w))
632 wd->prev_viewport_w = vw;
633 EINA_INLIST_FOREACH(wd->blocks, itb)
635 itb->must_recalc = EINA_TRUE;
637 if (wd->calc_job) ecore_job_del(wd->calc_job);
638 wd->calc_job = ecore_job_add(_calc_job, wd);
641 if (wd->mode == ELM_LIST_LIMIT)
643 Evas_Coord vmw, vmh, vw, vh;
647 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
648 if ((minw > 0) && (vw < minw)) vw = minw;
649 else if ((maxw > 0) && (vw > maxw))
651 edje_object_size_min_calc
652 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
659 edje_object_size_min_calc
660 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
664 evas_object_size_hint_min_set(obj, minw, minh);
665 evas_object_size_hint_max_set(obj, maxw, maxh);
669 _signal_emit_hook(Evas_Object *obj,
670 const char *emission,
673 Widget_Data *wd = elm_widget_data_get(obj);
674 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
679 _item_highlight(Elm_Genlist_Item *it)
681 const char *selectraise;
682 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
683 (it->disabled) || (it->display_only) || (it->mode_view))
685 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
686 selectraise = edje_object_data_get(it->base.view, "selectraise");
687 if ((selectraise) && (!strcmp(selectraise, "on")))
689 evas_object_raise(it->base.view);
690 if ((it->group_item) && (it->group_item->realized))
691 evas_object_raise(it->group_item->base.view);
693 it->highlighted = EINA_TRUE;
697 _item_unhighlight(Elm_Genlist_Item *it)
699 const char *stacking, *selectraise;
700 if ((it->delete_me) || (!it->highlighted)) return;
701 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
702 stacking = edje_object_data_get(it->base.view, "stacking");
703 selectraise = edje_object_data_get(it->base.view, "selectraise");
706 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
707 else evas_object_raise(it->base.view);
709 it->highlighted = EINA_FALSE;
713 _item_block_del(Elm_Genlist_Item *it)
716 Item_Block *itb = it->block;
718 itb->items = eina_list_remove(itb->items, it);
720 itb->changed = EINA_TRUE;
721 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
722 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
725 il = EINA_INLIST_GET(itb);
726 Item_Block *itbn = (Item_Block *)(il->next);
728 it->parent->items = eina_list_remove(it->parent->items, it);
730 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
732 if (itbn) itbn->changed = EINA_TRUE;
736 if (itb->count < itb->wd->max_items_per_block/2)
738 il = EINA_INLIST_GET(itb);
739 Item_Block *itbp = (Item_Block *)(il->prev);
740 Item_Block *itbn = (Item_Block *)(il->next);
741 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
743 Elm_Genlist_Item *it2;
745 EINA_LIST_FREE(itb->items, it2)
748 itbp->items = eina_list_append(itbp->items, it2);
750 itbp->changed = EINA_TRUE;
752 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
753 EINA_INLIST_GET(itb));
756 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
760 Eina_List *last = eina_list_last(itb->items);
761 Elm_Genlist_Item *it2 = last->data;
764 itb->items = eina_list_remove_list(itb->items, last);
765 itbn->items = eina_list_prepend(itbn->items, it2);
767 itbn->changed = EINA_TRUE;
770 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
778 _item_del(Elm_Genlist_Item *it)
780 Evas_Object *tob = it->wd->obj;
782 evas_event_freeze(evas_object_evas_get(tob));
783 elm_widget_item_pre_notify_del(it);
784 elm_genlist_item_subitems_clear(it);
785 it->wd->walking -= it->walking;
786 if (it->wd->show_item == it) it->wd->show_item = NULL;
787 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
788 if (it->realized) _item_unrealize(it, EINA_FALSE);
789 if (it->block) _item_block_del(it);
790 if ((!it->delete_me) && (it->itc->func.del))
791 it->itc->func.del((void *)it->base.data, it->base.widget);
792 it->delete_me = EINA_TRUE;
794 it->wd->queue = eina_list_remove(it->wd->queue, it);
795 if (it->wd->anchor_item == it)
797 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
798 if (!it->wd->anchor_item)
799 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
801 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
803 it->parent->items = eina_list_remove(it->parent->items, it);
804 if (it->flags & ELM_GENLIST_ITEM_GROUP)
805 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
806 if (it->long_timer) ecore_timer_del(it->long_timer);
807 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
809 if (it->tooltip.del_cb)
810 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
812 evas_event_thaw(evas_object_evas_get(tob));
813 evas_event_thaw_eval(evas_object_evas_get(tob));
815 elm_widget_item_del(it);
819 _item_select(Elm_Genlist_Item *it)
821 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
824 if (it->wd->always_select) goto call;
827 it->selected = EINA_TRUE;
828 it->wd->selected = eina_list_append(it->wd->selected, it);
832 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
834 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
837 if ((it->wd->clear_me) && (!it->wd->walking))
838 elm_genlist_clear(it->base.widget);
841 if ((!it->walking) && (it->delete_me))
843 if (!it->relcount) _item_del(it);
846 it->wd->last_selected_item = it;
850 _item_unselect(Elm_Genlist_Item *it)
852 if ((it->delete_me) || (!it->selected)) return;
853 it->selected = EINA_FALSE;
854 it->wd->selected = eina_list_remove(it->wd->selected, it);
855 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
859 _mouse_move(void *data,
860 Evas *evas __UNUSED__,
864 Elm_Genlist_Item *it = data;
865 Evas_Event_Mouse_Move *ev = event_info;
866 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
867 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
869 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
871 if (!it->wd->on_hold)
873 it->wd->on_hold = EINA_TRUE;
874 if (!it->wd->wasselected)
876 _item_unhighlight(it);
881 if (it->wd->multitouched)
883 it->wd->cur_x = ev->cur.canvas.x;
884 it->wd->cur_y = ev->cur.canvas.y;
887 if ((it->dragging) && (it->down))
889 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
892 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
893 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
894 if (abs((it->wd->history[it->wd->movements].x -
895 it->wd->history[0].x)) > 40)
896 it->wd->swipe = EINA_TRUE;
902 ecore_timer_del(it->long_timer);
903 it->long_timer = NULL;
905 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
908 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
912 ecore_timer_del(it->long_timer);
913 it->long_timer = NULL;
915 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
917 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
918 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
920 if (!it->wd->reorder_start_y)
921 it->wd->reorder_start_y = it->block->y + it->y;
923 if (it_scrl_y < oy) y_pos = oy;
924 else if (it_scrl_y + it->wd->reorder_it->h > oy+oh)
925 y_pos = oy + oh - it->wd->reorder_it->h;
926 else y_pos = it_scrl_y;
928 _item_position(it, it->base.view, it->scrl_x, y_pos);
930 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
931 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
935 if (!it->display_only)
936 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
937 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
938 x = ev->cur.canvas.x - x;
939 y = ev->cur.canvas.y - y;
942 if (adx < 0) adx = -dx;
945 if (ady < 0) ady = -dy;
948 if ((adx > minw) || (ady > minh))
950 it->dragging = EINA_TRUE;
953 ecore_timer_del(it->long_timer);
954 it->long_timer = NULL;
956 if (!it->wd->wasselected)
958 _item_unhighlight(it);
964 evas_object_smart_callback_call(it->base.widget,
965 SIG_DRAG_START_UP, it);
969 evas_object_smart_callback_call(it->base.widget,
970 SIG_DRAG_START_LEFT, it);
972 evas_object_smart_callback_call(it->base.widget,
973 SIG_DRAG_START_RIGHT, it);
979 evas_object_smart_callback_call(it->base.widget,
980 SIG_DRAG_START_DOWN, it);
984 evas_object_smart_callback_call(it->base.widget,
985 SIG_DRAG_START_LEFT, it);
987 evas_object_smart_callback_call(it->base.widget,
988 SIG_DRAG_START_RIGHT, it);
995 _long_press(void *data)
997 Elm_Genlist_Item *it = data, *it_tmp;
1000 it->long_timer = NULL;
1001 if ((it->disabled) || (it->dragging) || (it->display_only))
1002 return ECORE_CALLBACK_CANCEL;
1003 it->wd->longpressed = EINA_TRUE;
1004 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1005 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1007 it->wd->reorder_it = it;
1008 it->wd->reorder_start_y = 0;
1010 evas_object_raise(it->base.view);
1011 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1013 list = elm_genlist_realized_items_get(it->wd->obj);
1014 EINA_LIST_FOREACH(list, l, it_tmp)
1016 if (it != it_tmp) _item_unselect(it_tmp);
1018 if (elm_genlist_item_expanded_get(it))
1020 elm_genlist_item_expanded_set(it, EINA_FALSE);
1021 return ECORE_CALLBACK_RENEW;
1023 edje_object_signal_emit(it->base.view, "elm,state,reorder,enabled", "elm");
1025 return ECORE_CALLBACK_CANCEL;
1029 _swipe(Elm_Genlist_Item *it)
1034 if ((it->display_only) || (it->disabled)) return;
1035 it->wd->swipe = EINA_FALSE;
1036 for (i = 0; i < it->wd->movements; i++)
1038 sum += it->wd->history[i].x;
1039 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1042 sum /= it->wd->movements;
1043 if (abs(sum - it->wd->history[0].x) <= 10) return;
1044 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1048 _swipe_cancel(void *data)
1050 Elm_Genlist_Item *it = data;
1052 if (!it) return ECORE_CALLBACK_CANCEL;
1053 it->wd->swipe = EINA_FALSE;
1054 it->wd->movements = 0;
1055 return ECORE_CALLBACK_RENEW;
1059 _multi_cancel(void *data)
1061 Widget_Data *wd = data;
1063 if (!wd) return ECORE_CALLBACK_CANCEL;
1064 wd->multi_timeout = EINA_TRUE;
1065 return ECORE_CALLBACK_RENEW;
1069 _multi_touch_gesture_eval(void *data)
1071 Elm_Genlist_Item *it = data;
1073 it->wd->multitouched = EINA_FALSE;
1074 if (it->wd->multi_timer)
1076 ecore_timer_del(it->wd->multi_timer);
1077 it->wd->multi_timer = NULL;
1079 if (it->wd->multi_timeout)
1081 it->wd->multi_timeout = EINA_FALSE;
1085 Evas_Coord minw = 0, minh = 0;
1086 Evas_Coord off_x, off_y, off_mx, off_my;
1088 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1089 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1090 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1091 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1092 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1094 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1096 if ((off_x + off_mx) > (off_y + off_my))
1098 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1099 evas_object_smart_callback_call(it->base.widget,
1100 SIG_MULTI_SWIPE_RIGHT, it);
1101 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1102 evas_object_smart_callback_call(it->base.widget,
1103 SIG_MULTI_SWIPE_LEFT, it);
1104 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1105 evas_object_smart_callback_call(it->base.widget,
1106 SIG_MULTI_PINCH_OUT, it);
1108 evas_object_smart_callback_call(it->base.widget,
1109 SIG_MULTI_PINCH_IN, it);
1113 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1114 evas_object_smart_callback_call(it->base.widget,
1115 SIG_MULTI_SWIPE_DOWN, it);
1116 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1117 evas_object_smart_callback_call(it->base.widget,
1118 SIG_MULTI_SWIPE_UP, it);
1119 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1120 evas_object_smart_callback_call(it->base.widget,
1121 SIG_MULTI_PINCH_OUT, it);
1123 evas_object_smart_callback_call(it->base.widget,
1124 SIG_MULTI_PINCH_IN, it);
1127 it->wd->multi_timeout = EINA_FALSE;
1131 _multi_down(void *data,
1132 Evas *evas __UNUSED__,
1133 Evas_Object *obj __UNUSED__,
1136 Elm_Genlist_Item *it = data;
1137 Evas_Event_Multi_Down *ev = event_info;
1139 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1140 it->wd->multi_device = ev->device;
1141 it->wd->multi_down = EINA_TRUE;
1142 it->wd->multitouched = EINA_TRUE;
1143 it->wd->prev_mx = ev->canvas.x;
1144 it->wd->prev_my = ev->canvas.y;
1145 if (!it->wd->wasselected)
1147 _item_unhighlight(it);
1150 it->wd->wasselected = EINA_FALSE;
1151 it->wd->longpressed = EINA_FALSE;
1154 ecore_timer_del(it->long_timer);
1155 it->long_timer = NULL;
1159 it->dragging = EINA_FALSE;
1160 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1162 if (it->swipe_timer)
1164 ecore_timer_del(it->swipe_timer);
1165 it->swipe_timer = NULL;
1167 if (it->wd->on_hold)
1169 it->wd->swipe = EINA_FALSE;
1170 it->wd->movements = 0;
1171 it->wd->on_hold = EINA_FALSE;
1176 _multi_up(void *data,
1177 Evas *evas __UNUSED__,
1178 Evas_Object *obj __UNUSED__,
1181 Elm_Genlist_Item *it = data;
1182 Evas_Event_Multi_Up *ev = event_info;
1184 if (it->wd->multi_device != ev->device) return;
1185 it->wd->multi_device = 0;
1186 it->wd->multi_down = EINA_FALSE;
1187 if (it->wd->mouse_down) return;
1188 _multi_touch_gesture_eval(data);
1192 _multi_move(void *data,
1193 Evas *evas __UNUSED__,
1194 Evas_Object *obj __UNUSED__,
1197 Elm_Genlist_Item *it = data;
1198 Evas_Event_Multi_Move *ev = event_info;
1200 if (it->wd->multi_device != ev->device) return;
1201 it->wd->cur_mx = ev->cur.canvas.x;
1202 it->wd->cur_my = ev->cur.canvas.y;
1206 _mouse_down(void *data,
1207 Evas *evas __UNUSED__,
1211 Elm_Genlist_Item *it = data;
1212 Evas_Event_Mouse_Down *ev = event_info;
1215 if (ev->button != 1) return;
1216 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1218 it->wd->on_hold = EINA_TRUE;
1221 it->down = EINA_TRUE;
1222 it->dragging = EINA_FALSE;
1223 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1224 it->dx = ev->canvas.x - x;
1225 it->dy = ev->canvas.y - y;
1226 it->wd->mouse_down = EINA_TRUE;
1227 if (!it->wd->multitouched)
1229 it->wd->prev_x = ev->canvas.x;
1230 it->wd->prev_y = ev->canvas.y;
1231 it->wd->multi_timeout = EINA_FALSE;
1232 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1233 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1235 it->wd->longpressed = EINA_FALSE;
1236 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1237 else it->wd->on_hold = EINA_FALSE;
1238 if (it->wd->on_hold) return;
1239 it->wd->wasselected = it->selected;
1240 _item_highlight(it);
1241 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1242 if ((!it->disabled) && (!it->display_only))
1244 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1245 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
1247 if (it->long_timer) ecore_timer_del(it->long_timer);
1248 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1249 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1251 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1254 it->long_timer = NULL;
1255 it->wd->swipe = EINA_FALSE;
1256 it->wd->movements = 0;
1260 _mouse_up(void *data,
1261 Evas *evas __UNUSED__,
1262 Evas_Object *obj __UNUSED__,
1265 Elm_Genlist_Item *it = data;
1266 Evas_Event_Mouse_Up *ev = event_info;
1267 Eina_Bool dragged = EINA_FALSE;
1269 if (ev->button != 1) return;
1270 it->down = EINA_FALSE;
1271 it->wd->mouse_down = EINA_FALSE;
1272 if (it->wd->multitouched)
1274 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1275 if (it->wd->multi_down) return;
1276 _multi_touch_gesture_eval(data);
1279 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1280 else it->wd->on_hold = EINA_FALSE;
1283 ecore_timer_del(it->long_timer);
1284 it->long_timer = NULL;
1288 it->dragging = EINA_FALSE;
1289 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1292 if (it->swipe_timer)
1294 ecore_timer_del(it->swipe_timer);
1295 it->swipe_timer = NULL;
1297 if (it->wd->multi_timer)
1299 ecore_timer_del(it->wd->multi_timer);
1300 it->wd->multi_timer = NULL;
1301 it->wd->multi_timeout = EINA_FALSE;
1303 if (it->wd->on_hold)
1305 if (it->wd->swipe) _swipe(data);
1306 it->wd->longpressed = EINA_FALSE;
1307 it->wd->on_hold = EINA_FALSE;
1310 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1312 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1314 if (it->wd->reorder_rel)
1316 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent)
1318 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1319 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1321 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1325 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1326 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1329 edje_object_signal_emit(it->base.view, "elm,state,reorder,disabled", "elm");
1330 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1331 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1333 if (it->wd->longpressed)
1335 it->wd->longpressed = EINA_FALSE;
1336 if (!it->wd->wasselected)
1338 _item_unhighlight(it);
1341 it->wd->wasselected = EINA_FALSE;
1346 if (it->want_unrealize)
1348 _item_unrealize(it, EINA_FALSE);
1349 if (it->block->want_unrealize)
1350 _item_block_unrealize(it->block);
1353 if ((it->disabled) || (dragged) || (it->display_only)) return;
1354 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1359 _item_highlight(it);
1364 _item_unhighlight(it);
1372 Widget_Data *wd = it->wd;
1375 while (wd->selected)
1377 _item_unhighlight(wd->selected->data);
1378 _item_unselect(wd->selected->data);
1384 const Eina_List *l, *l_next;
1385 Elm_Genlist_Item *it2;
1387 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1390 _item_unhighlight(it2);
1391 _item_unselect(it2);
1393 //_item_highlight(it);
1396 _item_highlight(it);
1402 _signal_expand_toggle(void *data,
1403 Evas_Object *obj __UNUSED__,
1404 const char *emission __UNUSED__,
1405 const char *source __UNUSED__)
1407 Elm_Genlist_Item *it = data;
1410 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1412 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1416 _signal_expand(void *data,
1417 Evas_Object *obj __UNUSED__,
1418 const char *emission __UNUSED__,
1419 const char *source __UNUSED__)
1421 Elm_Genlist_Item *it = data;
1424 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1428 _signal_contract(void *data,
1429 Evas_Object *obj __UNUSED__,
1430 const char *emission __UNUSED__,
1431 const char *source __UNUSED__)
1433 Elm_Genlist_Item *it = data;
1436 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1440 _scr_hold_timer_cb(void *data)
1442 if (!data) return ECORE_CALLBACK_CANCEL;
1443 Widget_Data *wd = data;
1444 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1445 wd->scr_hold_timer = NULL;
1446 return ECORE_CALLBACK_CANCEL;
1450 _mode_finished_signal_cb(void *data,
1452 const char *emission __UNUSED__,
1453 const char *source __UNUSED__)
1457 Elm_Genlist_Item *it = data;
1458 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1460 Evas *te = evas_object_evas_get(obj);
1462 evas_event_freeze(te);
1463 it->nocache = EINA_FALSE;
1464 _mode_item_unrealize(it);
1465 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1466 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1467 evas_event_thaw(te);
1468 evas_event_thaw_eval(te);
1472 _item_cache_clean(Widget_Data *wd)
1474 evas_event_freeze(evas_object_evas_get(wd->obj));
1475 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1479 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1480 wd->item_cache = eina_inlist_remove(wd->item_cache,
1481 wd->item_cache->last);
1482 wd->item_cache_count--;
1483 if (itc->spacer) evas_object_del(itc->spacer);
1484 if (itc->base_view) evas_object_del(itc->base_view);
1485 if (itc->item_style) eina_stringshare_del(itc->item_style);
1488 evas_event_thaw(evas_object_evas_get(wd->obj));
1489 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1493 _item_cache_zero(Widget_Data *wd)
1495 int pmax = wd->item_cache_max;
1496 wd->item_cache_max = 0;
1497 _item_cache_clean(wd);
1498 wd->item_cache_max = pmax;
1502 _item_cache_add(Elm_Genlist_Item *it)
1506 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1507 if (it->wd->item_cache_max <= 0)
1509 evas_object_del(it->base.view);
1510 it->base.view = NULL;
1511 evas_object_del(it->spacer);
1513 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1514 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1518 it->wd->item_cache_count++;
1519 itc = calloc(1, sizeof(Item_Cache));
1520 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1521 EINA_INLIST_GET(itc));
1522 itc->spacer = it->spacer;
1524 itc->base_view = it->base.view;
1525 it->base.view = NULL;
1526 evas_object_hide(itc->base_view);
1527 evas_object_move(itc->base_view, -9999, -9999);
1528 itc->item_style = eina_stringshare_add(it->itc->item_style);
1529 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1530 itc->compress = (it->wd->compress);
1531 itc->selected = it->selected;
1532 itc->disabled = it->disabled;
1533 itc->expanded = it->expanded;
1536 ecore_timer_del(it->long_timer);
1537 it->long_timer = NULL;
1539 if (it->swipe_timer)
1541 ecore_timer_del(it->swipe_timer);
1542 it->swipe_timer = NULL;
1544 // FIXME: other callbacks?
1545 edje_object_signal_callback_del_full(itc->base_view,
1546 "elm,action,expand,toggle",
1547 "elm", _signal_expand_toggle, it);
1548 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1550 _signal_expand, it);
1551 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1552 "elm", _signal_contract, it);
1553 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1555 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1557 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1559 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1561 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1563 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1565 _item_cache_clean(it->wd);
1566 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1567 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1571 _item_cache_find(Elm_Genlist_Item *it)
1576 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1577 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1579 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1581 if ((itc->tree == tree) &&
1582 (itc->compress == it->wd->compress) &&
1583 (!strcmp(it->itc->item_style, itc->item_style)))
1585 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1586 EINA_INLIST_GET(itc));
1587 it->wd->item_cache_count--;
1595 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1597 if (!it->nostacking)
1599 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1600 evas_object_lower(it->base.view);
1602 evas_object_raise(it->base.view);
1605 if (it->order_num_in & 0x1)
1606 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1608 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1612 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1616 if (it->selected != itc->selected)
1619 edje_object_signal_emit(it->base.view,
1620 "elm,state,selected", "elm");
1622 if (it->disabled != itc->disabled)
1625 edje_object_signal_emit(it->base.view,
1626 "elm,state,disabled", "elm");
1628 if (it->expanded != itc->expanded)
1631 edje_object_signal_emit(it->base.view,
1632 "elm,state,expanded", "elm");
1638 edje_object_signal_emit(it->base.view,
1639 "elm,state,selected", "elm");
1641 edje_object_signal_emit(it->base.view,
1642 "elm,state,disabled", "elm");
1644 edje_object_signal_emit(it->base.view,
1645 "elm,state,expanded", "elm");
1650 _item_cache_free(Item_Cache *itc)
1652 if (itc->spacer) evas_object_del(itc->spacer);
1653 if (itc->base_view) evas_object_del(itc->base_view);
1654 if (itc->item_style) eina_stringshare_del(itc->item_style);
1659 _item_label_realize(Elm_Genlist_Item *it,
1660 Evas_Object *target,
1663 if (it->itc->func.label_get)
1668 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1669 EINA_LIST_FOREACH(*source, l, key)
1671 char *s = it->itc->func.label_get
1672 ((void *)it->base.data, it->base.widget, key);
1676 edje_object_part_text_set(target, key, s);
1681 edje_object_part_text_set(target, key, "");
1688 _item_icon_realize(Elm_Genlist_Item *it,
1689 Evas_Object *target,
1692 Eina_List *res = NULL;
1694 if (it->itc->func.icon_get)
1699 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1700 EINA_LIST_FOREACH(*source, l, key)
1702 Evas_Object *ic = it->itc->func.icon_get
1703 ((void *)it->base.data, it->base.widget, key);
1707 res = eina_list_append(res, ic);
1708 edje_object_part_swallow(target, key, ic);
1709 evas_object_show(ic);
1710 elm_widget_sub_object_add(it->base.widget, ic);
1712 elm_widget_disabled_set(ic, EINA_TRUE);
1721 _item_state_realize(Elm_Genlist_Item *it,
1722 Evas_Object *target,
1725 if (it->itc->func.state_get)
1731 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1732 EINA_LIST_FOREACH(*source, l, key)
1734 Eina_Bool on = it->itc->func.state_get
1735 ((void *)it->base.data, it->base.widget, key);
1739 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1740 edje_object_signal_emit(target, buf, "elm");
1744 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1745 edje_object_signal_emit(target, buf, "elm");
1752 _item_realize(Elm_Genlist_Item *it,
1756 Elm_Genlist_Item *it2;
1757 const char *treesize;
1759 int depth, tsize = 20;
1760 Item_Cache *itc = NULL;
1762 if (it->delete_me) return;
1763 //evas_event_freeze(evas_object_evas_get(it->wd->obj));
1766 if (it->order_num_in != in)
1768 it->order_num_in = in;
1769 _elm_genlist_item_odd_even_update(it);
1770 _elm_genlist_item_state_update(it, NULL);
1772 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1773 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1776 it->order_num_in = in;
1779 it->nocache = EINA_FALSE;
1781 itc = _item_cache_find(it);
1784 it->base.view = itc->base_view;
1785 itc->base_view = NULL;
1786 it->spacer = itc->spacer;
1791 const char *stacking_even;
1792 const char *stacking;
1794 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1795 edje_object_scale_set(it->base.view,
1796 elm_widget_scale_get(it->base.widget) *
1797 _elm_config->scale);
1798 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1799 elm_widget_sub_object_add(it->base.widget, it->base.view);
1801 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1802 strncpy(buf, "tree", sizeof(buf));
1803 else strncpy(buf, "item", sizeof(buf));
1804 if (it->wd->compress)
1805 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1807 strncat(buf, "/", sizeof(buf) - strlen(buf));
1808 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1810 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1811 elm_widget_style_get(it->base.widget));
1813 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1814 if (!stacking_even) stacking_even = "above";
1815 it->stacking_even = !!strcmp("above", stacking_even);
1817 stacking = edje_object_data_get(it->base.view, "stacking");
1818 if (!stacking) stacking = "yes";
1819 it->nostacking = !!strcmp("yes", stacking);
1821 edje_object_mirrored_set(it->base.view,
1822 elm_widget_mirrored_get(it->base.widget));
1824 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1825 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1826 elm_widget_sub_object_add(it->base.widget, it->spacer);
1829 _elm_genlist_item_odd_even_update(it);
1831 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1833 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1835 it->expanded_depth = depth;
1836 treesize = edje_object_data_get(it->base.view, "treesize");
1837 if (treesize) tsize = atoi(treesize);
1838 evas_object_size_hint_min_set(it->spacer,
1839 (depth * tsize) * _elm_config->scale, 1);
1840 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1843 edje_object_signal_callback_add(it->base.view,
1844 "elm,action,expand,toggle",
1845 "elm", _signal_expand_toggle, it);
1846 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1847 "elm", _signal_expand, it);
1848 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1849 "elm", _signal_contract, it);
1850 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1852 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1854 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1856 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1858 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1860 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1863 _elm_genlist_item_state_update(it, itc);
1866 if ((calc) && (it->wd->homogeneous) &&
1867 ((it->wd->item_width) ||
1868 ((it->wd->item_width) && (it->wd->group_item_width))))
1870 /* homogenous genlist shortcut */
1873 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1875 it->w = it->minw = it->wd->group_item_width;
1876 it->h = it->minh = it->wd->group_item_height;
1880 it->w = it->minw = it->wd->item_width;
1881 it->h = it->minh = it->wd->item_height;
1883 it->mincalcd = EINA_TRUE;
1888 /* FIXME: If you see that assert, please notify us and we
1889 will clean our mess */
1890 assert(eina_list_count(it->icon_objs) == 0);
1892 _item_label_realize(it, it->base.view, &it->labels);
1893 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
1894 _item_state_realize(it, it->base.view, &it->states);
1898 Evas_Coord mw = -1, mh = -1;
1900 if (!it->display_only)
1901 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1902 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1903 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1905 if (!it->display_only)
1906 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1907 it->w = it->minw = mw;
1908 it->h = it->minh = mh;
1909 it->mincalcd = EINA_TRUE;
1911 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1913 it->wd->group_item_width = mw;
1914 it->wd->group_item_height = mh;
1916 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1918 it->wd->item_width = mw;
1919 it->wd->item_height = mh;
1922 if (!calc) evas_object_show(it->base.view);
1925 if (it->tooltip.content_cb)
1927 elm_widget_item_tooltip_content_cb_set(it,
1928 it->tooltip.content_cb,
1929 it->tooltip.data, NULL);
1930 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1931 elm_widget_item_tooltip_size_restrict_disable(it, it->tooltip.free_size);
1934 if (it->mouse_cursor)
1935 elm_widget_item_cursor_set(it, it->mouse_cursor);
1937 it->realized = EINA_TRUE;
1938 it->want_unrealize = EINA_FALSE;
1940 if (itc) _item_cache_free(itc);
1941 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1942 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1944 evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
1945 edje_object_message_signal_process(it->base.view);
1949 _item_unrealize(Elm_Genlist_Item *it,
1954 if (!it->realized) return;
1955 if (it->wd->reorder_it == it) return;
1956 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1958 evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
1961 ecore_timer_del(it->long_timer);
1962 it->long_timer = NULL;
1966 evas_object_del(it->base.view);
1967 it->base.view = NULL;
1968 evas_object_del(it->spacer);
1973 edje_object_mirrored_set(it->base.view,
1974 elm_widget_mirrored_get(it->base.widget));
1975 edje_object_scale_set(it->base.view,
1976 elm_widget_scale_get(it->base.widget)
1977 * _elm_config->scale);
1978 _item_cache_add(it);
1980 elm_widget_stringlist_free(it->labels);
1982 elm_widget_stringlist_free(it->icons);
1984 elm_widget_stringlist_free(it->states);
1986 EINA_LIST_FREE(it->icon_objs, icon)
1987 evas_object_del(icon);
1989 _mode_item_unrealize(it);
1991 it->realized = EINA_FALSE;
1992 it->want_unrealize = EINA_FALSE;
1993 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1994 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1998 _item_block_recalc(Item_Block *itb,
2003 Elm_Genlist_Item *it;
2004 Evas_Coord minw = 0, minh = 0;
2005 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2008 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2010 EINA_LIST_FOREACH(itb->items, l, it)
2012 if (it->delete_me) continue;
2013 showme |= it->showme;
2018 if (!it->mincalcd) changed = EINA_TRUE;
2021 _item_realize(it, in, EINA_TRUE);
2022 _item_unrealize(it, EINA_TRUE);
2027 _item_realize(it, in, EINA_TRUE);
2028 _item_unrealize(it, EINA_TRUE);
2032 _item_realize(it, in, EINA_FALSE);
2034 if (minw < it->minw) minw = it->minw;
2042 itb->changed = EINA_FALSE;
2043 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2044 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2049 _item_block_realize(Item_Block *itb)
2051 if (itb->realized) return;
2052 itb->realized = EINA_TRUE;
2053 itb->want_unrealize = EINA_FALSE;
2057 _item_block_unrealize(Item_Block *itb)
2060 Elm_Genlist_Item *it;
2061 Eina_Bool dragging = EINA_FALSE;
2063 if (!itb->realized) return;
2064 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2065 EINA_LIST_FOREACH(itb->items, l, it)
2067 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2071 dragging = EINA_TRUE;
2072 it->want_unrealize = EINA_TRUE;
2075 _item_unrealize(it, EINA_FALSE);
2080 itb->realized = EINA_FALSE;
2081 itb->want_unrealize = EINA_TRUE;
2084 itb->want_unrealize = EINA_FALSE;
2085 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2086 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2090 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2092 Evas_Coord rox, roy, row, roh, oy, oh;
2093 Eina_Bool top = EINA_FALSE;
2094 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2095 if (!reorder_it) return 0;
2097 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2098 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2100 if ((it->wd->reorder_start_y < it->block->y) &&
2101 (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2103 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2104 if (it->block->count == 1)
2105 it->wd->reorder_rel = it;
2107 else if ((it->wd->reorder_start_y >= it->block->y) &&
2108 (roy - oy + (roh / 2) <= it->block->y - it->wd->pan_y))
2110 it->block->reorder_offset = it->wd->reorder_it->h;
2113 it->block->reorder_offset = 0;
2115 it->scrl_y += it->block->reorder_offset;
2117 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2118 rox, roy + (roh / 2), row, 1));
2121 it->wd->reorder_rel = it;
2122 it->scrl_y += it->wd->reorder_it->h;
2123 return it->wd->reorder_it->h;
2130 _reorder_move_animator_cb(void *data)
2132 Elm_Genlist_Item *it = data;
2133 Eina_Bool down = EINA_FALSE;
2135 int y, dy = it->h / 10 * _elm_config->scale, diff;
2137 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2139 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2142 diff = abs(it->old_scrl_y - it->scrl_y);
2143 if (diff > it->h) y = diff / 2;
2145 if (it->old_scrl_y < it->scrl_y)
2147 it->old_scrl_y += y;
2150 else if (it->old_scrl_y > it->scrl_y)
2152 it->old_scrl_y -= y;
2155 _item_position(it, it->base.view, it->scrl_x, it->old_scrl_y);
2156 _group_items_recalc(it->wd);
2158 if ((it->wd->reorder_pan_move) ||
2159 (down && it->old_scrl_y >= it->scrl_y) ||
2160 (!down && it->old_scrl_y <= it->scrl_y))
2162 it->old_scrl_y = it->scrl_y;
2163 it->move_effect_enabled = EINA_FALSE;
2164 it->wd->reorder_move_animator = NULL;
2165 return ECORE_CALLBACK_CANCEL;
2167 return ECORE_CALLBACK_RENEW;
2171 _item_position(Elm_Genlist_Item *it,
2179 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2180 evas_object_resize(view, it->w, it->h);
2181 evas_object_move(view, it_x, it_y);
2182 evas_object_show(view);
2183 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2184 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2188 _item_block_position(Item_Block *itb,
2192 Elm_Genlist_Item *it;
2193 Elm_Genlist_Item *git;
2194 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2197 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2198 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2199 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2201 EINA_LIST_FOREACH(itb->items, l, it)
2203 if (it->delete_me) continue;
2204 else if (it->wd->reorder_it == it) continue;
2208 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2209 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2211 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2212 cvx, cvy, cvw, cvh));
2213 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2215 if ((itb->realized) && (!it->realized))
2217 if (vis) _item_realize(it, in, EINA_FALSE);
2223 if (it->wd->reorder_mode)
2224 y += _get_space_for_reorder_item(it);
2225 git = it->group_item;
2228 if (git->scrl_y < oy)
2230 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2231 git->scrl_y = (it->scrl_y + it->h) - git->h;
2232 git->want_realize = EINA_TRUE;
2234 if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2236 if (!it->move_effect_enabled)
2238 it->move_effect_enabled = EINA_TRUE;
2239 it->wd->reorder_move_animator =
2241 _reorder_move_animator_cb, it);
2244 if (!it->move_effect_enabled)
2248 _item_position(it, it->mode_view, it->scrl_x,
2251 _item_position(it, it->base.view, it->scrl_x,
2254 it->old_scrl_y = it->scrl_y;
2259 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2266 if (vis) it->want_realize = EINA_TRUE;
2270 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2271 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2275 _group_items_recalc(void *data)
2277 Widget_Data *wd = data;
2279 Elm_Genlist_Item *git;
2281 evas_event_freeze(evas_object_evas_get(wd->obj));
2282 EINA_LIST_FOREACH(wd->group_items, l, git)
2284 if (git->want_realize)
2287 _item_realize(git, 0, EINA_FALSE);
2288 evas_object_resize(git->base.view, wd->minw, git->h);
2289 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2290 evas_object_show(git->base.view);
2291 evas_object_raise(git->base.view);
2293 else if (!git->want_realize && git->realized)
2296 _item_unrealize(git, EINA_FALSE);
2299 evas_event_thaw(evas_object_evas_get(wd->obj));
2300 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2304 _must_recalc_idler(void *data)
2306 Widget_Data *wd = data;
2307 if (wd->calc_job) ecore_job_del(wd->calc_job);
2308 wd->calc_job = ecore_job_add(_calc_job, wd);
2309 wd->must_recalc_idler = NULL;
2310 return ECORE_CALLBACK_CANCEL;
2314 _calc_job(void *data)
2316 Widget_Data *wd = data;
2317 Item_Block *itb, *chb = NULL;
2318 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2321 Eina_Bool minw_change = EINA_FALSE, changed = EINA_FALSE;
2322 Eina_Bool did_must_recalc = EINA_FALSE;
2325 t0 = ecore_time_get();
2326 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2330 evas_event_freeze(evas_object_evas_get(wd->obj));
2331 EINA_INLIST_FOREACH(wd->blocks, itb)
2333 Eina_Bool showme = EINA_FALSE;
2336 showme = itb->showme;
2337 itb->showme = EINA_FALSE;
2340 if (itb->realized) _item_block_unrealize(itb);
2342 if ((itb->changed) || (changed) ||
2343 ((itb->must_recalc) && (!did_must_recalc)))
2345 if ((changed) || (itb->must_recalc))
2348 Elm_Genlist_Item *it;
2349 EINA_LIST_FOREACH(itb->items, l, it)
2350 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2351 itb->changed = EINA_TRUE;
2352 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2353 itb->must_recalc = EINA_FALSE;
2355 if (itb->realized) _item_block_unrealize(itb);
2356 showme = _item_block_recalc(itb, in, EINA_FALSE);
2362 if (minw == -1) minw = itb->minw;
2363 else if ((!itb->must_recalc) && (minw < itb->minw))
2366 minw_change = EINA_TRUE;
2372 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2374 wd->show_item->showme = EINA_FALSE;
2376 elm_smart_scroller_region_bring_in(wd->scr,
2378 wd->show_item->block->x,
2380 wd->show_item->block->y,
2381 wd->show_item->block->w,
2384 elm_smart_scroller_child_region_show(wd->scr,
2386 wd->show_item->block->x,
2388 wd->show_item->block->y,
2389 wd->show_item->block->w,
2391 wd->show_item = NULL;
2396 EINA_INLIST_FOREACH(wd->blocks, itb)
2402 if ((chb) && (EINA_INLIST_GET(chb)->next))
2404 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2406 if (itb->realized) _item_block_unrealize(itb);
2409 wd->realminw = minw;
2410 if (minw < wd->w) minw = wd->w;
2411 if ((minw != wd->minw) || (minh != wd->minh))
2415 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2416 _sizing_eval(wd->obj);
2417 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scroll_enabled))
2419 Elm_Genlist_Item *it;
2422 it = wd->anchor_item;
2423 it_y = wd->anchor_y;
2424 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2425 it->block->y + it->y + it_y);
2426 wd->anchor_item = it;
2427 wd->anchor_y = it_y;
2430 t = ecore_time_get();
2431 if (did_must_recalc)
2433 if (!wd->must_recalc_idler)
2434 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2436 wd->calc_job = NULL;
2437 evas_object_smart_changed(wd->pan_smart);
2438 evas_event_thaw(evas_object_evas_get(wd->obj));
2439 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2443 _update_job(void *data)
2445 Widget_Data *wd = data;
2449 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2451 wd->update_job = NULL;
2454 evas_event_freeze(evas_object_evas_get(wd->obj));
2455 EINA_INLIST_FOREACH(wd->blocks, itb)
2457 Evas_Coord itminw, itminh;
2458 Elm_Genlist_Item *it;
2464 _item_block_position(itb, num);
2468 recalc = EINA_FALSE;
2469 EINA_LIST_FOREACH(itb->items, l2, it)
2476 it->updateme = EINA_FALSE;
2479 _item_unrealize(it, EINA_FALSE);
2480 _item_realize(it, num, EINA_FALSE);
2481 position = EINA_TRUE;
2485 _item_realize(it, num, EINA_TRUE);
2486 _item_unrealize(it, EINA_TRUE);
2488 if ((it->minw != itminw) || (it->minh != itminh))
2493 itb->updateme = EINA_FALSE;
2496 position = EINA_TRUE;
2497 itb->changed = EINA_TRUE;
2498 _item_block_recalc(itb, num0, EINA_FALSE);
2499 _item_block_position(itb, num0);
2504 if (wd->calc_job) ecore_job_del(wd->calc_job);
2505 wd->calc_job = ecore_job_add(_calc_job, wd);
2507 evas_event_thaw(evas_object_evas_get(wd->obj));
2508 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2512 _pan_set(Evas_Object *obj,
2516 Pan *sd = evas_object_smart_data_get(obj);
2519 // Evas_Coord ow, oh;
2520 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2521 // ow = sd->wd->minw - ow;
2522 // if (ow < 0) ow = 0;
2523 // oh = sd->wd->minh - oh;
2524 // if (oh < 0) oh = 0;
2525 // if (x < 0) x = 0;
2526 // if (y < 0) y = 0;
2527 // if (x > ow) x = ow;
2528 // if (y > oh) y = oh;
2529 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2533 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2535 if ((itb->y + itb->h) > y)
2537 Elm_Genlist_Item *it;
2540 EINA_LIST_FOREACH(itb->items, l2, it)
2542 if ((itb->y + it->y) >= y)
2544 sd->wd->anchor_item = it;
2545 sd->wd->anchor_y = -(itb->y + it->y - y);
2552 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2556 _pan_get(Evas_Object *obj,
2560 Pan *sd = evas_object_smart_data_get(obj);
2562 if (x) *x = sd->wd->pan_x;
2563 if (y) *y = sd->wd->pan_y;
2567 _pan_max_get(Evas_Object *obj,
2571 Pan *sd = evas_object_smart_data_get(obj);
2574 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2575 ow = sd->wd->minw - ow;
2577 oh = sd->wd->minh - oh;
2584 _pan_min_get(Evas_Object *obj __UNUSED__,
2593 _pan_child_size_get(Evas_Object *obj,
2597 Pan *sd = evas_object_smart_data_get(obj);
2599 if (w) *w = sd->wd->minw;
2600 if (h) *h = sd->wd->minh;
2604 _pan_add(Evas_Object *obj)
2607 Evas_Object_Smart_Clipped_Data *cd;
2610 cd = evas_object_smart_data_get(obj);
2613 sd->__clipped_data = *cd;
2615 evas_object_smart_data_set(obj, sd);
2619 _pan_del(Evas_Object *obj)
2621 Pan *sd = evas_object_smart_data_get(obj);
2626 ecore_job_del(sd->resize_job);
2627 sd->resize_job = NULL;
2633 _pan_resize_job(void *data)
2636 _sizing_eval(sd->wd->obj);
2637 sd->resize_job = NULL;
2641 _pan_resize(Evas_Object *obj,
2645 Pan *sd = evas_object_smart_data_get(obj);
2648 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2649 if ((ow == w) && (oh == h)) return;
2650 if ((sd->wd->height_for_width) && (ow != w))
2652 if (sd->resize_job) ecore_job_del(sd->resize_job);
2653 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2655 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2656 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2660 _pan_calculate(Evas_Object *obj)
2662 Pan *sd = evas_object_smart_data_get(obj);
2664 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2666 Elm_Genlist_Item *git;
2669 evas_event_freeze(evas_object_evas_get(obj));
2670 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2671 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2672 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2674 git->want_realize = EINA_FALSE;
2676 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2678 itb->w = sd->wd->minw;
2679 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2680 itb->y - sd->wd->pan_y + oy,
2682 cvx, cvy, cvw, cvh))
2684 if ((!itb->realized) || (itb->changed))
2685 _item_block_realize(itb);
2686 _item_block_position(itb, in);
2690 if (itb->realized) _item_block_unrealize(itb);
2694 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2695 _group_items_recalc(sd->wd);
2696 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2698 if (sd->wd->pan_y != sd->wd->old_pan_y)
2699 sd->wd->reorder_pan_move = EINA_TRUE;
2700 else sd->wd->reorder_pan_move = EINA_FALSE;
2701 evas_object_raise(sd->wd->reorder_it->base.view);
2702 sd->wd->old_pan_y = sd->wd->pan_y;
2703 sd->wd->start_time = ecore_loop_time_get();
2705 _item_auto_scroll(sd->wd);
2706 evas_event_thaw(evas_object_evas_get(obj));
2707 evas_event_thaw_eval(evas_object_evas_get(obj));
2711 _pan_move(Evas_Object *obj,
2712 Evas_Coord x __UNUSED__,
2713 Evas_Coord y __UNUSED__)
2715 Pan *sd = evas_object_smart_data_get(obj);
2717 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2718 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2722 _hold_on(void *data __UNUSED__,
2724 void *event_info __UNUSED__)
2726 Widget_Data *wd = elm_widget_data_get(obj);
2728 elm_smart_scroller_hold_set(wd->scr, 1);
2732 _hold_off(void *data __UNUSED__,
2734 void *event_info __UNUSED__)
2736 Widget_Data *wd = elm_widget_data_get(obj);
2738 elm_smart_scroller_hold_set(wd->scr, 0);
2742 _freeze_on(void *data __UNUSED__,
2744 void *event_info __UNUSED__)
2746 Widget_Data *wd = elm_widget_data_get(obj);
2748 elm_smart_scroller_freeze_set(wd->scr, 1);
2752 _freeze_off(void *data __UNUSED__,
2754 void *event_info __UNUSED__)
2756 Widget_Data *wd = elm_widget_data_get(obj);
2758 elm_smart_scroller_freeze_set(wd->scr, 0);
2762 _scroll_edge_left(void *data,
2763 Evas_Object *scr __UNUSED__,
2764 void *event_info __UNUSED__)
2766 Evas_Object *obj = data;
2767 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
2771 _scroll_edge_right(void *data,
2772 Evas_Object *scr __UNUSED__,
2773 void *event_info __UNUSED__)
2775 Evas_Object *obj = data;
2776 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
2780 _scroll_edge_top(void *data,
2781 Evas_Object *scr __UNUSED__,
2782 void *event_info __UNUSED__)
2784 Evas_Object *obj = data;
2785 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
2789 _scroll_edge_bottom(void *data,
2790 Evas_Object *scr __UNUSED__,
2791 void *event_info __UNUSED__)
2793 Evas_Object *obj = data;
2794 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
2798 _mode_item_realize(Elm_Genlist_Item *it)
2802 if ((it->mode_view) || (it->delete_me)) return;
2804 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2805 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2806 edje_object_scale_set(it->mode_view,
2807 elm_widget_scale_get(it->base.widget) *
2808 _elm_config->scale);
2809 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2810 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2812 strncpy(buf, "item", sizeof(buf));
2813 if (it->wd->compress)
2814 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2816 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2817 strncat(buf, "/", sizeof(buf) - strlen(buf));
2818 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2820 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2821 elm_widget_style_get(it->base.widget));
2822 edje_object_mirrored_set(it->mode_view,
2823 elm_widget_mirrored_get(it->base.widget));
2825 /* signal callback add */
2826 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2828 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2830 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2833 /* label_get, icon_get, state_get */
2834 /* FIXME: If you see that assert, please notify us and we
2835 will clean our mess */
2836 assert(eina_list_count(it->mode_icon_objs) == 0);
2838 _item_label_realize(it, it->mode_view, &it->mode_labels);
2839 it->mode_icon_objs = _item_icon_realize(it,
2842 _item_state_realize(it, it->mode_view, &it->mode_states);
2844 edje_object_part_swallow(it->mode_view,
2845 edje_object_data_get(it->mode_view, "mode_part"),
2848 it->want_unrealize = EINA_FALSE;
2849 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2850 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2854 _mode_item_unrealize(Elm_Genlist_Item *it)
2856 Widget_Data *wd = it->wd;
2858 if (!it->mode_view) return;
2860 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2861 elm_widget_stringlist_free(it->mode_labels);
2862 it->mode_labels = NULL;
2863 elm_widget_stringlist_free(it->mode_icons);
2864 it->mode_icons = NULL;
2865 elm_widget_stringlist_free(it->mode_states);
2867 EINA_LIST_FREE(it->mode_icon_objs, icon)
2868 evas_object_del(icon);
2870 edje_object_part_unswallow(it->mode_view, it->base.view);
2871 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2872 evas_object_del(it->mode_view);
2873 it->mode_view = NULL;
2875 if (wd->mode_item == it)
2876 wd->mode_item = NULL;
2877 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2878 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2882 _item_mode_set(Elm_Genlist_Item *it)
2885 Widget_Data *wd = it->wd;
2890 it->nocache = EINA_TRUE;
2892 if (wd->scr_hold_timer)
2894 ecore_timer_del(wd->scr_hold_timer);
2895 wd->scr_hold_timer = NULL;
2897 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2898 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2900 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2901 _mode_item_realize(it);
2902 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
2903 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2904 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2906 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2907 edje_object_signal_emit(it->mode_view, buf, "elm");
2911 _item_mode_unset(Widget_Data *wd)
2914 if (!wd->mode_item) return;
2915 char buf[1024], buf2[1024];
2916 Elm_Genlist_Item *it;
2919 it->nocache = EINA_TRUE;
2921 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2922 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2924 edje_object_signal_emit(it->mode_view, buf, "elm");
2925 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2927 wd->mode_item = NULL;
2931 _item_auto_scroll(Widget_Data *wd)
2934 Elm_Genlist_Item *it;
2936 Evas_Coord ox, oy, ow, oh;
2938 if ((wd->expanded_item) && (wd->auto_scroll_enabled))
2940 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
2941 if (wd->expanded_item->scrl_y > (oh + oy) / 2)
2943 EINA_LIST_FOREACH(wd->expanded_item->items, l, it)
2944 elm_genlist_item_bring_in(it);
2946 wd->auto_scroll_enabled = EINA_FALSE;
2951 elm_genlist_add(Evas_Object *parent)
2956 Evas_Coord minw, minh;
2957 static Evas_Smart *smart = NULL;
2961 static Evas_Smart_Class sc;
2963 evas_object_smart_clipped_smart_set(&_pan_sc);
2965 sc.name = "elm_genlist_pan";
2966 sc.version = EVAS_SMART_CLASS_VERSION;
2969 sc.resize = _pan_resize;
2970 sc.move = _pan_move;
2971 sc.calculate = _pan_calculate;
2972 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2975 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2977 ELM_SET_WIDTYPE(widtype, "genlist");
2978 elm_widget_type_set(obj, "genlist");
2979 elm_widget_sub_object_add(parent, obj);
2980 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2981 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2982 elm_widget_data_set(obj, wd);
2983 elm_widget_del_hook_set(obj, _del_hook);
2984 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2985 elm_widget_theme_hook_set(obj, _theme_hook);
2986 elm_widget_can_focus_set(obj, EINA_TRUE);
2987 elm_widget_event_hook_set(obj, _event_hook);
2988 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2990 wd->scr = elm_smart_scroller_add(e);
2991 elm_smart_scroller_widget_set(wd->scr, obj);
2992 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2993 elm_widget_style_get(obj));
2994 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2995 _elm_config->thumbscroll_bounce_enable);
2996 elm_widget_resize_object_set(obj, wd->scr);
2998 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2999 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3001 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3002 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3006 wd->mode = ELM_LIST_SCROLL;
3007 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3008 wd->item_cache_max = wd->max_items_per_block * 2;
3009 wd->longpress_timeout = _elm_config->longpress_timeout;
3011 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3012 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3013 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3014 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3016 wd->pan_smart = evas_object_smart_add(e, smart);
3017 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3020 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3021 _pan_set, _pan_get, _pan_max_get,
3022 _pan_min_get, _pan_child_size_get);
3024 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3026 evas_object_size_hint_min_set(obj, minw, minh);
3028 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3030 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3035 static Elm_Genlist_Item *
3036 _item_new(Widget_Data *wd,
3037 const Elm_Genlist_Item_Class *itc,
3039 Elm_Genlist_Item *parent,
3040 Elm_Genlist_Item_Flags flags,
3042 const void *func_data)
3044 Elm_Genlist_Item *it;
3046 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3047 if (!it) return NULL;
3050 it->base.data = data;
3051 it->parent = parent;
3053 it->func.func = func;
3054 it->func.data = func_data;
3055 it->mouse_cursor = NULL;
3056 it->expanded_depth = 0;
3061 _item_block_add(Widget_Data *wd,
3062 Elm_Genlist_Item *it)
3064 Item_Block *itb = NULL;
3071 itb = calloc(1, sizeof(Item_Block));
3074 if (!it->rel->block)
3077 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3078 itb->items = eina_list_append(itb->items, it);
3084 wd->blocks = eina_inlist_prepend_relative
3085 (wd->blocks, EINA_INLIST_GET(itb),
3086 EINA_INLIST_GET(it->rel->block));
3088 eina_list_prepend_relative(itb->items, it, it->rel);
3092 wd->blocks = eina_inlist_append_relative
3093 (wd->blocks, EINA_INLIST_GET(itb),
3094 EINA_INLIST_GET(it->rel->block));
3096 eina_list_append_relative(itb->items, it, it->rel);
3106 itb = (Item_Block *)(wd->blocks);
3107 if (itb->count >= wd->max_items_per_block)
3109 itb = calloc(1, sizeof(Item_Block));
3113 eina_inlist_prepend(wd->blocks,
3114 EINA_INLIST_GET(itb));
3119 itb = calloc(1, sizeof(Item_Block));
3123 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3125 itb->items = eina_list_prepend(itb->items, it);
3131 itb = (Item_Block *)(wd->blocks->last);
3132 if (itb->count >= wd->max_items_per_block)
3134 itb = calloc(1, sizeof(Item_Block));
3138 eina_inlist_append(wd->blocks,
3139 EINA_INLIST_GET(itb));
3144 itb = calloc(1, sizeof(Item_Block));
3148 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3150 itb->items = eina_list_append(itb->items, it);
3156 itb = it->rel->block;
3157 if (!itb) goto newblock;
3159 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3161 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3164 itb->changed = EINA_TRUE;
3166 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3167 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3170 it->rel->relcount--;
3171 if ((it->rel->delete_me) && (!it->rel->relcount))
3175 if (itb->count > itb->wd->max_items_per_block)
3179 Elm_Genlist_Item *it2;
3181 newc = itb->count / 2;
3182 itb2 = calloc(1, sizeof(Item_Block));
3186 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3187 EINA_INLIST_GET(itb));
3188 itb2->changed = EINA_TRUE;
3189 while ((itb->count > newc) && (itb->items))
3193 l = eina_list_last(itb->items);
3195 itb->items = eina_list_remove_list(itb->items, l);
3198 itb2->items = eina_list_prepend(itb2->items, it2);
3206 _queue_process(Widget_Data *wd)
3209 Eina_Bool showme = EINA_FALSE;
3212 t0 = ecore_time_get();
3213 //evas_event_freeze(evas_object_evas_get(wd->obj));
3214 for (n = 0; (wd->queue) && (n < 128); n++)
3216 Elm_Genlist_Item *it;
3218 it = wd->queue->data;
3219 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3220 it->queued = EINA_FALSE;
3221 _item_block_add(wd, it);
3222 t = ecore_time_get();
3223 if (it->block->changed)
3225 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3226 it->block->changed = 0;
3228 if (showme) it->block->showme = EINA_TRUE;
3229 if (eina_inlist_count(wd->blocks) > 1)
3231 if ((t - t0) > (ecore_animator_frametime_get())) break;
3234 //evas_event_thaw(evas_object_evas_get(wd->obj));
3235 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3240 _idle_process(void *data, Eina_Bool *wakeup)
3242 Widget_Data *wd = data;
3245 //static double q_start = 0.0;
3246 //if (q_start == 0.0) q_start = ecore_time_get();
3248 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3252 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3254 return ECORE_CALLBACK_CANCEL;
3256 return ECORE_CALLBACK_RENEW;
3260 _item_idle_enterer(void *data)
3262 Widget_Data *wd = data;
3263 Eina_Bool wakeup = EINA_FALSE;
3264 Eina_Bool ok = _idle_process(data, &wakeup);
3269 if (wd->calc_job) ecore_job_del(wd->calc_job);
3270 wd->calc_job = ecore_job_add(_calc_job, wd);
3272 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3277 _item_queue(Widget_Data *wd,
3278 Elm_Genlist_Item *it)
3280 if (it->queued) return;
3281 it->queued = EINA_TRUE;
3282 wd->queue = eina_list_append(wd->queue, it);
3283 // FIXME: why does a freeze then thaw here cause some genlist
3284 // elm_genlist_item_append() to be much much slower?
3285 // evas_event_freeze(evas_object_evas_get(wd->obj));
3286 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3288 if (wd->queue_idle_enterer)
3290 ecore_idle_enterer_del(wd->queue_idle_enterer);
3291 wd->queue_idle_enterer = NULL;
3295 // evas_event_thaw(evas_object_evas_get(wd->obj));
3296 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3297 if (!wd->queue_idle_enterer)
3298 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3302 _elm_genlist_item_compare_data(const void *data, const void *data1)
3304 const Elm_Genlist_Item *item = data;
3305 const Elm_Genlist_Item *item1 = data1;
3307 return _elm_genlist_item_compare_data_cb(item->base.data, item1->base.data);
3311 _elm_genlist_item_compare(const void *data, const void *data1)
3313 const Elm_Genlist_Item *item, *item1;
3314 item = ELM_GENLIST_ITEM_FROM_INLIST(data);
3315 item1 = ELM_GENLIST_ITEM_FROM_INLIST(data1);
3316 return _elm_genlist_item_compare_cb(item, item1);
3320 _elm_genlist_item_list_compare(const void *data, const void *data1)
3322 const Elm_Genlist_Item *item = data;
3323 const Elm_Genlist_Item *item1 = data1;
3324 return _elm_genlist_item_compare_cb(item, item1);
3328 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3333 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3334 _item_block_del(it);
3336 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3338 it->rel->relcount++;
3339 it->before = EINA_FALSE;
3340 if (after->group_item) it->group_item = after->group_item;
3341 _item_queue(it->wd, it);
3343 // TODO: change this to smart callback
3344 if (it->itc->func.moved)
3345 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
3349 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3352 if (!before) return;
3354 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3355 _item_block_del(it);
3356 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3358 it->rel->relcount++;
3359 it->before = EINA_TRUE;
3360 if (before->group_item) it->group_item = before->group_item;
3361 _item_queue(it->wd, it);
3363 // TODO: change this to smart callback
3364 if (it->itc->func.moved)
3365 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
3369 * Add item to the end of the genlist
3371 * This adds the given item to the end of the list or the end of
3372 * the children if the parent is given.
3374 * @param obj The genlist object
3375 * @param itc The item class for the item
3376 * @param data The item data
3377 * @param parent The parent item, or NULL if none
3378 * @param flags Item flags
3379 * @param func Convenience function called when item selected
3380 * @param func_data Data passed to @p func above.
3381 * @return A handle to the item added or NULL if not possible
3385 EAPI Elm_Genlist_Item *
3386 elm_genlist_item_append(Evas_Object *obj,
3387 const Elm_Genlist_Item_Class *itc,
3389 Elm_Genlist_Item *parent,
3390 Elm_Genlist_Item_Flags flags,
3392 const void *func_data)
3394 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3395 Widget_Data *wd = elm_widget_data_get(obj);
3396 if (!wd) return NULL;
3397 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3399 if (!it) return NULL;
3402 if (flags & ELM_GENLIST_ITEM_GROUP)
3403 wd->group_items = eina_list_append(wd->group_items, it);
3404 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3409 Elm_Genlist_Item *it2 = NULL;
3410 Eina_List *ll = eina_list_last(it->parent->items);
3411 if (ll) it2 = ll->data;
3412 it->parent->items = eina_list_append(it->parent->items, it);
3413 if (!it2) it2 = it->parent;
3415 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3416 EINA_INLIST_GET(it2));
3418 it->rel->relcount++;
3420 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3421 it->group_item = parent;
3422 else if (it->parent->group_item)
3423 it->group_item = it->parent->group_item;
3425 it->before = EINA_FALSE;
3426 _item_queue(wd, it);
3431 * Add item at start of the genlist
3433 * This adds an item to the beginning of the list or beginning of the
3434 * children of the parent if given.
3436 * @param obj The genlist object
3437 * @param itc The item class for the item
3438 * @param data The item data
3439 * @param parent The parent item, or NULL if none
3440 * @param flags Item flags
3441 * @param func Convenience function called when item selected
3442 * @param func_data Data passed to @p func above.
3443 * @return A handle to the item added or NULL if not possible
3447 EAPI Elm_Genlist_Item *
3448 elm_genlist_item_prepend(Evas_Object *obj,
3449 const Elm_Genlist_Item_Class *itc,
3451 Elm_Genlist_Item *parent,
3452 Elm_Genlist_Item_Flags flags,
3454 const void *func_data)
3456 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3457 Widget_Data *wd = elm_widget_data_get(obj);
3458 if (!wd) return NULL;
3459 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3461 if (!it) return NULL;
3464 if (flags & ELM_GENLIST_ITEM_GROUP)
3465 wd->group_items = eina_list_prepend(wd->group_items, it);
3466 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3471 Elm_Genlist_Item *it2 = NULL;
3472 Eina_List *ll = it->parent->items;
3473 if (ll) it2 = ll->data;
3474 it->parent->items = eina_list_prepend(it->parent->items, it);
3475 if (!it2) it2 = it->parent;
3477 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3478 EINA_INLIST_GET(it2));
3480 it->rel->relcount++;
3482 it->before = EINA_TRUE;
3483 _item_queue(wd, it);
3488 * Insert item before another in the genlist
3490 * This inserts an item before another in the list. It will be in the
3491 * same tree level or group as the item it is inseted before.
3493 * @param obj The genlist object
3494 * @param itc The item class for the item
3495 * @param data The item data
3496 * @param before The item to insert before
3497 * @param flags Item flags
3498 * @param func Convenience function called when item selected
3499 * @param func_data Data passed to @p func above.
3500 * @return A handle to the item added or NULL if not possible
3504 EAPI Elm_Genlist_Item *
3505 elm_genlist_item_insert_before(Evas_Object *obj,
3506 const Elm_Genlist_Item_Class *itc,
3508 Elm_Genlist_Item *parent,
3509 Elm_Genlist_Item *before,
3510 Elm_Genlist_Item_Flags flags,
3512 const void *func_data)
3514 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3515 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3516 Widget_Data *wd = elm_widget_data_get(obj);
3517 if (!wd) return NULL;
3518 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3520 if (!it) return NULL;
3523 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3526 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3527 EINA_INLIST_GET(before));
3529 it->rel->relcount++;
3530 it->before = EINA_TRUE;
3531 _item_queue(wd, it);
3535 EAPI Elm_Genlist_Item *
3536 elm_genlist_item_direct_sorted_insert(Evas_Object *obj,
3537 const Elm_Genlist_Item_Class *itc,
3539 Elm_Genlist_Item *parent,
3540 Elm_Genlist_Item_Flags flags,
3541 Eina_Compare_Cb comp,
3543 const void *func_data)
3545 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3546 Widget_Data *wd = elm_widget_data_get(obj);
3547 if (!wd) return NULL;
3548 Elm_Genlist_Item *rel = NULL;
3549 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3551 if (!it) return NULL;
3553 _elm_genlist_item_compare_cb = comp;
3560 l = eina_list_search_sorted_near_list(it->parent->items,
3561 _elm_genlist_item_list_compare, it,
3564 rel = eina_list_data_get(l);
3570 it->parent->items = eina_list_prepend_relative_list(it->parent->items, it, l);
3571 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
3572 it->before = EINA_FALSE;
3574 else if (cmp_result < 0)
3576 it->parent->items = eina_list_append_relative_list(it->parent->items, it, l);
3577 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
3578 it->before = EINA_TRUE;
3581 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3582 it->group_item = parent;
3583 else if (it->parent->group_item)
3584 it->group_item = it->parent->group_item;
3588 if (flags & ELM_GENLIST_ITEM_GROUP)
3589 wd->group_items = eina_list_append(wd->group_items, it);
3591 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(it),
3592 _elm_genlist_item_compare);
3594 if (EINA_INLIST_GET(it)->next)
3596 rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3597 it->before = EINA_TRUE;
3599 else if (EINA_INLIST_GET(it)->prev)
3601 rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3602 it->before = EINA_FALSE;
3609 it->rel->relcount++;
3612 _item_queue(wd, it);
3618 * Insert a new item into the sorted genlist object
3620 * @param obj The genlist object
3621 * @param itc The item class for the item
3622 * @param data The item data
3623 * @param parent The parent item, or NULL if none
3624 * @param flags Item flags
3625 * @param comp The function called for the sort
3626 * @param func Convenience function called when item selected
3627 * @param func_data Data passed to @p func above.
3628 * @return A handle to the item added or NULL if not possible
3632 EAPI Elm_Genlist_Item *
3633 elm_genlist_item_sorted_insert(Evas_Object *obj,
3634 const Elm_Genlist_Item_Class *itc,
3636 Elm_Genlist_Item *parent,
3637 Elm_Genlist_Item_Flags flags,
3638 Eina_Compare_Cb comp,
3640 const void *func_data)
3642 _elm_genlist_item_compare_data_cb = comp;
3644 return elm_genlist_item_direct_sorted_insert(obj, itc, data, parent, flags,
3645 _elm_genlist_item_compare_data, func, func_data);
3649 * Insert an item after another in the genlst
3651 * This inserts an item after another in the list. It will be in the
3652 * same tree level or group as the item it is inseted after.
3654 * @param obj The genlist object
3655 * @param itc The item class for the item
3656 * @param data The item data
3657 * @param after The item to insert after
3658 * @param flags Item flags
3659 * @param func Convenience function called when item selected
3660 * @param func_data Data passed to @p func above.
3661 * @return A handle to the item added or NULL if not possible
3665 EAPI Elm_Genlist_Item *
3666 elm_genlist_item_insert_after(Evas_Object *obj,
3667 const Elm_Genlist_Item_Class *itc,
3669 Elm_Genlist_Item *parent,
3670 Elm_Genlist_Item *after,
3671 Elm_Genlist_Item_Flags flags,
3673 const void *func_data)
3675 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3676 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3677 Widget_Data *wd = elm_widget_data_get(obj);
3678 if (!wd) return NULL;
3679 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3681 if (!it) return NULL;
3682 /* It make no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3683 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3685 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3686 EINA_INLIST_GET(after));
3689 it->parent->items = eina_list_append_relative(it->parent->items, it,
3693 it->rel->relcount++;
3694 it->before = EINA_FALSE;
3695 _item_queue(wd, it);
3700 elm_genlist_clear(Evas_Object *obj)
3702 ELM_CHECK_WIDTYPE(obj, widtype);
3703 Widget_Data *wd = elm_widget_data_get(obj);
3705 if (wd->walking > 0)
3707 Elm_Genlist_Item *it;
3709 wd->clear_me = EINA_TRUE;
3710 EINA_INLIST_FOREACH(wd->items, it)
3712 it->delete_me = EINA_TRUE;
3716 evas_event_freeze(evas_object_evas_get(wd->obj));
3719 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3721 if (wd->anchor_item == it)
3723 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3724 if (!wd->anchor_item)
3726 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3728 wd->items = eina_inlist_remove(wd->items, wd->items);
3729 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3730 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3731 elm_widget_item_pre_notify_del(it);
3732 if (it->realized) _item_unrealize(it, EINA_FALSE);
3733 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3734 it->itc->func.del((void *)it->base.data, it->base.widget);
3735 if (it->long_timer) ecore_timer_del(it->long_timer);
3736 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3737 elm_widget_item_del(it);
3739 wd->clear_me = EINA_FALSE;
3740 wd->anchor_item = NULL;
3743 Item_Block *itb = (Item_Block *)(wd->blocks);
3745 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3746 if (itb->items) eina_list_free(itb->items);
3751 ecore_job_del(wd->calc_job);
3752 wd->calc_job = NULL;
3754 if (wd->queue_idle_enterer)
3756 ecore_idle_enterer_del(wd->queue_idle_enterer);
3757 wd->queue_idle_enterer = NULL;
3759 if (wd->must_recalc_idler)
3761 ecore_idler_del(wd->must_recalc_idler);
3762 wd->must_recalc_idler = NULL;
3766 eina_list_free(wd->queue);
3771 eina_list_free(wd->selected);
3772 wd->selected = NULL;
3774 if (wd->reorder_move_animator)
3776 ecore_animator_del(wd->reorder_move_animator);
3777 wd->reorder_move_animator = NULL;
3779 wd->show_item = NULL;
3787 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3788 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3791 evas_event_thaw(evas_object_evas_get(wd->obj));
3792 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3796 elm_genlist_multi_select_set(Evas_Object *obj,
3799 ELM_CHECK_WIDTYPE(obj, widtype);
3800 Widget_Data *wd = elm_widget_data_get(obj);
3806 elm_genlist_multi_select_get(const Evas_Object *obj)
3808 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3809 Widget_Data *wd = elm_widget_data_get(obj);
3810 if (!wd) return EINA_FALSE;
3814 EAPI Elm_Genlist_Item *
3815 elm_genlist_selected_item_get(const Evas_Object *obj)
3817 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3818 Widget_Data *wd = elm_widget_data_get(obj);
3819 if (!wd) return NULL;
3820 if (wd->selected) return wd->selected->data;
3824 EAPI const Eina_List *
3825 elm_genlist_selected_items_get(const Evas_Object *obj)
3827 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3828 Widget_Data *wd = elm_widget_data_get(obj);
3829 if (!wd) return NULL;
3830 return wd->selected;
3834 elm_genlist_realized_items_get(const Evas_Object *obj)
3836 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3837 Widget_Data *wd = elm_widget_data_get(obj);
3838 Eina_List *list = NULL;
3840 Eina_Bool done = EINA_FALSE;
3841 if (!wd) return NULL;
3842 EINA_INLIST_FOREACH(wd->blocks, itb)
3847 Elm_Genlist_Item *it;
3850 EINA_LIST_FOREACH(itb->items, l, it)
3852 if (it->realized) list = eina_list_append(list, it);
3863 EAPI Elm_Genlist_Item *
3864 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3869 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3870 Widget_Data *wd = elm_widget_data_get(obj);
3871 Evas_Coord ox, oy, ow, oh;
3874 if (!wd) return NULL;
3875 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3877 EINA_INLIST_FOREACH(wd->blocks, itb)
3880 Elm_Genlist_Item *it;
3882 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3883 oy + itb->y - itb->wd->pan_y,
3884 itb->w, itb->h, x, y, 1, 1))
3886 EINA_LIST_FOREACH(itb->items, l, it)
3888 Evas_Coord itx, ity;
3890 itx = ox + itb->x + it->x - itb->wd->pan_x;
3891 ity = oy + itb->y + it->y - itb->wd->pan_y;
3892 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3896 if (y <= (ity + (it->h / 4))) *posret = -1;
3897 else if (y >= (ity + it->h - (it->h / 4)))
3903 lasty = ity + it->h;
3908 if (y > lasty) *posret = 1;
3915 * Get the first item in the genlist
3917 * This returns the first item in the list.
3919 * @param obj The genlist object
3920 * @return The first item, or NULL if none
3924 EAPI Elm_Genlist_Item *
3925 elm_genlist_first_item_get(const Evas_Object *obj)
3927 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3928 Widget_Data *wd = elm_widget_data_get(obj);
3929 if (!wd) return NULL;
3930 if (!wd->items) return NULL;
3931 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3932 while ((it) && (it->delete_me))
3933 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3938 * Get the last item in the genlist
3940 * This returns the last item in the list.
3942 * @return The last item, or NULL if none
3946 EAPI Elm_Genlist_Item *
3947 elm_genlist_last_item_get(const Evas_Object *obj)
3949 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3950 Widget_Data *wd = elm_widget_data_get(obj);
3951 if (!wd) return NULL;
3952 if (!wd->items) return NULL;
3953 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3954 while ((it) && (it->delete_me))
3955 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3960 * Get the next item in the genlist
3962 * This returns the item after the item @p it.
3964 * @param it The item
3965 * @return The item after @p it, or NULL if none
3969 EAPI Elm_Genlist_Item *
3970 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3972 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3975 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3976 if ((it) && (!it->delete_me)) break;
3978 return (Elm_Genlist_Item *)it;
3982 * Get the previous item in the genlist
3984 * This returns the item before the item @p it.
3986 * @param it The item
3987 * @return The item before @p it, or NULL if none
3991 EAPI Elm_Genlist_Item *
3992 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3994 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3997 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3998 if ((it) && (!it->delete_me)) break;
4000 return (Elm_Genlist_Item *)it;
4004 * Get the genlist object from an item
4006 * This returns the genlist object itself that an item belongs to.
4008 * @param it The item
4009 * @return The genlist object
4014 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4016 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4017 return it->base.widget;
4021 * Get the parent item of the given item
4023 * This returns the parent item of the item @p it given.
4025 * @param it The item
4026 * @return The parent of the item or NULL if none
4030 EAPI Elm_Genlist_Item *
4031 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4033 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4038 * Clear all sub-items (children) of the given item
4040 * This clears all items that are children (or their descendants) of the
4043 * @param it The item
4048 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4050 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4051 Eina_List *tl = NULL, *l;
4052 Elm_Genlist_Item *it2;
4054 EINA_LIST_FOREACH(it->items, l, it2)
4055 tl = eina_list_append(tl, it2);
4056 EINA_LIST_FREE(tl, it2)
4057 elm_genlist_item_del(it2);
4061 * Set the selected state of an item
4063 * This sets the selected state (1 selected, 0 not selected) of the given
4066 * @param it The item
4067 * @param selected The selected state
4072 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4075 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4076 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4078 if ((it->delete_me) || (it->disabled)) return;
4079 selected = !!selected;
4080 if (it->selected == selected) return;
4086 while (wd->selected)
4088 _item_unhighlight(wd->selected->data);
4089 _item_unselect(wd->selected->data);
4092 _item_highlight(it);
4097 _item_unhighlight(it);
4103 * Get the selected state of an item
4105 * This gets the selected state of an item (1 selected, 0 not selected).
4107 * @param it The item
4108 * @return The selected state
4113 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4115 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4116 return it->selected;
4120 * Sets the expanded state of an item (if it's a parent)
4122 * This expands or contracts a parent item (thus showing or hiding the
4125 * @param it The item
4126 * @param expanded The expanded state (1 expanded, 0 not expanded).
4131 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4134 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4135 if (it->expanded == expanded) return;
4136 it->expanded = expanded;
4137 it->wd->expanded_item = it;
4141 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4142 evas_object_smart_callback_call(it->base.widget, SIG_EXPANDED, it);
4143 it->wd->auto_scroll_enabled = EINA_TRUE;
4148 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4149 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACTED, it);
4150 it->wd->auto_scroll_enabled = EINA_FALSE;
4155 * Get the expanded state of an item
4157 * This gets the expanded state of an item
4159 * @param it The item
4160 * @return Thre expanded state
4165 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4167 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4168 return it->expanded;
4172 * Get the depth of expanded item
4174 * @param it The genlist item object
4175 * @return The depth of expanded item
4180 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4182 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4183 return it->expanded_depth;
4187 * Sets the disabled state of an item.
4189 * A disabled item cannot be selected or unselected. It will also
4190 * change appearance to appear disabled. This sets the disabled state
4191 * (1 disabled, 0 not disabled).
4193 * @param it The item
4194 * @param disabled The disabled state
4199 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4202 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4205 if (it->disabled == disabled) return;
4206 if (it->delete_me) return;
4207 it->disabled = !!disabled;
4209 elm_genlist_item_selected_set(it, EINA_FALSE);
4213 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4215 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4216 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4217 elm_widget_disabled_set(obj, disabled);
4222 * Get the disabled state of an item
4224 * This gets the disabled state of the given item.
4226 * @param it The item
4227 * @return The disabled state
4232 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4234 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4235 if (it->delete_me) return EINA_FALSE;
4236 return it->disabled;
4240 * Sets the display only state of an item.
4242 * A display only item cannot be selected or unselected. It is for
4243 * display only and not selecting or otherwise clicking, dragging
4244 * etc. by the user, thus finger size rules will not be applied to
4247 * @param it The item
4248 * @param display_only The display only state
4253 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4254 Eina_Bool display_only)
4256 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4257 if (it->display_only == display_only) return;
4258 if (it->delete_me) return;
4259 it->display_only = display_only;
4260 it->mincalcd = EINA_FALSE;
4261 it->updateme = EINA_TRUE;
4262 if (it->block) it->block->updateme = EINA_TRUE;
4263 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4264 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4268 * Get the display only state of an item
4270 * This gets the display only state of the given item.
4272 * @param it The item
4273 * @return The display only state
4278 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4280 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4281 if (it->delete_me) return EINA_FALSE;
4282 return it->display_only;
4286 * Show the given item
4288 * This causes genlist to jump to the given item @p it and show it (by
4289 * scrolling), if it is not fully visible.
4291 * @param it The item
4296 elm_genlist_item_show(Elm_Genlist_Item *it)
4298 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4299 Evas_Coord gith = 0;
4300 if (it->delete_me) return;
4301 if ((it->queued) || (!it->mincalcd))
4303 it->wd->show_item = it;
4304 it->wd->bring_in = EINA_TRUE;
4305 it->showme = EINA_TRUE;
4308 if (it->wd->show_item)
4310 it->wd->show_item->showme = EINA_FALSE;
4311 it->wd->show_item = NULL;
4313 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4314 gith = it->group_item->h;
4315 elm_smart_scroller_child_region_show(it->wd->scr,
4316 it->x + it->block->x,
4317 it->y + it->block->y - gith,
4318 it->block->w, it->h);
4322 * Bring in the given item
4324 * This causes genlist to jump to the given item @p it and show it (by
4325 * scrolling), if it is not fully visible. This may use animation to
4326 * do so and take a period of time
4328 * @param it The item
4333 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4335 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4336 Evas_Coord gith = 0;
4337 if (it->delete_me) return;
4338 if ((it->queued) || (!it->mincalcd))
4340 it->wd->show_item = it;
4341 it->wd->bring_in = EINA_TRUE;
4342 it->showme = EINA_TRUE;
4345 if (it->wd->show_item)
4347 it->wd->show_item->showme = EINA_FALSE;
4348 it->wd->show_item = NULL;
4350 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4351 gith = it->group_item->h;
4352 elm_smart_scroller_region_bring_in(it->wd->scr,
4353 it->x + it->block->x,
4354 it->y + it->block->y - gith,
4355 it->block->w, it->h);
4359 * Show the given item at the top
4361 * This causes genlist to jump to the given item @p it and show it (by
4362 * scrolling), if it is not fully visible.
4364 * @param it The item
4369 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4371 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4373 Evas_Coord gith = 0;
4375 if (it->delete_me) return;
4376 if ((it->queued) || (!it->mincalcd))
4378 it->wd->show_item = it;
4379 it->wd->bring_in = EINA_TRUE;
4380 it->showme = EINA_TRUE;
4383 if (it->wd->show_item)
4385 it->wd->show_item->showme = EINA_FALSE;
4386 it->wd->show_item = NULL;
4388 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4389 if (it->group_item) gith = it->group_item->h;
4390 elm_smart_scroller_child_region_show(it->wd->scr,
4391 it->x + it->block->x,
4392 it->y + it->block->y - gith,
4397 * Bring in the given item at the top
4399 * This causes genlist to jump to the given item @p it and show it (by
4400 * scrolling), if it is not fully visible. This may use animation to
4401 * do so and take a period of time
4403 * @param it The item
4408 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4410 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4412 Evas_Coord gith = 0;
4414 if (it->delete_me) return;
4415 if ((it->queued) || (!it->mincalcd))
4417 it->wd->show_item = it;
4418 it->wd->bring_in = EINA_TRUE;
4419 it->showme = EINA_TRUE;
4422 if (it->wd->show_item)
4424 it->wd->show_item->showme = EINA_FALSE;
4425 it->wd->show_item = NULL;
4427 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4428 if (it->group_item) gith = it->group_item->h;
4429 elm_smart_scroller_region_bring_in(it->wd->scr,
4430 it->x + it->block->x,
4431 it->y + it->block->y - gith,
4436 * Show the given item at the middle
4438 * This causes genlist to jump to the given item @p it and show it (by
4439 * scrolling), if it is not fully visible.
4441 * @param it The item
4446 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4448 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4451 if (it->delete_me) return;
4452 if ((it->queued) || (!it->mincalcd))
4454 it->wd->show_item = it;
4455 it->wd->bring_in = EINA_TRUE;
4456 it->showme = EINA_TRUE;
4459 if (it->wd->show_item)
4461 it->wd->show_item->showme = EINA_FALSE;
4462 it->wd->show_item = NULL;
4464 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4465 elm_smart_scroller_child_region_show(it->wd->scr,
4466 it->x + it->block->x,
4467 it->y + it->block->y - oh / 2 +
4468 it->h / 2, it->block->w, oh);
4472 * Bring in the given item at the middle
4474 * This causes genlist to jump to the given item @p it and show it (by
4475 * scrolling), if it is not fully visible. This may use animation to
4476 * do so and take a period of time
4478 * @param it The item
4483 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4485 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4488 if (it->delete_me) return;
4489 if ((it->queued) || (!it->mincalcd))
4491 it->wd->show_item = it;
4492 it->wd->bring_in = EINA_TRUE;
4493 it->showme = EINA_TRUE;
4496 if (it->wd->show_item)
4498 it->wd->show_item->showme = EINA_FALSE;
4499 it->wd->show_item = NULL;
4501 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4502 elm_smart_scroller_region_bring_in(it->wd->scr,
4503 it->x + it->block->x,
4504 it->y + it->block->y - oh / 2 + it->h / 2,
4509 * Delete a given item
4511 * This deletes the item from genlist and calls the genlist item del
4512 * class callback defined in the item class, if it is set. This clears all
4513 * subitems if it is a tree.
4515 * @param it The item
4520 elm_genlist_item_del(Elm_Genlist_Item *it)
4522 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4523 if ((it->relcount > 0) || (it->walking > 0))
4525 elm_widget_item_pre_notify_del(it);
4526 elm_genlist_item_subitems_clear(it);
4527 it->delete_me = EINA_TRUE;
4528 if (it->wd->show_item == it) it->wd->show_item = NULL;
4530 it->wd->selected = eina_list_remove(it->wd->selected,
4534 if (it->realized) _item_unrealize(it, EINA_FALSE);
4535 it->block->changed = EINA_TRUE;
4536 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4537 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4539 if (it->itc->func.del)
4540 it->itc->func.del((void *)it->base.data, it->base.widget);
4547 * Set the data item from the genlist item
4549 * This sets the data value passed on the elm_genlist_item_append() and
4550 * related item addition calls. This function will not call
4551 * elm_genlist_item_update() anymore. So call elm_genlist_item_update()
4552 * manually only when it's needed.
4554 * @param it The item
4555 * @param data The new data pointer to set
4560 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4563 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4564 elm_widget_item_data_set(it, data);
4568 * Get the data item from the genlist item
4570 * This returns the data value passed on the elm_genlist_item_append()
4571 * and related item addition calls and elm_genlist_item_data_set().
4573 * @param it The item
4574 * @return The data pointer provided when created
4579 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4581 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4582 return elm_widget_item_data_get(it);
4586 * Tells genlist to "orphan" icons fetchs by the item class
4588 * This instructs genlist to release references to icons in the item,
4589 * meaning that they will no longer be managed by genlist and are
4590 * floating "orphans" that can be re-used elsewhere if the user wants
4593 * @param it The item
4598 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4601 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4602 EINA_LIST_FREE(it->icon_objs, icon)
4604 elm_widget_sub_object_del(it->base.widget, icon);
4605 evas_object_smart_member_del(icon);
4606 evas_object_hide(icon);
4611 * Get the real evas object of the genlist item
4613 * This returns the actual evas object used for the specified genlist
4614 * item. This may be NULL as it may not be created, and may be deleted
4615 * at any time by genlist. Do not modify this object (move, resize,
4616 * show, hide etc.) as genlist is controlling it. This function is for
4617 * querying, emitting custom signals or hooking lower level callbacks
4618 * for events. Do not delete this object under any circumstances.
4620 * @param it The item
4621 * @return The object pointer
4625 EAPI const Evas_Object *
4626 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4628 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4629 return it->base.view;
4633 * Update the contents of an item
4635 * This updates an item by calling all the item class functions again
4636 * to get the icons, labels and states. Use this when the original
4637 * item data has changed and the changes are desired to be reflected.
4639 * @param it The item
4644 elm_genlist_item_update(Elm_Genlist_Item *it)
4646 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4647 if (!it->block) return;
4648 if (it->delete_me) return;
4649 it->mincalcd = EINA_FALSE;
4650 it->updateme = EINA_TRUE;
4651 it->block->updateme = EINA_TRUE;
4652 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4653 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4657 * Update the item class of an item
4659 * @param it The item
4660 * @parem itc The item class for the item
4665 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4666 const Elm_Genlist_Item_Class *itc)
4668 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4669 if (!it->block) return;
4670 EINA_SAFETY_ON_NULL_RETURN(itc);
4671 if (it->delete_me) return;
4673 it->nocache = EINA_TRUE;
4674 elm_genlist_item_update(it);
4677 EAPI const Elm_Genlist_Item_Class *
4678 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4680 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4681 if (it->delete_me) return NULL;
4685 static Evas_Object *
4686 _elm_genlist_item_label_create(void *data,
4687 Evas_Object *obj __UNUSED__,
4688 Evas_Object *tooltip,
4689 void *item __UNUSED__)
4691 Evas_Object *label = elm_label_add(tooltip);
4694 elm_object_style_set(label, "tooltip");
4695 elm_object_text_set(label, data);
4700 _elm_genlist_item_label_del_cb(void *data,
4701 Evas_Object *obj __UNUSED__,
4702 void *event_info __UNUSED__)
4704 eina_stringshare_del(data);
4708 * Set the text to be shown in the genlist item.
4710 * @param item Target item
4711 * @param text The text to set in the content
4713 * Setup the text as tooltip to object. The item can have only one
4714 * tooltip, so any previous tooltip data is removed.
4719 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4722 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4723 text = eina_stringshare_add(text);
4724 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4726 _elm_genlist_item_label_del_cb);
4730 * Set the content to be shown in the tooltip item
4732 * Setup the tooltip to item. The item can have only one tooltip, so
4733 * any previous tooltip data is removed. @p func(with @p data) will be
4734 * called every time that need to show the tooltip and it should return a
4735 * valid Evas_Object. This object is then managed fully by tooltip
4736 * system and is deleted when the tooltip is gone.
4738 * @param item the genlist item being attached by a tooltip.
4739 * @param func the function used to create the tooltip contents.
4740 * @param data what to provide to @a func as callback data/context.
4741 * @param del_cb called when data is not needed anymore, either when
4742 * another callback replaces @func, the tooltip is unset with
4743 * elm_genlist_item_tooltip_unset() or the owner @a item
4744 * dies. This callback receives as the first parameter the
4745 * given @a data, and @c event_info is the item.
4750 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4751 Elm_Tooltip_Item_Content_Cb func,
4753 Evas_Smart_Cb del_cb)
4755 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4757 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4760 if (item->tooltip.del_cb)
4761 item->tooltip.del_cb((void *)item->tooltip.data,
4762 item->base.widget, item);
4764 item->tooltip.content_cb = func;
4765 item->tooltip.data = data;
4766 item->tooltip.del_cb = del_cb;
4768 if (item->base.view)
4770 elm_widget_item_tooltip_content_cb_set(item,
4771 item->tooltip.content_cb,
4772 item->tooltip.data, NULL);
4773 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4774 elm_widget_item_tooltip_size_restrict_disable(item, item->tooltip.free_size);
4780 if (del_cb) del_cb((void *)data, NULL, NULL);
4784 * Unset tooltip from item
4786 * @param item genlist item to remove previously set tooltip.
4788 * Remove tooltip from item. The callback provided as del_cb to
4789 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4790 * it is not used anymore.
4792 * @see elm_genlist_item_tooltip_content_cb_set()
4797 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4799 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4800 if ((item->base.view) && (item->tooltip.content_cb))
4801 elm_widget_item_tooltip_unset(item);
4803 if (item->tooltip.del_cb)
4804 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4805 item->tooltip.del_cb = NULL;
4806 item->tooltip.content_cb = NULL;
4807 item->tooltip.data = NULL;
4808 item->tooltip.free_size = EINA_FALSE;
4809 if (item->tooltip.style)
4810 elm_genlist_item_tooltip_style_set(item, NULL);
4814 * Sets a different style for this item tooltip.
4816 * @note before you set a style you should define a tooltip with
4817 * elm_genlist_item_tooltip_content_cb_set() or
4818 * elm_genlist_item_tooltip_text_set()
4820 * @param item genlist item with tooltip already set.
4821 * @param style the theme style to use (default, transparent, ...)
4826 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4829 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4830 eina_stringshare_replace(&item->tooltip.style, style);
4831 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4835 * Get the style for this item tooltip.
4837 * @param item genlist item with tooltip already set.
4838 * @return style the theme style in use, defaults to "default". If the
4839 * object does not have a tooltip set, then NULL is returned.
4844 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4846 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4847 return item->tooltip.style;
4851 elm_genlist_item_tooltip_size_restrict_disable(Elm_Genlist_Item *item, Eina_Bool disable)
4853 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4854 item->tooltip.free_size = disable;
4855 if (item->base.view) return elm_widget_item_tooltip_size_restrict_disable(item, disable);
4860 elm_genlist_item_tooltip_size_restrict_disabled_get(const Elm_Genlist_Item *item)
4862 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4863 return item->tooltip.free_size;
4867 * Set the cursor to be shown when mouse is over the genlist item
4869 * @param item Target item
4870 * @param cursor the cursor name to be used.
4872 * @see elm_object_cursor_set()
4876 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4879 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4880 eina_stringshare_replace(&item->mouse_cursor, cursor);
4881 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4885 * Get the cursor to be shown when mouse is over the genlist item
4887 * @param item genlist item with cursor already set.
4888 * @return the cursor name.
4893 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4895 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4896 return elm_widget_item_cursor_get(item);
4900 * Unset the cursor to be shown when mouse is over the genlist item
4902 * @param item Target item
4904 * @see elm_object_cursor_unset()
4908 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4910 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4911 if (!item->mouse_cursor)
4914 if (item->base.view)
4915 elm_widget_item_cursor_unset(item);
4917 eina_stringshare_del(item->mouse_cursor);
4918 item->mouse_cursor = NULL;
4922 * Sets a different style for this item cursor.
4924 * @note before you set a style you should define a cursor with
4925 * elm_genlist_item_cursor_set()
4927 * @param item genlist item with cursor already set.
4928 * @param style the theme style to use (default, transparent, ...)
4933 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4936 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4937 elm_widget_item_cursor_style_set(item, style);
4941 * Get the style for this item cursor.
4943 * @param item genlist item with cursor already set.
4944 * @return style the theme style in use, defaults to "default". If the
4945 * object does not have a cursor set, then NULL is returned.
4950 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4952 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4953 return elm_widget_item_cursor_style_get(item);
4957 * Set if the cursor set should be searched on the theme or should use
4958 * the provided by the engine, only.
4960 * @note before you set if should look on theme you should define a
4961 * cursor with elm_object_cursor_set(). By default it will only look
4962 * for cursors provided by the engine.
4964 * @param item widget item with cursor already set.
4965 * @param engine_only boolean to define it cursors should be looked
4966 * only between the provided by the engine or searched on widget's
4972 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4973 Eina_Bool engine_only)
4975 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4976 elm_widget_item_cursor_engine_only_set(item, engine_only);
4980 * Get the cursor engine only usage for this item cursor.
4982 * @param item widget item with cursor already set.
4983 * @return engine_only boolean to define it cursors should be looked
4984 * only between the provided by the engine or searched on widget's
4985 * theme as well. If the object does not have a cursor set, then
4986 * EINA_FALSE is returned.
4991 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4993 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4994 return elm_widget_item_cursor_engine_only_get(item);
4998 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5001 ELM_CHECK_WIDTYPE(obj, widtype);
5002 Widget_Data *wd = elm_widget_data_get(obj);
5004 if (wd->mode == mode) return;
5010 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5012 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5013 Widget_Data *wd = elm_widget_data_get(obj);
5014 if (!wd) return ELM_LIST_LAST;
5019 elm_genlist_always_select_mode_set(Evas_Object *obj,
5020 Eina_Bool always_select)
5022 ELM_CHECK_WIDTYPE(obj, widtype);
5023 Widget_Data *wd = elm_widget_data_get(obj);
5025 wd->always_select = always_select;
5029 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5031 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5032 Widget_Data *wd = elm_widget_data_get(obj);
5033 if (!wd) return EINA_FALSE;
5034 return wd->always_select;
5038 elm_genlist_no_select_mode_set(Evas_Object *obj,
5039 Eina_Bool no_select)
5041 ELM_CHECK_WIDTYPE(obj, widtype);
5042 Widget_Data *wd = elm_widget_data_get(obj);
5044 wd->no_select = no_select;
5048 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5050 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5051 Widget_Data *wd = elm_widget_data_get(obj);
5052 if (!wd) return EINA_FALSE;
5053 return wd->no_select;
5057 elm_genlist_compress_mode_set(Evas_Object *obj,
5060 ELM_CHECK_WIDTYPE(obj, widtype);
5061 Widget_Data *wd = elm_widget_data_get(obj);
5063 wd->compress = compress;
5064 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
5068 elm_genlist_compress_mode_get(const Evas_Object *obj)
5070 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5071 Widget_Data *wd = elm_widget_data_get(obj);
5072 if (!wd) return EINA_FALSE;
5073 return wd->compress;
5077 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5078 Eina_Bool height_for_width)
5080 ELM_CHECK_WIDTYPE(obj, widtype);
5081 Widget_Data *wd = elm_widget_data_get(obj);
5083 wd->height_for_width = !!height_for_width;
5084 if (wd->height_for_width)
5086 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5087 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5092 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5094 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5095 Widget_Data *wd = elm_widget_data_get(obj);
5096 if (!wd) return EINA_FALSE;
5097 return wd->height_for_width;
5101 elm_genlist_bounce_set(Evas_Object *obj,
5105 ELM_CHECK_WIDTYPE(obj, widtype);
5106 Widget_Data *wd = elm_widget_data_get(obj);
5108 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5112 elm_genlist_bounce_get(const Evas_Object *obj,
5113 Eina_Bool *h_bounce,
5114 Eina_Bool *v_bounce)
5116 ELM_CHECK_WIDTYPE(obj, widtype);
5117 Widget_Data *wd = elm_widget_data_get(obj);
5119 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
5123 elm_genlist_homogeneous_set(Evas_Object *obj,
5124 Eina_Bool homogeneous)
5126 ELM_CHECK_WIDTYPE(obj, widtype);
5127 Widget_Data *wd = elm_widget_data_get(obj);
5129 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5130 wd->homogeneous = homogeneous;
5134 elm_genlist_homogeneous_get(const Evas_Object *obj)
5136 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5137 Widget_Data *wd = elm_widget_data_get(obj);
5138 if (!wd) return EINA_FALSE;
5139 return wd->homogeneous;
5143 elm_genlist_block_count_set(Evas_Object *obj,
5146 ELM_CHECK_WIDTYPE(obj, widtype);
5147 Widget_Data *wd = elm_widget_data_get(obj);
5149 wd->max_items_per_block = n;
5150 wd->item_cache_max = wd->max_items_per_block * 2;
5151 _item_cache_clean(wd);
5155 elm_genlist_block_count_get(const Evas_Object *obj)
5157 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5158 Widget_Data *wd = elm_widget_data_get(obj);
5160 return wd->max_items_per_block;
5164 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5167 ELM_CHECK_WIDTYPE(obj, widtype);
5168 Widget_Data *wd = elm_widget_data_get(obj);
5170 wd->longpress_timeout = timeout;
5174 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5176 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5177 Widget_Data *wd = elm_widget_data_get(obj);
5179 return wd->longpress_timeout;
5183 elm_genlist_scroller_policy_set(Evas_Object *obj,
5184 Elm_Scroller_Policy policy_h,
5185 Elm_Scroller_Policy policy_v)
5187 ELM_CHECK_WIDTYPE(obj, widtype);
5188 Widget_Data *wd = elm_widget_data_get(obj);
5190 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5191 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5194 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5198 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5199 Elm_Scroller_Policy *policy_h,
5200 Elm_Scroller_Policy *policy_v)
5202 ELM_CHECK_WIDTYPE(obj, widtype);
5203 Widget_Data *wd = elm_widget_data_get(obj);
5204 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5205 if ((!wd) || (!wd->scr)) return;
5206 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5207 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5208 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5212 elm_genlist_realized_items_update(Evas_Object *obj)
5214 ELM_CHECK_WIDTYPE(obj, widtype);
5216 Eina_List *list, *l;
5217 Elm_Genlist_Item *it;
5219 list = elm_genlist_realized_items_get(obj);
5220 EINA_LIST_FOREACH(list, l, it)
5221 elm_genlist_item_update(it);
5225 * Set genlist item mode
5227 * @param item The genlist item
5228 * @param mode Mode name
5229 * @param mode_set Boolean to define set or unset mode.
5234 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5235 const char *mode_type,
5238 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5239 Widget_Data *wd = it->wd;
5241 Elm_Genlist_Item *it2;
5244 if (!mode_type) return;
5245 if ((it->delete_me) || (it->disabled)) return;
5247 if ((wd->mode_item == it) &&
5248 (!strcmp(mode_type, wd->mode_type)) &&
5251 if (!it->itc->mode_item_style) return;
5255 EINA_LIST_FOREACH(wd->selected, l, it2)
5257 elm_genlist_item_selected_set(it2, EINA_FALSE);
5261 it2 = elm_genlist_selected_item_get(wd->obj);
5262 if ((it2) && (it2->realized))
5263 elm_genlist_item_selected_set(it2, EINA_FALSE);
5266 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5268 ((it == wd->mode_item) && (!mode_set)))
5269 _item_mode_unset(wd);
5271 eina_stringshare_replace(&wd->mode_type, mode_type);
5272 if (mode_set) _item_mode_set(it);
5276 * Get active genlist mode type
5278 * @param obj The genlist object
5283 elm_genlist_mode_get(const Evas_Object *obj)
5285 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5286 Widget_Data *wd = elm_widget_data_get(obj);
5287 if (!wd) return NULL;
5288 return wd->mode_type;
5292 * Get active genlist mode item
5294 * @param obj The genlist object
5298 EAPI const Elm_Genlist_Item *
5299 elm_genlist_mode_item_get(const Evas_Object *obj)
5301 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5302 Widget_Data *wd = elm_widget_data_get(obj);
5303 if (!wd) return NULL;
5304 return wd->mode_item;
5310 * @param obj The genlist object
5311 * @param reorder_mode The reorder mode
5312 * (EINA_TRUE = on, EINA_FALSE = off)
5317 elm_genlist_reorder_mode_set(Evas_Object *obj,
5318 Eina_Bool reorder_mode)
5320 ELM_CHECK_WIDTYPE(obj, widtype);
5321 Widget_Data *wd = elm_widget_data_get(obj);
5323 wd->reorder_mode = reorder_mode;
5327 * Get the reorder mode
5329 * @param obj The genlist object
5330 * @return The reorder mode
5331 * (EINA_TRUE = on, EINA_FALSE = off)
5336 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5338 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5339 Widget_Data *wd = elm_widget_data_get(obj);
5340 if (!wd) return EINA_FALSE;
5341 return wd->reorder_mode;