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) 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);
723 if (wd->always_select) goto call;
726 it->selected = EINA_TRUE;
727 wd->selected = eina_list_append(wd->selected, it);
730 evas_object_ref(obj);
733 if (it->func) it->func((void *)it->base.data, it->base.widget, it);
734 evas_object_smart_callback_call(obj, SIG_SELECTED, it);
735 it->wd->last_selected_item = it;
737 _elm_list_unwalk(wd);
738 evas_object_unref(obj);
742 _item_unselect(Elm_List_Item *it)
744 Evas_Object *obj = it->base.widget;
745 Widget_Data *wd = elm_widget_data_get(obj);
746 const char *stacking, *selectraise;
749 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
750 if (!it->highlighted) return;
752 evas_object_ref(obj);
755 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
756 stacking = edje_object_data_get(it->base.view, "stacking");
757 selectraise = edje_object_data_get(it->base.view, "selectraise");
758 if ((selectraise) && (!strcmp(selectraise, "on")))
760 if ((stacking) && (!strcmp(stacking, "below")))
761 evas_object_lower(it->base.view);
763 it->highlighted = EINA_FALSE;
766 it->selected = EINA_FALSE;
767 wd->selected = eina_list_remove(wd->selected, it);
768 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
771 _elm_list_unwalk(wd);
772 evas_object_unref(obj);
776 _swipe_cancel(void *data)
778 Elm_List_Item *it = data;
779 Widget_Data *wd = elm_widget_data_get(it->base.widget);
781 if (!wd) return ECORE_CALLBACK_CANCEL;
782 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
783 wd->swipe = EINA_FALSE;
785 return ECORE_CALLBACK_RENEW;
789 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
791 Elm_List_Item *it = data;
792 Evas_Object *obj2 = it->base.widget;
793 Widget_Data *wd = elm_widget_data_get(obj2);
794 Evas_Event_Mouse_Move *ev = event_info;
797 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
799 evas_object_ref(obj2);
802 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
806 wd->on_hold = EINA_TRUE;
809 ecore_timer_del(it->long_timer);
810 it->long_timer = NULL;
812 if (!wd->wasselected)
815 if (wd->movements == SWIPE_MOVES) wd->swipe = EINA_TRUE;
818 wd->history[wd->movements].x = ev->cur.canvas.x;
819 wd->history[wd->movements].y = ev->cur.canvas.y;
820 if (abs((wd->history[wd->movements].x - wd->history[0].x)) > 40)
821 wd->swipe = EINA_TRUE;
827 _elm_list_unwalk(wd);
828 evas_object_unref(obj2);
832 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
834 Evas_Object *obj = data;
835 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
839 _scroll_edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
841 Evas_Object *obj = data;
842 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
846 _scroll_edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
848 Evas_Object *obj = data;
849 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
853 _scroll_edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
855 Evas_Object *obj = data;
856 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
860 _long_press(void *data)
862 Elm_List_Item *it = data;
863 Evas_Object *obj = it->base.widget;
864 Widget_Data *wd = elm_widget_data_get(obj);
868 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
869 it->long_timer = NULL;
870 if (it->disabled) goto end;
872 wd->longpressed = EINA_TRUE;
873 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
876 return ECORE_CALLBACK_CANCEL;
880 _swipe(Elm_List_Item *it)
883 Widget_Data *wd = elm_widget_data_get(it->base.widget);
885 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
887 wd->swipe = EINA_FALSE;
888 for (i = 0; i < wd->movements; i++)
890 sum += wd->history[i].x;
891 if (abs(wd->history[0].y - wd->history[i].y) > 10) return;
894 sum /= wd->movements;
895 if (abs(sum - wd->history[0].x) <= 10) return;
896 evas_object_smart_callback_call(it->base.widget, "swipe", it);
900 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
902 Elm_List_Item *it = data;
903 Evas_Object *obj2 = it->base.widget;
904 Widget_Data *wd = elm_widget_data_get(obj2);
905 Evas_Event_Mouse_Down *ev = event_info;
908 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
909 if (ev->button != 1) return;
910 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
911 else wd->on_hold = EINA_FALSE;
912 if (wd->on_hold) return;
913 wd->wasselected = it->selected;
915 evas_object_ref(obj2);
919 wd->longpressed = EINA_FALSE;
920 if (it->long_timer) ecore_timer_del(it->long_timer);
921 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, it);
922 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
923 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
924 /* Always call the callbacks last - the user may delete our context! */
925 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
927 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
928 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
930 wd->swipe = EINA_FALSE;
933 _elm_list_unwalk(wd);
934 evas_object_unref(obj2);
938 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
940 Elm_List_Item *it = data;
941 Evas_Object *obj2 = it->base.widget;
942 Widget_Data *wd = elm_widget_data_get(obj2);
943 Evas_Event_Mouse_Up *ev = event_info;
946 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
947 if (ev->button != 1) return;
948 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
949 else wd->on_hold = EINA_FALSE;
950 wd->longpressed = EINA_FALSE;
953 ecore_timer_del(it->long_timer);
954 it->long_timer = NULL;
958 ecore_timer_del(it->swipe_timer);
959 it->swipe_timer = NULL;
963 if (wd->swipe) _swipe(data);
964 wd->on_hold = EINA_FALSE;
969 if (!wd->wasselected) _item_unselect(it);
976 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
978 evas_object_ref(obj2);
988 else _item_unselect(it);
995 _item_unselect(wd->selected->data);
1001 const Eina_List *l, *l_next;
1004 EINA_LIST_FOREACH_SAFE(wd->selected, l, l_next, it2)
1005 if (it2 != it) _item_unselect(it2);
1006 _item_highlight(it);
1011 _elm_list_unwalk(wd);
1012 evas_object_unref(obj2);
1015 static Elm_List_Item *
1016 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1018 Widget_Data *wd = elm_widget_data_get(obj);
1021 if (!wd) return NULL;
1022 it = elm_widget_item_new(obj, Elm_List_Item);
1024 it->label = eina_stringshare_add(label);
1028 it->base.data = data;
1029 it->base.view = edje_object_add(evas_object_evas_get(obj));
1030 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(obj));
1031 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1033 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1035 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1037 evas_object_size_hint_weight_set(it->base.view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1038 evas_object_size_hint_align_set(it->base.view, EVAS_HINT_FILL, EVAS_HINT_FILL);
1041 elm_widget_sub_object_add(obj, it->icon);
1042 evas_object_event_callback_add(it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1043 _changed_size_hints, obj);
1047 elm_widget_sub_object_add(obj, it->end);
1048 evas_object_event_callback_add(it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1049 _changed_size_hints, obj);
1055 _elm_list_mode_set_internal(Widget_Data *wd)
1060 if (wd->mode == ELM_LIST_LIMIT)
1064 wd->scr_minw = EINA_TRUE;
1065 wd->scr_minh = EINA_FALSE;
1069 wd->scr_minw = EINA_FALSE;
1070 wd->scr_minh = EINA_TRUE;
1073 else if (wd->mode == ELM_LIST_EXPAND)
1075 wd->scr_minw = EINA_TRUE;
1076 wd->scr_minh = EINA_TRUE;
1080 wd->scr_minw = EINA_FALSE;
1081 wd->scr_minh = EINA_FALSE;
1084 _sizing_eval(wd->self);
1088 _fix_items(Evas_Object *obj)
1090 Widget_Data *wd = elm_widget_data_get(obj);
1094 Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
1097 const char *style = elm_widget_style_get(obj);
1098 const char *it_plain = wd->h_mode ? "h_item" : "item";
1099 const char *it_odd = wd->h_mode ? "h_item_odd" : "item_odd";
1100 const char *it_compress = wd->h_mode ? "h_item_compress" : "item_compress";
1101 const char *it_compress_odd = wd->h_mode ? "h_item_compress_odd" : "item_compress_odd";
1105 wd->fix_pending = EINA_TRUE;
1109 evas_object_ref(obj);
1110 _elm_list_walk(wd); // watch out "return" before unwalk!
1112 EINA_LIST_FOREACH(wd->items, l, it)
1114 if (it->deleted) continue;
1117 evas_object_size_hint_min_get(it->icon, &mw, &mh);
1118 if (mw > minw[0]) minw[0] = mw;
1119 if (mh > minh[0]) minh[0] = mh;
1123 evas_object_size_hint_min_get(it->end, &mw, &mh);
1124 if (mw > minw[1]) minw[1] = mw;
1125 if (mh > minh[1]) minh[1] = mh;
1129 if ((minw[0] != wd->minw[0]) || (minw[1] != wd->minw[1]) ||
1130 (minw[0] != wd->minh[0]) || (minh[1] != wd->minh[1]))
1132 wd->minw[0] = minw[0];
1133 wd->minw[1] = minw[1];
1134 wd->minh[0] = minh[0];
1135 wd->minh[1] = minh[1];
1139 EINA_LIST_FOREACH(wd->items, l, it)
1145 if ((it->even != it->is_even) || (!it->fixed) || (redo))
1147 const char *stacking;
1149 /* FIXME: separators' themes seem to be b0rked */
1150 if (it->is_separator)
1151 _elm_theme_object_set(obj, it->base.view, "separator",
1152 wd->h_mode ? "horizontal" : "vertical",
1154 else if (wd->mode == ELM_LIST_COMPRESS)
1157 _elm_theme_object_set(obj, it->base.view, "list",
1158 it_compress, style);
1160 _elm_theme_object_set(obj, it->base.view, "list",
1161 it_compress_odd, style);
1166 _elm_theme_object_set(obj, it->base.view, "list", it_plain,
1169 _elm_theme_object_set(obj, it->base.view, "list", it_odd,
1172 stacking = edje_object_data_get(it->base.view, "stacking");
1175 if (!strcmp(stacking, "below"))
1176 evas_object_lower(it->base.view);
1177 else if (!strcmp(stacking, "above"))
1178 evas_object_raise(it->base.view);
1180 edje_object_part_text_set(it->base.view, "elm.text", it->label);
1182 if ((!it->icon) && (minh[0] > 0))
1184 it->icon = evas_object_rectangle_add(evas_object_evas_get(it->base.view));
1185 evas_object_color_set(it->icon, 0, 0, 0, 0);
1186 it->dummy_icon = EINA_TRUE;
1188 if ((!it->end) && (minh[1] > 0))
1190 it->end = evas_object_rectangle_add(evas_object_evas_get(it->base.view));
1191 evas_object_color_set(it->end, 0, 0, 0, 0);
1192 it->dummy_end = EINA_TRUE;
1196 evas_object_size_hint_min_set(it->icon, minw[0], minh[0]);
1197 evas_object_size_hint_max_set(it->icon, 99999, 99999);
1198 edje_object_part_swallow(it->base.view, "elm.swallow.icon", it->icon);
1202 evas_object_size_hint_min_set(it->end, minw[1], minh[1]);
1203 evas_object_size_hint_max_set(it->end, 99999, 99999);
1204 edje_object_part_swallow(it->base.view, "elm.swallow.end", it->end);
1208 // this may call up user and it may modify the list item
1209 // but we're safe as we're flagged as walking.
1210 // just don't process further
1211 edje_object_message_signal_process(it->base.view);
1215 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1216 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
1217 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1218 evas_object_size_hint_min_set(it->base.view, mw, mh);
1219 evas_object_show(it->base.view);
1221 if ((it->selected) || (it->highlighted))
1223 const char *selectraise;
1225 // this may call up user and it may modify the list item
1226 // but we're safe as we're flagged as walking.
1227 // just don't process further
1228 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
1232 selectraise = edje_object_data_get(it->base.view, "selectraise");
1233 if ((selectraise) && (!strcmp(selectraise, "on")))
1234 evas_object_raise(it->base.view);
1237 edje_object_signal_emit(it->base.view, "elm,state,disabled",
1240 it->fixed = EINA_TRUE;
1241 it->is_even = it->even;
1247 evas_object_size_hint_min_get(wd->box, &mw, &mh);
1249 _elm_list_mode_set_internal(wd);
1251 _elm_list_unwalk(wd);
1252 evas_object_unref(obj);
1256 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1258 Widget_Data *wd = elm_widget_data_get(obj);
1261 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
1265 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1267 Widget_Data *wd = elm_widget_data_get(obj);
1270 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1274 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1276 Widget_Data *wd = elm_widget_data_get(obj);
1279 elm_smart_scroller_freeze_set(wd->scr, EINA_TRUE);
1283 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1285 Widget_Data *wd = elm_widget_data_get(obj);
1288 elm_smart_scroller_freeze_set(wd->scr, EINA_FALSE);
1292 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1298 elm_list_add(Evas_Object *parent)
1303 Evas_Coord minw, minh;
1305 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1307 ELM_SET_WIDTYPE(widtype, "list");
1308 elm_widget_type_set(obj, "list");
1309 elm_widget_sub_object_add(parent, obj);
1310 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1311 elm_widget_data_set(obj, wd);
1312 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1313 elm_widget_del_hook_set(obj, _del_hook);
1314 elm_widget_theme_hook_set(obj, _theme_hook);
1315 elm_widget_disable_hook_set(obj, _disable_hook);
1316 elm_widget_can_focus_set(obj, EINA_TRUE);
1317 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1318 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1319 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1320 elm_widget_event_hook_set(obj, _event_hook);
1323 wd->scr = elm_smart_scroller_add(e);
1324 elm_smart_scroller_widget_set(wd->scr, obj);
1325 elm_widget_resize_object_set(obj, wd->scr);
1326 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1327 _changed_size_hints, obj);
1328 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
1329 evas_object_size_hint_min_set(obj, minw, minh);
1330 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1332 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
1333 _elm_config->thumbscroll_bounce_enable);
1335 wd->box = elm_box_add(parent);
1336 elm_box_homogeneous_set(wd->box, 1);
1337 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1338 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1339 elm_widget_on_show_region_hook_set(wd->box, _show_region_hook, obj);
1340 elm_widget_sub_object_add(obj, wd->box);
1341 elm_smart_scroller_child_set(wd->scr, wd->box);
1342 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1343 _changed_size_hints, obj);
1345 evas_object_show(wd->box);
1349 wd->mode = ELM_LIST_SCROLL;
1351 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
1352 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right, obj);
1353 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
1354 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom, obj);
1356 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1357 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1358 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1359 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1360 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1362 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1364 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1369 EAPI Elm_List_Item *
1370 elm_list_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1372 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1373 Widget_Data *wd = elm_widget_data_get(obj);
1374 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1376 wd->items = eina_list_append(wd->items, it);
1377 it->node = eina_list_last(wd->items);
1378 elm_box_pack_end(wd->box, it->base.view);
1382 EAPI Elm_List_Item *
1383 elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1385 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1386 Widget_Data *wd = elm_widget_data_get(obj);
1387 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1389 wd->items = eina_list_prepend(wd->items, it);
1390 it->node = wd->items;
1391 elm_box_pack_start(wd->box, it->base.view);
1395 EAPI Elm_List_Item *
1396 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)
1401 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
1402 if (!before->node) return NULL;
1403 ELM_LIST_ITEM_CHECK_DELETED_RETURN(before, NULL);
1405 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1406 wd = elm_widget_data_get(obj);
1407 if (!wd) return NULL;
1408 it = _item_new(obj, label, icon, end, func, data);
1409 wd->items = eina_list_prepend_relative_list(wd->items, it, before->node);
1410 it->node = before->node->prev;
1411 elm_box_pack_before(wd->box, it->base.view, before->base.view);
1415 EAPI Elm_List_Item *
1416 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)
1421 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
1422 if (!after->node) return NULL;
1423 ELM_LIST_ITEM_CHECK_DELETED_RETURN(after, NULL);
1425 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1426 wd = elm_widget_data_get(obj);
1427 if (!wd) return NULL;
1428 it = _item_new(obj, label, icon, end, func, data);
1429 wd->items = eina_list_append_relative_list(wd->items, it, after->node);
1430 it->node = after->node->next;
1431 elm_box_pack_after(wd->box, it->base.view, after->base.view);
1435 EAPI Elm_List_Item *
1436 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)
1438 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1439 Widget_Data *wd = elm_widget_data_get(obj);
1440 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1443 wd->items = eina_list_sorted_insert(wd->items, cmp_func, it);
1444 l = eina_list_data_find_list(wd->items, it);
1445 l = eina_list_next(l);
1448 it->node = eina_list_last(wd->items);
1449 elm_box_pack_end(wd->box, it->base.view);
1453 Elm_List_Item *before = eina_list_data_get(l);
1454 it->node = before->node->prev;
1455 elm_box_pack_before(wd->box, it->base.view, before->base.view);
1461 elm_list_clear(Evas_Object *obj)
1463 ELM_CHECK_WIDTYPE(obj, widtype);
1464 Widget_Data *wd = elm_widget_data_get(obj);
1468 if (!wd->items) return;
1470 eina_list_free(wd->selected);
1471 wd->selected = NULL;
1473 if (wd->walking > 0)
1477 EINA_LIST_FOREACH(wd->items, n, it)
1479 if (it->deleted) continue;
1480 it->deleted = EINA_TRUE;
1481 wd->to_delete = eina_list_append(wd->to_delete, it);
1486 evas_object_ref(obj);
1489 EINA_LIST_FREE(wd->items, it)
1491 elm_widget_item_pre_notify_del(it);
1492 _elm_list_item_free(it);
1495 _elm_list_unwalk(wd);
1499 evas_object_unref(obj);
1503 elm_list_go(Evas_Object *obj)
1505 ELM_CHECK_WIDTYPE(obj, widtype);
1506 Widget_Data *wd = elm_widget_data_get(obj);
1512 elm_list_multi_select_set(Evas_Object *obj, Eina_Bool multi)
1514 ELM_CHECK_WIDTYPE(obj, widtype);
1515 Widget_Data *wd = elm_widget_data_get(obj);
1521 elm_list_multi_select_get(const Evas_Object *obj)
1523 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1524 Widget_Data *wd = elm_widget_data_get(obj);
1525 if (!wd) return EINA_FALSE;
1530 elm_list_mode_set(Evas_Object *obj, Elm_List_Mode mode)
1532 ELM_CHECK_WIDTYPE(obj, widtype);
1536 wd = elm_widget_data_get(obj);
1539 if (wd->mode == mode)
1543 _elm_list_mode_set_internal(wd);
1547 elm_list_mode_get(const Evas_Object *obj)
1549 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
1550 Widget_Data *wd = elm_widget_data_get(obj);
1551 if (!wd) return ELM_LIST_LAST;
1556 elm_list_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1558 ELM_CHECK_WIDTYPE(obj, widtype);
1561 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1563 wd = elm_widget_data_get(obj);
1567 if (wd->h_mode == horizontal)
1570 wd->h_mode = horizontal;
1571 elm_box_horizontal_set(wd->box, horizontal);
1575 evas_object_size_hint_weight_set(wd->box, 0.0, EVAS_HINT_EXPAND);
1576 evas_object_size_hint_align_set(wd->box, 0.0, EVAS_HINT_FILL);
1577 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1581 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1582 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1583 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, bounce);
1586 _elm_list_mode_set_internal(wd);
1590 elm_list_horizontal_get(const Evas_Object *obj)
1592 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1596 wd = elm_widget_data_get(obj);
1604 elm_list_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
1606 ELM_CHECK_WIDTYPE(obj, widtype);
1607 Widget_Data *wd = elm_widget_data_get(obj);
1609 wd->always_select = always_select;
1613 elm_list_always_select_mode_get(const Evas_Object *obj)
1615 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1616 Widget_Data *wd = elm_widget_data_get(obj);
1617 if (!wd) return EINA_FALSE;
1618 return wd->always_select;
1621 EAPI const Eina_List *
1622 elm_list_items_get(const Evas_Object *obj)
1624 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1625 Widget_Data *wd = elm_widget_data_get(obj);
1626 if (!wd) return NULL;
1630 EAPI Elm_List_Item *
1631 elm_list_selected_item_get(const Evas_Object *obj)
1633 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1634 Widget_Data *wd = elm_widget_data_get(obj);
1635 if (!wd) return NULL;
1636 if (wd->selected) return wd->selected->data;
1640 EAPI const Eina_List *
1641 elm_list_selected_items_get(const Evas_Object *obj)
1643 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1644 Widget_Data *wd = elm_widget_data_get(obj);
1645 if (!wd) return NULL;
1646 return wd->selected;
1650 elm_list_item_separator_set(Elm_List_Item *it, Eina_Bool setting)
1652 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1653 it->is_separator = !!setting;
1657 elm_list_item_separator_get(const Elm_List_Item *it)
1659 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1660 return it->is_separator;
1665 elm_list_item_selected_set(Elm_List_Item *it, Eina_Bool selected)
1667 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1668 Evas_Object *obj = it->base.widget;
1669 Widget_Data *wd = elm_widget_data_get(obj);
1672 selected = !!selected;
1673 if (it->selected == selected) return;
1675 evas_object_ref(obj);
1682 while (wd->selected)
1683 _item_unselect(wd->selected->data);
1685 _item_highlight(it);
1691 _elm_list_unwalk(wd);
1692 evas_object_unref(obj);
1696 elm_list_item_selected_get(const Elm_List_Item *it)
1698 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1699 return it->selected;
1703 elm_list_item_show(Elm_List_Item *it)
1705 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1706 Widget_Data *wd = elm_widget_data_get(it->base.widget);
1707 Evas_Coord bx, by, bw, bh;
1708 Evas_Coord x, y, w, h;
1710 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1711 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
1715 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
1719 elm_list_item_bring_in(Elm_List_Item *it)
1721 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1722 Widget_Data *wd = elm_widget_data_get(it->base.widget);
1723 Evas_Coord bx, by, bw, bh;
1724 Evas_Coord x, y, w, h;
1726 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1727 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
1731 elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
1735 elm_list_item_del(Elm_List_Item *it)
1737 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1738 Evas_Object *obj = it->base.widget;
1739 Widget_Data *wd = elm_widget_data_get(obj);
1742 if (it->selected) _item_unselect(it);
1744 if (wd->walking > 0)
1746 if (it->deleted) return;
1747 it->deleted = EINA_TRUE;
1748 wd->to_delete = eina_list_append(wd->to_delete, it);
1752 wd->items = eina_list_remove_list(wd->items, it->node);
1754 evas_object_ref(obj);
1757 elm_widget_item_pre_notify_del(it);
1758 _elm_list_item_free(it);
1760 _elm_list_unwalk(wd);
1761 evas_object_unref(obj);
1765 elm_list_item_del_cb_set(Elm_List_Item *it, Evas_Smart_Cb func)
1767 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1768 elm_widget_item_del_cb_set(it, func);
1772 elm_list_item_data_get(const Elm_List_Item *it)
1774 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1775 return elm_widget_item_data_get(it);
1779 elm_list_item_icon_get(const Elm_List_Item *it)
1781 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1782 if (it->dummy_icon) return NULL;
1787 elm_list_item_icon_set(Elm_List_Item *it, Evas_Object *icon)
1789 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1790 if (it->icon == icon) return;
1791 if ((it->dummy_icon) && (!icon)) return;
1794 evas_object_del(it->icon);
1795 it->dummy_icon = EINA_FALSE;
1799 icon = evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1800 evas_object_color_set(icon, 0, 0, 0, 0);
1801 it->dummy_icon = EINA_TRUE;
1805 evas_object_del(it->icon);
1810 edje_object_part_swallow(it->base.view, "elm.swallow.icon", icon);
1814 elm_list_item_end_get(const Elm_List_Item *it)
1816 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1817 if (it->dummy_end) return NULL;
1822 elm_list_item_end_set(Elm_List_Item *it, Evas_Object *end)
1824 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1825 if (it->end == end) return;
1826 if ((it->dummy_end) && (!end)) return;
1829 evas_object_del(it->end);
1830 it->dummy_icon = EINA_FALSE;
1834 end = evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1835 evas_object_color_set(end, 0, 0, 0, 0);
1836 it->dummy_end = EINA_TRUE;
1840 evas_object_del(it->end);
1845 edje_object_part_swallow(it->base.view, "elm.swallow.end", end);
1849 elm_list_item_base_get(const Elm_List_Item *it)
1851 return elm_list_item_object_get(it);
1855 elm_list_item_object_get(const Elm_List_Item *it)
1857 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1858 return it->base.view;
1862 elm_list_item_label_get(const Elm_List_Item *it)
1864 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1869 elm_list_item_label_set(Elm_List_Item *it, const char *text)
1871 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1872 if (!eina_stringshare_replace(&it->label, text)) return;
1874 edje_object_part_text_set(it->base.view, "elm.text", it->label);
1877 EAPI Elm_List_Item *
1878 elm_list_item_prev(const Elm_List_Item *it)
1880 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1881 if (it->node->prev) return it->node->prev->data;
1885 EAPI Elm_List_Item *
1886 elm_list_item_next(const Elm_List_Item *it)
1888 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1889 if (it->node->next) return it->node->next->data;
1894 elm_list_item_tooltip_text_set(Elm_List_Item *item, const char *text)
1896 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1897 elm_widget_item_tooltip_text_set(item, text);
1901 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)
1903 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1904 elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
1908 elm_list_item_tooltip_unset(Elm_List_Item *item)
1910 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1911 elm_widget_item_tooltip_unset(item);
1915 elm_list_item_tooltip_size_restrict_disable(Elm_List_Item *item, Eina_Bool disable)
1917 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1918 return elm_widget_item_tooltip_size_restrict_disable(item, disable);
1922 elm_list_item_tooltip_size_restrict_disabled_get(const Elm_List_Item *item)
1924 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1925 return elm_widget_item_tooltip_size_restrict_disabled_get(item);
1929 elm_list_item_tooltip_style_set(Elm_List_Item *item, const char *style)
1931 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1932 elm_widget_item_tooltip_style_set(item, style);
1936 elm_list_item_tooltip_style_get(const Elm_List_Item *item)
1938 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1939 return elm_widget_item_tooltip_style_get(item);
1943 elm_list_item_cursor_set(Elm_List_Item *item, const char *cursor)
1945 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1946 elm_widget_item_cursor_set(item, cursor);
1950 elm_list_item_cursor_get(const Elm_List_Item *item)
1952 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1953 return elm_widget_item_cursor_get(item);
1957 elm_list_item_cursor_unset(Elm_List_Item *item)
1959 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1960 elm_widget_item_cursor_unset(item);
1964 elm_list_item_cursor_style_set(Elm_List_Item *item, const char *style)
1966 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1967 elm_widget_item_cursor_style_set(item, style);
1971 elm_list_item_cursor_style_get(const Elm_List_Item *item)
1973 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1974 return elm_widget_item_cursor_style_get(item);
1978 elm_list_item_cursor_engine_only_set(Elm_List_Item *item, Eina_Bool engine_only)
1980 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1981 elm_widget_item_cursor_engine_only_set(item, engine_only);
1985 elm_list_item_cursor_engine_only_get(const Elm_List_Item *item)
1987 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1988 return elm_widget_item_cursor_engine_only_get(item);
1992 elm_list_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1994 ELM_CHECK_WIDTYPE(obj, widtype);
1995 Widget_Data *wd = elm_widget_data_get(obj);
1998 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2002 elm_list_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
2004 ELM_CHECK_WIDTYPE(obj, widtype);
2005 Widget_Data *wd = elm_widget_data_get(obj);
2007 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
2011 elm_list_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
2013 ELM_CHECK_WIDTYPE(obj, widtype);
2014 Widget_Data *wd = elm_widget_data_get(obj);
2016 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
2017 (policy_v >= ELM_SCROLLER_POLICY_LAST))
2019 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
2023 elm_list_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
2025 ELM_CHECK_WIDTYPE(obj, widtype);
2026 Widget_Data *wd = elm_widget_data_get(obj);
2027 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
2028 if ((!wd) || (!wd->scr)) return;
2029 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
2030 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
2031 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
2035 elm_list_item_disabled_set(Elm_List_Item *it, Eina_Bool disabled)
2037 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2039 if (it->disabled == disabled)
2042 it->disabled = !!disabled;
2045 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
2047 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
2051 elm_list_item_disabled_get(const Elm_List_Item *it)
2053 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2055 return it->disabled;