1 #include <Elementary.h>
3 #include "els_scroller.h"
7 typedef struct _Widget_Data Widget_Data;
8 typedef struct _Elm_List_Item Elm_List_Item;
12 Evas_Object *scr, *box, *self;
13 Eina_List *items, *selected, *to_delete;
14 Elm_Object_Item *last_selected_item;
17 Evas_Coord minw[2], minh[2];
18 Eina_Bool scr_minw : 1;
19 Eina_Bool scr_minh : 1;
24 } history[SWIPE_MOVES];
26 Eina_Bool fix_pending : 1;
27 Eina_Bool on_hold : 1;
29 Eina_Bool always_select : 1;
30 Eina_Bool longpressed : 1;
31 Eina_Bool wasselected : 1;
40 Evas_Object *icon, *end;
42 Ecore_Timer *long_timer;
43 Ecore_Timer *swipe_timer;
44 Eina_Bool deleted : 1;
46 Eina_Bool is_even : 1;
47 Eina_Bool is_separator : 1;
49 Eina_Bool selected : 1;
50 Eina_Bool highlighted : 1;
51 Eina_Bool dummy_icon : 1;
52 Eina_Bool dummy_end : 1;
55 static const char *widtype = NULL;
56 static void _del_hook(Evas_Object *obj);
57 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
58 static void _theme_hook(Evas_Object *obj);
59 static void _sizing_eval(Evas_Object *obj);
60 static void _disable_hook(Evas_Object *obj);
61 static void _on_focus_hook(void *data, Evas_Object *obj);
62 static void _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source);
63 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
64 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
65 static void _fix_items(Evas_Object *obj);
66 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
67 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
68 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
69 static void _edge_left(void *data, Evas_Object *scr, void *event_info);
70 static void _edge_right(void *data, Evas_Object *scr, void *event_info);
71 static void _edge_top(void *data, Evas_Object *scr, void *event_info);
72 static void _edge_bottom(void *data, Evas_Object *scr, void *event_info);
73 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
74 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
75 static Eina_Bool _item_single_select_up(Widget_Data *wd);
76 static Eina_Bool _item_single_select_down(Widget_Data *wd);
77 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
78 Evas_Callback_Type type, void *event_info);
79 static Eina_Bool _deselect_all_items(Widget_Data *wd);
81 static const char SIG_ACTIVATED[] = "activated";
82 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
83 static const char SIG_SELECTED[] = "selected";
84 static const char SIG_UNSELECTED[] = "unselected";
85 static const char SIG_LONGPRESSED[] = "longpressed";
86 static const char SIG_EDGE_TOP[] = "edge,top";
87 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
88 static const char SIG_EDGE_LEFT[] = "edge,left";
89 static const char SIG_EDGE_RIGHT[] = "edge,right";
91 static const Evas_Smart_Cb_Description _signals[] = {
93 {SIG_CLICKED_DOUBLE, ""},
96 {SIG_LONGPRESSED, ""},
98 {SIG_EDGE_BOTTOM, ""},
100 {SIG_EDGE_RIGHT, ""},
104 #define ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ...) \
105 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, __VA_ARGS__); \
106 if (((Elm_List_Item *) it)->deleted) \
108 ERR("ERROR: "#it" has been DELETED.\n"); \
109 return __VA_ARGS__; \
113 _elm_list_item_free(Elm_List_Item *it)
115 evas_object_event_callback_del_full
116 (VIEW(it), EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
117 evas_object_event_callback_del_full
118 (VIEW(it), EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
119 evas_object_event_callback_del_full
120 (VIEW(it), EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, it);
123 evas_object_event_callback_del_full
124 (it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
125 _changed_size_hints, WIDGET(it));
128 evas_object_event_callback_del_full
129 (it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
130 _changed_size_hints, WIDGET(it));
132 eina_stringshare_del(it->label);
134 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
135 if (it->long_timer) ecore_timer_del(it->long_timer);
136 if (it->icon) evas_object_del(it->icon);
137 if (it->end) evas_object_del(it->end);
139 elm_widget_item_del(it);
143 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
145 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
146 Evas_Event_Key_Down *ev = event_info;
147 Widget_Data *wd = elm_widget_data_get(obj);
148 if (!wd) return EINA_FALSE;
149 if (!wd->items) return EINA_FALSE;
150 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
151 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
153 Elm_List_Item *it = NULL;
156 Evas_Coord step_x = 0;
157 Evas_Coord step_y = 0;
160 Evas_Coord page_x = 0;
161 Evas_Coord page_y = 0;
163 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
164 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
165 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
166 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
168 /* TODO: fix logic for horizontal mode */
169 if ((!strcmp(ev->keyname, "Left")) ||
170 (!strcmp(ev->keyname, "KP_Left")))
173 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
174 (_item_multi_select_up(wd)))
175 || (_item_single_select_up(wd))))
177 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
183 else if ((!strcmp(ev->keyname, "Right")) ||
184 (!strcmp(ev->keyname, "KP_Right")))
187 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
188 (_item_multi_select_down(wd)))
189 || (_item_single_select_down(wd))))
191 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
197 else if ((!strcmp(ev->keyname, "Up")) ||
198 (!strcmp(ev->keyname, "KP_Up")))
201 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
202 (_item_multi_select_up(wd)))
203 || (_item_single_select_up(wd))))
205 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
211 else if ((!strcmp(ev->keyname, "Down")) ||
212 (!strcmp(ev->keyname, "KP_Down")))
215 (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
216 (_item_multi_select_down(wd)))
217 || (_item_single_select_down(wd))))
219 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
225 else if ((!strcmp(ev->keyname, "Home")) ||
226 (!strcmp(ev->keyname, "KP_Home")))
228 it = eina_list_data_get(wd->items);
229 elm_list_item_bring_in((Elm_Object_Item *) it);
230 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
233 else if ((!strcmp(ev->keyname, "End")) ||
234 (!strcmp(ev->keyname, "KP_End")))
236 it = eina_list_data_get(eina_list_last(wd->items));
237 elm_list_item_bring_in((Elm_Object_Item *) it);
238 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
241 else if ((!strcmp(ev->keyname, "Prior")) ||
242 (!strcmp(ev->keyname, "KP_Prior")))
247 x -= -(page_x * v_w) / 100;
254 y -= -(page_y * v_h) / 100;
259 else if ((!strcmp(ev->keyname, "Next")) ||
260 (!strcmp(ev->keyname, "KP_Next")))
265 x += -(page_x * v_w) / 100;
272 y += -(page_y * v_h) / 100;
277 else if (((!strcmp(ev->keyname, "Return")) ||
278 (!strcmp(ev->keyname, "KP_Enter")) ||
279 (!strcmp(ev->keyname, "space")))
280 && (!wd->multi) && (wd->selected))
282 it = (Elm_List_Item *) elm_list_selected_item_get(obj);
283 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
285 else if (!strcmp(ev->keyname, "Escape"))
287 if (!_deselect_all_items(wd)) return EINA_FALSE;
288 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
291 else return EINA_FALSE;
293 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
294 elm_smart_scroller_child_pos_set(wd->scr, x, y);
299 _translate_hook(Evas_Object *obj)
301 evas_object_smart_callback_call(obj, "language,changed", NULL);
305 _deselect_all_items(Widget_Data *wd)
307 if (!wd->selected) return EINA_FALSE;
309 elm_list_item_selected_set((Elm_Object_Item *) wd->selected->data,
316 _item_multi_select_up(Widget_Data *wd)
318 if (!wd->selected) return EINA_FALSE;
319 if (!wd->multi) return EINA_FALSE;
321 Elm_Object_Item *prev = elm_list_item_prev(wd->last_selected_item);
322 if (!prev) return EINA_TRUE;
324 if (elm_list_item_selected_get(prev))
326 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
327 wd->last_selected_item = prev;
328 elm_list_item_show(wd->last_selected_item);
332 elm_list_item_selected_set(prev, EINA_TRUE);
333 elm_list_item_show(prev);
339 _item_multi_select_down(Widget_Data *wd)
341 if (!wd->selected) return EINA_FALSE;
342 if (!wd->multi) return EINA_FALSE;
344 Elm_Object_Item *next = elm_list_item_next(wd->last_selected_item);
345 if (!next) return EINA_TRUE;
347 if (elm_list_item_selected_get(next))
349 elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
350 wd->last_selected_item = next;
351 elm_list_item_show(wd->last_selected_item);
355 elm_list_item_selected_set(next, EINA_TRUE);
356 elm_list_item_show(next);
362 _item_single_select_up(Widget_Data *wd)
364 Elm_Object_Item *prev;
366 if (!wd->selected) prev = eina_list_data_get(eina_list_last(wd->items));
367 else prev = elm_list_item_prev(wd->last_selected_item);
368 if (!prev) return EINA_FALSE;
370 _deselect_all_items(wd);
372 elm_list_item_selected_set(prev, EINA_TRUE);
373 elm_list_item_show(prev);
378 _item_single_select_down(Widget_Data *wd)
380 Elm_Object_Item *next;
382 if (!wd->selected) next = eina_list_data_get(wd->items);
383 else next = elm_list_item_next(wd->last_selected_item);
384 if (!next) return EINA_FALSE;
386 _deselect_all_items(wd);
388 elm_list_item_selected_set(next, EINA_TRUE);
389 elm_list_item_show(next);
394 _elm_list_process_deletions(Widget_Data *wd)
398 wd->walking++; // avoid nested deletion and also _sub_del() fix_items
400 EINA_LIST_FREE(wd->to_delete, it)
402 elm_widget_item_pre_notify_del(it);
404 wd->items = eina_list_remove_list(wd->items, it->node);
405 _elm_list_item_free(it);
412 _elm_list_walk(Widget_Data *wd)
416 ERR("ERROR: walking was negative. fixed!\n");
423 _elm_list_unwalk(Widget_Data *wd)
428 ERR("ERROR: walking became negative. fixed!\n");
436 _elm_list_process_deletions(wd);
440 wd->fix_pending = EINA_FALSE;
441 _fix_items(wd->self);
442 _sizing_eval(wd->self);
447 _del_pre_hook(Evas_Object *obj)
449 Widget_Data *wd = elm_widget_data_get(obj);
452 evas_object_event_callback_del(wd->scr,
453 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
454 _changed_size_hints);
455 evas_object_event_callback_del(wd->box,
456 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
457 _changed_size_hints);
461 _del_hook(Evas_Object *obj)
463 Widget_Data *wd = elm_widget_data_get(obj);
469 ERR("ERROR: list deleted while walking.\n");
472 EINA_LIST_FOREACH(wd->items, n, it) elm_widget_item_pre_notify_del(it);
473 _elm_list_unwalk(wd);
475 ERR("ERROR: leaking nodes!\n");
477 EINA_LIST_FREE(wd->items, it) _elm_list_item_free(it);
478 eina_list_free(wd->selected);
483 _show_region_hook(void *data, Evas_Object *obj)
485 Widget_Data *wd = elm_widget_data_get(data);
486 Evas_Coord x, y, w, h;
488 elm_widget_show_region_get(obj, &x, &y, &w, &h);
489 elm_smart_scroller_child_region_set(wd->scr, x, y, w, h);
493 _disable_hook(Evas_Object *obj)
495 Widget_Data *wd = elm_widget_data_get(obj);
497 if (elm_widget_disabled_get(obj))
499 _signal_emit_hook(obj, "elm,state,disabled", "elm");
500 elm_widget_scroll_freeze_push(obj);
501 elm_widget_scroll_hold_push(obj);
502 /* FIXME: if we get to have a way to only un-highlight items
503 * in the future, keeping them selected... */
504 _deselect_all_items(wd);
508 _signal_emit_hook(obj, "elm,state,enabled", "elm");
509 elm_widget_scroll_freeze_pop(obj);
510 elm_widget_scroll_hold_pop(obj);
515 _sizing_eval(Evas_Object *obj)
518 Widget_Data *wd = elm_widget_data_get(obj);
520 Evas_Coord vw, vh, minw, minh, maxw, maxh, w, h, vmw, vmh;
523 evas_object_size_hint_min_get(wd->box, &minw, &minh);
524 evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
525 evas_object_size_hint_weight_get(wd->box, &xw, &yw);
526 if (!wd->scr) return;
527 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
530 if ((minw > 0) && (vw < minw)) vw = minw;
531 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
533 else if (minw > 0) vw = minw;
536 if ((minh > 0) && (vh < minh)) vh = minh;
537 else if ((maxh > 0) && (vh > maxh)) vh = maxh;
539 else if (minh > 0) vh = minh;
540 evas_object_resize(wd->box, vw, vh);
543 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
545 if (wd->scr_minw) w = vmw + minw;
546 if (wd->scr_minh) h = vmh + minh;
548 evas_object_size_hint_max_get(obj, &maxw, &maxh);
549 if ((maxw > 0) && (w > maxw))
551 if ((maxh > 0) && (h > maxh))
554 evas_object_size_hint_min_set(obj, w, h);
558 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
560 Widget_Data *wd = elm_widget_data_get(obj);
561 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
566 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
568 Widget_Data *wd = elm_widget_data_get(obj);
569 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
570 emission, source, func_cb, data);
574 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
576 Widget_Data *wd = elm_widget_data_get(obj);
577 edje_object_signal_callback_del_full(
578 elm_smart_scroller_edje_object_get(wd->scr),
579 emission, source, func_cb, data);
583 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
585 Widget_Data *wd = elm_widget_data_get(obj);
591 elm_smart_scroller_mirrored_set(wd->scr, rtl);
593 EINA_LIST_FOREACH(wd->items, n, it)
594 edje_object_mirrored_set(VIEW(it), rtl);
598 _theme_hook(Evas_Object *obj)
600 Widget_Data *wd = elm_widget_data_get(obj);
605 _elm_widget_mirrored_reload(obj);
606 _mirrored_set(obj, elm_widget_mirrored_get(obj));
613 elm_smart_scroller_object_theme_set(obj, wd->scr, "list", "base",
614 elm_widget_style_get(obj));
615 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
616 edj = elm_smart_scroller_edje_object_get(wd->scr);
617 str = edje_object_data_get(edj, "focus_highlight");
618 if ((str) && (!strcmp(str, "on")))
619 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
621 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
622 elm_object_style_set(wd->scr, elm_widget_style_get(obj));
624 EINA_LIST_FOREACH(wd->items, n, it)
626 edje_object_scale_set(VIEW(it), elm_widget_scale_get(obj) * _elm_config->scale);
634 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
636 Widget_Data *wd = elm_widget_data_get(obj);
638 if (elm_widget_focus_get(obj))
640 edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
641 evas_object_focus_set(wd->self, EINA_TRUE);
643 if ((wd->selected) && (!wd->last_selected_item))
644 wd->last_selected_item = eina_list_data_get(wd->selected);
648 edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
649 evas_object_focus_set(wd->self, EINA_FALSE);
654 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
656 Widget_Data *wd = elm_widget_data_get(data);
663 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
665 Widget_Data *wd = elm_widget_data_get(obj);
666 Evas_Object *sub = event_info;
672 if ((sub == wd->box) || (sub == wd->scr)) return;
674 EINA_LIST_FOREACH(wd->items, l, it)
676 if ((sub == it->icon) || (sub == it->end))
678 if (it->icon == sub) it->icon = NULL;
679 if (it->end == sub) it->end = NULL;
680 evas_object_event_callback_del_full
681 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints,
689 wd->fix_pending = EINA_TRUE;
696 _item_highlight(Elm_List_Item *it)
698 Evas_Object *obj = WIDGET(it);
699 Widget_Data *wd = elm_widget_data_get(obj);
700 const char *selectraise;
703 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
704 if ((it->highlighted) || (it->base.disabled)) return;
706 evas_object_ref(obj);
709 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
710 selectraise = edje_object_data_get(VIEW(it), "selectraise");
711 if ((selectraise) && (!strcmp(selectraise, "on")))
712 evas_object_raise(VIEW(it));
713 it->highlighted = EINA_TRUE;
715 _elm_list_unwalk(wd);
716 evas_object_unref(obj);
720 _item_select(Elm_List_Item *it)
722 Evas_Object *obj = WIDGET(it);
723 Widget_Data *wd = elm_widget_data_get(obj);
726 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
727 if (it->base.disabled) return;
730 if (wd->always_select) goto call;
733 it->selected = EINA_TRUE;
734 wd->selected = eina_list_append(wd->selected, it);
737 evas_object_ref(obj);
740 if (it->func) it->func((void *)it->base.data, WIDGET(it), it);
741 evas_object_smart_callback_call(obj, SIG_SELECTED, it);
742 it->wd->last_selected_item = (Elm_Object_Item *) it;
744 _elm_list_unwalk(wd);
745 evas_object_unref(obj);
749 _item_unselect(Elm_List_Item *it)
751 Evas_Object *obj = WIDGET(it);
752 Widget_Data *wd = elm_widget_data_get(obj);
753 const char *stacking, *selectraise;
756 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
757 if (!it->highlighted) return;
759 evas_object_ref(obj);
762 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
763 stacking = edje_object_data_get(VIEW(it), "stacking");
764 selectraise = edje_object_data_get(VIEW(it), "selectraise");
765 if ((selectraise) && (!strcmp(selectraise, "on")))
767 if ((stacking) && (!strcmp(stacking, "below")))
768 evas_object_lower(VIEW(it));
770 it->highlighted = EINA_FALSE;
773 it->selected = EINA_FALSE;
774 wd->selected = eina_list_remove(wd->selected, it);
775 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
778 _elm_list_unwalk(wd);
779 evas_object_unref(obj);
783 _swipe_cancel(void *data)
785 Elm_List_Item *it = data;
786 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
788 if (!wd) return ECORE_CALLBACK_CANCEL;
789 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
790 wd->swipe = EINA_FALSE;
792 return ECORE_CALLBACK_RENEW;
796 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
798 Elm_List_Item *it = data;
799 Evas_Object *obj2 = WIDGET(it);
800 Widget_Data *wd = elm_widget_data_get(obj2);
801 Evas_Event_Mouse_Move *ev = event_info;
804 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
806 evas_object_ref(obj2);
809 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
813 wd->on_hold = EINA_TRUE;
816 ecore_timer_del(it->long_timer);
817 it->long_timer = NULL;
819 if (!wd->wasselected)
822 if (wd->movements == SWIPE_MOVES) wd->swipe = EINA_TRUE;
825 wd->history[wd->movements].x = ev->cur.canvas.x;
826 wd->history[wd->movements].y = ev->cur.canvas.y;
827 if (abs((wd->history[wd->movements].x - wd->history[0].x)) > 40)
828 wd->swipe = EINA_TRUE;
834 _elm_list_unwalk(wd);
835 evas_object_unref(obj2);
839 _edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
841 Evas_Object *obj = data;
842 evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
846 _edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
848 Evas_Object *obj = data;
849 evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
853 _edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
855 Evas_Object *obj = data;
856 evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
860 _edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
862 Evas_Object *obj = data;
863 evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
867 _long_press(void *data)
869 Elm_List_Item *it = data;
870 Evas_Object *obj = WIDGET(it);
871 Widget_Data *wd = elm_widget_data_get(obj);
875 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
876 it->long_timer = NULL;
877 if (it->base.disabled) goto end;
879 wd->longpressed = EINA_TRUE;
880 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
883 return ECORE_CALLBACK_CANCEL;
887 _swipe(Elm_List_Item *it)
890 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
892 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
894 wd->swipe = EINA_FALSE;
895 for (i = 0; i < wd->movements; i++)
897 sum += wd->history[i].x;
898 if (abs(wd->history[0].y - wd->history[i].y) > 10) return;
901 sum /= wd->movements;
902 if (abs(sum - wd->history[0].x) <= 10) return;
903 evas_object_smart_callback_call(WIDGET(it), "swipe", it);
907 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
909 Elm_List_Item *it = data;
910 Evas_Object *obj2 = WIDGET(it);
911 Widget_Data *wd = elm_widget_data_get(obj2);
912 Evas_Event_Mouse_Down *ev = event_info;
915 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
916 if (ev->button != 1) return;
917 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
918 else wd->on_hold = EINA_FALSE;
919 if (wd->on_hold) return;
920 wd->wasselected = it->selected;
922 evas_object_ref(obj2);
926 wd->longpressed = EINA_FALSE;
927 if (it->long_timer) ecore_timer_del(it->long_timer);
928 it->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, it);
929 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
930 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
931 /* Always call the callbacks last - the user may delete our context! */
932 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
934 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
935 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
937 wd->swipe = EINA_FALSE;
940 _elm_list_unwalk(wd);
941 evas_object_unref(obj2);
945 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
947 Elm_List_Item *it = data;
948 Evas_Object *obj2 = WIDGET(it);
949 Widget_Data *wd = elm_widget_data_get(obj2);
950 Evas_Event_Mouse_Up *ev = event_info;
953 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
954 if (ev->button != 1) return;
955 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
956 else wd->on_hold = EINA_FALSE;
957 wd->longpressed = EINA_FALSE;
960 ecore_timer_del(it->long_timer);
961 it->long_timer = NULL;
965 ecore_timer_del(it->swipe_timer);
966 it->swipe_timer = NULL;
970 if (wd->swipe) _swipe(data);
971 wd->on_hold = EINA_FALSE;
976 if (!wd->wasselected) _item_unselect(it);
981 if (it->base.disabled)
983 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
985 evas_object_ref(obj2);
995 else _item_unselect(it);
1001 while (wd->selected)
1002 _item_unselect(wd->selected->data);
1003 _item_highlight(it);
1008 const Eina_List *l, *l_next;
1011 EINA_LIST_FOREACH_SAFE(wd->selected, l, l_next, it2)
1012 if (it2 != it) _item_unselect(it2);
1013 _item_highlight(it);
1018 _elm_list_unwalk(wd);
1019 evas_object_unref(obj2);
1023 _item_disable(void *data)
1025 Elm_List_Item *it = data;
1026 if (it->base.disabled)
1027 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1029 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
1033 _item_content_set(void *data, const char *part, Evas_Object *content)
1035 Elm_List_Item *it = data;
1036 Evas_Object **icon_p = NULL;
1037 Eina_Bool dummy = EINA_FALSE;
1039 if ((!part) || (!strcmp(part, "start")))
1041 icon_p = &(it->icon);
1042 dummy = it->dummy_icon;
1043 if (!content) it->dummy_icon = EINA_FALSE;
1044 else it->dummy_icon = EINA_TRUE;
1046 else if (!strcmp(part, "end"))
1048 icon_p = &(it->end);
1049 dummy = it->dummy_end;
1050 if (!content) it->dummy_end = EINA_FALSE;
1051 else it->dummy_end = EINA_TRUE;
1056 if (content == *icon_p) return;
1057 if ((dummy) && (!content)) return;
1058 if (dummy) evas_object_del(*icon_p);
1061 content = evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1062 evas_object_color_set(content, 0, 0, 0, 0);
1066 evas_object_del(*icon_p);
1071 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", content);
1074 static Evas_Object *
1075 _item_content_get(const void *data, const char *part)
1077 Elm_List_Item *it = (Elm_List_Item *)data;
1079 if ((!part) || (!strcmp(part, "start")))
1081 if (it->dummy_icon) return NULL;
1084 else if (!strcmp(part, "end"))
1086 if (it->dummy_end) return NULL;
1092 static Evas_Object *
1093 _item_content_unset(const void *data, const char *part)
1095 Elm_List_Item *it = (Elm_List_Item *)data;
1097 if ((!part) || (!strcmp(part, "start")))
1099 Evas_Object *obj = it->icon;
1100 _item_content_set((void *)data, part, NULL);
1103 else if (!strcmp(part, "end"))
1105 Evas_Object *obj = it->end;
1106 _item_content_set((void *)data, part, NULL);
1113 _item_text_set(void *data, const char *part __UNUSED__, const char *text)
1115 Elm_List_Item *it = data;
1117 if (!eina_stringshare_replace(&it->label, text)) return;
1119 edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1123 _item_text_get(const void *data, const char *part __UNUSED__)
1125 Elm_List_Item *it = (Elm_List_Item *)data;
1130 static Elm_List_Item *
1131 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1133 Widget_Data *wd = elm_widget_data_get(obj);
1136 if (!wd) return NULL;
1137 it = elm_widget_item_new(obj, Elm_List_Item);
1139 it->label = eina_stringshare_add(label);
1143 it->base.data = data;
1144 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
1145 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(obj));
1146 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1148 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1150 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1152 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1153 evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1156 elm_widget_sub_object_add(obj, it->icon);
1157 evas_object_event_callback_add(it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1158 _changed_size_hints, obj);
1162 elm_widget_sub_object_add(obj, it->end);
1163 evas_object_event_callback_add(it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1164 _changed_size_hints, obj);
1166 _elm_widget_item_disable_hook_set((Elm_Widget_Item *)it, _item_disable);
1167 _elm_widget_item_content_set_hook_set((Elm_Widget_Item *)it, _item_content_set);
1168 _elm_widget_item_content_get_hook_set((Elm_Widget_Item *)it, _item_content_get);
1169 _elm_widget_item_content_unset_hook_set((Elm_Widget_Item *)it, _item_content_unset);
1170 _elm_widget_item_text_set_hook_set((Elm_Widget_Item *)it, _item_text_set);
1171 _elm_widget_item_text_get_hook_set((Elm_Widget_Item *)it, _item_text_get);
1176 _elm_list_mode_set_internal(Widget_Data *wd)
1181 if (wd->mode == ELM_LIST_LIMIT)
1185 wd->scr_minw = EINA_TRUE;
1186 wd->scr_minh = EINA_FALSE;
1190 wd->scr_minw = EINA_FALSE;
1191 wd->scr_minh = EINA_TRUE;
1194 else if (wd->mode == ELM_LIST_EXPAND)
1196 wd->scr_minw = EINA_TRUE;
1197 wd->scr_minh = EINA_TRUE;
1201 wd->scr_minw = EINA_FALSE;
1202 wd->scr_minh = EINA_FALSE;
1205 _sizing_eval(wd->self);
1209 _fix_items(Evas_Object *obj)
1211 Widget_Data *wd = elm_widget_data_get(obj);
1215 Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
1218 const char *style = elm_widget_style_get(obj);
1219 const char *it_plain = wd->h_mode ? "h_item" : "item";
1220 const char *it_odd = wd->h_mode ? "h_item_odd" : "item_odd";
1221 const char *it_compress = wd->h_mode ? "h_item_compress" : "item_compress";
1222 const char *it_compress_odd = wd->h_mode ? "h_item_compress_odd" : "item_compress_odd";
1226 wd->fix_pending = EINA_TRUE;
1230 evas_object_ref(obj);
1231 _elm_list_walk(wd); // watch out "return" before unwalk!
1233 EINA_LIST_FOREACH(wd->items, l, it)
1235 if (it->deleted) continue;
1238 evas_object_size_hint_min_get(it->icon, &mw, &mh);
1239 if (mw > minw[0]) minw[0] = mw;
1240 if (mh > minh[0]) minh[0] = mh;
1244 evas_object_size_hint_min_get(it->end, &mw, &mh);
1245 if (mw > minw[1]) minw[1] = mw;
1246 if (mh > minh[1]) minh[1] = mh;
1250 if ((minw[0] != wd->minw[0]) || (minw[1] != wd->minw[1]) ||
1251 (minw[0] != wd->minh[0]) || (minh[1] != wd->minh[1]))
1253 wd->minw[0] = minw[0];
1254 wd->minw[1] = minw[1];
1255 wd->minh[0] = minh[0];
1256 wd->minh[1] = minh[1];
1260 EINA_LIST_FOREACH(wd->items, l, it)
1266 if ((it->even != it->is_even) || (!it->fixed) || (redo))
1268 const char *stacking;
1270 /* FIXME: separators' themes seem to be b0rked */
1271 if (it->is_separator)
1272 _elm_theme_object_set(obj, VIEW(it), "separator",
1273 wd->h_mode ? "horizontal" : "vertical",
1275 else if (wd->mode == ELM_LIST_COMPRESS)
1278 _elm_theme_object_set(obj, VIEW(it), "list",
1279 it_compress, style);
1281 _elm_theme_object_set(obj, VIEW(it), "list",
1282 it_compress_odd, style);
1287 _elm_theme_object_set(obj, VIEW(it), "list", it_plain,
1290 _elm_theme_object_set(obj, VIEW(it), "list", it_odd,
1293 stacking = edje_object_data_get(VIEW(it), "stacking");
1296 if (!strcmp(stacking, "below"))
1297 evas_object_lower(VIEW(it));
1298 else if (!strcmp(stacking, "above"))
1299 evas_object_raise(VIEW(it));
1301 edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1303 if ((!it->icon) && (minh[0] > 0))
1305 it->icon = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1306 evas_object_color_set(it->icon, 0, 0, 0, 0);
1307 it->dummy_icon = EINA_TRUE;
1309 if ((!it->end) && (minh[1] > 0))
1311 it->end = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1312 evas_object_color_set(it->end, 0, 0, 0, 0);
1313 it->dummy_end = EINA_TRUE;
1317 evas_object_size_hint_min_set(it->icon, minw[0], minh[0]);
1318 evas_object_size_hint_max_set(it->icon, 99999, 99999);
1319 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
1323 evas_object_size_hint_min_set(it->end, minw[1], minh[1]);
1324 evas_object_size_hint_max_set(it->end, 99999, 99999);
1325 edje_object_part_swallow(VIEW(it), "elm.swallow.end", it->end);
1329 // this may call up user and it may modify the list item
1330 // but we're safe as we're flagged as walking.
1331 // just don't process further
1332 edje_object_message_signal_process(VIEW(it));
1336 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1337 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
1338 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1339 evas_object_size_hint_min_set(VIEW(it), mw, mh);
1340 evas_object_show(VIEW(it));
1342 if ((it->selected) || (it->highlighted))
1344 const char *selectraise;
1346 // this may call up user and it may modify the list item
1347 // but we're safe as we're flagged as walking.
1348 // just don't process further
1349 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1353 selectraise = edje_object_data_get(VIEW(it), "selectraise");
1354 if ((selectraise) && (!strcmp(selectraise, "on")))
1355 evas_object_raise(VIEW(it));
1357 if (it->base.disabled)
1358 edje_object_signal_emit(VIEW(it), "elm,state,disabled",
1361 it->fixed = EINA_TRUE;
1362 it->is_even = it->even;
1368 evas_object_size_hint_min_get(wd->box, &mw, &mh);
1370 _elm_list_mode_set_internal(wd);
1372 _elm_list_unwalk(wd);
1373 evas_object_unref(obj);
1377 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1379 Widget_Data *wd = elm_widget_data_get(obj);
1382 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
1386 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1388 Widget_Data *wd = elm_widget_data_get(obj);
1391 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1395 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1397 Widget_Data *wd = elm_widget_data_get(obj);
1400 elm_smart_scroller_freeze_set(wd->scr, EINA_TRUE);
1404 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1406 Widget_Data *wd = elm_widget_data_get(obj);
1409 elm_smart_scroller_freeze_set(wd->scr, EINA_FALSE);
1413 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1419 elm_list_add(Evas_Object *parent)
1424 Evas_Coord minw, minh;
1426 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1428 ELM_SET_WIDTYPE(widtype, "list");
1429 elm_widget_type_set(obj, "list");
1430 elm_widget_sub_object_add(parent, obj);
1431 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1432 elm_widget_data_set(obj, wd);
1433 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1434 elm_widget_del_hook_set(obj, _del_hook);
1435 elm_widget_theme_hook_set(obj, _theme_hook);
1436 elm_widget_disable_hook_set(obj, _disable_hook);
1437 elm_widget_can_focus_set(obj, EINA_TRUE);
1438 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1439 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1440 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1441 elm_widget_event_hook_set(obj, _event_hook);
1442 elm_widget_translate_hook_set(obj, _translate_hook);
1445 wd->scr = elm_smart_scroller_add(e);
1446 elm_smart_scroller_widget_set(wd->scr, obj);
1447 elm_widget_resize_object_set(obj, wd->scr);
1448 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1449 _changed_size_hints, obj);
1450 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
1451 evas_object_size_hint_min_set(obj, minw, minh);
1452 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1454 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
1455 _elm_config->thumbscroll_bounce_enable);
1457 wd->box = elm_box_add(parent);
1458 elm_box_homogeneous_set(wd->box, 1);
1459 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1460 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1461 elm_widget_on_show_region_hook_set(wd->box, _show_region_hook, obj);
1462 elm_widget_sub_object_add(obj, wd->box);
1463 elm_smart_scroller_child_set(wd->scr, wd->box);
1464 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1465 _changed_size_hints, obj);
1467 evas_object_show(wd->box);
1471 wd->mode = ELM_LIST_SCROLL;
1473 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1474 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1475 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1476 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
1478 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1479 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1480 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1481 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1482 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1484 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1486 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1492 elm_list_go(Evas_Object *obj)
1494 ELM_CHECK_WIDTYPE(obj, widtype);
1495 Widget_Data *wd = elm_widget_data_get(obj);
1501 elm_list_multi_select_set(Evas_Object *obj, Eina_Bool multi)
1503 ELM_CHECK_WIDTYPE(obj, widtype);
1504 Widget_Data *wd = elm_widget_data_get(obj);
1510 elm_list_multi_select_get(const Evas_Object *obj)
1512 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1513 Widget_Data *wd = elm_widget_data_get(obj);
1514 if (!wd) return EINA_FALSE;
1519 elm_list_mode_set(Evas_Object *obj, Elm_List_Mode mode)
1521 ELM_CHECK_WIDTYPE(obj, widtype);
1525 wd = elm_widget_data_get(obj);
1528 if (wd->mode == mode)
1532 _elm_list_mode_set_internal(wd);
1536 elm_list_mode_get(const Evas_Object *obj)
1538 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
1539 Widget_Data *wd = elm_widget_data_get(obj);
1540 if (!wd) return ELM_LIST_LAST;
1545 elm_list_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1547 ELM_CHECK_WIDTYPE(obj, widtype);
1550 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1552 wd = elm_widget_data_get(obj);
1556 if (wd->h_mode == horizontal)
1559 wd->h_mode = horizontal;
1560 elm_box_horizontal_set(wd->box, horizontal);
1564 evas_object_size_hint_weight_set(wd->box, 0.0, EVAS_HINT_EXPAND);
1565 evas_object_size_hint_align_set(wd->box, 0.0, EVAS_HINT_FILL);
1566 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1570 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1571 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1572 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, bounce);
1575 _elm_list_mode_set_internal(wd);
1579 elm_list_horizontal_get(const Evas_Object *obj)
1581 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1585 wd = elm_widget_data_get(obj);
1593 elm_list_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
1595 ELM_CHECK_WIDTYPE(obj, widtype);
1596 Widget_Data *wd = elm_widget_data_get(obj);
1598 wd->always_select = always_select;
1602 elm_list_always_select_mode_get(const Evas_Object *obj)
1604 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1605 Widget_Data *wd = elm_widget_data_get(obj);
1606 if (!wd) return EINA_FALSE;
1607 return wd->always_select;
1611 elm_list_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1613 ELM_CHECK_WIDTYPE(obj, widtype);
1614 Widget_Data *wd = elm_widget_data_get(obj);
1617 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
1621 elm_list_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1623 ELM_CHECK_WIDTYPE(obj, widtype);
1624 Widget_Data *wd = elm_widget_data_get(obj);
1626 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
1630 elm_list_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
1632 ELM_CHECK_WIDTYPE(obj, widtype);
1633 Widget_Data *wd = elm_widget_data_get(obj);
1634 if ((!wd) || (!wd->scr)) return;
1635 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
1636 (policy_v >= ELM_SCROLLER_POLICY_LAST))
1638 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
1642 elm_list_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
1644 ELM_CHECK_WIDTYPE(obj, widtype);
1645 Widget_Data *wd = elm_widget_data_get(obj);
1646 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
1647 if ((!wd) || (!wd->scr)) return;
1648 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
1649 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
1650 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
1654 elm_list_clear(Evas_Object *obj)
1656 ELM_CHECK_WIDTYPE(obj, widtype);
1657 Widget_Data *wd = elm_widget_data_get(obj);
1661 if (!wd->items) return;
1663 eina_list_free(wd->selected);
1664 wd->selected = NULL;
1666 if (wd->walking > 0)
1670 EINA_LIST_FOREACH(wd->items, n, it)
1672 if (it->deleted) continue;
1673 it->deleted = EINA_TRUE;
1674 wd->to_delete = eina_list_append(wd->to_delete, it);
1679 evas_object_ref(obj);
1682 EINA_LIST_FREE(wd->items, it)
1684 elm_widget_item_pre_notify_del(it);
1685 _elm_list_item_free(it);
1688 _elm_list_unwalk(wd);
1692 evas_object_unref(obj);
1695 EAPI const Eina_List *
1696 elm_list_items_get(const Evas_Object *obj)
1698 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1699 Widget_Data *wd = elm_widget_data_get(obj);
1700 if (!wd) return NULL;
1704 EAPI Elm_Object_Item *
1705 elm_list_selected_item_get(const Evas_Object *obj)
1707 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1708 Widget_Data *wd = elm_widget_data_get(obj);
1709 if (!wd) return NULL;
1710 if (wd->selected) return (Elm_Object_Item *) wd->selected->data;
1714 EAPI const Eina_List *
1715 elm_list_selected_items_get(const Evas_Object *obj)
1717 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1718 Widget_Data *wd = elm_widget_data_get(obj);
1719 if (!wd) return NULL;
1720 return wd->selected;
1723 EAPI Elm_Object_Item *
1724 elm_list_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1726 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1727 Widget_Data *wd = elm_widget_data_get(obj);
1728 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1730 wd->items = eina_list_append(wd->items, it);
1731 it->node = eina_list_last(wd->items);
1732 elm_box_pack_end(wd->box, VIEW(it));
1733 return (Elm_Object_Item *) it;
1736 EAPI Elm_Object_Item *
1737 elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1739 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1740 Widget_Data *wd = elm_widget_data_get(obj);
1741 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1743 wd->items = eina_list_prepend(wd->items, it);
1744 it->node = wd->items;
1745 elm_box_pack_start(wd->box, VIEW(it));
1746 return (Elm_Object_Item *) it;
1749 EAPI Elm_Object_Item *
1750 elm_list_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1752 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1753 ELM_LIST_ITEM_CHECK_DELETED_RETURN(before, NULL);
1756 Elm_List_Item *it, *before_it;
1758 wd = elm_widget_data_get(obj);
1759 if (!wd) return NULL;
1761 before_it = (Elm_List_Item *) before;
1762 if (!before_it->node) return NULL;
1764 it = _item_new(obj, label, icon, end, func, data);
1765 wd->items = eina_list_prepend_relative_list(wd->items, it, before_it->node);
1766 it->node = before_it->node->prev;
1767 elm_box_pack_before(wd->box, VIEW(it), VIEW(before_it));
1768 return (Elm_Object_Item *) it;
1771 EAPI Elm_Object_Item *
1772 elm_list_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1774 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1775 ELM_LIST_ITEM_CHECK_DELETED_RETURN(after, NULL);
1778 Elm_List_Item *it, *after_it;
1780 wd = elm_widget_data_get(obj);
1781 if (!wd) return NULL;
1783 after_it = (Elm_List_Item *) after;
1784 if (!after_it->node) return NULL;
1786 it = _item_new(obj, label, icon, end, func, data);
1787 wd->items = eina_list_append_relative_list(wd->items, it, after_it->node);
1788 it->node = after_it->node->next;
1789 elm_box_pack_after(wd->box, VIEW(it), VIEW(after_it));
1790 return (Elm_Object_Item *) it;
1793 EAPI Elm_Object_Item *
1794 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)
1796 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1797 Widget_Data *wd = elm_widget_data_get(obj);
1798 Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1801 wd->items = eina_list_sorted_insert(wd->items, cmp_func, it);
1802 l = eina_list_data_find_list(wd->items, it);
1803 l = eina_list_next(l);
1806 it->node = eina_list_last(wd->items);
1807 elm_box_pack_end(wd->box, VIEW(it));
1811 Elm_List_Item *before = eina_list_data_get(l);
1812 it->node = before->node->prev;
1813 elm_box_pack_before(wd->box, VIEW(it), VIEW(before));
1815 return (Elm_Object_Item *) it;
1819 elm_list_item_separator_set(Elm_Object_Item *it, Eina_Bool setting)
1821 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1822 ((Elm_List_Item *) it)->is_separator = !!setting;
1826 elm_list_item_separator_get(const Elm_Object_Item *it)
1828 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1829 return ((Elm_List_Item *) it)->is_separator;
1833 elm_list_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1835 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1836 Evas_Object *obj = WIDGET(it);
1837 Widget_Data *wd = elm_widget_data_get(obj);
1838 Elm_List_Item *item = (Elm_List_Item *) it;
1841 selected = !!selected;
1842 if (item->selected == selected) return;
1844 evas_object_ref(obj);
1851 while (wd->selected)
1852 _item_unselect(wd->selected->data);
1854 _item_highlight(item);
1858 _item_unselect(item);
1860 _elm_list_unwalk(wd);
1861 evas_object_unref(obj);
1865 elm_list_item_selected_get(const Elm_Object_Item *it)
1867 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1868 return ((Elm_List_Item *) it)->selected;
1872 elm_list_item_show(Elm_Object_Item *it)
1874 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1875 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1877 Evas_Coord bx, by, bw, bh;
1878 Evas_Coord x, y, w, h;
1880 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1881 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1884 if (wd->scr) elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
1888 elm_list_item_bring_in(Elm_Object_Item *it)
1890 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1891 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1893 Evas_Coord bx, by, bw, bh;
1894 Evas_Coord x, y, w, h;
1896 evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1897 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1900 if (wd->scr) elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
1904 elm_list_item_del(Elm_Object_Item *it)
1906 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1907 Evas_Object *obj = WIDGET(it);
1908 Elm_List_Item *item = (Elm_List_Item *) it;
1909 Widget_Data *wd = elm_widget_data_get(obj);
1912 if (item->selected) _item_unselect(item);
1914 if (wd->walking > 0)
1916 if (item->deleted) return;
1917 item->deleted = EINA_TRUE;
1918 wd->to_delete = eina_list_append(wd->to_delete, item);
1922 wd->items = eina_list_remove_list(wd->items, item->node);
1924 evas_object_ref(obj);
1927 elm_widget_item_pre_notify_del(item);
1928 _elm_list_item_free(item);
1930 _elm_list_unwalk(wd);
1931 evas_object_unref(obj);
1935 elm_list_item_object_get(const Elm_Object_Item *it)
1937 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1941 EAPI Elm_Object_Item *
1942 elm_list_item_prev(const Elm_Object_Item *it)
1944 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1945 Elm_List_Item *item = (Elm_List_Item *) it;
1946 if (item->node->prev) return item->node->prev->data;
1950 EAPI Elm_Object_Item *
1951 elm_list_item_next(const Elm_Object_Item *it)
1953 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1954 Elm_List_Item *item = (Elm_List_Item *) it;
1955 if (item->node->next) return item->node->next->data;
1959 EINA_DEPRECATED EAPI Evas_Object *
1960 elm_list_item_base_get(const Elm_Object_Item *it)
1962 return elm_list_item_object_get(it);
1965 EINA_DEPRECATED EAPI void
1966 elm_list_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled)
1968 elm_object_item_disabled_set(it, disabled);
1971 EINA_DEPRECATED EAPI Eina_Bool
1972 elm_list_item_disabled_get(const Elm_Object_Item *it)
1974 return elm_object_item_disabled_get(it);
1977 EINA_DEPRECATED EAPI void
1978 elm_list_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func)
1980 elm_object_item_del_cb_set(it, func);
1983 EINA_DEPRECATED EAPI void *
1984 elm_list_item_data_get(const Elm_Object_Item *it)
1986 return elm_object_item_data_get(it);
1989 EINA_DEPRECATED EAPI Evas_Object *
1990 elm_list_item_icon_get(const Elm_Object_Item *it)
1992 return _item_content_get(it, NULL);
1995 EINA_DEPRECATED EAPI void
1996 elm_list_item_icon_set(Elm_Object_Item *it, Evas_Object *icon)
1998 _item_content_set(it, NULL, icon);
2001 EINA_DEPRECATED EAPI Evas_Object *
2002 elm_list_item_end_get(const Elm_Object_Item *it)
2004 return _item_content_get(it, "end");
2007 EINA_DEPRECATED EAPI void
2008 elm_list_item_end_set(Elm_Object_Item *it, Evas_Object *end)
2010 _item_content_set(it, "end", end);
2013 EINA_DEPRECATED EAPI const char *
2014 elm_list_item_label_get(const Elm_Object_Item *it)
2016 return _item_text_get(it, NULL);
2019 EINA_DEPRECATED EAPI void
2020 elm_list_item_label_set(Elm_Object_Item *it, const char *text)
2022 _item_text_set(it, NULL, text);
2025 // XXX: all the below - make elm_object_item*() calls to do these
2027 elm_list_item_tooltip_text_set(Elm_Object_Item *it, const char *text)
2029 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2030 elm_widget_item_tooltip_text_set(it, text);
2034 elm_list_item_tooltip_content_cb_set(Elm_Object_Item *it, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
2036 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2037 elm_widget_item_tooltip_content_cb_set(it, func, data, del_cb);
2041 elm_list_item_tooltip_unset(Elm_Object_Item *it)
2043 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2044 elm_widget_item_tooltip_unset(it);
2048 elm_list_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
2050 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2051 return elm_widget_item_tooltip_window_mode_set(it, disable);
2055 elm_list_item_tooltip_window_mode_get(const Elm_Object_Item *it)
2057 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2058 return elm_widget_item_tooltip_window_mode_get(it);
2062 elm_list_item_tooltip_style_set(Elm_Object_Item *it, const char *style)
2064 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2065 elm_widget_item_tooltip_style_set(it, style);
2069 elm_list_item_tooltip_style_get(const Elm_Object_Item *it)
2071 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
2072 return elm_widget_item_tooltip_style_get(it);
2076 elm_list_item_cursor_set(Elm_Object_Item *it, const char *cursor)
2078 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2079 elm_widget_item_cursor_set(it, cursor);
2083 elm_list_item_cursor_get(const Elm_Object_Item *it)
2085 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
2086 return elm_widget_item_cursor_get(it);
2090 elm_list_item_cursor_unset(Elm_Object_Item *it)
2092 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2093 elm_widget_item_cursor_unset(it);
2097 elm_list_item_cursor_style_set(Elm_Object_Item *it, const char *style)
2099 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2100 elm_widget_item_cursor_style_set(it, style);
2104 elm_list_item_cursor_style_get(const Elm_Object_Item *it)
2106 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
2107 return elm_widget_item_cursor_style_get(it);
2111 elm_list_item_cursor_engine_only_set(Elm_Object_Item *it, Eina_Bool engine_only)
2113 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2114 elm_widget_item_cursor_engine_only_set(it, engine_only);
2118 elm_list_item_cursor_engine_only_get(const Elm_Object_Item *it)
2120 ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2121 return elm_widget_item_cursor_engine_only_get(it);