2 #include <Elementary.h>
3 #include <Elementary_Cursor.h>
7 #define MAX_ITEMS_PER_BLOCK 32
8 #define REORDER_EFFECT_TIME 0.5
10 typedef struct _Widget_Data Widget_Data;
11 typedef struct _Item_Block Item_Block;
12 typedef struct _Pan Pan;
13 typedef struct _Item_Cache Item_Cache;
14 typedef enum _Elm_Genlist_Item_Move_effect_Mode
16 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
17 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
18 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
19 ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE = (1 << 2),
20 } Elm_Genlist_Item_Move_effect_Mode;
24 Evas_Object *obj, *scr, *pan_smart;
25 Eina_Inlist *items, *blocks;
26 Eina_List *group_items;
28 Evas_Coord pan_x, pan_y, old_pan_y, w, h, minw, minh, realminw, prev_viewport_w;
29 Ecore_Job *calc_job, *update_job;
30 Ecore_Idle_Enterer *queue_idle_enterer;
31 Ecore_Idler *must_recalc_idler;
32 Eina_List *queue, *selected;
33 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item, *reorder_it, *reorder_rel, *expand_item;
34 Eina_Inlist *item_cache;
35 Evas_Coord anchor_y, reorder_start_y;
37 Ecore_Timer *multi_timer, *scr_hold_timer;
38 Ecore_Animator *reorder_move_animator;
39 const char *mode_type;
40 unsigned int start_time;
41 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
42 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
43 Eina_Bool mouse_down : 1;
44 Eina_Bool multi_down : 1;
45 Eina_Bool multi_timeout : 1;
46 Eina_Bool multitouched : 1;
47 Eina_Bool on_hold : 1;
49 Eina_Bool always_select : 1;
50 Eina_Bool longpressed : 1;
51 Eina_Bool wasselected : 1;
52 Eina_Bool no_select : 1;
53 Eina_Bool bring_in : 1;
54 Eina_Bool compress : 1;
55 Eina_Bool height_for_width : 1;
56 Eina_Bool pan_resize : 1;
57 Eina_Bool homogeneous : 1;
58 Eina_Bool clear_me : 1;
60 Eina_Bool reorder_mode : 1;
61 Eina_Bool reorder_pan_move : 1;
62 Eina_List *dragging_queue;
66 } history[SWIPE_MOVES];
75 int group_item_height;
76 int max_items_per_block;
77 double longpress_timeout;
80 Eina_Bool reorder_deleted : 1;
81 Eina_Bool effect_mode : 1;
82 Eina_Bool auto_scrolled : 1;
84 Ecore_Animator *item_moving_effect_timer;
85 Evas_Object *alpha_bg;
86 Evas_Coord expand_item_end;
87 Evas_Coord expand_item_gap;
89 Ecore_Job *changed_job;
90 Elm_Genlist_Item *rename_it;
101 Evas_Coord x, y, w, h, minw, minh;
102 Eina_Bool want_unrealize : 1;
103 Eina_Bool realized : 1;
104 Eina_Bool changed : 1;
105 Eina_Bool updateme : 1;
106 Eina_Bool changeme : 1;
107 Eina_Bool showme : 1;
108 Eina_Bool must_recalc : 1;
111 struct _Elm_Genlist_Item
113 Elm_Widget_Item base;
118 Evas_Coord x, y, w, h, minw, minh;
119 const Elm_Genlist_Item_Class *itc;
120 Elm_Genlist_Item *parent;
121 Elm_Genlist_Item *group_item;
122 Elm_Genlist_Item_Flags flags;
130 Eina_List *labels, *icons, *states, *icon_objs;
131 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
132 Ecore_Timer *long_timer;
133 Ecore_Timer *swipe_timer;
135 Evas_Coord scrl_x, scrl_y;
137 Elm_Genlist_Item *rel;
138 Evas_Object *mode_view;
143 Elm_Tooltip_Item_Content_Cb content_cb;
144 Evas_Smart_Cb del_cb;
148 const char *mouse_cursor;
155 Eina_Bool before : 1;
157 Eina_Bool want_unrealize : 1;
158 Eina_Bool want_realize : 1;
159 Eina_Bool realized : 1;
160 Eina_Bool selected : 1;
161 Eina_Bool highlighted : 1;
162 Eina_Bool expanded : 1;
163 Eina_Bool disabled : 1;
164 Eina_Bool display_only : 1;
165 Eina_Bool mincalcd : 1;
166 Eina_Bool queued : 1;
167 Eina_Bool showme : 1;
168 Eina_Bool delete_me : 1;
170 Eina_Bool dragging : 1;
171 Eina_Bool updateme : 1;
172 Eina_Bool nocache : 1;
173 Eina_Bool move_effect_enabled : 1;
174 Eina_Bool defer_unrealize : 1;
177 Eina_Bool effect_done : 1;
178 Eina_Bool reordering : 1;
179 Eina_Bool renamed : 1;
180 Eina_Bool effect_item_realized : 1;
181 Eina_List *edit_icon_objs;
182 Evas_Object *edit_obj;
184 Ecore_Animator *item_moving_effect_timer;
185 Evas_Coord old_scrl_y;
192 Evas_Object *base_view, *spacer;
194 const char *item_style; // it->itc->item_style
195 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
196 Eina_Bool compress : 1; // it->wd->compress
197 Eina_Bool odd : 1; // in & 0x1
199 Eina_Bool selected : 1; // it->selected
200 Eina_Bool disabled : 1; // it->disabled
201 Eina_Bool expanded : 1; // it->expanded
204 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
205 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
209 Evas_Object_Smart_Clipped_Data __clipped_data;
211 Ecore_Job *resize_job;
214 static const char *widtype = NULL;
215 static void _item_cache_zero(Widget_Data *wd);
216 static void _del_hook(Evas_Object *obj);
217 static void _mirrored_set(Evas_Object *obj,
219 static void _theme_hook(Evas_Object *obj);
220 static void _show_region_hook(void *data,
222 static void _sizing_eval(Evas_Object *obj);
223 static void _item_realize(Elm_Genlist_Item *it,
226 static void _item_unrealize(Elm_Genlist_Item *it,
228 static void _item_block_unrealize(Item_Block *itb);
229 static void _calc_job(void *data);
230 static void _on_focus_hook(void *data,
232 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
233 static void _changed_job(void *data);
234 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
235 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
236 static Eina_Bool _item_single_select_up(Widget_Data *wd);
237 static Eina_Bool _item_single_select_down(Widget_Data *wd);
238 static Eina_Bool _event_hook(Evas_Object *obj,
240 Evas_Callback_Type type,
242 static void _signal_emit_hook(Evas_Object *obj,
243 const char *emission,
245 static Eina_Bool _deselect_all_items(Widget_Data *wd);
246 static void _pan_calculate(Evas_Object *obj);
247 static void _pan_max_get(Evas_Object *obj,
250 static void _item_position(Elm_Genlist_Item *it,
254 static void _mode_item_realize(Elm_Genlist_Item *it);
255 static void _mode_item_unrealize(Elm_Genlist_Item *it);
256 static void _item_mode_set(Elm_Genlist_Item *it);
257 static void _item_mode_unset(Widget_Data *wd);
258 static void _group_items_recalc(void *data);
259 static void _item_move_after(Elm_Genlist_Item *it,
260 Elm_Genlist_Item *after);
261 static void _item_move_before(Elm_Genlist_Item *it,
262 Elm_Genlist_Item *before);
264 // TODO : refactoring
265 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
266 static unsigned int current_time_get();
267 static Eina_Bool _item_moving_effect_timer_cb(void *data);
268 static int _item_flip_effect_show(Elm_Genlist_Item *it);
269 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
270 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
271 static void _effect_item_unrealize(Elm_Genlist_Item *it);
272 static void _item_auto_scroll(void *data);
274 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
276 static const char SIG_ACTIVATED[] = "activated";
277 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
278 static const char SIG_SELECTED[] = "selected";
279 static const char SIG_UNSELECTED[] = "unselected";
280 static const char SIG_EXPANDED[] = "expanded";
281 static const char SIG_CONTRACTED[] = "contracted";
282 static const char SIG_EXPAND_REQUEST[] = "expand,request";
283 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
284 static const char SIG_REALIZED[] = "realized";
285 static const char SIG_UNREALIZED[] = "unrealized";
286 static const char SIG_DRAG_START_UP[] = "drag,start,up";
287 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
288 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
289 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
290 static const char SIG_DRAG_STOP[] = "drag,stop";
291 static const char SIG_DRAG[] = "drag";
292 static const char SIG_LONGPRESSED[] = "longpressed";
293 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
294 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
295 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
296 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
297 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
298 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
299 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
300 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
301 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
302 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
303 static const char SIG_SWIPE[] = "swipe";
305 static const Evas_Smart_Cb_Description _signals[] = {
306 {SIG_CLICKED_DOUBLE, ""},
309 {SIG_UNSELECTED, ""},
311 {SIG_CONTRACTED, ""},
312 {SIG_EXPAND_REQUEST, ""},
313 {SIG_CONTRACT_REQUEST, ""},
315 {SIG_UNREALIZED, ""},
316 {SIG_DRAG_START_UP, ""},
317 {SIG_DRAG_START_DOWN, ""},
318 {SIG_DRAG_START_LEFT, ""},
319 {SIG_DRAG_START_RIGHT, ""},
322 {SIG_LONGPRESSED, ""},
323 {SIG_SCROLL_EDGE_TOP, ""},
324 {SIG_SCROLL_EDGE_BOTTOM, ""},
325 {SIG_SCROLL_EDGE_LEFT, ""},
326 {SIG_SCROLL_EDGE_RIGHT, ""},
327 {SIG_MULTI_SWIPE_LEFT, ""},
328 {SIG_MULTI_SWIPE_RIGHT, ""},
329 {SIG_MULTI_SWIPE_UP, ""},
330 {SIG_MULTI_SWIPE_DOWN, ""},
331 {SIG_MULTI_PINCH_OUT, ""},
332 {SIG_MULTI_PINCH_IN, ""},
338 _event_hook(Evas_Object *obj,
339 Evas_Object *src __UNUSED__,
340 Evas_Callback_Type type,
343 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
344 Evas_Event_Key_Down *ev = event_info;
345 Widget_Data *wd = elm_widget_data_get(obj);
346 Evas_Coord pan_max_x = 0, pan_max_y = 0;
347 if (!wd) return EINA_FALSE;
348 if (!wd->items) return EINA_FALSE;
349 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
350 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
352 Elm_Genlist_Item *it = NULL;
355 Evas_Coord step_x = 0;
356 Evas_Coord step_y = 0;
359 Evas_Coord page_x = 0;
360 Evas_Coord page_y = 0;
362 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
363 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
364 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
365 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
367 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
371 else if ((!strcmp(ev->keyname, "Right")) ||
372 (!strcmp(ev->keyname, "KP_Right")))
376 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
378 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
379 (_item_multi_select_up(wd)))
380 || (_item_single_select_up(wd)))
382 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
388 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
390 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
391 (_item_multi_select_down(wd)))
392 || (_item_single_select_down(wd)))
394 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
400 else if ((!strcmp(ev->keyname, "Home")) ||
401 (!strcmp(ev->keyname, "KP_Home")))
403 it = elm_genlist_first_item_get(obj);
404 elm_genlist_item_bring_in(it);
405 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
408 else if ((!strcmp(ev->keyname, "End")) ||
409 (!strcmp(ev->keyname, "KP_End")))
411 it = elm_genlist_last_item_get(obj);
412 elm_genlist_item_bring_in(it);
413 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
416 else if ((!strcmp(ev->keyname, "Prior")) ||
417 (!strcmp(ev->keyname, "KP_Prior")))
420 y -= -(page_y * v_h) / 100;
424 else if ((!strcmp(ev->keyname, "Next")) ||
425 (!strcmp(ev->keyname, "KP_Next")))
428 y += -(page_y * v_h) / 100;
432 else if (((!strcmp(ev->keyname, "Return")) ||
433 (!strcmp(ev->keyname, "KP_Enter")) ||
434 (!strcmp(ev->keyname, "space")))
435 && (!wd->multi) && (wd->selected))
437 it = elm_genlist_selected_item_get(obj);
438 elm_genlist_item_expanded_set(it,
439 !elm_genlist_item_expanded_get(it));
440 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
442 else if (!strcmp(ev->keyname, "Escape"))
444 if (!_deselect_all_items(wd)) return EINA_FALSE;
445 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
448 else return EINA_FALSE;
450 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
451 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
453 if (x > pan_max_x) x = pan_max_x;
455 if (y > pan_max_y) y = pan_max_y;
456 elm_smart_scroller_child_pos_set(wd->scr, x, y);
461 _deselect_all_items(Widget_Data *wd)
463 if (!wd->selected) return EINA_FALSE;
465 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
471 _item_multi_select_up(Widget_Data *wd)
473 if (!wd->selected) return EINA_FALSE;
474 if (!wd->multi) return EINA_FALSE;
476 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
477 if (!prev) return EINA_TRUE;
479 if (elm_genlist_item_selected_get(prev))
481 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
482 wd->last_selected_item = prev;
483 elm_genlist_item_show(wd->last_selected_item);
487 elm_genlist_item_selected_set(prev, EINA_TRUE);
488 elm_genlist_item_show(prev);
494 _item_multi_select_down(Widget_Data *wd)
496 if (!wd->selected) return EINA_FALSE;
497 if (!wd->multi) return EINA_FALSE;
499 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
500 if (!next) return EINA_TRUE;
502 if (elm_genlist_item_selected_get(next))
504 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
505 wd->last_selected_item = next;
506 elm_genlist_item_show(wd->last_selected_item);
510 elm_genlist_item_selected_set(next, EINA_TRUE);
511 elm_genlist_item_show(next);
517 _item_single_select_up(Widget_Data *wd)
519 Elm_Genlist_Item *prev;
522 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
523 while ((prev) && (prev->delete_me))
524 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
526 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
528 if (!prev) return EINA_FALSE;
530 _deselect_all_items(wd);
532 elm_genlist_item_selected_set(prev, EINA_TRUE);
533 elm_genlist_item_show(prev);
538 _item_single_select_down(Widget_Data *wd)
540 Elm_Genlist_Item *next;
543 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
544 while ((next) && (next->delete_me))
545 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
547 else next = elm_genlist_item_next_get(wd->last_selected_item);
549 if (!next) return EINA_FALSE;
551 _deselect_all_items(wd);
553 elm_genlist_item_selected_set(next, EINA_TRUE);
554 elm_genlist_item_show(next);
559 _on_focus_hook(void *data __UNUSED__,
562 Widget_Data *wd = elm_widget_data_get(obj);
564 if (elm_widget_focus_get(obj))
566 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
567 evas_object_focus_set(wd->obj, EINA_TRUE);
568 if ((wd->selected) && (!wd->last_selected_item))
569 wd->last_selected_item = eina_list_data_get(wd->selected);
573 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
574 evas_object_focus_set(wd->obj, EINA_FALSE);
579 _del_hook(Evas_Object *obj)
581 Widget_Data *wd = elm_widget_data_get(obj);
583 _item_cache_zero(wd);
584 if (wd->calc_job) ecore_job_del(wd->calc_job);
585 if (wd->update_job) ecore_job_del(wd->update_job);
586 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
587 if (wd->changed_job) ecore_job_del(wd->changed_job);
588 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
589 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
590 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
591 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
595 elm_genlist_clear(obj);
601 _del_pre_hook(Evas_Object *obj)
603 Widget_Data *wd = elm_widget_data_get(obj);
605 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
606 elm_genlist_clear(obj);
607 evas_object_del(wd->pan_smart);
608 wd->pan_smart = NULL;
612 _mirrored_set(Evas_Object *obj,
615 Widget_Data *wd = elm_widget_data_get(obj);
617 _item_cache_zero(wd);
618 elm_smart_scroller_mirrored_set(wd->scr, rtl);
622 _theme_hook(Evas_Object *obj)
624 Widget_Data *wd = elm_widget_data_get(obj);
627 evas_event_freeze(evas_object_evas_get(wd->obj));
628 _item_cache_zero(wd);
629 _elm_widget_mirrored_reload(obj);
630 _mirrored_set(obj, elm_widget_mirrored_get(obj));
631 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
632 elm_widget_style_get(obj));
633 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
634 wd->item_width = wd->item_height = 0;
635 wd->group_item_width = wd->group_item_height = 0;
636 wd->minw = wd->minh = wd->realminw = 0;
637 EINA_INLIST_FOREACH(wd->blocks, itb)
640 Elm_Genlist_Item *it;
642 if (itb->realized) _item_block_unrealize(itb);
643 EINA_LIST_FOREACH(itb->items, l, it)
644 it->mincalcd = EINA_FALSE;
646 itb->changed = EINA_TRUE;
648 if (wd->calc_job) ecore_job_del(wd->calc_job);
649 wd->calc_job = ecore_job_add(_calc_job, wd);
651 evas_event_thaw(evas_object_evas_get(wd->obj));
652 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
656 _show_region_hook(void *data,
659 Widget_Data *wd = elm_widget_data_get(data);
660 Evas_Coord x, y, w, h;
662 elm_widget_show_region_get(obj, &x, &y, &w, &h);
663 //x & y are screen coordinates, Add with pan coordinates
666 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
670 _sizing_eval(Evas_Object *obj)
672 Widget_Data *wd = elm_widget_data_get(obj);
673 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
675 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
676 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
678 if (wd->height_for_width)
682 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
683 if ((vw != 0) && (vw != wd->prev_viewport_w))
687 wd->prev_viewport_w = vw;
688 EINA_INLIST_FOREACH(wd->blocks, itb)
690 itb->must_recalc = EINA_TRUE;
692 if (wd->calc_job) ecore_job_del(wd->calc_job);
693 wd->calc_job = ecore_job_add(_calc_job, wd);
696 if (wd->mode == ELM_LIST_LIMIT)
698 Evas_Coord vmw, vmh, vw, vh;
702 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
703 if ((minw > 0) && (vw < minw)) vw = minw;
704 else if ((maxw > 0) && (vw > maxw))
706 edje_object_size_min_calc
707 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
714 edje_object_size_min_calc
715 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
719 evas_object_size_hint_min_set(obj, minw, minh);
720 evas_object_size_hint_max_set(obj, maxw, maxh);
724 _signal_emit_hook(Evas_Object *obj,
725 const char *emission,
728 Widget_Data *wd = elm_widget_data_get(obj);
729 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
734 _item_highlight(Elm_Genlist_Item *it)
736 const char *selectraise;
737 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
738 (it->disabled) || (it->display_only) || (it->mode_view))
740 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
741 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
742 selectraise = edje_object_data_get(it->base.view, "selectraise");
743 if ((selectraise) && (!strcmp(selectraise, "on")))
745 if (it->edit_obj) evas_object_raise(it->edit_obj);
746 else evas_object_raise(it->base.view);
747 if ((it->group_item) && (it->group_item->realized))
748 evas_object_raise(it->group_item->base.view);
750 it->highlighted = EINA_TRUE;
754 _item_block_del(Elm_Genlist_Item *it)
757 Item_Block *itb = it->block;
759 itb->items = eina_list_remove(itb->items, it);
761 itb->changed = EINA_TRUE;
762 if (!it->wd->reorder_deleted)
764 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
765 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
769 il = EINA_INLIST_GET(itb);
770 Item_Block *itbn = (Item_Block *)(il->next);
772 it->parent->items = eina_list_remove(it->parent->items, it);
774 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
776 if (itbn) itbn->changed = EINA_TRUE;
780 if (itb->count < itb->wd->max_items_per_block/2)
782 il = EINA_INLIST_GET(itb);
783 Item_Block *itbp = (Item_Block *)(il->prev);
784 Item_Block *itbn = (Item_Block *)(il->next);
785 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
787 Elm_Genlist_Item *it2;
789 EINA_LIST_FREE(itb->items, it2)
792 itbp->items = eina_list_append(itbp->items, it2);
794 itbp->changed = EINA_TRUE;
796 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
797 EINA_INLIST_GET(itb));
800 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
804 Eina_List *last = eina_list_last(itb->items);
805 Elm_Genlist_Item *it2 = last->data;
808 itb->items = eina_list_remove_list(itb->items, last);
809 itbn->items = eina_list_prepend(itbn->items, it2);
811 itbn->changed = EINA_TRUE;
814 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
822 _item_subitems_clear(Elm_Genlist_Item *it)
825 Eina_List *tl = NULL, *l;
826 Elm_Genlist_Item *it2;
828 EINA_LIST_FOREACH(it->items, l, it2)
829 tl = eina_list_append(tl, it2);
831 EINA_LIST_FREE(tl, it2)
832 elm_genlist_item_del(it2);
836 _item_del(Elm_Genlist_Item *it)
838 Evas_Object *tob = it->wd->obj;
840 evas_event_freeze(evas_object_evas_get(tob));
841 elm_widget_item_pre_notify_del(it);
842 elm_genlist_item_subitems_clear(it);
843 it->wd->walking -= it->walking;
844 if (it->wd->show_item == it) it->wd->show_item = NULL;
845 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
846 if (it->realized) _item_unrealize(it, EINA_FALSE);
847 if (it->effect_item_realized) _effect_item_unrealize(it);
848 if (it->block) _item_block_del(it);
849 if ((!it->delete_me) && (it->itc->func.del))
850 it->itc->func.del((void *)it->base.data, it->base.widget);
851 it->delete_me = EINA_TRUE;
853 it->wd->queue = eina_list_remove(it->wd->queue, it);
855 if (it->wd->anchor_item == it)
857 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
858 if (!it->wd->anchor_item)
859 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
862 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
864 it->parent->items = eina_list_remove(it->parent->items, it);
865 if (it->flags & ELM_GENLIST_ITEM_GROUP)
866 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
867 if (it->long_timer) ecore_timer_del(it->long_timer);
868 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
870 if (it->tooltip.del_cb)
871 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
873 evas_event_thaw(evas_object_evas_get(tob));
874 evas_event_thaw_eval(evas_object_evas_get(tob));
876 elm_widget_item_del(it);
880 _item_select(Elm_Genlist_Item *it)
882 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
885 if (it->wd->always_select) goto call;
888 it->selected = EINA_TRUE;
889 it->wd->selected = eina_list_append(it->wd->selected, it);
895 Evas_Object *baseobj = it->base.widget;
896 const char *objtype = NULL;
897 it->func.func((void *)it->func.data, it->base.widget, it);
898 objtype = evas_object_type_get(baseobj);
899 if ((!objtype) || (!strcmp(objtype,""))) return;
902 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
905 if ((it->wd->clear_me) && (!it->wd->walking))
907 elm_genlist_clear(it->base.widget);
912 if ((!it->walking) && (it->delete_me))
914 if (!it->relcount) _item_del(it);
917 if (it && it->wd) it->wd->last_selected_item = it; // TODO: Remove 'if'?
921 _item_unselect(Elm_Genlist_Item *it)
923 const char *stacking, *selectraise;
925 if ((it->delete_me) || (!it->highlighted)) return;
926 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
927 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
928 stacking = edje_object_data_get(it->base.view, "stacking");
929 selectraise = edje_object_data_get(it->base.view, "selectraise");
930 if ((selectraise) && (!strcmp(selectraise, "on")))
932 if ((stacking) && (!strcmp(stacking, "below")))
933 evas_object_lower(it->base.view);
935 it->highlighted = EINA_FALSE;
938 it->selected = EINA_FALSE;
939 it->wd->selected = eina_list_remove(it->wd->selected, it);
940 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
945 _mouse_move(void *data,
946 Evas *evas __UNUSED__,
950 Elm_Genlist_Item *it = data;
951 Evas_Event_Mouse_Move *ev = event_info;
952 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
953 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
955 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
957 if (!it->wd->on_hold)
959 it->wd->on_hold = EINA_TRUE;
960 if (!it->wd->wasselected)
964 if (it->wd->multitouched)
966 it->wd->cur_x = ev->cur.canvas.x;
967 it->wd->cur_y = ev->cur.canvas.y;
970 if ((it->dragging) && (it->down))
972 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
975 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
976 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
977 if (abs((it->wd->history[it->wd->movements].x -
978 it->wd->history[0].x)) > 40)
979 it->wd->swipe = EINA_TRUE;
985 ecore_timer_del(it->long_timer);
986 it->long_timer = NULL;
988 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
991 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
995 ecore_timer_del(it->long_timer);
996 it->long_timer = NULL;
998 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1000 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1001 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1003 if (!it->wd->reorder_start_y)
1004 it->wd->reorder_start_y = it->block->y + it->y;
1008 else if (it_scrl_y + it->wd->reorder_it->h > oy + oh)
1009 y_pos = oy + oh - it->wd->reorder_it->h;
1014 _item_position(it, it->edit_obj, it->scrl_x, y_pos);
1016 _item_position(it, it->base.view, it->scrl_x, y_pos);
1017 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1018 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1022 if (!it->display_only)
1023 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1024 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1025 x = ev->cur.canvas.x - x;
1026 y = ev->cur.canvas.y - y;
1029 if (adx < 0) adx = -dx;
1032 if (ady < 0) ady = -dy;
1035 if ((adx > minw) || (ady > minh))
1037 it->dragging = EINA_TRUE;
1038 it->wd->dragging_queue = eina_list_append(it->wd->dragging_queue, it);
1041 ecore_timer_del(it->long_timer);
1042 it->long_timer = NULL;
1044 if (!it->wd->wasselected)
1049 evas_object_smart_callback_call(it->base.widget,
1050 SIG_DRAG_START_UP, it);
1054 evas_object_smart_callback_call(it->base.widget,
1055 SIG_DRAG_START_LEFT, it);
1057 evas_object_smart_callback_call(it->base.widget,
1058 SIG_DRAG_START_RIGHT, it);
1064 evas_object_smart_callback_call(it->base.widget,
1065 SIG_DRAG_START_DOWN, it);
1069 evas_object_smart_callback_call(it->base.widget,
1070 SIG_DRAG_START_LEFT, it);
1072 evas_object_smart_callback_call(it->base.widget,
1073 SIG_DRAG_START_RIGHT, it);
1080 _long_press(void *data)
1082 Elm_Genlist_Item *it = data, *it_tmp;
1083 Eina_List *list, *l;
1084 //static Eina_Bool contracted = EINA_FALSE;
1086 it->long_timer = NULL;
1087 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
1088 return ECORE_CALLBACK_CANCEL;
1089 it->wd->longpressed = EINA_TRUE;
1090 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1091 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1093 it->wd->reorder_it = it;
1094 it->wd->reorder_start_y = 0;
1096 evas_object_raise(it->edit_obj);
1098 evas_object_raise(it->base.view);
1099 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1100 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1102 list = elm_genlist_realized_items_get(it->wd->obj);
1103 EINA_LIST_FOREACH(list, l, it_tmp)
1105 if (it != it_tmp) _item_unselect(it_tmp);
1109 EINA_LIST_FOREACH(it->items, l, it_tmp)
1111 if (elm_genlist_item_expanded_get(it_tmp))
1113 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1114 return ECORE_CALLBACK_RENEW;
1118 if (elm_genlist_item_expanded_get(it))
1120 elm_genlist_item_expanded_set(it, EINA_FALSE);
1121 return ECORE_CALLBACK_RENEW;
1124 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1126 edje_object_signal_emit(it->base.view, "elm,state,reorder,enabled", "elm");
1128 return ECORE_CALLBACK_CANCEL;
1132 _swipe(Elm_Genlist_Item *it)
1137 if ((it->display_only) || (it->disabled)) return;
1138 it->wd->swipe = EINA_FALSE;
1139 for (i = 0; i < it->wd->movements; i++)
1141 sum += it->wd->history[i].x;
1142 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1145 sum /= it->wd->movements;
1146 if (abs(sum - it->wd->history[0].x) <= 10) return;
1147 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1151 _swipe_cancel(void *data)
1153 Elm_Genlist_Item *it = data;
1155 if (!it) return ECORE_CALLBACK_CANCEL;
1156 it->wd->swipe = EINA_FALSE;
1157 it->wd->movements = 0;
1158 return ECORE_CALLBACK_RENEW;
1162 _multi_cancel(void *data)
1164 Widget_Data *wd = data;
1166 if (!wd) return ECORE_CALLBACK_CANCEL;
1167 wd->multi_timeout = EINA_TRUE;
1168 return ECORE_CALLBACK_RENEW;
1172 _multi_touch_gesture_eval(void *data)
1174 Elm_Genlist_Item *it = data;
1176 it->wd->multitouched = EINA_FALSE;
1177 if (it->wd->multi_timer)
1179 ecore_timer_del(it->wd->multi_timer);
1180 it->wd->multi_timer = NULL;
1182 if (it->wd->multi_timeout)
1184 it->wd->multi_timeout = EINA_FALSE;
1188 Evas_Coord minw = 0, minh = 0;
1189 Evas_Coord off_x, off_y, off_mx, off_my;
1191 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1192 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1193 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1194 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1195 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1197 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1199 if ((off_x + off_mx) > (off_y + off_my))
1201 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1202 evas_object_smart_callback_call(it->base.widget,
1203 SIG_MULTI_SWIPE_RIGHT, it);
1204 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1205 evas_object_smart_callback_call(it->base.widget,
1206 SIG_MULTI_SWIPE_LEFT, it);
1207 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1208 evas_object_smart_callback_call(it->base.widget,
1209 SIG_MULTI_PINCH_OUT, it);
1211 evas_object_smart_callback_call(it->base.widget,
1212 SIG_MULTI_PINCH_IN, it);
1216 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1217 evas_object_smart_callback_call(it->base.widget,
1218 SIG_MULTI_SWIPE_DOWN, it);
1219 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1220 evas_object_smart_callback_call(it->base.widget,
1221 SIG_MULTI_SWIPE_UP, it);
1222 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1223 evas_object_smart_callback_call(it->base.widget,
1224 SIG_MULTI_PINCH_OUT, it);
1226 evas_object_smart_callback_call(it->base.widget,
1227 SIG_MULTI_PINCH_IN, it);
1230 it->wd->multi_timeout = EINA_FALSE;
1234 _multi_down(void *data,
1235 Evas *evas __UNUSED__,
1236 Evas_Object *obj __UNUSED__,
1239 Elm_Genlist_Item *it = data;
1240 Evas_Event_Multi_Down *ev = event_info;
1242 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1243 it->wd->multi_device = ev->device;
1244 it->wd->multi_down = EINA_TRUE;
1245 it->wd->multitouched = EINA_TRUE;
1246 it->wd->prev_mx = ev->canvas.x;
1247 it->wd->prev_my = ev->canvas.y;
1248 if (!it->wd->wasselected) _item_unselect(it);
1249 it->wd->wasselected = EINA_FALSE;
1250 it->wd->longpressed = EINA_FALSE;
1253 ecore_timer_del(it->long_timer);
1254 it->long_timer = NULL;
1258 it->dragging = EINA_FALSE;
1259 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1261 if (it->swipe_timer)
1263 ecore_timer_del(it->swipe_timer);
1264 it->swipe_timer = NULL;
1266 if (it->wd->on_hold)
1268 it->wd->swipe = EINA_FALSE;
1269 it->wd->movements = 0;
1270 it->wd->on_hold = EINA_FALSE;
1275 _multi_up(void *data,
1276 Evas *evas __UNUSED__,
1277 Evas_Object *obj __UNUSED__,
1280 Elm_Genlist_Item *it = data;
1281 Evas_Event_Multi_Up *ev = event_info;
1283 if (it->wd->multi_device != ev->device) return;
1284 it->wd->multi_device = 0;
1285 it->wd->multi_down = EINA_FALSE;
1286 if (it->wd->mouse_down) return;
1287 _multi_touch_gesture_eval(data);
1291 _multi_move(void *data,
1292 Evas *evas __UNUSED__,
1293 Evas_Object *obj __UNUSED__,
1296 Elm_Genlist_Item *it = data;
1297 Evas_Event_Multi_Move *ev = event_info;
1299 if (it->wd->multi_device != ev->device) return;
1300 it->wd->cur_mx = ev->cur.canvas.x;
1301 it->wd->cur_my = ev->cur.canvas.y;
1305 _mouse_down(void *data,
1306 Evas *evas __UNUSED__,
1310 Elm_Genlist_Item *it = data;
1311 Evas_Event_Mouse_Down *ev = event_info;
1314 if (ev->button != 1) return;
1315 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1317 it->wd->on_hold = EINA_TRUE;
1319 it->down = EINA_TRUE;
1320 it->dragging = EINA_FALSE;
1321 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1322 it->dx = ev->canvas.x - x;
1323 it->dy = ev->canvas.y - y;
1324 it->wd->mouse_down = EINA_TRUE;
1325 if (!it->wd->multitouched)
1327 it->wd->prev_x = ev->canvas.x;
1328 it->wd->prev_y = ev->canvas.y;
1329 it->wd->multi_timeout = EINA_FALSE;
1330 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1331 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1333 it->wd->longpressed = EINA_FALSE;
1334 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1335 else it->wd->on_hold = EINA_FALSE;
1336 if (it->wd->on_hold) return;
1337 it->wd->wasselected = it->selected;
1338 _item_highlight(it);
1339 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1340 if ((!it->disabled) && (!it->display_only))
1342 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1343 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
1345 if (it->long_timer) ecore_timer_del(it->long_timer);
1346 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1347 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1349 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1352 it->long_timer = NULL;
1353 it->wd->swipe = EINA_FALSE;
1354 it->wd->movements = 0;
1358 _mouse_up(void *data,
1359 Evas *evas __UNUSED__,
1360 Evas_Object *obj __UNUSED__,
1363 Elm_Genlist_Item *it = data;
1364 Evas_Event_Mouse_Up *ev = event_info;
1365 Eina_Bool dragged = EINA_FALSE;
1367 if (ev->button != 1) return;
1368 it->down = EINA_FALSE;
1369 it->wd->mouse_down = EINA_FALSE;
1370 if (it->wd->multitouched)
1372 // in single selection modes, some multi touching can make multi highlighted items.
1373 // if a item not selected and highlighted, it should be unhighlighted.
1374 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unselect(it);
1375 if (it->wd->multi_down) return;
1376 _multi_touch_gesture_eval(data);
1379 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1380 else it->wd->on_hold = EINA_FALSE;
1383 ecore_timer_del(it->long_timer);
1384 it->long_timer = NULL;
1386 while (it->wd->dragging_queue)
1388 Elm_Genlist_Item *dragging_it = NULL;
1389 dragging_it = eina_list_data_get(it->wd->dragging_queue);
1390 dragging_it->dragging = EINA_FALSE;
1391 evas_object_smart_callback_call(dragging_it->base.widget, SIG_DRAG_STOP, dragging_it);
1392 if (dragging_it->want_unrealize)
1394 _item_unrealize(dragging_it, EINA_FALSE);
1395 if (dragging_it->block->want_unrealize)
1396 _item_block_unrealize(it->block);
1398 it->wd->dragging_queue = eina_list_remove_list(it->wd->dragging_queue,it->wd->dragging_queue);
1401 if (it->swipe_timer)
1403 ecore_timer_del(it->swipe_timer);
1404 it->swipe_timer = NULL;
1406 if (it->wd->multi_timer)
1408 ecore_timer_del(it->wd->multi_timer);
1409 it->wd->multi_timer = NULL;
1410 it->wd->multi_timeout = EINA_FALSE;
1412 if (it->wd->on_hold)
1414 if (it->wd->swipe) _swipe(data);
1415 it->wd->longpressed = EINA_FALSE;
1416 it->wd->on_hold = EINA_FALSE;
1419 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1421 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1423 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1425 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1426 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1428 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1432 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1433 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1435 it->wd->reorder_deleted = EINA_FALSE;
1436 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1437 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1438 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1439 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1442 if (it->wd->longpressed)
1444 it->wd->longpressed = EINA_FALSE;
1445 if (!it->wd->wasselected)
1447 it->wd->wasselected = EINA_FALSE;
1450 if ((it->disabled) || (dragged) || (it->display_only)) return;
1451 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1456 _item_highlight(it);
1459 else _item_unselect(it);
1465 Widget_Data *wd = it->wd;
1468 while (wd->selected) _item_unselect(wd->selected->data);
1473 const Eina_List *l, *l_next;
1474 Elm_Genlist_Item *it2;
1476 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1477 if (it2 != it) _item_unselect(it2);
1478 //_item_highlight(it);
1481 _item_highlight(it);
1487 _signal_expand_toggle(void *data,
1488 Evas_Object *obj __UNUSED__,
1489 const char *emission __UNUSED__,
1490 const char *source __UNUSED__)
1492 Elm_Genlist_Item *it = data;
1495 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1497 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1501 _signal_expand(void *data,
1502 Evas_Object *obj __UNUSED__,
1503 const char *emission __UNUSED__,
1504 const char *source __UNUSED__)
1506 Elm_Genlist_Item *it = data;
1509 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1513 _signal_contract(void *data,
1514 Evas_Object *obj __UNUSED__,
1515 const char *emission __UNUSED__,
1516 const char *source __UNUSED__)
1518 Elm_Genlist_Item *it = data;
1521 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1525 _scr_hold_timer_cb(void *data)
1527 if (!data) return ECORE_CALLBACK_CANCEL;
1528 Widget_Data *wd = data;
1529 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1530 wd->scr_hold_timer = NULL;
1531 return ECORE_CALLBACK_CANCEL;
1535 _mode_finished_signal_cb(void *data,
1537 const char *emission __UNUSED__,
1538 const char *source __UNUSED__)
1542 Elm_Genlist_Item *it = data;
1543 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1545 Evas *te = evas_object_evas_get(obj);
1547 evas_event_freeze(te);
1548 it->nocache = EINA_FALSE;
1549 _mode_item_unrealize(it);
1550 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1551 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1552 evas_event_thaw(te);
1553 evas_event_thaw_eval(te);
1557 _item_cache_clean(Widget_Data *wd)
1559 evas_event_freeze(evas_object_evas_get(wd->obj));
1560 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1564 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1565 wd->item_cache = eina_inlist_remove(wd->item_cache,
1566 wd->item_cache->last);
1567 wd->item_cache_count--;
1568 if (itc->spacer) evas_object_del(itc->spacer);
1569 if (itc->base_view) evas_object_del(itc->base_view);
1570 if (itc->item_style) eina_stringshare_del(itc->item_style);
1573 evas_event_thaw(evas_object_evas_get(wd->obj));
1574 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1578 _item_cache_zero(Widget_Data *wd)
1580 int pmax = wd->item_cache_max;
1581 wd->item_cache_max = 0;
1582 _item_cache_clean(wd);
1583 wd->item_cache_max = pmax;
1587 _item_cache_add(Elm_Genlist_Item *it)
1591 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1592 if (it->wd->item_cache_max <= 0)
1594 evas_object_del(it->base.view);
1595 it->base.view = NULL;
1596 evas_object_del(it->spacer);
1598 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1599 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1603 it->wd->item_cache_count++;
1604 itc = calloc(1, sizeof(Item_Cache));
1607 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1608 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1611 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1612 EINA_INLIST_GET(itc));
1613 itc->spacer = it->spacer;
1615 itc->base_view = it->base.view;
1616 it->base.view = NULL;
1617 evas_object_hide(itc->base_view);
1618 evas_object_move(itc->base_view, -9999, -9999);
1619 itc->item_style = eina_stringshare_add(it->itc->item_style);
1620 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1621 itc->compress = (it->wd->compress);
1622 itc->odd = (it->order_num_in & 0x1);
1623 itc->selected = it->selected;
1624 itc->disabled = it->disabled;
1625 itc->expanded = it->expanded;
1628 ecore_timer_del(it->long_timer);
1629 it->long_timer = NULL;
1631 if (it->swipe_timer)
1633 ecore_timer_del(it->swipe_timer);
1634 it->swipe_timer = NULL;
1636 // FIXME: other callbacks?
1637 edje_object_signal_callback_del_full(itc->base_view,
1638 "elm,action,expand,toggle",
1639 "elm", _signal_expand_toggle, it);
1640 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1642 _signal_expand, it);
1643 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1644 "elm", _signal_contract, it);
1645 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1647 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1649 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1651 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1653 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1655 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1657 _item_cache_clean(it->wd);
1658 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1659 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1663 _item_cache_find(Elm_Genlist_Item *it)
1666 Eina_Bool tree = 0, odd;
1668 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1669 odd = (it->order_num_in & 0x1);
1670 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1672 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1674 if ((itc->tree == tree) &&
1675 (itc->odd == odd) &&
1676 (itc->compress == it->wd->compress) &&
1677 (!strcmp(it->itc->item_style, itc->item_style)))
1679 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1680 EINA_INLIST_GET(itc));
1681 it->wd->item_cache_count--;
1689 _item_cache_free(Item_Cache *itc)
1691 if (itc->spacer) evas_object_del(itc->spacer);
1692 if (itc->base_view) evas_object_del(itc->base_view);
1693 if (itc->item_style) eina_stringshare_del(itc->item_style);
1698 _icon_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1700 Elm_Genlist_Item *it = data;
1701 if (it) it->defer_unrealize = EINA_TRUE;
1705 _icon_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1707 Elm_Genlist_Item *it = data;
1708 if (it) it->defer_unrealize = EINA_FALSE;
1712 _item_realize(Elm_Genlist_Item *it,
1716 Elm_Genlist_Item *it2;
1717 const char *stacking;
1718 const char *treesize;
1720 int depth, tsize = 20;
1721 Item_Cache *itc = NULL;
1723 if ((it->realized) || (it->delete_me)) return;
1724 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1725 it->order_num_in = in;
1726 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1727 if ((it->nocache) && (!it->renamed))
1728 it->nocache = EINA_FALSE;
1730 itc = _item_cache_find(it);
1731 if (itc && (!it->wd->effect_mode))
1733 it->base.view = itc->base_view;
1734 itc->base_view = NULL;
1735 it->spacer = itc->spacer;
1740 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1741 edje_object_scale_set(it->base.view,
1742 elm_widget_scale_get(it->base.widget) *
1743 _elm_config->scale);
1744 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1745 elm_widget_sub_object_add(it->base.widget, it->base.view);
1747 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1748 strncpy(buf, "tree", sizeof(buf));
1749 else strncpy(buf, "item", sizeof(buf));
1750 if (it->wd->compress)
1751 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1753 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1754 strncat(buf, "/", sizeof(buf) - strlen(buf));
1755 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1757 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1758 elm_widget_style_get(it->base.widget));
1759 edje_object_mirrored_set(it->base.view,
1760 elm_widget_mirrored_get(it->base.widget));
1762 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1763 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1764 elm_widget_sub_object_add(it->base.widget, it->spacer);
1766 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1768 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1770 it->expanded_depth = depth;
1771 treesize = edje_object_data_get(it->base.view, "treesize");
1772 if (treesize) tsize = atoi(treesize);
1773 evas_object_size_hint_min_set(it->spacer,
1774 (depth * tsize) * _elm_config->scale, 1);
1775 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1778 edje_object_signal_callback_add(it->base.view,
1779 "elm,action,expand,toggle",
1780 "elm", _signal_expand_toggle, it);
1781 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1782 "elm", _signal_expand, it);
1783 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1784 "elm", _signal_contract, it);
1785 stacking = edje_object_data_get(it->base.view, "stacking");
1788 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1789 else if (!strcmp(stacking, "above"))
1790 evas_object_raise(it->base.view);
1792 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1794 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1796 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1798 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1800 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1802 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1805 if ((!it->edit_obj) &&(it->wd->edit_mode) &&
1806 (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
1807 _effect_item_realize(it, EINA_FALSE);
1811 if ((it->selected) && (it->selected != itc->selected))
1813 edje_object_signal_emit(it->base.view,
1814 "elm,state,selected", "elm");
1816 edje_object_signal_emit(it->edit_obj,
1817 "elm,state,selected", "elm");
1819 if ((it->disabled) && (it->disabled != itc->disabled))
1821 edje_object_signal_emit(it->base.view,
1822 "elm,state,disabled", "elm");
1824 edje_object_signal_emit(it->edit_obj,
1825 "elm,state,disabled", "elm");
1827 if ((it->expanded) && (it->expanded != itc->expanded))
1829 edje_object_signal_emit(it->base.view,
1830 "elm,state,expanded", "elm");
1832 edje_object_signal_emit(it->edit_obj,
1833 "elm,state,expanded", "elm");
1840 edje_object_signal_emit(it->base.view,
1841 "elm,state,selected", "elm");
1843 edje_object_signal_emit(it->edit_obj,
1844 "elm,state,selected", "elm");
1848 edje_object_signal_emit(it->base.view,
1849 "elm,state,disabled", "elm");
1851 edje_object_signal_emit(it->edit_obj,
1852 "elm,state,disabled", "elm");
1856 edje_object_signal_emit(it->base.view,
1857 "elm,state,expanded", "elm");
1859 edje_object_signal_emit(it->edit_obj,
1860 "elm,state,expanded", "elm");
1865 if ((calc) && (it->wd->homogeneous) &&
1866 ((it->wd->item_width) ||
1867 ((it->wd->item_width) && (it->wd->group_item_width))))
1869 /* homogenous genlist shortcut */
1872 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1874 it->w = it->minw = it->wd->group_item_width;
1875 it->h = it->minh = it->wd->group_item_height;
1879 it->w = it->minw = it->wd->item_width;
1880 it->h = it->minh = it->wd->item_height;
1882 it->mincalcd = EINA_TRUE;
1887 if (it->itc->func.label_get)
1893 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1895 EINA_LIST_FOREACH(it->labels, l, key)
1897 char *s = it->itc->func.label_get
1898 ((void *)it->base.data, it->base.widget, l->data);
1902 edje_object_part_text_set(it->base.view, l->data, s);
1906 edje_object_part_text_set(it->base.view, l->data, "");
1909 if (it->itc->func.icon_get)
1915 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1917 EINA_LIST_FOREACH(it->icons, l, key)
1919 Evas_Object *ic = it->itc->func.icon_get
1920 ((void *)it->base.data, it->base.widget, l->data);
1924 it->icon_objs = eina_list_append(it->icon_objs, ic);
1925 edje_object_part_swallow(it->base.view, key, ic);
1926 evas_object_show(ic);
1927 elm_widget_sub_object_add(it->base.widget, ic);
1928 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
1930 elm_widget_disabled_set(ic, EINA_TRUE);
1936 elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
1937 EINA_LIST_FOREACH(it->icons, l, key)
1939 Evas_Object *ic = it->itc->func.icon_get
1940 ((void *)it->base.data, it->base.widget, l->data);
1943 it->icon_objs = eina_list_append(it->icon_objs, ic);
1944 edje_object_part_swallow(it->base.view, key, ic);
1945 evas_object_show(ic);
1946 elm_widget_sub_object_add(it->base.widget, ic);
1947 // FIXME: if entry calcuates its cursor position correctly and conformant works,
1948 // genlist does not need to handle this focus thing.
1949 evas_object_smart_callback_add(ic, "focused", _icon_focused, it);
1950 evas_object_smart_callback_add(ic, "unfocused", _icon_unfocused, it);
1955 if (it->itc->func.state_get)
1961 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1963 EINA_LIST_FOREACH(it->states, l, key)
1965 Eina_Bool on = it->itc->func.state_get
1966 ((void *)it->base.data, it->base.widget, l->data);
1970 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1971 edje_object_signal_emit(it->base.view, buf, "elm");
1975 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1976 edje_object_signal_emit(it->base.view, buf, "elm");
1980 if (!it->mincalcd || it->wd->pan_resize || ((it->wd->height_for_width) && (it->w != it->minw)))
1982 Evas_Coord mw = -1, mh = -1;
1984 if (it->wd->height_for_width) mw = it->wd->w; // TODO: Removed this. This was removed from upstream.
1986 if (!it->display_only)
1987 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1988 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1989 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1991 if (!it->display_only)
1992 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1993 it->w = it->minw = mw;
1994 it->h = it->minh = mh;
1995 it->mincalcd = EINA_TRUE;
1997 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1999 it->wd->group_item_width = mw;
2000 it->wd->group_item_height = mh;
2002 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2004 it->wd->item_width = mw;
2005 it->wd->item_height = mh;
2008 if (!calc) evas_object_show(it->base.view);
2011 if (it->tooltip.content_cb)
2013 elm_widget_item_tooltip_content_cb_set(it,
2014 it->tooltip.content_cb,
2015 it->tooltip.data, NULL);
2016 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2019 if (it->mouse_cursor)
2020 elm_widget_item_cursor_set(it, it->mouse_cursor);
2022 it->realized = EINA_TRUE;
2023 it->want_unrealize = EINA_FALSE;
2025 if (itc) _item_cache_free(itc);
2026 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2027 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2029 evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2030 if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
2032 if (it->itc->edit_item_style)
2034 if (!it->edit_obj) _effect_item_realize(it, EINA_FALSE);
2035 edje_object_message_signal_process(it->edit_obj);
2038 edje_object_message_signal_process(it->base.view);
2042 _item_unrealize(Elm_Genlist_Item *it,
2047 if (!it->realized) return;
2048 if (it->wd->reorder_it == it) return;
2049 if (it->defer_unrealize && !it->updateme) return;
2050 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2052 evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2055 ecore_timer_del(it->long_timer);
2056 it->long_timer = NULL;
2060 evas_object_del(it->base.view);
2061 it->base.view = NULL;
2062 evas_object_del(it->spacer);
2067 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2068 _item_cache_add(it);
2070 elm_widget_stringlist_free(it->labels);
2072 elm_widget_stringlist_free(it->icons);
2074 elm_widget_stringlist_free(it->states);
2076 EINA_LIST_FREE(it->icon_objs, icon)
2077 evas_object_del(icon);
2079 _mode_item_unrealize(it);
2081 it->realized = EINA_FALSE;
2082 it->want_unrealize = EINA_FALSE;
2083 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2084 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2085 if (it->wd->edit_mode) _effect_item_unrealize(it);
2089 _item_block_recalc(Item_Block *itb,
2094 Elm_Genlist_Item *it;
2095 Evas_Coord minw = 0, minh = 0;
2096 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2099 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2101 EINA_LIST_FOREACH(itb->items, l, it)
2103 if (it->delete_me) continue;
2104 showme |= it->showme;
2109 if (!it->mincalcd) changed = EINA_TRUE;
2112 _item_realize(it, in, EINA_TRUE);
2113 _item_unrealize(it, EINA_TRUE);
2118 _item_realize(it, in, EINA_TRUE);
2119 _item_unrealize(it, EINA_TRUE);
2123 _item_realize(it, in, EINA_FALSE);
2125 if (minw < it->minw) minw = it->minw;
2133 itb->changed = EINA_FALSE;
2134 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2135 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2140 _item_block_realize(Item_Block *itb,
2145 Elm_Genlist_Item *it;
2147 if (itb->realized) return;
2148 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2149 EINA_LIST_FOREACH(itb->items, l, it)
2151 if (it->delete_me) continue;
2152 if (full) _item_realize(it, in, EINA_FALSE);
2155 itb->realized = EINA_TRUE;
2156 itb->want_unrealize = EINA_FALSE;
2157 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2158 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2162 _item_block_unrealize(Item_Block *itb)
2165 Elm_Genlist_Item *it;
2166 Eina_Bool dragging = EINA_FALSE;
2168 if (!itb->realized) return;
2169 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2170 EINA_LIST_FOREACH(itb->items, l, it)
2172 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2176 dragging = EINA_TRUE;
2177 it->want_unrealize = EINA_TRUE;
2180 _item_unrealize(it, EINA_FALSE);
2185 itb->realized = EINA_FALSE;
2186 itb->want_unrealize = EINA_TRUE;
2189 itb->want_unrealize = EINA_FALSE;
2190 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2191 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2195 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2197 Evas_Coord rox, roy, row, roh, oy, oh;
2198 Eina_Bool top = EINA_FALSE;
2199 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2200 if (!reorder_it) return 0;
2202 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2203 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2205 if ((it->wd->reorder_start_y < it->block->y) &&
2206 (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2208 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2209 if (it->block->count == 1)
2210 it->wd->reorder_rel = it;
2212 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2214 it->block->reorder_offset = it->wd->reorder_it->h;
2217 it->block->reorder_offset = 0;
2219 it->scrl_y += it->block->reorder_offset;
2221 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2222 rox, roy + (roh / 2), row, 1));
2225 it->wd->reorder_rel = it;
2226 it->scrl_y += it->wd->reorder_it->h;
2227 return it->wd->reorder_it->h;
2234 _reorder_move_animator_cb(void *data)
2236 Elm_Genlist_Item *it = data;
2237 Eina_Bool down = EINA_FALSE;
2239 int y, dy = it->h / 10 * _elm_config->scale, diff;
2241 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2243 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2246 diff = abs(it->old_scrl_y - it->scrl_y);
2247 if (diff > it->h) y = diff / 2;
2248 if (it->old_scrl_y < it->scrl_y)
2250 it->old_scrl_y += y;
2253 else if (it->old_scrl_y > it->scrl_y)
2255 it->old_scrl_y -= y;
2260 _item_position(it, it->edit_obj, it->scrl_x, it->old_scrl_y);
2262 _item_position(it, it->base.view, it->scrl_x, it->old_scrl_y);
2263 _group_items_recalc(it->wd);
2264 if ((it->wd->reorder_pan_move) ||
2265 (down && it->old_scrl_y >= it->scrl_y) ||
2266 (!down && it->old_scrl_y <= it->scrl_y))
2268 it->old_scrl_y = it->scrl_y;
2269 it->move_effect_enabled = EINA_FALSE;
2270 it->wd->reorder_move_animator = NULL;
2271 return ECORE_CALLBACK_CANCEL;
2273 return ECORE_CALLBACK_RENEW;
2277 _item_position(Elm_Genlist_Item *it,
2285 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2286 evas_object_resize(view, it->w, it->h);
2287 evas_object_move(view, it_x, it_y);
2288 evas_object_show(view);
2289 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2290 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2294 _item_block_position(Item_Block *itb,
2298 Elm_Genlist_Item *it;
2299 Elm_Genlist_Item *git;
2300 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2301 Evas_Coord minh = 0;
2304 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2305 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2306 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2308 EINA_LIST_FOREACH(itb->items, l, it)
2310 if (it->delete_me) continue;
2311 else if (it->wd->reorder_it == it) continue;
2316 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2317 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2319 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2320 cvx, cvy, cvw, cvh));
2321 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2323 if ((itb->realized))
2327 if (!it->realized) _item_realize(it, in, EINA_FALSE);
2330 if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
2331 edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
2339 if (it->wd->reorder_mode)
2340 y += _get_space_for_reorder_item(it);
2341 git = it->group_item;
2344 git->scrl_x = it->scrl_x;
2345 if (git->scrl_y < oy)
2347 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2348 git->scrl_y = (it->scrl_y + it->h) - git->h;
2349 git->want_realize = EINA_TRUE;
2351 if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2353 if (!it->move_effect_enabled)
2355 it->move_effect_enabled = EINA_TRUE;
2356 it->wd->reorder_move_animator =
2358 _reorder_move_animator_cb, it);
2361 if (!it->move_effect_enabled)
2362 if (!it->wd->effect_mode || it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE || ((it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) && it->parent == it->wd->expand_item))
2364 if (it->wd->edit_mode && it->itc->edit_item_style)
2366 _item_position(it, it->edit_obj, it->scrl_x, it->scrl_y);
2370 if((!it->wd->effect_mode || it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE) || ((it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_NONE) && (it->old_scrl_y == it->scrl_y)))
2373 _item_position(it, it->mode_view, it->scrl_x,
2376 _item_position(it, it->base.view, it->scrl_x,
2381 evas_object_resize(it->base.view, it->w, it->h);
2382 evas_object_move(it->base.view, it->scrl_x, it->scrl_y);
2383 evas_object_hide(it->base.view);
2390 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2397 if (vis) it->want_realize = EINA_TRUE;
2399 if (!it->wd->effect_mode || it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE || ((it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) && it->parent == it->wd->expand_item))
2401 it->old_scrl_y = it->scrl_y;
2406 if (!itb->wd->reorder_it) itb->minh = minh;
2407 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2408 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2412 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2414 Elm_Genlist_Item *it = data;
2416 it->mincalcd = EINA_FALSE;
2417 it->block->changeme = EINA_TRUE;
2418 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2419 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2423 _group_items_recalc(void *data)
2425 Widget_Data *wd = data;
2427 Elm_Genlist_Item *git;
2429 evas_event_freeze(evas_object_evas_get(wd->obj));
2430 EINA_LIST_FOREACH(wd->group_items, l, git)
2432 if (git->want_realize)
2435 _item_realize(git, 0, EINA_FALSE);
2436 evas_object_resize(git->base.view, wd->minw, git->h);
2437 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2438 evas_object_show(git->base.view);
2439 evas_object_raise(git->base.view);
2441 else if (!git->want_realize && git->realized)
2444 _item_unrealize(git, EINA_FALSE);
2447 evas_event_thaw(evas_object_evas_get(wd->obj));
2448 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2452 _must_recalc_idler(void *data)
2454 Widget_Data *wd = data;
2455 if (wd->calc_job) ecore_job_del(wd->calc_job);
2456 wd->calc_job = ecore_job_add(_calc_job, wd);
2457 wd->must_recalc_idler = NULL;
2458 return ECORE_CALLBACK_CANCEL;
2462 _calc_job(void *data)
2464 Widget_Data *wd = data;
2465 Item_Block *itb, *chb = NULL;
2466 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2467 int in = 0, minw_change = 0;
2468 Eina_Bool changed = EINA_FALSE;
2470 Eina_Bool did_must_recalc = EINA_FALSE;
2473 t0 = ecore_time_get();
2474 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2478 evas_event_freeze(evas_object_evas_get(wd->obj));
2479 EINA_INLIST_FOREACH(wd->blocks, itb)
2481 Eina_Bool showme = EINA_FALSE;
2484 showme = itb->showme;
2485 itb->showme = EINA_FALSE;
2488 if (itb->realized) _item_block_unrealize(itb);
2490 if ((itb->changed) || (changed) ||
2491 ((itb->must_recalc) && (!did_must_recalc)))
2493 if ((changed) || (itb->must_recalc))
2496 Elm_Genlist_Item *it;
2497 EINA_LIST_FOREACH(itb->items, l, it)
2498 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2499 itb->changed = EINA_TRUE;
2500 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2501 itb->must_recalc = EINA_FALSE;
2502 if (itb->realized) _item_block_unrealize(itb);
2504 showme = _item_block_recalc(itb, in, EINA_FALSE);
2510 if (minw == -1) minw = itb->minw;
2511 else if ((!itb->must_recalc) && (minw < itb->minw))
2514 minw_change = EINA_TRUE;
2520 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2522 wd->show_item->showme = EINA_FALSE;
2524 elm_smart_scroller_region_bring_in(wd->scr,
2526 wd->show_item->block->x,
2528 wd->show_item->block->y,
2529 wd->show_item->block->w,
2532 elm_smart_scroller_child_region_show(wd->scr,
2534 wd->show_item->block->x,
2536 wd->show_item->block->y,
2537 wd->show_item->block->w,
2539 wd->show_item = NULL;
2544 EINA_INLIST_FOREACH(wd->blocks, itb)
2550 if ((chb) && (EINA_INLIST_GET(chb)->next))
2552 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2554 if (itb->realized) _item_block_unrealize(itb);
2557 wd->realminw = minw;
2558 if (minw < wd->w) minw = wd->w;
2559 if ((minw != wd->minw) || (minh != wd->minh))
2563 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2564 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2565 _sizing_eval(wd->obj);
2567 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2569 Elm_Genlist_Item *it;
2572 it = wd->anchor_item;
2573 it_y = wd->anchor_y;
2574 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2575 it->block->y + it->y + it_y);
2576 wd->anchor_item = it;
2577 wd->anchor_y = it_y;
2581 t = ecore_time_get();
2582 if (did_must_recalc)
2584 if (!wd->must_recalc_idler)
2585 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2587 wd->calc_job = NULL;
2588 evas_object_smart_changed(wd->pan_smart);
2589 evas_event_thaw(evas_object_evas_get(wd->obj));
2590 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2594 _update_job(void *data)
2596 Widget_Data *wd = data;
2600 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2602 wd->update_job = NULL;
2605 evas_event_freeze(evas_object_evas_get(wd->obj));
2606 EINA_INLIST_FOREACH(wd->blocks, itb)
2608 Evas_Coord itminw, itminh;
2609 Elm_Genlist_Item *it;
2615 _item_block_position(itb, num);
2619 recalc = EINA_FALSE;
2620 EINA_LIST_FOREACH(itb->items, l2, it)
2629 _item_unrealize(it, EINA_FALSE);
2630 _item_realize(it, num, EINA_FALSE);
2631 position = EINA_TRUE;
2635 _item_realize(it, num, EINA_TRUE);
2636 _item_unrealize(it, EINA_TRUE);
2638 if ((it->minw != itminw) || (it->minh != itminh))
2640 it->updateme = EINA_FALSE;
2644 itb->updateme = EINA_FALSE;
2647 position = EINA_TRUE;
2648 itb->changed = EINA_TRUE;
2649 _item_block_recalc(itb, num0, EINA_FALSE);
2650 _item_block_position(itb, num0);
2655 if (wd->calc_job) ecore_job_del(wd->calc_job);
2656 wd->calc_job = ecore_job_add(_calc_job, wd);
2658 evas_event_thaw(evas_object_evas_get(wd->obj));
2659 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2663 _changed_job(void *data)
2665 Widget_Data *wd = data; Eina_List *l2;
2667 int num, num0, position = 0;
2668 Eina_Bool width_changed = EINA_FALSE, height_changed = EINA_FALSE;
2670 wd->changed_job = NULL;
2672 EINA_INLIST_FOREACH(wd->blocks, itb)
2674 Evas_Coord itminw, itminh;
2675 Elm_Genlist_Item *it;
2681 _item_block_position(itb, num);
2685 width_changed = height_changed = EINA_FALSE;
2686 EINA_LIST_FOREACH(itb->items, l2, it)
2688 if ((!it->mincalcd) && (it->realized))
2690 Evas_Coord mw = -1, mh = -1;
2694 if (it->wd->height_for_width) mw = it->wd->w;
2695 if (!it->display_only)
2696 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2697 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2698 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2699 if (!it->display_only)
2700 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2701 it->w = it->minw = mw;
2702 it->h = it->minh = mh;
2703 it->mincalcd = EINA_TRUE;
2705 //if ((it->minw != itminw) || (it->minh != itminh))
2706 //if ((it->minh != itminh))
2708 if ((it->minw != itminw))
2709 width_changed = EINA_TRUE;
2710 if ((it->minh != itminh))
2711 height_changed = EINA_TRUE;
2713 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2715 it->wd->group_item_width = mw;
2716 it->wd->group_item_height = mh;
2718 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2720 it->wd->item_width = mw;
2721 it->wd->item_height = mh;
2726 itb->changeme = EINA_FALSE;
2727 // TODO: why this is separated.
2731 itb->changed = EINA_TRUE;
2732 _item_block_recalc(itb, num0, 0);
2733 _item_block_position(itb, num0);
2735 else if (width_changed)
2737 _item_block_position(itb, num0);
2742 if (wd->calc_job) ecore_job_del(wd->calc_job);
2743 wd->calc_job = ecore_job_add(_calc_job, wd);
2748 _pan_set(Evas_Object *obj,
2752 Pan *sd = evas_object_smart_data_get(obj);
2758 // Evas_Coord ow, oh;
2759 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2760 // ow = sd->wd->minw - ow;
2761 // if (ow < 0) ow = 0;
2762 // oh = sd->wd->minh - oh;
2763 // if (oh < 0) oh = 0;
2764 // if (x < 0) x = 0;
2765 // if (y < 0) y = 0;
2766 // if (x > ow) x = ow;
2767 // if (y > oh) y = oh;
2768 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2773 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2775 if ((itb->y + itb->h) > y)
2777 Elm_Genlist_Item *it;
2780 EINA_LIST_FOREACH(itb->items, l2, it)
2782 if ((itb->y + it->y) >= y)
2784 sd->wd->anchor_item = it;
2785 sd->wd->anchor_y = -(itb->y + it->y - y);
2793 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2797 _pan_get(Evas_Object *obj,
2801 Pan *sd = evas_object_smart_data_get(obj);
2804 if (x) *x = sd->wd->pan_x;
2805 if (y) *y = sd->wd->pan_y;
2809 _pan_max_get(Evas_Object *obj,
2813 Pan *sd = evas_object_smart_data_get(obj);
2817 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2818 ow = sd->wd->minw - ow;
2820 oh = sd->wd->minh - oh;
2827 _pan_min_get(Evas_Object *obj __UNUSED__,
2836 _pan_child_size_get(Evas_Object *obj,
2840 Pan *sd = evas_object_smart_data_get(obj);
2843 if (w) *w = sd->wd->minw;
2844 if (h) *h = sd->wd->minh;
2848 _pan_add(Evas_Object *obj)
2851 Evas_Object_Smart_Clipped_Data *cd;
2854 cd = evas_object_smart_data_get(obj);
2857 sd->__clipped_data = *cd;
2859 evas_object_smart_data_set(obj, sd);
2863 _pan_del(Evas_Object *obj)
2865 Pan *sd = evas_object_smart_data_get(obj);
2870 ecore_job_del(sd->resize_job);
2871 sd->resize_job = NULL;
2877 _pan_resize_job(void *data)
2881 _sizing_eval(sd->wd->obj);
2882 sd->resize_job = NULL;
2886 _pan_resize(Evas_Object *obj,
2890 Pan *sd = evas_object_smart_data_get(obj);
2894 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2895 if ((ow == w) && (oh == h)) return;
2896 if ((sd->wd->height_for_width) && (ow != w))
2898 sd->wd->pan_resize = EINA_TRUE;
2899 if (sd->resize_job) ecore_job_del(sd->resize_job);
2900 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2902 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2903 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2907 _pan_calculate(Evas_Object *obj)
2909 Pan *sd = evas_object_smart_data_get(obj);
2911 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2913 Elm_Genlist_Item *git;
2917 evas_event_freeze(evas_object_evas_get(obj));
2918 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2919 sd->wd->prev_viewport_w = ow;
2920 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2921 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2923 git->want_realize = EINA_FALSE;
2925 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2927 itb->w = sd->wd->minw;
2928 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2929 itb->y - sd->wd->pan_y + oy,
2931 cvx, cvy, cvw, cvh))
2933 if ((!itb->realized) || (itb->changed))
2934 _item_block_realize(itb, in, 0);
2935 _item_block_position(itb, in);
2939 if (itb->realized) _item_block_unrealize(itb);
2943 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2944 _group_items_recalc(sd->wd);
2946 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2948 if (sd->wd->pan_y != sd->wd->old_pan_y)
2949 sd->wd->reorder_pan_move = EINA_TRUE;
2950 else sd->wd->reorder_pan_move = EINA_FALSE;
2951 evas_object_raise(sd->wd->reorder_it->edit_obj);
2952 sd->wd->old_pan_y = sd->wd->pan_y;
2953 sd->wd->start_time = ecore_loop_time_get();
2956 if (sd->wd->effect_mode &&
2957 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
2958 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
2959 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
2961 if (!sd->wd->item_moving_effect_timer)
2963 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2964 _item_flip_effect_show(sd->wd->expand_item);
2966 evas_object_raise(sd->wd->alpha_bg);
2967 evas_object_show(sd->wd->alpha_bg);
2968 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
2969 sd->wd->start_time = current_time_get();
2970 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2973 else _item_auto_scroll(sd->wd);
2974 sd->wd->pan_resize = EINA_FALSE;
2975 evas_event_thaw(evas_object_evas_get(obj));
2976 evas_event_thaw_eval(evas_object_evas_get(obj));
2980 _pan_move(Evas_Object *obj,
2981 Evas_Coord x __UNUSED__,
2982 Evas_Coord y __UNUSED__)
2984 Pan *sd = evas_object_smart_data_get(obj);
2987 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2988 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2992 _hold_on(void *data __UNUSED__,
2994 void *event_info __UNUSED__)
2996 Widget_Data *wd = elm_widget_data_get(obj);
2998 elm_smart_scroller_hold_set(wd->scr, 1);
3002 _hold_off(void *data __UNUSED__,
3004 void *event_info __UNUSED__)
3006 Widget_Data *wd = elm_widget_data_get(obj);
3008 elm_smart_scroller_hold_set(wd->scr, 0);
3012 _freeze_on(void *data __UNUSED__,
3014 void *event_info __UNUSED__)
3016 Widget_Data *wd = elm_widget_data_get(obj);
3018 elm_smart_scroller_freeze_set(wd->scr, 1);
3022 _freeze_off(void *data __UNUSED__,
3024 void *event_info __UNUSED__)
3026 Widget_Data *wd = elm_widget_data_get(obj);
3028 elm_smart_scroller_freeze_set(wd->scr, 0);
3032 _scroll_edge_left(void *data,
3033 Evas_Object *scr __UNUSED__,
3034 void *event_info __UNUSED__)
3036 Evas_Object *obj = data;
3037 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
3041 _scroll_edge_right(void *data,
3042 Evas_Object *scr __UNUSED__,
3043 void *event_info __UNUSED__)
3045 Evas_Object *obj = data;
3046 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
3050 _scroll_edge_top(void *data,
3051 Evas_Object *scr __UNUSED__,
3052 void *event_info __UNUSED__)
3054 Evas_Object *obj = data;
3055 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
3059 _scroll_edge_bottom(void *data,
3060 Evas_Object *scr __UNUSED__,
3061 void *event_info __UNUSED__)
3063 Evas_Object *obj = data;
3064 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
3068 _mode_item_realize(Elm_Genlist_Item *it)
3072 if ((it->mode_view) || (it->delete_me)) return;
3074 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3075 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
3076 edje_object_scale_set(it->mode_view,
3077 elm_widget_scale_get(it->base.widget) *
3078 _elm_config->scale);
3079 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
3080 elm_widget_sub_object_add(it->base.widget, it->mode_view);
3082 strncpy(buf, "item", sizeof(buf));
3083 if (it->wd->compress)
3084 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3086 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3087 strncat(buf, "/", sizeof(buf) - strlen(buf));
3088 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3090 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
3091 elm_widget_style_get(it->base.widget));
3092 edje_object_mirrored_set(it->mode_view,
3093 elm_widget_mirrored_get(it->base.widget));
3095 /* signal callback add */
3096 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3098 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3100 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3103 /* label_get, icon_get, state_get */
3104 if (it->itc->func.label_get)
3110 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3112 EINA_LIST_FOREACH(it->mode_labels, l, key)
3114 char *s = it->itc->func.label_get
3115 ((void *)it->base.data, it->base.widget, l->data);
3119 edje_object_part_text_set(it->mode_view, l->data, s);
3124 if (it->itc->func.icon_get)
3130 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3132 EINA_LIST_FOREACH(it->mode_icons, l, key)
3134 Evas_Object *ic = it->itc->func.icon_get
3135 ((void *)it->base.data, it->base.widget, l->data);
3139 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
3140 edje_object_part_swallow(it->mode_view, key, ic);
3141 evas_object_show(ic);
3142 elm_widget_sub_object_add(it->base.widget, ic);
3144 elm_widget_disabled_set(ic, EINA_TRUE);
3148 if (it->itc->func.state_get)
3154 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3156 EINA_LIST_FOREACH(it->mode_states, l, key)
3158 Eina_Bool on = it->itc->func.state_get
3159 ((void *)it->base.data, it->base.widget, l->data);
3163 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
3164 edje_object_signal_emit(it->mode_view, buf, "elm");
3169 edje_object_part_swallow(it->mode_view,
3170 edje_object_data_get(it->mode_view, "mode_part"),
3173 it->want_unrealize = EINA_FALSE;
3174 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3175 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3179 _mode_item_unrealize(Elm_Genlist_Item *it)
3181 Widget_Data *wd = it->wd;
3183 if (!it->mode_view) return;
3185 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3186 elm_widget_stringlist_free(it->mode_labels);
3187 it->mode_labels = NULL;
3188 elm_widget_stringlist_free(it->mode_icons);
3189 it->mode_icons = NULL;
3190 elm_widget_stringlist_free(it->mode_states);
3192 EINA_LIST_FREE(it->mode_icon_objs, icon)
3193 evas_object_del(icon);
3195 edje_object_part_unswallow(it->mode_view, it->base.view);
3196 evas_object_smart_member_add(it->base.view, wd->pan_smart);
3197 evas_object_del(it->mode_view);
3198 it->mode_view = NULL;
3200 if (wd->mode_item == it)
3201 wd->mode_item = NULL;
3202 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3203 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3207 _item_mode_set(Elm_Genlist_Item *it)
3210 Widget_Data *wd = it->wd;
3215 it->nocache = EINA_TRUE;
3217 if (wd->scr_hold_timer)
3219 ecore_timer_del(wd->scr_hold_timer);
3220 wd->scr_hold_timer = NULL;
3222 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3223 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3225 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3226 _mode_item_realize(it);
3227 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
3228 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3229 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3231 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3232 edje_object_signal_emit(it->mode_view, buf, "elm");
3236 _item_mode_unset(Widget_Data *wd)
3239 if (!wd->mode_item) return;
3240 char buf[1024], buf2[1024];
3241 Elm_Genlist_Item *it;
3244 it->nocache = EINA_TRUE;
3246 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3247 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3249 edje_object_signal_emit(it->mode_view, buf, "elm");
3250 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3252 wd->mode_item = NULL;
3256 elm_genlist_add(Evas_Object *parent)
3261 Evas_Coord minw, minh;
3262 static Evas_Smart *smart = NULL;
3266 static Evas_Smart_Class sc;
3268 evas_object_smart_clipped_smart_set(&_pan_sc);
3270 sc.name = "elm_genlist_pan";
3271 sc.version = EVAS_SMART_CLASS_VERSION;
3274 sc.resize = _pan_resize;
3275 sc.move = _pan_move;
3276 sc.calculate = _pan_calculate;
3277 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3280 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3282 ELM_SET_WIDTYPE(widtype, "genlist");
3283 elm_widget_type_set(obj, "genlist");
3284 elm_widget_sub_object_add(parent, obj);
3285 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3286 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3287 elm_widget_data_set(obj, wd);
3288 elm_widget_del_hook_set(obj, _del_hook);
3289 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3290 elm_widget_theme_hook_set(obj, _theme_hook);
3291 elm_widget_can_focus_set(obj, EINA_TRUE);
3292 elm_widget_event_hook_set(obj, _event_hook);
3293 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3295 wd->scr = elm_smart_scroller_add(e);
3296 elm_smart_scroller_widget_set(wd->scr, obj);
3297 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3298 elm_widget_style_get(obj));
3299 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3300 _elm_config->thumbscroll_bounce_enable);
3301 elm_widget_resize_object_set(obj, wd->scr);
3303 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3304 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3306 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3307 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3311 wd->mode = ELM_LIST_SCROLL;
3312 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3313 wd->item_cache_max = wd->max_items_per_block * 2;
3314 wd->longpress_timeout = _elm_config->longpress_timeout;
3315 wd->effect_mode = _elm_config->effect_enable;
3317 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3318 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3319 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3320 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3322 wd->pan_smart = evas_object_smart_add(e, smart);
3323 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3326 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3327 _pan_set, _pan_get, _pan_max_get,
3328 _pan_min_get, _pan_child_size_get);
3330 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3332 evas_object_size_hint_min_set(obj, minw, minh);
3334 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3335 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3340 static Elm_Genlist_Item *
3341 _item_new(Widget_Data *wd,
3342 const Elm_Genlist_Item_Class *itc,
3344 Elm_Genlist_Item *parent,
3345 Elm_Genlist_Item_Flags flags,
3347 const void *func_data)
3349 Elm_Genlist_Item *it;
3351 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3352 if (!it) return NULL;
3355 it->base.data = data;
3356 it->parent = parent;
3358 it->func.func = func;
3359 it->func.data = func_data;
3360 it->mouse_cursor = NULL;
3361 it->expanded_depth = 0;
3365 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3366 it->group_item = parent;
3367 else if (it->parent->group_item)
3368 it->group_item = it->parent->group_item;
3374 _item_block_add(Widget_Data *wd,
3375 Elm_Genlist_Item *it)
3377 Item_Block *itb = NULL;
3384 itb = calloc(1, sizeof(Item_Block));
3387 if (!it->rel->block)
3390 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3391 itb->items = eina_list_append(itb->items, it);
3397 wd->blocks = eina_inlist_prepend_relative
3398 (wd->blocks, EINA_INLIST_GET(itb),
3399 EINA_INLIST_GET(it->rel->block));
3401 eina_list_prepend_relative(itb->items, it, it->rel);
3405 wd->blocks = eina_inlist_append_relative
3406 (wd->blocks, EINA_INLIST_GET(itb),
3407 EINA_INLIST_GET(it->rel->block));
3409 eina_list_append_relative(itb->items, it, it->rel);
3419 itb = (Item_Block *)(wd->blocks);
3420 if (itb->count >= wd->max_items_per_block)
3422 itb = calloc(1, sizeof(Item_Block));
3426 eina_inlist_prepend(wd->blocks,
3427 EINA_INLIST_GET(itb));
3432 itb = calloc(1, sizeof(Item_Block));
3436 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3438 itb->items = eina_list_prepend(itb->items, it);
3444 itb = (Item_Block *)(wd->blocks->last);
3445 if (itb->count >= wd->max_items_per_block)
3447 itb = calloc(1, sizeof(Item_Block));
3451 eina_inlist_append(wd->blocks,
3452 EINA_INLIST_GET(itb));
3457 itb = calloc(1, sizeof(Item_Block));
3461 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3463 itb->items = eina_list_append(itb->items, it);
3469 itb = it->rel->block;
3470 if (!itb) goto newblock;
3472 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3474 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3477 itb->changed = EINA_TRUE;
3479 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3480 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3483 it->rel->relcount--;
3484 if ((it->rel->delete_me) && (!it->rel->relcount))
3488 if (itb->count > itb->wd->max_items_per_block)
3492 Elm_Genlist_Item *it2;
3494 newc = itb->count / 2;
3495 itb2 = calloc(1, sizeof(Item_Block));
3499 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3500 EINA_INLIST_GET(itb));
3501 itb2->changed = EINA_TRUE;
3502 while ((itb->count > newc) && (itb->items))
3506 l = eina_list_last(itb->items);
3508 itb->items = eina_list_remove_list(itb->items, l);
3511 itb2->items = eina_list_prepend(itb2->items, it2);
3519 _queue_process(Widget_Data *wd)
3522 Eina_Bool showme = EINA_FALSE;
3525 t0 = ecore_time_get();
3526 //evas_event_freeze(evas_object_evas_get(wd->obj));
3527 for (n = 0; (wd->queue) && (n < 128); n++)
3529 Elm_Genlist_Item *it;
3531 it = wd->queue->data;
3532 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3533 it->queued = EINA_FALSE;
3534 _item_block_add(wd, it);
3535 t = ecore_time_get();
3536 if (it->block->changed)
3538 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3539 it->block->changed = 0;
3541 if (showme) it->block->showme = EINA_TRUE;
3542 if (eina_inlist_count(wd->blocks) > 1)
3544 if ((t - t0) > (ecore_animator_frametime_get())) break;
3547 //evas_event_thaw(evas_object_evas_get(wd->obj));
3548 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3553 _idle_process(void *data, Eina_Bool *wakeup)
3555 Widget_Data *wd = data;
3558 //static double q_start = 0.0;
3559 //if (q_start == 0.0) q_start = ecore_time_get();
3561 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3565 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3567 return ECORE_CALLBACK_CANCEL;
3569 return ECORE_CALLBACK_RENEW;
3573 _item_idle_enterer(void *data)
3575 Widget_Data *wd = data;
3576 Eina_Bool wakeup = EINA_FALSE;
3577 Eina_Bool ok = _idle_process(data, &wakeup);
3582 if (wd->calc_job) ecore_job_del(wd->calc_job);
3583 wd->calc_job = ecore_job_add(_calc_job, wd);
3585 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3590 _item_queue(Widget_Data *wd,
3591 Elm_Genlist_Item *it)
3593 if (it->queued) return;
3594 it->queued = EINA_TRUE;
3595 wd->queue = eina_list_append(wd->queue, it);
3596 // FIXME: why does a freeze then thaw here cause some genlist
3597 // elm_genlist_item_append() to be much much slower?
3598 // evas_event_freeze(evas_object_evas_get(wd->obj));
3599 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3601 if (wd->queue_idle_enterer)
3603 ecore_idle_enterer_del(wd->queue_idle_enterer);
3604 wd->queue_idle_enterer = NULL;
3608 // evas_event_thaw(evas_object_evas_get(wd->obj));
3609 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3610 if (!wd->queue_idle_enterer)
3611 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3615 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3620 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3621 it->wd->reorder_deleted = EINA_TRUE;
3622 _item_block_del(it);
3624 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3626 it->rel->relcount++;
3627 it->before = EINA_FALSE;
3628 if (after->group_item) it->group_item = after->group_item;
3629 _item_queue(it->wd, it);
3631 // TODO: change this to smart callback
3632 if (it->itc->func.moved)
3633 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
3637 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3640 if (!before) return;
3642 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3643 it->wd->reorder_deleted = EINA_TRUE;
3644 _item_block_del(it);
3645 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3647 it->rel->relcount++;
3648 it->before = EINA_TRUE;
3649 if (before->group_item) it->group_item = before->group_item;
3650 _item_queue(it->wd, it);
3652 // TODO: change this to smart callback
3653 if (it->itc->func.moved)
3654 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
3657 EAPI Elm_Genlist_Item *
3658 elm_genlist_item_append(Evas_Object *obj,
3659 const Elm_Genlist_Item_Class *itc,
3661 Elm_Genlist_Item *parent,
3662 Elm_Genlist_Item_Flags flags,
3664 const void *func_data)
3666 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3667 Widget_Data *wd = elm_widget_data_get(obj);
3668 if (!wd) return NULL;
3669 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3671 if (!it) return NULL;
3674 if (flags & ELM_GENLIST_ITEM_GROUP)
3675 wd->group_items = eina_list_append(wd->group_items, it);
3676 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3681 Elm_Genlist_Item *it2 = NULL;
3682 Eina_List *ll = eina_list_last(it->parent->items);
3683 if (ll) it2 = ll->data;
3684 it->parent->items = eina_list_append(it->parent->items, it);
3685 if (!it2) it2 = it->parent;
3687 it2 = elm_genlist_item_prev_get(it2);
3689 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3690 EINA_INLIST_GET(it2));
3692 it->rel->relcount++;
3694 it->before = EINA_FALSE;
3695 _item_queue(wd, it);
3699 EAPI Elm_Genlist_Item *
3700 elm_genlist_item_prepend(Evas_Object *obj,
3701 const Elm_Genlist_Item_Class *itc,
3703 Elm_Genlist_Item *parent,
3704 Elm_Genlist_Item_Flags flags,
3706 const void *func_data)
3708 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3709 Widget_Data *wd = elm_widget_data_get(obj);
3710 if (!wd) return NULL;
3711 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3713 if (!it) return NULL;
3716 if (flags & ELM_GENLIST_ITEM_GROUP)
3717 wd->group_items = eina_list_prepend(wd->group_items, it);
3718 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3723 Elm_Genlist_Item *it2 = NULL;
3724 Eina_List *ll = it->parent->items;
3725 if (ll) it2 = ll->data;
3726 it->parent->items = eina_list_prepend(it->parent->items, it);
3727 if (!it2) it2 = it->parent;
3729 it2 = elm_genlist_item_next_get(it2);
3731 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3732 EINA_INLIST_GET(it2));
3734 it->rel->relcount++;
3736 it->before = EINA_TRUE;
3737 _item_queue(wd, it);
3741 EAPI Elm_Genlist_Item *
3742 elm_genlist_item_insert_after(Evas_Object *obj,
3743 const Elm_Genlist_Item_Class *itc,
3745 Elm_Genlist_Item *parent,
3746 Elm_Genlist_Item *after,
3747 Elm_Genlist_Item_Flags flags,
3749 const void *func_data)
3751 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3752 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3753 Widget_Data *wd = elm_widget_data_get(obj);
3754 if (!wd) return NULL;
3755 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3757 if (!it) return NULL;
3758 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3759 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3763 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3764 (after->flags & ELM_GENLIST_ITEM_GROUP))
3765 wd->group_items = eina_list_append_relative(wd->group_items, it,
3770 it->parent->items = eina_list_append_relative(it->parent->items, it,
3773 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3774 EINA_INLIST_GET(after));
3776 it->rel->relcount++;
3777 it->before = EINA_FALSE;
3778 _item_queue(wd, it);
3782 EAPI Elm_Genlist_Item *
3783 elm_genlist_item_insert_before(Evas_Object *obj,
3784 const Elm_Genlist_Item_Class *itc,
3786 Elm_Genlist_Item *parent,
3787 Elm_Genlist_Item *before,
3788 Elm_Genlist_Item_Flags flags,
3790 const void *func_data)
3792 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3793 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3794 Widget_Data *wd = elm_widget_data_get(obj);
3795 if (!wd) return NULL;
3796 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3798 if (!it) return NULL;
3799 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
3800 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3804 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3805 (before->flags & ELM_GENLIST_ITEM_GROUP))
3806 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
3811 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3814 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3815 EINA_INLIST_GET(before));
3817 it->rel->relcount++;
3818 it->before = EINA_TRUE;
3819 _item_queue(wd, it);
3824 elm_genlist_clear(Evas_Object *obj)
3826 ELM_CHECK_WIDTYPE(obj, widtype);
3827 Widget_Data *wd = elm_widget_data_get(obj);
3829 if (wd->walking > 0)
3831 Elm_Genlist_Item *it;
3833 wd->clear_me = EINA_TRUE;
3834 EINA_INLIST_FOREACH(wd->items, it)
3836 it->delete_me = EINA_TRUE;
3840 evas_event_freeze(evas_object_evas_get(wd->obj));
3843 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3844 it->nocache = EINA_TRUE;
3845 it->highlighted = EINA_FALSE;
3847 if (wd->anchor_item == it)
3849 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3850 if (!wd->anchor_item)
3852 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3855 wd->items = eina_inlist_remove(wd->items, wd->items);
3856 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3857 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3858 elm_widget_item_pre_notify_del(it);
3859 if (it->realized) _item_unrealize(it, EINA_FALSE);
3860 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3861 it->itc->func.del((void *)it->base.data, it->base.widget);
3862 if (it->long_timer) ecore_timer_del(it->long_timer);
3863 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3864 elm_widget_item_del(it);
3866 wd->clear_me = EINA_FALSE;
3867 wd->anchor_item = NULL;
3870 Item_Block *itb = (Item_Block *)(wd->blocks);
3872 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3873 if (itb->items) eina_list_free(itb->items);
3878 ecore_job_del(wd->calc_job);
3879 wd->calc_job = NULL;
3881 if (wd->queue_idle_enterer)
3883 ecore_idle_enterer_del(wd->queue_idle_enterer);
3884 wd->queue_idle_enterer = NULL;
3886 if (wd->must_recalc_idler)
3888 ecore_idler_del(wd->must_recalc_idler);
3889 wd->must_recalc_idler = NULL;
3893 eina_list_free(wd->queue);
3898 eina_list_free(wd->selected);
3899 wd->selected = NULL;
3901 if (wd->reorder_move_animator)
3903 ecore_animator_del(wd->reorder_move_animator);
3904 wd->reorder_move_animator = NULL;
3906 wd->show_item = NULL;
3914 evas_object_del(wd->alpha_bg);
3915 wd->alpha_bg = NULL;
3919 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3920 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3923 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
3924 evas_event_thaw(evas_object_evas_get(wd->obj));
3925 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3929 elm_genlist_multi_select_set(Evas_Object *obj,
3932 ELM_CHECK_WIDTYPE(obj, widtype);
3933 Widget_Data *wd = elm_widget_data_get(obj);
3939 elm_genlist_multi_select_get(const Evas_Object *obj)
3941 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3942 Widget_Data *wd = elm_widget_data_get(obj);
3943 if (!wd) return EINA_FALSE;
3947 EAPI Elm_Genlist_Item *
3948 elm_genlist_selected_item_get(const Evas_Object *obj)
3950 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3951 Widget_Data *wd = elm_widget_data_get(obj);
3952 if (!wd) return NULL;
3953 if (wd->selected) return wd->selected->data;
3957 EAPI const Eina_List *
3958 elm_genlist_selected_items_get(const Evas_Object *obj)
3960 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3961 Widget_Data *wd = elm_widget_data_get(obj);
3962 if (!wd) return NULL;
3963 return wd->selected;
3967 elm_genlist_realized_items_get(const Evas_Object *obj)
3969 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3970 Widget_Data *wd = elm_widget_data_get(obj);
3971 Eina_List *list = NULL;
3973 Eina_Bool done = EINA_FALSE;
3974 if (!wd) return NULL;
3975 EINA_INLIST_FOREACH(wd->blocks, itb)
3980 Elm_Genlist_Item *it;
3983 EINA_LIST_FOREACH(itb->items, l, it)
3985 if (it->realized) list = eina_list_append(list, it);
3996 EAPI Elm_Genlist_Item *
3997 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4002 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4003 Widget_Data *wd = elm_widget_data_get(obj);
4004 Evas_Coord ox, oy, ow, oh;
4007 if (!wd) return NULL;
4008 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4010 EINA_INLIST_FOREACH(wd->blocks, itb)
4013 Elm_Genlist_Item *it;
4015 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4016 oy + itb->y - itb->wd->pan_y,
4017 itb->w, itb->h, x, y, 1, 1))
4019 EINA_LIST_FOREACH(itb->items, l, it)
4021 Evas_Coord itx, ity;
4023 itx = ox + itb->x + it->x - itb->wd->pan_x;
4024 ity = oy + itb->y + it->y - itb->wd->pan_y;
4025 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4029 if (y <= (ity + (it->h / 4))) *posret = -1;
4030 else if (y >= (ity + it->h - (it->h / 4)))
4036 lasty = ity + it->h;
4041 if (y > lasty) *posret = 1;
4047 EAPI Elm_Genlist_Item *
4048 elm_genlist_first_item_get(const Evas_Object *obj)
4050 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4051 Widget_Data *wd = elm_widget_data_get(obj);
4052 if (!wd) return NULL;
4053 if (!wd->items) return NULL;
4054 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4055 while ((it) && (it->delete_me))
4056 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4060 EAPI Elm_Genlist_Item *
4061 elm_genlist_last_item_get(const Evas_Object *obj)
4063 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4064 Widget_Data *wd = elm_widget_data_get(obj);
4065 if (!wd) return NULL;
4066 if (!wd->items) return NULL;
4067 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4068 while ((it) && (it->delete_me))
4069 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4073 EAPI Elm_Genlist_Item *
4074 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4076 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4079 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4080 if ((it) && (!it->delete_me)) break;
4082 return (Elm_Genlist_Item *)it;
4085 EAPI Elm_Genlist_Item *
4086 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4088 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4091 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4092 if ((it) && (!it->delete_me)) break;
4094 return (Elm_Genlist_Item *)it;
4098 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4100 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4101 return it->base.widget;
4104 EAPI Elm_Genlist_Item *
4105 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4107 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4112 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4114 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4115 Elm_Genlist_Item *it2;
4118 if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4119 _item_subitems_clear(it);
4122 if ((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4123 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4125 it->wd->expand_item = it;
4126 _item_flip_effect_show(it);
4127 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4128 it->wd->expand_item_end = y + h;
4132 it2 = elm_genlist_item_next_get(it2);
4134 } while (it2->expanded_depth > it->expanded_depth);
4136 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4138 it->wd->expand_item_gap = 0;
4140 evas_object_raise(it->wd->alpha_bg);
4141 evas_object_show(it->wd->alpha_bg);
4143 it->wd->start_time = current_time_get();
4144 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4147 _item_subitems_clear(it);
4152 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4155 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4156 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4158 if ((it->delete_me) || (it->disabled)) return;
4159 selected = !!selected;
4160 if (it->selected == selected) return;
4166 while (wd->selected)
4167 _item_unselect(wd->selected->data);
4169 _item_highlight(it);
4177 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4179 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4180 return it->selected;
4184 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4187 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4188 if (it->flags != ELM_GENLIST_ITEM_SUBITEMS) return;
4189 if (it->expanded == expanded) return;
4190 it->expanded = expanded;
4191 it->wd->expand_item = it;
4193 if (it->wd->effect_mode && !it->wd->alpha_bg)
4194 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4198 it->wd->auto_scrolled = EINA_FALSE;
4199 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4201 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4202 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4206 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4208 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4209 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4214 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4216 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4217 return it->expanded;
4221 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4223 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4224 return it->expanded_depth;
4228 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4231 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4234 if (it->disabled == disabled) return;
4235 if (it->delete_me) return;
4236 it->disabled = disabled;
4238 elm_genlist_item_selected_set(it, EINA_FALSE);
4243 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4245 edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
4249 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4251 edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
4253 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4254 elm_widget_disabled_set(obj, disabled);
4259 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4261 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4262 if (it->delete_me) return EINA_FALSE;
4263 return it->disabled;
4267 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4268 Eina_Bool display_only)
4270 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4271 if (it->display_only == display_only) return;
4272 if (it->delete_me) return;
4273 it->display_only = display_only;
4274 it->mincalcd = EINA_FALSE;
4275 it->updateme = EINA_TRUE;
4276 if (it->block) it->block->updateme = EINA_TRUE;
4277 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4278 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4282 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4284 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4285 if (it->delete_me) return EINA_FALSE;
4286 return it->display_only;
4290 elm_genlist_item_show(Elm_Genlist_Item *it)
4292 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4293 Evas_Coord gith = 0;
4294 if (it->delete_me) return;
4295 if ((it->queued) || (!it->mincalcd))
4297 it->wd->show_item = it;
4298 it->wd->bring_in = EINA_TRUE;
4299 it->showme = EINA_TRUE;
4302 if (it->wd->show_item)
4304 it->wd->show_item->showme = EINA_FALSE;
4305 it->wd->show_item = NULL;
4307 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4308 gith = it->group_item->h;
4309 elm_smart_scroller_child_region_show(it->wd->scr,
4310 it->x + it->block->x,
4311 it->y + it->block->y - gith,
4312 it->block->w, it->h);
4316 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4318 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4319 Evas_Coord gith = 0;
4320 if (it->delete_me) return;
4321 if ((it->queued) || (!it->mincalcd))
4323 it->wd->show_item = it;
4324 it->wd->bring_in = EINA_TRUE;
4325 it->showme = EINA_TRUE;
4328 if (it->wd->show_item)
4330 it->wd->show_item->showme = EINA_FALSE;
4331 it->wd->show_item = NULL;
4333 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4334 gith = it->group_item->h;
4335 elm_smart_scroller_region_bring_in(it->wd->scr,
4336 it->x + it->block->x,
4337 it->y + it->block->y - gith,
4338 it->block->w, it->h);
4342 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4344 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4346 Evas_Coord gith = 0;
4348 if (it->delete_me) return;
4349 if ((it->queued) || (!it->mincalcd))
4351 it->wd->show_item = it;
4352 it->wd->bring_in = EINA_TRUE;
4353 it->showme = EINA_TRUE;
4356 if (it->wd->show_item)
4358 it->wd->show_item->showme = EINA_FALSE;
4359 it->wd->show_item = NULL;
4361 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4362 if (it->group_item) gith = it->group_item->h;
4363 elm_smart_scroller_child_region_show(it->wd->scr,
4364 it->x + it->block->x,
4365 it->y + it->block->y - gith,
4370 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4372 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4374 Evas_Coord gith = 0;
4376 if (it->delete_me) return;
4377 if ((it->queued) || (!it->mincalcd))
4379 it->wd->show_item = it;
4380 it->wd->bring_in = EINA_TRUE;
4381 it->showme = EINA_TRUE;
4384 if (it->wd->show_item)
4386 it->wd->show_item->showme = EINA_FALSE;
4387 it->wd->show_item = NULL;
4389 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4390 if (it->group_item) gith = it->group_item->h;
4391 elm_smart_scroller_region_bring_in(it->wd->scr,
4392 it->x + it->block->x,
4393 it->y + it->block->y - gith,
4398 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4400 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4403 if (it->delete_me) return;
4404 if ((it->queued) || (!it->mincalcd))
4406 it->wd->show_item = it;
4407 it->wd->bring_in = EINA_TRUE;
4408 it->showme = EINA_TRUE;
4411 if (it->wd->show_item)
4413 it->wd->show_item->showme = EINA_FALSE;
4414 it->wd->show_item = NULL;
4416 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4417 elm_smart_scroller_child_region_show(it->wd->scr,
4418 it->x + it->block->x,
4419 it->y + it->block->y - oh / 2 +
4420 it->h / 2, it->block->w, oh);
4424 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4426 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4429 if (it->delete_me) return;
4430 if ((it->queued) || (!it->mincalcd))
4432 it->wd->show_item = it;
4433 it->wd->bring_in = EINA_TRUE;
4434 it->showme = EINA_TRUE;
4437 if (it->wd->show_item)
4439 it->wd->show_item->showme = EINA_FALSE;
4440 it->wd->show_item = NULL;
4442 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4443 elm_smart_scroller_region_bring_in(it->wd->scr,
4444 it->x + it->block->x,
4445 it->y + it->block->y - oh / 2 + it->h / 2,
4450 elm_genlist_item_del(Elm_Genlist_Item *it)
4452 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4453 if ((it->relcount > 0) || (it->walking > 0))
4455 elm_widget_item_pre_notify_del(it);
4456 elm_genlist_item_subitems_clear(it);
4457 it->delete_me = EINA_TRUE;
4458 if (it->wd->show_item == it) it->wd->show_item = NULL;
4460 it->wd->selected = eina_list_remove(it->wd->selected,
4464 if (it->realized) _item_unrealize(it, EINA_FALSE);
4465 it->block->changed = EINA_TRUE;
4466 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4467 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4469 if (it->itc->func.del)
4470 it->itc->func.del((void *)it->base.data, it->base.widget);
4477 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4480 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4481 elm_widget_item_data_set(it, data);
4482 elm_genlist_item_update(it);
4486 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4488 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4489 return elm_widget_item_data_get(it);
4493 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4496 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4497 EINA_LIST_FREE(it->icon_objs, icon)
4499 elm_widget_sub_object_del(it->base.widget, icon);
4500 evas_object_smart_member_del(icon);
4501 evas_object_hide(icon);
4505 EAPI const Evas_Object *
4506 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4508 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4509 return it->base.view;
4513 elm_genlist_item_update(Elm_Genlist_Item *it)
4515 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4516 if (!it->block) return;
4517 if (it->delete_me) return;
4518 it->mincalcd = EINA_FALSE;
4519 it->updateme = EINA_TRUE;
4520 it->block->updateme = EINA_TRUE;
4521 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4522 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4523 it->defer_unrealize = EINA_FALSE;
4527 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4528 const Elm_Genlist_Item_Class *itc)
4530 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4531 if (!it->block) return;
4532 EINA_SAFETY_ON_NULL_RETURN(itc);
4533 if (it->delete_me) return;
4535 it->nocache = EINA_TRUE;
4536 elm_genlist_item_update(it);
4539 EAPI const Elm_Genlist_Item_Class *
4540 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4542 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4543 if (it->delete_me) return NULL;
4546 static Evas_Object *
4547 _elm_genlist_item_label_create(void *data,
4549 void *item __UNUSED__)
4551 Evas_Object *label = elm_label_add(obj);
4554 elm_object_style_set(label, "tooltip");
4555 elm_object_text_set(label, data);
4560 _elm_genlist_item_label_del_cb(void *data,
4561 Evas_Object *obj __UNUSED__,
4562 void *event_info __UNUSED__)
4564 eina_stringshare_del(data);
4568 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4571 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4572 text = eina_stringshare_add(text);
4573 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4575 _elm_genlist_item_label_del_cb);
4579 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4580 Elm_Tooltip_Item_Content_Cb func,
4582 Evas_Smart_Cb del_cb)
4584 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4586 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4589 if (item->tooltip.del_cb)
4590 item->tooltip.del_cb((void *)item->tooltip.data,
4591 item->base.widget, item);
4593 item->tooltip.content_cb = func;
4594 item->tooltip.data = data;
4595 item->tooltip.del_cb = del_cb;
4597 if (item->base.view)
4599 elm_widget_item_tooltip_content_cb_set(item,
4600 item->tooltip.content_cb,
4601 item->tooltip.data, NULL);
4602 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4608 if (del_cb) del_cb((void *)data, NULL, NULL);
4612 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4614 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4615 if ((item->base.view) && (item->tooltip.content_cb))
4616 elm_widget_item_tooltip_unset(item);
4618 if (item->tooltip.del_cb)
4619 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4620 item->tooltip.del_cb = NULL;
4621 item->tooltip.content_cb = NULL;
4622 item->tooltip.data = NULL;
4623 if (item->tooltip.style)
4624 elm_genlist_item_tooltip_style_set(item, NULL);
4628 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4631 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4632 eina_stringshare_replace(&item->tooltip.style, style);
4633 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4637 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4639 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4640 return item->tooltip.style;
4644 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4647 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4648 eina_stringshare_replace(&item->mouse_cursor, cursor);
4649 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4653 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4655 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4656 return elm_widget_item_cursor_get(item);
4660 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4662 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4663 if (!item->mouse_cursor)
4666 if (item->base.view)
4667 elm_widget_item_cursor_unset(item);
4669 eina_stringshare_del(item->mouse_cursor);
4670 item->mouse_cursor = NULL;
4674 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4677 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4678 elm_widget_item_cursor_style_set(item, style);
4682 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4684 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4685 return elm_widget_item_cursor_style_get(item);
4689 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4690 Eina_Bool engine_only)
4692 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4693 elm_widget_item_cursor_engine_only_set(item, engine_only);
4697 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4699 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4700 return elm_widget_item_cursor_engine_only_get(item);
4704 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4707 ELM_CHECK_WIDTYPE(obj, widtype);
4708 Widget_Data *wd = elm_widget_data_get(obj);
4710 if (wd->mode == mode) return;
4716 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4718 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4719 Widget_Data *wd = elm_widget_data_get(obj);
4720 if (!wd) return ELM_LIST_LAST;
4725 elm_genlist_always_select_mode_set(Evas_Object *obj,
4726 Eina_Bool always_select)
4728 ELM_CHECK_WIDTYPE(obj, widtype);
4729 Widget_Data *wd = elm_widget_data_get(obj);
4731 wd->always_select = always_select;
4735 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4737 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4738 Widget_Data *wd = elm_widget_data_get(obj);
4739 if (!wd) return EINA_FALSE;
4740 return wd->always_select;
4744 elm_genlist_no_select_mode_set(Evas_Object *obj,
4745 Eina_Bool no_select)
4747 ELM_CHECK_WIDTYPE(obj, widtype);
4748 Widget_Data *wd = elm_widget_data_get(obj);
4750 wd->no_select = no_select;
4754 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4756 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4757 Widget_Data *wd = elm_widget_data_get(obj);
4758 if (!wd) return EINA_FALSE;
4759 return wd->no_select;
4763 elm_genlist_compress_mode_set(Evas_Object *obj,
4766 ELM_CHECK_WIDTYPE(obj, widtype);
4767 Widget_Data *wd = elm_widget_data_get(obj);
4769 wd->compress = compress;
4773 elm_genlist_compress_mode_get(const Evas_Object *obj)
4775 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4776 Widget_Data *wd = elm_widget_data_get(obj);
4777 if (!wd) return EINA_FALSE;
4778 return wd->compress;
4782 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4783 Eina_Bool height_for_width)
4785 ELM_CHECK_WIDTYPE(obj, widtype);
4786 Widget_Data *wd = elm_widget_data_get(obj);
4788 wd->height_for_width = !!height_for_width;
4789 if (wd->height_for_width)
4791 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4792 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4797 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4799 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4800 Widget_Data *wd = elm_widget_data_get(obj);
4801 if (!wd) return EINA_FALSE;
4802 return wd->height_for_width;
4806 elm_genlist_bounce_set(Evas_Object *obj,
4810 ELM_CHECK_WIDTYPE(obj, widtype);
4811 Widget_Data *wd = elm_widget_data_get(obj);
4813 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4817 elm_genlist_bounce_get(const Evas_Object *obj,
4818 Eina_Bool *h_bounce,
4819 Eina_Bool *v_bounce)
4821 ELM_CHECK_WIDTYPE(obj, widtype);
4822 Widget_Data *wd = elm_widget_data_get(obj);
4824 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4828 elm_genlist_homogeneous_set(Evas_Object *obj,
4829 Eina_Bool homogeneous)
4831 ELM_CHECK_WIDTYPE(obj, widtype);
4832 Widget_Data *wd = elm_widget_data_get(obj);
4834 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4835 wd->homogeneous = homogeneous;
4839 elm_genlist_homogeneous_get(const Evas_Object *obj)
4841 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4842 Widget_Data *wd = elm_widget_data_get(obj);
4843 if (!wd) return EINA_FALSE;
4844 return wd->homogeneous;
4848 elm_genlist_block_count_set(Evas_Object *obj,
4851 ELM_CHECK_WIDTYPE(obj, widtype);
4852 Widget_Data *wd = elm_widget_data_get(obj);
4854 wd->max_items_per_block = n;
4855 wd->item_cache_max = wd->max_items_per_block * 2;
4856 _item_cache_clean(wd);
4860 elm_genlist_block_count_get(const Evas_Object *obj)
4862 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4863 Widget_Data *wd = elm_widget_data_get(obj);
4865 return wd->max_items_per_block;
4869 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4872 ELM_CHECK_WIDTYPE(obj, widtype);
4873 Widget_Data *wd = elm_widget_data_get(obj);
4875 wd->longpress_timeout = timeout;
4879 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4881 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4882 Widget_Data *wd = elm_widget_data_get(obj);
4884 return wd->longpress_timeout;
4888 elm_genlist_scroller_policy_set(Evas_Object *obj,
4889 Elm_Scroller_Policy policy_h,
4890 Elm_Scroller_Policy policy_v)
4892 ELM_CHECK_WIDTYPE(obj, widtype);
4893 Widget_Data *wd = elm_widget_data_get(obj);
4895 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4896 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4899 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4903 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4904 Elm_Scroller_Policy *policy_h,
4905 Elm_Scroller_Policy *policy_v)
4907 ELM_CHECK_WIDTYPE(obj, widtype);
4908 Widget_Data *wd = elm_widget_data_get(obj);
4909 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4910 if ((!wd) || (!wd->scr)) return;
4911 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4912 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4913 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
4917 elm_genlist_realized_items_update(Evas_Object *obj)
4919 ELM_CHECK_WIDTYPE(obj, widtype);
4921 Eina_List *list, *l;
4922 Elm_Genlist_Item *it;
4924 list = elm_genlist_realized_items_get(obj);
4925 EINA_LIST_FOREACH(list, l, it)
4926 elm_genlist_item_update(it);
4930 * Set genlist item mode
4932 * @param item The genlist item
4933 * @param mode Mode name
4934 * @param mode_set Boolean to define set or unset mode.
4939 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
4940 const char *mode_type,
4943 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4944 Widget_Data *wd = it->wd;
4946 Elm_Genlist_Item *it2;
4949 if (!mode_type) return;
4950 if ((it->delete_me) || (it->disabled)) return;
4951 if (wd->edit_mode) return;
4953 if ((wd->mode_item == it) &&
4954 (!strcmp(mode_type, wd->mode_type)) &&
4957 if (!it->itc->mode_item_style) return;
4961 EINA_LIST_FOREACH(wd->selected, l, it2)
4963 elm_genlist_item_selected_set(it2, EINA_FALSE);
4967 it2 = elm_genlist_selected_item_get(wd->obj);
4968 if ((it2) && (it2->realized))
4969 elm_genlist_item_selected_set(it2, EINA_FALSE);
4972 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
4974 ((it == wd->mode_item) && (!mode_set)))
4975 _item_mode_unset(wd);
4977 eina_stringshare_replace(&wd->mode_type, mode_type);
4978 if (mode_set) _item_mode_set(it);
4982 * Get active genlist mode type
4984 * @param obj The genlist object
4989 elm_genlist_mode_get(const Evas_Object *obj)
4991 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4992 Widget_Data *wd = elm_widget_data_get(obj);
4993 if (!wd) return NULL;
4994 return wd->mode_type;
4998 * Get active genlist mode item
5000 * @param obj The genlist object
5004 EAPI const Elm_Genlist_Item *
5005 elm_genlist_mode_item_get(const Evas_Object *obj)
5007 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5008 Widget_Data *wd = elm_widget_data_get(obj);
5009 if (!wd) return NULL;
5010 return wd->mode_item;
5014 elm_genlist_reorder_mode_set(Evas_Object *obj,
5015 Eina_Bool reorder_mode)
5017 ELM_CHECK_WIDTYPE(obj, widtype);
5018 Widget_Data *wd = elm_widget_data_get(obj);
5020 wd->reorder_mode = reorder_mode;
5024 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5026 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5027 Widget_Data *wd = elm_widget_data_get(obj);
5028 if (!wd) return EINA_FALSE;
5029 return wd->reorder_mode;
5033 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
5039 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
5045 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5047 ELM_CHECK_WIDTYPE(obj, widtype);
5048 Widget_Data *wd = elm_widget_data_get(obj);
5050 wd->effect_mode = emode;
5051 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5052 // evas_object_resize(wd->point_rect, 10, 25);
5053 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5054 // evas_object_show(wd->point_rect);
5055 // evas_object_hide(wd->point_rect);
5059 _create_tray_alpha_bg(const Evas_Object *obj)
5061 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5062 Widget_Data *wd = elm_widget_data_get(obj);
5063 if (!wd) return NULL;
5065 Evas_Object *bg = NULL;
5066 Evas_Coord ox, oy, ow, oh;
5068 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5069 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5070 evas_object_color_set(bg,0,0,0,0);
5071 evas_object_resize(bg , ow, oh);
5072 evas_object_move(bg , ox, oy);
5073 evas_object_show(bg);
5074 evas_object_hide(bg);
5081 struct timeval timev;
5083 gettimeofday(&timev, NULL);
5084 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5087 // added for item moving animation.
5089 _item_moving_effect_timer_cb(void *data)
5091 Widget_Data *wd = data;
5092 if (!wd) return EINA_FALSE;
5094 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5095 Elm_Genlist_Item *it = NULL, *it2;
5097 double time = 0.3, t;
5099 Eina_Bool check, end = EINA_FALSE;
5102 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5104 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5105 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5106 if (t > time) end = EINA_TRUE;
5108 it2 = elm_genlist_item_next_get(wd->expand_item);
5111 if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5112 it2 = elm_genlist_item_next_get(it2);
5117 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5118 dy = it2->scrl_y - it2->old_scrl_y;
5119 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5120 dy = wd->expand_item_gap;
5124 y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5133 EINA_INLIST_FOREACH(wd->blocks, itb)
5136 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5137 itb->y - wd->pan_y + oy,
5139 cvx, cvy, cvw, cvh))
5141 EINA_LIST_FOREACH(itb->items, l, it)
5143 if (it == it2) check = EINA_TRUE;
5144 if (!check) continue;
5146 if (!it->old_scrl_y)
5147 it->old_scrl_y = it->scrl_y;
5148 if (it->old_scrl_y + y < oy + oh)
5150 if (!it->realized) _item_realize(it, in, 0);
5152 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5153 it->old_scrl_y = it->scrl_y - y;
5156 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5157 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5159 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5162 evas_object_resize(it->base.view, it->w, it->h);
5163 evas_object_move(it->base.view, it->scrl_x, it->old_scrl_y + y);
5164 evas_object_show(it->base.view);
5165 evas_object_raise(it->base.view);
5168 if (it->group_item) evas_object_raise(it->group_item->base.view);
5174 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5176 it = elm_genlist_item_prev_get(it2);
5179 if (it->expanded_depth <= it2->expanded_depth) break;
5180 if ((it->scrl_y < it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5182 if (!it->effect_done)
5184 edje_object_signal_emit(it->base.view, "flip_item", "");
5185 evas_object_show(it->base.view);
5186 it->effect_done = EINA_TRUE;
5189 it = elm_genlist_item_prev_get(it);
5192 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5194 it = elm_genlist_item_prev_get(it2);
5197 if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5199 if (!it->effect_done)
5201 edje_object_signal_emit(it->base.view, "elm,state,hide", "");
5202 it->effect_done = EINA_TRUE;
5207 it = elm_genlist_item_prev_get(it);
5214 int expand_order = 0;
5215 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5219 it = elm_genlist_item_next_get(it);
5221 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5225 if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
5226 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5228 if (!it->effect_done)
5230 if (t >= (((expand_order - 1) * time) / expand_num))
5232 edje_object_signal_emit(it->base.view, "flip_item", "");
5233 evas_object_show(it->base.view);
5234 it->effect_done = EINA_TRUE;
5238 it = elm_genlist_item_next_get(it);
5244 if (wd->item_moving_effect_timer)
5246 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5247 _item_subitems_clear(wd->expand_item);
5248 EINA_INLIST_FOREACH(wd->blocks, itb)
5250 EINA_LIST_FOREACH(itb->items, l, it)
5252 it->effect_done = EINA_TRUE;
5253 it->old_scrl_y = it->scrl_y;
5257 wd->item_moving_effect_timer = NULL;
5259 _item_auto_scroll(wd);
5260 evas_object_lower(wd->alpha_bg);
5261 evas_object_hide(wd->alpha_bg);
5262 if (wd->calc_job) ecore_job_del(wd->calc_job);
5263 wd->calc_job = ecore_job_add(_calc_job, wd);
5264 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5265 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5267 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5268 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5269 return ECORE_CALLBACK_CANCEL;
5271 return ECORE_CALLBACK_RENEW;
5275 _emit_contract(Elm_Genlist_Item *it)
5277 Elm_Genlist_Item *it2;
5280 // printf("%p is emited contract\n", it);
5281 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5282 it->effect_done = EINA_FALSE;
5284 EINA_LIST_FOREACH(it->items, l, it2)
5286 _emit_contract(it2);
5289 // added for item moving animation.
5291 _item_flip_effect_show(Elm_Genlist_Item *it)
5293 Elm_Genlist_Item *it2;
5295 Widget_Data *wd = it->wd;
5296 Eina_Bool check = EINA_FALSE;
5298 it2 = elm_genlist_item_next_get(it);
5301 if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5302 it2 = elm_genlist_item_next_get(it2);
5304 EINA_LIST_FOREACH(it->items, l, it2)
5306 if (it2->parent && it == it2->parent)
5308 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5309 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5310 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5311 _emit_contract(it2);
5315 return ECORE_CALLBACK_CANCEL;
5320 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5322 printf("!!! NOW FIXING \n");
5327 * Set pinch zoom mode
5329 * @param obj The genlist object
5331 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5336 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5338 printf("!!! NOW FIXING \n");
5342 * Get pinch zoom mode
5344 * @param obj The genlist object
5345 * @return The pinch mode
5346 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5351 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
5353 printf("!!! NOW FIXING \n");
5358 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5360 printf("!!! NOW FIXING \n");
5364 ////////////////////////////////////////////////////////////////////////
5366 ////////////////////////////////////////////////////////////////////////
5369 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5371 if (!it->wd->edit_mode) return;
5372 evas_object_resize(it->edit_obj,it->w, it->h);
5373 evas_object_move(it->edit_obj, itx, ity);
5377 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5379 if ((it->effect_item_realized) || (it->delete_me)) return;
5383 _mode_finished_signal_cb(it, (Evas_Object *)elm_genlist_item_object_get(it), NULL, NULL);
5385 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
5386 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
5387 _elm_config->scale);
5388 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5389 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
5391 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5392 else strncpy(buf, "item", sizeof(buf));
5393 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5395 strncat(buf, "/", sizeof(buf) - strlen(buf));
5397 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5399 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
5400 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
5404 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget));
5407 if (it->wd->reorder_mode)
5409 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
5410 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
5412 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
5413 else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
5415 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
5416 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
5419 if ((it->wd->edit_mode))
5421 if (it->itc->func.icon_get)
5426 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5427 EINA_LIST_FOREACH(it->icons, l, key)
5429 Evas_Object *ic = it->itc->func.icon_get
5430 ((void *)it->base.data, it->base.widget, l->data);
5434 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5435 edje_object_part_swallow(it->edit_obj, key, ic);
5436 evas_object_show(ic);
5437 elm_widget_sub_object_add(it->base.widget, ic);
5439 elm_widget_disabled_set(ic, EINA_TRUE);
5444 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
5445 _effect_item_controls(it,it->scrl_x, it->scrl_y);
5446 evas_object_show(it->edit_obj);
5448 it->effect_item_realized = EINA_TRUE;
5449 it->want_unrealize = EINA_FALSE;
5453 _effect_item_unrealize(Elm_Genlist_Item *it)
5457 if (!it->effect_item_realized) return;
5458 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5460 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
5461 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
5462 edje_object_message_signal_process(it->edit_obj);
5463 edje_object_part_unswallow(it->edit_obj, it->base.view);
5464 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
5465 elm_widget_sub_object_add(it->base.widget, it->base.view);
5466 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5467 // _item_cache_add(it);
5468 evas_object_del(it->edit_obj);
5469 it->edit_obj = NULL;
5470 EINA_LIST_FREE(it->edit_icon_objs, icon)
5471 evas_object_del(icon);
5473 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5474 it->effect_item_realized = EINA_FALSE;
5478 * Get Genlist edit mode
5480 * @param obj The genlist object
5481 * @return The edit mode status
5482 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5487 elm_genlist_edit_mode_get(const Evas_Object *obj)
5489 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5490 Widget_Data *wd = elm_widget_data_get(obj);
5491 if (!wd) return EINA_FALSE;
5493 if (wd->edit_mode) return EINA_TRUE;
5494 else return EINA_FALSE;
5498 * Set Genlist edit mode
5500 * This sets Genlist edit mode.
5502 * @param obj The Genlist object
5503 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5504 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5509 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5511 ELM_CHECK_WIDTYPE(obj, widtype);
5515 Elm_Genlist_Item *it;
5517 Widget_Data *wd = elm_widget_data_get(obj);
5519 if (wd->edit_mode == edit_mode) return;
5521 wd->edit_mode = edit_mode;
5524 EINA_INLIST_FOREACH(wd->blocks, itb)
5528 EINA_LIST_FOREACH(itb->items, l, it)
5530 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5532 _effect_item_unrealize(it);
5537 _item_cache_zero(wd);
5542 EINA_INLIST_FOREACH(wd->blocks, itb)
5546 EINA_LIST_FOREACH(itb->items, l, it)
5548 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5550 if(it->selected) _item_unselect(it);
5551 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
5558 if (wd->calc_job) ecore_job_del(wd->calc_job);
5559 wd->calc_job = ecore_job_add(_calc_job, wd);
5563 * Set a given item's rename mode
5565 * This renames the item's label from genlist
5567 * @param it The item
5568 * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
5573 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
5579 _item_unrealize(it, EINA_FALSE);
5580 it->renamed = EINA_TRUE;
5581 it->wd->rename_it = it;
5582 it->nocache = EINA_TRUE;
5583 if (it->selected) _item_unselect(it);
5585 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5586 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5592 it->renamed = EINA_FALSE;
5593 it->nocache = EINA_TRUE;
5594 it->wd->rename_it = NULL;
5595 _item_cache_zero(it->wd);
5596 elm_genlist_item_update(it);
5602 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
5604 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5605 return item->renamed;
5609 _item_auto_scroll(void *data)
5611 Widget_Data *wd = data;
5614 if ((wd->expand_item) && (!wd->auto_scrolled))
5616 Elm_Genlist_Item *it;
5618 Evas_Coord ox, oy, ow, oh;
5619 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
5621 wd->auto_scrolled = EINA_TRUE;
5622 if (wd->expand_item->scrl_y > (oh + oy) / 2)
5624 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
5626 elm_genlist_item_bring_in(it);