1 #include <Elementary.h>
6 typedef struct _Widget_Data Widget_Data;
10 Evas_Object *scr, *box, *self;
11 Eina_List *items, *selected, *to_delete;
12 Elm_List_Item *last_selected_item;
15 Evas_Coord minw[2], minh[2];
16 Eina_Bool scr_minw : 1;
17 Eina_Bool scr_minh : 1;
22 } history[SWIPE_MOVES];
24 Eina_Bool fix_pending : 1;
25 Eina_Bool on_hold : 1;
27 Eina_Bool always_select : 1;
28 Eina_Bool longpressed : 1;
29 Eina_Bool wasselected : 1;
38 Evas_Object *icon, *end;
40 Ecore_Timer *long_timer;
41 Ecore_Timer *swipe_timer;
42 Eina_Bool deleted : 1;
43 Eina_Bool disabled : 1;
45 Eina_Bool is_even : 1;
46 Eina_Bool is_separator : 1;
48 Eina_Bool selected : 1;
49 Eina_Bool highlighted : 1;
50 Eina_Bool dummy_icon : 1;
51 Eina_Bool dummy_end : 1;
54 static const char *widtype = NULL;
55 static void _del_hook(Evas_Object *obj);
56 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
57 static void _theme_hook(Evas_Object *obj);
58 static void _sizing_eval(Evas_Object *obj);
59 static void _disable_hook(Evas_Object *obj);
60 static void _on_focus_hook(void *data, Evas_Object *obj);
61 static void _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source);
62 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
63 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
64 static void _fix_items(Evas_Object *obj);
65 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
66 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
67 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
68 static void _scroll_edge_left(void *data, Evas_Object *scr, void *event_info);
69 static void _scroll_edge_right(void *data, Evas_Object *scr, void *event_info);
70 static void _scroll_edge_top(void *data, Evas_Object *scr, void *event_info);
71 static void _scroll_edge_bottom(void *data, Evas_Object *scr, void *event_info);
72 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
73 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
74 static Eina_Bool _item_single_select_up(Widget_Data *wd);
75 static Eina_Bool _item_single_select_down(Widget_Data *wd);
76 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
77 Evas_Callback_Type type, void *event_info);
78 static Eina_Bool _deselect_all_items(Widget_Data *wd);
80 static const char SIG_ACTIVATED[] = "activated";
81 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
82 static const char SIG_SELECTED[] = "selected";
83 static const char SIG_UNSELECTED[] = "unselected";
84 static const char SIG_LONGPRESSED[] = "longpressed";
85 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
86 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
87 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
88 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
90 static const Evas_Smart_Cb_Description _signals[] = {
92 {SIG_CLICKED_DOUBLE, ""},
95 {SIG_LONGPRESSED, ""},
96 {SIG_SCROLL_EDGE_TOP, ""},
97 {SIG_SCROLL_EDGE_BOTTOM, ""},
98 {SIG_SCROLL_EDGE_LEFT, ""},
99 {SIG_SCROLL_EDGE_RIGHT, ""},
103 #define ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ...) \
104 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, __VA_ARGS__); \
107 ERR("ERROR: "#it" has been DELETED.\n"); \
108 return __VA_ARGS__; \
112 _elm_list_item_free(Elm_List_Item *it)
114 evas_object_event_callback_del_full
115 (it->base.view, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
116 evas_object_event_callback_del_full
117 (it->base.view, EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
118 evas_object_event_callback_del_full
119 (it->base.view, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, it);
122 evas_object_event_callback_del_full
123 (it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
124 _changed_size_hints, it->base.widget);
127 evas_object_event_callback_del_full
128 (it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
129 _changed_size_hints, it->base.widget);
131 eina_stringshare_del(it->label);
133 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
134 if (it->long_timer) ecore_timer_del(it->long_timer);
135 if (it->icon) evas_object_del(it->icon);
136 if (it->end) evas_object_del(it->end);
138 elm_widget_item_del(it);
142 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
144 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
145 Evas_Event_Key_Down *ev = event_info;
146 Widget_Data *wd = elm_widget_data_get(obj);
147 if (!wd) return EINA_FALSE;
148 if (!wd->items) return EINA_FALSE;
149 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
150 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
152 Elm_List_Item *it = NULL;
155 Evas_Coord step_x = 0;
156 Evas_Coord step_y = 0;
159 Evas_Coord page_x = 0;
160 Evas_Coord page_y = 0;
162 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
163 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
164 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
165 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
167 /* TODO: fix logic for horizontal mode */
168 if ((!strcmp(ev->keyname, "Left")) ||
169 (!strcmp(ev->keyname, "KP_Left")))
172 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
173 (_item_multi_select_up(wd)))
174 || (_item_single_select_up(wd))))
176 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
182 else if ((!strcmp(ev->keyname, "Right")) ||
183 (!strcmp(ev->keyname, "KP_Right")))
186 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
187 (_item_multi_select_down(wd)))
188 || (_item_single_select_down(wd))))
190 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
196 else if ((!strcmp(ev->keyname, "Up")) ||
197 (!strcmp(ev->keyname, "KP_Up")))
200 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
201 (_item_multi_select_up(wd)))
202 || (_item_single_select_up(wd))))
204 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
210 else if ((!strcmp(ev->keyname, "Down")) ||
211 (!strcmp(ev->keyname, "KP_Down")))
214 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
215 (_item_multi_select_down(wd)))
216 || (_item_single_select_down(wd))))
218 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
224 else if ((!strcmp(ev->keyname, "Home")) ||
225 (!strcmp(ev->keyname, "KP_Home")))
227 it = eina_list_data_get(wd->items);
228 elm_list_item_bring_in(it);
229 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
232 else if ((!strcmp(ev->keyname, "End")) ||
233 (!strcmp(ev->keyname, "KP_End")))
235 it = eina_list_data_get(eina_list_last(wd->items));
236 elm_list_item_bring_in(it);
237 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
240 else if ((!strcmp(ev->keyname, "Prior")) ||
241 (!strcmp(ev->keyname, "KP_Prior")))
246 x -= -(page_x * v_w) / 100;
253 y -= -(page_y * v_h) / 100;
258 else if ((!strcmp(ev->keyname, "Next")) ||
259 (!strcmp(ev->keyname, "KP_Next")))
264 x += -(page_x * v_w) / 100;
271 y += -(page_y * v_h) / 100;
276 else if (((!strcmp(ev->keyname, "Return")) ||
277 (!strcmp(ev->keyname, "KP_Enter")) ||
278 (!strcmp(ev->keyname, "space")))
279 && (!wd->multi) && (wd->selected))
281 it = elm_list_selected_item_get(obj);
282 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
284 else if (!strcmp(ev->keyname, "Escape"))
286 if (!_deselect_all_items(wd)) return EINA_FALSE;
287 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
290 else return EINA_FALSE;
292 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
293 elm_smart_scroller_child_pos_set(wd->scr, x, y);
298 _deselect_all_items(Widget_Data *wd)
300 if (!wd->selected) return EINA_FALSE;
302 elm_list_item_selected_set(wd->selected->data, EINA_FALSE);
308 _item_multi_select_up(Widget_Data *wd)
310 if (!wd->selected) return EINA_FALSE;
311 if (!wd->multi) return EINA_FALSE;
313 Elm_List_Item *prev = elm_list_item_prev(wd->last_selected_item);
314 if (!prev) return EINA_TRUE;
316 if (elm_list_item_selected_get(prev))
318 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
319 wd->last_selected_item = prev;
320 elm_list_item_show(wd->last_selected_item);
324 elm_list_item_selected_set(prev, EINA_TRUE);
325 elm_list_item_show(prev);
331 _item_multi_select_down(Widget_Data *wd)
333 if (!wd->selected) return EINA_FALSE;
334 if (!wd->multi) return EINA_FALSE;
336 Elm_List_Item *next = elm_list_item_next(wd->last_selected_item);
337 if (!next) return EINA_TRUE;
339 if (elm_list_item_selected_get(next))
341 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
342 wd->last_selected_item = next;
343 elm_list_item_show(wd->last_selected_item);
347 elm_list_item_selected_set(next, EINA_TRUE);
348 elm_list_item_show(next);
354 _item_single_select_up(Widget_Data *wd)
358 if (!wd->selected) prev = eina_list_data_get(eina_list_last(wd->items));
359 else prev = elm_list_item_prev(wd->last_selected_item);
361 if (!prev) return EINA_FALSE;
363 _deselect_all_items(wd);
365 elm_list_item_selected_set(prev, EINA_TRUE);
366 elm_list_item_show(prev);
371 _item_single_select_down(Widget_Data *wd)
375 if (!wd->selected) next = eina_list_data_get(wd->items);
376 else next = elm_list_item_next(wd->last_selected_item);
378 if (!next) return EINA_FALSE;
380 _deselect_all_items(wd);
382 elm_list_item_selected_set(next, EINA_TRUE);
383 elm_list_item_show(next);
388 _elm_list_process_deletions(Widget_Data *wd)
392 wd->walking++; // avoid nested deletion and also _sub_del() fix_items
394 EINA_LIST_FREE(wd->to_delete, it)
396 elm_widget_item_pre_notify_del(it);
398 wd->items = eina_list_remove_list(wd->items, it->node);
399 _elm_list_item_free(it);
406 _elm_list_walk(Widget_Data *wd)
410 ERR("ERROR: walking was negative. fixed!\n");
417 _elm_list_unwalk(Widget_Data *wd)
422 ERR("ERROR: walking became negative. fixed!\n");
430 _elm_list_process_deletions(wd);
434 wd->fix_pending = EINA_FALSE;
435 _fix_items(wd->self);
436 _sizing_eval(wd->self);
441 _del_pre_hook(Evas_Object *obj)
443 Widget_Data *wd = elm_widget_data_get(obj);
446 evas_object_event_callback_del(wd->scr,
447 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
448 _changed_size_hints);
449 evas_object_event_callback_del(wd->box,
450 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
451 _changed_size_hints);
455 _del_hook(Evas_Object *obj)
457 Widget_Data *wd = elm_widget_data_get(obj);
463 ERR("ERROR: list deleted while walking.\n");
466 EINA_LIST_FOREACH(wd->items, n, it) elm_widget_item_pre_notify_del(it);
467 _elm_list_unwalk(wd);
469 ERR("ERROR: leaking nodes!\n");
471 EINA_LIST_FREE(wd->items, it) _elm_list_item_free(it);
472 eina_list_free(wd->selected);
477 _show_region_hook(void *data, Evas_Object *obj)
479 Widget_Data *wd = elm_widget_data_get(data);
480 Evas_Coord x, y, w, h;
482 elm_widget_show_region_get(obj, &x, &y, &w, &h);
483 elm_smart_scroller_child_region_set(wd->scr, x, y, w, h);
487 _disable_hook(Evas_Object *obj)
489 Widget_Data *wd = elm_widget_data_get(obj);
491 if (elm_widget_disabled_get(obj))
493 _signal_emit_hook(obj, "elm,state,disabled", "elm");
494 elm_widget_scroll_freeze_push(obj);
495 elm_widget_scroll_hold_push(obj);
496 /* FIXME: if we get to have a way to only un-highlight items
497 * in the future, keeping them selected... */
498 _deselect_all_items(wd);
502 _signal_emit_hook(obj, "elm,state,enabled", "elm");
503 elm_widget_scroll_freeze_pop(obj);
504 elm_widget_scroll_hold_pop(obj);
509 _sizing_eval(Evas_Object *obj)
512 Widget_Data *wd = elm_widget_data_get(obj);
514 Evas_Coord vw, vh, minw, minh, maxw, maxh, w, h, vmw, vmh;
517 evas_object_size_hint_min_get(wd->box, &minw, &minh);
518 evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
519 evas_object_size_hint_weight_get(wd->box, &xw, &yw);
520 if (!wd->scr) return;
521 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
524 if ((minw > 0) && (vw < minw)) vw = minw;
525 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
527 else if (minw > 0) vw = minw;
530 if ((minh > 0) && (vh < minh)) vh = minh;
531 else if ((maxh > 0) && (vh > maxh)) vh = maxh;
533 else if (minh > 0) vh = minh;
534 evas_object_resize(wd->box, vw, vh);
537 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
539 if (wd->scr_minw) w = vmw + minw;
540 if (wd->scr_minh) h = vmh + minh;
542 evas_object_size_hint_max_get(obj, &maxw, &maxh);
543 if ((maxw > 0) && (w > maxw))
545 if ((maxh > 0) && (h > maxh))
548 evas_object_size_hint_min_set(obj, w, h);
552 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
554 Widget_Data *wd = elm_widget_data_get(obj);
555 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
560 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
562 Widget_Data *wd = elm_widget_data_get(obj);
563 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
564 emission, source, func_cb, data);
568 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
570 Widget_Data *wd = elm_widget_data_get(obj);
571 edje_object_signal_callback_del_full(
572 elm_smart_scroller_edje_object_get(wd->scr),
573 emission, source, func_cb, data);
577 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
579 Widget_Data *wd = elm_widget_data_get(obj);
585 elm_smart_scroller_mirrored_set(wd->scr, rtl);
587 EINA_LIST_FOREACH(wd->items, n, it)
588 edje_object_mirrored_set(it->base.view, rtl);
592 _theme_hook(Evas_Object *obj)
594 Widget_Data *wd = elm_widget_data_get(obj);
599 _elm_widget_mirrored_reload(obj);
600 _mirrored_set(obj, elm_widget_mirrored_get(obj));
607 elm_smart_scroller_object_theme_set(obj, wd->scr, "list", "base",
608 elm_widget_style_get(obj));
609 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
610 edj = elm_smart_scroller_edje_object_get(wd->scr);
611 str = edje_object_data_get(edj, "focus_highlight");
612 if ((str) && (!strcmp(str, "on")))
613 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
615 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
616 elm_object_style_set(wd->scr, elm_widget_style_get(obj));
618 EINA_LIST_FOREACH(wd->items, n, it)
620 edje_object_scale_set(it->base.view, elm_widget_scale_get(obj) * _elm_config->scale);
628 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
630 Widget_Data *wd = elm_widget_data_get(obj);
632 if (elm_widget_focus_get(obj))
634 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
635 evas_object_focus_set(wd->self, EINA_TRUE);
637 if ((wd->selected) && (!wd->last_selected_item))
638 wd->last_selected_item = eina_list_data_get(wd->selected);
642 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
643 evas_object_focus_set(wd->self, EINA_FALSE);
648 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
650 Widget_Data *wd = elm_widget_data_get(data);
657 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
659 Widget_Data *wd = elm_widget_data_get(obj);
660 Evas_Object *sub = event_info;
666 if ((sub == wd->box) || (sub == wd->scr)) return;
668 EINA_LIST_FOREACH(wd->items, l, it)
670 if ((sub == it->icon) || (sub == it->end))
672 if (it->icon == sub) it->icon = NULL;
673 if (it->end == sub) it->end = NULL;
674 evas_object_event_callback_del_full
675 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints,
683 wd->fix_pending = EINA_TRUE;
690 _item_highlight(Elm_List_Item *it)
692 Evas_Object *obj = it->base.widget;
693 Widget_Data *wd = elm_widget_data_get(obj);
694 const char *selectraise;
697 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
698 if ((it->highlighted) || (it->disabled)) return;
700 evas_object_ref(obj);
703 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
704 selectraise = edje_object_data_get(it->base.view, "selectraise");
705 if ((selectraise) && (!strcmp(selectraise, "on")))
706 evas_object_raise(it->base.view);
707 it->highlighted = EINA_TRUE;
709 _elm_list_unwalk(wd);
710 evas_object_unref(obj);
714 _item_select(Elm_List_Item *it)
716 Evas_Object *obj = it->base.widget;
717 Widget_Data *wd = elm_widget_data_get(obj);
720 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
721 if (it->disabled) return;
724 if (wd->always_select) goto call;
727 it->selected = EINA_TRUE;
728 wd->selected = eina_list_append(wd->selected, it);
731 evas_object_ref(obj);
734 if (it->func) it->func((void *)it->base.data, it->base.widget, it);
735 evas_object_smart_callback_call(obj, SIG_SELECTED, it);
736 it->wd->last_selected_item = it;
738 _elm_list_unwalk(wd);
739 evas_object_unref(obj);
743 _item_unselect(Elm_List_Item *it)
745 Evas_Object *obj = it->base.widget;
746 Widget_Data *wd = elm_widget_data_get(obj);
747 const char *stacking, *selectraise;
750 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
751 if (!it->highlighted) return;
753 evas_object_ref(obj);
756 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
757 stacking = edje_object_data_get(it->base.view, "stacking");
758 selectraise = edje_object_data_get(it->base.view, "selectraise");
759 if ((selectraise) && (!strcmp(selectraise, "on")))
761 if ((stacking) && (!strcmp(stacking, "below")))
762 evas_object_lower(it->base.view);
764 it->highlighted = EINA_FALSE;
767 it->selected = EINA_FALSE;
768 wd->selected = eina_list_remove(wd->selected, it);
769 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
772 _elm_list_unwalk(wd);
773 evas_object_unref(obj);
777 _swipe_cancel(void *data)
779 Elm_List_Item *it = data;
780 Widget_Data *wd = elm_widget_data_get(it->base.widget);
782 if (!wd) return ECORE_CALLBACK_CANCEL;
783 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
784 wd->swipe = EINA_FALSE;
786 return ECORE_CALLBACK_RENEW;
790 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
792 Elm_List_Item *it = data;
793 Evas_Object *obj2 = it->base.widget;
794 Widget_Data *wd = elm_widget_data_get(obj2);
795 Evas_Event_Mouse_Move *ev = event_info;
798 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
800 evas_object_ref(obj2);
803 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
807 wd->on_hold = EINA_TRUE;
810 ecore_timer_del(it->long_timer);
811 it->long_timer = NULL;
813 if (!wd->wasselected)
816 if (wd->movements == SWIPE_MOVES) wd->swipe = EINA_TRUE;
819 wd->history[wd->movements].x = ev->cur.canvas.x;
820 wd->history[wd->movements].y = ev->cur.canvas.y;
821 if (abs((wd->history[wd->movements].x - wd->history[0].x)) > 40)
822 wd->swipe = EINA_TRUE;
828 _elm_list_unwalk(wd);
829 evas_object_unref(obj2);
833 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
835 Evas_Object *obj = data;
836 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
840 _scroll_edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
842 Evas_Object *obj = data;
843 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
847 _scroll_edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
849 Evas_Object *obj = data;
850 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
854 _scroll_edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
856 Evas_Object *obj = data;
857 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
861 _long_press(void *data)
863 Elm_List_Item *it = data;
864 Evas_Object *obj = it->base.widget;
865 Widget_Data *wd = elm_widget_data_get(obj);
869 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
870 it->long_timer = NULL;
871 if (it->disabled) goto end;
873 wd->longpressed = EINA_TRUE;
874 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
877 return ECORE_CALLBACK_CANCEL;
881 _swipe(Elm_List_Item *it)
884 Widget_Data *wd = elm_widget_data_get(it->base.widget);
886 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
888 wd->swipe = EINA_FALSE;
889 for (i = 0; i < wd->movements; i++)
891 sum += wd->history[i].x;
892 if (abs(wd->history[0].y - wd->history[i].y) > 10) return;
895 sum /= wd->movements;
896 if (abs(sum - wd->history[0].x) <= 10) return;
897 evas_object_smart_callback_call(it->base.widget, "swipe", it);
901 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
903 Elm_List_Item *it = data;
904 Evas_Object *obj2 = it->base.widget;
905 Widget_Data *wd = elm_widget_data_get(obj2);
906 Evas_Event_Mouse_Down *ev = event_info;
909 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
910 if (ev->button != 1) return;
911 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
912 else wd->on_hold = EINA_FALSE;
913 if (wd->on_hold) return;
914 wd->wasselected = it->selected;
916 evas_object_ref(obj2);
920 wd->longpressed = EINA_FALSE;
921 if (it->long_timer) ecore_timer_del(it->long_timer);
922 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, it);
923 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
924 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
925 /* Always call the callbacks last - the user may delete our context! */
926 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
928 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
929 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
931 wd->swipe = EINA_FALSE;
934 _elm_list_unwalk(wd);
935 evas_object_unref(obj2);
939 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
941 Elm_List_Item *it = data;
942 Evas_Object *obj2 = it->base.widget;
943 Widget_Data *wd = elm_widget_data_get(obj2);
944 Evas_Event_Mouse_Up *ev = event_info;
947 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
948 if (ev->button != 1) return;
949 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
950 else wd->on_hold = EINA_FALSE;
951 wd->longpressed = EINA_FALSE;
954 ecore_timer_del(it->long_timer);
955 it->long_timer = NULL;
959 ecore_timer_del(it->swipe_timer);
960 it->swipe_timer = NULL;
964 if (wd->swipe) _swipe(data);
965 wd->on_hold = EINA_FALSE;
970 if (!wd->wasselected) _item_unselect(it);
977 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
979 evas_object_ref(obj2);
989 else _item_unselect(it);
996 _item_unselect(wd->selected->data);
1002 const Eina_List *l, *l_next;
1005 EINA_LIST_FOREACH_SAFE(wd->selected, l, l_next, it2)
1006 if (it2 != it) _item_unselect(it2);
1007 _item_highlight(it);
1012 _elm_list_unwalk(wd);
1013 evas_object_unref(obj2);
1016 static Elm_List_Item *
1017 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1019 Widget_Data *wd = elm_widget_data_get(obj);
1022 if (!wd) return NULL;
1023 it = elm_widget_item_new(obj, Elm_List_Item);
1025 it->label = eina_stringshare_add(label);
1029 it->base.data = data;
1030 it->base.view = edje_object_add(evas_object_evas_get(obj));
1031 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(obj));
1032 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1034 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1036 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1038 evas_object_size_hint_weight_set(it->base.view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1039 evas_object_size_hint_align_set(it->base.view, EVAS_HINT_FILL, EVAS_HINT_FILL);
1042 elm_widget_sub_object_add(obj, it->icon);
1043 evas_object_event_callback_add(it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1044 _changed_size_hints, obj);
1048 elm_widget_sub_object_add(obj, it->end);
1049 evas_object_event_callback_add(it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1050 _changed_size_hints, obj);
1056 _elm_list_mode_set_internal(Widget_Data *wd)
1061 if (wd->mode == ELM_LIST_LIMIT)
1065 wd->scr_minw = EINA_TRUE;
1066 wd->scr_minh = EINA_FALSE;
1070 wd->scr_minw = EINA_FALSE;
1071 wd->scr_minh = EINA_TRUE;
1074 else if (wd->mode == ELM_LIST_EXPAND)
1076 wd->scr_minw = EINA_TRUE;
1077 wd->scr_minh = EINA_TRUE;
1081 wd->scr_minw = EINA_FALSE;
1082 wd->scr_minh = EINA_FALSE;
1085 _sizing_eval(wd->self);
1089 _fix_items(Evas_Object *obj)
1091 Widget_Data *wd = elm_widget_data_get(obj);
1095 Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
1098 const char *style = elm_widget_style_get(obj);
1099 const char *it_plain = wd->h_mode ? "h_item" : "item";
1100 const char *it_odd = wd->h_mode ? "h_item_odd" : "item_odd";
1101 const char *it_compress = wd->h_mode ? "h_item_compress" : "item_compress";
1102 const char *it_compress_odd = wd->h_mode ? "h_item_compress_odd" : "item_compress_odd";
1106 wd->fix_pending = EINA_TRUE;
1110 evas_object_ref(obj);
1111 _elm_list_walk(wd); // watch out "return" before unwalk!
1113 EINA_LIST_FOREACH(wd->items, l, it)
1115 if (it->deleted) continue;
1118 evas_object_size_hint_min_get(it->icon, &mw, &mh);
1119 if (mw > minw[0]) minw[0] = mw;
1120 if (mh > minh[0]) minh[0] = mh;
1124 evas_object_size_hint_min_get(it->end, &mw, &mh);
1125 if (mw > minw[1]) minw[1] = mw;
1126 if (mh > minh[1]) minh[1] = mh;
1130 if ((minw[0] != wd->minw[0]) || (minw[1] != wd->minw[1]) ||
1131 (minw[0] != wd->minh[0]) || (minh[1] != wd->minh[1]))
1133 wd->minw[0] = minw[0];
1134 wd->minw[1] = minw[1];
1135 wd->minh[0] = minh[0];
1136 wd->minh[1] = minh[1];
1140 EINA_LIST_FOREACH(wd->items, l, it)
1146 if ((it->even != it->is_even) || (!it->fixed) || (redo))
1148 const char *stacking;
1150 /* FIXME: separators' themes seem to be b0rked */
1151 if (it->is_separator)
1152 _elm_theme_object_set(obj, it->base.view, "separator",
1153 wd->h_mode ? "horizontal" : "vertical",
1155 else if (wd->mode == ELM_LIST_COMPRESS)
1158 _elm_theme_object_set(obj, it->base.view, "list",
1159 it_compress, style);
1161 _elm_theme_object_set(obj, it->base.view, "list",
1162 it_compress_odd, style);
1167 _elm_theme_object_set(obj, it->base.view, "list", it_plain,
1170 _elm_theme_object_set(obj, it->base.view, "list", it_odd,
1173 stacking = edje_object_data_get(it->base.view, "stacking");
1176 if (!strcmp(stacking, "below"))
1177 evas_object_lower(it->base.view);
1178 else if (!strcmp(stacking, "above"))
1179 evas_object_raise(it->base.view);
1181 edje_object_part_text_set(it->base.view, "elm.text", it->label);
1183 if ((!it->icon) && (minh[0] > 0))
1185 it->icon = evas_object_rectangle_add(evas_object_evas_get(it->base.view));
1186 evas_object_color_set(it->icon, 0, 0, 0, 0);
1187 it->dummy_icon = EINA_TRUE;
1189 if ((!it->end) && (minh[1] > 0))
1191 it->end = evas_object_rectangle_add(evas_object_evas_get(it->base.view));
1192 evas_object_color_set(it->end, 0, 0, 0, 0);
1193 it->dummy_end = EINA_TRUE;
1197 evas_object_size_hint_min_set(it->icon, minw[0], minh[0]);
1198 evas_object_size_hint_max_set(it->icon, 99999, 99999);
1199 edje_object_part_swallow(it->base.view, "elm.swallow.icon", it->icon);
1203 evas_object_size_hint_min_set(it->end, minw[1], minh[1]);
1204 evas_object_size_hint_max_set(it->end, 99999, 99999);
1205 edje_object_part_swallow(it->base.view, "elm.swallow.end", it->end);
1209 // this may call up user and it may modify the list item
1210 // but we're safe as we're flagged as walking.
1211 // just don't process further
1212 edje_object_message_signal_process(it->base.view);
1216 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1217 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
1218 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1219 evas_object_size_hint_min_set(it->base.view, mw, mh);
1220 evas_object_show(it->base.view);
1222 if ((it->selected) || (it->highlighted))
1224 const char *selectraise;
1226 // this may call up user and it may modify the list item
1227 // but we're safe as we're flagged as walking.
1228 // just don't process further
1229 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
1233 selectraise = edje_object_data_get(it->base.view, "selectraise");
1234 if ((selectraise) && (!strcmp(selectraise, "on")))
1235 evas_object_raise(it->base.view);
1238 edje_object_signal_emit(it->base.view, "elm,state,disabled",
1241 it->fixed = EINA_TRUE;
1242 it->is_even = it->even;
1248 evas_object_size_hint_min_get(wd->box, &mw, &mh);
1250 _elm_list_mode_set_internal(wd);
1252 _elm_list_unwalk(wd);
1253 evas_object_unref(obj);
1257 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1259 Widget_Data *wd = elm_widget_data_get(obj);
1262 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
1266 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1268 Widget_Data *wd = elm_widget_data_get(obj);
1271 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1275 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1277 Widget_Data *wd = elm_widget_data_get(obj);
1280 elm_smart_scroller_freeze_set(wd->scr, EINA_TRUE);
1284 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1286 Widget_Data *wd = elm_widget_data_get(obj);
1289 elm_smart_scroller_freeze_set(wd->scr, EINA_FALSE);
1293 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1299 elm_list_add(Evas_Object *parent)
1304 Evas_Coord minw, minh;
1306 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1308 ELM_SET_WIDTYPE(widtype, "list");
1309 elm_widget_type_set(obj, "list");
1310 elm_widget_sub_object_add(parent, obj);
1311 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1312 elm_widget_data_set(obj, wd);
1313 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1314 elm_widget_del_hook_set(obj, _del_hook);
1315 elm_widget_theme_hook_set(obj, _theme_hook);
1316 elm_widget_disable_hook_set(obj, _disable_hook);
1317 elm_widget_can_focus_set(obj, EINA_TRUE);
1318 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1319 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1320 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1321 elm_widget_event_hook_set(obj, _event_hook);
1324 wd->scr = elm_smart_scroller_add(e);
1325 elm_smart_scroller_widget_set(wd->scr, obj);
1326 elm_widget_resize_object_set(obj, wd->scr);
1327 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1328 _changed_size_hints, obj);
1329 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
1330 evas_object_size_hint_min_set(obj, minw, minh);
1331 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1333 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
1334 _elm_config->thumbscroll_bounce_enable);
1336 wd->box = elm_box_add(parent);
1337 elm_box_homogeneous_set(wd->box, 1);
1338 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1339 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1340 elm_widget_on_show_region_hook_set(wd->box, _show_region_hook, obj);
1341 elm_widget_sub_object_add(obj, wd->box);
1342 elm_smart_scroller_child_set(wd->scr, wd->box);
1343 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1344 _changed_size_hints, obj);
1346 evas_object_show(wd->box);
1350 wd->mode = ELM_LIST_SCROLL;
1352 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
1353 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right, obj);
1354 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
1355 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom, obj);
1357 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1358 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1359 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1360 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1361 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1363 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1365 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1370 EAPI Elm_List_Item *
1371 elm_list_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1373 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1374 Widget_Data *wd = elm_widget_data_get(obj);
1375 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1377 wd->items = eina_list_append(wd->items, it);
1378 it->node = eina_list_last(wd->items);
1379 elm_box_pack_end(wd->box, it->base.view);
1383 EAPI Elm_List_Item *
1384 elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1386 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1387 Widget_Data *wd = elm_widget_data_get(obj);
1388 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1390 wd->items = eina_list_prepend(wd->items, it);
1391 it->node = wd->items;
1392 elm_box_pack_start(wd->box, it->base.view);
1396 EAPI Elm_List_Item *
1397 elm_list_item_insert_before(Evas_Object *obj, Elm_List_Item *before, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1402 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
1403 if (!before->node) return NULL;
1404 ELM_LIST_ITEM_CHECK_DELETED_RETURN(before, NULL);
1406 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1407 wd = elm_widget_data_get(obj);
1408 if (!wd) return NULL;
1409 it = _item_new(obj, label, icon, end, func, data);
1410 wd->items = eina_list_prepend_relative_list(wd->items, it, before->node);
1411 it->node = before->node->prev;
1412 elm_box_pack_before(wd->box, it->base.view, before->base.view);
1416 EAPI Elm_List_Item *
1417 elm_list_item_insert_after(Evas_Object *obj, Elm_List_Item *after, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1422 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
1423 if (!after->node) return NULL;
1424 ELM_LIST_ITEM_CHECK_DELETED_RETURN(after, NULL);
1426 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1427 wd = elm_widget_data_get(obj);
1428 if (!wd) return NULL;
1429 it = _item_new(obj, label, icon, end, func, data);
1430 wd->items = eina_list_append_relative_list(wd->items, it, after->node);
1431 it->node = after->node->next;
1432 elm_box_pack_after(wd->box, it->base.view, after->base.view);
1436 EAPI Elm_List_Item *
1437 elm_list_item_sorted_insert(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data, Eina_Compare_Cb cmp_func)
1439 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1440 Widget_Data *wd = elm_widget_data_get(obj);
1441 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1444 wd->items = eina_list_sorted_insert(wd->items, cmp_func, it);
1445 l = eina_list_data_find_list(wd->items, it);
1446 l = eina_list_next(l);
1449 it->node = eina_list_last(wd->items);
1450 elm_box_pack_end(wd->box, it->base.view);
1454 Elm_List_Item *before = eina_list_data_get(l);
1455 it->node = before->node->prev;
1456 elm_box_pack_before(wd->box, it->base.view, before->base.view);
1462 elm_list_clear(Evas_Object *obj)
1464 ELM_CHECK_WIDTYPE(obj, widtype);
1465 Widget_Data *wd = elm_widget_data_get(obj);
1469 if (!wd->items) return;
1471 eina_list_free(wd->selected);
1472 wd->selected = NULL;
1474 if (wd->walking > 0)
1478 EINA_LIST_FOREACH(wd->items, n, it)
1480 if (it->deleted) continue;
1481 it->deleted = EINA_TRUE;
1482 wd->to_delete = eina_list_append(wd->to_delete, it);
1487 evas_object_ref(obj);
1490 EINA_LIST_FREE(wd->items, it)
1492 elm_widget_item_pre_notify_del(it);
1493 _elm_list_item_free(it);
1496 _elm_list_unwalk(wd);
1500 evas_object_unref(obj);
1504 elm_list_go(Evas_Object *obj)
1506 ELM_CHECK_WIDTYPE(obj, widtype);
1507 Widget_Data *wd = elm_widget_data_get(obj);
1513 elm_list_multi_select_set(Evas_Object *obj, Eina_Bool multi)
1515 ELM_CHECK_WIDTYPE(obj, widtype);
1516 Widget_Data *wd = elm_widget_data_get(obj);
1522 elm_list_multi_select_get(const Evas_Object *obj)
1524 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1525 Widget_Data *wd = elm_widget_data_get(obj);
1526 if (!wd) return EINA_FALSE;
1531 elm_list_mode_set(Evas_Object *obj, Elm_List_Mode mode)
1533 ELM_CHECK_WIDTYPE(obj, widtype);
1537 wd = elm_widget_data_get(obj);
1540 if (wd->mode == mode)
1544 _elm_list_mode_set_internal(wd);
1548 elm_list_mode_get(const Evas_Object *obj)
1550 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
1551 Widget_Data *wd = elm_widget_data_get(obj);
1552 if (!wd) return ELM_LIST_LAST;
1557 elm_list_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1559 ELM_CHECK_WIDTYPE(obj, widtype);
1562 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1564 wd = elm_widget_data_get(obj);
1568 if (wd->h_mode == horizontal)
1571 wd->h_mode = horizontal;
1572 elm_box_horizontal_set(wd->box, horizontal);
1576 evas_object_size_hint_weight_set(wd->box, 0.0, EVAS_HINT_EXPAND);
1577 evas_object_size_hint_align_set(wd->box, 0.0, EVAS_HINT_FILL);
1578 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1582 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1583 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1584 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, bounce);
1587 _elm_list_mode_set_internal(wd);
1591 elm_list_horizontal_get(const Evas_Object *obj)
1593 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1597 wd = elm_widget_data_get(obj);
1605 elm_list_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
1607 ELM_CHECK_WIDTYPE(obj, widtype);
1608 Widget_Data *wd = elm_widget_data_get(obj);
1610 wd->always_select = always_select;
1614 elm_list_always_select_mode_get(const Evas_Object *obj)
1616 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1617 Widget_Data *wd = elm_widget_data_get(obj);
1618 if (!wd) return EINA_FALSE;
1619 return wd->always_select;
1622 EAPI const Eina_List *
1623 elm_list_items_get(const Evas_Object *obj)
1625 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1626 Widget_Data *wd = elm_widget_data_get(obj);
1627 if (!wd) return NULL;
1631 EAPI Elm_List_Item *
1632 elm_list_selected_item_get(const Evas_Object *obj)
1634 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1635 Widget_Data *wd = elm_widget_data_get(obj);
1636 if (!wd) return NULL;
1637 if (wd->selected) return wd->selected->data;
1641 EAPI const Eina_List *
1642 elm_list_selected_items_get(const Evas_Object *obj)
1644 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1645 Widget_Data *wd = elm_widget_data_get(obj);
1646 if (!wd) return NULL;
1647 return wd->selected;
1651 elm_list_item_separator_set(Elm_List_Item *it, Eina_Bool setting)
1653 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1654 it->is_separator = !!setting;
1658 elm_list_item_separator_get(const Elm_List_Item *it)
1660 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1661 return it->is_separator;
1666 elm_list_item_selected_set(Elm_List_Item *it, Eina_Bool selected)
1668 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1669 Evas_Object *obj = it->base.widget;
1670 Widget_Data *wd = elm_widget_data_get(obj);
1673 selected = !!selected;
1674 if (it->selected == selected) return;
1676 evas_object_ref(obj);
1683 while (wd->selected)
1684 _item_unselect(wd->selected->data);
1686 _item_highlight(it);
1692 _elm_list_unwalk(wd);
1693 evas_object_unref(obj);
1697 elm_list_item_selected_get(const Elm_List_Item *it)
1699 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1700 return it->selected;
1704 elm_list_item_show(Elm_List_Item *it)
1706 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1707 Widget_Data *wd = elm_widget_data_get(it->base.widget);
1708 Evas_Coord bx, by, bw, bh;
1709 Evas_Coord x, y, w, h;
1711 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1712 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
1716 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
1720 elm_list_item_bring_in(Elm_List_Item *it)
1722 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1723 Widget_Data *wd = elm_widget_data_get(it->base.widget);
1724 Evas_Coord bx, by, bw, bh;
1725 Evas_Coord x, y, w, h;
1727 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1728 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
1732 elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
1736 elm_list_item_del(Elm_List_Item *it)
1738 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1739 Evas_Object *obj = it->base.widget;
1740 Widget_Data *wd = elm_widget_data_get(obj);
1743 if (it->selected) _item_unselect(it);
1745 if (wd->walking > 0)
1747 if (it->deleted) return;
1748 it->deleted = EINA_TRUE;
1749 wd->to_delete = eina_list_append(wd->to_delete, it);
1753 wd->items = eina_list_remove_list(wd->items, it->node);
1755 evas_object_ref(obj);
1758 elm_widget_item_pre_notify_del(it);
1759 _elm_list_item_free(it);
1761 _elm_list_unwalk(wd);
1762 evas_object_unref(obj);
1766 elm_list_item_del_cb_set(Elm_List_Item *it, Evas_Smart_Cb func)
1768 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1769 elm_widget_item_del_cb_set(it, func);
1773 elm_list_item_data_get(const Elm_List_Item *it)
1775 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1776 return elm_widget_item_data_get(it);
1780 elm_list_item_icon_get(const Elm_List_Item *it)
1782 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1783 if (it->dummy_icon) return NULL;
1788 elm_list_item_icon_set(Elm_List_Item *it, Evas_Object *icon)
1790 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1791 if (it->icon == icon) return;
1792 if ((it->dummy_icon) && (!icon)) return;
1795 evas_object_del(it->icon);
1796 it->dummy_icon = EINA_FALSE;
1800 icon = evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1801 evas_object_color_set(icon, 0, 0, 0, 0);
1802 it->dummy_icon = EINA_TRUE;
1806 evas_object_del(it->icon);
1811 edje_object_part_swallow(it->base.view, "elm.swallow.icon", icon);
1815 elm_list_item_end_get(const Elm_List_Item *it)
1817 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1818 if (it->dummy_end) return NULL;
1823 elm_list_item_end_set(Elm_List_Item *it, Evas_Object *end)
1825 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1826 if (it->end == end) return;
1827 if ((it->dummy_end) && (!end)) return;
1830 evas_object_del(it->end);
1831 it->dummy_icon = EINA_FALSE;
1835 end = evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1836 evas_object_color_set(end, 0, 0, 0, 0);
1837 it->dummy_end = EINA_TRUE;
1841 evas_object_del(it->end);
1846 edje_object_part_swallow(it->base.view, "elm.swallow.end", end);
1850 elm_list_item_base_get(const Elm_List_Item *it)
1852 return elm_list_item_object_get(it);
1856 elm_list_item_object_get(const Elm_List_Item *it)
1858 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1859 return it->base.view;
1863 elm_list_item_label_get(const Elm_List_Item *it)
1865 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1870 elm_list_item_label_set(Elm_List_Item *it, const char *text)
1872 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1873 if (!eina_stringshare_replace(&it->label, text)) return;
1875 edje_object_part_text_set(it->base.view, "elm.text", it->label);
1878 EAPI Elm_List_Item *
1879 elm_list_item_prev(const Elm_List_Item *it)
1881 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1882 if (it->node->prev) return it->node->prev->data;
1886 EAPI Elm_List_Item *
1887 elm_list_item_next(const Elm_List_Item *it)
1889 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1890 if (it->node->next) return it->node->next->data;
1895 elm_list_item_tooltip_text_set(Elm_List_Item *item, const char *text)
1897 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1898 elm_widget_item_tooltip_text_set(item, text);
1902 elm_list_item_tooltip_content_cb_set(Elm_List_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
1904 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1905 elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
1909 elm_list_item_tooltip_unset(Elm_List_Item *item)
1911 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1912 elm_widget_item_tooltip_unset(item);
1916 elm_list_item_tooltip_size_restrict_disable(Elm_List_Item *item, Eina_Bool disable)
1918 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1919 return elm_widget_item_tooltip_size_restrict_disable(item, disable);
1923 elm_list_item_tooltip_size_restrict_disabled_get(const Elm_List_Item *item)
1925 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1926 return elm_widget_item_tooltip_size_restrict_disabled_get(item);
1930 elm_list_item_tooltip_style_set(Elm_List_Item *item, const char *style)
1932 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1933 elm_widget_item_tooltip_style_set(item, style);
1937 elm_list_item_tooltip_style_get(const Elm_List_Item *item)
1939 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1940 return elm_widget_item_tooltip_style_get(item);
1944 elm_list_item_cursor_set(Elm_List_Item *item, const char *cursor)
1946 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1947 elm_widget_item_cursor_set(item, cursor);
1951 elm_list_item_cursor_get(const Elm_List_Item *item)
1953 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1954 return elm_widget_item_cursor_get(item);
1958 elm_list_item_cursor_unset(Elm_List_Item *item)
1960 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1961 elm_widget_item_cursor_unset(item);
1965 elm_list_item_cursor_style_set(Elm_List_Item *item, const char *style)
1967 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1968 elm_widget_item_cursor_style_set(item, style);
1972 elm_list_item_cursor_style_get(const Elm_List_Item *item)
1974 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1975 return elm_widget_item_cursor_style_get(item);
1979 elm_list_item_cursor_engine_only_set(Elm_List_Item *item, Eina_Bool engine_only)
1981 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1982 elm_widget_item_cursor_engine_only_set(item, engine_only);
1986 elm_list_item_cursor_engine_only_get(const Elm_List_Item *item)
1988 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1989 return elm_widget_item_cursor_engine_only_get(item);
1993 elm_list_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1995 ELM_CHECK_WIDTYPE(obj, widtype);
1996 Widget_Data *wd = elm_widget_data_get(obj);
1999 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2003 elm_list_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
2005 ELM_CHECK_WIDTYPE(obj, widtype);
2006 Widget_Data *wd = elm_widget_data_get(obj);
2008 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
2012 elm_list_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
2014 ELM_CHECK_WIDTYPE(obj, widtype);
2015 Widget_Data *wd = elm_widget_data_get(obj);
2017 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
2018 (policy_v >= ELM_SCROLLER_POLICY_LAST))
2020 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
2024 elm_list_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
2026 ELM_CHECK_WIDTYPE(obj, widtype);
2027 Widget_Data *wd = elm_widget_data_get(obj);
2028 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
2029 if ((!wd) || (!wd->scr)) return;
2030 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
2031 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
2032 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
2036 elm_list_item_disabled_set(Elm_List_Item *it, Eina_Bool disabled)
2038 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2040 if (it->disabled == disabled)
2043 it->disabled = !!disabled;
2046 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
2048 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
2052 elm_list_item_disabled_get(const Elm_List_Item *it)
2054 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2056 return it->disabled;