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;
83 Eina_Bool pan_changed : 1;
85 Ecore_Animator *item_moving_effect_timer;
86 Evas_Object *alpha_bg;
87 Evas_Coord expand_item_end;
88 Evas_Coord expand_item_gap;
90 Ecore_Job *changed_job;
91 Elm_Genlist_Item *rename_it;
102 Evas_Coord x, y, w, h, minw, minh;
103 Eina_Bool want_unrealize : 1;
104 Eina_Bool realized : 1;
105 Eina_Bool changed : 1;
106 Eina_Bool updateme : 1;
107 Eina_Bool changeme : 1;
108 Eina_Bool showme : 1;
109 Eina_Bool must_recalc : 1;
112 struct _Elm_Genlist_Item
114 Elm_Widget_Item base;
119 Evas_Coord x, y, w, h, minw, minh;
120 const Elm_Genlist_Item_Class *itc;
121 Elm_Genlist_Item *parent;
122 Elm_Genlist_Item *group_item;
123 Elm_Genlist_Item_Flags flags;
131 Eina_List *labels, *icons, *states, *icon_objs;
132 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
133 Ecore_Timer *long_timer;
134 Ecore_Timer *swipe_timer;
136 Evas_Coord scrl_x, scrl_y;
138 Elm_Genlist_Item *rel;
139 Evas_Object *mode_view;
144 Elm_Tooltip_Item_Content_Cb content_cb;
145 Evas_Smart_Cb del_cb;
149 const char *mouse_cursor;
156 Eina_Bool before : 1;
158 Eina_Bool want_unrealize : 1;
159 Eina_Bool want_realize : 1;
160 Eina_Bool realized : 1;
161 Eina_Bool selected : 1;
162 Eina_Bool highlighted : 1;
163 Eina_Bool expanded : 1;
164 Eina_Bool disabled : 1;
165 Eina_Bool display_only : 1;
166 Eina_Bool mincalcd : 1;
167 Eina_Bool queued : 1;
168 Eina_Bool showme : 1;
169 Eina_Bool delete_me : 1;
171 Eina_Bool dragging : 1;
172 Eina_Bool updateme : 1;
173 Eina_Bool nocache : 1;
174 Eina_Bool move_effect_enabled : 1;
175 Eina_Bool defer_unrealize : 1;
178 Eina_Bool effect_done : 1;
179 Eina_Bool reordering : 1;
180 Eina_Bool renamed : 1;
181 Eina_Bool effect_item_realized : 1;
182 Eina_List *edit_icon_objs;
183 Evas_Object *edit_obj;
185 Ecore_Animator *item_moving_effect_timer;
186 Evas_Coord old_scrl_y;
193 Evas_Object *base_view, *spacer;
195 const char *item_style; // it->itc->item_style
196 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
197 Eina_Bool compress : 1; // it->wd->compress
198 Eina_Bool odd : 1; // in & 0x1
200 Eina_Bool selected : 1; // it->selected
201 Eina_Bool disabled : 1; // it->disabled
202 Eina_Bool expanded : 1; // it->expanded
205 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
206 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
210 Evas_Object_Smart_Clipped_Data __clipped_data;
212 Ecore_Job *resize_job;
215 static const char *widtype = NULL;
216 static void _item_cache_zero(Widget_Data *wd);
217 static void _del_hook(Evas_Object *obj);
218 static void _mirrored_set(Evas_Object *obj,
220 static void _theme_hook(Evas_Object *obj);
221 static void _show_region_hook(void *data,
223 static void _sizing_eval(Evas_Object *obj);
224 static void _item_realize(Elm_Genlist_Item *it,
227 static void _item_unrealize(Elm_Genlist_Item *it,
229 static void _item_block_unrealize(Item_Block *itb);
230 static void _calc_job(void *data);
231 static void _on_focus_hook(void *data,
233 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
234 static void _changed_job(void *data);
235 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
236 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
237 static Eina_Bool _item_single_select_up(Widget_Data *wd);
238 static Eina_Bool _item_single_select_down(Widget_Data *wd);
239 static Eina_Bool _event_hook(Evas_Object *obj,
241 Evas_Callback_Type type,
243 static void _signal_emit_hook(Evas_Object *obj,
244 const char *emission,
246 static Eina_Bool _deselect_all_items(Widget_Data *wd);
247 static void _pan_calculate(Evas_Object *obj);
248 static void _pan_max_get(Evas_Object *obj,
251 static void _item_position(Elm_Genlist_Item *it,
255 static void _mode_item_realize(Elm_Genlist_Item *it);
256 static void _mode_item_unrealize(Elm_Genlist_Item *it);
257 static void _item_mode_set(Elm_Genlist_Item *it);
258 static void _item_mode_unset(Widget_Data *wd);
259 static void _group_items_recalc(void *data);
260 static void _item_move_after(Elm_Genlist_Item *it,
261 Elm_Genlist_Item *after);
262 static void _item_move_before(Elm_Genlist_Item *it,
263 Elm_Genlist_Item *before);
265 // TODO : refactoring
266 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
267 static unsigned int current_time_get();
268 static Eina_Bool _item_moving_effect_timer_cb(void *data);
269 static int _item_flip_effect_show(Elm_Genlist_Item *it);
270 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
271 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
272 static void _effect_item_unrealize(Elm_Genlist_Item *it);
273 static void _item_auto_scroll(void *data);
275 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
277 static const char SIG_ACTIVATED[] = "activated";
278 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
279 static const char SIG_SELECTED[] = "selected";
280 static const char SIG_UNSELECTED[] = "unselected";
281 static const char SIG_EXPANDED[] = "expanded";
282 static const char SIG_CONTRACTED[] = "contracted";
283 static const char SIG_EXPAND_REQUEST[] = "expand,request";
284 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
285 static const char SIG_REALIZED[] = "realized";
286 static const char SIG_UNREALIZED[] = "unrealized";
287 static const char SIG_DRAG_START_UP[] = "drag,start,up";
288 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
289 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
290 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
291 static const char SIG_DRAG_STOP[] = "drag,stop";
292 static const char SIG_DRAG[] = "drag";
293 static const char SIG_LONGPRESSED[] = "longpressed";
294 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
295 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
296 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
297 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
298 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
299 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
300 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
301 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
302 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
303 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
304 static const char SIG_SWIPE[] = "swipe";
306 static const Evas_Smart_Cb_Description _signals[] = {
307 {SIG_CLICKED_DOUBLE, ""},
310 {SIG_UNSELECTED, ""},
312 {SIG_CONTRACTED, ""},
313 {SIG_EXPAND_REQUEST, ""},
314 {SIG_CONTRACT_REQUEST, ""},
316 {SIG_UNREALIZED, ""},
317 {SIG_DRAG_START_UP, ""},
318 {SIG_DRAG_START_DOWN, ""},
319 {SIG_DRAG_START_LEFT, ""},
320 {SIG_DRAG_START_RIGHT, ""},
323 {SIG_LONGPRESSED, ""},
324 {SIG_SCROLL_EDGE_TOP, ""},
325 {SIG_SCROLL_EDGE_BOTTOM, ""},
326 {SIG_SCROLL_EDGE_LEFT, ""},
327 {SIG_SCROLL_EDGE_RIGHT, ""},
328 {SIG_MULTI_SWIPE_LEFT, ""},
329 {SIG_MULTI_SWIPE_RIGHT, ""},
330 {SIG_MULTI_SWIPE_UP, ""},
331 {SIG_MULTI_SWIPE_DOWN, ""},
332 {SIG_MULTI_PINCH_OUT, ""},
333 {SIG_MULTI_PINCH_IN, ""},
339 _event_hook(Evas_Object *obj,
340 Evas_Object *src __UNUSED__,
341 Evas_Callback_Type type,
344 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
345 Evas_Event_Key_Down *ev = event_info;
346 Widget_Data *wd = elm_widget_data_get(obj);
347 Evas_Coord pan_max_x = 0, pan_max_y = 0;
348 if (!wd) return EINA_FALSE;
349 if (!wd->items) return EINA_FALSE;
350 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
351 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
353 Elm_Genlist_Item *it = NULL;
356 Evas_Coord step_x = 0;
357 Evas_Coord step_y = 0;
360 Evas_Coord page_x = 0;
361 Evas_Coord page_y = 0;
363 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
364 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
365 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
366 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
368 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
372 else if ((!strcmp(ev->keyname, "Right")) ||
373 (!strcmp(ev->keyname, "KP_Right")))
377 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
379 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
380 (_item_multi_select_up(wd)))
381 || (_item_single_select_up(wd)))
383 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
389 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
391 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
392 (_item_multi_select_down(wd)))
393 || (_item_single_select_down(wd)))
395 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
401 else if ((!strcmp(ev->keyname, "Home")) ||
402 (!strcmp(ev->keyname, "KP_Home")))
404 it = elm_genlist_first_item_get(obj);
405 elm_genlist_item_bring_in(it);
406 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
409 else if ((!strcmp(ev->keyname, "End")) ||
410 (!strcmp(ev->keyname, "KP_End")))
412 it = elm_genlist_last_item_get(obj);
413 elm_genlist_item_bring_in(it);
414 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
417 else if ((!strcmp(ev->keyname, "Prior")) ||
418 (!strcmp(ev->keyname, "KP_Prior")))
421 y -= -(page_y * v_h) / 100;
425 else if ((!strcmp(ev->keyname, "Next")) ||
426 (!strcmp(ev->keyname, "KP_Next")))
429 y += -(page_y * v_h) / 100;
433 else if (((!strcmp(ev->keyname, "Return")) ||
434 (!strcmp(ev->keyname, "KP_Enter")) ||
435 (!strcmp(ev->keyname, "space")))
436 && (!wd->multi) && (wd->selected))
438 it = elm_genlist_selected_item_get(obj);
439 elm_genlist_item_expanded_set(it,
440 !elm_genlist_item_expanded_get(it));
441 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
443 else if (!strcmp(ev->keyname, "Escape"))
445 if (!_deselect_all_items(wd)) return EINA_FALSE;
446 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
449 else return EINA_FALSE;
451 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
452 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
454 if (x > pan_max_x) x = pan_max_x;
456 if (y > pan_max_y) y = pan_max_y;
457 elm_smart_scroller_child_pos_set(wd->scr, x, y);
462 _deselect_all_items(Widget_Data *wd)
464 if (!wd->selected) return EINA_FALSE;
466 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
472 _item_multi_select_up(Widget_Data *wd)
474 if (!wd->selected) return EINA_FALSE;
475 if (!wd->multi) return EINA_FALSE;
477 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
478 if (!prev) return EINA_TRUE;
480 if (elm_genlist_item_selected_get(prev))
482 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
483 wd->last_selected_item = prev;
484 elm_genlist_item_show(wd->last_selected_item);
488 elm_genlist_item_selected_set(prev, EINA_TRUE);
489 elm_genlist_item_show(prev);
495 _item_multi_select_down(Widget_Data *wd)
497 if (!wd->selected) return EINA_FALSE;
498 if (!wd->multi) return EINA_FALSE;
500 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
501 if (!next) return EINA_TRUE;
503 if (elm_genlist_item_selected_get(next))
505 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
506 wd->last_selected_item = next;
507 elm_genlist_item_show(wd->last_selected_item);
511 elm_genlist_item_selected_set(next, EINA_TRUE);
512 elm_genlist_item_show(next);
518 _item_single_select_up(Widget_Data *wd)
520 Elm_Genlist_Item *prev;
523 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
524 while ((prev) && (prev->delete_me))
525 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
527 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
529 if (!prev) return EINA_FALSE;
531 _deselect_all_items(wd);
533 elm_genlist_item_selected_set(prev, EINA_TRUE);
534 elm_genlist_item_show(prev);
539 _item_single_select_down(Widget_Data *wd)
541 Elm_Genlist_Item *next;
544 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
545 while ((next) && (next->delete_me))
546 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
548 else next = elm_genlist_item_next_get(wd->last_selected_item);
550 if (!next) return EINA_FALSE;
552 _deselect_all_items(wd);
554 elm_genlist_item_selected_set(next, EINA_TRUE);
555 elm_genlist_item_show(next);
560 _on_focus_hook(void *data __UNUSED__,
563 Widget_Data *wd = elm_widget_data_get(obj);
565 if (elm_widget_focus_get(obj))
567 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
568 evas_object_focus_set(wd->obj, EINA_TRUE);
569 if ((wd->selected) && (!wd->last_selected_item))
570 wd->last_selected_item = eina_list_data_get(wd->selected);
574 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
575 evas_object_focus_set(wd->obj, EINA_FALSE);
580 _del_hook(Evas_Object *obj)
582 Widget_Data *wd = elm_widget_data_get(obj);
584 _item_cache_zero(wd);
585 if (wd->calc_job) ecore_job_del(wd->calc_job);
586 if (wd->update_job) ecore_job_del(wd->update_job);
587 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
588 if (wd->changed_job) ecore_job_del(wd->changed_job);
589 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
590 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
591 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
592 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
597 _del_pre_hook(Evas_Object *obj)
599 Widget_Data *wd = elm_widget_data_get(obj);
601 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
602 elm_genlist_clear(obj);
603 evas_object_del(wd->pan_smart);
604 wd->pan_smart = NULL;
608 _mirrored_set(Evas_Object *obj,
611 Widget_Data *wd = elm_widget_data_get(obj);
613 _item_cache_zero(wd);
614 elm_smart_scroller_mirrored_set(wd->scr, rtl);
618 _theme_hook(Evas_Object *obj)
620 Widget_Data *wd = elm_widget_data_get(obj);
623 evas_event_freeze(evas_object_evas_get(wd->obj));
624 _item_cache_zero(wd);
625 _elm_widget_mirrored_reload(obj);
626 _mirrored_set(obj, elm_widget_mirrored_get(obj));
627 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
628 elm_widget_style_get(obj));
629 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
630 wd->item_width = wd->item_height = 0;
631 wd->group_item_width = wd->group_item_height = 0;
632 wd->minw = wd->minh = wd->realminw = 0;
633 EINA_INLIST_FOREACH(wd->blocks, itb)
636 Elm_Genlist_Item *it;
638 if (itb->realized) _item_block_unrealize(itb);
639 EINA_LIST_FOREACH(itb->items, l, it)
640 it->mincalcd = EINA_FALSE;
642 itb->changed = EINA_TRUE;
644 if (wd->calc_job) ecore_job_del(wd->calc_job);
645 wd->calc_job = ecore_job_add(_calc_job, wd);
647 evas_event_thaw(evas_object_evas_get(wd->obj));
648 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
652 _show_region_hook(void *data,
655 Widget_Data *wd = elm_widget_data_get(data);
656 Evas_Coord x, y, w, h;
658 elm_widget_show_region_get(obj, &x, &y, &w, &h);
659 //x & y are screen coordinates, Add with pan coordinates
662 if(wd->rename_it) elm_genlist_item_bring_in(wd->rename_it);
663 else elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
667 _sizing_eval(Evas_Object *obj)
669 Widget_Data *wd = elm_widget_data_get(obj);
670 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
672 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
673 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
675 if (wd->height_for_width)
679 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
680 if ((vw != 0) && (vw != wd->prev_viewport_w))
684 wd->prev_viewport_w = vw;
685 EINA_INLIST_FOREACH(wd->blocks, itb)
687 itb->must_recalc = EINA_TRUE;
689 if (wd->calc_job) ecore_job_del(wd->calc_job);
690 wd->calc_job = ecore_job_add(_calc_job, wd);
693 if (wd->mode == ELM_LIST_LIMIT)
695 Evas_Coord vmw, vmh, vw, vh;
699 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
700 if ((minw > 0) && (vw < minw)) vw = minw;
701 else if ((maxw > 0) && (vw > maxw))
703 edje_object_size_min_calc
704 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
711 edje_object_size_min_calc
712 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
716 evas_object_size_hint_min_set(obj, minw, minh);
717 evas_object_size_hint_max_set(obj, maxw, maxh);
721 _signal_emit_hook(Evas_Object *obj,
722 const char *emission,
725 Widget_Data *wd = elm_widget_data_get(obj);
726 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
731 _item_highlight(Elm_Genlist_Item *it)
733 const char *selectraise;
734 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
735 (it->disabled) || (it->display_only) || (it->mode_view))
737 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
738 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
739 selectraise = edje_object_data_get(it->base.view, "selectraise");
740 if ((selectraise) && (!strcmp(selectraise, "on")))
742 if (it->edit_obj) evas_object_raise(it->edit_obj);
743 else evas_object_raise(it->base.view);
744 if ((it->group_item) && (it->group_item->realized))
745 evas_object_raise(it->group_item->base.view);
747 it->highlighted = EINA_TRUE;
751 _item_block_del(Elm_Genlist_Item *it)
754 Item_Block *itb = it->block;
756 itb->items = eina_list_remove(itb->items, it);
758 itb->changed = EINA_TRUE;
759 if (!it->wd->reorder_deleted)
761 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
762 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
766 il = EINA_INLIST_GET(itb);
767 Item_Block *itbn = (Item_Block *)(il->next);
769 it->parent->items = eina_list_remove(it->parent->items, it);
771 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
773 if (itbn) itbn->changed = EINA_TRUE;
777 if (itb->count < itb->wd->max_items_per_block/2)
779 il = EINA_INLIST_GET(itb);
780 Item_Block *itbp = (Item_Block *)(il->prev);
781 Item_Block *itbn = (Item_Block *)(il->next);
782 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
784 Elm_Genlist_Item *it2;
786 EINA_LIST_FREE(itb->items, it2)
789 itbp->items = eina_list_append(itbp->items, it2);
791 itbp->changed = EINA_TRUE;
793 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
794 EINA_INLIST_GET(itb));
797 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
801 Eina_List *last = eina_list_last(itb->items);
802 Elm_Genlist_Item *it2 = last->data;
805 itb->items = eina_list_remove_list(itb->items, last);
806 itbn->items = eina_list_prepend(itbn->items, it2);
808 itbn->changed = EINA_TRUE;
811 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
819 _item_subitems_clear(Elm_Genlist_Item *it)
822 Eina_List *tl = NULL, *l;
823 Elm_Genlist_Item *it2;
825 EINA_LIST_FOREACH(it->items, l, it2)
826 tl = eina_list_append(tl, it2);
828 EINA_LIST_FREE(tl, it2)
829 elm_genlist_item_del(it2);
833 _item_del(Elm_Genlist_Item *it)
835 Evas_Object *tob = it->wd->obj;
837 evas_event_freeze(evas_object_evas_get(tob));
838 elm_widget_item_pre_notify_del(it);
839 elm_genlist_item_subitems_clear(it);
840 it->wd->walking -= it->walking;
841 if (it->wd->show_item == it) it->wd->show_item = NULL;
842 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
843 if (it->realized) _item_unrealize(it, EINA_FALSE);
844 if (it->effect_item_realized) _effect_item_unrealize(it);
845 if (it->block) _item_block_del(it);
846 if ((!it->delete_me) && (it->itc->func.del))
847 it->itc->func.del((void *)it->base.data, it->base.widget);
848 it->delete_me = EINA_TRUE;
850 it->wd->queue = eina_list_remove(it->wd->queue, it);
852 if (it->wd->anchor_item == it)
854 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
855 if (!it->wd->anchor_item)
856 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
859 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
861 it->parent->items = eina_list_remove(it->parent->items, it);
862 if (it->flags & ELM_GENLIST_ITEM_GROUP)
863 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
864 if (it->long_timer) ecore_timer_del(it->long_timer);
865 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
867 if (it->tooltip.del_cb)
868 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
870 evas_event_thaw(evas_object_evas_get(tob));
871 evas_event_thaw_eval(evas_object_evas_get(tob));
873 elm_widget_item_del(it);
877 _item_select(Elm_Genlist_Item *it)
881 Evas_Object *parent = it->base.widget;
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);
891 evas_object_ref(parent);
894 if (it->wd->last_selected_item && (it != it->wd->last_selected_item))
896 EINA_LIST_FOREACH(it->wd->last_selected_item->icon_objs, l, obj)
897 elm_widget_focused_object_clear(obj);
899 if (it->func.func) it->func.func((void *)it->func.data, parent, it);
901 evas_object_smart_callback_call(parent, SIG_SELECTED, it);
904 if ((it->wd->clear_me) && (!it->wd->walking))
906 elm_genlist_clear(parent);
911 if ((!it->walking) && (it->delete_me))
913 if (!it->relcount) _item_del(it);
917 if (it && it->wd) it->wd->last_selected_item = it; // TODO: Remove 'if'?
919 evas_object_unref(parent);
923 _item_unselect(Elm_Genlist_Item *it)
925 const char *stacking, *selectraise;
927 if ((it->delete_me) || (!it->highlighted)) return;
928 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
929 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
930 stacking = edje_object_data_get(it->base.view, "stacking");
931 selectraise = edje_object_data_get(it->base.view, "selectraise");
932 if ((selectraise) && (!strcmp(selectraise, "on")))
934 if ((stacking) && (!strcmp(stacking, "below")))
935 evas_object_lower(it->base.view);
937 it->highlighted = EINA_FALSE;
940 it->selected = EINA_FALSE;
941 it->wd->selected = eina_list_remove(it->wd->selected, it);
942 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
947 _mouse_move(void *data,
948 Evas *evas __UNUSED__,
952 Elm_Genlist_Item *it = data;
953 Evas_Event_Mouse_Move *ev = event_info;
954 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
955 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
957 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
959 if (!it->wd->on_hold)
961 it->wd->on_hold = EINA_TRUE;
962 if (!it->wd->wasselected)
966 if (it->wd->multitouched)
968 it->wd->cur_x = ev->cur.canvas.x;
969 it->wd->cur_y = ev->cur.canvas.y;
972 if ((it->dragging) && (it->down))
974 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
977 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
978 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
979 if (abs((it->wd->history[it->wd->movements].x -
980 it->wd->history[0].x)) > 40)
981 it->wd->swipe = EINA_TRUE;
987 ecore_timer_del(it->long_timer);
988 it->long_timer = NULL;
990 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
993 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
997 ecore_timer_del(it->long_timer);
998 it->long_timer = NULL;
1000 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1002 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1003 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1005 if (!it->wd->reorder_start_y)
1006 it->wd->reorder_start_y = it->block->y + it->y;
1010 else if (it_scrl_y + it->wd->reorder_it->h > oy + oh)
1011 y_pos = oy + oh - it->wd->reorder_it->h;
1016 _item_position(it, it->edit_obj, it->scrl_x, y_pos);
1018 _item_position(it, it->base.view, it->scrl_x, y_pos);
1019 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1020 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1024 if (!it->display_only)
1025 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1026 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1027 x = ev->cur.canvas.x - x;
1028 y = ev->cur.canvas.y - y;
1031 if (adx < 0) adx = -dx;
1034 if (ady < 0) ady = -dy;
1037 if ((adx > minw) || (ady > minh))
1039 it->dragging = EINA_TRUE;
1040 it->wd->dragging_queue = eina_list_append(it->wd->dragging_queue, it);
1043 ecore_timer_del(it->long_timer);
1044 it->long_timer = NULL;
1046 if (!it->wd->wasselected)
1051 evas_object_smart_callback_call(it->base.widget,
1052 SIG_DRAG_START_UP, it);
1056 evas_object_smart_callback_call(it->base.widget,
1057 SIG_DRAG_START_LEFT, it);
1059 evas_object_smart_callback_call(it->base.widget,
1060 SIG_DRAG_START_RIGHT, it);
1066 evas_object_smart_callback_call(it->base.widget,
1067 SIG_DRAG_START_DOWN, it);
1071 evas_object_smart_callback_call(it->base.widget,
1072 SIG_DRAG_START_LEFT, it);
1074 evas_object_smart_callback_call(it->base.widget,
1075 SIG_DRAG_START_RIGHT, it);
1082 _long_press(void *data)
1084 Elm_Genlist_Item *it = data, *it_tmp;
1085 Eina_List *list, *l;
1087 it->long_timer = NULL;
1088 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
1089 return ECORE_CALLBACK_CANCEL;
1090 it->wd->longpressed = EINA_TRUE;
1091 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1092 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1094 it->wd->reorder_it = it;
1095 it->wd->reorder_start_y = 0;
1097 evas_object_raise(it->edit_obj);
1099 evas_object_raise(it->base.view);
1100 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1101 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1103 list = elm_genlist_realized_items_get(it->wd->obj);
1104 EINA_LIST_FOREACH(list, l, it_tmp)
1106 if (it != it_tmp) _item_unselect(it_tmp);
1110 EINA_LIST_FOREACH(it->items, l, it_tmp)
1112 if (elm_genlist_item_expanded_get(it_tmp))
1114 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1115 return ECORE_CALLBACK_RENEW;
1119 if (elm_genlist_item_expanded_get(it))
1121 elm_genlist_item_expanded_set(it, EINA_FALSE);
1122 return ECORE_CALLBACK_RENEW;
1125 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1127 edje_object_signal_emit(it->base.view, "elm,state,reorder,enabled", "elm");
1129 return ECORE_CALLBACK_CANCEL;
1133 _swipe(Elm_Genlist_Item *it)
1138 if ((it->display_only) || (it->disabled)) return;
1139 it->wd->swipe = EINA_FALSE;
1140 for (i = 0; i < it->wd->movements; i++)
1142 sum += it->wd->history[i].x;
1143 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1146 sum /= it->wd->movements;
1147 if (abs(sum - it->wd->history[0].x) <= 10) return;
1148 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1152 _swipe_cancel(void *data)
1154 Elm_Genlist_Item *it = data;
1156 if (!it) return ECORE_CALLBACK_CANCEL;
1157 it->wd->swipe = EINA_FALSE;
1158 it->wd->movements = 0;
1159 return ECORE_CALLBACK_RENEW;
1163 _multi_cancel(void *data)
1165 Widget_Data *wd = data;
1167 if (!wd) return ECORE_CALLBACK_CANCEL;
1168 wd->multi_timeout = EINA_TRUE;
1169 return ECORE_CALLBACK_RENEW;
1173 _multi_touch_gesture_eval(void *data)
1175 Elm_Genlist_Item *it = data;
1177 it->wd->multitouched = EINA_FALSE;
1178 if (it->wd->multi_timer)
1180 ecore_timer_del(it->wd->multi_timer);
1181 it->wd->multi_timer = NULL;
1183 if (it->wd->multi_timeout)
1185 it->wd->multi_timeout = EINA_FALSE;
1189 Evas_Coord minw = 0, minh = 0;
1190 Evas_Coord off_x, off_y, off_mx, off_my;
1192 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1193 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1194 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1195 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1196 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1198 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1200 if ((off_x + off_mx) > (off_y + off_my))
1202 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1203 evas_object_smart_callback_call(it->base.widget,
1204 SIG_MULTI_SWIPE_RIGHT, it);
1205 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1206 evas_object_smart_callback_call(it->base.widget,
1207 SIG_MULTI_SWIPE_LEFT, it);
1208 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1209 evas_object_smart_callback_call(it->base.widget,
1210 SIG_MULTI_PINCH_OUT, it);
1212 evas_object_smart_callback_call(it->base.widget,
1213 SIG_MULTI_PINCH_IN, it);
1217 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1218 evas_object_smart_callback_call(it->base.widget,
1219 SIG_MULTI_SWIPE_DOWN, it);
1220 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1221 evas_object_smart_callback_call(it->base.widget,
1222 SIG_MULTI_SWIPE_UP, it);
1223 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1224 evas_object_smart_callback_call(it->base.widget,
1225 SIG_MULTI_PINCH_OUT, it);
1227 evas_object_smart_callback_call(it->base.widget,
1228 SIG_MULTI_PINCH_IN, it);
1231 it->wd->multi_timeout = EINA_FALSE;
1235 _multi_down(void *data,
1236 Evas *evas __UNUSED__,
1237 Evas_Object *obj __UNUSED__,
1240 Elm_Genlist_Item *it = data;
1241 Evas_Event_Multi_Down *ev = event_info;
1243 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1244 it->wd->multi_device = ev->device;
1245 it->wd->multi_down = EINA_TRUE;
1246 it->wd->multitouched = EINA_TRUE;
1247 it->wd->prev_mx = ev->canvas.x;
1248 it->wd->prev_my = ev->canvas.y;
1249 if (!it->wd->wasselected) _item_unselect(it);
1250 it->wd->wasselected = EINA_FALSE;
1251 it->wd->longpressed = EINA_FALSE;
1254 ecore_timer_del(it->long_timer);
1255 it->long_timer = NULL;
1259 it->dragging = EINA_FALSE;
1260 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1262 if (it->swipe_timer)
1264 ecore_timer_del(it->swipe_timer);
1265 it->swipe_timer = NULL;
1267 if (it->wd->on_hold)
1269 it->wd->swipe = EINA_FALSE;
1270 it->wd->movements = 0;
1271 it->wd->on_hold = EINA_FALSE;
1276 _multi_up(void *data,
1277 Evas *evas __UNUSED__,
1278 Evas_Object *obj __UNUSED__,
1281 Elm_Genlist_Item *it = data;
1282 Evas_Event_Multi_Up *ev = event_info;
1284 if (it->wd->multi_device != ev->device) return;
1285 it->wd->multi_device = 0;
1286 it->wd->multi_down = EINA_FALSE;
1287 if (it->wd->mouse_down) return;
1288 _multi_touch_gesture_eval(data);
1292 _multi_move(void *data,
1293 Evas *evas __UNUSED__,
1294 Evas_Object *obj __UNUSED__,
1297 Elm_Genlist_Item *it = data;
1298 Evas_Event_Multi_Move *ev = event_info;
1300 if (it->wd->multi_device != ev->device) return;
1301 it->wd->cur_mx = ev->cur.canvas.x;
1302 it->wd->cur_my = ev->cur.canvas.y;
1306 _mouse_down(void *data,
1307 Evas *evas __UNUSED__,
1311 Elm_Genlist_Item *it = data;
1312 Evas_Event_Mouse_Down *ev = event_info;
1315 if (ev->button != 1) return;
1316 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1318 it->wd->on_hold = EINA_TRUE;
1320 it->down = EINA_TRUE;
1321 it->dragging = EINA_FALSE;
1322 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1323 it->dx = ev->canvas.x - x;
1324 it->dy = ev->canvas.y - y;
1325 it->wd->mouse_down = EINA_TRUE;
1326 if (!it->wd->multitouched)
1328 it->wd->prev_x = ev->canvas.x;
1329 it->wd->prev_y = ev->canvas.y;
1330 it->wd->multi_timeout = EINA_FALSE;
1331 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1332 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1334 it->wd->longpressed = EINA_FALSE;
1335 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1336 else it->wd->on_hold = EINA_FALSE;
1337 if (it->wd->on_hold) return;
1338 it->wd->wasselected = it->selected;
1339 _item_highlight(it);
1340 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1341 if ((!it->disabled) && (!it->display_only))
1343 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1344 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
1346 if (it->long_timer) ecore_timer_del(it->long_timer);
1347 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1348 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1350 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1353 it->long_timer = NULL;
1354 it->wd->swipe = EINA_FALSE;
1355 it->wd->movements = 0;
1359 _mouse_up(void *data,
1360 Evas *evas __UNUSED__,
1361 Evas_Object *obj __UNUSED__,
1364 Elm_Genlist_Item *it = data;
1365 Evas_Event_Mouse_Up *ev = event_info;
1366 Eina_Bool dragged = EINA_FALSE;
1368 if (ev->button != 1) return;
1369 it->down = EINA_FALSE;
1370 it->wd->mouse_down = EINA_FALSE;
1371 if (it->wd->multitouched)
1373 // in single selection modes, some multi touching can make multi highlighted items.
1374 // if a item not selected and highlighted, it should be unhighlighted.
1375 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unselect(it);
1376 if (it->wd->multi_down) return;
1377 _multi_touch_gesture_eval(data);
1380 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1381 else it->wd->on_hold = EINA_FALSE;
1384 ecore_timer_del(it->long_timer);
1385 it->long_timer = NULL;
1387 while (it->wd->dragging_queue)
1389 Elm_Genlist_Item *dragging_it = NULL;
1390 dragging_it = eina_list_data_get(it->wd->dragging_queue);
1391 dragging_it->dragging = EINA_FALSE;
1392 evas_object_smart_callback_call(dragging_it->base.widget, SIG_DRAG_STOP, dragging_it);
1393 if (dragging_it->want_unrealize)
1395 _item_unrealize(dragging_it, EINA_FALSE);
1396 if (dragging_it->block->want_unrealize)
1397 _item_block_unrealize(it->block);
1399 it->wd->dragging_queue = eina_list_remove_list(it->wd->dragging_queue,it->wd->dragging_queue);
1402 if (it->swipe_timer)
1404 ecore_timer_del(it->swipe_timer);
1405 it->swipe_timer = NULL;
1407 if (it->wd->multi_timer)
1409 ecore_timer_del(it->wd->multi_timer);
1410 it->wd->multi_timer = NULL;
1411 it->wd->multi_timeout = EINA_FALSE;
1413 if (it->wd->on_hold)
1415 if (it->wd->swipe) _swipe(data);
1416 it->wd->longpressed = EINA_FALSE;
1417 it->wd->on_hold = EINA_FALSE;
1420 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1422 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1424 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1426 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1427 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1429 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1433 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1434 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1436 it->wd->reorder_deleted = EINA_FALSE;
1437 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1438 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1439 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1440 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1443 if (it->wd->longpressed)
1445 it->wd->longpressed = EINA_FALSE;
1446 if (!it->wd->wasselected)
1448 it->wd->wasselected = EINA_FALSE;
1451 if ((it->disabled) || (dragged) || (it->display_only)) return;
1452 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1457 _item_highlight(it);
1460 else _item_unselect(it);
1466 Widget_Data *wd = it->wd;
1469 while (wd->selected) _item_unselect(wd->selected->data);
1474 const Eina_List *l, *l_next;
1475 Elm_Genlist_Item *it2;
1477 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1478 if (it2 != it) _item_unselect(it2);
1479 //_item_highlight(it);
1482 _item_highlight(it);
1488 _signal_expand_toggle(void *data,
1489 Evas_Object *obj __UNUSED__,
1490 const char *emission __UNUSED__,
1491 const char *source __UNUSED__)
1493 Elm_Genlist_Item *it = data;
1496 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1498 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1502 _signal_expand(void *data,
1503 Evas_Object *obj __UNUSED__,
1504 const char *emission __UNUSED__,
1505 const char *source __UNUSED__)
1507 Elm_Genlist_Item *it = data;
1510 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1514 _signal_contract(void *data,
1515 Evas_Object *obj __UNUSED__,
1516 const char *emission __UNUSED__,
1517 const char *source __UNUSED__)
1519 Elm_Genlist_Item *it = data;
1522 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1526 _scr_hold_timer_cb(void *data)
1528 if (!data) return ECORE_CALLBACK_CANCEL;
1529 Widget_Data *wd = data;
1530 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1531 wd->scr_hold_timer = NULL;
1532 return ECORE_CALLBACK_CANCEL;
1536 _mode_finished_signal_cb(void *data,
1538 const char *emission __UNUSED__,
1539 const char *source __UNUSED__)
1543 Elm_Genlist_Item *it = data;
1544 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1546 Evas *te = evas_object_evas_get(obj);
1548 evas_event_freeze(te);
1549 it->nocache = EINA_FALSE;
1550 _mode_item_unrealize(it);
1552 evas_object_raise(it->group_item->base.view);
1553 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1554 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1555 evas_event_thaw(te);
1556 evas_event_thaw_eval(te);
1560 _item_cache_clean(Widget_Data *wd)
1562 evas_event_freeze(evas_object_evas_get(wd->obj));
1563 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1567 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1568 wd->item_cache = eina_inlist_remove(wd->item_cache,
1569 wd->item_cache->last);
1570 wd->item_cache_count--;
1571 if (itc->spacer) evas_object_del(itc->spacer);
1572 if (itc->base_view) evas_object_del(itc->base_view);
1573 if (itc->item_style) eina_stringshare_del(itc->item_style);
1576 evas_event_thaw(evas_object_evas_get(wd->obj));
1577 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1581 _item_cache_zero(Widget_Data *wd)
1583 int pmax = wd->item_cache_max;
1584 wd->item_cache_max = 0;
1585 _item_cache_clean(wd);
1586 wd->item_cache_max = pmax;
1590 _item_cache_add(Elm_Genlist_Item *it)
1594 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1595 if (it->wd->item_cache_max <= 0)
1597 evas_object_del(it->base.view);
1598 it->base.view = NULL;
1599 evas_object_del(it->spacer);
1601 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1602 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1606 it->wd->item_cache_count++;
1607 itc = calloc(1, sizeof(Item_Cache));
1610 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1611 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1614 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1615 EINA_INLIST_GET(itc));
1616 itc->spacer = it->spacer;
1618 itc->base_view = it->base.view;
1619 it->base.view = NULL;
1620 evas_object_hide(itc->base_view);
1621 evas_object_move(itc->base_view, -9999, -9999);
1622 itc->item_style = eina_stringshare_add(it->itc->item_style);
1623 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1624 itc->compress = (it->wd->compress);
1625 itc->odd = (it->order_num_in & 0x1);
1626 itc->selected = it->selected;
1627 itc->disabled = it->disabled;
1628 itc->expanded = it->expanded;
1631 ecore_timer_del(it->long_timer);
1632 it->long_timer = NULL;
1634 if (it->swipe_timer)
1636 ecore_timer_del(it->swipe_timer);
1637 it->swipe_timer = NULL;
1639 // FIXME: other callbacks?
1640 edje_object_signal_callback_del_full(itc->base_view,
1641 "elm,action,expand,toggle",
1642 "elm", _signal_expand_toggle, it);
1643 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1645 _signal_expand, it);
1646 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1647 "elm", _signal_contract, it);
1648 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1650 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1652 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1654 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1656 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1658 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1660 _item_cache_clean(it->wd);
1661 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1662 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1666 _item_cache_find(Elm_Genlist_Item *it)
1669 Eina_Bool tree = 0, odd;
1671 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1672 odd = (it->order_num_in & 0x1);
1673 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1675 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1677 if ((itc->tree == tree) &&
1678 (itc->odd == odd) &&
1679 (itc->compress == it->wd->compress) &&
1680 (!strcmp(it->itc->item_style, itc->item_style)))
1682 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1683 EINA_INLIST_GET(itc));
1684 it->wd->item_cache_count--;
1692 _item_cache_free(Item_Cache *itc)
1694 if (itc->spacer) evas_object_del(itc->spacer);
1695 if (itc->base_view) evas_object_del(itc->base_view);
1696 if (itc->item_style) eina_stringshare_del(itc->item_style);
1701 _item_label_hook(Elm_Genlist_Item *it, const char *part)
1703 if (!it->itc->func.label_get) return NULL;
1704 return edje_object_part_text_get(it->base.view, part);
1708 _icon_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1710 Elm_Genlist_Item *it = data;
1711 if (it) it->defer_unrealize = EINA_TRUE;
1715 _icon_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1717 Elm_Genlist_Item *it = data;
1718 if (it) it->defer_unrealize = EINA_FALSE;
1721 _item_del_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1723 Elm_Genlist_Item *it = event_info;
1725 if (it->wd->last_selected_item == it)
1726 it->wd->last_selected_item = NULL;
1730 _item_label_realize(Elm_Genlist_Item *it,
1731 Evas_Object *target,
1734 if (it->itc->func.label_get)
1739 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1740 EINA_LIST_FOREACH(*source, l, key)
1742 char *s = it->itc->func.label_get
1743 ((void *)it->base.data, it->base.widget, key);
1747 edje_object_part_text_set(target, key, s);
1752 edje_object_part_text_set(target, key, "");
1759 _item_icon_realize(Elm_Genlist_Item *it,
1760 Evas_Object *target,
1763 Eina_List *res = NULL;
1765 if (it->itc->func.icon_get)
1770 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1771 EINA_LIST_FOREACH(*source, l, key)
1773 Evas_Object *ic = it->itc->func.icon_get
1774 ((void *)it->base.data, it->base.widget, key);
1778 res = eina_list_append(res, ic);
1779 edje_object_part_swallow(target, key, ic);
1780 evas_object_show(ic);
1781 elm_widget_sub_object_add(it->base.widget, ic);
1782 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
1784 elm_widget_disabled_set(ic, EINA_TRUE);
1793 _item_state_realize(Elm_Genlist_Item *it,
1794 Evas_Object *target,
1797 if (it->itc->func.state_get)
1803 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1804 EINA_LIST_FOREACH(*source, l, key)
1806 Eina_Bool on = it->itc->func.state_get
1807 ((void *)it->base.data, it->base.widget, key);
1811 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1812 edje_object_signal_emit(target, buf, "elm");
1816 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1817 edje_object_signal_emit(target, buf, "elm");
1824 _item_realize(Elm_Genlist_Item *it,
1828 Elm_Genlist_Item *it2;
1829 const char *stacking;
1830 const char *treesize;
1832 int depth, tsize = 20;
1833 Item_Cache *itc = NULL;
1835 if ((it->realized) || (it->delete_me)) return;
1836 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1837 it->order_num_in = in;
1838 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1839 if ((it->nocache) && (!it->renamed))
1840 it->nocache = EINA_FALSE;
1842 itc = _item_cache_find(it);
1843 if (itc && (!it->wd->effect_mode))
1845 it->base.view = itc->base_view;
1846 itc->base_view = NULL;
1847 it->spacer = itc->spacer;
1852 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1853 edje_object_scale_set(it->base.view,
1854 elm_widget_scale_get(it->base.widget) *
1855 _elm_config->scale);
1856 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1857 elm_widget_sub_object_add(it->base.widget, it->base.view);
1859 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1860 strncpy(buf, "tree", sizeof(buf));
1861 else strncpy(buf, "item", sizeof(buf));
1862 if (it->wd->compress)
1863 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1865 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1866 strncat(buf, "/", sizeof(buf) - strlen(buf));
1867 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1869 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1870 elm_widget_style_get(it->base.widget));
1871 edje_object_mirrored_set(it->base.view,
1872 elm_widget_mirrored_get(it->base.widget));
1874 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1875 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1876 elm_widget_sub_object_add(it->base.widget, it->spacer);
1878 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1880 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1882 it->expanded_depth = depth;
1883 treesize = edje_object_data_get(it->base.view, "treesize");
1884 if (treesize) tsize = atoi(treesize);
1885 evas_object_size_hint_min_set(it->spacer,
1886 (depth * tsize) * _elm_config->scale, 1);
1887 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1890 edje_object_signal_callback_add(it->base.view,
1891 "elm,action,expand,toggle",
1892 "elm", _signal_expand_toggle, it);
1893 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1894 "elm", _signal_expand, it);
1895 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1896 "elm", _signal_contract, it);
1897 stacking = edje_object_data_get(it->base.view, "stacking");
1900 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1901 else if (!strcmp(stacking, "above"))
1902 evas_object_raise(it->base.view);
1904 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1906 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1908 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1910 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1912 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1914 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1917 if ((!it->edit_obj) &&(it->wd->edit_mode) &&
1918 (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
1919 _effect_item_realize(it, EINA_FALSE);
1923 if ((it->selected) && (it->selected != itc->selected))
1925 edje_object_signal_emit(it->base.view,
1926 "elm,state,selected", "elm");
1928 edje_object_signal_emit(it->edit_obj,
1929 "elm,state,selected", "elm");
1931 if ((it->disabled) && (it->disabled != itc->disabled))
1933 edje_object_signal_emit(it->base.view,
1934 "elm,state,disabled", "elm");
1936 edje_object_signal_emit(it->edit_obj,
1937 "elm,state,disabled", "elm");
1939 if ((it->expanded) && (it->expanded != itc->expanded))
1941 edje_object_signal_emit(it->base.view,
1942 "elm,state,expanded", "elm");
1944 edje_object_signal_emit(it->edit_obj,
1945 "elm,state,expanded", "elm");
1952 edje_object_signal_emit(it->base.view,
1953 "elm,state,selected", "elm");
1955 edje_object_signal_emit(it->edit_obj,
1956 "elm,state,selected", "elm");
1960 edje_object_signal_emit(it->base.view,
1961 "elm,state,disabled", "elm");
1963 edje_object_signal_emit(it->edit_obj,
1964 "elm,state,disabled", "elm");
1968 edje_object_signal_emit(it->base.view,
1969 "elm,state,expanded", "elm");
1971 edje_object_signal_emit(it->edit_obj,
1972 "elm,state,expanded", "elm");
1977 if ((calc) && (it->wd->homogeneous) &&
1978 ((it->wd->item_width) ||
1979 ((it->wd->item_width) && (it->wd->group_item_width))))
1981 /* homogenous genlist shortcut */
1984 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1986 it->w = it->minw = it->wd->group_item_width;
1987 it->h = it->minh = it->wd->group_item_height;
1991 it->w = it->minw = it->wd->item_width;
1992 it->h = it->minh = it->wd->item_height;
1994 it->mincalcd = EINA_TRUE;
1999 _item_label_realize(it, it->base.view, &it->labels);
2000 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
2001 _item_state_realize(it, it->base.view, &it->states);
2002 if (it->itc->func.icon_get) // for rename mode
2009 elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
2010 EINA_LIST_FOREACH(it->icons, l, key)
2012 Evas_Object *ic = it->itc->func.icon_get
2013 ((void *)it->base.data, it->base.widget, l->data);
2016 it->icon_objs = eina_list_append(it->icon_objs, ic);
2017 edje_object_part_swallow(it->base.view, key, ic);
2018 evas_object_show(ic);
2019 elm_widget_sub_object_add(it->base.widget, ic);
2020 // FIXME: if entry calcuates its cursor position correctly and conformant works,
2021 // genlist does not need to handle this focus thing.
2022 evas_object_smart_callback_add(ic, "focused", _icon_focused, it);
2023 evas_object_smart_callback_add(ic, "unfocused", _icon_unfocused, it);
2028 if (!it->mincalcd || it->wd->pan_resize || ((it->wd->height_for_width) && (it->w != it->minw)))
2030 Evas_Coord mw = -1, mh = -1;
2032 if (it->wd->height_for_width) mw = it->wd->w; // TODO: Removed this. This was removed from upstream.
2034 if (!it->display_only)
2035 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2036 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2037 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2039 if (!it->display_only)
2040 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2041 it->w = it->minw = mw;
2042 it->h = it->minh = mh;
2043 it->mincalcd = EINA_TRUE;
2045 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2047 it->wd->group_item_width = mw;
2048 it->wd->group_item_height = mh;
2050 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2052 it->wd->item_width = mw;
2053 it->wd->item_height = mh;
2056 if (!calc) evas_object_show(it->base.view);
2059 if (it->tooltip.content_cb)
2061 elm_widget_item_tooltip_content_cb_set(it,
2062 it->tooltip.content_cb,
2063 it->tooltip.data, NULL);
2064 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2067 if (it->mouse_cursor)
2068 elm_widget_item_cursor_set(it, it->mouse_cursor);
2070 it->realized = EINA_TRUE;
2071 it->want_unrealize = EINA_FALSE;
2073 if (itc) _item_cache_free(itc);
2074 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2075 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2077 evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2078 if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
2080 if (it->itc->edit_item_style)
2082 if (!it->edit_obj) _effect_item_realize(it, EINA_FALSE);
2083 edje_object_message_signal_process(it->edit_obj);
2086 edje_object_message_signal_process(it->base.view);
2090 _item_unrealize(Elm_Genlist_Item *it,
2095 if (!it->realized) return;
2096 if (it->wd->reorder_it == it) return;
2097 if (it->defer_unrealize && !it->updateme) return;
2098 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2100 evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2103 ecore_timer_del(it->long_timer);
2104 it->long_timer = NULL;
2108 evas_object_del(it->base.view);
2109 it->base.view = NULL;
2110 evas_object_del(it->spacer);
2115 edje_object_mirrored_set(it->base.view,
2116 elm_widget_mirrored_get(it->base.widget));
2117 edje_object_scale_set(it->base.view,
2118 elm_widget_scale_get(it->base.widget)
2119 * _elm_config->scale);
2120 _item_cache_add(it);
2122 elm_widget_stringlist_free(it->labels);
2124 elm_widget_stringlist_free(it->icons);
2126 elm_widget_stringlist_free(it->states);
2128 EINA_LIST_FREE(it->icon_objs, icon)
2129 evas_object_del(icon);
2131 _mode_item_unrealize(it);
2133 it->realized = EINA_FALSE;
2134 it->want_unrealize = EINA_FALSE;
2135 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2136 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2137 if (it->wd->edit_mode) _effect_item_unrealize(it);
2141 _item_block_recalc(Item_Block *itb,
2146 Elm_Genlist_Item *it;
2147 Evas_Coord minw = 0, minh = 0;
2148 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2151 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2153 EINA_LIST_FOREACH(itb->items, l, it)
2155 if (it->delete_me) continue;
2156 showme |= it->showme;
2161 if (!it->mincalcd) changed = EINA_TRUE;
2164 _item_realize(it, in, EINA_TRUE);
2165 _item_unrealize(it, EINA_TRUE);
2170 _item_realize(it, in, EINA_TRUE);
2171 _item_unrealize(it, EINA_TRUE);
2175 _item_realize(it, in, EINA_FALSE);
2177 if (minw < it->minw) minw = it->minw;
2185 itb->changed = EINA_FALSE;
2186 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2187 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2192 _item_block_realize(Item_Block *itb)
2194 if (itb->realized) return;
2195 itb->realized = EINA_TRUE;
2196 itb->want_unrealize = EINA_FALSE;
2200 _item_block_unrealize(Item_Block *itb)
2203 Elm_Genlist_Item *it;
2204 Eina_Bool dragging = EINA_FALSE;
2206 if (!itb->realized) return;
2207 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2208 EINA_LIST_FOREACH(itb->items, l, it)
2210 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2214 dragging = EINA_TRUE;
2215 it->want_unrealize = EINA_TRUE;
2218 _item_unrealize(it, EINA_FALSE);
2223 itb->realized = EINA_FALSE;
2224 itb->want_unrealize = EINA_TRUE;
2227 itb->want_unrealize = EINA_FALSE;
2228 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2229 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2233 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2235 Evas_Coord rox, roy, row, roh, oy, oh;
2236 Eina_Bool top = EINA_FALSE;
2237 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2238 if (!reorder_it) return 0;
2240 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2241 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2243 if ((it->wd->reorder_start_y < it->block->y) &&
2244 (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2246 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2247 if (it->block->count == 1)
2248 it->wd->reorder_rel = it;
2250 else if ((it->wd->reorder_start_y >= it->block->y) &&
2251 (roy - oy + (roh / 2) <= it->block->y - it->wd->pan_y))
2253 it->block->reorder_offset = it->wd->reorder_it->h;
2256 it->block->reorder_offset = 0;
2258 it->scrl_y += it->block->reorder_offset;
2260 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2261 rox, roy + (roh / 2), row, 1));
2264 it->wd->reorder_rel = it;
2265 it->scrl_y += it->wd->reorder_it->h;
2266 return it->wd->reorder_it->h;
2273 _reorder_move_animator_cb(void *data)
2275 Elm_Genlist_Item *it = data;
2276 Eina_Bool down = EINA_FALSE;
2278 int y, dy = it->h / 10 * _elm_config->scale, diff;
2280 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2282 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2285 diff = abs(it->old_scrl_y - it->scrl_y);
2286 if (diff > it->h) y = diff / 2;
2287 if (it->old_scrl_y < it->scrl_y)
2289 it->old_scrl_y += y;
2292 else if (it->old_scrl_y > it->scrl_y)
2294 it->old_scrl_y -= y;
2299 _item_position(it, it->edit_obj, it->scrl_x, it->old_scrl_y);
2301 _item_position(it, it->base.view, it->scrl_x, it->old_scrl_y);
2302 _group_items_recalc(it->wd);
2303 if ((it->wd->reorder_pan_move) ||
2304 (down && it->old_scrl_y >= it->scrl_y) ||
2305 (!down && it->old_scrl_y <= it->scrl_y))
2307 it->old_scrl_y = it->scrl_y;
2308 it->move_effect_enabled = EINA_FALSE;
2309 it->wd->reorder_move_animator = NULL;
2310 return ECORE_CALLBACK_CANCEL;
2312 return ECORE_CALLBACK_RENEW;
2316 _item_position(Elm_Genlist_Item *it,
2324 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2325 evas_object_resize(view, it->w, it->h);
2326 evas_object_move(view, it_x, it_y);
2327 evas_object_show(view);
2328 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2329 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2333 _item_block_position(Item_Block *itb,
2337 Elm_Genlist_Item *it;
2338 Elm_Genlist_Item *git;
2339 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2340 Evas_Coord minh = 0;
2343 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2344 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2345 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2347 EINA_LIST_FOREACH(itb->items, l, it)
2349 if (it->delete_me) continue;
2350 else if (it->wd->reorder_it == it) continue;
2355 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2356 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2358 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2359 cvx, cvy, cvw, cvh));
2360 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2362 if ((itb->realized))
2366 if (!it->realized) _item_realize(it, in, EINA_FALSE);
2369 if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
2370 edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
2378 if (it->wd->reorder_mode)
2379 y += _get_space_for_reorder_item(it);
2380 git = it->group_item;
2383 git->scrl_x = it->scrl_x;
2384 if (git->scrl_y < oy)
2386 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2387 git->scrl_y = (it->scrl_y + it->h) - git->h;
2388 git->want_realize = EINA_TRUE;
2390 if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2392 if (!it->move_effect_enabled)
2394 it->move_effect_enabled = EINA_TRUE;
2395 it->wd->reorder_move_animator =
2397 _reorder_move_animator_cb, it);
2400 if (!it->move_effect_enabled)
2401 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))
2403 if (it->wd->edit_mode && it->itc->edit_item_style)
2405 _item_position(it, it->edit_obj, it->scrl_x, it->scrl_y);
2409 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)))
2412 _item_position(it, it->mode_view, it->scrl_x,
2415 _item_position(it, it->base.view, it->scrl_x,
2420 evas_object_resize(it->base.view, it->w, it->h);
2421 evas_object_move(it->base.view, it->scrl_x, it->scrl_y);
2422 evas_object_hide(it->base.view);
2429 if (!it->dragging && (!it->wd->item_moving_effect_timer)) _item_unrealize(it, EINA_FALSE);
2436 if (vis) it->want_realize = EINA_TRUE;
2438 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))
2440 it->old_scrl_y = it->scrl_y;
2445 if (!itb->wd->reorder_it) itb->minh = minh;
2446 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2447 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2451 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2453 Elm_Genlist_Item *it = data;
2455 it->mincalcd = EINA_FALSE;
2456 it->block->changeme = EINA_TRUE;
2457 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2458 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2462 _group_items_recalc(void *data)
2464 Widget_Data *wd = data;
2466 Elm_Genlist_Item *git;
2468 evas_event_freeze(evas_object_evas_get(wd->obj));
2469 EINA_LIST_FOREACH(wd->group_items, l, git)
2471 if (git->want_realize)
2474 _item_realize(git, 0, EINA_FALSE);
2475 evas_object_resize(git->base.view, wd->minw, git->h);
2476 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2477 evas_object_show(git->base.view);
2478 evas_object_raise(git->base.view);
2480 else if (!git->want_realize && git->realized)
2483 _item_unrealize(git, EINA_FALSE);
2486 evas_event_thaw(evas_object_evas_get(wd->obj));
2487 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2491 _must_recalc_idler(void *data)
2493 Widget_Data *wd = data;
2494 if (wd->calc_job) ecore_job_del(wd->calc_job);
2495 wd->calc_job = ecore_job_add(_calc_job, wd);
2496 wd->must_recalc_idler = NULL;
2497 return ECORE_CALLBACK_CANCEL;
2501 _calc_job(void *data)
2503 Widget_Data *wd = data;
2504 Item_Block *itb, *chb = NULL;
2505 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2508 Eina_Bool minw_change = EINA_FALSE;
2509 Eina_Bool did_must_recalc = EINA_FALSE;
2512 t0 = ecore_time_get();
2513 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2517 evas_event_freeze(evas_object_evas_get(wd->obj));
2518 EINA_INLIST_FOREACH(wd->blocks, itb)
2520 Eina_Bool showme = EINA_FALSE;
2523 showme = itb->showme;
2524 itb->showme = EINA_FALSE;
2527 if (itb->realized) _item_block_unrealize(itb);
2529 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2531 if (itb->must_recalc)
2534 Elm_Genlist_Item *it;
2535 EINA_LIST_FOREACH(itb->items, l, it)
2536 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2537 itb->changed = EINA_TRUE;
2538 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2539 itb->must_recalc = EINA_FALSE;
2540 if (itb->realized) _item_block_unrealize(itb);
2542 showme = _item_block_recalc(itb, in, EINA_FALSE);
2548 if (minw == -1) minw = itb->minw;
2549 else if ((!itb->must_recalc) && (minw < itb->minw))
2552 minw_change = EINA_TRUE;
2558 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2560 wd->show_item->showme = EINA_FALSE;
2562 elm_smart_scroller_region_bring_in(wd->scr,
2564 wd->show_item->block->x,
2566 wd->show_item->block->y,
2567 wd->show_item->block->w,
2570 elm_smart_scroller_child_region_show(wd->scr,
2572 wd->show_item->block->x,
2574 wd->show_item->block->y,
2575 wd->show_item->block->w,
2577 wd->show_item = NULL;
2582 EINA_INLIST_FOREACH(wd->blocks, itb)
2588 if ((chb) && (EINA_INLIST_GET(chb)->next))
2590 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2592 if (itb->realized) _item_block_unrealize(itb);
2595 wd->realminw = minw;
2596 if (minw < wd->w) minw = wd->w;
2597 if ((minw != wd->minw) || (minh != wd->minh))
2601 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2602 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2603 _sizing_eval(wd->obj);
2605 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2607 Elm_Genlist_Item *it;
2610 it = wd->anchor_item;
2611 it_y = wd->anchor_y;
2612 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2613 it->block->y + it->y + it_y);
2614 wd->anchor_item = it;
2615 wd->anchor_y = it_y;
2619 t = ecore_time_get();
2620 if (did_must_recalc)
2622 if (!wd->must_recalc_idler)
2623 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2625 wd->calc_job = NULL;
2626 evas_object_smart_changed(wd->pan_smart);
2627 evas_event_thaw(evas_object_evas_get(wd->obj));
2628 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2632 _update_job(void *data)
2634 Widget_Data *wd = data;
2638 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2640 wd->update_job = NULL;
2643 evas_event_freeze(evas_object_evas_get(wd->obj));
2644 EINA_INLIST_FOREACH(wd->blocks, itb)
2646 Evas_Coord itminw, itminh;
2647 Elm_Genlist_Item *it;
2653 _item_block_position(itb, num);
2657 recalc = EINA_FALSE;
2658 EINA_LIST_FOREACH(itb->items, l2, it)
2667 _item_unrealize(it, EINA_FALSE);
2668 _item_realize(it, num, EINA_FALSE);
2669 position = EINA_TRUE;
2673 _item_realize(it, num, EINA_TRUE);
2674 _item_unrealize(it, EINA_TRUE);
2676 if ((it->minw != itminw) || (it->minh != itminh))
2678 it->updateme = EINA_FALSE;
2682 itb->updateme = EINA_FALSE;
2685 position = EINA_TRUE;
2686 itb->changed = EINA_TRUE;
2687 _item_block_recalc(itb, num0, EINA_FALSE);
2688 _item_block_position(itb, num0);
2693 if (wd->calc_job) ecore_job_del(wd->calc_job);
2694 wd->calc_job = ecore_job_add(_calc_job, wd);
2696 evas_event_thaw(evas_object_evas_get(wd->obj));
2697 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2701 _changed_job(void *data)
2703 Widget_Data *wd = data; Eina_List *l2;
2705 int num, num0, position = 0;
2706 Eina_Bool width_changed = EINA_FALSE, height_changed = EINA_FALSE;
2708 wd->changed_job = NULL;
2710 EINA_INLIST_FOREACH(wd->blocks, itb)
2712 Evas_Coord itminw, itminh;
2713 Elm_Genlist_Item *it;
2719 _item_block_position(itb, num);
2723 width_changed = height_changed = EINA_FALSE;
2724 EINA_LIST_FOREACH(itb->items, l2, it)
2726 if ((!it->mincalcd) && (it->realized))
2728 Evas_Coord mw = -1, mh = -1;
2732 if (it->wd->height_for_width) mw = it->wd->w;
2733 if (!it->display_only)
2734 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2735 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2736 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2737 if (!it->display_only)
2738 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2739 it->w = it->minw = mw;
2740 it->h = it->minh = mh;
2741 it->mincalcd = EINA_TRUE;
2743 //if ((it->minw != itminw) || (it->minh != itminh))
2744 //if ((it->minh != itminh))
2746 if ((it->minw != itminw))
2747 width_changed = EINA_TRUE;
2748 if ((it->minh != itminh))
2749 height_changed = EINA_TRUE;
2751 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2753 it->wd->group_item_width = mw;
2754 it->wd->group_item_height = mh;
2756 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2758 it->wd->item_width = mw;
2759 it->wd->item_height = mh;
2764 itb->changeme = EINA_FALSE;
2765 // TODO: why this is separated.
2769 itb->changed = EINA_TRUE;
2770 _item_block_recalc(itb, num0, 0);
2771 _item_block_position(itb, num0);
2773 else if (width_changed)
2775 _item_block_position(itb, num0);
2780 if (wd->calc_job) ecore_job_del(wd->calc_job);
2781 wd->calc_job = ecore_job_add(_calc_job, wd);
2786 _pan_set(Evas_Object *obj,
2790 Pan *sd = evas_object_smart_data_get(obj);
2796 // Evas_Coord ow, oh;
2797 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2798 // ow = sd->wd->minw - ow;
2799 // if (ow < 0) ow = 0;
2800 // oh = sd->wd->minh - oh;
2801 // if (oh < 0) oh = 0;
2802 // if (x < 0) x = 0;
2803 // if (y < 0) y = 0;
2804 // if (x > ow) x = ow;
2805 // if (y > oh) y = oh;
2806 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2811 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2813 if ((itb->y + itb->h) > y)
2815 Elm_Genlist_Item *it;
2818 EINA_LIST_FOREACH(itb->items, l2, it)
2820 if ((itb->y + it->y) >= y)
2822 sd->wd->anchor_item = it;
2823 sd->wd->anchor_y = -(itb->y + it->y - y);
2831 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2835 _pan_get(Evas_Object *obj,
2839 Pan *sd = evas_object_smart_data_get(obj);
2842 if (x) *x = sd->wd->pan_x;
2843 if (y) *y = sd->wd->pan_y;
2847 _pan_max_get(Evas_Object *obj,
2851 Pan *sd = evas_object_smart_data_get(obj);
2855 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2856 ow = sd->wd->minw - ow;
2858 oh = sd->wd->minh - oh;
2865 _pan_min_get(Evas_Object *obj __UNUSED__,
2874 _pan_child_size_get(Evas_Object *obj,
2878 Pan *sd = evas_object_smart_data_get(obj);
2881 if (w) *w = sd->wd->minw;
2882 if (h) *h = sd->wd->minh;
2886 _pan_add(Evas_Object *obj)
2889 Evas_Object_Smart_Clipped_Data *cd;
2892 cd = evas_object_smart_data_get(obj);
2895 sd->__clipped_data = *cd;
2897 evas_object_smart_data_set(obj, sd);
2901 _pan_del(Evas_Object *obj)
2903 Pan *sd = evas_object_smart_data_get(obj);
2908 ecore_job_del(sd->resize_job);
2909 sd->resize_job = NULL;
2915 _pan_resize_job(void *data)
2919 _sizing_eval(sd->wd->obj);
2920 sd->resize_job = NULL;
2924 _pan_resize(Evas_Object *obj,
2928 Pan *sd = evas_object_smart_data_get(obj);
2932 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2933 if ((ow == w) && (oh == h)) return;
2934 if ((sd->wd->height_for_width) && (ow != w))
2936 sd->wd->pan_resize = EINA_TRUE;
2937 if (sd->resize_job) ecore_job_del(sd->resize_job);
2938 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2940 sd->wd->pan_changed = EINA_TRUE;
2941 evas_object_smart_changed(obj);
2942 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2943 sd->wd->calc_job = NULL;
2947 _pan_calculate(Evas_Object *obj)
2949 Pan *sd = evas_object_smart_data_get(obj);
2951 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2953 Elm_Genlist_Item *git;
2957 evas_event_freeze(evas_object_evas_get(obj));
2959 if (sd->wd->pan_changed)
2962 sd->wd->pan_changed = EINA_FALSE;
2965 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2966 sd->wd->prev_viewport_w = ow;
2967 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2968 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2970 git->want_realize = EINA_FALSE;
2972 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2974 itb->w = sd->wd->minw;
2975 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2976 itb->y - sd->wd->pan_y + oy,
2978 cvx, cvy, cvw, cvh))
2980 if ((!itb->realized) || (itb->changed))
2981 _item_block_realize(itb);
2982 _item_block_position(itb, in);
2986 if (itb->realized) _item_block_unrealize(itb);
2990 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2991 _group_items_recalc(sd->wd);
2993 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2995 if (sd->wd->pan_y != sd->wd->old_pan_y)
2996 sd->wd->reorder_pan_move = EINA_TRUE;
2997 else sd->wd->reorder_pan_move = EINA_FALSE;
2998 evas_object_raise(sd->wd->reorder_it->edit_obj);
2999 sd->wd->old_pan_y = sd->wd->pan_y;
3000 sd->wd->start_time = ecore_loop_time_get();
3003 if (sd->wd->effect_mode &&
3004 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
3005 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
3006 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
3008 if (!sd->wd->item_moving_effect_timer)
3010 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
3011 _item_flip_effect_show(sd->wd->expand_item);
3013 evas_object_raise(sd->wd->alpha_bg);
3014 evas_object_show(sd->wd->alpha_bg);
3015 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
3016 sd->wd->start_time = current_time_get();
3017 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
3020 else _item_auto_scroll(sd->wd);
3021 sd->wd->pan_resize = EINA_FALSE;
3022 evas_event_thaw(evas_object_evas_get(obj));
3023 evas_event_thaw_eval(evas_object_evas_get(obj));
3027 _pan_move(Evas_Object *obj,
3028 Evas_Coord x __UNUSED__,
3029 Evas_Coord y __UNUSED__)
3031 Pan *sd = evas_object_smart_data_get(obj);
3035 sd->wd->pan_changed = EINA_TRUE;
3036 evas_object_smart_changed(obj);
3037 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3038 sd->wd->calc_job = NULL;
3042 _hold_on(void *data __UNUSED__,
3044 void *event_info __UNUSED__)
3046 Widget_Data *wd = elm_widget_data_get(obj);
3048 elm_smart_scroller_hold_set(wd->scr, 1);
3052 _hold_off(void *data __UNUSED__,
3054 void *event_info __UNUSED__)
3056 Widget_Data *wd = elm_widget_data_get(obj);
3058 elm_smart_scroller_hold_set(wd->scr, 0);
3062 _freeze_on(void *data __UNUSED__,
3064 void *event_info __UNUSED__)
3066 Widget_Data *wd = elm_widget_data_get(obj);
3068 elm_smart_scroller_freeze_set(wd->scr, 1);
3072 _freeze_off(void *data __UNUSED__,
3074 void *event_info __UNUSED__)
3076 Widget_Data *wd = elm_widget_data_get(obj);
3078 elm_smart_scroller_freeze_set(wd->scr, 0);
3082 _scroll_edge_left(void *data,
3083 Evas_Object *scr __UNUSED__,
3084 void *event_info __UNUSED__)
3086 Evas_Object *obj = data;
3087 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
3091 _scroll_edge_right(void *data,
3092 Evas_Object *scr __UNUSED__,
3093 void *event_info __UNUSED__)
3095 Evas_Object *obj = data;
3096 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
3100 _scroll_edge_top(void *data,
3101 Evas_Object *scr __UNUSED__,
3102 void *event_info __UNUSED__)
3104 Evas_Object *obj = data;
3105 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
3109 _scroll_edge_bottom(void *data,
3110 Evas_Object *scr __UNUSED__,
3111 void *event_info __UNUSED__)
3113 Evas_Object *obj = data;
3114 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
3118 _mode_item_realize(Elm_Genlist_Item *it)
3122 if ((it->mode_view) || (it->delete_me)) return;
3124 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3125 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
3126 edje_object_scale_set(it->mode_view,
3127 elm_widget_scale_get(it->base.widget) *
3128 _elm_config->scale);
3129 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
3130 elm_widget_sub_object_add(it->base.widget, it->mode_view);
3132 strncpy(buf, "item", sizeof(buf));
3133 if (it->wd->compress)
3134 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3136 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3137 strncat(buf, "/", sizeof(buf) - strlen(buf));
3138 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3140 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
3141 elm_widget_style_get(it->base.widget));
3142 edje_object_mirrored_set(it->mode_view,
3143 elm_widget_mirrored_get(it->base.widget));
3145 /* signal callback add */
3146 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3148 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3150 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3153 /* label_get, icon_get, state_get */
3154 _item_label_realize(it, it->mode_view, &it->mode_labels);
3155 if (it->itc->func.icon_get)
3161 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3163 EINA_LIST_FOREACH(it->mode_icons, l, key)
3165 Evas_Object *ic = it->itc->func.icon_get
3166 ((void *)it->base.data, it->base.widget, l->data);
3170 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
3171 edje_object_part_swallow(it->mode_view, key, ic);
3172 evas_object_show(ic);
3173 elm_widget_sub_object_add(it->base.widget, ic);
3175 elm_widget_disabled_set(ic, EINA_TRUE);
3179 _item_state_realize(it, it->mode_view, &it->mode_states);
3180 edje_object_part_swallow(it->mode_view,
3181 edje_object_data_get(it->mode_view, "mode_part"),
3184 it->want_unrealize = EINA_FALSE;
3185 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3186 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3190 _mode_item_unrealize(Elm_Genlist_Item *it)
3192 Widget_Data *wd = it->wd;
3194 if (!it->mode_view) return;
3196 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3197 elm_widget_stringlist_free(it->mode_labels);
3198 it->mode_labels = NULL;
3199 elm_widget_stringlist_free(it->mode_icons);
3200 it->mode_icons = NULL;
3201 elm_widget_stringlist_free(it->mode_states);
3203 EINA_LIST_FREE(it->mode_icon_objs, icon)
3204 evas_object_del(icon);
3206 edje_object_part_unswallow(it->mode_view, it->base.view);
3207 evas_object_smart_member_add(it->base.view, wd->pan_smart);
3208 evas_object_del(it->mode_view);
3209 it->mode_view = NULL;
3211 if (wd->mode_item == it)
3212 wd->mode_item = NULL;
3213 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3214 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3218 _item_mode_set(Elm_Genlist_Item *it)
3221 Widget_Data *wd = it->wd;
3226 it->nocache = EINA_TRUE;
3228 if (wd->scr_hold_timer)
3230 ecore_timer_del(wd->scr_hold_timer);
3231 wd->scr_hold_timer = NULL;
3233 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3234 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3236 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3237 _mode_item_realize(it);
3239 evas_object_raise(it->group_item->base.view);
3240 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
3241 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3242 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3244 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3245 edje_object_signal_emit(it->mode_view, buf, "elm");
3249 _item_mode_unset(Widget_Data *wd)
3252 if (!wd->mode_item) return;
3253 char buf[1024], buf2[1024];
3254 Elm_Genlist_Item *it;
3257 it->nocache = EINA_TRUE;
3259 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3260 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3262 edje_object_signal_emit(it->mode_view, buf, "elm");
3263 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3265 wd->mode_item = NULL;
3270 _item_auto_scroll(void *data)
3272 Widget_Data *wd = data;
3275 if ((wd->expand_item) && (!wd->auto_scrolled))
3277 Elm_Genlist_Item *it;
3279 Evas_Coord ox, oy, ow, oh;
3280 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3282 wd->auto_scrolled = EINA_TRUE;
3283 if (wd->expand_item->scrl_y > (oh + oy) / 2)
3285 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
3287 elm_genlist_item_bring_in(it);
3293 elm_genlist_add(Evas_Object *parent)
3298 Evas_Coord minw, minh;
3299 static Evas_Smart *smart = NULL;
3303 static Evas_Smart_Class sc;
3305 evas_object_smart_clipped_smart_set(&_pan_sc);
3307 sc.name = "elm_genlist_pan";
3308 sc.version = EVAS_SMART_CLASS_VERSION;
3311 sc.resize = _pan_resize;
3312 sc.move = _pan_move;
3313 sc.calculate = _pan_calculate;
3314 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3317 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3319 ELM_SET_WIDTYPE(widtype, "genlist");
3320 elm_widget_type_set(obj, "genlist");
3321 elm_widget_sub_object_add(parent, obj);
3322 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3323 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3324 elm_widget_data_set(obj, wd);
3325 elm_widget_del_hook_set(obj, _del_hook);
3326 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3327 elm_widget_theme_hook_set(obj, _theme_hook);
3328 elm_widget_can_focus_set(obj, EINA_TRUE);
3329 elm_widget_event_hook_set(obj, _event_hook);
3330 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3332 wd->scr = elm_smart_scroller_add(e);
3333 elm_smart_scroller_widget_set(wd->scr, obj);
3334 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3335 elm_widget_style_get(obj));
3336 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3337 _elm_config->thumbscroll_bounce_enable);
3338 elm_widget_resize_object_set(obj, wd->scr);
3340 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3341 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3343 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3344 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3348 wd->mode = ELM_LIST_SCROLL;
3349 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3350 wd->item_cache_max = wd->max_items_per_block * 2;
3351 wd->longpress_timeout = _elm_config->longpress_timeout;
3352 wd->effect_mode = _elm_config->effect_enable;
3354 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3355 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3356 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3357 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3359 wd->pan_smart = evas_object_smart_add(e, smart);
3360 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3363 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3364 _pan_set, _pan_get, _pan_max_get,
3365 _pan_min_get, _pan_child_size_get);
3367 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3369 evas_object_size_hint_min_set(obj, minw, minh);
3371 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3372 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3377 static Elm_Genlist_Item *
3378 _item_new(Widget_Data *wd,
3379 const Elm_Genlist_Item_Class *itc,
3381 Elm_Genlist_Item *parent,
3382 Elm_Genlist_Item_Flags flags,
3384 const void *func_data)
3386 Elm_Genlist_Item *it;
3388 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3389 if (!it) return NULL;
3392 it->base.data = data;
3393 it->parent = parent;
3395 it->func.func = func;
3396 it->func.data = func_data;
3397 it->mouse_cursor = NULL;
3398 it->expanded_depth = 0;
3399 elm_widget_item_text_get_hook_set(it, _item_label_hook);
3400 elm_widget_item_del_cb_set(it, _item_del_hook);
3404 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3405 it->group_item = parent;
3406 else if (it->parent->group_item)
3407 it->group_item = it->parent->group_item;
3413 _item_block_add(Widget_Data *wd,
3414 Elm_Genlist_Item *it)
3416 Item_Block *itb = NULL;
3423 itb = calloc(1, sizeof(Item_Block));
3426 if (!it->rel->block)
3429 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3430 itb->items = eina_list_append(itb->items, it);
3436 wd->blocks = eina_inlist_prepend_relative
3437 (wd->blocks, EINA_INLIST_GET(itb),
3438 EINA_INLIST_GET(it->rel->block));
3440 eina_list_prepend_relative(itb->items, it, it->rel);
3444 wd->blocks = eina_inlist_append_relative
3445 (wd->blocks, EINA_INLIST_GET(itb),
3446 EINA_INLIST_GET(it->rel->block));
3448 eina_list_append_relative(itb->items, it, it->rel);
3458 itb = (Item_Block *)(wd->blocks);
3459 if (itb->count >= wd->max_items_per_block)
3461 itb = calloc(1, sizeof(Item_Block));
3465 eina_inlist_prepend(wd->blocks,
3466 EINA_INLIST_GET(itb));
3471 itb = calloc(1, sizeof(Item_Block));
3475 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3477 itb->items = eina_list_prepend(itb->items, it);
3483 itb = (Item_Block *)(wd->blocks->last);
3484 if (itb->count >= wd->max_items_per_block)
3486 itb = calloc(1, sizeof(Item_Block));
3490 eina_inlist_append(wd->blocks,
3491 EINA_INLIST_GET(itb));
3496 itb = calloc(1, sizeof(Item_Block));
3500 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3502 itb->items = eina_list_append(itb->items, it);
3508 itb = it->rel->block;
3509 if (!itb) goto newblock;
3511 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3513 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3516 itb->changed = EINA_TRUE;
3518 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3519 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3522 it->rel->relcount--;
3523 if ((it->rel->delete_me) && (!it->rel->relcount))
3527 if (itb->count > itb->wd->max_items_per_block)
3531 Elm_Genlist_Item *it2;
3533 newc = itb->count / 2;
3534 itb2 = calloc(1, sizeof(Item_Block));
3538 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3539 EINA_INLIST_GET(itb));
3540 itb2->changed = EINA_TRUE;
3541 while ((itb->count > newc) && (itb->items))
3545 l = eina_list_last(itb->items);
3547 itb->items = eina_list_remove_list(itb->items, l);
3550 itb2->items = eina_list_prepend(itb2->items, it2);
3558 _queue_process(Widget_Data *wd)
3561 Eina_Bool showme = EINA_FALSE;
3564 t0 = ecore_time_get();
3565 //evas_event_freeze(evas_object_evas_get(wd->obj));
3566 for (n = 0; (wd->queue) && (n < 128); n++)
3568 Elm_Genlist_Item *it;
3570 it = wd->queue->data;
3571 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3572 it->queued = EINA_FALSE;
3573 _item_block_add(wd, it);
3574 t = ecore_time_get();
3575 if (it->block->changed)
3577 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3578 it->block->changed = 0;
3580 if (showme) it->block->showme = EINA_TRUE;
3581 if (eina_inlist_count(wd->blocks) > 1)
3583 if ((t - t0) > (ecore_animator_frametime_get())) break;
3586 //evas_event_thaw(evas_object_evas_get(wd->obj));
3587 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3592 _idle_process(void *data, Eina_Bool *wakeup)
3594 Widget_Data *wd = data;
3597 //static double q_start = 0.0;
3598 //if (q_start == 0.0) q_start = ecore_time_get();
3600 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3604 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3606 return ECORE_CALLBACK_CANCEL;
3608 return ECORE_CALLBACK_RENEW;
3612 _item_idle_enterer(void *data)
3614 Widget_Data *wd = data;
3615 Eina_Bool wakeup = EINA_FALSE;
3616 Eina_Bool ok = _idle_process(data, &wakeup);
3621 if (wd->calc_job) ecore_job_del(wd->calc_job);
3622 wd->calc_job = ecore_job_add(_calc_job, wd);
3624 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3629 _item_queue(Widget_Data *wd,
3630 Elm_Genlist_Item *it)
3632 if (it->queued) return;
3633 it->queued = EINA_TRUE;
3634 wd->queue = eina_list_append(wd->queue, it);
3635 // FIXME: why does a freeze then thaw here cause some genlist
3636 // elm_genlist_item_append() to be much much slower?
3637 // evas_event_freeze(evas_object_evas_get(wd->obj));
3638 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3640 if (wd->queue_idle_enterer)
3642 ecore_idle_enterer_del(wd->queue_idle_enterer);
3643 wd->queue_idle_enterer = NULL;
3647 // evas_event_thaw(evas_object_evas_get(wd->obj));
3648 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3649 if (!wd->queue_idle_enterer)
3650 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3654 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3659 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3660 it->wd->reorder_deleted = EINA_TRUE;
3661 _item_block_del(it);
3663 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3665 it->rel->relcount++;
3666 it->before = EINA_FALSE;
3667 if (after->group_item) it->group_item = after->group_item;
3668 _item_queue(it->wd, it);
3670 // TODO: change this to smart callback
3671 if (it->itc->func.moved)
3672 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
3676 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3679 if (!before) return;
3681 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3682 it->wd->reorder_deleted = EINA_TRUE;
3683 _item_block_del(it);
3684 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3686 it->rel->relcount++;
3687 it->before = EINA_TRUE;
3688 if (before->group_item) it->group_item = before->group_item;
3689 _item_queue(it->wd, it);
3691 // TODO: change this to smart callback
3692 if (it->itc->func.moved)
3693 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
3696 EAPI Elm_Genlist_Item *
3697 elm_genlist_item_append(Evas_Object *obj,
3698 const Elm_Genlist_Item_Class *itc,
3700 Elm_Genlist_Item *parent,
3701 Elm_Genlist_Item_Flags flags,
3703 const void *func_data)
3705 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3706 Widget_Data *wd = elm_widget_data_get(obj);
3707 if (!wd) return NULL;
3708 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3710 if (!it) return NULL;
3713 if (flags & ELM_GENLIST_ITEM_GROUP)
3714 wd->group_items = eina_list_append(wd->group_items, it);
3715 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3720 Elm_Genlist_Item *it2 = NULL;
3721 Eina_List *ll = eina_list_last(it->parent->items);
3722 if (ll) it2 = ll->data;
3723 it->parent->items = eina_list_append(it->parent->items, it);
3724 if (!it2) it2 = it->parent;
3726 it2 = elm_genlist_item_prev_get(it2);
3728 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3729 EINA_INLIST_GET(it2));
3731 it->rel->relcount++;
3733 it->before = EINA_FALSE;
3734 _item_queue(wd, it);
3738 EAPI Elm_Genlist_Item *
3739 elm_genlist_item_prepend(Evas_Object *obj,
3740 const Elm_Genlist_Item_Class *itc,
3742 Elm_Genlist_Item *parent,
3743 Elm_Genlist_Item_Flags flags,
3745 const void *func_data)
3747 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3748 Widget_Data *wd = elm_widget_data_get(obj);
3749 if (!wd) return NULL;
3750 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3752 if (!it) return NULL;
3755 if (flags & ELM_GENLIST_ITEM_GROUP)
3756 wd->group_items = eina_list_prepend(wd->group_items, it);
3757 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3762 Elm_Genlist_Item *it2 = NULL;
3763 Eina_List *ll = it->parent->items;
3764 if (ll) it2 = ll->data;
3765 it->parent->items = eina_list_prepend(it->parent->items, it);
3766 if (!it2) it2 = it->parent;
3768 it2 = elm_genlist_item_next_get(it2);
3770 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3771 EINA_INLIST_GET(it2));
3773 it->rel->relcount++;
3775 it->before = EINA_TRUE;
3776 _item_queue(wd, it);
3780 EAPI Elm_Genlist_Item *
3781 elm_genlist_item_insert_after(Evas_Object *obj,
3782 const Elm_Genlist_Item_Class *itc,
3784 Elm_Genlist_Item *parent,
3785 Elm_Genlist_Item *after,
3786 Elm_Genlist_Item_Flags flags,
3788 const void *func_data)
3790 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3791 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3792 Widget_Data *wd = elm_widget_data_get(obj);
3793 if (!wd) return NULL;
3794 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3796 if (!it) return NULL;
3797 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3798 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3802 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3803 (after->flags & ELM_GENLIST_ITEM_GROUP))
3804 wd->group_items = eina_list_append_relative(wd->group_items, it,
3809 it->parent->items = eina_list_append_relative(it->parent->items, it,
3812 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3813 EINA_INLIST_GET(after));
3815 it->rel->relcount++;
3816 it->before = EINA_FALSE;
3817 _item_queue(wd, it);
3821 EAPI Elm_Genlist_Item *
3822 elm_genlist_item_insert_before(Evas_Object *obj,
3823 const Elm_Genlist_Item_Class *itc,
3825 Elm_Genlist_Item *parent,
3826 Elm_Genlist_Item *before,
3827 Elm_Genlist_Item_Flags flags,
3829 const void *func_data)
3831 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3832 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3833 Widget_Data *wd = elm_widget_data_get(obj);
3834 if (!wd) return NULL;
3835 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3837 if (!it) return NULL;
3838 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
3839 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3843 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3844 (before->flags & ELM_GENLIST_ITEM_GROUP))
3845 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
3850 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3853 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3854 EINA_INLIST_GET(before));
3856 it->rel->relcount++;
3857 it->before = EINA_TRUE;
3858 _item_queue(wd, it);
3863 elm_genlist_clear(Evas_Object *obj)
3865 ELM_CHECK_WIDTYPE(obj, widtype);
3866 Widget_Data *wd = elm_widget_data_get(obj);
3868 if (wd->walking > 0)
3870 Elm_Genlist_Item *it;
3872 wd->clear_me = EINA_TRUE;
3873 EINA_INLIST_FOREACH(wd->items, it)
3875 it->delete_me = EINA_TRUE;
3879 evas_event_freeze(evas_object_evas_get(wd->obj));
3882 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3883 it->nocache = EINA_TRUE;
3884 it->highlighted = EINA_FALSE;
3886 if (wd->anchor_item == it)
3888 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3889 if (!wd->anchor_item)
3891 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3894 wd->items = eina_inlist_remove(wd->items, wd->items);
3895 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3896 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3897 elm_widget_item_pre_notify_del(it);
3898 if (it->realized) _item_unrealize(it, EINA_FALSE);
3899 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3900 it->itc->func.del((void *)it->base.data, it->base.widget);
3901 if (it->long_timer) ecore_timer_del(it->long_timer);
3902 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3903 elm_widget_item_del(it);
3905 wd->clear_me = EINA_FALSE;
3906 wd->anchor_item = NULL;
3909 Item_Block *itb = (Item_Block *)(wd->blocks);
3911 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3912 if (itb->items) eina_list_free(itb->items);
3917 ecore_job_del(wd->calc_job);
3918 wd->calc_job = NULL;
3920 if (wd->queue_idle_enterer)
3922 ecore_idle_enterer_del(wd->queue_idle_enterer);
3923 wd->queue_idle_enterer = NULL;
3925 if (wd->must_recalc_idler)
3927 ecore_idler_del(wd->must_recalc_idler);
3928 wd->must_recalc_idler = NULL;
3932 eina_list_free(wd->queue);
3937 eina_list_free(wd->selected);
3938 wd->selected = NULL;
3940 if (wd->reorder_move_animator)
3942 ecore_animator_del(wd->reorder_move_animator);
3943 wd->reorder_move_animator = NULL;
3945 wd->show_item = NULL;
3953 evas_object_del(wd->alpha_bg);
3954 wd->alpha_bg = NULL;
3958 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3959 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3962 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
3963 evas_event_thaw(evas_object_evas_get(wd->obj));
3964 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3968 elm_genlist_multi_select_set(Evas_Object *obj,
3971 ELM_CHECK_WIDTYPE(obj, widtype);
3972 Widget_Data *wd = elm_widget_data_get(obj);
3978 elm_genlist_multi_select_get(const Evas_Object *obj)
3980 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3981 Widget_Data *wd = elm_widget_data_get(obj);
3982 if (!wd) return EINA_FALSE;
3986 EAPI Elm_Genlist_Item *
3987 elm_genlist_selected_item_get(const Evas_Object *obj)
3989 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3990 Widget_Data *wd = elm_widget_data_get(obj);
3991 if (!wd) return NULL;
3992 if (wd->selected) return wd->selected->data;
3996 EAPI const Eina_List *
3997 elm_genlist_selected_items_get(const Evas_Object *obj)
3999 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4000 Widget_Data *wd = elm_widget_data_get(obj);
4001 if (!wd) return NULL;
4002 return wd->selected;
4006 elm_genlist_realized_items_get(const Evas_Object *obj)
4008 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4009 Widget_Data *wd = elm_widget_data_get(obj);
4010 Eina_List *list = NULL;
4012 Eina_Bool done = EINA_FALSE;
4013 if (!wd) return NULL;
4014 EINA_INLIST_FOREACH(wd->blocks, itb)
4019 Elm_Genlist_Item *it;
4022 EINA_LIST_FOREACH(itb->items, l, it)
4024 if (it->realized) list = eina_list_append(list, it);
4035 EAPI Elm_Genlist_Item *
4036 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4041 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4042 Widget_Data *wd = elm_widget_data_get(obj);
4043 Evas_Coord ox, oy, ow, oh;
4046 if (!wd) return NULL;
4047 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4049 EINA_INLIST_FOREACH(wd->blocks, itb)
4052 Elm_Genlist_Item *it;
4054 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4055 oy + itb->y - itb->wd->pan_y,
4056 itb->w, itb->h, x, y, 1, 1))
4058 EINA_LIST_FOREACH(itb->items, l, it)
4060 Evas_Coord itx, ity;
4062 itx = ox + itb->x + it->x - itb->wd->pan_x;
4063 ity = oy + itb->y + it->y - itb->wd->pan_y;
4064 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4068 if (y <= (ity + (it->h / 4))) *posret = -1;
4069 else if (y >= (ity + it->h - (it->h / 4)))
4075 lasty = ity + it->h;
4080 if (y > lasty) *posret = 1;
4086 EAPI Elm_Genlist_Item *
4087 elm_genlist_first_item_get(const Evas_Object *obj)
4089 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4090 Widget_Data *wd = elm_widget_data_get(obj);
4091 if (!wd) return NULL;
4092 if (!wd->items) return NULL;
4093 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4094 while ((it) && (it->delete_me))
4095 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4099 EAPI Elm_Genlist_Item *
4100 elm_genlist_last_item_get(const Evas_Object *obj)
4102 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4103 Widget_Data *wd = elm_widget_data_get(obj);
4104 if (!wd) return NULL;
4105 if (!wd->items) return NULL;
4106 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4107 while ((it) && (it->delete_me))
4108 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4112 EAPI Elm_Genlist_Item *
4113 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4115 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4118 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4119 if ((it) && (!it->delete_me)) break;
4121 return (Elm_Genlist_Item *)it;
4124 EAPI Elm_Genlist_Item *
4125 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4127 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4130 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4131 if ((it) && (!it->delete_me)) break;
4133 return (Elm_Genlist_Item *)it;
4137 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4139 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4140 return it->base.widget;
4143 EAPI Elm_Genlist_Item *
4144 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4146 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4151 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4153 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4154 Elm_Genlist_Item *it2;
4157 if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4158 _item_subitems_clear(it);
4161 if ((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4162 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4164 it->wd->expand_item = it;
4165 _item_flip_effect_show(it);
4166 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4167 it->wd->expand_item_end = y + h;
4171 it2 = elm_genlist_item_next_get(it2);
4173 } while (it2->expanded_depth > it->expanded_depth);
4175 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4177 it->wd->expand_item_gap = 0;
4179 evas_object_raise(it->wd->alpha_bg);
4180 evas_object_show(it->wd->alpha_bg);
4182 it->wd->start_time = current_time_get();
4183 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4186 _item_subitems_clear(it);
4191 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4194 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4195 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4197 if ((it->delete_me) || (it->disabled)) return;
4198 selected = !!selected;
4199 if (it->selected == selected) return;
4205 while (wd->selected)
4206 _item_unselect(wd->selected->data);
4208 _item_highlight(it);
4216 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4218 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4219 return it->selected;
4223 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4226 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4227 if (it->flags != ELM_GENLIST_ITEM_SUBITEMS) return;
4228 if (it->expanded == expanded) return;
4229 it->expanded = expanded;
4230 it->wd->expand_item = it;
4232 if (it->wd->effect_mode && !it->wd->alpha_bg)
4233 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4237 it->wd->auto_scrolled = EINA_FALSE;
4238 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4240 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4241 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4245 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4247 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4248 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4253 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4255 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4256 return it->expanded;
4260 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4262 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4263 return it->expanded_depth;
4267 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4270 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4273 if (it->disabled == disabled) return;
4274 if (it->delete_me) return;
4275 it->disabled = !!disabled;
4277 elm_genlist_item_selected_set(it, EINA_FALSE);
4282 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4284 edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
4288 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4290 edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
4292 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4293 elm_widget_disabled_set(obj, disabled);
4298 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4300 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4301 if (it->delete_me) return EINA_FALSE;
4302 return it->disabled;
4306 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4307 Eina_Bool display_only)
4309 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4310 if (it->display_only == display_only) return;
4311 if (it->delete_me) return;
4312 it->display_only = display_only;
4313 it->mincalcd = EINA_FALSE;
4314 it->updateme = EINA_TRUE;
4315 if (it->block) it->block->updateme = EINA_TRUE;
4316 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4317 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4321 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4323 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4324 if (it->delete_me) return EINA_FALSE;
4325 return it->display_only;
4329 elm_genlist_item_show(Elm_Genlist_Item *it)
4331 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4332 Evas_Coord gith = 0;
4333 if (it->delete_me) return;
4334 if ((it->queued) || (!it->mincalcd))
4336 it->wd->show_item = it;
4337 it->wd->bring_in = EINA_TRUE;
4338 it->showme = EINA_TRUE;
4341 if (it->wd->show_item)
4343 it->wd->show_item->showme = EINA_FALSE;
4344 it->wd->show_item = NULL;
4346 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4347 gith = it->group_item->h;
4348 elm_smart_scroller_child_region_show(it->wd->scr,
4349 it->x + it->block->x,
4350 it->y + it->block->y - gith,
4351 it->block->w, it->h);
4355 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4357 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4358 Evas_Coord gith = 0;
4359 if (it->delete_me) return;
4360 if ((it->queued) || (!it->mincalcd))
4362 it->wd->show_item = it;
4363 it->wd->bring_in = EINA_TRUE;
4364 it->showme = EINA_TRUE;
4367 if (it->wd->show_item)
4369 it->wd->show_item->showme = EINA_FALSE;
4370 it->wd->show_item = NULL;
4372 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4373 gith = it->group_item->h;
4374 elm_smart_scroller_region_bring_in(it->wd->scr,
4375 it->x + it->block->x,
4376 it->y + it->block->y - gith,
4377 it->block->w, it->h);
4381 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4383 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4385 Evas_Coord gith = 0;
4387 if (it->delete_me) return;
4388 if ((it->queued) || (!it->mincalcd))
4390 it->wd->show_item = it;
4391 it->wd->bring_in = EINA_TRUE;
4392 it->showme = EINA_TRUE;
4395 if (it->wd->show_item)
4397 it->wd->show_item->showme = EINA_FALSE;
4398 it->wd->show_item = NULL;
4400 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4401 if (it->group_item) gith = it->group_item->h;
4402 elm_smart_scroller_child_region_show(it->wd->scr,
4403 it->x + it->block->x,
4404 it->y + it->block->y - gith,
4409 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4411 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4413 Evas_Coord gith = 0;
4415 if (it->delete_me) return;
4416 if ((it->queued) || (!it->mincalcd))
4418 it->wd->show_item = it;
4419 it->wd->bring_in = EINA_TRUE;
4420 it->showme = EINA_TRUE;
4423 if (it->wd->show_item)
4425 it->wd->show_item->showme = EINA_FALSE;
4426 it->wd->show_item = NULL;
4428 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4429 if (it->group_item) gith = it->group_item->h;
4430 elm_smart_scroller_region_bring_in(it->wd->scr,
4431 it->x + it->block->x,
4432 it->y + it->block->y - gith,
4437 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4439 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4442 if (it->delete_me) return;
4443 if ((it->queued) || (!it->mincalcd))
4445 it->wd->show_item = it;
4446 it->wd->bring_in = EINA_TRUE;
4447 it->showme = EINA_TRUE;
4450 if (it->wd->show_item)
4452 it->wd->show_item->showme = EINA_FALSE;
4453 it->wd->show_item = NULL;
4455 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4456 elm_smart_scroller_child_region_show(it->wd->scr,
4457 it->x + it->block->x,
4458 it->y + it->block->y - oh / 2 +
4459 it->h / 2, it->block->w, oh);
4463 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4465 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4468 if (it->delete_me) return;
4469 if ((it->queued) || (!it->mincalcd))
4471 it->wd->show_item = it;
4472 it->wd->bring_in = EINA_TRUE;
4473 it->showme = EINA_TRUE;
4476 if (it->wd->show_item)
4478 it->wd->show_item->showme = EINA_FALSE;
4479 it->wd->show_item = NULL;
4481 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4482 elm_smart_scroller_region_bring_in(it->wd->scr,
4483 it->x + it->block->x,
4484 it->y + it->block->y - oh / 2 + it->h / 2,
4489 elm_genlist_item_del(Elm_Genlist_Item *it)
4491 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4492 if ((it->relcount > 0) || (it->walking > 0))
4494 elm_widget_item_pre_notify_del(it);
4495 elm_genlist_item_subitems_clear(it);
4496 it->delete_me = EINA_TRUE;
4497 if (it->wd->show_item == it) it->wd->show_item = NULL;
4499 it->wd->selected = eina_list_remove(it->wd->selected,
4503 if (it->realized) _item_unrealize(it, EINA_FALSE);
4504 it->block->changed = EINA_TRUE;
4505 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4506 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4508 if (it->itc->func.del)
4509 it->itc->func.del((void *)it->base.data, it->base.widget);
4516 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4519 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4520 elm_widget_item_data_set(it, data);
4521 elm_genlist_item_update(it);
4525 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4527 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4528 return elm_widget_item_data_get(it);
4532 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4535 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4536 EINA_LIST_FREE(it->icon_objs, icon)
4538 elm_widget_sub_object_del(it->base.widget, icon);
4539 evas_object_smart_member_del(icon);
4540 evas_object_hide(icon);
4544 EAPI const Evas_Object *
4545 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4547 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4548 return it->base.view;
4552 elm_genlist_item_update(Elm_Genlist_Item *it)
4554 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4555 if (!it->block) return;
4556 if (it->delete_me) return;
4557 it->mincalcd = EINA_FALSE;
4558 it->updateme = EINA_TRUE;
4559 it->block->updateme = EINA_TRUE;
4560 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4561 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4562 it->defer_unrealize = EINA_FALSE;
4566 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4567 const Elm_Genlist_Item_Class *itc)
4569 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4570 if (!it->block) return;
4571 EINA_SAFETY_ON_NULL_RETURN(itc);
4572 if (it->delete_me) return;
4574 it->nocache = EINA_TRUE;
4575 elm_genlist_item_update(it);
4578 EAPI const Elm_Genlist_Item_Class *
4579 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4581 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4582 if (it->delete_me) return NULL;
4585 static Evas_Object *
4586 _elm_genlist_item_label_create(void *data,
4587 Evas_Object *obj __UNUSED__,
4588 Evas_Object *tooltip,
4589 void *item __UNUSED__)
4591 Evas_Object *label = elm_label_add(tooltip);
4594 elm_object_style_set(label, "tooltip");
4595 elm_object_text_set(label, data);
4600 _elm_genlist_item_label_del_cb(void *data,
4601 Evas_Object *obj __UNUSED__,
4602 void *event_info __UNUSED__)
4604 eina_stringshare_del(data);
4608 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4611 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4612 text = eina_stringshare_add(text);
4613 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4615 _elm_genlist_item_label_del_cb);
4619 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4620 Elm_Tooltip_Item_Content_Cb func,
4622 Evas_Smart_Cb del_cb)
4624 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4626 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4629 if (item->tooltip.del_cb)
4630 item->tooltip.del_cb((void *)item->tooltip.data,
4631 item->base.widget, item);
4633 item->tooltip.content_cb = func;
4634 item->tooltip.data = data;
4635 item->tooltip.del_cb = del_cb;
4637 if (item->base.view)
4639 elm_widget_item_tooltip_content_cb_set(item,
4640 item->tooltip.content_cb,
4641 item->tooltip.data, NULL);
4642 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4648 if (del_cb) del_cb((void *)data, NULL, NULL);
4652 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4654 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4655 if ((item->base.view) && (item->tooltip.content_cb))
4656 elm_widget_item_tooltip_unset(item);
4658 if (item->tooltip.del_cb)
4659 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4660 item->tooltip.del_cb = NULL;
4661 item->tooltip.content_cb = NULL;
4662 item->tooltip.data = NULL;
4663 if (item->tooltip.style)
4664 elm_genlist_item_tooltip_style_set(item, NULL);
4668 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4671 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4672 eina_stringshare_replace(&item->tooltip.style, style);
4673 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4677 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4679 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4680 return item->tooltip.style;
4684 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4687 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4688 eina_stringshare_replace(&item->mouse_cursor, cursor);
4689 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4693 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4695 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4696 return elm_widget_item_cursor_get(item);
4700 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4702 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4703 if (!item->mouse_cursor)
4706 if (item->base.view)
4707 elm_widget_item_cursor_unset(item);
4709 eina_stringshare_del(item->mouse_cursor);
4710 item->mouse_cursor = NULL;
4714 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4717 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4718 elm_widget_item_cursor_style_set(item, style);
4722 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4724 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4725 return elm_widget_item_cursor_style_get(item);
4729 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4730 Eina_Bool engine_only)
4732 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4733 elm_widget_item_cursor_engine_only_set(item, engine_only);
4737 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4739 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4740 return elm_widget_item_cursor_engine_only_get(item);
4744 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4747 ELM_CHECK_WIDTYPE(obj, widtype);
4748 Widget_Data *wd = elm_widget_data_get(obj);
4750 if (wd->mode == mode) return;
4756 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4758 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4759 Widget_Data *wd = elm_widget_data_get(obj);
4760 if (!wd) return ELM_LIST_LAST;
4765 elm_genlist_always_select_mode_set(Evas_Object *obj,
4766 Eina_Bool always_select)
4768 ELM_CHECK_WIDTYPE(obj, widtype);
4769 Widget_Data *wd = elm_widget_data_get(obj);
4771 wd->always_select = always_select;
4775 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4777 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4778 Widget_Data *wd = elm_widget_data_get(obj);
4779 if (!wd) return EINA_FALSE;
4780 return wd->always_select;
4784 elm_genlist_no_select_mode_set(Evas_Object *obj,
4785 Eina_Bool no_select)
4787 ELM_CHECK_WIDTYPE(obj, widtype);
4788 Widget_Data *wd = elm_widget_data_get(obj);
4790 wd->no_select = no_select;
4794 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4796 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4797 Widget_Data *wd = elm_widget_data_get(obj);
4798 if (!wd) return EINA_FALSE;
4799 return wd->no_select;
4803 elm_genlist_compress_mode_set(Evas_Object *obj,
4806 ELM_CHECK_WIDTYPE(obj, widtype);
4807 Widget_Data *wd = elm_widget_data_get(obj);
4809 wd->compress = compress;
4813 elm_genlist_compress_mode_get(const Evas_Object *obj)
4815 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4816 Widget_Data *wd = elm_widget_data_get(obj);
4817 if (!wd) return EINA_FALSE;
4818 return wd->compress;
4822 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4823 Eina_Bool height_for_width)
4825 ELM_CHECK_WIDTYPE(obj, widtype);
4826 Widget_Data *wd = elm_widget_data_get(obj);
4828 wd->height_for_width = !!height_for_width;
4829 if (wd->height_for_width)
4831 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4832 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4837 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4839 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4840 Widget_Data *wd = elm_widget_data_get(obj);
4841 if (!wd) return EINA_FALSE;
4842 return wd->height_for_width;
4846 elm_genlist_bounce_set(Evas_Object *obj,
4850 ELM_CHECK_WIDTYPE(obj, widtype);
4851 Widget_Data *wd = elm_widget_data_get(obj);
4853 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4857 elm_genlist_bounce_get(const Evas_Object *obj,
4858 Eina_Bool *h_bounce,
4859 Eina_Bool *v_bounce)
4861 ELM_CHECK_WIDTYPE(obj, widtype);
4862 Widget_Data *wd = elm_widget_data_get(obj);
4864 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
4868 elm_genlist_homogeneous_set(Evas_Object *obj,
4869 Eina_Bool homogeneous)
4871 ELM_CHECK_WIDTYPE(obj, widtype);
4872 Widget_Data *wd = elm_widget_data_get(obj);
4874 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4875 wd->homogeneous = homogeneous;
4879 elm_genlist_homogeneous_get(const Evas_Object *obj)
4881 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4882 Widget_Data *wd = elm_widget_data_get(obj);
4883 if (!wd) return EINA_FALSE;
4884 return wd->homogeneous;
4888 elm_genlist_block_count_set(Evas_Object *obj,
4891 ELM_CHECK_WIDTYPE(obj, widtype);
4892 Widget_Data *wd = elm_widget_data_get(obj);
4894 wd->max_items_per_block = n;
4895 wd->item_cache_max = wd->max_items_per_block * 2;
4896 _item_cache_clean(wd);
4900 elm_genlist_block_count_get(const Evas_Object *obj)
4902 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4903 Widget_Data *wd = elm_widget_data_get(obj);
4905 return wd->max_items_per_block;
4909 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4912 ELM_CHECK_WIDTYPE(obj, widtype);
4913 Widget_Data *wd = elm_widget_data_get(obj);
4915 wd->longpress_timeout = timeout;
4919 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4921 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4922 Widget_Data *wd = elm_widget_data_get(obj);
4924 return wd->longpress_timeout;
4928 elm_genlist_scroller_policy_set(Evas_Object *obj,
4929 Elm_Scroller_Policy policy_h,
4930 Elm_Scroller_Policy policy_v)
4932 ELM_CHECK_WIDTYPE(obj, widtype);
4933 Widget_Data *wd = elm_widget_data_get(obj);
4934 if ((!wd) || (!wd->scr)) return;
4935 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4936 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4938 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4942 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4943 Elm_Scroller_Policy *policy_h,
4944 Elm_Scroller_Policy *policy_v)
4946 ELM_CHECK_WIDTYPE(obj, widtype);
4947 Widget_Data *wd = elm_widget_data_get(obj);
4948 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4949 if ((!wd) || (!wd->scr)) return;
4950 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4951 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4952 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
4956 elm_genlist_realized_items_update(Evas_Object *obj)
4958 ELM_CHECK_WIDTYPE(obj, widtype);
4960 Eina_List *list, *l;
4961 Elm_Genlist_Item *it;
4963 list = elm_genlist_realized_items_get(obj);
4964 EINA_LIST_FOREACH(list, l, it)
4965 elm_genlist_item_update(it);
4969 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
4970 const char *mode_type,
4973 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4974 Widget_Data *wd = it->wd;
4976 Elm_Genlist_Item *it2;
4979 if (!mode_type) return;
4980 if ((it->delete_me) || (it->disabled)) return;
4981 if (wd->edit_mode) return;
4983 if ((wd->mode_item == it) &&
4984 (!strcmp(mode_type, wd->mode_type)) &&
4987 if (!it->itc->mode_item_style) return;
4991 EINA_LIST_FOREACH(wd->selected, l, it2)
4993 elm_genlist_item_selected_set(it2, EINA_FALSE);
4997 it2 = elm_genlist_selected_item_get(wd->obj);
4998 if ((it2) && (it2->realized))
4999 elm_genlist_item_selected_set(it2, EINA_FALSE);
5002 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5004 ((it == wd->mode_item) && (!mode_set)))
5005 _item_mode_unset(wd);
5007 eina_stringshare_replace(&wd->mode_type, mode_type);
5008 if (mode_set) _item_mode_set(it);
5012 elm_genlist_mode_get(const Evas_Object *obj)
5014 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5015 Widget_Data *wd = elm_widget_data_get(obj);
5016 if (!wd) return NULL;
5017 return wd->mode_type;
5020 EAPI const Elm_Genlist_Item *
5021 elm_genlist_mode_item_get(const Evas_Object *obj)
5023 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5024 Widget_Data *wd = elm_widget_data_get(obj);
5025 if (!wd) return NULL;
5026 return wd->mode_item;
5030 elm_genlist_reorder_mode_set(Evas_Object *obj,
5031 Eina_Bool reorder_mode)
5033 ELM_CHECK_WIDTYPE(obj, widtype);
5034 Widget_Data *wd = elm_widget_data_get(obj);
5036 wd->reorder_mode = reorder_mode;
5040 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5042 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5043 Widget_Data *wd = elm_widget_data_get(obj);
5044 if (!wd) return EINA_FALSE;
5045 return wd->reorder_mode;
5049 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
5055 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
5061 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5063 ELM_CHECK_WIDTYPE(obj, widtype);
5064 Widget_Data *wd = elm_widget_data_get(obj);
5066 wd->effect_mode = emode;
5067 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5068 // evas_object_resize(wd->point_rect, 10, 25);
5069 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5070 // evas_object_show(wd->point_rect);
5071 // evas_object_hide(wd->point_rect);
5075 _create_tray_alpha_bg(const Evas_Object *obj)
5077 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5078 Widget_Data *wd = elm_widget_data_get(obj);
5079 if (!wd) return NULL;
5081 Evas_Object *bg = NULL;
5082 Evas_Coord ox, oy, ow, oh;
5084 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5085 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5086 evas_object_color_set(bg,0,0,0,0);
5087 evas_object_resize(bg , ow, oh);
5088 evas_object_move(bg , ox, oy);
5089 evas_object_show(bg);
5090 evas_object_hide(bg);
5097 struct timeval timev;
5099 gettimeofday(&timev, NULL);
5100 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5103 // added for item moving animation.
5105 _item_moving_effect_timer_cb(void *data)
5107 Widget_Data *wd = data;
5108 if (!wd) return EINA_FALSE;
5110 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5111 Elm_Genlist_Item *it = NULL, *it2;
5113 double time = 0.3, t;
5115 Eina_Bool check, end = EINA_FALSE;
5118 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5120 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5121 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5122 if (t > time) end = EINA_TRUE;
5124 it2 = elm_genlist_item_next_get(wd->expand_item);
5127 if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5128 it2 = elm_genlist_item_next_get(it2);
5133 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5134 dy = it2->scrl_y - it2->old_scrl_y;
5135 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5136 dy = wd->expand_item_gap;
5140 y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5149 EINA_INLIST_FOREACH(wd->blocks, itb)
5152 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5153 itb->y - wd->pan_y + oy,
5155 cvx, cvy, cvw, cvh))
5157 EINA_LIST_FOREACH(itb->items, l, it)
5159 if (it == it2) check = EINA_TRUE;
5160 if (!check) continue;
5162 if (!it->old_scrl_y)
5163 it->old_scrl_y = it->scrl_y;
5164 if (it->old_scrl_y + y < oy + oh)
5166 if (!it->realized) _item_realize(it, in, 0);
5168 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5169 it->old_scrl_y = it->scrl_y - y;
5172 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5173 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5175 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5178 evas_object_resize(it->base.view, it->w, it->h);
5179 evas_object_move(it->base.view, it->scrl_x, it->old_scrl_y + y);
5180 evas_object_show(it->base.view);
5181 evas_object_raise(it->base.view);
5184 if (it->group_item) evas_object_raise(it->group_item->base.view);
5190 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5192 it = elm_genlist_item_prev_get(it2);
5195 if (it->expanded_depth <= it2->expanded_depth) break;
5196 if ((it->scrl_y < it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5198 if (!it->effect_done)
5200 edje_object_signal_emit(it->base.view, "flip_item", "");
5201 evas_object_show(it->base.view);
5202 it->effect_done = EINA_TRUE;
5205 it = elm_genlist_item_prev_get(it);
5208 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5210 it = elm_genlist_item_prev_get(it2);
5213 if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5215 if (!it->effect_done)
5217 edje_object_signal_emit(it->base.view, "elm,state,hide", "");
5218 it->effect_done = EINA_TRUE;
5223 it = elm_genlist_item_prev_get(it);
5226 if (wd->calc_job) ecore_job_del(wd->calc_job);
5227 wd->calc_job = ecore_job_add(_calc_job, wd);
5232 int expand_order = 0;
5233 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5237 it = elm_genlist_item_next_get(it);
5239 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5243 if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
5244 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5246 if (!it->effect_done)
5248 if (t >= (((expand_order - 1) * time) / expand_num))
5250 edje_object_signal_emit(it->base.view, "flip_item", "");
5251 evas_object_show(it->base.view);
5252 it->effect_done = EINA_TRUE;
5256 it = elm_genlist_item_next_get(it);
5262 if (wd->item_moving_effect_timer)
5264 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5265 _item_subitems_clear(wd->expand_item);
5266 EINA_INLIST_FOREACH(wd->blocks, itb)
5268 EINA_LIST_FOREACH(itb->items, l, it)
5270 it->effect_done = EINA_TRUE;
5271 it->old_scrl_y = it->scrl_y;
5275 wd->item_moving_effect_timer = NULL;
5277 _item_auto_scroll(wd);
5278 evas_object_lower(wd->alpha_bg);
5279 evas_object_hide(wd->alpha_bg);
5280 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5281 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5283 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5284 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5285 return ECORE_CALLBACK_CANCEL;
5287 return ECORE_CALLBACK_RENEW;
5291 _emit_contract(Elm_Genlist_Item *it)
5293 Elm_Genlist_Item *it2;
5296 // printf("%p is emited contract\n", it);
5297 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5298 it->effect_done = EINA_FALSE;
5300 EINA_LIST_FOREACH(it->items, l, it2)
5302 _emit_contract(it2);
5305 // added for item moving animation.
5307 _item_flip_effect_show(Elm_Genlist_Item *it)
5309 Elm_Genlist_Item *it2;
5311 Widget_Data *wd = it->wd;
5312 Eina_Bool check = EINA_FALSE;
5314 it2 = elm_genlist_item_next_get(it);
5317 if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5318 it2 = elm_genlist_item_next_get(it2);
5320 EINA_LIST_FOREACH(it->items, l, it2)
5322 if (it2->parent && it == it2->parent)
5324 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5325 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5326 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5327 _emit_contract(it2);
5331 return ECORE_CALLBACK_CANCEL;
5336 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5338 printf("!!! NOW FIXING \n");
5343 * Set pinch zoom mode
5345 * @param obj The genlist object
5347 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5352 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5354 printf("!!! NOW FIXING \n");
5358 * Get pinch zoom mode
5360 * @param obj The genlist object
5361 * @return The pinch mode
5362 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5367 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
5369 printf("!!! NOW FIXING \n");
5374 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5376 printf("!!! NOW FIXING \n");
5380 ////////////////////////////////////////////////////////////////////////
5382 ////////////////////////////////////////////////////////////////////////
5385 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5387 if (!it->wd->edit_mode) return;
5388 evas_object_resize(it->edit_obj,it->w, it->h);
5389 evas_object_move(it->edit_obj, itx, ity);
5393 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5395 if ((it->effect_item_realized) || (it->delete_me)) return;
5399 _mode_finished_signal_cb(it, (Evas_Object *)elm_genlist_item_object_get(it), NULL, NULL);
5401 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
5402 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
5403 _elm_config->scale);
5404 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5405 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
5407 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5408 else strncpy(buf, "item", sizeof(buf));
5409 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5411 strncat(buf, "/", sizeof(buf) - strlen(buf));
5413 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5415 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
5416 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
5420 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget));
5423 if (it->wd->reorder_mode)
5425 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
5426 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
5428 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
5429 else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
5431 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
5432 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
5435 if ((it->wd->edit_mode))
5437 if (it->itc->func.icon_get)
5442 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5443 EINA_LIST_FOREACH(it->icons, l, key)
5445 Evas_Object *ic = it->itc->func.icon_get
5446 ((void *)it->base.data, it->base.widget, l->data);
5450 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5451 edje_object_part_swallow(it->edit_obj, key, ic);
5452 evas_object_show(ic);
5453 elm_widget_sub_object_add(it->base.widget, ic);
5455 elm_widget_disabled_set(ic, EINA_TRUE);
5460 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
5461 _effect_item_controls(it,it->scrl_x, it->scrl_y);
5462 evas_object_show(it->edit_obj);
5464 it->effect_item_realized = EINA_TRUE;
5465 it->want_unrealize = EINA_FALSE;
5469 _effect_item_unrealize(Elm_Genlist_Item *it)
5473 if (!it->effect_item_realized) return;
5474 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5476 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
5477 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
5478 edje_object_message_signal_process(it->edit_obj);
5479 edje_object_part_unswallow(it->edit_obj, it->base.view);
5480 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
5481 elm_widget_sub_object_add(it->base.widget, it->base.view);
5482 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5483 // _item_cache_add(it);
5484 evas_object_del(it->edit_obj);
5485 it->edit_obj = NULL;
5486 EINA_LIST_FREE(it->edit_icon_objs, icon)
5487 evas_object_del(icon);
5489 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5490 it->effect_item_realized = EINA_FALSE;
5494 * Get Genlist edit mode
5496 * @param obj The genlist object
5497 * @return The edit mode status
5498 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5503 elm_genlist_edit_mode_get(const Evas_Object *obj)
5505 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5506 Widget_Data *wd = elm_widget_data_get(obj);
5507 if (!wd) return EINA_FALSE;
5509 if (wd->edit_mode) return EINA_TRUE;
5510 else return EINA_FALSE;
5514 * Set Genlist edit mode
5516 * This sets Genlist edit mode.
5518 * @param obj The Genlist object
5519 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5520 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5525 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5527 ELM_CHECK_WIDTYPE(obj, widtype);
5531 Elm_Genlist_Item *it;
5533 Widget_Data *wd = elm_widget_data_get(obj);
5535 if (wd->edit_mode == edit_mode) return;
5537 wd->edit_mode = edit_mode;
5540 EINA_INLIST_FOREACH(wd->blocks, itb)
5544 EINA_LIST_FOREACH(itb->items, l, it)
5546 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5548 _effect_item_unrealize(it);
5553 _item_cache_zero(wd);
5558 EINA_INLIST_FOREACH(wd->blocks, itb)
5562 EINA_LIST_FOREACH(itb->items, l, it)
5564 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5566 if(it->selected) _item_unselect(it);
5567 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
5574 if (wd->calc_job) ecore_job_del(wd->calc_job);
5575 wd->calc_job = ecore_job_add(_calc_job, wd);
5579 * Set a given item's rename mode
5581 * This renames the item's label from genlist
5583 * @param it The item
5584 * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
5589 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
5595 _item_unrealize(it, EINA_FALSE);
5596 it->renamed = EINA_TRUE;
5597 it->wd->rename_it = it;
5598 it->nocache = EINA_TRUE;
5599 if (it->selected) _item_unselect(it);
5601 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5602 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5608 it->renamed = EINA_FALSE;
5609 it->nocache = EINA_TRUE;
5610 it->wd->rename_it = NULL;
5611 _item_cache_zero(it->wd);
5612 elm_genlist_item_update(it);
5618 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
5620 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5621 return item->renamed;