1 #include <Elementary.h>
3 #include "els_scroller.h"
7 typedef struct _Widget_Data Widget_Data;
11 Evas_Object *scr, *box, *self;
12 Eina_List *items, *selected, *to_delete;
13 Elm_List_Item *last_selected_item;
16 Evas_Coord minw[2], minh[2];
17 Eina_Bool scr_minw : 1;
18 Eina_Bool scr_minh : 1;
23 } history[SWIPE_MOVES];
25 Eina_Bool fix_pending : 1;
26 Eina_Bool on_hold : 1;
28 Eina_Bool always_select : 1;
29 Eina_Bool longpressed : 1;
30 Eina_Bool wasselected : 1;
39 Evas_Object *icon, *end;
41 Ecore_Timer *long_timer;
42 Ecore_Timer *swipe_timer;
43 Eina_Bool deleted : 1;
44 Eina_Bool disabled : 1;
46 Eina_Bool is_even : 1;
47 Eina_Bool is_separator : 1;
49 Eina_Bool selected : 1;
50 Eina_Bool highlighted : 1;
51 Eina_Bool dummy_icon : 1;
52 Eina_Bool dummy_end : 1;
55 static const char *widtype = NULL;
56 static void _del_hook(Evas_Object *obj);
57 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
58 static void _theme_hook(Evas_Object *obj);
59 static void _sizing_eval(Evas_Object *obj);
60 static void _disable_hook(Evas_Object *obj);
61 static void _on_focus_hook(void *data, Evas_Object *obj);
62 static void _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source);
63 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
64 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
65 static void _fix_items(Evas_Object *obj);
66 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
67 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
68 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
69 static void _scroll_edge_left(void *data, Evas_Object *scr, void *event_info);
70 static void _scroll_edge_right(void *data, Evas_Object *scr, void *event_info);
71 static void _scroll_edge_top(void *data, Evas_Object *scr, void *event_info);
72 static void _scroll_edge_bottom(void *data, Evas_Object *scr, void *event_info);
73 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
74 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
75 static Eina_Bool _item_single_select_up(Widget_Data *wd);
76 static Eina_Bool _item_single_select_down(Widget_Data *wd);
77 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
78 Evas_Callback_Type type, void *event_info);
79 static Eina_Bool _deselect_all_items(Widget_Data *wd);
81 static const char SIG_ACTIVATED[] = "activated";
82 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
83 static const char SIG_SELECTED[] = "selected";
84 static const char SIG_UNSELECTED[] = "unselected";
85 static const char SIG_LONGPRESSED[] = "longpressed";
86 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
87 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
88 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
89 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
91 static const Evas_Smart_Cb_Description _signals[] = {
93 {SIG_CLICKED_DOUBLE, ""},
96 {SIG_LONGPRESSED, ""},
97 {SIG_SCROLL_EDGE_TOP, ""},
98 {SIG_SCROLL_EDGE_BOTTOM, ""},
99 {SIG_SCROLL_EDGE_LEFT, ""},
100 {SIG_SCROLL_EDGE_RIGHT, ""},
104 #define ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ...) \
105 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, __VA_ARGS__); \
108 ERR("ERROR: "#it" has been DELETED.\n"); \
109 return __VA_ARGS__; \
113 _elm_list_item_free(Elm_List_Item *it)
115 evas_object_event_callback_del_full
116 (it->base.view, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
117 evas_object_event_callback_del_full
118 (it->base.view, EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
119 evas_object_event_callback_del_full
120 (it->base.view, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, it);
123 evas_object_event_callback_del_full
124 (it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
125 _changed_size_hints, it->base.widget);
128 evas_object_event_callback_del_full
129 (it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
130 _changed_size_hints, it->base.widget);
132 eina_stringshare_del(it->label);
134 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
135 if (it->long_timer) ecore_timer_del(it->long_timer);
136 if (it->icon) evas_object_del(it->icon);
137 if (it->end) evas_object_del(it->end);
139 elm_widget_item_del(it);
143 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
145 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
146 Evas_Event_Key_Down *ev = event_info;
147 Widget_Data *wd = elm_widget_data_get(obj);
148 if (!wd) return EINA_FALSE;
149 if (!wd->items) return EINA_FALSE;
150 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
151 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
153 Elm_List_Item *it = NULL;
156 Evas_Coord step_x = 0;
157 Evas_Coord step_y = 0;
160 Evas_Coord page_x = 0;
161 Evas_Coord page_y = 0;
163 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
164 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
165 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
166 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
168 /* TODO: fix logic for horizontal mode */
169 if ((!strcmp(ev->keyname, "Left")) ||
170 (!strcmp(ev->keyname, "KP_Left")))
173 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
174 (_item_multi_select_up(wd)))
175 || (_item_single_select_up(wd))))
177 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
183 else if ((!strcmp(ev->keyname, "Right")) ||
184 (!strcmp(ev->keyname, "KP_Right")))
187 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
188 (_item_multi_select_down(wd)))
189 || (_item_single_select_down(wd))))
191 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
197 else if ((!strcmp(ev->keyname, "Up")) ||
198 (!strcmp(ev->keyname, "KP_Up")))
201 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
202 (_item_multi_select_up(wd)))
203 || (_item_single_select_up(wd))))
205 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
211 else if ((!strcmp(ev->keyname, "Down")) ||
212 (!strcmp(ev->keyname, "KP_Down")))
215 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
216 (_item_multi_select_down(wd)))
217 || (_item_single_select_down(wd))))
219 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
225 else if ((!strcmp(ev->keyname, "Home")) ||
226 (!strcmp(ev->keyname, "KP_Home")))
228 it = eina_list_data_get(wd->items);
229 elm_list_item_bring_in(it);
230 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
233 else if ((!strcmp(ev->keyname, "End")) ||
234 (!strcmp(ev->keyname, "KP_End")))
236 it = eina_list_data_get(eina_list_last(wd->items));
237 elm_list_item_bring_in(it);
238 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
241 else if ((!strcmp(ev->keyname, "Prior")) ||
242 (!strcmp(ev->keyname, "KP_Prior")))
247 x -= -(page_x * v_w) / 100;
254 y -= -(page_y * v_h) / 100;
259 else if ((!strcmp(ev->keyname, "Next")) ||
260 (!strcmp(ev->keyname, "KP_Next")))
265 x += -(page_x * v_w) / 100;
272 y += -(page_y * v_h) / 100;
277 else if (((!strcmp(ev->keyname, "Return")) ||
278 (!strcmp(ev->keyname, "KP_Enter")) ||
279 (!strcmp(ev->keyname, "space")))
280 && (!wd->multi) && (wd->selected))
282 it = elm_list_selected_item_get(obj);
283 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
285 else if (!strcmp(ev->keyname, "Escape"))
287 if (!_deselect_all_items(wd)) return EINA_FALSE;
288 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
291 else return EINA_FALSE;
293 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
294 elm_smart_scroller_child_pos_set(wd->scr, x, y);
299 _deselect_all_items(Widget_Data *wd)
301 if (!wd->selected) return EINA_FALSE;
303 elm_list_item_selected_set(wd->selected->data, EINA_FALSE);
309 _item_multi_select_up(Widget_Data *wd)
311 if (!wd->selected) return EINA_FALSE;
312 if (!wd->multi) return EINA_FALSE;
314 Elm_List_Item *prev = elm_list_item_prev(wd->last_selected_item);
315 if (!prev) return EINA_TRUE;
317 if (elm_list_item_selected_get(prev))
319 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
320 wd->last_selected_item = prev;
321 elm_list_item_show(wd->last_selected_item);
325 elm_list_item_selected_set(prev, EINA_TRUE);
326 elm_list_item_show(prev);
332 _item_multi_select_down(Widget_Data *wd)
334 if (!wd->selected) return EINA_FALSE;
335 if (!wd->multi) return EINA_FALSE;
337 Elm_List_Item *next = elm_list_item_next(wd->last_selected_item);
338 if (!next) return EINA_TRUE;
340 if (elm_list_item_selected_get(next))
342 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
343 wd->last_selected_item = next;
344 elm_list_item_show(wd->last_selected_item);
348 elm_list_item_selected_set(next, EINA_TRUE);
349 elm_list_item_show(next);
355 _item_single_select_up(Widget_Data *wd)
359 if (!wd->selected) prev = eina_list_data_get(eina_list_last(wd->items));
360 else prev = elm_list_item_prev(wd->last_selected_item);
362 if (!prev) return EINA_FALSE;
364 _deselect_all_items(wd);
366 elm_list_item_selected_set(prev, EINA_TRUE);
367 elm_list_item_show(prev);
372 _item_single_select_down(Widget_Data *wd)
376 if (!wd->selected) next = eina_list_data_get(wd->items);
377 else next = elm_list_item_next(wd->last_selected_item);
379 if (!next) return EINA_FALSE;
381 _deselect_all_items(wd);
383 elm_list_item_selected_set(next, EINA_TRUE);
384 elm_list_item_show(next);
389 _elm_list_process_deletions(Widget_Data *wd)
393 wd->walking++; // avoid nested deletion and also _sub_del() fix_items
395 EINA_LIST_FREE(wd->to_delete, it)
397 elm_widget_item_pre_notify_del(it);
399 wd->items = eina_list_remove_list(wd->items, it->node);
400 _elm_list_item_free(it);
407 _elm_list_walk(Widget_Data *wd)
411 ERR("ERROR: walking was negative. fixed!\n");
418 _elm_list_unwalk(Widget_Data *wd)
423 ERR("ERROR: walking became negative. fixed!\n");
431 _elm_list_process_deletions(wd);
435 wd->fix_pending = EINA_FALSE;
436 _fix_items(wd->self);
437 _sizing_eval(wd->self);
442 _del_pre_hook(Evas_Object *obj)
444 Widget_Data *wd = elm_widget_data_get(obj);
447 evas_object_event_callback_del(wd->scr,
448 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
449 _changed_size_hints);
450 evas_object_event_callback_del(wd->box,
451 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
452 _changed_size_hints);
456 _del_hook(Evas_Object *obj)
458 Widget_Data *wd = elm_widget_data_get(obj);
464 ERR("ERROR: list deleted while walking.\n");
467 EINA_LIST_FOREACH(wd->items, n, it) elm_widget_item_pre_notify_del(it);
468 _elm_list_unwalk(wd);
470 ERR("ERROR: leaking nodes!\n");
472 EINA_LIST_FREE(wd->items, it) _elm_list_item_free(it);
473 eina_list_free(wd->selected);
478 _show_region_hook(void *data, Evas_Object *obj)
480 Widget_Data *wd = elm_widget_data_get(data);
481 Evas_Coord x, y, w, h;
483 elm_widget_show_region_get(obj, &x, &y, &w, &h);
484 elm_smart_scroller_child_region_set(wd->scr, x, y, w, h);
488 _disable_hook(Evas_Object *obj)
490 Widget_Data *wd = elm_widget_data_get(obj);
492 if (elm_widget_disabled_get(obj))
494 _signal_emit_hook(obj, "elm,state,disabled", "elm");
495 elm_widget_scroll_freeze_push(obj);
496 elm_widget_scroll_hold_push(obj);
497 /* FIXME: if we get to have a way to only un-highlight items
498 * in the future, keeping them selected... */
499 _deselect_all_items(wd);
503 _signal_emit_hook(obj, "elm,state,enabled", "elm");
504 elm_widget_scroll_freeze_pop(obj);
505 elm_widget_scroll_hold_pop(obj);
510 _sizing_eval(Evas_Object *obj)
513 Widget_Data *wd = elm_widget_data_get(obj);
515 Evas_Coord vw, vh, minw, minh, maxw, maxh, w, h, vmw, vmh;
518 evas_object_size_hint_min_get(wd->box, &minw, &minh);
519 evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
520 evas_object_size_hint_weight_get(wd->box, &xw, &yw);
521 if (!wd->scr) return;
522 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
525 if ((minw > 0) && (vw < minw)) vw = minw;
526 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
528 else if (minw > 0) vw = minw;
531 if ((minh > 0) && (vh < minh)) vh = minh;
532 else if ((maxh > 0) && (vh > maxh)) vh = maxh;
534 else if (minh > 0) vh = minh;
535 evas_object_resize(wd->box, vw, vh);
538 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
540 if (wd->scr_minw) w = vmw + minw;
541 if (wd->scr_minh) h = vmh + minh;
543 evas_object_size_hint_max_get(obj, &maxw, &maxh);
544 if ((maxw > 0) && (w > maxw))
546 if ((maxh > 0) && (h > maxh))
549 evas_object_size_hint_min_set(obj, w, h);
553 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
555 Widget_Data *wd = elm_widget_data_get(obj);
556 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
561 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
563 Widget_Data *wd = elm_widget_data_get(obj);
564 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
565 emission, source, func_cb, data);
569 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
571 Widget_Data *wd = elm_widget_data_get(obj);
572 edje_object_signal_callback_del_full(
573 elm_smart_scroller_edje_object_get(wd->scr),
574 emission, source, func_cb, data);
578 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
580 Widget_Data *wd = elm_widget_data_get(obj);
586 elm_smart_scroller_mirrored_set(wd->scr, rtl);
588 EINA_LIST_FOREACH(wd->items, n, it)
589 edje_object_mirrored_set(it->base.view, rtl);
593 _theme_hook(Evas_Object *obj)
595 Widget_Data *wd = elm_widget_data_get(obj);
600 _elm_widget_mirrored_reload(obj);
601 _mirrored_set(obj, elm_widget_mirrored_get(obj));
608 elm_smart_scroller_object_theme_set(obj, wd->scr, "list", "base",
609 elm_widget_style_get(obj));
610 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
611 edj = elm_smart_scroller_edje_object_get(wd->scr);
612 str = edje_object_data_get(edj, "focus_highlight");
613 if ((str) && (!strcmp(str, "on")))
614 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
616 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
617 elm_object_style_set(wd->scr, elm_widget_style_get(obj));
619 EINA_LIST_FOREACH(wd->items, n, it)
621 edje_object_scale_set(it->base.view, elm_widget_scale_get(obj) * _elm_config->scale);
629 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
631 Widget_Data *wd = elm_widget_data_get(obj);
633 if (elm_widget_focus_get(obj))
635 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
636 evas_object_focus_set(wd->self, EINA_TRUE);
638 if ((wd->selected) && (!wd->last_selected_item))
639 wd->last_selected_item = eina_list_data_get(wd->selected);
643 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
644 evas_object_focus_set(wd->self, EINA_FALSE);
649 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
651 Widget_Data *wd = elm_widget_data_get(data);
658 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
660 Widget_Data *wd = elm_widget_data_get(obj);
661 Evas_Object *sub = event_info;
667 if ((sub == wd->box) || (sub == wd->scr)) return;
669 EINA_LIST_FOREACH(wd->items, l, it)
671 if ((sub == it->icon) || (sub == it->end))
673 if (it->icon == sub) it->icon = NULL;
674 if (it->end == sub) it->end = NULL;
675 evas_object_event_callback_del_full
676 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints,
684 wd->fix_pending = EINA_TRUE;
691 _item_highlight(Elm_List_Item *it)
693 Evas_Object *obj = it->base.widget;
694 Widget_Data *wd = elm_widget_data_get(obj);
695 const char *selectraise;
698 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
699 if ((it->highlighted) || (it->disabled)) return;
701 evas_object_ref(obj);
704 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
705 selectraise = edje_object_data_get(it->base.view, "selectraise");
706 if ((selectraise) && (!strcmp(selectraise, "on")))
707 evas_object_raise(it->base.view);
708 it->highlighted = EINA_TRUE;
710 _elm_list_unwalk(wd);
711 evas_object_unref(obj);
715 _item_select(Elm_List_Item *it)
717 Evas_Object *obj = it->base.widget;
718 Widget_Data *wd = elm_widget_data_get(obj);
721 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
722 if (it->disabled) return;
725 if (wd->always_select) goto call;
728 it->selected = EINA_TRUE;
729 wd->selected = eina_list_append(wd->selected, it);
732 evas_object_ref(obj);
735 if (it->func) it->func((void *)it->base.data, it->base.widget, it);
736 evas_object_smart_callback_call(obj, SIG_SELECTED, it);
737 it->wd->last_selected_item = it;
739 _elm_list_unwalk(wd);
740 evas_object_unref(obj);
744 _item_unselect(Elm_List_Item *it)
746 Evas_Object *obj = it->base.widget;
747 Widget_Data *wd = elm_widget_data_get(obj);
748 const char *stacking, *selectraise;
751 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
752 if (!it->highlighted) return;
754 evas_object_ref(obj);
757 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
758 stacking = edje_object_data_get(it->base.view, "stacking");
759 selectraise = edje_object_data_get(it->base.view, "selectraise");
760 if ((selectraise) && (!strcmp(selectraise, "on")))
762 if ((stacking) && (!strcmp(stacking, "below")))
763 evas_object_lower(it->base.view);
765 it->highlighted = EINA_FALSE;
768 it->selected = EINA_FALSE;
769 wd->selected = eina_list_remove(wd->selected, it);
770 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
773 _elm_list_unwalk(wd);
774 evas_object_unref(obj);
778 _swipe_cancel(void *data)
780 Elm_List_Item *it = data;
781 Widget_Data *wd = elm_widget_data_get(it->base.widget);
783 if (!wd) return ECORE_CALLBACK_CANCEL;
784 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
785 wd->swipe = EINA_FALSE;
787 return ECORE_CALLBACK_RENEW;
791 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
793 Elm_List_Item *it = data;
794 Evas_Object *obj2 = it->base.widget;
795 Widget_Data *wd = elm_widget_data_get(obj2);
796 Evas_Event_Mouse_Move *ev = event_info;
799 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
801 evas_object_ref(obj2);
804 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
808 wd->on_hold = EINA_TRUE;
811 ecore_timer_del(it->long_timer);
812 it->long_timer = NULL;
814 if (!wd->wasselected)
817 if (wd->movements == SWIPE_MOVES) wd->swipe = EINA_TRUE;
820 wd->history[wd->movements].x = ev->cur.canvas.x;
821 wd->history[wd->movements].y = ev->cur.canvas.y;
822 if (abs((wd->history[wd->movements].x - wd->history[0].x)) > 40)
823 wd->swipe = EINA_TRUE;
829 _elm_list_unwalk(wd);
830 evas_object_unref(obj2);
834 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
836 Evas_Object *obj = data;
837 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
841 _scroll_edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
843 Evas_Object *obj = data;
844 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
848 _scroll_edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
850 Evas_Object *obj = data;
851 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
855 _scroll_edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
857 Evas_Object *obj = data;
858 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
862 _long_press(void *data)
864 Elm_List_Item *it = data;
865 Evas_Object *obj = it->base.widget;
866 Widget_Data *wd = elm_widget_data_get(obj);
870 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
871 it->long_timer = NULL;
872 if (it->disabled) goto end;
874 wd->longpressed = EINA_TRUE;
875 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
878 return ECORE_CALLBACK_CANCEL;
882 _swipe(Elm_List_Item *it)
885 Widget_Data *wd = elm_widget_data_get(it->base.widget);
887 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
889 wd->swipe = EINA_FALSE;
890 for (i = 0; i < wd->movements; i++)
892 sum += wd->history[i].x;
893 if (abs(wd->history[0].y - wd->history[i].y) > 10) return;
896 sum /= wd->movements;
897 if (abs(sum - wd->history[0].x) <= 10) return;
898 evas_object_smart_callback_call(it->base.widget, "swipe", it);
902 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
904 Elm_List_Item *it = data;
905 Evas_Object *obj2 = it->base.widget;
906 Widget_Data *wd = elm_widget_data_get(obj2);
907 Evas_Event_Mouse_Down *ev = event_info;
910 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
911 if (ev->button != 1) return;
912 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
913 else wd->on_hold = EINA_FALSE;
914 if (wd->on_hold) return;
915 wd->wasselected = it->selected;
917 evas_object_ref(obj2);
921 wd->longpressed = EINA_FALSE;
922 if (it->long_timer) ecore_timer_del(it->long_timer);
923 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, it);
924 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
925 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
926 /* Always call the callbacks last - the user may delete our context! */
927 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
929 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
930 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
932 wd->swipe = EINA_FALSE;
935 _elm_list_unwalk(wd);
936 evas_object_unref(obj2);
940 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
942 Elm_List_Item *it = data;
943 Evas_Object *obj2 = it->base.widget;
944 Widget_Data *wd = elm_widget_data_get(obj2);
945 Evas_Event_Mouse_Up *ev = event_info;
948 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
949 if (ev->button != 1) return;
950 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
951 else wd->on_hold = EINA_FALSE;
952 wd->longpressed = EINA_FALSE;
955 ecore_timer_del(it->long_timer);
956 it->long_timer = NULL;
960 ecore_timer_del(it->swipe_timer);
961 it->swipe_timer = NULL;
965 if (wd->swipe) _swipe(data);
966 wd->on_hold = EINA_FALSE;
971 if (!wd->wasselected) _item_unselect(it);
978 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
980 evas_object_ref(obj2);
990 else _item_unselect(it);
997 _item_unselect(wd->selected->data);
1003 const Eina_List *l, *l_next;
1006 EINA_LIST_FOREACH_SAFE(wd->selected, l, l_next, it2)
1007 if (it2 != it) _item_unselect(it2);
1008 _item_highlight(it);
1013 _elm_list_unwalk(wd);
1014 evas_object_unref(obj2);
1017 static Elm_List_Item *
1018 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1020 Widget_Data *wd = elm_widget_data_get(obj);
1023 if (!wd) return NULL;
1024 it = elm_widget_item_new(obj, Elm_List_Item);
1026 it->label = eina_stringshare_add(label);
1030 it->base.data = data;
1031 it->base.view = edje_object_add(evas_object_evas_get(obj));
1032 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(obj));
1033 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1035 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1037 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1039 evas_object_size_hint_weight_set(it->base.view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1040 evas_object_size_hint_align_set(it->base.view, EVAS_HINT_FILL, EVAS_HINT_FILL);
1043 elm_widget_sub_object_add(obj, it->icon);
1044 evas_object_event_callback_add(it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1045 _changed_size_hints, obj);
1049 elm_widget_sub_object_add(obj, it->end);
1050 evas_object_event_callback_add(it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1051 _changed_size_hints, obj);
1057 _elm_list_mode_set_internal(Widget_Data *wd)
1062 if (wd->mode == ELM_LIST_LIMIT)
1066 wd->scr_minw = EINA_TRUE;
1067 wd->scr_minh = EINA_FALSE;
1071 wd->scr_minw = EINA_FALSE;
1072 wd->scr_minh = EINA_TRUE;
1075 else if (wd->mode == ELM_LIST_EXPAND)
1077 wd->scr_minw = EINA_TRUE;
1078 wd->scr_minh = EINA_TRUE;
1082 wd->scr_minw = EINA_FALSE;
1083 wd->scr_minh = EINA_FALSE;
1086 _sizing_eval(wd->self);
1090 _fix_items(Evas_Object *obj)
1092 Widget_Data *wd = elm_widget_data_get(obj);
1096 Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
1099 const char *style = elm_widget_style_get(obj);
1100 const char *it_plain = wd->h_mode ? "h_item" : "item";
1101 const char *it_odd = wd->h_mode ? "h_item_odd" : "item_odd";
1102 const char *it_compress = wd->h_mode ? "h_item_compress" : "item_compress";
1103 const char *it_compress_odd = wd->h_mode ? "h_item_compress_odd" : "item_compress_odd";
1107 wd->fix_pending = EINA_TRUE;
1111 evas_object_ref(obj);
1112 _elm_list_walk(wd); // watch out "return" before unwalk!
1114 EINA_LIST_FOREACH(wd->items, l, it)
1116 if (it->deleted) continue;
1119 evas_object_size_hint_min_get(it->icon, &mw, &mh);
1120 if (mw > minw[0]) minw[0] = mw;
1121 if (mh > minh[0]) minh[0] = mh;
1125 evas_object_size_hint_min_get(it->end, &mw, &mh);
1126 if (mw > minw[1]) minw[1] = mw;
1127 if (mh > minh[1]) minh[1] = mh;
1131 if ((minw[0] != wd->minw[0]) || (minw[1] != wd->minw[1]) ||
1132 (minw[0] != wd->minh[0]) || (minh[1] != wd->minh[1]))
1134 wd->minw[0] = minw[0];
1135 wd->minw[1] = minw[1];
1136 wd->minh[0] = minh[0];
1137 wd->minh[1] = minh[1];
1141 EINA_LIST_FOREACH(wd->items, l, it)
1147 if ((it->even != it->is_even) || (!it->fixed) || (redo))
1149 const char *stacking;
1151 /* FIXME: separators' themes seem to be b0rked */
1152 if (it->is_separator)
1153 _elm_theme_object_set(obj, it->base.view, "separator",
1154 wd->h_mode ? "horizontal" : "vertical",
1156 else if (wd->mode == ELM_LIST_COMPRESS)
1159 _elm_theme_object_set(obj, it->base.view, "list",
1160 it_compress, style);
1162 _elm_theme_object_set(obj, it->base.view, "list",
1163 it_compress_odd, style);
1168 _elm_theme_object_set(obj, it->base.view, "list", it_plain,
1171 _elm_theme_object_set(obj, it->base.view, "list", it_odd,
1174 stacking = edje_object_data_get(it->base.view, "stacking");
1177 if (!strcmp(stacking, "below"))
1178 evas_object_lower(it->base.view);
1179 else if (!strcmp(stacking, "above"))
1180 evas_object_raise(it->base.view);
1182 edje_object_part_text_set(it->base.view, "elm.text", it->label);
1184 if ((!it->icon) && (minh[0] > 0))
1186 it->icon = evas_object_rectangle_add(evas_object_evas_get(it->base.view));
1187 evas_object_color_set(it->icon, 0, 0, 0, 0);
1188 it->dummy_icon = EINA_TRUE;
1190 if ((!it->end) && (minh[1] > 0))
1192 it->end = evas_object_rectangle_add(evas_object_evas_get(it->base.view));
1193 evas_object_color_set(it->end, 0, 0, 0, 0);
1194 it->dummy_end = EINA_TRUE;
1198 evas_object_size_hint_min_set(it->icon, minw[0], minh[0]);
1199 evas_object_size_hint_max_set(it->icon, 99999, 99999);
1200 edje_object_part_swallow(it->base.view, "elm.swallow.icon", it->icon);
1204 evas_object_size_hint_min_set(it->end, minw[1], minh[1]);
1205 evas_object_size_hint_max_set(it->end, 99999, 99999);
1206 edje_object_part_swallow(it->base.view, "elm.swallow.end", it->end);
1210 // this may call up user and it may modify the list item
1211 // but we're safe as we're flagged as walking.
1212 // just don't process further
1213 edje_object_message_signal_process(it->base.view);
1217 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1218 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
1219 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1220 evas_object_size_hint_min_set(it->base.view, mw, mh);
1221 evas_object_show(it->base.view);
1223 if ((it->selected) || (it->highlighted))
1225 const char *selectraise;
1227 // this may call up user and it may modify the list item
1228 // but we're safe as we're flagged as walking.
1229 // just don't process further
1230 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
1234 selectraise = edje_object_data_get(it->base.view, "selectraise");
1235 if ((selectraise) && (!strcmp(selectraise, "on")))
1236 evas_object_raise(it->base.view);
1239 edje_object_signal_emit(it->base.view, "elm,state,disabled",
1242 it->fixed = EINA_TRUE;
1243 it->is_even = it->even;
1249 evas_object_size_hint_min_get(wd->box, &mw, &mh);
1251 _elm_list_mode_set_internal(wd);
1253 _elm_list_unwalk(wd);
1254 evas_object_unref(obj);
1258 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1260 Widget_Data *wd = elm_widget_data_get(obj);
1263 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
1267 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1269 Widget_Data *wd = elm_widget_data_get(obj);
1272 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1276 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1278 Widget_Data *wd = elm_widget_data_get(obj);
1281 elm_smart_scroller_freeze_set(wd->scr, EINA_TRUE);
1285 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1287 Widget_Data *wd = elm_widget_data_get(obj);
1290 elm_smart_scroller_freeze_set(wd->scr, EINA_FALSE);
1294 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1300 elm_list_add(Evas_Object *parent)
1305 Evas_Coord minw, minh;
1307 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1309 ELM_SET_WIDTYPE(widtype, "list");
1310 elm_widget_type_set(obj, "list");
1311 elm_widget_sub_object_add(parent, obj);
1312 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1313 elm_widget_data_set(obj, wd);
1314 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1315 elm_widget_del_hook_set(obj, _del_hook);
1316 elm_widget_theme_hook_set(obj, _theme_hook);
1317 elm_widget_disable_hook_set(obj, _disable_hook);
1318 elm_widget_can_focus_set(obj, EINA_TRUE);
1319 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1320 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1321 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1322 elm_widget_event_hook_set(obj, _event_hook);
1325 wd->scr = elm_smart_scroller_add(e);
1326 elm_smart_scroller_widget_set(wd->scr, obj);
1327 elm_widget_resize_object_set(obj, wd->scr);
1328 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1329 _changed_size_hints, obj);
1330 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
1331 evas_object_size_hint_min_set(obj, minw, minh);
1332 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1334 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
1335 _elm_config->thumbscroll_bounce_enable);
1337 wd->box = elm_box_add(parent);
1338 elm_box_homogeneous_set(wd->box, 1);
1339 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1340 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1341 elm_widget_on_show_region_hook_set(wd->box, _show_region_hook, obj);
1342 elm_widget_sub_object_add(obj, wd->box);
1343 elm_smart_scroller_child_set(wd->scr, wd->box);
1344 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1345 _changed_size_hints, obj);
1347 evas_object_show(wd->box);
1351 wd->mode = ELM_LIST_SCROLL;
1353 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
1354 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right, obj);
1355 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
1356 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom, obj);
1358 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1359 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1360 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1361 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1362 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1364 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1366 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1371 EAPI Elm_List_Item *
1372 elm_list_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1374 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1375 Widget_Data *wd = elm_widget_data_get(obj);
1376 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1378 wd->items = eina_list_append(wd->items, it);
1379 it->node = eina_list_last(wd->items);
1380 elm_box_pack_end(wd->box, it->base.view);
1384 EAPI Elm_List_Item *
1385 elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1387 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1388 Widget_Data *wd = elm_widget_data_get(obj);
1389 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1391 wd->items = eina_list_prepend(wd->items, it);
1392 it->node = wd->items;
1393 elm_box_pack_start(wd->box, it->base.view);
1397 EAPI Elm_List_Item *
1398 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)
1403 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
1404 if (!before->node) return NULL;
1405 ELM_LIST_ITEM_CHECK_DELETED_RETURN(before, NULL);
1407 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1408 wd = elm_widget_data_get(obj);
1409 if (!wd) return NULL;
1410 it = _item_new(obj, label, icon, end, func, data);
1411 wd->items = eina_list_prepend_relative_list(wd->items, it, before->node);
1412 it->node = before->node->prev;
1413 elm_box_pack_before(wd->box, it->base.view, before->base.view);
1417 EAPI Elm_List_Item *
1418 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)
1423 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
1424 if (!after->node) return NULL;
1425 ELM_LIST_ITEM_CHECK_DELETED_RETURN(after, NULL);
1427 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1428 wd = elm_widget_data_get(obj);
1429 if (!wd) return NULL;
1430 it = _item_new(obj, label, icon, end, func, data);
1431 wd->items = eina_list_append_relative_list(wd->items, it, after->node);
1432 it->node = after->node->next;
1433 elm_box_pack_after(wd->box, it->base.view, after->base.view);
1437 EAPI Elm_List_Item *
1438 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)
1440 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1441 Widget_Data *wd = elm_widget_data_get(obj);
1442 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1445 wd->items = eina_list_sorted_insert(wd->items, cmp_func, it);
1446 l = eina_list_data_find_list(wd->items, it);
1447 l = eina_list_next(l);
1450 it->node = eina_list_last(wd->items);
1451 elm_box_pack_end(wd->box, it->base.view);
1455 Elm_List_Item *before = eina_list_data_get(l);
1456 it->node = before->node->prev;
1457 elm_box_pack_before(wd->box, it->base.view, before->base.view);
1463 elm_list_clear(Evas_Object *obj)
1465 ELM_CHECK_WIDTYPE(obj, widtype);
1466 Widget_Data *wd = elm_widget_data_get(obj);
1470 if (!wd->items) return;
1472 eina_list_free(wd->selected);
1473 wd->selected = NULL;
1475 if (wd->walking > 0)
1479 EINA_LIST_FOREACH(wd->items, n, it)
1481 if (it->deleted) continue;
1482 it->deleted = EINA_TRUE;
1483 wd->to_delete = eina_list_append(wd->to_delete, it);
1488 evas_object_ref(obj);
1491 EINA_LIST_FREE(wd->items, it)
1493 elm_widget_item_pre_notify_del(it);
1494 _elm_list_item_free(it);
1497 _elm_list_unwalk(wd);
1501 evas_object_unref(obj);
1505 elm_list_go(Evas_Object *obj)
1507 ELM_CHECK_WIDTYPE(obj, widtype);
1508 Widget_Data *wd = elm_widget_data_get(obj);
1514 elm_list_multi_select_set(Evas_Object *obj, Eina_Bool multi)
1516 ELM_CHECK_WIDTYPE(obj, widtype);
1517 Widget_Data *wd = elm_widget_data_get(obj);
1523 elm_list_multi_select_get(const Evas_Object *obj)
1525 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1526 Widget_Data *wd = elm_widget_data_get(obj);
1527 if (!wd) return EINA_FALSE;
1532 elm_list_mode_set(Evas_Object *obj, Elm_List_Mode mode)
1534 ELM_CHECK_WIDTYPE(obj, widtype);
1538 wd = elm_widget_data_get(obj);
1541 if (wd->mode == mode)
1545 _elm_list_mode_set_internal(wd);
1549 elm_list_mode_get(const Evas_Object *obj)
1551 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
1552 Widget_Data *wd = elm_widget_data_get(obj);
1553 if (!wd) return ELM_LIST_LAST;
1558 elm_list_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1560 ELM_CHECK_WIDTYPE(obj, widtype);
1563 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1565 wd = elm_widget_data_get(obj);
1569 if (wd->h_mode == horizontal)
1572 wd->h_mode = horizontal;
1573 elm_box_horizontal_set(wd->box, horizontal);
1577 evas_object_size_hint_weight_set(wd->box, 0.0, EVAS_HINT_EXPAND);
1578 evas_object_size_hint_align_set(wd->box, 0.0, EVAS_HINT_FILL);
1579 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1583 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1584 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1585 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, bounce);
1588 _elm_list_mode_set_internal(wd);
1592 elm_list_horizontal_get(const Evas_Object *obj)
1594 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1598 wd = elm_widget_data_get(obj);
1606 elm_list_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
1608 ELM_CHECK_WIDTYPE(obj, widtype);
1609 Widget_Data *wd = elm_widget_data_get(obj);
1611 wd->always_select = always_select;
1615 elm_list_always_select_mode_get(const Evas_Object *obj)
1617 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1618 Widget_Data *wd = elm_widget_data_get(obj);
1619 if (!wd) return EINA_FALSE;
1620 return wd->always_select;
1623 EAPI const Eina_List *
1624 elm_list_items_get(const Evas_Object *obj)
1626 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1627 Widget_Data *wd = elm_widget_data_get(obj);
1628 if (!wd) return NULL;
1632 EAPI Elm_List_Item *
1633 elm_list_selected_item_get(const Evas_Object *obj)
1635 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1636 Widget_Data *wd = elm_widget_data_get(obj);
1637 if (!wd) return NULL;
1638 if (wd->selected) return wd->selected->data;
1642 EAPI const Eina_List *
1643 elm_list_selected_items_get(const Evas_Object *obj)
1645 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1646 Widget_Data *wd = elm_widget_data_get(obj);
1647 if (!wd) return NULL;
1648 return wd->selected;
1652 elm_list_item_separator_set(Elm_List_Item *it, Eina_Bool setting)
1654 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1655 it->is_separator = !!setting;
1659 elm_list_item_separator_get(const Elm_List_Item *it)
1661 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1662 return it->is_separator;
1667 elm_list_item_selected_set(Elm_List_Item *it, Eina_Bool selected)
1669 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1670 Evas_Object *obj = it->base.widget;
1671 Widget_Data *wd = elm_widget_data_get(obj);
1674 selected = !!selected;
1675 if (it->selected == selected) return;
1677 evas_object_ref(obj);
1684 while (wd->selected)
1685 _item_unselect(wd->selected->data);
1687 _item_highlight(it);
1693 _elm_list_unwalk(wd);
1694 evas_object_unref(obj);
1698 elm_list_item_selected_get(const Elm_List_Item *it)
1700 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1701 return it->selected;
1705 elm_list_item_show(Elm_List_Item *it)
1707 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1708 Widget_Data *wd = elm_widget_data_get(it->base.widget);
1709 Evas_Coord bx, by, bw, bh;
1710 Evas_Coord x, y, w, h;
1712 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1713 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
1717 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
1721 elm_list_item_bring_in(Elm_List_Item *it)
1723 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1724 Widget_Data *wd = elm_widget_data_get(it->base.widget);
1725 Evas_Coord bx, by, bw, bh;
1726 Evas_Coord x, y, w, h;
1728 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1729 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
1733 elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
1737 elm_list_item_del(Elm_List_Item *it)
1739 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1740 Evas_Object *obj = it->base.widget;
1741 Widget_Data *wd = elm_widget_data_get(obj);
1744 if (it->selected) _item_unselect(it);
1746 if (wd->walking > 0)
1748 if (it->deleted) return;
1749 it->deleted = EINA_TRUE;
1750 wd->to_delete = eina_list_append(wd->to_delete, it);
1754 wd->items = eina_list_remove_list(wd->items, it->node);
1756 evas_object_ref(obj);
1759 elm_widget_item_pre_notify_del(it);
1760 _elm_list_item_free(it);
1762 _elm_list_unwalk(wd);
1763 evas_object_unref(obj);
1767 elm_list_item_del_cb_set(Elm_List_Item *it, Evas_Smart_Cb func)
1769 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1770 elm_widget_item_del_cb_set(it, func);
1774 elm_list_item_data_get(const Elm_List_Item *it)
1776 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1777 return elm_widget_item_data_get(it);
1781 elm_list_item_icon_get(const Elm_List_Item *it)
1783 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1784 if (it->dummy_icon) return NULL;
1789 elm_list_item_icon_set(Elm_List_Item *it, Evas_Object *icon)
1791 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1792 if (it->icon == icon) return;
1793 if ((it->dummy_icon) && (!icon)) return;
1796 evas_object_del(it->icon);
1797 it->dummy_icon = EINA_FALSE;
1801 icon = evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1802 evas_object_color_set(icon, 0, 0, 0, 0);
1803 it->dummy_icon = EINA_TRUE;
1807 evas_object_del(it->icon);
1812 edje_object_part_swallow(it->base.view, "elm.swallow.icon", icon);
1816 elm_list_item_end_get(const Elm_List_Item *it)
1818 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1819 if (it->dummy_end) return NULL;
1824 elm_list_item_end_set(Elm_List_Item *it, Evas_Object *end)
1826 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1827 if (it->end == end) return;
1828 if ((it->dummy_end) && (!end)) return;
1831 evas_object_del(it->end);
1832 it->dummy_icon = EINA_FALSE;
1836 end = evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1837 evas_object_color_set(end, 0, 0, 0, 0);
1838 it->dummy_end = EINA_TRUE;
1842 evas_object_del(it->end);
1847 edje_object_part_swallow(it->base.view, "elm.swallow.end", end);
1851 elm_list_item_base_get(const Elm_List_Item *it)
1853 return elm_list_item_object_get(it);
1857 elm_list_item_object_get(const Elm_List_Item *it)
1859 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1860 return it->base.view;
1864 elm_list_item_label_get(const Elm_List_Item *it)
1866 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1871 elm_list_item_label_set(Elm_List_Item *it, const char *text)
1873 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1874 if (!eina_stringshare_replace(&it->label, text)) return;
1876 edje_object_part_text_set(it->base.view, "elm.text", it->label);
1879 EAPI Elm_List_Item *
1880 elm_list_item_prev(const Elm_List_Item *it)
1882 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1883 if (it->node->prev) return it->node->prev->data;
1887 EAPI Elm_List_Item *
1888 elm_list_item_next(const Elm_List_Item *it)
1890 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1891 if (it->node->next) return it->node->next->data;
1896 elm_list_item_tooltip_text_set(Elm_List_Item *item, const char *text)
1898 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1899 elm_widget_item_tooltip_text_set(item, text);
1903 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)
1905 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1906 elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
1910 elm_list_item_tooltip_unset(Elm_List_Item *item)
1912 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1913 elm_widget_item_tooltip_unset(item);
1917 elm_list_item_tooltip_size_restrict_disable(Elm_List_Item *item, Eina_Bool disable)
1919 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1920 return elm_widget_item_tooltip_size_restrict_disable(item, disable);
1924 elm_list_item_tooltip_size_restrict_disabled_get(const Elm_List_Item *item)
1926 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1927 return elm_widget_item_tooltip_size_restrict_disabled_get(item);
1931 elm_list_item_tooltip_style_set(Elm_List_Item *item, const char *style)
1933 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1934 elm_widget_item_tooltip_style_set(item, style);
1938 elm_list_item_tooltip_style_get(const Elm_List_Item *item)
1940 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1941 return elm_widget_item_tooltip_style_get(item);
1945 elm_list_item_cursor_set(Elm_List_Item *item, const char *cursor)
1947 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1948 elm_widget_item_cursor_set(item, cursor);
1952 elm_list_item_cursor_get(const Elm_List_Item *item)
1954 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1955 return elm_widget_item_cursor_get(item);
1959 elm_list_item_cursor_unset(Elm_List_Item *item)
1961 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1962 elm_widget_item_cursor_unset(item);
1966 elm_list_item_cursor_style_set(Elm_List_Item *item, const char *style)
1968 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1969 elm_widget_item_cursor_style_set(item, style);
1973 elm_list_item_cursor_style_get(const Elm_List_Item *item)
1975 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1976 return elm_widget_item_cursor_style_get(item);
1980 elm_list_item_cursor_engine_only_set(Elm_List_Item *item, Eina_Bool engine_only)
1982 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1983 elm_widget_item_cursor_engine_only_set(item, engine_only);
1987 elm_list_item_cursor_engine_only_get(const Elm_List_Item *item)
1989 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1990 return elm_widget_item_cursor_engine_only_get(item);
1994 elm_list_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1996 ELM_CHECK_WIDTYPE(obj, widtype);
1997 Widget_Data *wd = elm_widget_data_get(obj);
2000 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2004 elm_list_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
2006 ELM_CHECK_WIDTYPE(obj, widtype);
2007 Widget_Data *wd = elm_widget_data_get(obj);
2009 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
2013 elm_list_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
2015 ELM_CHECK_WIDTYPE(obj, widtype);
2016 Widget_Data *wd = elm_widget_data_get(obj);
2017 if ((!wd) || (!wd->scr)) return;
2018 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
2019 (policy_v >= ELM_SCROLLER_POLICY_LAST))
2021 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
2025 elm_list_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
2027 ELM_CHECK_WIDTYPE(obj, widtype);
2028 Widget_Data *wd = elm_widget_data_get(obj);
2029 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
2030 if ((!wd) || (!wd->scr)) return;
2031 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
2032 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
2033 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
2037 elm_list_item_disabled_set(Elm_List_Item *it, Eina_Bool disabled)
2039 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2041 if (it->disabled == disabled)
2044 it->disabled = !!disabled;
2047 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
2049 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
2053 elm_list_item_disabled_get(const Elm_List_Item *it)
2055 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2057 return it->disabled;