1 #include <Elementary.h>
3 #include "els_scroller.h"
7 typedef struct _Widget_Data Widget_Data;
11 Evas_Object *scr, *box, *self;
12 Eina_List *items, *selected, *to_delete;
13 Elm_List_Item *last_selected_item;
16 Evas_Coord minw[2], minh[2];
17 Eina_Bool scr_minw : 1;
18 Eina_Bool scr_minh : 1;
23 } history[SWIPE_MOVES];
25 Eina_Bool fix_pending : 1;
26 Eina_Bool on_hold : 1;
28 Eina_Bool always_select : 1;
29 Eina_Bool longpressed : 1;
30 Eina_Bool wasselected : 1;
39 Evas_Object *icon, *end;
41 Ecore_Timer *long_timer;
42 Ecore_Timer *swipe_timer;
43 Eina_Bool deleted : 1;
44 Eina_Bool disabled : 1;
46 Eina_Bool is_even : 1;
47 Eina_Bool is_separator : 1;
49 Eina_Bool selected : 1;
50 Eina_Bool highlighted : 1;
51 Eina_Bool dummy_icon : 1;
52 Eina_Bool dummy_end : 1;
55 static const char *widtype = NULL;
56 static void _del_hook(Evas_Object *obj);
57 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
58 static void _theme_hook(Evas_Object *obj);
59 static void _sizing_eval(Evas_Object *obj);
60 static void _disable_hook(Evas_Object *obj);
61 static void _on_focus_hook(void *data, Evas_Object *obj);
62 static void _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source);
63 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
64 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
65 static void _fix_items(Evas_Object *obj);
66 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
67 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
68 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
69 static void _edge_left(void *data, Evas_Object *scr, void *event_info);
70 static void _edge_right(void *data, Evas_Object *scr, void *event_info);
71 static void _edge_top(void *data, Evas_Object *scr, void *event_info);
72 static void _edge_bottom(void *data, Evas_Object *scr, void *event_info);
73 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
74 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
75 static Eina_Bool _item_single_select_up(Widget_Data *wd);
76 static Eina_Bool _item_single_select_down(Widget_Data *wd);
77 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
78 Evas_Callback_Type type, void *event_info);
79 static Eina_Bool _deselect_all_items(Widget_Data *wd);
81 static const char SIG_ACTIVATED[] = "activated";
82 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
83 static const char SIG_SELECTED[] = "selected";
84 static const char SIG_UNSELECTED[] = "unselected";
85 static const char SIG_LONGPRESSED[] = "longpressed";
86 static const char SIG_EDGE_TOP[] = "edge,top";
87 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
88 static const char SIG_EDGE_LEFT[] = "edge,left";
89 static const char SIG_EDGE_RIGHT[] = "edge,right";
91 static const Evas_Smart_Cb_Description _signals[] = {
93 {SIG_CLICKED_DOUBLE, ""},
96 {SIG_LONGPRESSED, ""},
98 {SIG_EDGE_BOTTOM, ""},
100 {SIG_EDGE_RIGHT, ""},
104 #define ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ...) \
105 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, __VA_ARGS__); \
108 ERR("ERROR: "#it" has been DELETED.\n"); \
109 return __VA_ARGS__; \
113 _elm_list_item_free(Elm_List_Item *it)
115 evas_object_event_callback_del_full
116 (VIEW(it), EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
117 evas_object_event_callback_del_full
118 (VIEW(it), EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
119 evas_object_event_callback_del_full
120 (VIEW(it), EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, it);
123 evas_object_event_callback_del_full
124 (it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
125 _changed_size_hints, WIDGET(it));
128 evas_object_event_callback_del_full
129 (it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
130 _changed_size_hints, WIDGET(it));
132 eina_stringshare_del(it->label);
134 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
135 if (it->long_timer) ecore_timer_del(it->long_timer);
136 if (it->icon) evas_object_del(it->icon);
137 if (it->end) evas_object_del(it->end);
139 elm_widget_item_del(it);
143 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
145 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
146 Evas_Event_Key_Down *ev = event_info;
147 Widget_Data *wd = elm_widget_data_get(obj);
148 if (!wd) return EINA_FALSE;
149 if (!wd->items) return EINA_FALSE;
150 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
151 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
153 Elm_List_Item *it = NULL;
156 Evas_Coord step_x = 0;
157 Evas_Coord step_y = 0;
160 Evas_Coord page_x = 0;
161 Evas_Coord page_y = 0;
163 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
164 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
165 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
166 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
168 /* TODO: fix logic for horizontal mode */
169 if ((!strcmp(ev->keyname, "Left")) ||
170 (!strcmp(ev->keyname, "KP_Left")))
173 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
174 (_item_multi_select_up(wd)))
175 || (_item_single_select_up(wd))))
177 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
183 else if ((!strcmp(ev->keyname, "Right")) ||
184 (!strcmp(ev->keyname, "KP_Right")))
187 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
188 (_item_multi_select_down(wd)))
189 || (_item_single_select_down(wd))))
191 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
197 else if ((!strcmp(ev->keyname, "Up")) ||
198 (!strcmp(ev->keyname, "KP_Up")))
201 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
202 (_item_multi_select_up(wd)))
203 || (_item_single_select_up(wd))))
205 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
211 else if ((!strcmp(ev->keyname, "Down")) ||
212 (!strcmp(ev->keyname, "KP_Down")))
215 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
216 (_item_multi_select_down(wd)))
217 || (_item_single_select_down(wd))))
219 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
225 else if ((!strcmp(ev->keyname, "Home")) ||
226 (!strcmp(ev->keyname, "KP_Home")))
228 it = eina_list_data_get(wd->items);
229 elm_list_item_bring_in(it);
230 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
233 else if ((!strcmp(ev->keyname, "End")) ||
234 (!strcmp(ev->keyname, "KP_End")))
236 it = eina_list_data_get(eina_list_last(wd->items));
237 elm_list_item_bring_in(it);
238 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
241 else if ((!strcmp(ev->keyname, "Prior")) ||
242 (!strcmp(ev->keyname, "KP_Prior")))
247 x -= -(page_x * v_w) / 100;
254 y -= -(page_y * v_h) / 100;
259 else if ((!strcmp(ev->keyname, "Next")) ||
260 (!strcmp(ev->keyname, "KP_Next")))
265 x += -(page_x * v_w) / 100;
272 y += -(page_y * v_h) / 100;
277 else if (((!strcmp(ev->keyname, "Return")) ||
278 (!strcmp(ev->keyname, "KP_Enter")) ||
279 (!strcmp(ev->keyname, "space")))
280 && (!wd->multi) && (wd->selected))
282 it = elm_list_selected_item_get(obj);
283 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
285 else if (!strcmp(ev->keyname, "Escape"))
287 if (!_deselect_all_items(wd)) return EINA_FALSE;
288 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
291 else return EINA_FALSE;
293 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
294 elm_smart_scroller_child_pos_set(wd->scr, x, y);
299 _translate_hook(Evas_Object *obj)
301 evas_object_smart_callback_call(obj, "language,changed", NULL);
305 _deselect_all_items(Widget_Data *wd)
307 if (!wd->selected) return EINA_FALSE;
309 elm_list_item_selected_set(wd->selected->data, EINA_FALSE);
315 _item_multi_select_up(Widget_Data *wd)
317 if (!wd->selected) return EINA_FALSE;
318 if (!wd->multi) return EINA_FALSE;
320 Elm_List_Item *prev = elm_list_item_prev(wd->last_selected_item);
321 if (!prev) return EINA_TRUE;
323 if (elm_list_item_selected_get(prev))
325 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
326 wd->last_selected_item = prev;
327 elm_list_item_show(wd->last_selected_item);
331 elm_list_item_selected_set(prev, EINA_TRUE);
332 elm_list_item_show(prev);
338 _item_multi_select_down(Widget_Data *wd)
340 if (!wd->selected) return EINA_FALSE;
341 if (!wd->multi) return EINA_FALSE;
343 Elm_List_Item *next = elm_list_item_next(wd->last_selected_item);
344 if (!next) return EINA_TRUE;
346 if (elm_list_item_selected_get(next))
348 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
349 wd->last_selected_item = next;
350 elm_list_item_show(wd->last_selected_item);
354 elm_list_item_selected_set(next, EINA_TRUE);
355 elm_list_item_show(next);
361 _item_single_select_up(Widget_Data *wd)
365 if (!wd->selected) prev = eina_list_data_get(eina_list_last(wd->items));
366 else prev = elm_list_item_prev(wd->last_selected_item);
368 if (!prev) return EINA_FALSE;
370 _deselect_all_items(wd);
372 elm_list_item_selected_set(prev, EINA_TRUE);
373 elm_list_item_show(prev);
378 _item_single_select_down(Widget_Data *wd)
382 if (!wd->selected) next = eina_list_data_get(wd->items);
383 else next = elm_list_item_next(wd->last_selected_item);
385 if (!next) return EINA_FALSE;
387 _deselect_all_items(wd);
389 elm_list_item_selected_set(next, EINA_TRUE);
390 elm_list_item_show(next);
395 _elm_list_process_deletions(Widget_Data *wd)
399 wd->walking++; // avoid nested deletion and also _sub_del() fix_items
401 EINA_LIST_FREE(wd->to_delete, it)
403 elm_widget_item_pre_notify_del(it);
405 wd->items = eina_list_remove_list(wd->items, it->node);
406 _elm_list_item_free(it);
413 _elm_list_walk(Widget_Data *wd)
417 ERR("ERROR: walking was negative. fixed!\n");
424 _elm_list_unwalk(Widget_Data *wd)
429 ERR("ERROR: walking became negative. fixed!\n");
437 _elm_list_process_deletions(wd);
441 wd->fix_pending = EINA_FALSE;
442 _fix_items(wd->self);
443 _sizing_eval(wd->self);
448 _del_pre_hook(Evas_Object *obj)
450 Widget_Data *wd = elm_widget_data_get(obj);
453 evas_object_event_callback_del(wd->scr,
454 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
455 _changed_size_hints);
456 evas_object_event_callback_del(wd->box,
457 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
458 _changed_size_hints);
462 _del_hook(Evas_Object *obj)
464 Widget_Data *wd = elm_widget_data_get(obj);
470 ERR("ERROR: list deleted while walking.\n");
473 EINA_LIST_FOREACH(wd->items, n, it) elm_widget_item_pre_notify_del(it);
474 _elm_list_unwalk(wd);
476 ERR("ERROR: leaking nodes!\n");
478 EINA_LIST_FREE(wd->items, it) _elm_list_item_free(it);
479 eina_list_free(wd->selected);
484 _show_region_hook(void *data, Evas_Object *obj)
486 Widget_Data *wd = elm_widget_data_get(data);
487 Evas_Coord x, y, w, h;
489 elm_widget_show_region_get(obj, &x, &y, &w, &h);
490 elm_smart_scroller_child_region_set(wd->scr, x, y, w, h);
494 _disable_hook(Evas_Object *obj)
496 Widget_Data *wd = elm_widget_data_get(obj);
498 if (elm_widget_disabled_get(obj))
500 _signal_emit_hook(obj, "elm,state,disabled", "elm");
501 elm_widget_scroll_freeze_push(obj);
502 elm_widget_scroll_hold_push(obj);
503 /* FIXME: if we get to have a way to only un-highlight items
504 * in the future, keeping them selected... */
505 _deselect_all_items(wd);
509 _signal_emit_hook(obj, "elm,state,enabled", "elm");
510 elm_widget_scroll_freeze_pop(obj);
511 elm_widget_scroll_hold_pop(obj);
516 _sizing_eval(Evas_Object *obj)
519 Widget_Data *wd = elm_widget_data_get(obj);
521 Evas_Coord vw, vh, minw, minh, maxw, maxh, w, h, vmw, vmh;
524 evas_object_size_hint_min_get(wd->box, &minw, &minh);
525 evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
526 evas_object_size_hint_weight_get(wd->box, &xw, &yw);
527 if (!wd->scr) return;
528 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
531 if ((minw > 0) && (vw < minw)) vw = minw;
532 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
534 else if (minw > 0) vw = minw;
537 if ((minh > 0) && (vh < minh)) vh = minh;
538 else if ((maxh > 0) && (vh > maxh)) vh = maxh;
540 else if (minh > 0) vh = minh;
541 evas_object_resize(wd->box, vw, vh);
544 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
546 if (wd->scr_minw) w = vmw + minw;
547 if (wd->scr_minh) h = vmh + minh;
549 evas_object_size_hint_max_get(obj, &maxw, &maxh);
550 if ((maxw > 0) && (w > maxw))
552 if ((maxh > 0) && (h > maxh))
555 evas_object_size_hint_min_set(obj, w, h);
559 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
561 Widget_Data *wd = elm_widget_data_get(obj);
562 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
567 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
569 Widget_Data *wd = elm_widget_data_get(obj);
570 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
571 emission, source, func_cb, data);
575 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
577 Widget_Data *wd = elm_widget_data_get(obj);
578 edje_object_signal_callback_del_full(
579 elm_smart_scroller_edje_object_get(wd->scr),
580 emission, source, func_cb, data);
584 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
586 Widget_Data *wd = elm_widget_data_get(obj);
592 elm_smart_scroller_mirrored_set(wd->scr, rtl);
594 EINA_LIST_FOREACH(wd->items, n, it)
595 edje_object_mirrored_set(VIEW(it), rtl);
599 _theme_hook(Evas_Object *obj)
601 Widget_Data *wd = elm_widget_data_get(obj);
606 _elm_widget_mirrored_reload(obj);
607 _mirrored_set(obj, elm_widget_mirrored_get(obj));
614 elm_smart_scroller_object_theme_set(obj, wd->scr, "list", "base",
615 elm_widget_style_get(obj));
616 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
617 edj = elm_smart_scroller_edje_object_get(wd->scr);
618 str = edje_object_data_get(edj, "focus_highlight");
619 if ((str) && (!strcmp(str, "on")))
620 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
622 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
623 elm_object_style_set(wd->scr, elm_widget_style_get(obj));
625 EINA_LIST_FOREACH(wd->items, n, it)
627 edje_object_scale_set(VIEW(it), elm_widget_scale_get(obj) * _elm_config->scale);
635 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
637 Widget_Data *wd = elm_widget_data_get(obj);
639 if (elm_widget_focus_get(obj))
641 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
642 evas_object_focus_set(wd->self, EINA_TRUE);
644 if ((wd->selected) && (!wd->last_selected_item))
645 wd->last_selected_item = eina_list_data_get(wd->selected);
649 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
650 evas_object_focus_set(wd->self, EINA_FALSE);
655 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
657 Widget_Data *wd = elm_widget_data_get(data);
664 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
666 Widget_Data *wd = elm_widget_data_get(obj);
667 Evas_Object *sub = event_info;
673 if ((sub == wd->box) || (sub == wd->scr)) return;
675 EINA_LIST_FOREACH(wd->items, l, it)
677 if ((sub == it->icon) || (sub == it->end))
679 if (it->icon == sub) it->icon = NULL;
680 if (it->end == sub) it->end = NULL;
681 evas_object_event_callback_del_full
682 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints,
690 wd->fix_pending = EINA_TRUE;
697 _item_highlight(Elm_List_Item *it)
699 Evas_Object *obj = WIDGET(it);
700 Widget_Data *wd = elm_widget_data_get(obj);
701 const char *selectraise;
704 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
705 if ((it->highlighted) || (it->disabled)) return;
707 evas_object_ref(obj);
710 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
711 selectraise = edje_object_data_get(VIEW(it), "selectraise");
712 if ((selectraise) && (!strcmp(selectraise, "on")))
713 evas_object_raise(VIEW(it));
714 it->highlighted = EINA_TRUE;
716 _elm_list_unwalk(wd);
717 evas_object_unref(obj);
721 _item_select(Elm_List_Item *it)
723 Evas_Object *obj = WIDGET(it);
724 Widget_Data *wd = elm_widget_data_get(obj);
727 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
728 if (it->disabled) return;
731 if (wd->always_select) goto call;
734 it->selected = EINA_TRUE;
735 wd->selected = eina_list_append(wd->selected, it);
738 evas_object_ref(obj);
741 if (it->func) it->func((void *)it->base.data, WIDGET(it), it);
742 evas_object_smart_callback_call(obj, SIG_SELECTED, it);
743 it->wd->last_selected_item = it;
745 _elm_list_unwalk(wd);
746 evas_object_unref(obj);
750 _item_unselect(Elm_List_Item *it)
752 Evas_Object *obj = WIDGET(it);
753 Widget_Data *wd = elm_widget_data_get(obj);
754 const char *stacking, *selectraise;
757 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
758 if (!it->highlighted) return;
760 evas_object_ref(obj);
763 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
764 stacking = edje_object_data_get(VIEW(it), "stacking");
765 selectraise = edje_object_data_get(VIEW(it), "selectraise");
766 if ((selectraise) && (!strcmp(selectraise, "on")))
768 if ((stacking) && (!strcmp(stacking, "below")))
769 evas_object_lower(VIEW(it));
771 it->highlighted = EINA_FALSE;
774 it->selected = EINA_FALSE;
775 wd->selected = eina_list_remove(wd->selected, it);
776 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
779 _elm_list_unwalk(wd);
780 evas_object_unref(obj);
784 _swipe_cancel(void *data)
786 Elm_List_Item *it = data;
787 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
789 if (!wd) return ECORE_CALLBACK_CANCEL;
790 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
791 wd->swipe = EINA_FALSE;
793 return ECORE_CALLBACK_RENEW;
797 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
799 Elm_List_Item *it = data;
800 Evas_Object *obj2 = WIDGET(it);
801 Widget_Data *wd = elm_widget_data_get(obj2);
802 Evas_Event_Mouse_Move *ev = event_info;
805 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
807 evas_object_ref(obj2);
810 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
814 wd->on_hold = EINA_TRUE;
817 ecore_timer_del(it->long_timer);
818 it->long_timer = NULL;
820 if (!wd->wasselected)
823 if (wd->movements == SWIPE_MOVES) wd->swipe = EINA_TRUE;
826 wd->history[wd->movements].x = ev->cur.canvas.x;
827 wd->history[wd->movements].y = ev->cur.canvas.y;
828 if (abs((wd->history[wd->movements].x - wd->history[0].x)) > 40)
829 wd->swipe = EINA_TRUE;
835 _elm_list_unwalk(wd);
836 evas_object_unref(obj2);
840 _edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
842 Evas_Object *obj = data;
843 evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
847 _edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
849 Evas_Object *obj = data;
850 evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
854 _edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
856 Evas_Object *obj = data;
857 evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
861 _edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
863 Evas_Object *obj = data;
864 evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
868 _long_press(void *data)
870 Elm_List_Item *it = data;
871 Evas_Object *obj = WIDGET(it);
872 Widget_Data *wd = elm_widget_data_get(obj);
876 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
877 it->long_timer = NULL;
878 if (it->disabled) goto end;
880 wd->longpressed = EINA_TRUE;
881 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
884 return ECORE_CALLBACK_CANCEL;
888 _swipe(Elm_List_Item *it)
891 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
893 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
895 wd->swipe = EINA_FALSE;
896 for (i = 0; i < wd->movements; i++)
898 sum += wd->history[i].x;
899 if (abs(wd->history[0].y - wd->history[i].y) > 10) return;
902 sum /= wd->movements;
903 if (abs(sum - wd->history[0].x) <= 10) return;
904 evas_object_smart_callback_call(WIDGET(it), "swipe", it);
908 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
910 Elm_List_Item *it = data;
911 Evas_Object *obj2 = WIDGET(it);
912 Widget_Data *wd = elm_widget_data_get(obj2);
913 Evas_Event_Mouse_Down *ev = event_info;
916 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
917 if (ev->button != 1) return;
918 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
919 else wd->on_hold = EINA_FALSE;
920 if (wd->on_hold) return;
921 wd->wasselected = it->selected;
923 evas_object_ref(obj2);
927 wd->longpressed = EINA_FALSE;
928 if (it->long_timer) ecore_timer_del(it->long_timer);
929 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, it);
930 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
931 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
932 /* Always call the callbacks last - the user may delete our context! */
933 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
935 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
936 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
938 wd->swipe = EINA_FALSE;
941 _elm_list_unwalk(wd);
942 evas_object_unref(obj2);
946 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
948 Elm_List_Item *it = data;
949 Evas_Object *obj2 = WIDGET(it);
950 Widget_Data *wd = elm_widget_data_get(obj2);
951 Evas_Event_Mouse_Up *ev = event_info;
954 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
955 if (ev->button != 1) return;
956 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
957 else wd->on_hold = EINA_FALSE;
958 wd->longpressed = EINA_FALSE;
961 ecore_timer_del(it->long_timer);
962 it->long_timer = NULL;
966 ecore_timer_del(it->swipe_timer);
967 it->swipe_timer = NULL;
971 if (wd->swipe) _swipe(data);
972 wd->on_hold = EINA_FALSE;
977 if (!wd->wasselected) _item_unselect(it);
984 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
986 evas_object_ref(obj2);
996 else _item_unselect(it);
1002 while (wd->selected)
1003 _item_unselect(wd->selected->data);
1004 _item_highlight(it);
1009 const Eina_List *l, *l_next;
1012 EINA_LIST_FOREACH_SAFE(wd->selected, l, l_next, it2)
1013 if (it2 != it) _item_unselect(it2);
1014 _item_highlight(it);
1019 _elm_list_unwalk(wd);
1020 evas_object_unref(obj2);
1023 static Elm_List_Item *
1024 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1026 Widget_Data *wd = elm_widget_data_get(obj);
1029 if (!wd) return NULL;
1030 it = elm_widget_item_new(obj, Elm_List_Item);
1032 it->label = eina_stringshare_add(label);
1036 it->base.data = data;
1037 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
1038 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(obj));
1039 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1041 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1043 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1045 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1046 evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1049 elm_widget_sub_object_add(obj, it->icon);
1050 evas_object_event_callback_add(it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1051 _changed_size_hints, obj);
1055 elm_widget_sub_object_add(obj, it->end);
1056 evas_object_event_callback_add(it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1057 _changed_size_hints, obj);
1063 _elm_list_mode_set_internal(Widget_Data *wd)
1068 if (wd->mode == ELM_LIST_LIMIT)
1072 wd->scr_minw = EINA_TRUE;
1073 wd->scr_minh = EINA_FALSE;
1077 wd->scr_minw = EINA_FALSE;
1078 wd->scr_minh = EINA_TRUE;
1081 else if (wd->mode == ELM_LIST_EXPAND)
1083 wd->scr_minw = EINA_TRUE;
1084 wd->scr_minh = EINA_TRUE;
1088 wd->scr_minw = EINA_FALSE;
1089 wd->scr_minh = EINA_FALSE;
1092 _sizing_eval(wd->self);
1096 _fix_items(Evas_Object *obj)
1098 Widget_Data *wd = elm_widget_data_get(obj);
1102 Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
1105 const char *style = elm_widget_style_get(obj);
1106 const char *it_plain = wd->h_mode ? "h_item" : "item";
1107 const char *it_odd = wd->h_mode ? "h_item_odd" : "item_odd";
1108 const char *it_compress = wd->h_mode ? "h_item_compress" : "item_compress";
1109 const char *it_compress_odd = wd->h_mode ? "h_item_compress_odd" : "item_compress_odd";
1113 wd->fix_pending = EINA_TRUE;
1117 evas_object_ref(obj);
1118 _elm_list_walk(wd); // watch out "return" before unwalk!
1120 EINA_LIST_FOREACH(wd->items, l, it)
1122 if (it->deleted) continue;
1125 evas_object_size_hint_min_get(it->icon, &mw, &mh);
1126 if (mw > minw[0]) minw[0] = mw;
1127 if (mh > minh[0]) minh[0] = mh;
1131 evas_object_size_hint_min_get(it->end, &mw, &mh);
1132 if (mw > minw[1]) minw[1] = mw;
1133 if (mh > minh[1]) minh[1] = mh;
1137 if ((minw[0] != wd->minw[0]) || (minw[1] != wd->minw[1]) ||
1138 (minw[0] != wd->minh[0]) || (minh[1] != wd->minh[1]))
1140 wd->minw[0] = minw[0];
1141 wd->minw[1] = minw[1];
1142 wd->minh[0] = minh[0];
1143 wd->minh[1] = minh[1];
1147 EINA_LIST_FOREACH(wd->items, l, it)
1153 if ((it->even != it->is_even) || (!it->fixed) || (redo))
1155 const char *stacking;
1157 /* FIXME: separators' themes seem to be b0rked */
1158 if (it->is_separator)
1159 _elm_theme_object_set(obj, VIEW(it), "separator",
1160 wd->h_mode ? "horizontal" : "vertical",
1162 else if (wd->mode == ELM_LIST_COMPRESS)
1165 _elm_theme_object_set(obj, VIEW(it), "list",
1166 it_compress, style);
1168 _elm_theme_object_set(obj, VIEW(it), "list",
1169 it_compress_odd, style);
1174 _elm_theme_object_set(obj, VIEW(it), "list", it_plain,
1177 _elm_theme_object_set(obj, VIEW(it), "list", it_odd,
1180 stacking = edje_object_data_get(VIEW(it), "stacking");
1183 if (!strcmp(stacking, "below"))
1184 evas_object_lower(VIEW(it));
1185 else if (!strcmp(stacking, "above"))
1186 evas_object_raise(VIEW(it));
1188 edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1190 if ((!it->icon) && (minh[0] > 0))
1192 it->icon = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1193 evas_object_color_set(it->icon, 0, 0, 0, 0);
1194 it->dummy_icon = EINA_TRUE;
1196 if ((!it->end) && (minh[1] > 0))
1198 it->end = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1199 evas_object_color_set(it->end, 0, 0, 0, 0);
1200 it->dummy_end = EINA_TRUE;
1204 evas_object_size_hint_min_set(it->icon, minw[0], minh[0]);
1205 evas_object_size_hint_max_set(it->icon, 99999, 99999);
1206 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
1210 evas_object_size_hint_min_set(it->end, minw[1], minh[1]);
1211 evas_object_size_hint_max_set(it->end, 99999, 99999);
1212 edje_object_part_swallow(VIEW(it), "elm.swallow.end", it->end);
1216 // this may call up user and it may modify the list item
1217 // but we're safe as we're flagged as walking.
1218 // just don't process further
1219 edje_object_message_signal_process(VIEW(it));
1223 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1224 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
1225 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1226 evas_object_size_hint_min_set(VIEW(it), mw, mh);
1227 evas_object_show(VIEW(it));
1229 if ((it->selected) || (it->highlighted))
1231 const char *selectraise;
1233 // this may call up user and it may modify the list item
1234 // but we're safe as we're flagged as walking.
1235 // just don't process further
1236 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1240 selectraise = edje_object_data_get(VIEW(it), "selectraise");
1241 if ((selectraise) && (!strcmp(selectraise, "on")))
1242 evas_object_raise(VIEW(it));
1245 edje_object_signal_emit(VIEW(it), "elm,state,disabled",
1248 it->fixed = EINA_TRUE;
1249 it->is_even = it->even;
1255 evas_object_size_hint_min_get(wd->box, &mw, &mh);
1257 _elm_list_mode_set_internal(wd);
1259 _elm_list_unwalk(wd);
1260 evas_object_unref(obj);
1264 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1266 Widget_Data *wd = elm_widget_data_get(obj);
1269 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
1273 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1275 Widget_Data *wd = elm_widget_data_get(obj);
1278 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1282 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1284 Widget_Data *wd = elm_widget_data_get(obj);
1287 elm_smart_scroller_freeze_set(wd->scr, EINA_TRUE);
1291 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1293 Widget_Data *wd = elm_widget_data_get(obj);
1296 elm_smart_scroller_freeze_set(wd->scr, EINA_FALSE);
1300 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1306 elm_list_add(Evas_Object *parent)
1311 Evas_Coord minw, minh;
1313 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1315 ELM_SET_WIDTYPE(widtype, "list");
1316 elm_widget_type_set(obj, "list");
1317 elm_widget_sub_object_add(parent, obj);
1318 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1319 elm_widget_data_set(obj, wd);
1320 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1321 elm_widget_del_hook_set(obj, _del_hook);
1322 elm_widget_theme_hook_set(obj, _theme_hook);
1323 elm_widget_disable_hook_set(obj, _disable_hook);
1324 elm_widget_can_focus_set(obj, EINA_TRUE);
1325 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1326 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1327 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1328 elm_widget_event_hook_set(obj, _event_hook);
1329 elm_widget_translate_hook_set(obj, _translate_hook);
1332 wd->scr = elm_smart_scroller_add(e);
1333 elm_smart_scroller_widget_set(wd->scr, obj);
1334 elm_widget_resize_object_set(obj, wd->scr);
1335 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1336 _changed_size_hints, obj);
1337 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
1338 evas_object_size_hint_min_set(obj, minw, minh);
1339 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1341 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
1342 _elm_config->thumbscroll_bounce_enable);
1344 wd->box = elm_box_add(parent);
1345 elm_box_homogeneous_set(wd->box, 1);
1346 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1347 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1348 elm_widget_on_show_region_hook_set(wd->box, _show_region_hook, obj);
1349 elm_widget_sub_object_add(obj, wd->box);
1350 elm_smart_scroller_child_set(wd->scr, wd->box);
1351 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1352 _changed_size_hints, obj);
1354 evas_object_show(wd->box);
1358 wd->mode = ELM_LIST_SCROLL;
1360 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1361 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1362 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1363 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
1365 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1366 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1367 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1368 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1369 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1371 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1373 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1378 EAPI Elm_List_Item *
1379 elm_list_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1381 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1382 Widget_Data *wd = elm_widget_data_get(obj);
1383 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1385 wd->items = eina_list_append(wd->items, it);
1386 it->node = eina_list_last(wd->items);
1387 elm_box_pack_end(wd->box, VIEW(it));
1391 EAPI Elm_List_Item *
1392 elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1394 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1395 Widget_Data *wd = elm_widget_data_get(obj);
1396 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1398 wd->items = eina_list_prepend(wd->items, it);
1399 it->node = wd->items;
1400 elm_box_pack_start(wd->box, VIEW(it));
1404 EAPI Elm_List_Item *
1405 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)
1410 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
1411 if (!before->node) return NULL;
1412 ELM_LIST_ITEM_CHECK_DELETED_RETURN(before, NULL);
1414 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1415 wd = elm_widget_data_get(obj);
1416 if (!wd) return NULL;
1417 it = _item_new(obj, label, icon, end, func, data);
1418 wd->items = eina_list_prepend_relative_list(wd->items, it, before->node);
1419 it->node = before->node->prev;
1420 elm_box_pack_before(wd->box, VIEW(it), VIEW(before));
1424 EAPI Elm_List_Item *
1425 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)
1430 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
1431 if (!after->node) return NULL;
1432 ELM_LIST_ITEM_CHECK_DELETED_RETURN(after, NULL);
1434 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1435 wd = elm_widget_data_get(obj);
1436 if (!wd) return NULL;
1437 it = _item_new(obj, label, icon, end, func, data);
1438 wd->items = eina_list_append_relative_list(wd->items, it, after->node);
1439 it->node = after->node->next;
1440 elm_box_pack_after(wd->box, VIEW(it), VIEW(after));
1444 EAPI Elm_List_Item *
1445 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)
1447 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1448 Widget_Data *wd = elm_widget_data_get(obj);
1449 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1452 wd->items = eina_list_sorted_insert(wd->items, cmp_func, it);
1453 l = eina_list_data_find_list(wd->items, it);
1454 l = eina_list_next(l);
1457 it->node = eina_list_last(wd->items);
1458 elm_box_pack_end(wd->box, VIEW(it));
1462 Elm_List_Item *before = eina_list_data_get(l);
1463 it->node = before->node->prev;
1464 elm_box_pack_before(wd->box, VIEW(it), VIEW(before));
1470 elm_list_clear(Evas_Object *obj)
1472 ELM_CHECK_WIDTYPE(obj, widtype);
1473 Widget_Data *wd = elm_widget_data_get(obj);
1477 if (!wd->items) return;
1479 eina_list_free(wd->selected);
1480 wd->selected = NULL;
1482 if (wd->walking > 0)
1486 EINA_LIST_FOREACH(wd->items, n, it)
1488 if (it->deleted) continue;
1489 it->deleted = EINA_TRUE;
1490 wd->to_delete = eina_list_append(wd->to_delete, it);
1495 evas_object_ref(obj);
1498 EINA_LIST_FREE(wd->items, it)
1500 elm_widget_item_pre_notify_del(it);
1501 _elm_list_item_free(it);
1504 _elm_list_unwalk(wd);
1508 evas_object_unref(obj);
1512 elm_list_go(Evas_Object *obj)
1514 ELM_CHECK_WIDTYPE(obj, widtype);
1515 Widget_Data *wd = elm_widget_data_get(obj);
1521 elm_list_multi_select_set(Evas_Object *obj, Eina_Bool multi)
1523 ELM_CHECK_WIDTYPE(obj, widtype);
1524 Widget_Data *wd = elm_widget_data_get(obj);
1530 elm_list_multi_select_get(const Evas_Object *obj)
1532 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1533 Widget_Data *wd = elm_widget_data_get(obj);
1534 if (!wd) return EINA_FALSE;
1539 elm_list_mode_set(Evas_Object *obj, Elm_List_Mode mode)
1541 ELM_CHECK_WIDTYPE(obj, widtype);
1545 wd = elm_widget_data_get(obj);
1548 if (wd->mode == mode)
1552 _elm_list_mode_set_internal(wd);
1556 elm_list_mode_get(const Evas_Object *obj)
1558 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
1559 Widget_Data *wd = elm_widget_data_get(obj);
1560 if (!wd) return ELM_LIST_LAST;
1565 elm_list_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1567 ELM_CHECK_WIDTYPE(obj, widtype);
1570 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1572 wd = elm_widget_data_get(obj);
1576 if (wd->h_mode == horizontal)
1579 wd->h_mode = horizontal;
1580 elm_box_horizontal_set(wd->box, horizontal);
1584 evas_object_size_hint_weight_set(wd->box, 0.0, EVAS_HINT_EXPAND);
1585 evas_object_size_hint_align_set(wd->box, 0.0, EVAS_HINT_FILL);
1586 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1590 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1591 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1592 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, bounce);
1595 _elm_list_mode_set_internal(wd);
1599 elm_list_horizontal_get(const Evas_Object *obj)
1601 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1605 wd = elm_widget_data_get(obj);
1613 elm_list_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
1615 ELM_CHECK_WIDTYPE(obj, widtype);
1616 Widget_Data *wd = elm_widget_data_get(obj);
1618 wd->always_select = always_select;
1622 elm_list_always_select_mode_get(const Evas_Object *obj)
1624 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1625 Widget_Data *wd = elm_widget_data_get(obj);
1626 if (!wd) return EINA_FALSE;
1627 return wd->always_select;
1630 EAPI const Eina_List *
1631 elm_list_items_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;
1639 EAPI Elm_List_Item *
1640 elm_list_selected_item_get(const Evas_Object *obj)
1642 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1643 Widget_Data *wd = elm_widget_data_get(obj);
1644 if (!wd) return NULL;
1645 if (wd->selected) return wd->selected->data;
1649 EAPI const Eina_List *
1650 elm_list_selected_items_get(const Evas_Object *obj)
1652 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1653 Widget_Data *wd = elm_widget_data_get(obj);
1654 if (!wd) return NULL;
1655 return wd->selected;
1659 elm_list_item_separator_set(Elm_List_Item *it, Eina_Bool setting)
1661 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1662 it->is_separator = !!setting;
1666 elm_list_item_separator_get(const Elm_List_Item *it)
1668 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1669 return it->is_separator;
1674 elm_list_item_selected_set(Elm_List_Item *it, Eina_Bool selected)
1676 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1677 Evas_Object *obj = WIDGET(it);
1678 Widget_Data *wd = elm_widget_data_get(obj);
1681 selected = !!selected;
1682 if (it->selected == selected) return;
1684 evas_object_ref(obj);
1691 while (wd->selected)
1692 _item_unselect(wd->selected->data);
1694 _item_highlight(it);
1700 _elm_list_unwalk(wd);
1701 evas_object_unref(obj);
1705 elm_list_item_selected_get(const Elm_List_Item *it)
1707 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1708 return it->selected;
1712 elm_list_item_show(Elm_List_Item *it)
1714 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1715 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1716 Evas_Coord bx, by, bw, bh;
1717 Evas_Coord x, y, w, h;
1719 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1720 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1724 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
1728 elm_list_item_bring_in(Elm_List_Item *it)
1730 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1731 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1732 Evas_Coord bx, by, bw, bh;
1733 Evas_Coord x, y, w, h;
1735 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1736 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1740 elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
1744 elm_list_item_del(Elm_List_Item *it)
1746 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1747 Evas_Object *obj = WIDGET(it);
1748 Widget_Data *wd = elm_widget_data_get(obj);
1751 if (it->selected) _item_unselect(it);
1753 if (wd->walking > 0)
1755 if (it->deleted) return;
1756 it->deleted = EINA_TRUE;
1757 wd->to_delete = eina_list_append(wd->to_delete, it);
1761 wd->items = eina_list_remove_list(wd->items, it->node);
1763 evas_object_ref(obj);
1766 elm_widget_item_pre_notify_del(it);
1767 _elm_list_item_free(it);
1769 _elm_list_unwalk(wd);
1770 evas_object_unref(obj);
1774 elm_list_item_del_cb_set(Elm_List_Item *it, Evas_Smart_Cb func)
1776 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1777 elm_widget_item_del_cb_set(it, func);
1781 elm_list_item_data_get(const Elm_List_Item *it)
1783 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1784 return elm_widget_item_data_get(it);
1788 elm_list_item_icon_get(const Elm_List_Item *it)
1790 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1791 if (it->dummy_icon) return NULL;
1796 elm_list_item_icon_set(Elm_List_Item *it, Evas_Object *icon)
1798 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1799 if (it->icon == icon) return;
1800 if ((it->dummy_icon) && (!icon)) return;
1803 evas_object_del(it->icon);
1804 it->dummy_icon = EINA_FALSE;
1808 icon = evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1809 evas_object_color_set(icon, 0, 0, 0, 0);
1810 it->dummy_icon = EINA_TRUE;
1814 evas_object_del(it->icon);
1819 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", icon);
1823 elm_list_item_end_get(const Elm_List_Item *it)
1825 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1826 if (it->dummy_end) return NULL;
1831 elm_list_item_end_set(Elm_List_Item *it, Evas_Object *end)
1833 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1834 if (it->end == end) return;
1835 if ((it->dummy_end) && (!end)) return;
1838 evas_object_del(it->end);
1839 it->dummy_icon = EINA_FALSE;
1843 end = evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1844 evas_object_color_set(end, 0, 0, 0, 0);
1845 it->dummy_end = EINA_TRUE;
1849 evas_object_del(it->end);
1854 edje_object_part_swallow(VIEW(it), "elm.swallow.end", end);
1858 elm_list_item_base_get(const Elm_List_Item *it)
1860 return elm_list_item_object_get(it);
1864 elm_list_item_object_get(const Elm_List_Item *it)
1866 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1871 elm_list_item_label_get(const Elm_List_Item *it)
1873 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1878 elm_list_item_label_set(Elm_List_Item *it, const char *text)
1880 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1881 if (!eina_stringshare_replace(&it->label, text)) return;
1883 edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1886 EAPI Elm_List_Item *
1887 elm_list_item_prev(const Elm_List_Item *it)
1889 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1890 if (it->node->prev) return it->node->prev->data;
1894 EAPI Elm_List_Item *
1895 elm_list_item_next(const Elm_List_Item *it)
1897 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1898 if (it->node->next) return it->node->next->data;
1903 elm_list_item_tooltip_text_set(Elm_List_Item *item, const char *text)
1905 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1906 elm_widget_item_tooltip_text_set(item, text);
1910 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)
1912 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1913 elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
1917 elm_list_item_tooltip_unset(Elm_List_Item *item)
1919 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1920 elm_widget_item_tooltip_unset(item);
1924 elm_list_item_tooltip_window_mode_set(Elm_List_Item *item, Eina_Bool disable)
1926 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1927 return elm_widget_item_tooltip_window_mode_set(item, disable);
1931 elm_list_item_tooltip_window_mode_get(const Elm_List_Item *item)
1933 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1934 return elm_widget_item_tooltip_window_mode_get(item);
1938 elm_list_item_tooltip_style_set(Elm_List_Item *item, const char *style)
1940 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1941 elm_widget_item_tooltip_style_set(item, style);
1945 elm_list_item_tooltip_style_get(const Elm_List_Item *item)
1947 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1948 return elm_widget_item_tooltip_style_get(item);
1952 elm_list_item_cursor_set(Elm_List_Item *item, const char *cursor)
1954 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1955 elm_widget_item_cursor_set(item, cursor);
1959 elm_list_item_cursor_get(const Elm_List_Item *item)
1961 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1962 return elm_widget_item_cursor_get(item);
1966 elm_list_item_cursor_unset(Elm_List_Item *item)
1968 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1969 elm_widget_item_cursor_unset(item);
1973 elm_list_item_cursor_style_set(Elm_List_Item *item, const char *style)
1975 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1976 elm_widget_item_cursor_style_set(item, style);
1980 elm_list_item_cursor_style_get(const Elm_List_Item *item)
1982 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1983 return elm_widget_item_cursor_style_get(item);
1987 elm_list_item_cursor_engine_only_set(Elm_List_Item *item, Eina_Bool engine_only)
1989 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1990 elm_widget_item_cursor_engine_only_set(item, engine_only);
1994 elm_list_item_cursor_engine_only_get(const Elm_List_Item *item)
1996 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1997 return elm_widget_item_cursor_engine_only_get(item);
2001 elm_list_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
2003 ELM_CHECK_WIDTYPE(obj, widtype);
2004 Widget_Data *wd = elm_widget_data_get(obj);
2007 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2011 elm_list_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
2013 ELM_CHECK_WIDTYPE(obj, widtype);
2014 Widget_Data *wd = elm_widget_data_get(obj);
2016 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
2020 elm_list_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
2022 ELM_CHECK_WIDTYPE(obj, widtype);
2023 Widget_Data *wd = elm_widget_data_get(obj);
2024 if ((!wd) || (!wd->scr)) return;
2025 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
2026 (policy_v >= ELM_SCROLLER_POLICY_LAST))
2028 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
2032 elm_list_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
2034 ELM_CHECK_WIDTYPE(obj, widtype);
2035 Widget_Data *wd = elm_widget_data_get(obj);
2036 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
2037 if ((!wd) || (!wd->scr)) return;
2038 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
2039 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
2040 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
2044 elm_list_item_disabled_set(Elm_List_Item *it, Eina_Bool disabled)
2046 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2048 if (it->disabled == disabled)
2051 it->disabled = !!disabled;
2054 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
2056 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
2060 elm_list_item_disabled_get(const Elm_List_Item *it)
2062 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2064 return it->disabled;