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 hilighted : 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_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[] = {
91 {SIG_CLICKED_DOUBLE, ""},
94 {SIG_LONGPRESSED, ""},
95 {SIG_SCROLL_EDGE_TOP, ""},
96 {SIG_SCROLL_EDGE_BOTTOM, ""},
97 {SIG_SCROLL_EDGE_LEFT, ""},
98 {SIG_SCROLL_EDGE_RIGHT, ""},
102 #define ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ...) \
103 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, __VA_ARGS__); \
106 ERR("ERROR: "#it" has been DELETED.\n"); \
107 return __VA_ARGS__; \
111 _elm_list_item_free(Elm_List_Item *it)
113 evas_object_event_callback_del_full
114 (VIEW(it), EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
115 evas_object_event_callback_del_full
116 (VIEW(it), EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
117 evas_object_event_callback_del_full
118 (VIEW(it), EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, it);
121 evas_object_event_callback_del_full
122 (it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
123 _changed_size_hints, WIDGET(it));
126 evas_object_event_callback_del_full
127 (it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
128 _changed_size_hints, WIDGET(it));
130 eina_stringshare_del(it->label);
132 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
133 if (it->long_timer) ecore_timer_del(it->long_timer);
134 if (it->icon) evas_object_del(it->icon);
135 if (it->end) evas_object_del(it->end);
137 elm_widget_item_del(it);
141 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
143 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
144 Evas_Event_Key_Down *ev = event_info;
145 Widget_Data *wd = elm_widget_data_get(obj);
146 if (!wd) return EINA_FALSE;
147 if (!wd->items) return EINA_FALSE;
148 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
149 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
151 Elm_List_Item *it = NULL;
154 Evas_Coord step_x = 0;
155 Evas_Coord step_y = 0;
158 Evas_Coord page_x = 0;
159 Evas_Coord page_y = 0;
161 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
162 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
163 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
164 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
166 /* TODO: fix logic for horizontal mode */
167 if ((!strcmp(ev->keyname, "Left")) ||
168 (!strcmp(ev->keyname, "KP_Left")))
171 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
172 (_item_multi_select_up(wd)))
173 || (_item_single_select_up(wd))))
175 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
181 else if ((!strcmp(ev->keyname, "Right")) ||
182 (!strcmp(ev->keyname, "KP_Right")))
185 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
186 (_item_multi_select_down(wd)))
187 || (_item_single_select_down(wd))))
189 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
195 else if ((!strcmp(ev->keyname, "Up")) ||
196 (!strcmp(ev->keyname, "KP_Up")))
199 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
200 (_item_multi_select_up(wd)))
201 || (_item_single_select_up(wd))))
203 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
209 else if ((!strcmp(ev->keyname, "Down")) ||
210 (!strcmp(ev->keyname, "KP_Down")))
213 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
214 (_item_multi_select_down(wd)))
215 || (_item_single_select_down(wd))))
217 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
223 else if ((!strcmp(ev->keyname, "Home")) ||
224 (!strcmp(ev->keyname, "KP_Home")))
226 it = eina_list_data_get(wd->items);
227 elm_list_item_bring_in(it);
228 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
231 else if ((!strcmp(ev->keyname, "End")) ||
232 (!strcmp(ev->keyname, "KP_End")))
234 it = eina_list_data_get(eina_list_last(wd->items));
235 elm_list_item_bring_in(it);
236 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
239 else if ((!strcmp(ev->keyname, "Prior")) ||
240 (!strcmp(ev->keyname, "KP_Prior")))
245 x -= -(page_x * v_w) / 100;
252 y -= -(page_y * v_h) / 100;
257 else if ((!strcmp(ev->keyname, "Next")) ||
258 (!strcmp(ev->keyname, "KP_Next")))
263 x += -(page_x * v_w) / 100;
270 y += -(page_y * v_h) / 100;
275 else if (!strcmp(ev->keyname, "Escape"))
277 if (!_deselect_all_items(wd)) return EINA_FALSE;
278 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
281 else return EINA_FALSE;
283 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
284 elm_smart_scroller_child_pos_set(wd->scr, x, y);
289 _deselect_all_items(Widget_Data *wd)
291 if (!wd->selected) return EINA_FALSE;
293 elm_list_item_selected_set(wd->selected->data, EINA_FALSE);
299 _item_multi_select_up(Widget_Data *wd)
301 if (!wd->selected) return EINA_FALSE;
302 if (!wd->multi) return EINA_FALSE;
304 Elm_List_Item *prev = elm_list_item_prev(wd->last_selected_item);
305 if (!prev) return EINA_TRUE;
307 if (elm_list_item_selected_get(prev))
309 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
310 wd->last_selected_item = prev;
311 elm_list_item_show(wd->last_selected_item);
315 elm_list_item_selected_set(prev, EINA_TRUE);
316 elm_list_item_show(prev);
322 _item_multi_select_down(Widget_Data *wd)
324 if (!wd->selected) return EINA_FALSE;
325 if (!wd->multi) return EINA_FALSE;
327 Elm_List_Item *next = elm_list_item_next(wd->last_selected_item);
328 if (!next) return EINA_TRUE;
330 if (elm_list_item_selected_get(next))
332 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
333 wd->last_selected_item = next;
334 elm_list_item_show(wd->last_selected_item);
338 elm_list_item_selected_set(next, EINA_TRUE);
339 elm_list_item_show(next);
345 _item_single_select_up(Widget_Data *wd)
349 if (!wd->selected) prev = eina_list_data_get(eina_list_last(wd->items));
350 else prev = elm_list_item_prev(wd->last_selected_item);
352 if (!prev) return EINA_FALSE;
354 _deselect_all_items(wd);
356 elm_list_item_selected_set(prev, EINA_TRUE);
357 elm_list_item_show(prev);
362 _item_single_select_down(Widget_Data *wd)
366 if (!wd->selected) next = eina_list_data_get(wd->items);
367 else next = elm_list_item_next(wd->last_selected_item);
369 if (!next) return EINA_FALSE;
371 _deselect_all_items(wd);
373 elm_list_item_selected_set(next, EINA_TRUE);
374 elm_list_item_show(next);
379 _elm_list_process_deletions(Widget_Data *wd)
383 wd->walking++; // avoid nested deletion and also _sub_del() fix_items
385 EINA_LIST_FREE(wd->to_delete, it)
387 elm_widget_item_pre_notify_del(it);
389 wd->items = eina_list_remove_list(wd->items, it->node);
390 _elm_list_item_free(it);
397 _elm_list_walk(Widget_Data *wd)
401 ERR("ERROR: walking was negative. fixed!\n");
408 _elm_list_unwalk(Widget_Data *wd)
413 ERR("ERROR: walking became negative. fixed!\n");
421 _elm_list_process_deletions(wd);
425 wd->fix_pending = EINA_FALSE;
426 _fix_items(wd->self);
427 _sizing_eval(wd->self);
432 _del_pre_hook(Evas_Object *obj)
434 Widget_Data *wd = elm_widget_data_get(obj);
437 evas_object_event_callback_del(wd->scr,
438 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
439 _changed_size_hints);
440 evas_object_event_callback_del(wd->box,
441 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
442 _changed_size_hints);
446 _del_hook(Evas_Object *obj)
448 Widget_Data *wd = elm_widget_data_get(obj);
454 ERR("ERROR: list deleted while walking.\n");
457 EINA_LIST_FOREACH(wd->items, n, it) elm_widget_item_pre_notify_del(it);
458 _elm_list_unwalk(wd);
460 ERR("ERROR: leaking nodes!\n");
462 EINA_LIST_FREE(wd->items, it) _elm_list_item_free(it);
463 eina_list_free(wd->selected);
468 _show_region_hook(void *data, Evas_Object *obj)
470 Widget_Data *wd = elm_widget_data_get(data);
471 Evas_Coord x, y, w, h;
473 elm_widget_show_region_get(obj, &x, &y, &w, &h);
474 elm_smart_scroller_child_region_set(wd->scr, x, y, w, h);
478 _disable_hook(Evas_Object *obj)
480 Widget_Data *wd = elm_widget_data_get(obj);
482 if (elm_widget_disabled_get(obj))
484 _signal_emit_hook(obj, "elm,state,disabled", "elm");
485 elm_widget_scroll_freeze_push(obj);
486 elm_widget_scroll_hold_push(obj);
487 /* FIXME: if we get to have a way to only un-hilight items
488 * in the future, keeping them selected... */
489 _deselect_all_items(wd);
493 _signal_emit_hook(obj, "elm,state,enabled", "elm");
494 elm_widget_scroll_freeze_pop(obj);
495 elm_widget_scroll_hold_pop(obj);
500 _sizing_eval(Evas_Object *obj)
503 Widget_Data *wd = elm_widget_data_get(obj);
505 Evas_Coord vw, vh, minw, minh, maxw, maxh, w, h, vmw, vmh;
508 evas_object_size_hint_min_get(wd->box, &minw, &minh);
509 evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
510 evas_object_size_hint_weight_get(wd->box, &xw, &yw);
511 if (!wd->scr) return;
512 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
515 if ((minw > 0) && (vw < minw)) vw = minw;
516 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
518 else if (minw > 0) vw = minw;
521 if ((minh > 0) && (vh < minh)) vh = minh;
522 else if ((maxh > 0) && (vh > maxh)) vh = maxh;
524 else if (minh > 0) vh = minh;
525 evas_object_resize(wd->box, vw, vh);
528 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
530 if (wd->scr_minw) w = vmw + minw;
531 if (wd->scr_minh) h = vmh + minh;
533 evas_object_size_hint_max_get(obj, &maxw, &maxh);
534 if ((maxw > 0) && (w > maxw))
536 if ((maxh > 0) && (h > maxh))
539 evas_object_size_hint_min_set(obj, w, h);
543 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
545 Widget_Data *wd = elm_widget_data_get(obj);
546 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
551 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
553 Widget_Data *wd = elm_widget_data_get(obj);
554 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
555 emission, source, func_cb, data);
559 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
561 Widget_Data *wd = elm_widget_data_get(obj);
562 edje_object_signal_callback_del_full(
563 elm_smart_scroller_edje_object_get(wd->scr),
564 emission, source, func_cb, data);
568 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
570 Widget_Data *wd = elm_widget_data_get(obj);
576 elm_smart_scroller_mirrored_set(wd->scr, rtl);
578 EINA_LIST_FOREACH(wd->items, n, it)
579 edje_object_mirrored_set(VIEW(it), rtl);
583 _theme_hook(Evas_Object *obj)
585 Widget_Data *wd = elm_widget_data_get(obj);
590 _elm_widget_mirrored_reload(obj);
591 _mirrored_set(obj, elm_widget_mirrored_get(obj));
598 elm_smart_scroller_object_theme_set(obj, wd->scr, "list", "base",
599 elm_widget_style_get(obj));
600 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
601 edj = elm_smart_scroller_edje_object_get(wd->scr);
602 str = edje_object_data_get(edj, "focus_highlight");
603 if ((str) && (!strcmp(str, "on")))
604 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
606 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
607 elm_object_style_set(wd->scr, elm_widget_style_get(obj));
609 EINA_LIST_FOREACH(wd->items, n, it)
611 edje_object_scale_set(VIEW(it), elm_widget_scale_get(obj) * _elm_config->scale);
619 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
621 Widget_Data *wd = elm_widget_data_get(obj);
623 if (elm_widget_focus_get(obj))
625 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
626 evas_object_focus_set(wd->self, EINA_TRUE);
628 if ((wd->selected) && (!wd->last_selected_item))
629 wd->last_selected_item = eina_list_data_get(wd->selected);
633 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
634 evas_object_focus_set(wd->self, EINA_FALSE);
639 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
641 Widget_Data *wd = elm_widget_data_get(data);
648 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
650 Widget_Data *wd = elm_widget_data_get(obj);
651 Evas_Object *sub = event_info;
657 if ((sub == wd->box) || (sub == wd->scr)) return;
659 EINA_LIST_FOREACH(wd->items, l, it)
661 if ((sub == it->icon) || (sub == it->end))
663 if (it->icon == sub) it->icon = NULL;
664 if (it->end == sub) it->end = NULL;
665 evas_object_event_callback_del_full
666 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints,
674 wd->fix_pending = EINA_TRUE;
681 _item_hilight(Elm_List_Item *it)
683 Evas_Object *obj = WIDGET(it);
684 Widget_Data *wd = elm_widget_data_get(obj);
685 const char *selectraise;
688 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
689 if (it->hilighted) return;
691 evas_object_ref(obj);
694 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
695 selectraise = edje_object_data_get(VIEW(it), "selectraise");
696 if ((selectraise) && (!strcmp(selectraise, "on")))
697 evas_object_raise(VIEW(it));
698 it->hilighted = EINA_TRUE;
700 _elm_list_unwalk(wd);
701 evas_object_unref(obj);
705 _item_select(Elm_List_Item *it)
707 Evas_Object *obj = WIDGET(it);
708 Widget_Data *wd = elm_widget_data_get(obj);
711 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
714 if (wd->always_select) goto call;
717 it->selected = EINA_TRUE;
718 wd->selected = eina_list_append(wd->selected, it);
721 evas_object_ref(obj);
724 if (it->func) it->func((void *)it->base.data, WIDGET(it), it);
725 evas_object_smart_callback_call(obj, SIG_SELECTED, it);
726 it->wd->last_selected_item = it;
728 _elm_list_unwalk(wd);
729 evas_object_unref(obj);
733 _item_unselect(Elm_List_Item *it)
735 Evas_Object *obj = WIDGET(it);
736 Widget_Data *wd = elm_widget_data_get(obj);
737 const char *stacking, *selectraise;
740 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
741 if (!it->hilighted) return;
743 evas_object_ref(obj);
746 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
747 stacking = edje_object_data_get(VIEW(it), "stacking");
748 selectraise = edje_object_data_get(VIEW(it), "selectraise");
749 if ((selectraise) && (!strcmp(selectraise, "on")))
751 if ((stacking) && (!strcmp(stacking, "below")))
752 evas_object_lower(VIEW(it));
754 it->hilighted = EINA_FALSE;
757 it->selected = EINA_FALSE;
758 wd->selected = eina_list_remove(wd->selected, it);
759 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
762 _elm_list_unwalk(wd);
763 evas_object_unref(obj);
767 _swipe_cancel(void *data)
769 Elm_List_Item *it = data;
770 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
772 if (!wd) return ECORE_CALLBACK_CANCEL;
773 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
774 wd->swipe = EINA_FALSE;
776 return ECORE_CALLBACK_RENEW;
780 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
782 Elm_List_Item *it = data;
783 Evas_Object *obj2 = WIDGET(it);
784 Widget_Data *wd = elm_widget_data_get(obj2);
785 Evas_Event_Mouse_Move *ev = event_info;
788 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
790 evas_object_ref(obj2);
793 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
797 wd->on_hold = EINA_TRUE;
800 ecore_timer_del(it->long_timer);
801 it->long_timer = NULL;
803 if (!wd->wasselected)
806 if (wd->movements == SWIPE_MOVES) wd->swipe = EINA_TRUE;
809 wd->history[wd->movements].x = ev->cur.canvas.x;
810 wd->history[wd->movements].y = ev->cur.canvas.y;
811 if (abs((wd->history[wd->movements].x - wd->history[0].x)) > 40)
812 wd->swipe = EINA_TRUE;
818 _elm_list_unwalk(wd);
819 evas_object_unref(obj2);
823 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
825 Evas_Object *obj = data;
826 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
830 _scroll_edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
832 Evas_Object *obj = data;
833 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
837 _scroll_edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
839 Evas_Object *obj = data;
840 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
844 _scroll_edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
846 Evas_Object *obj = data;
847 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
851 _long_press(void *data)
853 Elm_List_Item *it = data;
854 Evas_Object *obj = WIDGET(it);
855 Widget_Data *wd = elm_widget_data_get(obj);
859 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
860 it->long_timer = NULL;
861 if (it->disabled) goto end;
863 wd->longpressed = EINA_TRUE;
864 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
867 return ECORE_CALLBACK_CANCEL;
871 _swipe(Elm_List_Item *it)
874 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
876 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
878 wd->swipe = EINA_FALSE;
879 for (i = 0; i < wd->movements; i++)
881 sum += wd->history[i].x;
882 if (abs(wd->history[0].y - wd->history[i].y) > 10) return;
885 sum /= wd->movements;
886 if (abs(sum - wd->history[0].x) <= 10) return;
887 evas_object_smart_callback_call(WIDGET(it), "swipe", it);
891 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
893 Elm_List_Item *it = data;
894 Evas_Object *obj2 = WIDGET(it);
895 Widget_Data *wd = elm_widget_data_get(obj2);
896 Evas_Event_Mouse_Down *ev = event_info;
899 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
900 if (ev->button != 1) return;
901 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
902 else wd->on_hold = EINA_FALSE;
903 if (wd->on_hold) return;
904 wd->wasselected = it->selected;
906 evas_object_ref(obj2);
910 wd->longpressed = EINA_FALSE;
911 if (it->long_timer) ecore_timer_del(it->long_timer);
912 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, it);
913 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
914 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
915 /* Always call the callbacks last - the user may delete our context! */
916 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
917 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
918 wd->swipe = EINA_FALSE;
921 _elm_list_unwalk(wd);
922 evas_object_unref(obj2);
926 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
928 Elm_List_Item *it = data;
929 Evas_Object *obj2 = WIDGET(it);
930 Widget_Data *wd = elm_widget_data_get(obj2);
931 Evas_Event_Mouse_Up *ev = event_info;
934 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
935 if (ev->button != 1) return;
936 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
937 else wd->on_hold = EINA_FALSE;
938 wd->longpressed = EINA_FALSE;
941 ecore_timer_del(it->long_timer);
942 it->long_timer = NULL;
946 ecore_timer_del(it->swipe_timer);
947 it->swipe_timer = NULL;
951 if (wd->swipe) _swipe(data);
952 wd->on_hold = EINA_FALSE;
957 if (!wd->wasselected) _item_unselect(it);
964 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
966 evas_object_ref(obj2);
976 else _item_unselect(it);
983 _item_unselect(wd->selected->data);
989 const Eina_List *l, *l_next;
992 EINA_LIST_FOREACH_SAFE(wd->selected, l, l_next, it2)
993 if (it2 != it) _item_unselect(it2);
999 _elm_list_unwalk(wd);
1000 evas_object_unref(obj2);
1003 static Elm_List_Item *
1004 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1006 Widget_Data *wd = elm_widget_data_get(obj);
1009 if (!wd) return NULL;
1010 it = elm_widget_item_new(obj, Elm_List_Item);
1012 it->label = eina_stringshare_add(label);
1016 it->base.data = data;
1017 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
1018 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(obj));
1019 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1021 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1023 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1025 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1026 evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1029 elm_widget_sub_object_add(obj, it->icon);
1030 evas_object_event_callback_add(it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1031 _changed_size_hints, obj);
1035 elm_widget_sub_object_add(obj, it->end);
1036 evas_object_event_callback_add(it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1037 _changed_size_hints, obj);
1043 _elm_list_mode_set_internal(Widget_Data *wd)
1048 if (wd->mode == ELM_LIST_LIMIT)
1052 wd->scr_minw = EINA_TRUE;
1053 wd->scr_minh = EINA_FALSE;
1057 wd->scr_minw = EINA_FALSE;
1058 wd->scr_minh = EINA_TRUE;
1061 else if (wd->mode == ELM_LIST_EXPAND)
1063 wd->scr_minw = EINA_TRUE;
1064 wd->scr_minh = EINA_TRUE;
1068 wd->scr_minw = EINA_FALSE;
1069 wd->scr_minh = EINA_FALSE;
1072 _sizing_eval(wd->self);
1076 _fix_items(Evas_Object *obj)
1078 Widget_Data *wd = elm_widget_data_get(obj);
1082 Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
1085 const char *style = elm_widget_style_get(obj);
1086 const char *it_plain = wd->h_mode ? "h_item" : "item";
1087 const char *it_odd = wd->h_mode ? "h_item_odd" : "item_odd";
1088 const char *it_compress = wd->h_mode ? "h_item_compress" : "item_compress";
1089 const char *it_compress_odd = wd->h_mode ? "h_item_compress_odd" : "item_compress_odd";
1093 wd->fix_pending = EINA_TRUE;
1097 evas_object_ref(obj);
1098 _elm_list_walk(wd); // watch out "return" before unwalk!
1100 EINA_LIST_FOREACH(wd->items, l, it)
1102 if (it->deleted) continue;
1105 evas_object_size_hint_min_get(it->icon, &mw, &mh);
1106 if (mw > minw[0]) minw[0] = mw;
1107 if (mh > minh[0]) minh[0] = mh;
1111 evas_object_size_hint_min_get(it->end, &mw, &mh);
1112 if (mw > minw[1]) minw[1] = mw;
1113 if (mh > minh[1]) minh[1] = mh;
1117 if ((minw[0] != wd->minw[0]) || (minw[1] != wd->minw[1]) ||
1118 (minw[0] != wd->minh[0]) || (minh[1] != wd->minh[1]))
1120 wd->minw[0] = minw[0];
1121 wd->minw[1] = minw[1];
1122 wd->minh[0] = minh[0];
1123 wd->minh[1] = minh[1];
1127 EINA_LIST_FOREACH(wd->items, l, it)
1133 if ((it->even != it->is_even) || (!it->fixed) || (redo))
1135 const char *stacking;
1137 /* FIXME: separators' themes seem to be b0rked */
1138 if (it->is_separator)
1139 _elm_theme_object_set(obj, VIEW(it), "separator",
1140 wd->h_mode ? "horizontal" : "vertical",
1142 else if (wd->mode == ELM_LIST_COMPRESS)
1145 _elm_theme_object_set(obj, VIEW(it), "list",
1146 it_compress, style);
1148 _elm_theme_object_set(obj, VIEW(it), "list",
1149 it_compress_odd, style);
1154 _elm_theme_object_set(obj, VIEW(it), "list", it_plain,
1157 _elm_theme_object_set(obj, VIEW(it), "list", it_odd,
1160 stacking = edje_object_data_get(VIEW(it), "stacking");
1163 if (!strcmp(stacking, "below"))
1164 evas_object_lower(VIEW(it));
1165 else if (!strcmp(stacking, "above"))
1166 evas_object_raise(VIEW(it));
1168 edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1170 if ((!it->icon) && (minh[0] > 0))
1172 it->icon = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1173 evas_object_color_set(it->icon, 0, 0, 0, 0);
1174 it->dummy_icon = EINA_TRUE;
1176 if ((!it->end) && (minh[1] > 0))
1178 it->end = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1179 evas_object_color_set(it->end, 0, 0, 0, 0);
1180 it->dummy_end = EINA_TRUE;
1184 evas_object_size_hint_min_set(it->icon, minw[0], minh[0]);
1185 evas_object_size_hint_max_set(it->icon, 99999, 99999);
1186 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
1190 evas_object_size_hint_min_set(it->end, minw[1], minh[1]);
1191 evas_object_size_hint_max_set(it->end, 99999, 99999);
1192 edje_object_part_swallow(VIEW(it), "elm.swallow.end", it->end);
1196 // this may call up user and it may modify the list item
1197 // but we're safe as we're flagged as walking.
1198 // just don't process further
1199 edje_object_message_signal_process(VIEW(it));
1203 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1204 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
1205 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1206 evas_object_size_hint_min_set(VIEW(it), mw, mh);
1207 evas_object_show(VIEW(it));
1209 if ((it->selected) || (it->hilighted))
1211 const char *selectraise;
1213 // this may call up user and it may modify the list item
1214 // but we're safe as we're flagged as walking.
1215 // just don't process further
1216 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1220 selectraise = edje_object_data_get(VIEW(it), "selectraise");
1221 if ((selectraise) && (!strcmp(selectraise, "on")))
1222 evas_object_raise(VIEW(it));
1225 edje_object_signal_emit(VIEW(it), "elm,state,disabled",
1228 it->fixed = EINA_TRUE;
1229 it->is_even = it->even;
1235 evas_object_size_hint_min_get(wd->box, &mw, &mh);
1237 _elm_list_mode_set_internal(wd);
1239 _elm_list_unwalk(wd);
1240 evas_object_unref(obj);
1244 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1246 Widget_Data *wd = elm_widget_data_get(obj);
1249 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
1253 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1255 Widget_Data *wd = elm_widget_data_get(obj);
1258 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1262 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1264 Widget_Data *wd = elm_widget_data_get(obj);
1267 elm_smart_scroller_freeze_set(wd->scr, EINA_TRUE);
1271 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1273 Widget_Data *wd = elm_widget_data_get(obj);
1276 elm_smart_scroller_freeze_set(wd->scr, EINA_FALSE);
1280 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1286 elm_list_add(Evas_Object *parent)
1291 Evas_Coord minw, minh;
1293 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1295 ELM_SET_WIDTYPE(widtype, "list");
1296 elm_widget_type_set(obj, "list");
1297 elm_widget_sub_object_add(parent, obj);
1298 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1299 elm_widget_data_set(obj, wd);
1300 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1301 elm_widget_del_hook_set(obj, _del_hook);
1302 elm_widget_theme_hook_set(obj, _theme_hook);
1303 elm_widget_disable_hook_set(obj, _disable_hook);
1304 elm_widget_can_focus_set(obj, EINA_TRUE);
1305 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1306 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1307 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1308 elm_widget_event_hook_set(obj, _event_hook);
1311 wd->scr = elm_smart_scroller_add(e);
1312 elm_smart_scroller_widget_set(wd->scr, obj);
1313 elm_widget_resize_object_set(obj, wd->scr);
1314 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1315 _changed_size_hints, obj);
1316 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
1317 evas_object_size_hint_min_set(obj, minw, minh);
1318 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1320 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
1321 _elm_config->thumbscroll_bounce_enable);
1323 wd->box = elm_box_add(parent);
1324 elm_box_homogeneous_set(wd->box, 1);
1325 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1326 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1327 elm_widget_on_show_region_hook_set(wd->box, _show_region_hook, obj);
1328 elm_widget_sub_object_add(obj, wd->box);
1329 elm_smart_scroller_child_set(wd->scr, wd->box);
1330 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1331 _changed_size_hints, obj);
1333 evas_object_show(wd->box);
1337 wd->mode = ELM_LIST_SCROLL;
1339 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
1340 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right, obj);
1341 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
1342 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom, obj);
1344 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1345 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1346 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1347 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1348 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1350 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1352 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1357 EAPI Elm_List_Item *
1358 elm_list_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1360 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1361 Widget_Data *wd = elm_widget_data_get(obj);
1362 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1364 wd->items = eina_list_append(wd->items, it);
1365 it->node = eina_list_last(wd->items);
1366 elm_box_pack_end(wd->box, VIEW(it));
1370 EAPI Elm_List_Item *
1371 elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1373 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1374 Widget_Data *wd = elm_widget_data_get(obj);
1375 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1377 wd->items = eina_list_prepend(wd->items, it);
1378 it->node = wd->items;
1379 elm_box_pack_start(wd->box, VIEW(it));
1383 EAPI Elm_List_Item *
1384 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)
1389 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
1390 if (!before->node) return NULL;
1391 ELM_LIST_ITEM_CHECK_DELETED_RETURN(before, NULL);
1393 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1394 wd = elm_widget_data_get(obj);
1395 if (!wd) return NULL;
1396 it = _item_new(obj, label, icon, end, func, data);
1397 wd->items = eina_list_prepend_relative_list(wd->items, it, before->node);
1398 it->node = before->node->prev;
1399 elm_box_pack_before(wd->box, VIEW(it), VIEW(before));
1403 EAPI Elm_List_Item *
1404 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)
1409 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
1410 if (!after->node) return NULL;
1411 ELM_LIST_ITEM_CHECK_DELETED_RETURN(after, NULL);
1413 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1414 wd = elm_widget_data_get(obj);
1415 if (!wd) return NULL;
1416 it = _item_new(obj, label, icon, end, func, data);
1417 wd->items = eina_list_append_relative_list(wd->items, it, after->node);
1418 it->node = after->node->next;
1419 elm_box_pack_after(wd->box, VIEW(it), VIEW(after));
1423 EAPI Elm_List_Item *
1424 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)
1426 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1427 Widget_Data *wd = elm_widget_data_get(obj);
1428 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1431 wd->items = eina_list_sorted_insert(wd->items, cmp_func, it);
1432 l = eina_list_data_find_list(wd->items, it);
1433 l = eina_list_next(l);
1436 it->node = eina_list_last(wd->items);
1437 elm_box_pack_end(wd->box, VIEW(it));
1441 Elm_List_Item *before = eina_list_data_get(l);
1442 it->node = before->node->prev;
1443 elm_box_pack_before(wd->box, VIEW(it), VIEW(before));
1449 elm_list_clear(Evas_Object *obj)
1451 ELM_CHECK_WIDTYPE(obj, widtype);
1452 Widget_Data *wd = elm_widget_data_get(obj);
1456 if (!wd->items) return;
1458 eina_list_free(wd->selected);
1459 wd->selected = NULL;
1461 if (wd->walking > 0)
1465 EINA_LIST_FOREACH(wd->items, n, it)
1467 if (it->deleted) continue;
1468 it->deleted = EINA_TRUE;
1469 wd->to_delete = eina_list_append(wd->to_delete, it);
1474 evas_object_ref(obj);
1477 EINA_LIST_FREE(wd->items, it)
1479 elm_widget_item_pre_notify_del(it);
1480 _elm_list_item_free(it);
1483 _elm_list_unwalk(wd);
1487 evas_object_unref(obj);
1491 elm_list_go(Evas_Object *obj)
1493 ELM_CHECK_WIDTYPE(obj, widtype);
1494 Widget_Data *wd = elm_widget_data_get(obj);
1500 elm_list_multi_select_set(Evas_Object *obj, Eina_Bool multi)
1502 ELM_CHECK_WIDTYPE(obj, widtype);
1503 Widget_Data *wd = elm_widget_data_get(obj);
1509 elm_list_multi_select_get(const Evas_Object *obj)
1511 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1512 Widget_Data *wd = elm_widget_data_get(obj);
1513 if (!wd) return EINA_FALSE;
1518 elm_list_mode_set(Evas_Object *obj, Elm_List_Mode mode)
1520 ELM_CHECK_WIDTYPE(obj, widtype);
1524 wd = elm_widget_data_get(obj);
1527 if (wd->mode == mode)
1531 _elm_list_mode_set_internal(wd);
1535 elm_list_mode_get(const Evas_Object *obj)
1537 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
1538 Widget_Data *wd = elm_widget_data_get(obj);
1539 if (!wd) return ELM_LIST_LAST;
1544 elm_list_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1546 ELM_CHECK_WIDTYPE(obj, widtype);
1549 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1551 wd = elm_widget_data_get(obj);
1555 if (wd->h_mode == horizontal)
1558 wd->h_mode = horizontal;
1559 elm_box_horizontal_set(wd->box, horizontal);
1563 evas_object_size_hint_weight_set(wd->box, 0.0, EVAS_HINT_EXPAND);
1564 evas_object_size_hint_align_set(wd->box, 0.0, EVAS_HINT_FILL);
1565 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1569 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1570 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1571 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, bounce);
1574 _elm_list_mode_set_internal(wd);
1578 elm_list_horizontal_get(const Evas_Object *obj)
1580 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1584 wd = elm_widget_data_get(obj);
1592 elm_list_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
1594 ELM_CHECK_WIDTYPE(obj, widtype);
1595 Widget_Data *wd = elm_widget_data_get(obj);
1597 wd->always_select = always_select;
1601 elm_list_always_select_mode_get(const Evas_Object *obj)
1603 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1604 Widget_Data *wd = elm_widget_data_get(obj);
1605 if (!wd) return EINA_FALSE;
1606 return wd->always_select;
1609 EAPI const Eina_List *
1610 elm_list_items_get(const Evas_Object *obj)
1612 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1613 Widget_Data *wd = elm_widget_data_get(obj);
1614 if (!wd) return NULL;
1618 EAPI Elm_List_Item *
1619 elm_list_selected_item_get(const Evas_Object *obj)
1621 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1622 Widget_Data *wd = elm_widget_data_get(obj);
1623 if (!wd) return NULL;
1624 if (wd->selected) return wd->selected->data;
1628 EAPI const Eina_List *
1629 elm_list_selected_items_get(const Evas_Object *obj)
1631 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1632 Widget_Data *wd = elm_widget_data_get(obj);
1633 if (!wd) return NULL;
1634 return wd->selected;
1638 elm_list_item_separator_set(Elm_List_Item *it, Eina_Bool setting)
1640 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1641 it->is_separator = !!setting;
1645 elm_list_item_separator_get(const Elm_List_Item *it)
1647 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1648 return it->is_separator;
1652 elm_list_item_selected_set(Elm_List_Item *it, Eina_Bool selected)
1654 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1655 Evas_Object *obj = WIDGET(it);
1656 Widget_Data *wd = elm_widget_data_get(obj);
1659 selected = !!selected;
1660 if (it->selected == selected) return;
1662 evas_object_ref(obj);
1669 while (wd->selected)
1670 _item_unselect(wd->selected->data);
1678 _elm_list_unwalk(wd);
1679 evas_object_unref(obj);
1683 elm_list_item_selected_get(const Elm_List_Item *it)
1685 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1686 return it->selected;
1690 elm_list_item_show(Elm_List_Item *it)
1692 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1693 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1694 Evas_Coord bx, by, bw, bh;
1695 Evas_Coord x, y, w, h;
1697 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1698 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1702 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
1706 elm_list_item_bring_in(Elm_List_Item *it)
1708 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1709 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1710 Evas_Coord bx, by, bw, bh;
1711 Evas_Coord x, y, w, h;
1713 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1714 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1718 elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
1722 elm_list_item_del(Elm_List_Item *it)
1724 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1725 Evas_Object *obj = WIDGET(it);
1726 Widget_Data *wd = elm_widget_data_get(obj);
1729 if (it->selected) _item_unselect(it);
1731 if (wd->walking > 0)
1733 if (it->deleted) return;
1734 it->deleted = EINA_TRUE;
1735 wd->to_delete = eina_list_append(wd->to_delete, it);
1739 wd->items = eina_list_remove_list(wd->items, it->node);
1741 evas_object_ref(obj);
1744 elm_widget_item_pre_notify_del(it);
1745 _elm_list_item_free(it);
1747 _elm_list_unwalk(wd);
1748 evas_object_unref(obj);
1752 elm_list_item_del_cb_set(Elm_List_Item *it, Evas_Smart_Cb func)
1754 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1755 elm_widget_item_del_cb_set(it, func);
1759 elm_list_item_data_get(const Elm_List_Item *it)
1761 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1762 return elm_widget_item_data_get(it);
1766 elm_list_item_icon_get(const Elm_List_Item *it)
1768 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1769 if (it->dummy_icon) return NULL;
1774 elm_list_item_icon_set(Elm_List_Item *it, Evas_Object *icon)
1776 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1777 if (it->icon == icon) return;
1778 if ((it->dummy_icon) && (!icon)) return;
1781 evas_object_del(it->icon);
1782 it->dummy_icon = EINA_FALSE;
1786 icon = evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1787 evas_object_color_set(icon, 0, 0, 0, 0);
1788 it->dummy_icon = EINA_TRUE;
1792 evas_object_del(it->icon);
1797 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", icon);
1801 elm_list_item_end_get(const Elm_List_Item *it)
1803 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1804 if (it->dummy_end) return NULL;
1809 elm_list_item_end_set(Elm_List_Item *it, Evas_Object *end)
1811 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1812 if (it->end == end) return;
1813 if ((it->dummy_end) && (!end)) return;
1816 evas_object_del(it->end);
1817 it->dummy_icon = EINA_FALSE;
1821 end = evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1822 evas_object_color_set(end, 0, 0, 0, 0);
1823 it->dummy_end = EINA_TRUE;
1827 evas_object_del(it->end);
1832 edje_object_part_swallow(VIEW(it), "elm.swallow.end", end);
1836 elm_list_item_base_get(const Elm_List_Item *it)
1838 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1843 elm_list_item_label_get(const Elm_List_Item *it)
1845 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1850 elm_list_item_label_set(Elm_List_Item *it, const char *text)
1852 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1853 if (!eina_stringshare_replace(&it->label, text)) return;
1855 edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1858 EAPI Elm_List_Item *
1859 elm_list_item_prev(const Elm_List_Item *it)
1861 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1862 if (it->node->prev) return it->node->prev->data;
1866 EAPI Elm_List_Item *
1867 elm_list_item_next(const Elm_List_Item *it)
1869 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1870 if (it->node->next) return it->node->next->data;
1875 elm_list_item_tooltip_text_set(Elm_List_Item *item, const char *text)
1877 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1878 elm_widget_item_tooltip_text_set(item, text);
1882 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)
1884 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1885 elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
1889 elm_list_item_tooltip_unset(Elm_List_Item *item)
1891 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1892 elm_widget_item_tooltip_unset(item);
1896 elm_list_item_tooltip_style_set(Elm_List_Item *item, const char *style)
1898 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1899 elm_widget_item_tooltip_style_set(item, style);
1903 elm_list_item_tooltip_style_get(const Elm_List_Item *item)
1905 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1906 return elm_widget_item_tooltip_style_get(item);
1910 elm_list_item_cursor_set(Elm_List_Item *item, const char *cursor)
1912 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1913 elm_widget_item_cursor_set(item, cursor);
1917 elm_list_item_cursor_get(const Elm_List_Item *item)
1919 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1920 return elm_widget_item_cursor_get(item);
1924 elm_list_item_cursor_unset(Elm_List_Item *item)
1926 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1927 elm_widget_item_cursor_unset(item);
1931 elm_list_item_cursor_style_set(Elm_List_Item *item, const char *style)
1933 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1934 elm_widget_item_cursor_style_set(item, style);
1938 elm_list_item_cursor_style_get(const Elm_List_Item *item)
1940 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1941 return elm_widget_item_cursor_style_get(item);
1945 elm_list_item_cursor_engine_only_set(Elm_List_Item *item, Eina_Bool engine_only)
1947 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1948 elm_widget_item_cursor_engine_only_set(item, engine_only);
1952 elm_list_item_cursor_engine_only_get(const Elm_List_Item *item)
1954 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1955 return elm_widget_item_cursor_engine_only_get(item);
1959 elm_list_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1961 ELM_CHECK_WIDTYPE(obj, widtype);
1962 Widget_Data *wd = elm_widget_data_get(obj);
1965 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
1969 elm_list_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1971 ELM_CHECK_WIDTYPE(obj, widtype);
1972 Widget_Data *wd = elm_widget_data_get(obj);
1974 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
1978 elm_list_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
1980 ELM_CHECK_WIDTYPE(obj, widtype);
1981 Widget_Data *wd = elm_widget_data_get(obj);
1983 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
1984 (policy_v >= ELM_SCROLLER_POLICY_LAST))
1986 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
1990 elm_list_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
1992 ELM_CHECK_WIDTYPE(obj, widtype);
1993 Widget_Data *wd = elm_widget_data_get(obj);
1994 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
1995 if ((!wd) || (!wd->scr)) return;
1996 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
1997 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
1998 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
2002 elm_list_item_disabled_set(Elm_List_Item *it, Eina_Bool disabled)
2004 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2006 if (it->disabled == disabled)
2009 it->disabled = !!disabled;
2012 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
2014 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
2018 elm_list_item_disabled_get(const Elm_List_Item *it)
2020 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2022 return it->disabled;