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 _translate_hook(Evas_Object *obj)
291 evas_object_smart_callback_call(obj, "language,changed", NULL);
295 _deselect_all_items(Widget_Data *wd)
297 if (!wd->selected) return EINA_FALSE;
299 elm_list_item_selected_set(wd->selected->data, EINA_FALSE);
305 _item_multi_select_up(Widget_Data *wd)
307 if (!wd->selected) return EINA_FALSE;
308 if (!wd->multi) return EINA_FALSE;
310 Elm_List_Item *prev = elm_list_item_prev(wd->last_selected_item);
311 if (!prev) return EINA_TRUE;
313 if (elm_list_item_selected_get(prev))
315 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
316 wd->last_selected_item = prev;
317 elm_list_item_show(wd->last_selected_item);
321 elm_list_item_selected_set(prev, EINA_TRUE);
322 elm_list_item_show(prev);
328 _item_multi_select_down(Widget_Data *wd)
330 if (!wd->selected) return EINA_FALSE;
331 if (!wd->multi) return EINA_FALSE;
333 Elm_List_Item *next = elm_list_item_next(wd->last_selected_item);
334 if (!next) return EINA_TRUE;
336 if (elm_list_item_selected_get(next))
338 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
339 wd->last_selected_item = next;
340 elm_list_item_show(wd->last_selected_item);
344 elm_list_item_selected_set(next, EINA_TRUE);
345 elm_list_item_show(next);
351 _item_single_select_up(Widget_Data *wd)
355 if (!wd->selected) prev = eina_list_data_get(eina_list_last(wd->items));
356 else prev = elm_list_item_prev(wd->last_selected_item);
358 if (!prev) return EINA_FALSE;
360 _deselect_all_items(wd);
362 elm_list_item_selected_set(prev, EINA_TRUE);
363 elm_list_item_show(prev);
368 _item_single_select_down(Widget_Data *wd)
372 if (!wd->selected) next = eina_list_data_get(wd->items);
373 else next = elm_list_item_next(wd->last_selected_item);
375 if (!next) return EINA_FALSE;
377 _deselect_all_items(wd);
379 elm_list_item_selected_set(next, EINA_TRUE);
380 elm_list_item_show(next);
385 _elm_list_process_deletions(Widget_Data *wd)
389 wd->walking++; // avoid nested deletion and also _sub_del() fix_items
391 EINA_LIST_FREE(wd->to_delete, it)
393 elm_widget_item_pre_notify_del(it);
395 wd->items = eina_list_remove_list(wd->items, it->node);
396 _elm_list_item_free(it);
403 _elm_list_walk(Widget_Data *wd)
407 ERR("ERROR: walking was negative. fixed!\n");
414 _elm_list_unwalk(Widget_Data *wd)
419 ERR("ERROR: walking became negative. fixed!\n");
427 _elm_list_process_deletions(wd);
431 wd->fix_pending = EINA_FALSE;
432 _fix_items(wd->self);
433 _sizing_eval(wd->self);
438 _del_pre_hook(Evas_Object *obj)
440 Widget_Data *wd = elm_widget_data_get(obj);
443 evas_object_event_callback_del(wd->scr,
444 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
445 _changed_size_hints);
446 evas_object_event_callback_del(wd->box,
447 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
448 _changed_size_hints);
452 _del_hook(Evas_Object *obj)
454 Widget_Data *wd = elm_widget_data_get(obj);
460 ERR("ERROR: list deleted while walking.\n");
463 EINA_LIST_FOREACH(wd->items, n, it) elm_widget_item_pre_notify_del(it);
464 _elm_list_unwalk(wd);
466 ERR("ERROR: leaking nodes!\n");
468 EINA_LIST_FREE(wd->items, it) _elm_list_item_free(it);
469 eina_list_free(wd->selected);
474 _show_region_hook(void *data, Evas_Object *obj)
476 Widget_Data *wd = elm_widget_data_get(data);
477 Evas_Coord x, y, w, h;
479 elm_widget_show_region_get(obj, &x, &y, &w, &h);
480 elm_smart_scroller_child_region_set(wd->scr, x, y, w, h);
484 _disable_hook(Evas_Object *obj)
486 Widget_Data *wd = elm_widget_data_get(obj);
488 if (elm_widget_disabled_get(obj))
490 _signal_emit_hook(obj, "elm,state,disabled", "elm");
491 elm_widget_scroll_freeze_push(obj);
492 elm_widget_scroll_hold_push(obj);
493 /* FIXME: if we get to have a way to only un-hilight items
494 * in the future, keeping them selected... */
495 _deselect_all_items(wd);
499 _signal_emit_hook(obj, "elm,state,enabled", "elm");
500 elm_widget_scroll_freeze_pop(obj);
501 elm_widget_scroll_hold_pop(obj);
506 _sizing_eval(Evas_Object *obj)
509 Widget_Data *wd = elm_widget_data_get(obj);
511 Evas_Coord vw, vh, minw, minh, maxw, maxh, w, h, vmw, vmh;
514 evas_object_size_hint_min_get(wd->box, &minw, &minh);
515 evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
516 evas_object_size_hint_weight_get(wd->box, &xw, &yw);
517 if (!wd->scr) return;
518 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
521 if ((minw > 0) && (vw < minw)) vw = minw;
522 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
524 else if (minw > 0) vw = minw;
527 if ((minh > 0) && (vh < minh)) vh = minh;
528 else if ((maxh > 0) && (vh > maxh)) vh = maxh;
530 else if (minh > 0) vh = minh;
531 evas_object_resize(wd->box, vw, vh);
534 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
536 if (wd->scr_minw) w = vmw + minw;
537 if (wd->scr_minh) h = vmh + minh;
539 evas_object_size_hint_max_get(obj, &maxw, &maxh);
540 if ((maxw > 0) && (w > maxw))
542 if ((maxh > 0) && (h > maxh))
545 evas_object_size_hint_min_set(obj, w, h);
549 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
551 Widget_Data *wd = elm_widget_data_get(obj);
552 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
557 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
559 Widget_Data *wd = elm_widget_data_get(obj);
560 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
561 emission, source, func_cb, data);
565 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
567 Widget_Data *wd = elm_widget_data_get(obj);
568 edje_object_signal_callback_del_full(
569 elm_smart_scroller_edje_object_get(wd->scr),
570 emission, source, func_cb, data);
574 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
576 Widget_Data *wd = elm_widget_data_get(obj);
582 elm_smart_scroller_mirrored_set(wd->scr, rtl);
584 EINA_LIST_FOREACH(wd->items, n, it)
585 edje_object_mirrored_set(VIEW(it), rtl);
589 _theme_hook(Evas_Object *obj)
591 Widget_Data *wd = elm_widget_data_get(obj);
596 _elm_widget_mirrored_reload(obj);
597 _mirrored_set(obj, elm_widget_mirrored_get(obj));
604 elm_smart_scroller_object_theme_set(obj, wd->scr, "list", "base",
605 elm_widget_style_get(obj));
606 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
607 edj = elm_smart_scroller_edje_object_get(wd->scr);
608 str = edje_object_data_get(edj, "focus_highlight");
609 if ((str) && (!strcmp(str, "on")))
610 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
612 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
613 elm_object_style_set(wd->scr, elm_widget_style_get(obj));
615 EINA_LIST_FOREACH(wd->items, n, it)
617 edje_object_scale_set(VIEW(it), elm_widget_scale_get(obj) * _elm_config->scale);
625 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
627 Widget_Data *wd = elm_widget_data_get(obj);
629 if (elm_widget_focus_get(obj))
631 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
632 evas_object_focus_set(wd->self, EINA_TRUE);
634 if ((wd->selected) && (!wd->last_selected_item))
635 wd->last_selected_item = eina_list_data_get(wd->selected);
639 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
640 evas_object_focus_set(wd->self, EINA_FALSE);
645 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
647 Widget_Data *wd = elm_widget_data_get(data);
654 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
656 Widget_Data *wd = elm_widget_data_get(obj);
657 Evas_Object *sub = event_info;
663 if ((sub == wd->box) || (sub == wd->scr)) return;
665 EINA_LIST_FOREACH(wd->items, l, it)
667 if ((sub == it->icon) || (sub == it->end))
669 if (it->icon == sub) it->icon = NULL;
670 if (it->end == sub) it->end = NULL;
671 evas_object_event_callback_del_full
672 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints,
680 wd->fix_pending = EINA_TRUE;
687 _item_hilight(Elm_List_Item *it)
689 Evas_Object *obj = WIDGET(it);
690 Widget_Data *wd = elm_widget_data_get(obj);
691 const char *selectraise;
694 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
695 if (it->hilighted) return;
697 evas_object_ref(obj);
700 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
701 selectraise = edje_object_data_get(VIEW(it), "selectraise");
702 if ((selectraise) && (!strcmp(selectraise, "on")))
703 evas_object_raise(VIEW(it));
704 it->hilighted = EINA_TRUE;
706 _elm_list_unwalk(wd);
707 evas_object_unref(obj);
711 _item_select(Elm_List_Item *it)
713 Evas_Object *obj = WIDGET(it);
714 Widget_Data *wd = elm_widget_data_get(obj);
717 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
720 if (wd->always_select) goto call;
723 it->selected = EINA_TRUE;
724 wd->selected = eina_list_append(wd->selected, it);
727 evas_object_ref(obj);
730 if (it->func) it->func((void *)it->base.data, WIDGET(it), it);
731 evas_object_smart_callback_call(obj, SIG_SELECTED, it);
732 it->wd->last_selected_item = it;
734 _elm_list_unwalk(wd);
735 evas_object_unref(obj);
739 _item_unselect(Elm_List_Item *it)
741 Evas_Object *obj = WIDGET(it);
742 Widget_Data *wd = elm_widget_data_get(obj);
743 const char *stacking, *selectraise;
746 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
747 if (!it->hilighted) return;
749 evas_object_ref(obj);
752 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
753 stacking = edje_object_data_get(VIEW(it), "stacking");
754 selectraise = edje_object_data_get(VIEW(it), "selectraise");
755 if ((selectraise) && (!strcmp(selectraise, "on")))
757 if ((stacking) && (!strcmp(stacking, "below")))
758 evas_object_lower(VIEW(it));
760 it->hilighted = EINA_FALSE;
763 it->selected = EINA_FALSE;
764 wd->selected = eina_list_remove(wd->selected, it);
765 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
768 _elm_list_unwalk(wd);
769 evas_object_unref(obj);
773 _swipe_cancel(void *data)
775 Elm_List_Item *it = data;
776 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
778 if (!wd) return ECORE_CALLBACK_CANCEL;
779 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
780 wd->swipe = EINA_FALSE;
782 return ECORE_CALLBACK_RENEW;
786 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
788 Elm_List_Item *it = data;
789 Evas_Object *obj2 = WIDGET(it);
790 Widget_Data *wd = elm_widget_data_get(obj2);
791 Evas_Event_Mouse_Move *ev = event_info;
794 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
796 evas_object_ref(obj2);
799 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
803 wd->on_hold = EINA_TRUE;
806 ecore_timer_del(it->long_timer);
807 it->long_timer = NULL;
809 if (!wd->wasselected)
812 if (wd->movements == SWIPE_MOVES) wd->swipe = EINA_TRUE;
815 wd->history[wd->movements].x = ev->cur.canvas.x;
816 wd->history[wd->movements].y = ev->cur.canvas.y;
817 if (abs((wd->history[wd->movements].x - wd->history[0].x)) > 40)
818 wd->swipe = EINA_TRUE;
824 _elm_list_unwalk(wd);
825 evas_object_unref(obj2);
829 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
831 Evas_Object *obj = data;
832 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
836 _scroll_edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
838 Evas_Object *obj = data;
839 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
843 _scroll_edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
845 Evas_Object *obj = data;
846 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
850 _scroll_edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
852 Evas_Object *obj = data;
853 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
857 _long_press(void *data)
859 Elm_List_Item *it = data;
860 Evas_Object *obj = WIDGET(it);
861 Widget_Data *wd = elm_widget_data_get(obj);
865 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
866 it->long_timer = NULL;
867 if (it->disabled) goto end;
869 wd->longpressed = EINA_TRUE;
870 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
873 return ECORE_CALLBACK_CANCEL;
877 _swipe(Elm_List_Item *it)
880 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
882 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
884 wd->swipe = EINA_FALSE;
885 for (i = 0; i < wd->movements; i++)
887 sum += wd->history[i].x;
888 if (abs(wd->history[0].y - wd->history[i].y) > 10) return;
891 sum /= wd->movements;
892 if (abs(sum - wd->history[0].x) <= 10) return;
893 evas_object_smart_callback_call(WIDGET(it), "swipe", it);
897 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
899 Elm_List_Item *it = data;
900 Evas_Object *obj2 = WIDGET(it);
901 Widget_Data *wd = elm_widget_data_get(obj2);
902 Evas_Event_Mouse_Down *ev = event_info;
905 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
906 if (ev->button != 1) return;
907 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
908 else wd->on_hold = EINA_FALSE;
909 if (wd->on_hold) return;
910 wd->wasselected = it->selected;
912 evas_object_ref(obj2);
916 wd->longpressed = EINA_FALSE;
917 if (it->long_timer) ecore_timer_del(it->long_timer);
918 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, it);
919 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
920 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
921 /* Always call the callbacks last - the user may delete our context! */
922 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
923 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
924 wd->swipe = EINA_FALSE;
927 _elm_list_unwalk(wd);
928 evas_object_unref(obj2);
932 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
934 Elm_List_Item *it = data;
935 Evas_Object *obj2 = WIDGET(it);
936 Widget_Data *wd = elm_widget_data_get(obj2);
937 Evas_Event_Mouse_Up *ev = event_info;
940 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
941 if (ev->button != 1) return;
942 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
943 else wd->on_hold = EINA_FALSE;
944 wd->longpressed = EINA_FALSE;
947 ecore_timer_del(it->long_timer);
948 it->long_timer = NULL;
952 ecore_timer_del(it->swipe_timer);
953 it->swipe_timer = NULL;
957 if (wd->swipe) _swipe(data);
958 wd->on_hold = EINA_FALSE;
963 if (!wd->wasselected) _item_unselect(it);
970 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
972 evas_object_ref(obj2);
982 else _item_unselect(it);
989 _item_unselect(wd->selected->data);
995 const Eina_List *l, *l_next;
998 EINA_LIST_FOREACH_SAFE(wd->selected, l, l_next, it2)
999 if (it2 != it) _item_unselect(it2);
1005 _elm_list_unwalk(wd);
1006 evas_object_unref(obj2);
1009 static Elm_List_Item *
1010 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1012 Widget_Data *wd = elm_widget_data_get(obj);
1015 if (!wd) return NULL;
1016 it = elm_widget_item_new(obj, Elm_List_Item);
1018 it->label = eina_stringshare_add(label);
1022 it->base.data = data;
1023 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
1024 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(obj));
1025 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1027 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1029 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1031 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1032 evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1035 elm_widget_sub_object_add(obj, it->icon);
1036 evas_object_event_callback_add(it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1037 _changed_size_hints, obj);
1041 elm_widget_sub_object_add(obj, it->end);
1042 evas_object_event_callback_add(it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1043 _changed_size_hints, obj);
1049 _elm_list_mode_set_internal(Widget_Data *wd)
1054 if (wd->mode == ELM_LIST_LIMIT)
1058 wd->scr_minw = EINA_TRUE;
1059 wd->scr_minh = EINA_FALSE;
1063 wd->scr_minw = EINA_FALSE;
1064 wd->scr_minh = EINA_TRUE;
1067 else if (wd->mode == ELM_LIST_EXPAND)
1069 wd->scr_minw = EINA_TRUE;
1070 wd->scr_minh = EINA_TRUE;
1074 wd->scr_minw = EINA_FALSE;
1075 wd->scr_minh = EINA_FALSE;
1078 _sizing_eval(wd->self);
1082 _fix_items(Evas_Object *obj)
1084 Widget_Data *wd = elm_widget_data_get(obj);
1088 Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
1091 const char *style = elm_widget_style_get(obj);
1092 const char *it_plain = wd->h_mode ? "h_item" : "item";
1093 const char *it_odd = wd->h_mode ? "h_item_odd" : "item_odd";
1094 const char *it_compress = wd->h_mode ? "h_item_compress" : "item_compress";
1095 const char *it_compress_odd = wd->h_mode ? "h_item_compress_odd" : "item_compress_odd";
1099 wd->fix_pending = EINA_TRUE;
1103 evas_object_ref(obj);
1104 _elm_list_walk(wd); // watch out "return" before unwalk!
1106 EINA_LIST_FOREACH(wd->items, l, it)
1108 if (it->deleted) continue;
1111 evas_object_size_hint_min_get(it->icon, &mw, &mh);
1112 if (mw > minw[0]) minw[0] = mw;
1113 if (mh > minh[0]) minh[0] = mh;
1117 evas_object_size_hint_min_get(it->end, &mw, &mh);
1118 if (mw > minw[1]) minw[1] = mw;
1119 if (mh > minh[1]) minh[1] = mh;
1123 if ((minw[0] != wd->minw[0]) || (minw[1] != wd->minw[1]) ||
1124 (minw[0] != wd->minh[0]) || (minh[1] != wd->minh[1]))
1126 wd->minw[0] = minw[0];
1127 wd->minw[1] = minw[1];
1128 wd->minh[0] = minh[0];
1129 wd->minh[1] = minh[1];
1133 EINA_LIST_FOREACH(wd->items, l, it)
1139 if ((it->even != it->is_even) || (!it->fixed) || (redo))
1141 const char *stacking;
1143 /* FIXME: separators' themes seem to be b0rked */
1144 if (it->is_separator)
1145 _elm_theme_object_set(obj, VIEW(it), "separator",
1146 wd->h_mode ? "horizontal" : "vertical",
1148 else if (wd->mode == ELM_LIST_COMPRESS)
1151 _elm_theme_object_set(obj, VIEW(it), "list",
1152 it_compress, style);
1154 _elm_theme_object_set(obj, VIEW(it), "list",
1155 it_compress_odd, style);
1160 _elm_theme_object_set(obj, VIEW(it), "list", it_plain,
1163 _elm_theme_object_set(obj, VIEW(it), "list", it_odd,
1166 stacking = edje_object_data_get(VIEW(it), "stacking");
1169 if (!strcmp(stacking, "below"))
1170 evas_object_lower(VIEW(it));
1171 else if (!strcmp(stacking, "above"))
1172 evas_object_raise(VIEW(it));
1174 edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1176 if ((!it->icon) && (minh[0] > 0))
1178 it->icon = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1179 evas_object_color_set(it->icon, 0, 0, 0, 0);
1180 it->dummy_icon = EINA_TRUE;
1182 if ((!it->end) && (minh[1] > 0))
1184 it->end = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1185 evas_object_color_set(it->end, 0, 0, 0, 0);
1186 it->dummy_end = EINA_TRUE;
1190 evas_object_size_hint_min_set(it->icon, minw[0], minh[0]);
1191 evas_object_size_hint_max_set(it->icon, 99999, 99999);
1192 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
1196 evas_object_size_hint_min_set(it->end, minw[1], minh[1]);
1197 evas_object_size_hint_max_set(it->end, 99999, 99999);
1198 edje_object_part_swallow(VIEW(it), "elm.swallow.end", it->end);
1202 // this may call up user and it may modify the list item
1203 // but we're safe as we're flagged as walking.
1204 // just don't process further
1205 edje_object_message_signal_process(VIEW(it));
1209 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1210 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
1211 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1212 evas_object_size_hint_min_set(VIEW(it), mw, mh);
1213 evas_object_show(VIEW(it));
1215 if ((it->selected) || (it->hilighted))
1217 const char *selectraise;
1219 // this may call up user and it may modify the list item
1220 // but we're safe as we're flagged as walking.
1221 // just don't process further
1222 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1226 selectraise = edje_object_data_get(VIEW(it), "selectraise");
1227 if ((selectraise) && (!strcmp(selectraise, "on")))
1228 evas_object_raise(VIEW(it));
1231 edje_object_signal_emit(VIEW(it), "elm,state,disabled",
1234 it->fixed = EINA_TRUE;
1235 it->is_even = it->even;
1241 evas_object_size_hint_min_get(wd->box, &mw, &mh);
1243 _elm_list_mode_set_internal(wd);
1245 _elm_list_unwalk(wd);
1246 evas_object_unref(obj);
1250 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1252 Widget_Data *wd = elm_widget_data_get(obj);
1255 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
1259 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1261 Widget_Data *wd = elm_widget_data_get(obj);
1264 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1268 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1270 Widget_Data *wd = elm_widget_data_get(obj);
1273 elm_smart_scroller_freeze_set(wd->scr, EINA_TRUE);
1277 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1279 Widget_Data *wd = elm_widget_data_get(obj);
1282 elm_smart_scroller_freeze_set(wd->scr, EINA_FALSE);
1286 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1292 elm_list_add(Evas_Object *parent)
1297 Evas_Coord minw, minh;
1299 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1301 ELM_SET_WIDTYPE(widtype, "list");
1302 elm_widget_type_set(obj, "list");
1303 elm_widget_sub_object_add(parent, obj);
1304 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1305 elm_widget_data_set(obj, wd);
1306 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1307 elm_widget_del_hook_set(obj, _del_hook);
1308 elm_widget_theme_hook_set(obj, _theme_hook);
1309 elm_widget_disable_hook_set(obj, _disable_hook);
1310 elm_widget_can_focus_set(obj, EINA_TRUE);
1311 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1312 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1313 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1314 elm_widget_event_hook_set(obj, _event_hook);
1315 elm_widget_translate_hook_set(obj, _translate_hook);
1318 wd->scr = elm_smart_scroller_add(e);
1319 elm_smart_scroller_widget_set(wd->scr, obj);
1320 elm_widget_resize_object_set(obj, wd->scr);
1321 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1322 _changed_size_hints, obj);
1323 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
1324 evas_object_size_hint_min_set(obj, minw, minh);
1325 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1327 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
1328 _elm_config->thumbscroll_bounce_enable);
1330 wd->box = elm_box_add(parent);
1331 elm_box_homogeneous_set(wd->box, 1);
1332 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1333 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1334 elm_widget_on_show_region_hook_set(wd->box, _show_region_hook, obj);
1335 elm_widget_sub_object_add(obj, wd->box);
1336 elm_smart_scroller_child_set(wd->scr, wd->box);
1337 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1338 _changed_size_hints, obj);
1340 evas_object_show(wd->box);
1344 wd->mode = ELM_LIST_SCROLL;
1346 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
1347 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right, obj);
1348 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
1349 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom, obj);
1351 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1352 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1353 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1354 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1355 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1357 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1359 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1364 EAPI Elm_List_Item *
1365 elm_list_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1367 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1368 Widget_Data *wd = elm_widget_data_get(obj);
1369 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1371 wd->items = eina_list_append(wd->items, it);
1372 it->node = eina_list_last(wd->items);
1373 elm_box_pack_end(wd->box, VIEW(it));
1377 EAPI Elm_List_Item *
1378 elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1380 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1381 Widget_Data *wd = elm_widget_data_get(obj);
1382 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1384 wd->items = eina_list_prepend(wd->items, it);
1385 it->node = wd->items;
1386 elm_box_pack_start(wd->box, VIEW(it));
1390 EAPI Elm_List_Item *
1391 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)
1396 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
1397 if (!before->node) return NULL;
1398 ELM_LIST_ITEM_CHECK_DELETED_RETURN(before, NULL);
1400 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1401 wd = elm_widget_data_get(obj);
1402 if (!wd) return NULL;
1403 it = _item_new(obj, label, icon, end, func, data);
1404 wd->items = eina_list_prepend_relative_list(wd->items, it, before->node);
1405 it->node = before->node->prev;
1406 elm_box_pack_before(wd->box, VIEW(it), VIEW(before));
1410 EAPI Elm_List_Item *
1411 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)
1416 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
1417 if (!after->node) return NULL;
1418 ELM_LIST_ITEM_CHECK_DELETED_RETURN(after, NULL);
1420 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1421 wd = elm_widget_data_get(obj);
1422 if (!wd) return NULL;
1423 it = _item_new(obj, label, icon, end, func, data);
1424 wd->items = eina_list_append_relative_list(wd->items, it, after->node);
1425 it->node = after->node->next;
1426 elm_box_pack_after(wd->box, VIEW(it), VIEW(after));
1430 EAPI Elm_List_Item *
1431 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)
1433 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1434 Widget_Data *wd = elm_widget_data_get(obj);
1435 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1438 wd->items = eina_list_sorted_insert(wd->items, cmp_func, it);
1439 l = eina_list_data_find_list(wd->items, it);
1440 l = eina_list_next(l);
1443 it->node = eina_list_last(wd->items);
1444 elm_box_pack_end(wd->box, VIEW(it));
1448 Elm_List_Item *before = eina_list_data_get(l);
1449 it->node = before->node->prev;
1450 elm_box_pack_before(wd->box, VIEW(it), VIEW(before));
1456 elm_list_clear(Evas_Object *obj)
1458 ELM_CHECK_WIDTYPE(obj, widtype);
1459 Widget_Data *wd = elm_widget_data_get(obj);
1463 if (!wd->items) return;
1465 eina_list_free(wd->selected);
1466 wd->selected = NULL;
1468 if (wd->walking > 0)
1472 EINA_LIST_FOREACH(wd->items, n, it)
1474 if (it->deleted) continue;
1475 it->deleted = EINA_TRUE;
1476 wd->to_delete = eina_list_append(wd->to_delete, it);
1481 evas_object_ref(obj);
1484 EINA_LIST_FREE(wd->items, it)
1486 elm_widget_item_pre_notify_del(it);
1487 _elm_list_item_free(it);
1490 _elm_list_unwalk(wd);
1494 evas_object_unref(obj);
1498 elm_list_go(Evas_Object *obj)
1500 ELM_CHECK_WIDTYPE(obj, widtype);
1501 Widget_Data *wd = elm_widget_data_get(obj);
1507 elm_list_multi_select_set(Evas_Object *obj, Eina_Bool multi)
1509 ELM_CHECK_WIDTYPE(obj, widtype);
1510 Widget_Data *wd = elm_widget_data_get(obj);
1516 elm_list_multi_select_get(const Evas_Object *obj)
1518 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1519 Widget_Data *wd = elm_widget_data_get(obj);
1520 if (!wd) return EINA_FALSE;
1525 elm_list_mode_set(Evas_Object *obj, Elm_List_Mode mode)
1527 ELM_CHECK_WIDTYPE(obj, widtype);
1531 wd = elm_widget_data_get(obj);
1534 if (wd->mode == mode)
1538 _elm_list_mode_set_internal(wd);
1542 elm_list_mode_get(const Evas_Object *obj)
1544 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
1545 Widget_Data *wd = elm_widget_data_get(obj);
1546 if (!wd) return ELM_LIST_LAST;
1551 elm_list_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1553 ELM_CHECK_WIDTYPE(obj, widtype);
1556 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1558 wd = elm_widget_data_get(obj);
1562 if (wd->h_mode == horizontal)
1565 wd->h_mode = horizontal;
1566 elm_box_horizontal_set(wd->box, horizontal);
1570 evas_object_size_hint_weight_set(wd->box, 0.0, EVAS_HINT_EXPAND);
1571 evas_object_size_hint_align_set(wd->box, 0.0, EVAS_HINT_FILL);
1572 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1576 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1577 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1578 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, bounce);
1581 _elm_list_mode_set_internal(wd);
1585 elm_list_horizontal_get(const Evas_Object *obj)
1587 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1591 wd = elm_widget_data_get(obj);
1599 elm_list_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
1601 ELM_CHECK_WIDTYPE(obj, widtype);
1602 Widget_Data *wd = elm_widget_data_get(obj);
1604 wd->always_select = always_select;
1608 elm_list_always_select_mode_get(const Evas_Object *obj)
1610 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1611 Widget_Data *wd = elm_widget_data_get(obj);
1612 if (!wd) return EINA_FALSE;
1613 return wd->always_select;
1616 EAPI const Eina_List *
1617 elm_list_items_get(const Evas_Object *obj)
1619 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1620 Widget_Data *wd = elm_widget_data_get(obj);
1621 if (!wd) return NULL;
1625 EAPI Elm_List_Item *
1626 elm_list_selected_item_get(const Evas_Object *obj)
1628 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1629 Widget_Data *wd = elm_widget_data_get(obj);
1630 if (!wd) return NULL;
1631 if (wd->selected) return wd->selected->data;
1635 EAPI const Eina_List *
1636 elm_list_selected_items_get(const Evas_Object *obj)
1638 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1639 Widget_Data *wd = elm_widget_data_get(obj);
1640 if (!wd) return NULL;
1641 return wd->selected;
1645 elm_list_item_separator_set(Elm_List_Item *it, Eina_Bool setting)
1647 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1648 it->is_separator = !!setting;
1652 elm_list_item_separator_get(const Elm_List_Item *it)
1654 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1655 return it->is_separator;
1659 elm_list_item_selected_set(Elm_List_Item *it, Eina_Bool selected)
1661 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1662 Evas_Object *obj = WIDGET(it);
1663 Widget_Data *wd = elm_widget_data_get(obj);
1666 selected = !!selected;
1667 if (it->selected == selected) return;
1669 evas_object_ref(obj);
1676 while (wd->selected)
1677 _item_unselect(wd->selected->data);
1685 _elm_list_unwalk(wd);
1686 evas_object_unref(obj);
1690 elm_list_item_selected_get(const Elm_List_Item *it)
1692 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1693 return it->selected;
1697 elm_list_item_show(Elm_List_Item *it)
1699 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1700 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1701 Evas_Coord bx, by, bw, bh;
1702 Evas_Coord x, y, w, h;
1704 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1705 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1709 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
1713 elm_list_item_bring_in(Elm_List_Item *it)
1715 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1716 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1717 Evas_Coord bx, by, bw, bh;
1718 Evas_Coord x, y, w, h;
1720 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1721 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1725 elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
1729 elm_list_item_del(Elm_List_Item *it)
1731 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1732 Evas_Object *obj = WIDGET(it);
1733 Widget_Data *wd = elm_widget_data_get(obj);
1736 if (it->selected) _item_unselect(it);
1738 if (wd->walking > 0)
1740 if (it->deleted) return;
1741 it->deleted = EINA_TRUE;
1742 wd->to_delete = eina_list_append(wd->to_delete, it);
1746 wd->items = eina_list_remove_list(wd->items, it->node);
1748 evas_object_ref(obj);
1751 elm_widget_item_pre_notify_del(it);
1752 _elm_list_item_free(it);
1754 _elm_list_unwalk(wd);
1755 evas_object_unref(obj);
1759 elm_list_item_del_cb_set(Elm_List_Item *it, Evas_Smart_Cb func)
1761 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1762 elm_widget_item_del_cb_set(it, func);
1766 elm_list_item_data_get(const Elm_List_Item *it)
1768 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1769 return elm_widget_item_data_get(it);
1773 elm_list_item_icon_get(const Elm_List_Item *it)
1775 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1776 if (it->dummy_icon) return NULL;
1781 elm_list_item_icon_set(Elm_List_Item *it, Evas_Object *icon)
1783 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1784 if (it->icon == icon) return;
1785 if ((it->dummy_icon) && (!icon)) return;
1788 evas_object_del(it->icon);
1789 it->dummy_icon = EINA_FALSE;
1793 icon = evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1794 evas_object_color_set(icon, 0, 0, 0, 0);
1795 it->dummy_icon = EINA_TRUE;
1799 evas_object_del(it->icon);
1804 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", icon);
1808 elm_list_item_end_get(const Elm_List_Item *it)
1810 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1811 if (it->dummy_end) return NULL;
1816 elm_list_item_end_set(Elm_List_Item *it, Evas_Object *end)
1818 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1819 if (it->end == end) return;
1820 if ((it->dummy_end) && (!end)) return;
1823 evas_object_del(it->end);
1824 it->dummy_icon = EINA_FALSE;
1828 end = evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1829 evas_object_color_set(end, 0, 0, 0, 0);
1830 it->dummy_end = EINA_TRUE;
1834 evas_object_del(it->end);
1839 edje_object_part_swallow(VIEW(it), "elm.swallow.end", end);
1843 elm_list_item_base_get(const Elm_List_Item *it)
1845 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1850 elm_list_item_label_get(const Elm_List_Item *it)
1852 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1857 elm_list_item_label_set(Elm_List_Item *it, const char *text)
1859 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1860 if (!eina_stringshare_replace(&it->label, text)) return;
1862 edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1865 EAPI Elm_List_Item *
1866 elm_list_item_prev(const Elm_List_Item *it)
1868 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1869 if (it->node->prev) return it->node->prev->data;
1873 EAPI Elm_List_Item *
1874 elm_list_item_next(const Elm_List_Item *it)
1876 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1877 if (it->node->next) return it->node->next->data;
1882 elm_list_item_tooltip_text_set(Elm_List_Item *item, const char *text)
1884 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1885 elm_widget_item_tooltip_text_set(item, text);
1889 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)
1891 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1892 elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
1896 elm_list_item_tooltip_unset(Elm_List_Item *item)
1898 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1899 elm_widget_item_tooltip_unset(item);
1903 elm_list_item_tooltip_style_set(Elm_List_Item *item, const char *style)
1905 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1906 elm_widget_item_tooltip_style_set(item, style);
1910 elm_list_item_tooltip_style_get(const Elm_List_Item *item)
1912 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1913 return elm_widget_item_tooltip_style_get(item);
1917 elm_list_item_cursor_set(Elm_List_Item *item, const char *cursor)
1919 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1920 elm_widget_item_cursor_set(item, cursor);
1924 elm_list_item_cursor_get(const Elm_List_Item *item)
1926 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1927 return elm_widget_item_cursor_get(item);
1931 elm_list_item_cursor_unset(Elm_List_Item *item)
1933 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1934 elm_widget_item_cursor_unset(item);
1938 elm_list_item_cursor_style_set(Elm_List_Item *item, const char *style)
1940 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1941 elm_widget_item_cursor_style_set(item, style);
1945 elm_list_item_cursor_style_get(const Elm_List_Item *item)
1947 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1948 return elm_widget_item_cursor_style_get(item);
1952 elm_list_item_cursor_engine_only_set(Elm_List_Item *item, Eina_Bool engine_only)
1954 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1955 elm_widget_item_cursor_engine_only_set(item, engine_only);
1959 elm_list_item_cursor_engine_only_get(const Elm_List_Item *item)
1961 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1962 return elm_widget_item_cursor_engine_only_get(item);
1966 elm_list_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1968 ELM_CHECK_WIDTYPE(obj, widtype);
1969 Widget_Data *wd = elm_widget_data_get(obj);
1972 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
1976 elm_list_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1978 ELM_CHECK_WIDTYPE(obj, widtype);
1979 Widget_Data *wd = elm_widget_data_get(obj);
1981 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
1985 elm_list_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
1987 ELM_CHECK_WIDTYPE(obj, widtype);
1988 Widget_Data *wd = elm_widget_data_get(obj);
1990 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
1991 (policy_v >= ELM_SCROLLER_POLICY_LAST))
1993 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
1997 elm_list_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
1999 ELM_CHECK_WIDTYPE(obj, widtype);
2000 Widget_Data *wd = elm_widget_data_get(obj);
2001 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
2002 if ((!wd) || (!wd->scr)) return;
2003 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
2004 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
2005 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
2009 elm_list_item_disabled_set(Elm_List_Item *it, Eina_Bool disabled)
2011 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2013 if (it->disabled == disabled)
2016 it->disabled = !!disabled;
2019 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
2021 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
2025 elm_list_item_disabled_get(const Elm_List_Item *it)
2027 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2029 return it->disabled;