1 #include <Elementary.h>
6 typedef struct _Widget_Data Widget_Data;
10 Evas_Object *scr, *box, *self;
11 Eina_List *items, *selected, *to_delete;
12 Elm_List_Item *last_selected_item;
15 Evas_Coord minw[2], minh[2];
16 Eina_Bool scr_minw : 1;
17 Eina_Bool scr_minh : 1;
22 } history[SWIPE_MOVES];
24 Eina_Bool fix_pending : 1;
25 Eina_Bool on_hold : 1;
27 Eina_Bool always_select : 1;
28 Eina_Bool longpressed : 1;
29 Eina_Bool wasselected : 1;
38 Evas_Object *icon, *end;
40 Ecore_Timer *long_timer;
41 Ecore_Timer *swipe_timer;
42 Eina_Bool deleted : 1;
43 Eina_Bool disabled : 1;
45 Eina_Bool is_even : 1;
46 Eina_Bool is_separator : 1;
48 Eina_Bool selected : 1;
49 Eina_Bool hilighted : 1;
50 Eina_Bool dummy_icon : 1;
51 Eina_Bool dummy_end : 1;
54 static const char *widtype = NULL;
55 static void _del_hook(Evas_Object *obj);
56 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
57 static void _theme_hook(Evas_Object *obj);
58 static void _sizing_eval(Evas_Object *obj);
59 static void _disable_hook(Evas_Object *obj);
60 static void _on_focus_hook(void *data, Evas_Object *obj);
61 static void _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source);
62 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
63 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
64 static void _fix_items(Evas_Object *obj);
65 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
66 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
67 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
68 static void _scroll_edge_left(void *data, Evas_Object *scr, void *event_info);
69 static void _scroll_edge_right(void *data, Evas_Object *scr, void *event_info);
70 static void _scroll_edge_top(void *data, Evas_Object *scr, void *event_info);
71 static void _scroll_edge_bottom(void *data, Evas_Object *scr, void *event_info);
72 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
73 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
74 static Eina_Bool _item_single_select_up(Widget_Data *wd);
75 static Eina_Bool _item_single_select_down(Widget_Data *wd);
76 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
77 Evas_Callback_Type type, void *event_info);
78 static Eina_Bool _deselect_all_items(Widget_Data *wd);
80 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
81 static const char SIG_SELECTED[] = "selected";
82 static const char SIG_UNSELECTED[] = "unselected";
83 static const char SIG_LONGPRESSED[] = "longpressed";
84 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
85 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
86 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
87 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
89 static const Evas_Smart_Cb_Description _signals[] = {
90 {SIG_CLICKED_DOUBLE, ""},
93 {SIG_LONGPRESSED, ""},
94 {SIG_SCROLL_EDGE_TOP, ""},
95 {SIG_SCROLL_EDGE_BOTTOM, ""},
96 {SIG_SCROLL_EDGE_LEFT, ""},
97 {SIG_SCROLL_EDGE_RIGHT, ""},
101 #define ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ...) \
102 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, __VA_ARGS__); \
105 ERR("ERROR: "#it" has been DELETED.\n"); \
106 return __VA_ARGS__; \
110 _elm_list_item_free(Elm_List_Item *it)
112 evas_object_event_callback_del_full
113 (it->base.view, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
114 evas_object_event_callback_del_full
115 (it->base.view, EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
116 evas_object_event_callback_del_full
117 (it->base.view, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, it);
120 evas_object_event_callback_del_full
121 (it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
122 _changed_size_hints, it->base.widget);
125 evas_object_event_callback_del_full
126 (it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
127 _changed_size_hints, it->base.widget);
129 eina_stringshare_del(it->label);
131 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
132 if (it->long_timer) ecore_timer_del(it->long_timer);
133 if (it->icon) evas_object_del(it->icon);
134 if (it->end) evas_object_del(it->end);
136 elm_widget_item_del(it);
140 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
142 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
143 Evas_Event_Key_Down *ev = event_info;
144 Widget_Data *wd = elm_widget_data_get(obj);
145 if (!wd) return EINA_FALSE;
146 if (!wd->items) return EINA_FALSE;
147 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
148 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
150 Elm_List_Item *it = NULL;
153 Evas_Coord step_x = 0;
154 Evas_Coord step_y = 0;
157 Evas_Coord page_x = 0;
158 Evas_Coord page_y = 0;
160 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
161 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
162 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
163 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
165 /* TODO: fix logic for horizontal mode */
166 if ((!strcmp(ev->keyname, "Left")) ||
167 (!strcmp(ev->keyname, "KP_Left")))
170 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
171 (_item_multi_select_up(wd)))
172 || (_item_single_select_up(wd))))
174 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
180 else if ((!strcmp(ev->keyname, "Right")) ||
181 (!strcmp(ev->keyname, "KP_Right")))
184 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
185 (_item_multi_select_down(wd)))
186 || (_item_single_select_down(wd))))
188 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
194 else if ((!strcmp(ev->keyname, "Up")) ||
195 (!strcmp(ev->keyname, "KP_Up")))
198 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
199 (_item_multi_select_up(wd)))
200 || (_item_single_select_up(wd))))
202 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
208 else if ((!strcmp(ev->keyname, "Down")) ||
209 (!strcmp(ev->keyname, "KP_Down")))
212 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
213 (_item_multi_select_down(wd)))
214 || (_item_single_select_down(wd))))
216 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
222 else if ((!strcmp(ev->keyname, "Home")) ||
223 (!strcmp(ev->keyname, "KP_Home")))
225 it = eina_list_data_get(wd->items);
226 elm_list_item_bring_in(it);
227 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
230 else if ((!strcmp(ev->keyname, "End")) ||
231 (!strcmp(ev->keyname, "KP_End")))
233 it = eina_list_data_get(eina_list_last(wd->items));
234 elm_list_item_bring_in(it);
235 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
238 else if ((!strcmp(ev->keyname, "Prior")) ||
239 (!strcmp(ev->keyname, "KP_Prior")))
244 x -= -(page_x * v_w) / 100;
251 y -= -(page_y * v_h) / 100;
256 else if ((!strcmp(ev->keyname, "Next")) ||
257 (!strcmp(ev->keyname, "KP_Next")))
262 x += -(page_x * v_w) / 100;
269 y += -(page_y * v_h) / 100;
274 else if (!strcmp(ev->keyname, "Escape"))
276 if (!_deselect_all_items(wd)) return EINA_FALSE;
277 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
280 else return EINA_FALSE;
282 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
283 elm_smart_scroller_child_pos_set(wd->scr, x, y);
288 _deselect_all_items(Widget_Data *wd)
290 if (!wd->selected) return EINA_FALSE;
292 elm_list_item_selected_set(wd->selected->data, EINA_FALSE);
298 _item_multi_select_up(Widget_Data *wd)
300 if (!wd->selected) return EINA_FALSE;
301 if (!wd->multi) return EINA_FALSE;
303 Elm_List_Item *prev = elm_list_item_prev(wd->last_selected_item);
304 if (!prev) return EINA_TRUE;
306 if (elm_list_item_selected_get(prev))
308 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
309 wd->last_selected_item = prev;
310 elm_list_item_show(wd->last_selected_item);
314 elm_list_item_selected_set(prev, EINA_TRUE);
315 elm_list_item_show(prev);
321 _item_multi_select_down(Widget_Data *wd)
323 if (!wd->selected) return EINA_FALSE;
324 if (!wd->multi) return EINA_FALSE;
326 Elm_List_Item *next = elm_list_item_next(wd->last_selected_item);
327 if (!next) return EINA_TRUE;
329 if (elm_list_item_selected_get(next))
331 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
332 wd->last_selected_item = next;
333 elm_list_item_show(wd->last_selected_item);
337 elm_list_item_selected_set(next, EINA_TRUE);
338 elm_list_item_show(next);
344 _item_single_select_up(Widget_Data *wd)
348 if (!wd->selected) prev = eina_list_data_get(eina_list_last(wd->items));
349 else prev = elm_list_item_prev(wd->last_selected_item);
351 if (!prev) return EINA_FALSE;
353 _deselect_all_items(wd);
355 elm_list_item_selected_set(prev, EINA_TRUE);
356 elm_list_item_show(prev);
361 _item_single_select_down(Widget_Data *wd)
365 if (!wd->selected) next = eina_list_data_get(wd->items);
366 else next = elm_list_item_next(wd->last_selected_item);
368 if (!next) return EINA_FALSE;
370 _deselect_all_items(wd);
372 elm_list_item_selected_set(next, EINA_TRUE);
373 elm_list_item_show(next);
378 _elm_list_process_deletions(Widget_Data *wd)
382 wd->walking++; // avoid nested deletion and also _sub_del() fix_items
384 EINA_LIST_FREE(wd->to_delete, it)
386 elm_widget_item_pre_notify_del(it);
388 wd->items = eina_list_remove_list(wd->items, it->node);
389 _elm_list_item_free(it);
396 _elm_list_walk(Widget_Data *wd)
400 ERR("ERROR: walking was negative. fixed!\n");
407 _elm_list_unwalk(Widget_Data *wd)
412 ERR("ERROR: walking became negative. fixed!\n");
420 _elm_list_process_deletions(wd);
424 wd->fix_pending = EINA_FALSE;
425 _fix_items(wd->self);
426 _sizing_eval(wd->self);
431 _del_pre_hook(Evas_Object *obj)
433 Widget_Data *wd = elm_widget_data_get(obj);
436 evas_object_event_callback_del(wd->scr,
437 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
438 _changed_size_hints);
439 evas_object_event_callback_del(wd->box,
440 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
441 _changed_size_hints);
445 _del_hook(Evas_Object *obj)
447 Widget_Data *wd = elm_widget_data_get(obj);
453 ERR("ERROR: list deleted while walking.\n");
456 EINA_LIST_FOREACH(wd->items, n, it) elm_widget_item_pre_notify_del(it);
457 _elm_list_unwalk(wd);
459 ERR("ERROR: leaking nodes!\n");
461 EINA_LIST_FREE(wd->items, it) _elm_list_item_free(it);
462 eina_list_free(wd->selected);
467 _show_region_hook(void *data, Evas_Object *obj)
469 Widget_Data *wd = elm_widget_data_get(data);
470 Evas_Coord x, y, w, h;
472 elm_widget_show_region_get(obj, &x, &y, &w, &h);
473 elm_smart_scroller_child_region_set(wd->scr, x, y, w, h);
477 _disable_hook(Evas_Object *obj)
479 Widget_Data *wd = elm_widget_data_get(obj);
481 if (elm_widget_disabled_get(obj))
483 _signal_emit_hook(obj, "elm,state,disabled", "elm");
484 elm_widget_scroll_freeze_push(obj);
485 elm_widget_scroll_hold_push(obj);
486 /* FIXME: if we get to have a way to only un-hilight items
487 * in the future, keeping them selected... */
488 _deselect_all_items(wd);
492 _signal_emit_hook(obj, "elm,state,enabled", "elm");
493 elm_widget_scroll_freeze_pop(obj);
494 elm_widget_scroll_hold_pop(obj);
499 _sizing_eval(Evas_Object *obj)
502 Widget_Data *wd = elm_widget_data_get(obj);
504 Evas_Coord vw, vh, minw, minh, maxw, maxh, w, h, vmw, vmh;
507 evas_object_size_hint_min_get(wd->box, &minw, &minh);
508 evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
509 evas_object_size_hint_weight_get(wd->box, &xw, &yw);
510 if (!wd->scr) return;
511 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
514 if ((minw > 0) && (vw < minw)) vw = minw;
515 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
517 else if (minw > 0) vw = minw;
520 if ((minh > 0) && (vh < minh)) vh = minh;
521 else if ((maxh > 0) && (vh > maxh)) vh = maxh;
523 else if (minh > 0) vh = minh;
524 evas_object_resize(wd->box, vw, vh);
527 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
529 if (wd->scr_minw) w = vmw + minw;
530 if (wd->scr_minh) h = vmh + minh;
532 evas_object_size_hint_max_get(obj, &maxw, &maxh);
533 if ((maxw > 0) && (w > maxw))
535 if ((maxh > 0) && (h > maxh))
538 evas_object_size_hint_min_set(obj, w, h);
542 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
544 Widget_Data *wd = elm_widget_data_get(obj);
545 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
550 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
552 Widget_Data *wd = elm_widget_data_get(obj);
553 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
554 emission, source, func_cb, data);
558 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
560 Widget_Data *wd = elm_widget_data_get(obj);
561 edje_object_signal_callback_del_full(
562 elm_smart_scroller_edje_object_get(wd->scr),
563 emission, source, func_cb, data);
567 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
569 Widget_Data *wd = elm_widget_data_get(obj);
575 elm_smart_scroller_mirrored_set(wd->scr, rtl);
577 EINA_LIST_FOREACH(wd->items, n, it)
578 edje_object_mirrored_set(it->base.view, rtl);
582 _theme_hook(Evas_Object *obj)
584 Widget_Data *wd = elm_widget_data_get(obj);
589 _elm_widget_mirrored_reload(obj);
590 _mirrored_set(obj, elm_widget_mirrored_get(obj));
597 elm_smart_scroller_object_theme_set(obj, wd->scr, "list", "base",
598 elm_widget_style_get(obj));
599 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
600 edj = elm_smart_scroller_edje_object_get(wd->scr);
601 str = edje_object_data_get(edj, "focus_highlight");
602 if ((str) && (!strcmp(str, "on")))
603 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
605 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
606 elm_object_style_set(wd->scr, elm_widget_style_get(obj));
608 EINA_LIST_FOREACH(wd->items, n, it)
610 edje_object_scale_set(it->base.view, elm_widget_scale_get(obj) * _elm_config->scale);
618 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
620 Widget_Data *wd = elm_widget_data_get(obj);
622 if (elm_widget_focus_get(obj))
624 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
625 evas_object_focus_set(wd->self, EINA_TRUE);
627 if ((wd->selected) && (!wd->last_selected_item))
628 wd->last_selected_item = eina_list_data_get(wd->selected);
632 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
633 evas_object_focus_set(wd->self, EINA_FALSE);
638 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
640 Widget_Data *wd = elm_widget_data_get(data);
647 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
649 Widget_Data *wd = elm_widget_data_get(obj);
650 Evas_Object *sub = event_info;
656 if ((sub == wd->box) || (sub == wd->scr)) return;
658 EINA_LIST_FOREACH(wd->items, l, it)
660 if ((sub == it->icon) || (sub == it->end))
662 if (it->icon == sub) it->icon = NULL;
663 if (it->end == sub) it->end = NULL;
664 evas_object_event_callback_del_full
665 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints,
673 wd->fix_pending = EINA_TRUE;
680 _item_hilight(Elm_List_Item *it)
682 Evas_Object *obj = it->base.widget;
683 Widget_Data *wd = elm_widget_data_get(obj);
684 const char *selectraise;
687 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
688 if (it->hilighted) return;
690 evas_object_ref(obj);
693 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
694 selectraise = edje_object_data_get(it->base.view, "selectraise");
695 if ((selectraise) && (!strcmp(selectraise, "on")))
696 evas_object_raise(it->base.view);
697 it->hilighted = EINA_TRUE;
699 _elm_list_unwalk(wd);
700 evas_object_unref(obj);
704 _item_select(Elm_List_Item *it)
706 Evas_Object *obj = it->base.widget;
707 Widget_Data *wd = elm_widget_data_get(obj);
710 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
713 if (wd->always_select) goto call;
716 it->selected = EINA_TRUE;
717 wd->selected = eina_list_append(wd->selected, it);
720 evas_object_ref(obj);
723 if (it->func) it->func((void *)it->base.data, it->base.widget, it);
724 evas_object_smart_callback_call(obj, SIG_SELECTED, it);
725 it->wd->last_selected_item = it;
727 _elm_list_unwalk(wd);
728 evas_object_unref(obj);
732 _item_unselect(Elm_List_Item *it)
734 Evas_Object *obj = it->base.widget;
735 Widget_Data *wd = elm_widget_data_get(obj);
736 const char *stacking, *selectraise;
739 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
740 if (!it->hilighted) return;
742 evas_object_ref(obj);
745 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
746 stacking = edje_object_data_get(it->base.view, "stacking");
747 selectraise = edje_object_data_get(it->base.view, "selectraise");
748 if ((selectraise) && (!strcmp(selectraise, "on")))
750 if ((stacking) && (!strcmp(stacking, "below")))
751 evas_object_lower(it->base.view);
753 it->hilighted = EINA_FALSE;
756 it->selected = EINA_FALSE;
757 wd->selected = eina_list_remove(wd->selected, it);
758 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
761 _elm_list_unwalk(wd);
762 evas_object_unref(obj);
766 _swipe_cancel(void *data)
768 Elm_List_Item *it = data;
769 Widget_Data *wd = elm_widget_data_get(it->base.widget);
771 if (!wd) return ECORE_CALLBACK_CANCEL;
772 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
773 wd->swipe = EINA_FALSE;
775 return ECORE_CALLBACK_RENEW;
779 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
781 Elm_List_Item *it = data;
782 Evas_Object *obj2 = it->base.widget;
783 Widget_Data *wd = elm_widget_data_get(obj2);
784 Evas_Event_Mouse_Move *ev = event_info;
787 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
789 evas_object_ref(obj2);
792 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
796 wd->on_hold = EINA_TRUE;
799 ecore_timer_del(it->long_timer);
800 it->long_timer = NULL;
802 if (!wd->wasselected)
805 if (wd->movements == SWIPE_MOVES) wd->swipe = EINA_TRUE;
808 wd->history[wd->movements].x = ev->cur.canvas.x;
809 wd->history[wd->movements].y = ev->cur.canvas.y;
810 if (abs((wd->history[wd->movements].x - wd->history[0].x)) > 40)
811 wd->swipe = EINA_TRUE;
817 _elm_list_unwalk(wd);
818 evas_object_unref(obj2);
822 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
824 Evas_Object *obj = data;
825 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
829 _scroll_edge_right(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_RIGHT, NULL);
836 _scroll_edge_top(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_TOP, NULL);
843 _scroll_edge_bottom(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_BOTTOM, NULL);
850 _long_press(void *data)
852 Elm_List_Item *it = data;
853 Evas_Object *obj = it->base.widget;
854 Widget_Data *wd = elm_widget_data_get(obj);
858 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
859 it->long_timer = NULL;
860 if (it->disabled) goto end;
862 wd->longpressed = EINA_TRUE;
863 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
866 return ECORE_CALLBACK_CANCEL;
870 _swipe(Elm_List_Item *it)
873 Widget_Data *wd = elm_widget_data_get(it->base.widget);
875 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
877 wd->swipe = EINA_FALSE;
878 for (i = 0; i < wd->movements; i++)
880 sum += wd->history[i].x;
881 if (abs(wd->history[0].y - wd->history[i].y) > 10) return;
884 sum /= wd->movements;
885 if (abs(sum - wd->history[0].x) <= 10) return;
886 evas_object_smart_callback_call(it->base.widget, "swipe", it);
890 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
892 Elm_List_Item *it = data;
893 Evas_Object *obj2 = it->base.widget;
894 Widget_Data *wd = elm_widget_data_get(obj2);
895 Evas_Event_Mouse_Down *ev = event_info;
898 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
899 if (ev->button != 1) return;
900 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
901 else wd->on_hold = EINA_FALSE;
902 if (wd->on_hold) return;
903 wd->wasselected = it->selected;
905 evas_object_ref(obj2);
909 wd->longpressed = EINA_FALSE;
910 if (it->long_timer) ecore_timer_del(it->long_timer);
911 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, it);
912 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
913 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
914 /* Always call the callbacks last - the user may delete our context! */
915 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
916 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
917 wd->swipe = EINA_FALSE;
920 _elm_list_unwalk(wd);
921 evas_object_unref(obj2);
925 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
927 Elm_List_Item *it = data;
928 Evas_Object *obj2 = it->base.widget;
929 Widget_Data *wd = elm_widget_data_get(obj2);
930 Evas_Event_Mouse_Up *ev = event_info;
933 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
934 if (ev->button != 1) return;
935 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
936 else wd->on_hold = EINA_FALSE;
937 wd->longpressed = EINA_FALSE;
940 ecore_timer_del(it->long_timer);
941 it->long_timer = NULL;
945 ecore_timer_del(it->swipe_timer);
946 it->swipe_timer = NULL;
950 if (wd->swipe) _swipe(data);
951 wd->on_hold = EINA_FALSE;
956 if (!wd->wasselected) _item_unselect(it);
963 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
965 evas_object_ref(obj2);
975 else _item_unselect(it);
982 _item_unselect(wd->selected->data);
988 const Eina_List *l, *l_next;
991 EINA_LIST_FOREACH_SAFE(wd->selected, l, l_next, it2)
992 if (it2 != it) _item_unselect(it2);
998 _elm_list_unwalk(wd);
999 evas_object_unref(obj2);
1002 static Elm_List_Item *
1003 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1005 Widget_Data *wd = elm_widget_data_get(obj);
1008 if (!wd) return NULL;
1009 it = elm_widget_item_new(obj, Elm_List_Item);
1011 it->label = eina_stringshare_add(label);
1015 it->base.data = data;
1016 it->base.view = edje_object_add(evas_object_evas_get(obj));
1017 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(obj));
1018 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1020 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1022 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1024 evas_object_size_hint_weight_set(it->base.view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1025 evas_object_size_hint_align_set(it->base.view, EVAS_HINT_FILL, EVAS_HINT_FILL);
1028 elm_widget_sub_object_add(obj, it->icon);
1029 evas_object_event_callback_add(it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1030 _changed_size_hints, obj);
1034 elm_widget_sub_object_add(obj, it->end);
1035 evas_object_event_callback_add(it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1036 _changed_size_hints, obj);
1042 _elm_list_mode_set_internal(Widget_Data *wd)
1047 if (wd->mode == ELM_LIST_LIMIT)
1051 wd->scr_minw = EINA_TRUE;
1052 wd->scr_minh = EINA_FALSE;
1056 wd->scr_minw = EINA_FALSE;
1057 wd->scr_minh = EINA_TRUE;
1060 else if (wd->mode == ELM_LIST_EXPAND)
1062 wd->scr_minw = EINA_TRUE;
1063 wd->scr_minh = EINA_TRUE;
1067 wd->scr_minw = EINA_FALSE;
1068 wd->scr_minh = EINA_FALSE;
1071 _sizing_eval(wd->self);
1075 _fix_items(Evas_Object *obj)
1077 Widget_Data *wd = elm_widget_data_get(obj);
1081 Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
1084 const char *style = elm_widget_style_get(obj);
1085 const char *it_plain = wd->h_mode ? "h_item" : "item";
1086 const char *it_odd = wd->h_mode ? "h_item_odd" : "item_odd";
1087 const char *it_compress = wd->h_mode ? "h_item_compress" : "item_compress";
1088 const char *it_compress_odd = wd->h_mode ? "h_item_compress_odd" : "item_compress_odd";
1092 wd->fix_pending = EINA_TRUE;
1096 evas_object_ref(obj);
1097 _elm_list_walk(wd); // watch out "return" before unwalk!
1099 EINA_LIST_FOREACH(wd->items, l, it)
1101 if (it->deleted) continue;
1104 evas_object_size_hint_min_get(it->icon, &mw, &mh);
1105 if (mw > minw[0]) minw[0] = mw;
1106 if (mh > minh[0]) minh[0] = mh;
1110 evas_object_size_hint_min_get(it->end, &mw, &mh);
1111 if (mw > minw[1]) minw[1] = mw;
1112 if (mh > minh[1]) minh[1] = mh;
1116 if ((minw[0] != wd->minw[0]) || (minw[1] != wd->minw[1]) ||
1117 (minw[0] != wd->minh[0]) || (minh[1] != wd->minh[1]))
1119 wd->minw[0] = minw[0];
1120 wd->minw[1] = minw[1];
1121 wd->minh[0] = minh[0];
1122 wd->minh[1] = minh[1];
1126 EINA_LIST_FOREACH(wd->items, l, it)
1132 if ((it->even != it->is_even) || (!it->fixed) || (redo))
1134 const char *stacking;
1136 /* FIXME: separators' themes seem to be b0rked */
1137 if (it->is_separator)
1138 _elm_theme_object_set(obj, it->base.view, "separator",
1139 wd->h_mode ? "horizontal" : "vertical",
1141 else if (wd->mode == ELM_LIST_COMPRESS)
1144 _elm_theme_object_set(obj, it->base.view, "list",
1145 it_compress, style);
1147 _elm_theme_object_set(obj, it->base.view, "list",
1148 it_compress_odd, style);
1153 _elm_theme_object_set(obj, it->base.view, "list", it_plain,
1156 _elm_theme_object_set(obj, it->base.view, "list", it_odd,
1159 stacking = edje_object_data_get(it->base.view, "stacking");
1162 if (!strcmp(stacking, "below"))
1163 evas_object_lower(it->base.view);
1164 else if (!strcmp(stacking, "above"))
1165 evas_object_raise(it->base.view);
1167 edje_object_part_text_set(it->base.view, "elm.text", it->label);
1169 if ((!it->icon) && (minh[0] > 0))
1171 it->icon = evas_object_rectangle_add(evas_object_evas_get(it->base.view));
1172 evas_object_color_set(it->icon, 0, 0, 0, 0);
1173 it->dummy_icon = EINA_TRUE;
1175 if ((!it->end) && (minh[1] > 0))
1177 it->end = evas_object_rectangle_add(evas_object_evas_get(it->base.view));
1178 evas_object_color_set(it->end, 0, 0, 0, 0);
1179 it->dummy_end = EINA_TRUE;
1183 evas_object_size_hint_min_set(it->icon, minw[0], minh[0]);
1184 evas_object_size_hint_max_set(it->icon, 99999, 99999);
1185 edje_object_part_swallow(it->base.view, "elm.swallow.icon", it->icon);
1189 evas_object_size_hint_min_set(it->end, minw[1], minh[1]);
1190 evas_object_size_hint_max_set(it->end, 99999, 99999);
1191 edje_object_part_swallow(it->base.view, "elm.swallow.end", it->end);
1195 // this may call up user and it may modify the list item
1196 // but we're safe as we're flagged as walking.
1197 // just don't process further
1198 edje_object_message_signal_process(it->base.view);
1202 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1203 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
1204 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1205 evas_object_size_hint_min_set(it->base.view, mw, mh);
1206 evas_object_show(it->base.view);
1208 if ((it->selected) || (it->hilighted))
1210 const char *selectraise;
1212 // this may call up user and it may modify the list item
1213 // but we're safe as we're flagged as walking.
1214 // just don't process further
1215 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
1219 selectraise = edje_object_data_get(it->base.view, "selectraise");
1220 if ((selectraise) && (!strcmp(selectraise, "on")))
1221 evas_object_raise(it->base.view);
1224 edje_object_signal_emit(it->base.view, "elm,state,disabled",
1227 it->fixed = EINA_TRUE;
1228 it->is_even = it->even;
1234 evas_object_size_hint_min_get(wd->box, &mw, &mh);
1236 _elm_list_mode_set_internal(wd);
1238 _elm_list_unwalk(wd);
1239 evas_object_unref(obj);
1243 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1245 Widget_Data *wd = elm_widget_data_get(obj);
1248 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
1252 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1254 Widget_Data *wd = elm_widget_data_get(obj);
1257 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1261 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1263 Widget_Data *wd = elm_widget_data_get(obj);
1266 elm_smart_scroller_freeze_set(wd->scr, EINA_TRUE);
1270 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1272 Widget_Data *wd = elm_widget_data_get(obj);
1275 elm_smart_scroller_freeze_set(wd->scr, EINA_FALSE);
1279 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1285 elm_list_add(Evas_Object *parent)
1290 Evas_Coord minw, minh;
1292 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1294 ELM_SET_WIDTYPE(widtype, "list");
1295 elm_widget_type_set(obj, "list");
1296 elm_widget_sub_object_add(parent, obj);
1297 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1298 elm_widget_data_set(obj, wd);
1299 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1300 elm_widget_del_hook_set(obj, _del_hook);
1301 elm_widget_theme_hook_set(obj, _theme_hook);
1302 elm_widget_disable_hook_set(obj, _disable_hook);
1303 elm_widget_can_focus_set(obj, EINA_TRUE);
1304 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1305 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1306 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1307 elm_widget_event_hook_set(obj, _event_hook);
1310 wd->scr = elm_smart_scroller_add(e);
1311 elm_smart_scroller_widget_set(wd->scr, obj);
1312 elm_widget_resize_object_set(obj, wd->scr);
1313 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1314 _changed_size_hints, obj);
1315 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
1316 evas_object_size_hint_min_set(obj, minw, minh);
1317 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1319 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
1320 _elm_config->thumbscroll_bounce_enable);
1322 wd->box = elm_box_add(parent);
1323 elm_box_homogeneous_set(wd->box, 1);
1324 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1325 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1326 elm_widget_on_show_region_hook_set(wd->box, _show_region_hook, obj);
1327 elm_widget_sub_object_add(obj, wd->box);
1328 elm_smart_scroller_child_set(wd->scr, wd->box);
1329 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1330 _changed_size_hints, obj);
1332 evas_object_show(wd->box);
1336 wd->mode = ELM_LIST_SCROLL;
1338 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
1339 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right, obj);
1340 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
1341 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom, obj);
1343 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1344 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1345 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1346 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1347 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1349 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1351 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1356 EAPI Elm_List_Item *
1357 elm_list_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1359 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1360 Widget_Data *wd = elm_widget_data_get(obj);
1361 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1363 wd->items = eina_list_append(wd->items, it);
1364 it->node = eina_list_last(wd->items);
1365 elm_box_pack_end(wd->box, it->base.view);
1369 EAPI Elm_List_Item *
1370 elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1372 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1373 Widget_Data *wd = elm_widget_data_get(obj);
1374 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1376 wd->items = eina_list_prepend(wd->items, it);
1377 it->node = wd->items;
1378 elm_box_pack_start(wd->box, it->base.view);
1382 EAPI Elm_List_Item *
1383 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)
1388 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
1389 if (!before->node) return NULL;
1390 ELM_LIST_ITEM_CHECK_DELETED_RETURN(before, NULL);
1392 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1393 wd = elm_widget_data_get(obj);
1394 if (!wd) return NULL;
1395 it = _item_new(obj, label, icon, end, func, data);
1396 wd->items = eina_list_prepend_relative_list(wd->items, it, before->node);
1397 it->node = before->node->prev;
1398 elm_box_pack_before(wd->box, it->base.view, before->base.view);
1402 EAPI Elm_List_Item *
1403 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)
1408 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
1409 if (!after->node) return NULL;
1410 ELM_LIST_ITEM_CHECK_DELETED_RETURN(after, NULL);
1412 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1413 wd = elm_widget_data_get(obj);
1414 if (!wd) return NULL;
1415 it = _item_new(obj, label, icon, end, func, data);
1416 wd->items = eina_list_append_relative_list(wd->items, it, after->node);
1417 it->node = after->node->next;
1418 elm_box_pack_after(wd->box, it->base.view, after->base.view);
1422 EAPI Elm_List_Item *
1423 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)
1425 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1426 Widget_Data *wd = elm_widget_data_get(obj);
1427 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1430 wd->items = eina_list_sorted_insert(wd->items, cmp_func, it);
1431 l = eina_list_data_find_list(wd->items, it);
1432 l = eina_list_next(l);
1435 it->node = eina_list_last(wd->items);
1436 elm_box_pack_end(wd->box, it->base.view);
1440 Elm_List_Item *before = eina_list_data_get(l);
1441 it->node = before->node->prev;
1442 elm_box_pack_before(wd->box, it->base.view, before->base.view);
1448 elm_list_clear(Evas_Object *obj)
1450 ELM_CHECK_WIDTYPE(obj, widtype);
1451 Widget_Data *wd = elm_widget_data_get(obj);
1455 if (!wd->items) return;
1457 eina_list_free(wd->selected);
1458 wd->selected = NULL;
1460 if (wd->walking > 0)
1464 EINA_LIST_FOREACH(wd->items, n, it)
1466 if (it->deleted) continue;
1467 it->deleted = EINA_TRUE;
1468 wd->to_delete = eina_list_append(wd->to_delete, it);
1473 evas_object_ref(obj);
1476 EINA_LIST_FREE(wd->items, it)
1478 elm_widget_item_pre_notify_del(it);
1479 _elm_list_item_free(it);
1482 _elm_list_unwalk(wd);
1486 evas_object_unref(obj);
1490 elm_list_go(Evas_Object *obj)
1492 ELM_CHECK_WIDTYPE(obj, widtype);
1493 Widget_Data *wd = elm_widget_data_get(obj);
1499 elm_list_multi_select_set(Evas_Object *obj, Eina_Bool multi)
1501 ELM_CHECK_WIDTYPE(obj, widtype);
1502 Widget_Data *wd = elm_widget_data_get(obj);
1508 elm_list_multi_select_get(const Evas_Object *obj)
1510 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1511 Widget_Data *wd = elm_widget_data_get(obj);
1512 if (!wd) return EINA_FALSE;
1517 elm_list_mode_set(Evas_Object *obj, Elm_List_Mode mode)
1519 ELM_CHECK_WIDTYPE(obj, widtype);
1523 wd = elm_widget_data_get(obj);
1526 if (wd->mode == mode)
1530 _elm_list_mode_set_internal(wd);
1534 elm_list_mode_get(const Evas_Object *obj)
1536 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
1537 Widget_Data *wd = elm_widget_data_get(obj);
1538 if (!wd) return ELM_LIST_LAST;
1543 elm_list_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1545 ELM_CHECK_WIDTYPE(obj, widtype);
1548 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1550 wd = elm_widget_data_get(obj);
1554 if (wd->h_mode == horizontal)
1557 wd->h_mode = horizontal;
1558 elm_box_horizontal_set(wd->box, horizontal);
1562 evas_object_size_hint_weight_set(wd->box, 0.0, EVAS_HINT_EXPAND);
1563 evas_object_size_hint_align_set(wd->box, 0.0, EVAS_HINT_FILL);
1564 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1568 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1569 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1570 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, bounce);
1573 _elm_list_mode_set_internal(wd);
1577 elm_list_horizontal_get(const Evas_Object *obj)
1579 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1583 wd = elm_widget_data_get(obj);
1591 elm_list_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
1593 ELM_CHECK_WIDTYPE(obj, widtype);
1594 Widget_Data *wd = elm_widget_data_get(obj);
1596 wd->always_select = always_select;
1600 elm_list_always_select_mode_get(const Evas_Object *obj)
1602 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1603 Widget_Data *wd = elm_widget_data_get(obj);
1604 if (!wd) return EINA_FALSE;
1605 return wd->always_select;
1608 EAPI const Eina_List *
1609 elm_list_items_get(const Evas_Object *obj)
1611 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1612 Widget_Data *wd = elm_widget_data_get(obj);
1613 if (!wd) return NULL;
1617 EAPI Elm_List_Item *
1618 elm_list_selected_item_get(const Evas_Object *obj)
1620 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1621 Widget_Data *wd = elm_widget_data_get(obj);
1622 if (!wd) return NULL;
1623 if (wd->selected) return wd->selected->data;
1627 EAPI const Eina_List *
1628 elm_list_selected_items_get(const Evas_Object *obj)
1630 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1631 Widget_Data *wd = elm_widget_data_get(obj);
1632 if (!wd) return NULL;
1633 return wd->selected;
1637 elm_list_item_separator_set(Elm_List_Item *it, Eina_Bool setting)
1639 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1640 it->is_separator = !!setting;
1644 elm_list_item_separator_get(const Elm_List_Item *it)
1646 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1647 return it->is_separator;
1652 elm_list_item_selected_set(Elm_List_Item *it, Eina_Bool selected)
1654 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1655 Evas_Object *obj = it->base.widget;
1656 Widget_Data *wd = elm_widget_data_get(obj);
1659 selected = !!selected;
1660 if (it->selected == selected) return;
1662 evas_object_ref(obj);
1669 while (wd->selected)
1670 _item_unselect(wd->selected->data);
1678 _elm_list_unwalk(wd);
1679 evas_object_unref(obj);
1683 elm_list_item_selected_get(const Elm_List_Item *it)
1685 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1686 return it->selected;
1690 elm_list_item_show(Elm_List_Item *it)
1692 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1693 Widget_Data *wd = elm_widget_data_get(it->base.widget);
1694 Evas_Coord bx, by, bw, bh;
1695 Evas_Coord x, y, w, h;
1697 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1698 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
1702 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
1706 elm_list_item_bring_in(Elm_List_Item *it)
1708 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1709 Widget_Data *wd = elm_widget_data_get(it->base.widget);
1710 Evas_Coord bx, by, bw, bh;
1711 Evas_Coord x, y, w, h;
1713 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1714 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
1718 elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
1722 elm_list_item_del(Elm_List_Item *it)
1724 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1725 Evas_Object *obj = it->base.widget;
1726 Widget_Data *wd = elm_widget_data_get(obj);
1729 if (it->selected) _item_unselect(it);
1731 if (wd->walking > 0)
1733 if (it->deleted) return;
1734 it->deleted = EINA_TRUE;
1735 wd->to_delete = eina_list_append(wd->to_delete, it);
1739 wd->items = eina_list_remove_list(wd->items, it->node);
1741 evas_object_ref(obj);
1744 elm_widget_item_pre_notify_del(it);
1745 _elm_list_item_free(it);
1747 _elm_list_unwalk(wd);
1748 evas_object_unref(obj);
1752 elm_list_item_del_cb_set(Elm_List_Item *it, Evas_Smart_Cb func)
1754 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1755 elm_widget_item_del_cb_set(it, func);
1759 elm_list_item_data_get(const Elm_List_Item *it)
1761 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1762 return elm_widget_item_data_get(it);
1766 elm_list_item_icon_get(const Elm_List_Item *it)
1768 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1769 if (it->dummy_icon) return NULL;
1774 elm_list_item_icon_set(Elm_List_Item *it, Evas_Object *icon)
1776 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1777 if (it->icon == icon) return;
1778 if ((it->dummy_icon) && (!icon)) return;
1781 evas_object_del(it->icon);
1782 it->dummy_icon = EINA_FALSE;
1786 icon = evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1787 evas_object_color_set(icon, 0, 0, 0, 0);
1788 it->dummy_icon = EINA_TRUE;
1792 evas_object_del(it->icon);
1797 edje_object_part_swallow(it->base.view, "elm.swallow.icon", icon);
1801 elm_list_item_end_get(const Elm_List_Item *it)
1803 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1804 if (it->dummy_end) return NULL;
1809 elm_list_item_end_set(Elm_List_Item *it, Evas_Object *end)
1811 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1812 if (it->end == end) return;
1813 if ((it->dummy_end) && (!end)) return;
1816 evas_object_del(it->end);
1817 it->dummy_icon = EINA_FALSE;
1821 end = evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1822 evas_object_color_set(end, 0, 0, 0, 0);
1823 it->dummy_end = EINA_TRUE;
1827 evas_object_del(it->end);
1832 edje_object_part_swallow(it->base.view, "elm.swallow.end", end);
1836 elm_list_item_base_get(const Elm_List_Item *it)
1838 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1839 return it->base.view;
1843 elm_list_item_label_get(const Elm_List_Item *it)
1845 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1850 elm_list_item_label_set(Elm_List_Item *it, const char *text)
1852 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1853 if (!eina_stringshare_replace(&it->label, text)) return;
1855 edje_object_part_text_set(it->base.view, "elm.text", it->label);
1858 EAPI Elm_List_Item *
1859 elm_list_item_prev(const Elm_List_Item *it)
1861 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1862 if (it->node->prev) return it->node->prev->data;
1866 EAPI Elm_List_Item *
1867 elm_list_item_next(const Elm_List_Item *it)
1869 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1870 if (it->node->next) return it->node->next->data;
1875 elm_list_item_tooltip_text_set(Elm_List_Item *item, const char *text)
1877 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1878 elm_widget_item_tooltip_text_set(item, text);
1882 elm_list_item_tooltip_content_cb_set(Elm_List_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
1884 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1885 elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
1889 elm_list_item_tooltip_unset(Elm_List_Item *item)
1891 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1892 elm_widget_item_tooltip_unset(item);
1896 elm_list_item_tooltip_style_set(Elm_List_Item *item, const char *style)
1898 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1899 elm_widget_item_tooltip_style_set(item, style);
1903 elm_list_item_tooltip_style_get(const Elm_List_Item *item)
1905 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1906 return elm_widget_item_tooltip_style_get(item);
1910 elm_list_item_cursor_set(Elm_List_Item *item, const char *cursor)
1912 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1913 elm_widget_item_cursor_set(item, cursor);
1917 elm_list_item_cursor_get(const Elm_List_Item *item)
1919 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1920 return elm_widget_item_cursor_get(item);
1924 elm_list_item_cursor_unset(Elm_List_Item *item)
1926 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1927 elm_widget_item_cursor_unset(item);
1931 elm_list_item_cursor_style_set(Elm_List_Item *item, const char *style)
1933 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1934 elm_widget_item_cursor_style_set(item, style);
1938 elm_list_item_cursor_style_get(const Elm_List_Item *item)
1940 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1941 return elm_widget_item_cursor_style_get(item);
1945 elm_list_item_cursor_engine_only_set(Elm_List_Item *item, Eina_Bool engine_only)
1947 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1948 elm_widget_item_cursor_engine_only_set(item, engine_only);
1952 elm_list_item_cursor_engine_only_get(const Elm_List_Item *item)
1954 ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1955 return elm_widget_item_cursor_engine_only_get(item);
1959 elm_list_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1961 ELM_CHECK_WIDTYPE(obj, widtype);
1962 Widget_Data *wd = elm_widget_data_get(obj);
1965 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
1969 elm_list_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1971 ELM_CHECK_WIDTYPE(obj, widtype);
1972 Widget_Data *wd = elm_widget_data_get(obj);
1974 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
1978 elm_list_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
1980 ELM_CHECK_WIDTYPE(obj, widtype);
1981 Widget_Data *wd = elm_widget_data_get(obj);
1983 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
1984 (policy_v >= ELM_SCROLLER_POLICY_LAST))
1986 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
1990 elm_list_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
1992 ELM_CHECK_WIDTYPE(obj, widtype);
1993 Widget_Data *wd = elm_widget_data_get(obj);
1994 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
1995 if ((!wd) || (!wd->scr)) return;
1996 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
1997 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
1998 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
2002 elm_list_item_disabled_set(Elm_List_Item *it, Eina_Bool disabled)
2004 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2006 if (it->disabled == disabled)
2009 it->disabled = !!disabled;
2012 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
2014 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
2018 elm_list_item_disabled_get(const Elm_List_Item *it)
2020 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2022 return it->disabled;