3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
6 #include "els_scroller.h"
9 #define MAX_ITEMS_PER_BLOCK 32
10 #define REORDER_EFFECT_TIME 0.5
12 typedef struct _Widget_Data Widget_Data;
13 typedef struct _Item_Block Item_Block;
14 typedef struct _Pan Pan;
15 typedef struct _Item_Cache Item_Cache;
16 typedef enum _Elm_Genlist_Item_Move_effect_Mode
18 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
19 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
20 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
21 ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE = (1 << 2),
22 } Elm_Genlist_Item_Move_effect_Mode;
26 Evas_Object *obj, *scr, *pan_smart;
27 Eina_Inlist *items, *blocks;
28 Eina_List *group_items;
30 Evas_Coord pan_x, pan_y, old_pan_y, w, h, minw, minh, realminw, prev_viewport_w;
31 Ecore_Job *calc_job, *update_job;
32 Ecore_Idle_Enterer *queue_idle_enterer;
33 Ecore_Idler *must_recalc_idler;
34 Eina_List *queue, *selected;
35 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item, *reorder_it, *reorder_rel, *expand_item;
36 Eina_Inlist *item_cache;
37 Evas_Coord anchor_y, reorder_start_y;
39 Ecore_Timer *multi_timer, *scr_hold_timer;
40 Ecore_Animator *reorder_move_animator;
41 const char *mode_type;
42 unsigned int start_time;
43 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
44 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
45 Eina_Bool mouse_down : 1;
46 Eina_Bool multi_down : 1;
47 Eina_Bool multi_timeout : 1;
48 Eina_Bool multitouched : 1;
49 Eina_Bool on_hold : 1;
51 Eina_Bool always_select : 1;
52 Eina_Bool longpressed : 1;
53 Eina_Bool wasselected : 1;
54 Eina_Bool no_select : 1;
55 Eina_Bool bring_in : 1;
56 Eina_Bool compress : 1;
57 Eina_Bool height_for_width : 1;
58 Eina_Bool pan_resize : 1;
59 Eina_Bool homogeneous : 1;
60 Eina_Bool clear_me : 1;
62 Eina_Bool reorder_mode : 1;
63 Eina_Bool reorder_pan_move : 1;
67 } history[SWIPE_MOVES];
76 int group_item_height;
77 int max_items_per_block;
78 double longpress_timeout;
81 Eina_Bool reorder_deleted : 1;
82 Eina_Bool effect_mode : 1;
83 Eina_Bool auto_scrolled : 1;
84 Eina_Bool pan_changed : 1;
85 Eina_Bool drag_started : 1;
87 Ecore_Animator *item_moving_effect_timer;
88 Evas_Object *alpha_bg;
89 Evas_Coord expand_item_end;
90 Evas_Coord expand_item_gap;
92 Ecore_Job *changed_job;
93 Elm_Genlist_Item *rename_it;
104 Evas_Coord x, y, w, h, minw, minh;
105 Eina_Bool want_unrealize : 1;
106 Eina_Bool realized : 1;
107 Eina_Bool changed : 1;
108 Eina_Bool updateme : 1;
109 Eina_Bool changeme : 1;
110 Eina_Bool showme : 1;
111 Eina_Bool must_recalc : 1;
114 struct _Elm_Genlist_Item
116 Elm_Widget_Item base;
121 Evas_Coord x, y, w, h, minw, minh;
122 const Elm_Genlist_Item_Class *itc;
123 Elm_Genlist_Item *parent;
124 Elm_Genlist_Item *group_item;
125 Elm_Genlist_Item_Flags flags;
133 Eina_List *labels, *icons, *states, *icon_objs;
134 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
135 Ecore_Timer *long_timer;
136 Ecore_Timer *swipe_timer;
138 Evas_Coord scrl_x, scrl_y;
140 Elm_Genlist_Item *rel;
141 Evas_Object *mode_view;
146 Elm_Tooltip_Item_Content_Cb content_cb;
147 Evas_Smart_Cb del_cb;
151 const char *mouse_cursor;
158 Eina_Bool before : 1;
160 Eina_Bool want_unrealize : 1;
161 Eina_Bool want_realize : 1;
162 Eina_Bool realized : 1;
163 Eina_Bool selected : 1;
164 Eina_Bool highlighted : 1;
165 Eina_Bool expanded : 1;
166 Eina_Bool disabled : 1;
167 Eina_Bool display_only : 1;
168 Eina_Bool mincalcd : 1;
169 Eina_Bool queued : 1;
170 Eina_Bool showme : 1;
171 Eina_Bool delete_me : 1;
173 Eina_Bool dragging : 1;
174 Eina_Bool updateme : 1;
175 Eina_Bool nocache : 1;
176 Eina_Bool move_effect_enabled : 1;
177 Eina_Bool defer_unrealize : 1;
180 Eina_Bool effect_done : 1;
181 Eina_Bool reordering : 1;
182 Eina_Bool renamed : 1;
183 Eina_Bool effect_item_realized : 1;
184 Eina_List *edit_icon_objs;
185 Evas_Object *edit_obj;
187 Ecore_Animator *item_moving_effect_timer;
188 Evas_Coord old_scrl_y;
195 Evas_Object *base_view, *spacer;
197 const char *item_style; // it->itc->item_style
198 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
199 Eina_Bool compress : 1; // it->wd->compress
200 Eina_Bool odd : 1; // in & 0x1
202 Eina_Bool selected : 1; // it->selected
203 Eina_Bool disabled : 1; // it->disabled
204 Eina_Bool expanded : 1; // it->expanded
207 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
208 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
212 Evas_Object_Smart_Clipped_Data __clipped_data;
214 Ecore_Job *resize_job;
217 static const char *widtype = NULL;
218 static void _item_cache_zero(Widget_Data *wd);
219 static void _del_hook(Evas_Object *obj);
220 static void _mirrored_set(Evas_Object *obj,
222 static void _theme_hook(Evas_Object *obj);
223 static void _show_region_hook(void *data,
225 static void _sizing_eval(Evas_Object *obj);
226 static void _item_realize(Elm_Genlist_Item *it,
229 static void _item_unrealize(Elm_Genlist_Item *it,
231 static void _item_block_unrealize(Item_Block *itb);
232 static void _calc_job(void *data);
233 static void _on_focus_hook(void *data,
235 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
236 static void _changed_job(void *data);
237 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
238 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
239 static Eina_Bool _item_single_select_up(Widget_Data *wd);
240 static Eina_Bool _item_single_select_down(Widget_Data *wd);
241 static Eina_Bool _event_hook(Evas_Object *obj,
243 Evas_Callback_Type type,
245 static void _signal_emit_hook(Evas_Object *obj,
246 const char *emission,
248 static Eina_Bool _deselect_all_items(Widget_Data *wd);
249 static void _pan_calculate(Evas_Object *obj);
250 static void _pan_max_get(Evas_Object *obj,
253 static void _item_position(Elm_Genlist_Item *it,
257 static void _mode_item_realize(Elm_Genlist_Item *it);
258 static void _mode_item_unrealize(Elm_Genlist_Item *it);
259 static void _item_mode_set(Elm_Genlist_Item *it);
260 static void _item_mode_unset(Widget_Data *wd);
261 static void _group_items_recalc(void *data);
262 static void _item_move_after(Elm_Genlist_Item *it,
263 Elm_Genlist_Item *after);
264 static void _item_move_before(Elm_Genlist_Item *it,
265 Elm_Genlist_Item *before);
267 // TODO : refactoring
268 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
269 static unsigned int current_time_get();
270 static Eina_Bool _item_moving_effect_timer_cb(void *data);
271 static int _item_flip_effect_show(Elm_Genlist_Item *it);
272 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
273 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
274 static void _effect_item_unrealize(Elm_Genlist_Item *it);
275 static void _item_auto_scroll(void *data);
277 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
279 static const char SIG_ACTIVATED[] = "activated";
280 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
281 static const char SIG_SELECTED[] = "selected";
282 static const char SIG_UNSELECTED[] = "unselected";
283 static const char SIG_EXPANDED[] = "expanded";
284 static const char SIG_CONTRACTED[] = "contracted";
285 static const char SIG_EXPAND_REQUEST[] = "expand,request";
286 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
287 static const char SIG_REALIZED[] = "realized";
288 static const char SIG_UNREALIZED[] = "unrealized";
289 static const char SIG_DRAG_START_UP[] = "drag,start,up";
290 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
291 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
292 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
293 static const char SIG_DRAG_STOP[] = "drag,stop";
294 static const char SIG_DRAG[] = "drag";
295 static const char SIG_LONGPRESSED[] = "longpressed";
296 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
297 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
298 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
299 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
300 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
301 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
302 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
303 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
304 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
305 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
306 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
307 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
308 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
309 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
310 static const char SIG_SWIPE[] = "swipe";
312 static const Evas_Smart_Cb_Description _signals[] = {
313 {SIG_CLICKED_DOUBLE, ""},
316 {SIG_UNSELECTED, ""},
318 {SIG_CONTRACTED, ""},
319 {SIG_EXPAND_REQUEST, ""},
320 {SIG_CONTRACT_REQUEST, ""},
322 {SIG_UNREALIZED, ""},
323 {SIG_DRAG_START_UP, ""},
324 {SIG_DRAG_START_DOWN, ""},
325 {SIG_DRAG_START_LEFT, ""},
326 {SIG_DRAG_START_RIGHT, ""},
329 {SIG_LONGPRESSED, ""},
330 {SIG_SCROLL_ANIM_START, ""},
331 {SIG_SCROLL_ANIM_STOP, ""},
332 {SIG_SCROLL_DRAG_START, ""},
333 {SIG_SCROLL_DRAG_STOP, ""},
334 {SIG_SCROLL_EDGE_TOP, ""},
335 {SIG_SCROLL_EDGE_BOTTOM, ""},
336 {SIG_SCROLL_EDGE_LEFT, ""},
337 {SIG_SCROLL_EDGE_RIGHT, ""},
338 {SIG_MULTI_SWIPE_LEFT, ""},
339 {SIG_MULTI_SWIPE_RIGHT, ""},
340 {SIG_MULTI_SWIPE_UP, ""},
341 {SIG_MULTI_SWIPE_DOWN, ""},
342 {SIG_MULTI_PINCH_OUT, ""},
343 {SIG_MULTI_PINCH_IN, ""},
349 _event_hook(Evas_Object *obj,
350 Evas_Object *src __UNUSED__,
351 Evas_Callback_Type type,
354 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
355 Evas_Event_Key_Down *ev = event_info;
356 Widget_Data *wd = elm_widget_data_get(obj);
357 Evas_Coord pan_max_x = 0, pan_max_y = 0;
358 if (!wd) return EINA_FALSE;
359 if (!wd->items) return EINA_FALSE;
360 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
361 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
363 Elm_Genlist_Item *it = NULL;
366 Evas_Coord step_x = 0;
367 Evas_Coord step_y = 0;
370 Evas_Coord page_x = 0;
371 Evas_Coord page_y = 0;
373 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
374 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
375 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
376 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
378 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
382 else if ((!strcmp(ev->keyname, "Right")) ||
383 (!strcmp(ev->keyname, "KP_Right")))
387 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
389 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
390 (_item_multi_select_up(wd)))
391 || (_item_single_select_up(wd)))
393 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
399 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
401 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
402 (_item_multi_select_down(wd)))
403 || (_item_single_select_down(wd)))
405 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
411 else if ((!strcmp(ev->keyname, "Home")) ||
412 (!strcmp(ev->keyname, "KP_Home")))
414 it = elm_genlist_first_item_get(obj);
415 elm_genlist_item_bring_in(it);
416 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
419 else if ((!strcmp(ev->keyname, "End")) ||
420 (!strcmp(ev->keyname, "KP_End")))
422 it = elm_genlist_last_item_get(obj);
423 elm_genlist_item_bring_in(it);
424 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
427 else if ((!strcmp(ev->keyname, "Prior")) ||
428 (!strcmp(ev->keyname, "KP_Prior")))
431 y -= -(page_y * v_h) / 100;
435 else if ((!strcmp(ev->keyname, "Next")) ||
436 (!strcmp(ev->keyname, "KP_Next")))
439 y += -(page_y * v_h) / 100;
443 else if (((!strcmp(ev->keyname, "Return")) ||
444 (!strcmp(ev->keyname, "KP_Enter")) ||
445 (!strcmp(ev->keyname, "space")))
446 && (!wd->multi) && (wd->selected))
448 it = elm_genlist_selected_item_get(obj);
449 elm_genlist_item_expanded_set(it,
450 !elm_genlist_item_expanded_get(it));
451 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
453 else if (!strcmp(ev->keyname, "Escape"))
455 if (!_deselect_all_items(wd)) return EINA_FALSE;
456 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
459 else return EINA_FALSE;
461 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
462 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
464 if (x > pan_max_x) x = pan_max_x;
466 if (y > pan_max_y) y = pan_max_y;
467 elm_smart_scroller_child_pos_set(wd->scr, x, y);
472 _deselect_all_items(Widget_Data *wd)
474 if (!wd->selected) return EINA_FALSE;
476 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
482 _item_multi_select_up(Widget_Data *wd)
484 if (!wd->selected) return EINA_FALSE;
485 if (!wd->multi) return EINA_FALSE;
487 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
488 if (!prev) return EINA_TRUE;
490 if (elm_genlist_item_selected_get(prev))
492 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
493 wd->last_selected_item = prev;
494 elm_genlist_item_show(wd->last_selected_item);
498 elm_genlist_item_selected_set(prev, EINA_TRUE);
499 elm_genlist_item_show(prev);
505 _item_multi_select_down(Widget_Data *wd)
507 if (!wd->selected) return EINA_FALSE;
508 if (!wd->multi) return EINA_FALSE;
510 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
511 if (!next) return EINA_TRUE;
513 if (elm_genlist_item_selected_get(next))
515 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
516 wd->last_selected_item = next;
517 elm_genlist_item_show(wd->last_selected_item);
521 elm_genlist_item_selected_set(next, EINA_TRUE);
522 elm_genlist_item_show(next);
528 _item_single_select_up(Widget_Data *wd)
530 Elm_Genlist_Item *prev;
533 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
534 while ((prev) && (prev->delete_me))
535 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
537 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
539 if (!prev) return EINA_FALSE;
541 _deselect_all_items(wd);
543 elm_genlist_item_selected_set(prev, EINA_TRUE);
544 elm_genlist_item_show(prev);
549 _item_single_select_down(Widget_Data *wd)
551 Elm_Genlist_Item *next;
554 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
555 while ((next) && (next->delete_me))
556 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
558 else next = elm_genlist_item_next_get(wd->last_selected_item);
560 if (!next) return EINA_FALSE;
562 _deselect_all_items(wd);
564 elm_genlist_item_selected_set(next, EINA_TRUE);
565 elm_genlist_item_show(next);
570 _on_focus_hook(void *data __UNUSED__,
573 Widget_Data *wd = elm_widget_data_get(obj);
575 if (elm_widget_focus_get(obj))
577 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
578 evas_object_focus_set(wd->obj, EINA_TRUE);
579 if ((wd->items) && (wd->selected) && (!wd->last_selected_item))
580 wd->last_selected_item = eina_list_data_get(wd->selected);
584 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
585 evas_object_focus_set(wd->obj, EINA_FALSE);
590 _del_hook(Evas_Object *obj)
592 Widget_Data *wd = elm_widget_data_get(obj);
594 _item_cache_zero(wd);
595 if (wd->calc_job) ecore_job_del(wd->calc_job);
596 if (wd->update_job) ecore_job_del(wd->update_job);
597 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
598 if (wd->changed_job) ecore_job_del(wd->changed_job);
599 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
600 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
601 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
602 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
607 _del_pre_hook(Evas_Object *obj)
609 Widget_Data *wd = elm_widget_data_get(obj);
611 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
612 elm_genlist_clear(obj);
613 evas_object_del(wd->pan_smart);
614 wd->pan_smart = NULL;
618 _mirrored_set(Evas_Object *obj,
621 Widget_Data *wd = elm_widget_data_get(obj);
623 _item_cache_zero(wd);
624 elm_smart_scroller_mirrored_set(wd->scr, rtl);
628 _theme_hook(Evas_Object *obj)
630 Widget_Data *wd = elm_widget_data_get(obj);
633 evas_event_freeze(evas_object_evas_get(wd->obj));
634 _item_cache_zero(wd);
635 _elm_widget_mirrored_reload(obj);
636 _mirrored_set(obj, elm_widget_mirrored_get(obj));
637 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
638 elm_widget_style_get(obj));
639 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
640 wd->item_width = wd->item_height = 0;
641 wd->group_item_width = wd->group_item_height = 0;
642 wd->minw = wd->minh = wd->realminw = 0;
643 EINA_INLIST_FOREACH(wd->blocks, itb)
646 Elm_Genlist_Item *it;
648 if (itb->realized) _item_block_unrealize(itb);
649 EINA_LIST_FOREACH(itb->items, l, it)
650 it->mincalcd = EINA_FALSE;
652 itb->changed = EINA_TRUE;
654 if (wd->calc_job) ecore_job_del(wd->calc_job);
655 wd->calc_job = ecore_job_add(_calc_job, wd);
657 evas_event_thaw(evas_object_evas_get(wd->obj));
658 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
662 _show_region_hook(void *data,
665 Widget_Data *wd = elm_widget_data_get(data);
666 Evas_Coord x, y, w, h;
668 elm_widget_show_region_get(obj, &x, &y, &w, &h);
669 //x & y are screen coordinates, Add with pan coordinates
672 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
676 _translate_hook(Evas_Object *obj)
678 evas_object_smart_callback_call(obj, "language,changed", NULL);
682 _sizing_eval(Evas_Object *obj)
684 Widget_Data *wd = elm_widget_data_get(obj);
685 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
687 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
688 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
690 if (wd->height_for_width)
694 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
695 if ((vw != 0) && (vw != wd->prev_viewport_w))
699 wd->prev_viewport_w = vw;
700 EINA_INLIST_FOREACH(wd->blocks, itb)
702 itb->must_recalc = EINA_TRUE;
704 if (wd->calc_job) ecore_job_del(wd->calc_job);
705 wd->calc_job = ecore_job_add(_calc_job, wd);
708 if (wd->mode == ELM_LIST_LIMIT)
710 Evas_Coord vmw, vmh, vw, vh;
714 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
715 if ((minw > 0) && (vw < minw)) vw = minw;
716 else if ((maxw > 0) && (vw > maxw))
718 edje_object_size_min_calc
719 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
726 edje_object_size_min_calc
727 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
731 evas_object_size_hint_min_set(obj, minw, minh);
732 evas_object_size_hint_max_set(obj, maxw, maxh);
736 _signal_emit_hook(Evas_Object *obj,
737 const char *emission,
740 Widget_Data *wd = elm_widget_data_get(obj);
741 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
746 _item_highlight(Elm_Genlist_Item *it)
748 const char *selectraise;
749 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
750 (it->disabled) || (it->display_only) || (it->mode_view))
752 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
753 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
754 selectraise = edje_object_data_get(VIEW(it), "selectraise");
755 if ((selectraise) && (!strcmp(selectraise, "on")))
757 if (it->edit_obj) evas_object_raise(it->edit_obj);
758 else evas_object_raise(VIEW(it));
759 if ((it->group_item) && (it->group_item->realized))
760 evas_object_raise(it->VIEW(group_item));
762 it->highlighted = EINA_TRUE;
766 _item_block_del(Elm_Genlist_Item *it)
769 Item_Block *itb = it->block;
771 itb->items = eina_list_remove(itb->items, it);
773 itb->changed = EINA_TRUE;
774 if (!it->wd->reorder_deleted)
776 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
777 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
781 il = EINA_INLIST_GET(itb);
782 Item_Block *itbn = (Item_Block *)(il->next);
784 it->parent->items = eina_list_remove(it->parent->items, it);
786 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
788 if (itbn) itbn->changed = EINA_TRUE;
792 if (itb->count < itb->wd->max_items_per_block/2)
794 il = EINA_INLIST_GET(itb);
795 Item_Block *itbp = (Item_Block *)(il->prev);
796 Item_Block *itbn = (Item_Block *)(il->next);
797 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
799 Elm_Genlist_Item *it2;
801 EINA_LIST_FREE(itb->items, it2)
804 itbp->items = eina_list_append(itbp->items, it2);
806 itbp->changed = EINA_TRUE;
808 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
809 EINA_INLIST_GET(itb));
812 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
816 Eina_List *last = eina_list_last(itb->items);
817 Elm_Genlist_Item *it2 = last->data;
820 itb->items = eina_list_remove_list(itb->items, last);
821 itbn->items = eina_list_prepend(itbn->items, it2);
823 itbn->changed = EINA_TRUE;
826 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
834 _item_subitems_clear(Elm_Genlist_Item *it)
837 Eina_List *tl = NULL, *l;
838 Elm_Genlist_Item *it2;
840 EINA_LIST_FOREACH(it->items, l, it2)
841 tl = eina_list_append(tl, it2);
843 EINA_LIST_FREE(tl, it2)
844 elm_genlist_item_del(it2);
848 _item_del(Elm_Genlist_Item *it)
850 Evas_Object *tob = it->wd->obj;
852 evas_event_freeze(evas_object_evas_get(tob));
853 elm_widget_item_pre_notify_del(it);
854 elm_genlist_item_subitems_clear(it);
855 it->wd->walking -= it->walking;
856 if (it->wd->show_item == it) it->wd->show_item = NULL;
857 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
858 if (it->realized) _item_unrealize(it, EINA_FALSE);
859 if (it->effect_item_realized) _effect_item_unrealize(it);
860 if (it->block) _item_block_del(it);
861 if ((!it->delete_me) && (it->itc->func.del))
862 it->itc->func.del((void *)it->base.data, WIDGET(it));
863 it->delete_me = EINA_TRUE;
865 it->wd->queue = eina_list_remove(it->wd->queue, it);
867 if (it->wd->anchor_item == it)
869 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
870 if (!it->wd->anchor_item)
871 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
874 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
876 it->parent->items = eina_list_remove(it->parent->items, it);
877 if (it->flags & ELM_GENLIST_ITEM_GROUP)
878 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
879 if (it->long_timer) ecore_timer_del(it->long_timer);
880 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
882 if (it->tooltip.del_cb)
883 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
885 evas_event_thaw(evas_object_evas_get(tob));
886 evas_event_thaw_eval(evas_object_evas_get(tob));
888 elm_widget_item_del(it);
892 _item_select(Elm_Genlist_Item *it)
896 Evas_Object *parent = WIDGET(it);
898 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
901 if (it->wd->always_select) goto call;
904 it->selected = EINA_TRUE;
905 it->wd->selected = eina_list_append(it->wd->selected, it);
907 evas_object_ref(parent);
910 if (it->wd->last_selected_item && (it != it->wd->last_selected_item))
912 EINA_LIST_FOREACH(it->wd->last_selected_item->icon_objs, l, obj)
913 elm_widget_focused_object_clear(obj);
915 if (it->func.func) it->func.func((void *)it->func.data, parent, it);
917 evas_object_smart_callback_call(parent, SIG_SELECTED, it);
920 if ((it->wd->clear_me) && (!it->wd->walking))
922 elm_genlist_clear(parent);
927 if ((!it->walking) && (it->delete_me))
929 if (!it->relcount) _item_del(it);
933 if (it && it->wd) it->wd->last_selected_item = it; // TODO: Remove 'if'?
935 evas_object_unref(parent);
939 _item_unselect(Elm_Genlist_Item *it)
941 const char *stacking, *selectraise;
943 if ((it->delete_me) || (!it->highlighted)) return;
944 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
945 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
946 stacking = edje_object_data_get(VIEW(it), "stacking");
947 selectraise = edje_object_data_get(VIEW(it), "selectraise");
948 if ((selectraise) && (!strcmp(selectraise, "on")))
950 if ((stacking) && (!strcmp(stacking, "below")))
951 evas_object_lower(VIEW(it));
953 it->highlighted = EINA_FALSE;
956 it->selected = EINA_FALSE;
957 it->wd->selected = eina_list_remove(it->wd->selected, it);
958 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
963 _mouse_move(void *data,
964 Evas *evas __UNUSED__,
968 Elm_Genlist_Item *it = data;
969 Evas_Event_Mouse_Move *ev = event_info;
970 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
971 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
973 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
975 if (!it->wd->on_hold)
977 it->wd->on_hold = EINA_TRUE;
978 if ((!it->wd->wasselected) && (!it->renamed))
982 if (it->wd->multitouched)
984 it->wd->cur_x = ev->cur.canvas.x;
985 it->wd->cur_y = ev->cur.canvas.y;
988 if ((it->dragging) && (it->down))
990 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
993 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
994 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
995 if (abs((it->wd->history[it->wd->movements].x -
996 it->wd->history[0].x)) > 40)
997 it->wd->swipe = EINA_TRUE;
1003 ecore_timer_del(it->long_timer);
1004 it->long_timer = NULL;
1006 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
1009 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1013 ecore_timer_del(it->long_timer);
1014 it->long_timer = NULL;
1016 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1018 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1019 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1021 if (!it->wd->reorder_start_y)
1022 it->wd->reorder_start_y = it->block->y + it->y;
1026 else if (it_scrl_y + it->wd->reorder_it->h > oy + oh)
1027 y_pos = oy + oh - it->wd->reorder_it->h;
1032 _item_position(it, it->edit_obj, it->scrl_x, y_pos);
1034 _item_position(it, VIEW(it), it->scrl_x, y_pos);
1036 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1037 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1041 if (!it->display_only)
1042 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1043 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1044 x = ev->cur.canvas.x - x;
1045 y = ev->cur.canvas.y - y;
1048 if (adx < 0) adx = -dx;
1051 if (ady < 0) ady = -dy;
1054 if ((adx > minw) || (ady > minh))
1056 it->dragging = EINA_TRUE;
1059 ecore_timer_del(it->long_timer);
1060 it->long_timer = NULL;
1062 if ((!it->wd->wasselected) && (!it->renamed))
1066 if ((ady > adx) && (!it->wd->drag_started))
1067 evas_object_smart_callback_call(WIDGET(it),
1068 SIG_DRAG_START_UP, it);
1072 evas_object_smart_callback_call(WIDGET(it),
1073 SIG_DRAG_START_LEFT, it);
1075 evas_object_smart_callback_call(WIDGET(it),
1076 SIG_DRAG_START_RIGHT, it);
1081 if ((ady > adx) && (!it->wd->drag_started))
1082 evas_object_smart_callback_call(WIDGET(it),
1083 SIG_DRAG_START_DOWN, it);
1087 evas_object_smart_callback_call(WIDGET(it),
1088 SIG_DRAG_START_LEFT, it);
1090 evas_object_smart_callback_call(WIDGET(it),
1091 SIG_DRAG_START_RIGHT, it);
1098 _long_press(void *data)
1100 Elm_Genlist_Item *it = data, *it_tmp;
1101 Eina_List *list, *l;
1103 it->long_timer = NULL;
1104 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
1105 return ECORE_CALLBACK_CANCEL;
1106 it->wd->longpressed = EINA_TRUE;
1107 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
1108 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1110 it->wd->reorder_it = it;
1111 it->wd->reorder_start_y = 0;
1113 evas_object_raise(it->edit_obj);
1115 evas_object_raise(VIEW(it));
1117 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1118 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1120 list = elm_genlist_realized_items_get(it->wd->obj);
1121 EINA_LIST_FOREACH(list, l, it_tmp)
1123 if (it != it_tmp) _item_unselect(it_tmp);
1127 EINA_LIST_FOREACH(it->items, l, it_tmp)
1129 if (elm_genlist_item_expanded_get(it_tmp))
1131 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1132 return ECORE_CALLBACK_RENEW;
1136 if (elm_genlist_item_expanded_get(it))
1138 elm_genlist_item_expanded_set(it, EINA_FALSE);
1139 return ECORE_CALLBACK_RENEW;
1142 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1144 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
1146 return ECORE_CALLBACK_CANCEL;
1150 _swipe(Elm_Genlist_Item *it)
1155 if ((it->display_only) || (it->disabled)) return;
1156 it->wd->swipe = EINA_FALSE;
1157 for (i = 0; i < it->wd->movements; i++)
1159 sum += it->wd->history[i].x;
1160 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1163 sum /= it->wd->movements;
1164 if (abs(sum - it->wd->history[0].x) <= 10) return;
1165 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
1169 _swipe_cancel(void *data)
1171 Elm_Genlist_Item *it = data;
1173 if (!it) return ECORE_CALLBACK_CANCEL;
1174 it->wd->swipe = EINA_FALSE;
1175 it->wd->movements = 0;
1176 return ECORE_CALLBACK_RENEW;
1180 _multi_cancel(void *data)
1182 Widget_Data *wd = data;
1184 if (!wd) return ECORE_CALLBACK_CANCEL;
1185 wd->multi_timeout = EINA_TRUE;
1186 return ECORE_CALLBACK_RENEW;
1190 _multi_touch_gesture_eval(void *data)
1192 Elm_Genlist_Item *it = data;
1194 it->wd->multitouched = EINA_FALSE;
1195 if (it->wd->multi_timer)
1197 ecore_timer_del(it->wd->multi_timer);
1198 it->wd->multi_timer = NULL;
1200 if (it->wd->multi_timeout)
1202 it->wd->multi_timeout = EINA_FALSE;
1206 Evas_Coord minw = 0, minh = 0;
1207 Evas_Coord off_x, off_y, off_mx, off_my;
1209 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1210 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1211 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1212 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1213 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1215 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1217 if ((off_x + off_mx) > (off_y + off_my))
1219 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1220 evas_object_smart_callback_call(WIDGET(it),
1221 SIG_MULTI_SWIPE_RIGHT, it);
1222 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1223 evas_object_smart_callback_call(WIDGET(it),
1224 SIG_MULTI_SWIPE_LEFT, it);
1225 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1226 evas_object_smart_callback_call(WIDGET(it),
1227 SIG_MULTI_PINCH_OUT, it);
1229 evas_object_smart_callback_call(WIDGET(it),
1230 SIG_MULTI_PINCH_IN, it);
1234 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1235 evas_object_smart_callback_call(WIDGET(it),
1236 SIG_MULTI_SWIPE_DOWN, it);
1237 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1238 evas_object_smart_callback_call(WIDGET(it),
1239 SIG_MULTI_SWIPE_UP, it);
1240 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1241 evas_object_smart_callback_call(WIDGET(it),
1242 SIG_MULTI_PINCH_OUT, it);
1244 evas_object_smart_callback_call(WIDGET(it),
1245 SIG_MULTI_PINCH_IN, it);
1248 it->wd->multi_timeout = EINA_FALSE;
1252 _multi_down(void *data,
1253 Evas *evas __UNUSED__,
1254 Evas_Object *obj __UNUSED__,
1257 Elm_Genlist_Item *it = data;
1258 Evas_Event_Multi_Down *ev = event_info;
1260 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1261 it->wd->multi_device = ev->device;
1262 it->wd->multi_down = EINA_TRUE;
1263 it->wd->multitouched = EINA_TRUE;
1264 it->wd->prev_mx = ev->canvas.x;
1265 it->wd->prev_my = ev->canvas.y;
1266 if (!it->wd->wasselected) _item_unselect(it);
1267 it->wd->wasselected = EINA_FALSE;
1268 it->wd->longpressed = EINA_FALSE;
1271 ecore_timer_del(it->long_timer);
1272 it->long_timer = NULL;
1276 it->dragging = EINA_FALSE;
1277 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1279 if (it->swipe_timer)
1281 ecore_timer_del(it->swipe_timer);
1282 it->swipe_timer = NULL;
1284 if (it->wd->on_hold)
1286 it->wd->swipe = EINA_FALSE;
1287 it->wd->movements = 0;
1288 it->wd->on_hold = EINA_FALSE;
1293 _multi_up(void *data,
1294 Evas *evas __UNUSED__,
1295 Evas_Object *obj __UNUSED__,
1298 Elm_Genlist_Item *it = data;
1299 Evas_Event_Multi_Up *ev = event_info;
1301 if (it->wd->multi_device != ev->device) return;
1302 it->wd->multi_device = 0;
1303 it->wd->multi_down = EINA_FALSE;
1304 if (it->wd->mouse_down) return;
1305 _multi_touch_gesture_eval(data);
1309 _multi_move(void *data,
1310 Evas *evas __UNUSED__,
1311 Evas_Object *obj __UNUSED__,
1314 Elm_Genlist_Item *it = data;
1315 Evas_Event_Multi_Move *ev = event_info;
1317 if (it->wd->multi_device != ev->device) return;
1318 it->wd->cur_mx = ev->cur.canvas.x;
1319 it->wd->cur_my = ev->cur.canvas.y;
1323 _mouse_down(void *data,
1324 Evas *evas __UNUSED__,
1328 Elm_Genlist_Item *it = data;
1329 Evas_Event_Mouse_Down *ev = event_info;
1332 if (ev->button != 1) return;
1333 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1335 it->wd->on_hold = EINA_TRUE;
1337 it->down = EINA_TRUE;
1338 it->dragging = EINA_FALSE;
1339 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1340 it->dx = ev->canvas.x - x;
1341 it->dy = ev->canvas.y - y;
1342 it->wd->mouse_down = EINA_TRUE;
1343 if (!it->wd->multitouched)
1345 it->wd->prev_x = ev->canvas.x;
1346 it->wd->prev_y = ev->canvas.y;
1347 it->wd->multi_timeout = EINA_FALSE;
1348 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1349 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1351 it->wd->longpressed = EINA_FALSE;
1352 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1353 else it->wd->on_hold = EINA_FALSE;
1354 if (it->wd->on_hold) return;
1355 it->wd->wasselected = it->selected;
1356 _item_highlight(it);
1357 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1358 if ((!it->disabled) && (!it->display_only))
1360 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1361 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
1363 if (it->long_timer) ecore_timer_del(it->long_timer);
1364 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1365 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1367 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1370 it->long_timer = NULL;
1371 it->wd->swipe = EINA_FALSE;
1372 it->wd->movements = 0;
1376 _mouse_up(void *data,
1377 Evas *evas __UNUSED__,
1378 Evas_Object *obj __UNUSED__,
1381 Elm_Genlist_Item *it = data;
1382 Evas_Event_Mouse_Up *ev = event_info;
1383 Eina_Bool dragged = EINA_FALSE;
1385 if (ev->button != 1) return;
1386 it->down = EINA_FALSE;
1387 it->wd->mouse_down = EINA_FALSE;
1388 if (it->wd->multitouched)
1390 // in single selection modes, some multi touching can make multi highlighted items.
1391 // if a item not selected and highlighted, it should be unhighlighted.
1392 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unselect(it);
1393 if (it->wd->multi_down) return;
1394 _multi_touch_gesture_eval(data);
1397 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1398 else it->wd->on_hold = EINA_FALSE;
1401 ecore_timer_del(it->long_timer);
1402 it->long_timer = NULL;
1406 it->dragging = EINA_FALSE;
1407 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1410 if (it->swipe_timer)
1412 ecore_timer_del(it->swipe_timer);
1413 it->swipe_timer = NULL;
1415 if (it->wd->multi_timer)
1417 ecore_timer_del(it->wd->multi_timer);
1418 it->wd->multi_timer = NULL;
1419 it->wd->multi_timeout = EINA_FALSE;
1421 if (it->wd->on_hold)
1423 if (it->wd->swipe) _swipe(data);
1424 it->wd->longpressed = EINA_FALSE;
1425 it->wd->on_hold = EINA_FALSE;
1428 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1430 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1432 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1434 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1435 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1437 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1441 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1442 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1444 it->wd->reorder_deleted = EINA_FALSE;
1445 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1446 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1447 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1448 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1451 if (it->wd->longpressed)
1453 it->wd->longpressed = EINA_FALSE;
1454 if ((!it->wd->wasselected) && (!it->renamed))
1456 it->wd->wasselected = EINA_FALSE;
1461 if (it->want_unrealize)
1463 _item_unrealize(it, EINA_FALSE);
1464 if (it->block->want_unrealize)
1465 _item_block_unrealize(it->block);
1468 if ((it->disabled) || (dragged) || (it->display_only)) return;
1469 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1474 _item_highlight(it);
1477 else _item_unselect(it);
1483 Widget_Data *wd = it->wd;
1486 while (wd->selected) _item_unselect(wd->selected->data);
1491 const Eina_List *l, *l_next;
1492 Elm_Genlist_Item *it2;
1494 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1495 if (it2 != it) _item_unselect(it2);
1496 //_item_highlight(it);
1499 _item_highlight(it);
1505 _mouse_down_scroller(void *data,
1506 Evas *evas __UNUSED__,
1507 Evas_Object *obj __UNUSED__,
1508 void *event_info __UNUSED__)
1510 Widget_Data *wd = elm_widget_data_get(data);
1513 wd->drag_started = EINA_FALSE;
1517 _mouse_up_scroller(void *data,
1518 Evas *evas __UNUSED__,
1519 Evas_Object *obj __UNUSED__,
1520 void *event_info __UNUSED__)
1522 Widget_Data *wd = elm_widget_data_get(data);
1525 wd->drag_started = EINA_FALSE;
1529 _mouse_move_scroller(void *data,
1530 Evas *evas __UNUSED__,
1531 Evas_Object *obj __UNUSED__,
1534 Widget_Data *wd = elm_widget_data_get(data);
1535 Evas_Event_Mouse_Move *ev = event_info;
1536 Evas_Coord minw = 0, minh = 0, dx, dy, adx, ady;
1539 if (wd->drag_started) return;
1541 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1542 dx = ev->cur.canvas.x - ev->prev.canvas.x;
1543 dy = ev->cur.canvas.y - ev->prev.canvas.y;
1546 if (adx < 0) adx = -dx;
1547 if (ady < 0) ady = -dy;
1548 if (((ady < minh) && (ady > minh / 2)) && (ady > adx))
1552 evas_object_smart_callback_call(data, SIG_DRAG_START_UP, NULL);
1553 wd->drag_started = EINA_TRUE;
1557 evas_object_smart_callback_call(data, SIG_DRAG_START_DOWN, NULL);
1558 wd->drag_started = EINA_TRUE;
1564 _signal_expand_toggle(void *data,
1565 Evas_Object *obj __UNUSED__,
1566 const char *emission __UNUSED__,
1567 const char *source __UNUSED__)
1569 Elm_Genlist_Item *it = data;
1572 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1574 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1578 _signal_expand(void *data,
1579 Evas_Object *obj __UNUSED__,
1580 const char *emission __UNUSED__,
1581 const char *source __UNUSED__)
1583 Elm_Genlist_Item *it = data;
1586 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1590 _signal_contract(void *data,
1591 Evas_Object *obj __UNUSED__,
1592 const char *emission __UNUSED__,
1593 const char *source __UNUSED__)
1595 Elm_Genlist_Item *it = data;
1598 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1602 _scr_hold_timer_cb(void *data)
1604 if (!data) return ECORE_CALLBACK_CANCEL;
1605 Widget_Data *wd = data;
1606 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1607 wd->scr_hold_timer = NULL;
1608 return ECORE_CALLBACK_CANCEL;
1612 _mode_finished_signal_cb(void *data,
1614 const char *emission __UNUSED__,
1615 const char *source __UNUSED__)
1619 Elm_Genlist_Item *it = data;
1620 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1622 Evas *te = evas_object_evas_get(obj);
1624 evas_event_freeze(te);
1625 it->nocache = EINA_FALSE;
1626 _mode_item_unrealize(it);
1628 evas_object_raise(it->VIEW(group_item));
1629 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1630 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1631 evas_event_thaw(te);
1632 evas_event_thaw_eval(te);
1636 _item_cache_clean(Widget_Data *wd)
1638 evas_event_freeze(evas_object_evas_get(wd->obj));
1639 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1643 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1644 wd->item_cache = eina_inlist_remove(wd->item_cache,
1645 wd->item_cache->last);
1646 wd->item_cache_count--;
1647 if (itc->spacer) evas_object_del(itc->spacer);
1648 if (itc->base_view) evas_object_del(itc->base_view);
1649 if (itc->item_style) eina_stringshare_del(itc->item_style);
1652 evas_event_thaw(evas_object_evas_get(wd->obj));
1653 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1657 _item_cache_zero(Widget_Data *wd)
1659 int pmax = wd->item_cache_max;
1660 wd->item_cache_max = 0;
1661 _item_cache_clean(wd);
1662 wd->item_cache_max = pmax;
1666 _item_cache_add(Elm_Genlist_Item *it)
1670 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1671 if (it->wd->item_cache_max <= 0)
1673 evas_object_del(VIEW(it));
1675 evas_object_del(it->spacer);
1677 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1678 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1682 it->wd->item_cache_count++;
1683 itc = calloc(1, sizeof(Item_Cache));
1686 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1687 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1690 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1691 EINA_INLIST_GET(itc));
1692 itc->spacer = it->spacer;
1694 itc->base_view = VIEW(it);
1696 evas_object_hide(itc->base_view);
1697 evas_object_move(itc->base_view, -9999, -9999);
1698 itc->item_style = eina_stringshare_add(it->itc->item_style);
1699 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1700 itc->compress = (it->wd->compress);
1701 itc->odd = (it->order_num_in & 0x1);
1702 itc->selected = it->selected;
1703 itc->disabled = it->disabled;
1704 itc->expanded = it->expanded;
1707 ecore_timer_del(it->long_timer);
1708 it->long_timer = NULL;
1710 if (it->swipe_timer)
1712 ecore_timer_del(it->swipe_timer);
1713 it->swipe_timer = NULL;
1715 // FIXME: other callbacks?
1716 edje_object_signal_callback_del_full(itc->base_view,
1717 "elm,action,expand,toggle",
1718 "elm", _signal_expand_toggle, it);
1719 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1721 _signal_expand, it);
1722 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1723 "elm", _signal_contract, it);
1724 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1726 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1728 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1730 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1732 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1734 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1736 _item_cache_clean(it->wd);
1737 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1738 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1742 _item_cache_find(Elm_Genlist_Item *it)
1745 Eina_Bool tree = 0, odd;
1747 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1748 odd = (it->order_num_in & 0x1);
1749 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1751 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1753 if ((itc->tree == tree) &&
1754 (itc->odd == odd) &&
1755 (itc->compress == it->wd->compress) &&
1756 (!strcmp(it->itc->item_style, itc->item_style)))
1758 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1759 EINA_INLIST_GET(itc));
1760 it->wd->item_cache_count--;
1768 _item_cache_free(Item_Cache *itc)
1770 if (itc->spacer) evas_object_del(itc->spacer);
1771 if (itc->base_view) evas_object_del(itc->base_view);
1772 if (itc->item_style) eina_stringshare_del(itc->item_style);
1777 _item_label_hook(Elm_Genlist_Item *it, const char *part)
1779 if (!it->itc->func.label_get) return NULL;
1780 return edje_object_part_text_get(VIEW(it), part);
1784 _icon_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1786 Elm_Genlist_Item *it = data;
1787 if (it) it->defer_unrealize = EINA_TRUE;
1791 _icon_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1793 Elm_Genlist_Item *it = data;
1794 if (it) it->defer_unrealize = EINA_FALSE;
1798 _item_del_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1800 Elm_Genlist_Item *it = event_info;
1802 if (it->wd->last_selected_item == it)
1803 it->wd->last_selected_item = NULL;
1807 _item_label_realize(Elm_Genlist_Item *it,
1808 Evas_Object *target,
1812 if (it->itc->func.label_get)
1817 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1818 EINA_LIST_FOREACH(*source, l, key)
1820 if (parts && fnmatch(parts, key, FNM_PERIOD))
1823 char *s = it->itc->func.label_get
1824 ((void *)it->base.data, WIDGET(it), key);
1828 edje_object_part_text_set(target, key, s);
1833 edje_object_part_text_set(target, key, "");
1841 _item_icon_unrealize(Elm_Genlist_Item *it,
1842 Evas_Object *target,
1846 Eina_List *res = it->icon_objs;
1848 if (it->itc->func.icon_get)
1852 Evas_Object *ic = NULL;
1854 EINA_LIST_FOREACH(*source, l, key)
1856 if (parts && fnmatch(parts, key, FNM_PERIOD))
1859 ic = edje_object_part_swallow_get(target, key);
1862 res = eina_list_remove(res, ic);
1863 edje_object_part_unswallow(target, ic);
1864 evas_object_del(ic);
1873 _item_icon_realize(Elm_Genlist_Item *it,
1874 Evas_Object *target,
1878 Eina_List *res = NULL;
1880 if (it->itc->func.icon_get)
1885 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1886 if (parts && (eina_list_count(*source) != eina_list_count(it->icon_objs)))
1887 res = it->icon_objs;
1888 EINA_LIST_FOREACH(*source, l, key)
1890 if (parts && fnmatch(parts, key, FNM_PERIOD))
1893 Evas_Object *ic = it->itc->func.icon_get
1894 ((void *)it->base.data, WIDGET(it), key);
1898 res = eina_list_append(res, ic);
1899 edje_object_part_swallow(target, key, ic);
1900 evas_object_show(ic);
1901 elm_widget_sub_object_add(WIDGET(it), ic);
1902 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
1904 elm_widget_disabled_set(ic, EINA_TRUE);
1913 _item_state_realize(Elm_Genlist_Item *it,
1914 Evas_Object *target,
1918 if (it->itc->func.state_get)
1924 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1925 EINA_LIST_FOREACH(*source, l, key)
1927 if (parts && fnmatch(parts, key, FNM_PERIOD))
1930 Eina_Bool on = it->itc->func.state_get
1931 ((void *)it->base.data, WIDGET(it), key);
1935 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1936 edje_object_signal_emit(target, buf, "elm");
1940 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1941 edje_object_signal_emit(target, buf, "elm");
1948 _item_realize(Elm_Genlist_Item *it,
1952 Elm_Genlist_Item *it2;
1953 const char *stacking;
1954 const char *treesize;
1956 int depth, tsize = 20;
1957 Item_Cache *itc = NULL;
1959 if ((it->realized) || (it->delete_me)) return;
1960 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1961 it->order_num_in = in;
1962 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1963 if ((it->nocache) && (!it->renamed))
1964 it->nocache = EINA_FALSE;
1966 itc = _item_cache_find(it);
1967 if (itc && (!it->wd->effect_mode))
1969 VIEW(it) = itc->base_view;
1970 itc->base_view = NULL;
1971 it->spacer = itc->spacer;
1976 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
1977 edje_object_scale_set(VIEW(it),
1978 elm_widget_scale_get(WIDGET(it)) *
1979 _elm_config->scale);
1980 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
1981 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
1983 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1984 strncpy(buf, "tree", sizeof(buf));
1985 else strncpy(buf, "item", sizeof(buf));
1986 if (it->wd->compress)
1987 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1989 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1990 strncat(buf, "/", sizeof(buf) - strlen(buf));
1991 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1993 _elm_theme_object_set(WIDGET(it), VIEW(it), "genlist", buf,
1994 elm_widget_style_get(WIDGET(it)));
1995 edje_object_mirrored_set(VIEW(it),
1996 elm_widget_mirrored_get(WIDGET(it)));
1998 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1999 evas_object_color_set(it->spacer, 0, 0, 0, 0);
2000 elm_widget_sub_object_add(WIDGET(it), it->spacer);
2002 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
2004 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
2006 it->expanded_depth = depth;
2007 treesize = edje_object_data_get(VIEW(it), "treesize");
2008 if (treesize) tsize = atoi(treesize);
2009 evas_object_size_hint_min_set(it->spacer,
2010 (depth * tsize) * _elm_config->scale, 1);
2011 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
2014 edje_object_signal_callback_add(VIEW(it),
2015 "elm,action,expand,toggle",
2016 "elm", _signal_expand_toggle, it);
2017 edje_object_signal_callback_add(VIEW(it), "elm,action,expand",
2018 "elm", _signal_expand, it);
2019 edje_object_signal_callback_add(VIEW(it), "elm,action,contract",
2020 "elm", _signal_contract, it);
2021 stacking = edje_object_data_get(VIEW(it), "stacking");
2024 if (!strcmp(stacking, "below")) evas_object_lower(VIEW(it));
2025 else if (!strcmp(stacking, "above"))
2026 evas_object_raise(VIEW(it));
2028 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
2030 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
2032 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
2034 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_DOWN,
2036 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_UP,
2038 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_MOVE,
2041 if ((!it->edit_obj) &&(it->wd->edit_mode) &&
2042 (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
2043 _effect_item_realize(it, EINA_FALSE);
2047 if ((it->selected) && (it->selected != itc->selected))
2049 edje_object_signal_emit(VIEW(it),
2050 "elm,state,selected", "elm");
2052 edje_object_signal_emit(it->edit_obj,
2053 "elm,state,selected", "elm");
2055 if ((it->disabled) && (it->disabled != itc->disabled))
2057 edje_object_signal_emit(VIEW(it),
2058 "elm,state,disabled", "elm");
2060 edje_object_signal_emit(it->edit_obj,
2061 "elm,state,disabled", "elm");
2063 if ((it->expanded) && (it->expanded != itc->expanded))
2065 edje_object_signal_emit(VIEW(it),
2066 "elm,state,expanded", "elm");
2068 edje_object_signal_emit(it->edit_obj,
2069 "elm,state,expanded", "elm");
2076 edje_object_signal_emit(VIEW(it),
2077 "elm,state,selected", "elm");
2079 edje_object_signal_emit(it->edit_obj,
2080 "elm,state,selected", "elm");
2084 edje_object_signal_emit(VIEW(it),
2085 "elm,state,disabled", "elm");
2087 edje_object_signal_emit(it->edit_obj,
2088 "elm,state,disabled", "elm");
2092 edje_object_signal_emit(VIEW(it),
2093 "elm,state,expanded", "elm");
2095 edje_object_signal_emit(it->edit_obj,
2096 "elm,state,expanded", "elm");
2101 if ((calc) && (it->wd->homogeneous) &&
2102 ((it->wd->item_width) ||
2103 ((it->wd->item_width) && (it->wd->group_item_width))))
2105 /* homogenous genlist shortcut */
2108 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2110 it->w = it->minw = it->wd->group_item_width;
2111 it->h = it->minh = it->wd->group_item_height;
2115 it->w = it->minw = it->wd->item_width;
2116 it->h = it->minh = it->wd->item_height;
2118 it->mincalcd = EINA_TRUE;
2123 _item_label_realize(it, VIEW(it), &it->labels, NULL);
2124 it->icon_objs = _item_icon_realize(it, VIEW(it), &it->icons, NULL);
2125 _item_state_realize(it, VIEW(it), &it->states, NULL);
2126 if (it->itc->func.icon_get) // for rename mode
2132 edje_object_signal_emit(VIEW(it), "elm,state,rename,enabled", "elm");
2134 elm_widget_stringlist_get(edje_object_data_get(VIEW(it), "renames"));
2135 EINA_LIST_FOREACH(it->icons, l, key)
2137 Evas_Object *ic = it->itc->func.icon_get
2138 ((void *)it->base.data, WIDGET(it), l->data);
2141 it->icon_objs = eina_list_append(it->icon_objs, ic);
2142 edje_object_part_swallow(VIEW(it), key, ic);
2143 evas_object_show(ic);
2144 elm_widget_sub_object_add(WIDGET(it), ic);
2145 // FIXME: if entry calcuates its cursor position correctly and conformant works,
2146 // genlist does not need to handle this focus thing.
2147 evas_object_smart_callback_add(ic, "focused", _icon_focused, it);
2148 evas_object_smart_callback_add(ic, "unfocused", _icon_unfocused, it);
2153 if (!it->mincalcd || it->wd->pan_resize || ((it->wd->height_for_width) && (it->w != it->minw)))
2155 Evas_Coord mw = -1, mh = -1;
2157 if (it->wd->height_for_width) mw = it->wd->w; // TODO: Removed this. This was removed from upstream.
2159 if (!it->display_only)
2160 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2161 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2162 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
2164 if (!it->display_only)
2165 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2166 it->w = it->minw = mw;
2167 it->h = it->minh = mh;
2168 it->mincalcd = EINA_TRUE;
2170 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2172 it->wd->group_item_width = mw;
2173 it->wd->group_item_height = mh;
2175 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2177 it->wd->item_width = mw;
2178 it->wd->item_height = mh;
2181 if (!calc) evas_object_show(VIEW(it));
2184 if (it->tooltip.content_cb)
2186 elm_widget_item_tooltip_content_cb_set(it,
2187 it->tooltip.content_cb,
2188 it->tooltip.data, NULL);
2189 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2192 if (it->mouse_cursor)
2193 elm_widget_item_cursor_set(it, it->mouse_cursor);
2195 it->realized = EINA_TRUE;
2196 it->want_unrealize = EINA_FALSE;
2198 if (itc) _item_cache_free(itc);
2199 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2200 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2202 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
2203 if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
2205 if (it->itc->edit_item_style)
2207 if (!it->edit_obj) _effect_item_realize(it, EINA_FALSE);
2208 edje_object_message_signal_process(it->edit_obj);
2211 edje_object_message_signal_process(VIEW(it));
2215 _item_unrealize(Elm_Genlist_Item *it,
2220 if (!it->realized) return;
2221 if (it->wd->reorder_it == it) return;
2222 if (it->defer_unrealize && !it->updateme) return;
2223 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2225 evas_object_smart_callback_call(WIDGET(it), SIG_UNREALIZED, it);
2228 ecore_timer_del(it->long_timer);
2229 it->long_timer = NULL;
2233 evas_object_del(VIEW(it));
2235 evas_object_del(it->spacer);
2240 edje_object_mirrored_set(VIEW(it),
2241 elm_widget_mirrored_get(WIDGET(it)));
2242 edje_object_scale_set(VIEW(it),
2243 elm_widget_scale_get(WIDGET(it))
2244 * _elm_config->scale);
2245 _item_cache_add(it);
2247 elm_widget_stringlist_free(it->labels);
2249 elm_widget_stringlist_free(it->icons);
2251 elm_widget_stringlist_free(it->states);
2253 EINA_LIST_FREE(it->icon_objs, icon)
2254 evas_object_del(icon);
2256 _mode_item_unrealize(it);
2258 it->realized = EINA_FALSE;
2259 it->want_unrealize = EINA_FALSE;
2260 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2261 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2262 if (it->wd->edit_mode) _effect_item_unrealize(it);
2266 _item_block_recalc(Item_Block *itb,
2271 Elm_Genlist_Item *it;
2272 Evas_Coord minw = 0, minh = 0;
2273 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2276 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2278 EINA_LIST_FOREACH(itb->items, l, it)
2280 if (it->delete_me) continue;
2281 showme |= it->showme;
2286 if (!it->mincalcd) changed = EINA_TRUE;
2289 _item_realize(it, in, EINA_TRUE);
2290 _item_unrealize(it, EINA_TRUE);
2295 _item_realize(it, in, EINA_TRUE);
2296 _item_unrealize(it, EINA_TRUE);
2300 _item_realize(it, in, EINA_FALSE);
2302 if (minw < it->minw) minw = it->minw;
2310 itb->changed = EINA_FALSE;
2311 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2312 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2317 _item_block_realize(Item_Block *itb)
2319 if (itb->realized) return;
2320 itb->realized = EINA_TRUE;
2321 itb->want_unrealize = EINA_FALSE;
2325 _item_block_unrealize(Item_Block *itb)
2328 Elm_Genlist_Item *it;
2329 Eina_Bool dragging = EINA_FALSE;
2331 if (!itb->realized) return;
2332 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2333 EINA_LIST_FOREACH(itb->items, l, it)
2335 if (itb->must_recalc || it->flags != ELM_GENLIST_ITEM_GROUP)
2339 dragging = EINA_TRUE;
2340 it->want_unrealize = EINA_TRUE;
2343 _item_unrealize(it, EINA_FALSE);
2348 itb->realized = EINA_FALSE;
2349 itb->want_unrealize = EINA_TRUE;
2352 itb->want_unrealize = EINA_FALSE;
2353 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2354 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2358 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2360 Evas_Coord rox, roy, row, roh, oy, oh;
2361 Eina_Bool top = EINA_FALSE;
2362 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2363 if (!reorder_it) return 0;
2365 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2366 evas_object_geometry_get(it->wd->VIEW(reorder_it), &rox, &roy, &row, &roh);
2368 if ((it->wd->reorder_start_y < it->block->y) &&
2369 (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2371 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2372 if (it->block->count == 1)
2373 it->wd->reorder_rel = it;
2375 else if ((it->wd->reorder_start_y >= it->block->y) &&
2376 (roy - oy + (roh / 2) <= it->block->y - it->wd->pan_y))
2378 it->block->reorder_offset = it->wd->reorder_it->h;
2381 it->block->reorder_offset = 0;
2383 it->scrl_y += it->block->reorder_offset;
2385 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2386 rox, roy + (roh / 2), row, 1));
2389 it->wd->reorder_rel = it;
2390 it->scrl_y += it->wd->reorder_it->h;
2391 return it->wd->reorder_it->h;
2398 _reorder_move_animator_cb(void *data)
2400 Elm_Genlist_Item *it = data;
2401 Eina_Bool down = EINA_FALSE;
2403 int y, dy = it->h / 10 * _elm_config->scale, diff;
2405 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2407 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2410 diff = abs(it->old_scrl_y - it->scrl_y);
2411 if (diff > it->h) y = diff / 2;
2412 if (it->old_scrl_y < it->scrl_y)
2414 it->old_scrl_y += y;
2417 else if (it->old_scrl_y > it->scrl_y)
2419 it->old_scrl_y -= y;
2424 _item_position(it, it->edit_obj, it->scrl_x, it->old_scrl_y);
2426 _item_position(it, VIEW(it), it->scrl_x, it->old_scrl_y);
2427 _group_items_recalc(it->wd);
2428 if ((it->wd->reorder_pan_move) ||
2429 (down && it->old_scrl_y >= it->scrl_y) ||
2430 (!down && it->old_scrl_y <= it->scrl_y))
2432 it->old_scrl_y = it->scrl_y;
2433 it->move_effect_enabled = EINA_FALSE;
2434 it->wd->reorder_move_animator = NULL;
2435 return ECORE_CALLBACK_CANCEL;
2437 return ECORE_CALLBACK_RENEW;
2441 _item_position(Elm_Genlist_Item *it,
2449 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2450 evas_object_resize(view, it->w, it->h);
2451 evas_object_move(view, it_x, it_y);
2452 evas_object_show(view);
2453 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2454 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2458 _item_block_position(Item_Block *itb,
2462 Elm_Genlist_Item *it;
2463 Elm_Genlist_Item *git;
2464 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2465 Evas_Coord minh = 0;
2468 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2469 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2470 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2472 EINA_LIST_FOREACH(itb->items, l, it)
2474 if (it->delete_me) continue;
2475 else if (it->wd->reorder_it == it) continue;
2480 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2481 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2483 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2484 cvx, cvy, cvw, cvh));
2485 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2487 if ((itb->realized))
2491 if (!it->realized) _item_realize(it, in, EINA_FALSE);
2498 if (it->wd->reorder_mode)
2499 y += _get_space_for_reorder_item(it);
2500 git = it->group_item;
2503 git->scrl_x = it->scrl_x;
2504 if (git->scrl_y < oy)
2506 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2507 git->scrl_y = (it->scrl_y + it->h) - git->h;
2508 git->want_realize = EINA_TRUE;
2510 if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2512 if (!it->move_effect_enabled)
2514 it->move_effect_enabled = EINA_TRUE;
2515 it->wd->reorder_move_animator =
2517 _reorder_move_animator_cb, it);
2520 if (!it->move_effect_enabled)
2521 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))
2523 if (it->wd->edit_mode && it->itc->edit_item_style)
2525 _item_position(it, it->edit_obj, it->scrl_x, it->scrl_y);
2529 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)))
2532 _item_position(it, it->mode_view, it->scrl_x,
2535 _item_position(it, VIEW(it), it->scrl_x,
2540 evas_object_resize(VIEW(it), it->w, it->h);
2541 evas_object_move(VIEW(it), it->scrl_x, it->scrl_y);
2542 evas_object_hide(VIEW(it));
2549 if (!it->dragging && (!it->wd->item_moving_effect_timer)) _item_unrealize(it, EINA_FALSE);
2556 if (vis) it->want_realize = EINA_TRUE;
2558 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))
2560 it->old_scrl_y = it->scrl_y;
2565 if (!itb->wd->reorder_it) itb->minh = minh;
2566 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2567 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2571 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2573 Elm_Genlist_Item *it = data;
2575 it->mincalcd = EINA_FALSE;
2576 it->block->changeme = EINA_TRUE;
2577 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2578 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2582 _group_items_recalc(void *data)
2584 Widget_Data *wd = data;
2586 Elm_Genlist_Item *git;
2588 evas_event_freeze(evas_object_evas_get(wd->obj));
2589 EINA_LIST_FOREACH(wd->group_items, l, git)
2591 if (git->want_realize)
2594 _item_realize(git, 0, EINA_FALSE);
2595 evas_object_resize(VIEW(git), wd->minw, git->h);
2596 evas_object_move(VIEW(git), git->scrl_x, git->scrl_y);
2597 evas_object_show(VIEW(git));
2598 evas_object_raise(VIEW(git));
2600 else if (!git->want_realize && git->realized)
2603 _item_unrealize(git, EINA_FALSE);
2606 evas_event_thaw(evas_object_evas_get(wd->obj));
2607 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2611 _must_recalc_idler(void *data)
2613 Widget_Data *wd = data;
2614 if (wd->calc_job) ecore_job_del(wd->calc_job);
2615 wd->calc_job = ecore_job_add(_calc_job, wd);
2616 wd->must_recalc_idler = NULL;
2617 return ECORE_CALLBACK_CANCEL;
2621 _calc_job(void *data)
2623 Widget_Data *wd = data;
2624 Item_Block *itb, *chb = NULL;
2625 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2628 Eina_Bool minw_change = EINA_FALSE;
2629 Eina_Bool did_must_recalc = EINA_FALSE;
2632 t0 = ecore_time_get();
2633 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2637 evas_event_freeze(evas_object_evas_get(wd->obj));
2638 EINA_INLIST_FOREACH(wd->blocks, itb)
2640 Eina_Bool showme = EINA_FALSE;
2643 showme = itb->showme;
2644 itb->showme = EINA_FALSE;
2647 if (itb->realized) _item_block_unrealize(itb);
2649 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2651 if (itb->must_recalc)
2654 Elm_Genlist_Item *it;
2655 EINA_LIST_FOREACH(itb->items, l, it)
2656 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2657 itb->changed = EINA_TRUE;
2658 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2659 if (itb->realized) _item_block_unrealize(itb);
2660 itb->must_recalc = EINA_FALSE;
2662 showme = _item_block_recalc(itb, in, EINA_FALSE);
2668 if (minw == -1) minw = itb->minw;
2669 else if ((!itb->must_recalc) && (minw < itb->minw))
2672 minw_change = EINA_TRUE;
2678 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2680 wd->show_item->showme = EINA_FALSE;
2682 elm_smart_scroller_region_bring_in(wd->scr,
2684 wd->show_item->block->x,
2686 wd->show_item->block->y,
2687 wd->show_item->block->w,
2690 elm_smart_scroller_child_region_show(wd->scr,
2692 wd->show_item->block->x,
2694 wd->show_item->block->y,
2695 wd->show_item->block->w,
2697 wd->show_item = NULL;
2702 EINA_INLIST_FOREACH(wd->blocks, itb)
2708 if ((chb) && (EINA_INLIST_GET(chb)->next))
2710 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2712 if (itb->realized) _item_block_unrealize(itb);
2715 wd->realminw = minw;
2716 if (minw < wd->w) minw = wd->w;
2717 if ((minw != wd->minw) || (minh != wd->minh))
2721 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2722 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2723 _sizing_eval(wd->obj);
2725 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2727 Elm_Genlist_Item *it;
2730 it = wd->anchor_item;
2731 it_y = wd->anchor_y;
2732 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2733 it->block->y + it->y + it_y);
2734 wd->anchor_item = it;
2735 wd->anchor_y = it_y;
2739 t = ecore_time_get();
2740 if (did_must_recalc)
2742 if (!wd->must_recalc_idler)
2743 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2745 wd->calc_job = NULL;
2746 evas_object_smart_changed(wd->pan_smart);
2747 evas_event_thaw(evas_object_evas_get(wd->obj));
2748 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2752 _update_job(void *data)
2754 Widget_Data *wd = data;
2758 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2760 wd->update_job = NULL;
2763 evas_event_freeze(evas_object_evas_get(wd->obj));
2764 EINA_INLIST_FOREACH(wd->blocks, itb)
2766 Evas_Coord itminw, itminh;
2767 Elm_Genlist_Item *it;
2773 _item_block_position(itb, num);
2777 recalc = EINA_FALSE;
2778 EINA_LIST_FOREACH(itb->items, l2, it)
2787 _item_unrealize(it, EINA_FALSE);
2788 _item_realize(it, num, EINA_FALSE);
2789 position = EINA_TRUE;
2793 _item_realize(it, num, EINA_TRUE);
2794 _item_unrealize(it, EINA_TRUE);
2796 if ((it->minw != itminw) || (it->minh != itminh))
2798 it->updateme = EINA_FALSE;
2802 itb->updateme = EINA_FALSE;
2805 position = EINA_TRUE;
2806 itb->changed = EINA_TRUE;
2807 _item_block_recalc(itb, num0, EINA_FALSE);
2808 _item_block_position(itb, num0);
2813 if (wd->calc_job) ecore_job_del(wd->calc_job);
2814 wd->calc_job = ecore_job_add(_calc_job, wd);
2816 evas_event_thaw(evas_object_evas_get(wd->obj));
2817 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2821 _changed_job(void *data)
2823 Widget_Data *wd = data; Eina_List *l2;
2825 int num, num0, position = 0;
2826 Eina_Bool width_changed = EINA_FALSE, height_changed = EINA_FALSE;
2828 wd->changed_job = NULL;
2830 EINA_INLIST_FOREACH(wd->blocks, itb)
2832 Evas_Coord itminw, itminh;
2833 Elm_Genlist_Item *it;
2839 _item_block_position(itb, num);
2843 width_changed = height_changed = EINA_FALSE;
2844 EINA_LIST_FOREACH(itb->items, l2, it)
2846 if ((!it->mincalcd) && (it->realized))
2848 Evas_Coord mw = -1, mh = -1;
2852 if (it->wd->height_for_width) mw = it->wd->w;
2853 if (!it->display_only)
2854 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2855 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2856 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
2857 if (!it->display_only)
2858 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2859 it->w = it->minw = mw;
2860 it->h = it->minh = mh;
2861 it->mincalcd = EINA_TRUE;
2863 //if ((it->minw != itminw) || (it->minh != itminh))
2864 //if ((it->minh != itminh))
2866 if ((it->minw != itminw))
2867 width_changed = EINA_TRUE;
2868 if ((it->minh != itminh))
2869 height_changed = EINA_TRUE;
2871 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2873 it->wd->group_item_width = mw;
2874 it->wd->group_item_height = mh;
2876 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2878 it->wd->item_width = mw;
2879 it->wd->item_height = mh;
2884 itb->changeme = EINA_FALSE;
2885 // TODO: why this is separated.
2889 itb->changed = EINA_TRUE;
2890 _item_block_recalc(itb, num0, 0);
2891 _item_block_position(itb, num0);
2893 else if (width_changed)
2895 _item_block_position(itb, num0);
2900 if (wd->calc_job) ecore_job_del(wd->calc_job);
2901 wd->calc_job = ecore_job_add(_calc_job, wd);
2906 _pan_set(Evas_Object *obj,
2910 Pan *sd = evas_object_smart_data_get(obj);
2916 // Evas_Coord ow, oh;
2917 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2918 // ow = sd->wd->minw - ow;
2919 // if (ow < 0) ow = 0;
2920 // oh = sd->wd->minh - oh;
2921 // if (oh < 0) oh = 0;
2922 // if (x < 0) x = 0;
2923 // if (y < 0) y = 0;
2924 // if (x > ow) x = ow;
2925 // if (y > oh) y = oh;
2926 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2931 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2933 if ((itb->y + itb->h) > y)
2935 Elm_Genlist_Item *it;
2938 EINA_LIST_FOREACH(itb->items, l2, it)
2940 if ((itb->y + it->y) >= y)
2942 sd->wd->anchor_item = it;
2943 sd->wd->anchor_y = -(itb->y + it->y - y);
2951 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2955 _pan_get(Evas_Object *obj,
2959 Pan *sd = evas_object_smart_data_get(obj);
2962 if (x) *x = sd->wd->pan_x;
2963 if (y) *y = sd->wd->pan_y;
2967 _pan_max_get(Evas_Object *obj,
2971 Pan *sd = evas_object_smart_data_get(obj);
2975 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2976 ow = sd->wd->minw - ow;
2978 oh = sd->wd->minh - oh;
2985 _pan_min_get(Evas_Object *obj __UNUSED__,
2994 _pan_child_size_get(Evas_Object *obj,
2998 Pan *sd = evas_object_smart_data_get(obj);
3001 if (w) *w = sd->wd->minw;
3002 if (h) *h = sd->wd->minh;
3006 _pan_add(Evas_Object *obj)
3009 Evas_Object_Smart_Clipped_Data *cd;
3012 cd = evas_object_smart_data_get(obj);
3015 sd->__clipped_data = *cd;
3017 evas_object_smart_data_set(obj, sd);
3021 _pan_del(Evas_Object *obj)
3023 Pan *sd = evas_object_smart_data_get(obj);
3028 ecore_job_del(sd->resize_job);
3029 sd->resize_job = NULL;
3035 _pan_resize_job(void *data)
3039 _sizing_eval(sd->wd->obj);
3040 sd->resize_job = NULL;
3044 _pan_resize(Evas_Object *obj,
3048 Pan *sd = evas_object_smart_data_get(obj);
3052 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
3053 if ((ow == w) && (oh == h)) return;
3054 if ((sd->wd->height_for_width) && (ow != w))
3056 sd->wd->pan_resize = EINA_TRUE;
3057 if (sd->resize_job) ecore_job_del(sd->resize_job);
3058 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
3060 sd->wd->pan_changed = EINA_TRUE;
3061 evas_object_smart_changed(obj);
3062 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3063 sd->wd->calc_job = NULL;
3067 _pan_calculate(Evas_Object *obj)
3069 Pan *sd = evas_object_smart_data_get(obj);
3071 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
3073 Elm_Genlist_Item *git;
3077 evas_event_freeze(evas_object_evas_get(obj));
3079 if (sd->wd->pan_changed)
3082 sd->wd->pan_changed = EINA_FALSE;
3085 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3086 sd->wd->prev_viewport_w = ow;
3087 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
3088 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
3090 git->want_realize = EINA_FALSE;
3092 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
3094 itb->w = sd->wd->minw;
3095 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
3096 itb->y - sd->wd->pan_y + oy,
3098 cvx, cvy, cvw, cvh))
3100 if ((!itb->realized) || (itb->changed))
3101 _item_block_realize(itb);
3102 _item_block_position(itb, in);
3106 if (itb->realized) _item_block_unrealize(itb);
3110 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
3111 _group_items_recalc(sd->wd);
3113 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
3115 if (sd->wd->pan_y != sd->wd->old_pan_y)
3116 sd->wd->reorder_pan_move = EINA_TRUE;
3117 else sd->wd->reorder_pan_move = EINA_FALSE;
3118 evas_object_raise(sd->wd->reorder_it->edit_obj);
3119 sd->wd->old_pan_y = sd->wd->pan_y;
3120 sd->wd->start_time = ecore_loop_time_get();
3123 if (sd->wd->effect_mode &&
3124 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
3125 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
3126 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
3128 if (!sd->wd->item_moving_effect_timer)
3130 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
3131 _item_flip_effect_show(sd->wd->expand_item);
3133 evas_object_raise(sd->wd->alpha_bg);
3134 evas_object_show(sd->wd->alpha_bg);
3135 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
3136 sd->wd->start_time = current_time_get();
3137 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
3140 else _item_auto_scroll(sd->wd);
3141 sd->wd->pan_resize = EINA_FALSE;
3142 evas_event_thaw(evas_object_evas_get(obj));
3143 evas_event_thaw_eval(evas_object_evas_get(obj));
3147 _pan_move(Evas_Object *obj,
3148 Evas_Coord x __UNUSED__,
3149 Evas_Coord y __UNUSED__)
3151 Pan *sd = evas_object_smart_data_get(obj);
3155 sd->wd->pan_changed = EINA_TRUE;
3156 evas_object_smart_changed(obj);
3157 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3158 sd->wd->calc_job = NULL;
3162 _hold_on(void *data __UNUSED__,
3164 void *event_info __UNUSED__)
3166 Widget_Data *wd = elm_widget_data_get(obj);
3168 elm_smart_scroller_hold_set(wd->scr, 1);
3172 _hold_off(void *data __UNUSED__,
3174 void *event_info __UNUSED__)
3176 Widget_Data *wd = elm_widget_data_get(obj);
3178 elm_smart_scroller_hold_set(wd->scr, 0);
3182 _freeze_on(void *data __UNUSED__,
3184 void *event_info __UNUSED__)
3186 Widget_Data *wd = elm_widget_data_get(obj);
3188 elm_smart_scroller_freeze_set(wd->scr, 1);
3192 _freeze_off(void *data __UNUSED__,
3194 void *event_info __UNUSED__)
3196 Widget_Data *wd = elm_widget_data_get(obj);
3198 elm_smart_scroller_freeze_set(wd->scr, 0);
3202 _scr_anim_start(void *data,
3203 Evas_Object *obj __UNUSED__,
3204 void *event_info __UNUSED__)
3206 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
3210 _scr_anim_stop(void *data,
3211 Evas_Object *obj __UNUSED__,
3212 void *event_info __UNUSED__)
3214 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
3218 _scr_drag_start(void *data,
3219 Evas_Object *obj __UNUSED__,
3220 void *event_info __UNUSED__)
3222 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
3226 _scr_drag_stop(void *data,
3227 Evas_Object *obj __UNUSED__,
3228 void *event_info __UNUSED__)
3230 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
3234 _scroll_edge_left(void *data,
3235 Evas_Object *scr __UNUSED__,
3236 void *event_info __UNUSED__)
3238 Evas_Object *obj = data;
3239 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
3243 _scroll_edge_right(void *data,
3244 Evas_Object *scr __UNUSED__,
3245 void *event_info __UNUSED__)
3247 Evas_Object *obj = data;
3248 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
3252 _scroll_edge_top(void *data,
3253 Evas_Object *scr __UNUSED__,
3254 void *event_info __UNUSED__)
3256 Evas_Object *obj = data;
3257 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
3261 _scroll_edge_bottom(void *data,
3262 Evas_Object *scr __UNUSED__,
3263 void *event_info __UNUSED__)
3265 Evas_Object *obj = data;
3266 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
3270 _mode_item_realize(Elm_Genlist_Item *it)
3274 if ((it->mode_view) || (it->delete_me)) return;
3276 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3277 it->mode_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
3278 edje_object_scale_set(it->mode_view,
3279 elm_widget_scale_get(WIDGET(it)) *
3280 _elm_config->scale);
3281 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
3282 elm_widget_sub_object_add(WIDGET(it), it->mode_view);
3284 strncpy(buf, "item", sizeof(buf));
3285 if (it->wd->compress)
3286 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3288 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3289 strncat(buf, "/", sizeof(buf) - strlen(buf));
3290 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3292 _elm_theme_object_set(WIDGET(it), it->mode_view, "genlist", buf,
3293 elm_widget_style_get(WIDGET(it)));
3294 edje_object_mirrored_set(it->mode_view,
3295 elm_widget_mirrored_get(WIDGET(it)));
3297 /* signal callback add */
3298 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3300 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3302 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3305 /* label_get, icon_get, state_get */
3306 _item_label_realize(it, it->mode_view, &it->mode_labels, NULL);
3307 if (it->itc->func.icon_get)
3313 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3315 EINA_LIST_FOREACH(it->mode_icons, l, key)
3317 Evas_Object *ic = it->itc->func.icon_get
3318 ((void *)it->base.data, WIDGET(it), l->data);
3322 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
3323 edje_object_part_swallow(it->mode_view, key, ic);
3324 evas_object_show(ic);
3325 elm_widget_sub_object_add(WIDGET(it), ic);
3327 elm_widget_disabled_set(ic, EINA_TRUE);
3331 _item_state_realize(it, it->mode_view, &it->mode_states, NULL);
3332 edje_object_part_swallow(it->mode_view,
3333 edje_object_data_get(it->mode_view, "mode_part"),
3336 it->want_unrealize = EINA_FALSE;
3337 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3338 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3342 _mode_item_unrealize(Elm_Genlist_Item *it)
3344 Widget_Data *wd = it->wd;
3346 if (!it->mode_view) return;
3348 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3349 elm_widget_stringlist_free(it->mode_labels);
3350 it->mode_labels = NULL;
3351 elm_widget_stringlist_free(it->mode_icons);
3352 it->mode_icons = NULL;
3353 elm_widget_stringlist_free(it->mode_states);
3355 EINA_LIST_FREE(it->mode_icon_objs, icon)
3356 evas_object_del(icon);
3358 edje_object_part_unswallow(it->mode_view, VIEW(it));
3359 evas_object_smart_member_add(VIEW(it), wd->pan_smart);
3360 evas_object_del(it->mode_view);
3361 it->mode_view = NULL;
3363 if (wd->mode_item == it)
3364 wd->mode_item = NULL;
3365 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3366 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3370 _item_mode_set(Elm_Genlist_Item *it)
3373 Widget_Data *wd = it->wd;
3378 it->nocache = EINA_TRUE;
3380 if (wd->scr_hold_timer)
3382 ecore_timer_del(wd->scr_hold_timer);
3383 wd->scr_hold_timer = NULL;
3385 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3386 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3388 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3389 _mode_item_realize(it);
3391 evas_object_raise(it->VIEW(group_item));
3392 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
3393 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3394 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3396 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3397 edje_object_signal_emit(it->mode_view, buf, "elm");
3401 _item_mode_unset(Widget_Data *wd)
3404 if (!wd->mode_item) return;
3405 char buf[1024], buf2[1024];
3406 Elm_Genlist_Item *it;
3409 it->nocache = EINA_TRUE;
3411 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3412 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3414 edje_object_signal_emit(it->mode_view, buf, "elm");
3415 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3417 wd->mode_item = NULL;
3422 _item_auto_scroll(void *data)
3424 Widget_Data *wd = data;
3427 if ((wd->expand_item) && (!wd->auto_scrolled))
3429 Elm_Genlist_Item *it;
3431 Evas_Coord ox, oy, ow, oh;
3432 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3434 wd->auto_scrolled = EINA_TRUE;
3435 if (wd->expand_item->scrl_y > (oh + oy) / 2)
3437 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
3439 elm_genlist_item_bring_in(it);
3445 elm_genlist_add(Evas_Object *parent)
3450 Evas_Coord minw, minh;
3451 static Evas_Smart *smart = NULL;
3455 static Evas_Smart_Class sc;
3457 evas_object_smart_clipped_smart_set(&_pan_sc);
3459 sc.name = "elm_genlist_pan";
3460 sc.version = EVAS_SMART_CLASS_VERSION;
3463 sc.resize = _pan_resize;
3464 sc.move = _pan_move;
3465 sc.calculate = _pan_calculate;
3466 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3469 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3471 ELM_SET_WIDTYPE(widtype, "genlist");
3472 elm_widget_type_set(obj, "genlist");
3473 elm_widget_sub_object_add(parent, obj);
3474 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3475 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3476 elm_widget_data_set(obj, wd);
3477 elm_widget_del_hook_set(obj, _del_hook);
3478 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3479 elm_widget_theme_hook_set(obj, _theme_hook);
3480 elm_widget_can_focus_set(obj, EINA_TRUE);
3481 elm_widget_event_hook_set(obj, _event_hook);
3482 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3483 elm_widget_translate_hook_set(obj, _translate_hook);
3485 wd->scr = elm_smart_scroller_add(e);
3486 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_DOWN,
3487 _mouse_down_scroller, obj);
3488 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_UP,
3489 _mouse_up_scroller, obj);
3490 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_MOVE,
3491 _mouse_move_scroller, obj);
3492 elm_smart_scroller_widget_set(wd->scr, obj);
3493 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3494 elm_widget_style_get(obj));
3495 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3496 _elm_config->thumbscroll_bounce_enable);
3497 elm_widget_resize_object_set(obj, wd->scr);
3499 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3500 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3501 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3502 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3503 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3504 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3506 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3507 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3511 wd->mode = ELM_LIST_SCROLL;
3512 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3513 wd->item_cache_max = wd->max_items_per_block * 2;
3514 wd->longpress_timeout = _elm_config->longpress_timeout;
3515 wd->effect_mode = _elm_config->effect_enable;
3517 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3518 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3519 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3520 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3522 wd->pan_smart = evas_object_smart_add(e, smart);
3523 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3526 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3527 _pan_set, _pan_get, _pan_max_get,
3528 _pan_min_get, _pan_child_size_get);
3530 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3532 evas_object_size_hint_min_set(obj, minw, minh);
3534 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3535 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3540 static Elm_Genlist_Item *
3541 _item_new(Widget_Data *wd,
3542 const Elm_Genlist_Item_Class *itc,
3544 Elm_Genlist_Item *parent,
3545 Elm_Genlist_Item_Flags flags,
3547 const void *func_data)
3549 Elm_Genlist_Item *it;
3551 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3552 if (!it) return NULL;
3555 it->base.data = data;
3556 it->parent = parent;
3558 it->func.func = func;
3559 it->func.data = func_data;
3560 it->mouse_cursor = NULL;
3561 it->expanded_depth = 0;
3562 elm_widget_item_text_get_hook_set(it, _item_label_hook);
3563 elm_widget_item_del_cb_set(it, _item_del_hook);
3567 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3568 it->group_item = parent;
3569 else if (it->parent->group_item)
3570 it->group_item = it->parent->group_item;
3576 _item_block_add(Widget_Data *wd,
3577 Elm_Genlist_Item *it)
3579 Item_Block *itb = NULL;
3586 itb = calloc(1, sizeof(Item_Block));
3589 if (!it->rel->block)
3592 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3593 itb->items = eina_list_append(itb->items, it);
3599 wd->blocks = eina_inlist_prepend_relative
3600 (wd->blocks, EINA_INLIST_GET(itb),
3601 EINA_INLIST_GET(it->rel->block));
3603 eina_list_prepend_relative(itb->items, it, it->rel);
3607 wd->blocks = eina_inlist_append_relative
3608 (wd->blocks, EINA_INLIST_GET(itb),
3609 EINA_INLIST_GET(it->rel->block));
3611 eina_list_append_relative(itb->items, it, it->rel);
3621 itb = (Item_Block *)(wd->blocks);
3622 if (itb->count >= wd->max_items_per_block)
3624 itb = calloc(1, sizeof(Item_Block));
3628 eina_inlist_prepend(wd->blocks,
3629 EINA_INLIST_GET(itb));
3634 itb = calloc(1, sizeof(Item_Block));
3638 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3640 itb->items = eina_list_prepend(itb->items, it);
3646 itb = (Item_Block *)(wd->blocks->last);
3647 if (itb->count >= wd->max_items_per_block)
3649 itb = calloc(1, sizeof(Item_Block));
3653 eina_inlist_append(wd->blocks,
3654 EINA_INLIST_GET(itb));
3659 itb = calloc(1, sizeof(Item_Block));
3663 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3665 itb->items = eina_list_append(itb->items, it);
3671 itb = it->rel->block;
3672 if (!itb) goto newblock;
3674 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3676 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3679 itb->changed = EINA_TRUE;
3681 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3682 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3685 it->rel->relcount--;
3686 if ((it->rel->delete_me) && (!it->rel->relcount))
3690 if (itb->count > itb->wd->max_items_per_block)
3694 Elm_Genlist_Item *it2;
3696 newc = itb->count / 2;
3697 itb2 = calloc(1, sizeof(Item_Block));
3701 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3702 EINA_INLIST_GET(itb));
3703 itb2->changed = EINA_TRUE;
3704 while ((itb->count > newc) && (itb->items))
3708 l = eina_list_last(itb->items);
3710 itb->items = eina_list_remove_list(itb->items, l);
3713 itb2->items = eina_list_prepend(itb2->items, it2);
3721 _queue_process(Widget_Data *wd)
3724 Eina_Bool showme = EINA_FALSE;
3727 t0 = ecore_time_get();
3728 //evas_event_freeze(evas_object_evas_get(wd->obj));
3729 for (n = 0; (wd->queue) && (n < 128); n++)
3731 Elm_Genlist_Item *it;
3733 it = wd->queue->data;
3734 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3735 it->queued = EINA_FALSE;
3736 _item_block_add(wd, it);
3737 t = ecore_time_get();
3738 if (it->block->changed)
3740 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3741 it->block->changed = 0;
3744 if (wd->calc_job) ecore_job_del(wd->calc_job);
3745 wd->calc_job = NULL;
3747 wd->pan_changed = EINA_FALSE;
3750 if (showme) it->block->showme = EINA_TRUE;
3751 if (eina_inlist_count(wd->blocks) > 1)
3753 if ((t - t0) > (ecore_animator_frametime_get())) break;
3756 //evas_event_thaw(evas_object_evas_get(wd->obj));
3757 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3762 _idle_process(void *data, Eina_Bool *wakeup)
3764 Widget_Data *wd = data;
3767 //static double q_start = 0.0;
3768 //if (q_start == 0.0) q_start = ecore_time_get();
3770 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3774 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3776 return ECORE_CALLBACK_CANCEL;
3778 return ECORE_CALLBACK_RENEW;
3782 _item_idle_enterer(void *data)
3784 Widget_Data *wd = data;
3785 Eina_Bool wakeup = EINA_FALSE;
3786 Eina_Bool ok = _idle_process(data, &wakeup);
3791 if (wd->calc_job) ecore_job_del(wd->calc_job);
3792 wd->calc_job = ecore_job_add(_calc_job, wd);
3794 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3799 _item_queue(Widget_Data *wd,
3800 Elm_Genlist_Item *it)
3802 if (it->queued) return;
3803 it->queued = EINA_TRUE;
3804 wd->queue = eina_list_append(wd->queue, it);
3805 // FIXME: why does a freeze then thaw here cause some genlist
3806 // elm_genlist_item_append() to be much much slower?
3807 // evas_event_freeze(evas_object_evas_get(wd->obj));
3808 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3810 if (wd->queue_idle_enterer)
3812 ecore_idle_enterer_del(wd->queue_idle_enterer);
3813 wd->queue_idle_enterer = NULL;
3817 // evas_event_thaw(evas_object_evas_get(wd->obj));
3818 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3819 if (!wd->queue_idle_enterer)
3820 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3824 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3829 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3830 it->wd->reorder_deleted = EINA_TRUE;
3831 _item_block_del(it);
3833 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3835 it->rel->relcount++;
3836 it->before = EINA_FALSE;
3837 if (after->group_item) it->group_item = after->group_item;
3838 _item_queue(it->wd, it);
3840 // TODO: change this to smart callback
3841 if (it->itc->func.moved)
3842 it->itc->func.moved(WIDGET(it), it, after, EINA_TRUE);
3846 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3849 if (!before) return;
3851 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3852 it->wd->reorder_deleted = EINA_TRUE;
3853 _item_block_del(it);
3854 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3856 it->rel->relcount++;
3857 it->before = EINA_TRUE;
3858 if (before->group_item) it->group_item = before->group_item;
3859 _item_queue(it->wd, it);
3861 // TODO: change this to smart callback
3862 if (it->itc->func.moved)
3863 it->itc->func.moved(WIDGET(it), it, before, EINA_FALSE);
3866 EAPI Elm_Genlist_Item *
3867 elm_genlist_item_append(Evas_Object *obj,
3868 const Elm_Genlist_Item_Class *itc,
3870 Elm_Genlist_Item *parent,
3871 Elm_Genlist_Item_Flags flags,
3873 const void *func_data)
3875 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3876 Widget_Data *wd = elm_widget_data_get(obj);
3877 if (!wd) return NULL;
3878 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3880 if (!it) return NULL;
3883 if (flags & ELM_GENLIST_ITEM_GROUP)
3884 wd->group_items = eina_list_append(wd->group_items, it);
3885 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3890 Elm_Genlist_Item *it2 = NULL;
3891 Eina_List *ll = eina_list_last(it->parent->items);
3892 if (ll) it2 = ll->data;
3893 it->parent->items = eina_list_append(it->parent->items, it);
3894 if (!it2) it2 = it->parent;
3896 it2 = elm_genlist_item_prev_get(it2);
3898 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3899 EINA_INLIST_GET(it2));
3901 it->rel->relcount++;
3903 it->before = EINA_FALSE;
3904 _item_queue(wd, it);
3908 EAPI Elm_Genlist_Item *
3909 elm_genlist_item_prepend(Evas_Object *obj,
3910 const Elm_Genlist_Item_Class *itc,
3912 Elm_Genlist_Item *parent,
3913 Elm_Genlist_Item_Flags flags,
3915 const void *func_data)
3917 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3918 Widget_Data *wd = elm_widget_data_get(obj);
3919 if (!wd) return NULL;
3920 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3923 if (!it) return NULL;
3926 if (flags & ELM_GENLIST_ITEM_GROUP)
3927 wd->group_items = eina_list_prepend(wd->group_items, it);
3928 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3933 Elm_Genlist_Item *it2 = NULL;
3934 Eina_List *ll = it->parent->items;
3935 if (ll) it2 = ll->data;
3936 it->parent->items = eina_list_prepend(it->parent->items, it);
3937 if (!it2) it2 = it->parent;
3939 it2 = elm_genlist_item_next_get(it2);
3941 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3942 EINA_INLIST_GET(it2));
3944 it->rel->relcount++;
3946 it->before = EINA_TRUE;
3947 _item_queue(wd, it);
3951 EAPI Elm_Genlist_Item *
3952 elm_genlist_item_insert_after(Evas_Object *obj,
3953 const Elm_Genlist_Item_Class *itc,
3955 Elm_Genlist_Item *parent,
3956 Elm_Genlist_Item *after,
3957 Elm_Genlist_Item_Flags flags,
3959 const void *func_data)
3961 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3962 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3963 Widget_Data *wd = elm_widget_data_get(obj);
3964 if (!wd) return NULL;
3965 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3967 if (!it) return NULL;
3968 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3969 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3973 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3974 (after->flags & ELM_GENLIST_ITEM_GROUP))
3975 wd->group_items = eina_list_append_relative(wd->group_items, it,
3980 it->parent->items = eina_list_append_relative(it->parent->items, it,
3983 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3984 EINA_INLIST_GET(after));
3986 it->rel->relcount++;
3987 it->before = EINA_FALSE;
3988 _item_queue(wd, it);
3992 EAPI Elm_Genlist_Item *
3993 elm_genlist_item_insert_before(Evas_Object *obj,
3994 const Elm_Genlist_Item_Class *itc,
3996 Elm_Genlist_Item *parent,
3997 Elm_Genlist_Item *before,
3998 Elm_Genlist_Item_Flags flags,
4000 const void *func_data)
4002 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4003 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
4004 Widget_Data *wd = elm_widget_data_get(obj);
4005 if (!wd) return NULL;
4006 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
4008 if (!it) return NULL;
4009 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
4010 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4014 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
4015 (before->flags & ELM_GENLIST_ITEM_GROUP))
4016 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
4021 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
4024 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4025 EINA_INLIST_GET(before));
4027 it->rel->relcount++;
4028 it->before = EINA_TRUE;
4029 _item_queue(wd, it);
4034 elm_genlist_clear(Evas_Object *obj)
4036 ELM_CHECK_WIDTYPE(obj, widtype);
4037 Widget_Data *wd = elm_widget_data_get(obj);
4039 if (wd->walking > 0)
4041 Elm_Genlist_Item *it;
4043 wd->clear_me = EINA_TRUE;
4044 EINA_INLIST_FOREACH(wd->items, it)
4046 it->delete_me = EINA_TRUE;
4050 evas_event_freeze(evas_object_evas_get(wd->obj));
4053 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4054 it->nocache = EINA_TRUE;
4055 it->highlighted = EINA_FALSE;
4057 if (wd->anchor_item == it)
4059 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4060 if (!wd->anchor_item)
4062 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4065 wd->items = eina_inlist_remove(wd->items, wd->items);
4066 if (it->flags & ELM_GENLIST_ITEM_GROUP)
4067 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
4068 elm_widget_item_pre_notify_del(it);
4069 if (it->realized) _item_unrealize(it, EINA_FALSE);
4070 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
4071 it->itc->func.del((void *)it->base.data, WIDGET(it));
4072 if (it->long_timer) ecore_timer_del(it->long_timer);
4073 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
4074 elm_widget_item_del(it);
4076 wd->clear_me = EINA_FALSE;
4077 wd->anchor_item = NULL;
4080 Item_Block *itb = (Item_Block *)(wd->blocks);
4082 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
4083 if (itb->items) eina_list_free(itb->items);
4086 wd->pan_changed = EINA_TRUE;
4089 ecore_job_del(wd->calc_job);
4090 wd->calc_job = NULL;
4092 if (wd->queue_idle_enterer)
4094 ecore_idle_enterer_del(wd->queue_idle_enterer);
4095 wd->queue_idle_enterer = NULL;
4097 if (wd->must_recalc_idler)
4099 ecore_idler_del(wd->must_recalc_idler);
4100 wd->must_recalc_idler = NULL;
4104 eina_list_free(wd->queue);
4109 eina_list_free(wd->selected);
4110 wd->selected = NULL;
4112 if (wd->reorder_move_animator)
4114 ecore_animator_del(wd->reorder_move_animator);
4115 wd->reorder_move_animator = NULL;
4117 wd->show_item = NULL;
4125 evas_object_del(wd->alpha_bg);
4126 wd->alpha_bg = NULL;
4130 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4131 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4134 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
4135 evas_event_thaw(evas_object_evas_get(wd->obj));
4136 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4140 elm_genlist_multi_select_set(Evas_Object *obj,
4143 ELM_CHECK_WIDTYPE(obj, widtype);
4144 Widget_Data *wd = elm_widget_data_get(obj);
4150 elm_genlist_multi_select_get(const Evas_Object *obj)
4152 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4153 Widget_Data *wd = elm_widget_data_get(obj);
4154 if (!wd) return EINA_FALSE;
4158 EAPI Elm_Genlist_Item *
4159 elm_genlist_selected_item_get(const Evas_Object *obj)
4161 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4162 Widget_Data *wd = elm_widget_data_get(obj);
4163 if (!wd) return NULL;
4164 if (wd->selected) return wd->selected->data;
4168 EAPI const Eina_List *
4169 elm_genlist_selected_items_get(const Evas_Object *obj)
4171 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4172 Widget_Data *wd = elm_widget_data_get(obj);
4173 if (!wd) return NULL;
4174 return wd->selected;
4178 elm_genlist_realized_items_get(const Evas_Object *obj)
4180 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4181 Widget_Data *wd = elm_widget_data_get(obj);
4182 Eina_List *list = NULL;
4184 Eina_Bool done = EINA_FALSE;
4185 if (!wd) return NULL;
4186 EINA_INLIST_FOREACH(wd->blocks, itb)
4191 Elm_Genlist_Item *it;
4194 EINA_LIST_FOREACH(itb->items, l, it)
4196 if (it->realized) list = eina_list_append(list, it);
4207 EAPI Elm_Genlist_Item *
4208 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4213 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4214 Widget_Data *wd = elm_widget_data_get(obj);
4215 Evas_Coord ox, oy, ow, oh;
4218 if (!wd) return NULL;
4219 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4221 EINA_INLIST_FOREACH(wd->blocks, itb)
4224 Elm_Genlist_Item *it;
4226 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4227 oy + itb->y - itb->wd->pan_y,
4228 itb->w, itb->h, x, y, 1, 1))
4230 EINA_LIST_FOREACH(itb->items, l, it)
4232 Evas_Coord itx, ity;
4234 itx = ox + itb->x + it->x - itb->wd->pan_x;
4235 ity = oy + itb->y + it->y - itb->wd->pan_y;
4236 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4240 if (y <= (ity + (it->h / 4))) *posret = -1;
4241 else if (y >= (ity + it->h - (it->h / 4)))
4247 lasty = ity + it->h;
4252 if (y > lasty) *posret = 1;
4258 EAPI Elm_Genlist_Item *
4259 elm_genlist_first_item_get(const Evas_Object *obj)
4261 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4262 Widget_Data *wd = elm_widget_data_get(obj);
4263 if (!wd) return NULL;
4264 if (!wd->items) return NULL;
4265 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4266 while ((it) && (it->delete_me))
4267 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4271 EAPI Elm_Genlist_Item *
4272 elm_genlist_last_item_get(const Evas_Object *obj)
4274 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4275 Widget_Data *wd = elm_widget_data_get(obj);
4276 if (!wd) return NULL;
4277 if (!wd->items) return NULL;
4278 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4279 while ((it) && (it->delete_me))
4280 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4284 EAPI Elm_Genlist_Item *
4285 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4287 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4290 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4291 if ((it) && (!it->delete_me)) break;
4293 return (Elm_Genlist_Item *)it;
4296 EAPI Elm_Genlist_Item *
4297 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4299 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4302 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4303 if ((it) && (!it->delete_me)) break;
4305 return (Elm_Genlist_Item *)it;
4309 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4311 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4315 EAPI Elm_Genlist_Item *
4316 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4318 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4323 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4325 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4326 Elm_Genlist_Item *it2;
4329 if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4330 _item_subitems_clear(it);
4333 if ((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4334 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4336 it->wd->expand_item = it;
4337 _item_flip_effect_show(it);
4338 evas_object_geometry_get(VIEW(it), NULL, &y, NULL, &h);
4339 it->wd->expand_item_end = y + h;
4343 it2 = elm_genlist_item_next_get(it2);
4345 } while (it2->expanded_depth > it->expanded_depth);
4347 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4349 it->wd->expand_item_gap = 0;
4351 evas_object_raise(it->wd->alpha_bg);
4352 evas_object_show(it->wd->alpha_bg);
4354 it->wd->start_time = current_time_get();
4355 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4358 _item_subitems_clear(it);
4363 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4366 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4367 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
4369 if ((it->delete_me) || (it->disabled)) return;
4370 selected = !!selected;
4371 if (it->selected == selected) return;
4377 while (wd->selected)
4378 _item_unselect(wd->selected->data);
4380 _item_highlight(it);
4388 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4390 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4391 return it->selected;
4395 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4398 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4399 if (it->flags != ELM_GENLIST_ITEM_SUBITEMS) return;
4400 if (it->expanded == expanded) return;
4401 it->expanded = expanded;
4402 it->wd->expand_item = it;
4404 if (it->wd->effect_mode && !it->wd->alpha_bg)
4405 it->wd->alpha_bg = _create_tray_alpha_bg(WIDGET(it));
4409 it->wd->auto_scrolled = EINA_FALSE;
4410 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4412 edje_object_signal_emit(VIEW(it), "elm,state,expanded", "elm");
4413 evas_object_smart_callback_call(WIDGET(it), "expanded", it);
4417 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4419 edje_object_signal_emit(VIEW(it), "elm,state,contracted", "elm");
4420 evas_object_smart_callback_call(WIDGET(it), "contracted", it);
4425 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4427 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4428 return it->expanded;
4432 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4434 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4435 return it->expanded_depth;
4439 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4442 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4445 if (it->disabled == disabled) return;
4446 if (it->delete_me) return;
4447 it->disabled = !!disabled;
4449 elm_genlist_item_selected_set(it, EINA_FALSE);
4454 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
4456 edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
4460 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
4462 edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
4464 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4465 elm_widget_disabled_set(obj, disabled);
4470 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4472 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4473 if (it->delete_me) return EINA_FALSE;
4474 return it->disabled;
4478 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4479 Eina_Bool display_only)
4481 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4482 if (it->display_only == display_only) return;
4483 if (it->delete_me) return;
4484 it->display_only = display_only;
4485 it->mincalcd = EINA_FALSE;
4486 it->updateme = EINA_TRUE;
4487 if (it->block) it->block->updateme = EINA_TRUE;
4488 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4489 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4493 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4495 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4496 if (it->delete_me) return EINA_FALSE;
4497 return it->display_only;
4501 elm_genlist_item_show(Elm_Genlist_Item *it)
4503 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4504 Evas_Coord gith = 0;
4505 if (it->delete_me) return;
4506 if ((it->queued) || (!it->mincalcd))
4508 it->wd->show_item = it;
4509 it->wd->bring_in = EINA_TRUE;
4510 it->showme = EINA_TRUE;
4513 if (it->wd->show_item)
4515 it->wd->show_item->showme = EINA_FALSE;
4516 it->wd->show_item = NULL;
4518 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4519 gith = it->group_item->h;
4520 elm_smart_scroller_child_region_show(it->wd->scr,
4521 it->x + it->block->x,
4522 it->y + it->block->y - gith,
4523 it->block->w, it->h);
4527 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4529 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4530 Evas_Coord gith = 0;
4531 if (it->delete_me) return;
4532 if ((it->queued) || (!it->mincalcd))
4534 it->wd->show_item = it;
4535 it->wd->bring_in = EINA_TRUE;
4536 it->showme = EINA_TRUE;
4539 if (it->wd->show_item)
4541 it->wd->show_item->showme = EINA_FALSE;
4542 it->wd->show_item = NULL;
4544 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4545 gith = it->group_item->h;
4546 elm_smart_scroller_region_bring_in(it->wd->scr,
4547 it->x + it->block->x,
4548 it->y + it->block->y - gith,
4549 it->block->w, it->h);
4553 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4555 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4557 Evas_Coord gith = 0;
4559 if (it->delete_me) return;
4560 if ((it->queued) || (!it->mincalcd))
4562 it->wd->show_item = it;
4563 it->wd->bring_in = EINA_TRUE;
4564 it->showme = EINA_TRUE;
4567 if (it->wd->show_item)
4569 it->wd->show_item->showme = EINA_FALSE;
4570 it->wd->show_item = NULL;
4572 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4573 if (it->group_item) gith = it->group_item->h;
4574 elm_smart_scroller_child_region_show(it->wd->scr,
4575 it->x + it->block->x,
4576 it->y + it->block->y - gith,
4581 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4583 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4585 Evas_Coord gith = 0;
4587 if (it->delete_me) return;
4588 if ((it->queued) || (!it->mincalcd))
4590 it->wd->show_item = it;
4591 it->wd->bring_in = EINA_TRUE;
4592 it->showme = EINA_TRUE;
4595 if (it->wd->show_item)
4597 it->wd->show_item->showme = EINA_FALSE;
4598 it->wd->show_item = NULL;
4600 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4601 if (it->group_item) gith = it->group_item->h;
4602 elm_smart_scroller_region_bring_in(it->wd->scr,
4603 it->x + it->block->x,
4604 it->y + it->block->y - gith,
4609 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4611 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4614 if (it->delete_me) return;
4615 if ((it->queued) || (!it->mincalcd))
4617 it->wd->show_item = it;
4618 it->wd->bring_in = EINA_TRUE;
4619 it->showme = EINA_TRUE;
4622 if (it->wd->show_item)
4624 it->wd->show_item->showme = EINA_FALSE;
4625 it->wd->show_item = NULL;
4627 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4628 elm_smart_scroller_child_region_show(it->wd->scr,
4629 it->x + it->block->x,
4630 it->y + it->block->y - oh / 2 +
4631 it->h / 2, it->block->w, oh);
4635 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4637 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4640 if (it->delete_me) return;
4641 if ((it->queued) || (!it->mincalcd))
4643 it->wd->show_item = it;
4644 it->wd->bring_in = EINA_TRUE;
4645 it->showme = EINA_TRUE;
4648 if (it->wd->show_item)
4650 it->wd->show_item->showme = EINA_FALSE;
4651 it->wd->show_item = NULL;
4653 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4654 elm_smart_scroller_region_bring_in(it->wd->scr,
4655 it->x + it->block->x,
4656 it->y + it->block->y - oh / 2 + it->h / 2,
4661 elm_genlist_item_del(Elm_Genlist_Item *it)
4663 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4664 if ((it->relcount > 0) || (it->walking > 0))
4666 elm_widget_item_pre_notify_del(it);
4667 elm_genlist_item_subitems_clear(it);
4668 it->delete_me = EINA_TRUE;
4669 if (it->wd->show_item == it) it->wd->show_item = NULL;
4671 it->wd->selected = eina_list_remove(it->wd->selected,
4675 if (it->realized) _item_unrealize(it, EINA_FALSE);
4676 it->block->changed = EINA_TRUE;
4677 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4678 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4680 if (it->itc->func.del)
4681 it->itc->func.del((void *)it->base.data, WIDGET(it));
4688 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4691 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4692 elm_widget_item_data_set(it, data);
4693 elm_genlist_item_update(it);
4697 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4699 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4700 return elm_widget_item_data_get(it);
4704 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4707 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4708 EINA_LIST_FREE(it->icon_objs, icon)
4710 elm_widget_sub_object_del(WIDGET(it), icon);
4711 evas_object_smart_member_del(icon);
4712 evas_object_hide(icon);
4716 EAPI const Evas_Object *
4717 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4719 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4724 elm_genlist_item_update(Elm_Genlist_Item *it)
4726 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4727 if (!it->block) return;
4728 if (it->delete_me) return;
4729 it->mincalcd = EINA_FALSE;
4730 it->updateme = EINA_TRUE;
4731 it->block->updateme = EINA_TRUE;
4732 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4733 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4734 it->defer_unrealize = EINA_FALSE;
4738 elm_genlist_item_fields_update(Elm_Genlist_Item *it,
4740 Elm_Genlist_Item_Field_Flags itf)
4742 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4743 if (!it->block) return;
4744 if (it->delete_me) return;
4746 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_LABEL))
4747 _item_label_realize(it, VIEW(it), &it->labels, parts);
4748 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_ICON))
4750 it->icon_objs = _item_icon_unrealize(it, VIEW(it),
4752 it->icon_objs = _item_icon_realize(it, VIEW(it),
4755 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
4756 _item_state_realize(it, VIEW(it), &it->states, parts);
4760 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4761 const Elm_Genlist_Item_Class *itc)
4763 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4764 if (!it->block) return;
4765 EINA_SAFETY_ON_NULL_RETURN(itc);
4766 if (it->delete_me) return;
4768 it->nocache = EINA_TRUE;
4769 elm_genlist_item_update(it);
4772 EAPI const Elm_Genlist_Item_Class *
4773 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4775 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4776 if (it->delete_me) return NULL;
4779 static Evas_Object *
4780 _elm_genlist_item_label_create(void *data,
4782 void *item __UNUSED__)
4784 Evas_Object *label = elm_label_add(obj);
4787 elm_object_style_set(label, "tooltip");
4788 elm_object_text_set(label, data);
4793 _elm_genlist_item_label_del_cb(void *data,
4794 Evas_Object *obj __UNUSED__,
4795 void *event_info __UNUSED__)
4797 eina_stringshare_del(data);
4801 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4804 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4805 text = eina_stringshare_add(text);
4806 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4808 _elm_genlist_item_label_del_cb);
4812 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4813 Elm_Tooltip_Item_Content_Cb func,
4815 Evas_Smart_Cb del_cb)
4817 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4819 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4822 if (item->tooltip.del_cb)
4823 item->tooltip.del_cb((void *)item->tooltip.data,
4824 item->base.widget, item);
4826 item->tooltip.content_cb = func;
4827 item->tooltip.data = data;
4828 item->tooltip.del_cb = del_cb;
4832 elm_widget_item_tooltip_content_cb_set(item,
4833 item->tooltip.content_cb,
4834 item->tooltip.data, NULL);
4835 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4841 if (del_cb) del_cb((void *)data, NULL, NULL);
4845 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4847 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4848 if ((item->base.view) && (item->tooltip.content_cb))
4849 elm_widget_item_tooltip_unset(item);
4851 if (item->tooltip.del_cb)
4852 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4853 item->tooltip.del_cb = NULL;
4854 item->tooltip.content_cb = NULL;
4855 item->tooltip.data = NULL;
4856 if (item->tooltip.style)
4857 elm_genlist_item_tooltip_style_set(item, NULL);
4861 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4864 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4865 eina_stringshare_replace(&item->tooltip.style, style);
4866 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4870 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4872 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4873 return item->tooltip.style;
4877 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4880 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4881 eina_stringshare_replace(&item->mouse_cursor, cursor);
4882 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4886 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4888 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4889 return elm_widget_item_cursor_get(item);
4893 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4895 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4896 if (!item->mouse_cursor)
4900 elm_widget_item_cursor_unset(item);
4902 eina_stringshare_del(item->mouse_cursor);
4903 item->mouse_cursor = NULL;
4907 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4910 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4911 elm_widget_item_cursor_style_set(item, style);
4915 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4917 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4918 return elm_widget_item_cursor_style_get(item);
4922 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4923 Eina_Bool engine_only)
4925 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4926 elm_widget_item_cursor_engine_only_set(item, engine_only);
4930 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4932 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4933 return elm_widget_item_cursor_engine_only_get(item);
4937 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4940 ELM_CHECK_WIDTYPE(obj, widtype);
4941 Widget_Data *wd = elm_widget_data_get(obj);
4943 if (wd->mode == mode) return;
4949 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4951 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4952 Widget_Data *wd = elm_widget_data_get(obj);
4953 if (!wd) return ELM_LIST_LAST;
4958 elm_genlist_always_select_mode_set(Evas_Object *obj,
4959 Eina_Bool always_select)
4961 ELM_CHECK_WIDTYPE(obj, widtype);
4962 Widget_Data *wd = elm_widget_data_get(obj);
4964 wd->always_select = always_select;
4968 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4970 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4971 Widget_Data *wd = elm_widget_data_get(obj);
4972 if (!wd) return EINA_FALSE;
4973 return wd->always_select;
4977 elm_genlist_no_select_mode_set(Evas_Object *obj,
4978 Eina_Bool no_select)
4980 ELM_CHECK_WIDTYPE(obj, widtype);
4981 Widget_Data *wd = elm_widget_data_get(obj);
4983 wd->no_select = no_select;
4987 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4989 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4990 Widget_Data *wd = elm_widget_data_get(obj);
4991 if (!wd) return EINA_FALSE;
4992 return wd->no_select;
4996 elm_genlist_compress_mode_set(Evas_Object *obj,
4999 ELM_CHECK_WIDTYPE(obj, widtype);
5000 Widget_Data *wd = elm_widget_data_get(obj);
5002 wd->compress = compress;
5006 elm_genlist_compress_mode_get(const Evas_Object *obj)
5008 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5009 Widget_Data *wd = elm_widget_data_get(obj);
5010 if (!wd) return EINA_FALSE;
5011 return wd->compress;
5015 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5016 Eina_Bool height_for_width)
5018 ELM_CHECK_WIDTYPE(obj, widtype);
5019 Widget_Data *wd = elm_widget_data_get(obj);
5021 wd->height_for_width = !!height_for_width;
5022 if (wd->height_for_width)
5024 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5025 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5030 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5032 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5033 Widget_Data *wd = elm_widget_data_get(obj);
5034 if (!wd) return EINA_FALSE;
5035 return wd->height_for_width;
5039 elm_genlist_bounce_set(Evas_Object *obj,
5043 ELM_CHECK_WIDTYPE(obj, widtype);
5044 Widget_Data *wd = elm_widget_data_get(obj);
5046 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5050 elm_genlist_bounce_get(const Evas_Object *obj,
5051 Eina_Bool *h_bounce,
5052 Eina_Bool *v_bounce)
5054 ELM_CHECK_WIDTYPE(obj, widtype);
5055 Widget_Data *wd = elm_widget_data_get(obj);
5057 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
5061 elm_genlist_homogeneous_set(Evas_Object *obj,
5062 Eina_Bool homogeneous)
5064 ELM_CHECK_WIDTYPE(obj, widtype);
5065 Widget_Data *wd = elm_widget_data_get(obj);
5067 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5068 wd->homogeneous = homogeneous;
5072 elm_genlist_homogeneous_get(const Evas_Object *obj)
5074 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5075 Widget_Data *wd = elm_widget_data_get(obj);
5076 if (!wd) return EINA_FALSE;
5077 return wd->homogeneous;
5081 elm_genlist_block_count_set(Evas_Object *obj,
5084 ELM_CHECK_WIDTYPE(obj, widtype);
5085 Widget_Data *wd = elm_widget_data_get(obj);
5087 wd->max_items_per_block = n;
5088 wd->item_cache_max = wd->max_items_per_block * 2;
5089 _item_cache_clean(wd);
5093 elm_genlist_block_count_get(const Evas_Object *obj)
5095 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5096 Widget_Data *wd = elm_widget_data_get(obj);
5098 return wd->max_items_per_block;
5102 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5105 ELM_CHECK_WIDTYPE(obj, widtype);
5106 Widget_Data *wd = elm_widget_data_get(obj);
5108 wd->longpress_timeout = timeout;
5112 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5114 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5115 Widget_Data *wd = elm_widget_data_get(obj);
5117 return wd->longpress_timeout;
5121 elm_genlist_scroller_policy_set(Evas_Object *obj,
5122 Elm_Scroller_Policy policy_h,
5123 Elm_Scroller_Policy policy_v)
5125 ELM_CHECK_WIDTYPE(obj, widtype);
5126 Widget_Data *wd = elm_widget_data_get(obj);
5127 if ((!wd) || (!wd->scr)) return;
5128 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5129 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5131 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5135 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5136 Elm_Scroller_Policy *policy_h,
5137 Elm_Scroller_Policy *policy_v)
5139 ELM_CHECK_WIDTYPE(obj, widtype);
5140 Widget_Data *wd = elm_widget_data_get(obj);
5141 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5142 if ((!wd) || (!wd->scr)) return;
5143 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5144 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5145 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5149 elm_genlist_realized_items_update(Evas_Object *obj)
5151 ELM_CHECK_WIDTYPE(obj, widtype);
5153 Eina_List *list, *l;
5154 Elm_Genlist_Item *it;
5156 list = elm_genlist_realized_items_get(obj);
5157 EINA_LIST_FOREACH(list, l, it)
5158 elm_genlist_item_update(it);
5162 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5163 const char *mode_type,
5166 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5167 Widget_Data *wd = it->wd;
5169 Elm_Genlist_Item *it2;
5172 if (!mode_type) return;
5173 if ((it->delete_me) || (it->disabled)) return;
5174 if (wd->edit_mode) return;
5176 if ((wd->mode_item == it) &&
5177 (!strcmp(mode_type, wd->mode_type)) &&
5180 if (!it->itc->mode_item_style) return;
5184 EINA_LIST_FOREACH(wd->selected, l, it2)
5186 elm_genlist_item_selected_set(it2, EINA_FALSE);
5190 it2 = elm_genlist_selected_item_get(wd->obj);
5191 if ((it2) && (it2->realized))
5192 elm_genlist_item_selected_set(it2, EINA_FALSE);
5195 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5197 ((it == wd->mode_item) && (!mode_set)))
5198 _item_mode_unset(wd);
5200 eina_stringshare_replace(&wd->mode_type, mode_type);
5201 if (mode_set) _item_mode_set(it);
5205 elm_genlist_mode_get(const Evas_Object *obj)
5207 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5208 Widget_Data *wd = elm_widget_data_get(obj);
5209 if (!wd) return NULL;
5210 return wd->mode_type;
5213 EAPI const Elm_Genlist_Item *
5214 elm_genlist_mode_item_get(const Evas_Object *obj)
5216 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5217 Widget_Data *wd = elm_widget_data_get(obj);
5218 if (!wd) return NULL;
5219 return wd->mode_item;
5223 elm_genlist_reorder_mode_set(Evas_Object *obj,
5224 Eina_Bool reorder_mode)
5226 ELM_CHECK_WIDTYPE(obj, widtype);
5227 Widget_Data *wd = elm_widget_data_get(obj);
5229 wd->reorder_mode = reorder_mode;
5233 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5235 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5236 Widget_Data *wd = elm_widget_data_get(obj);
5237 if (!wd) return EINA_FALSE;
5238 return wd->reorder_mode;
5242 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
5248 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
5254 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5256 ELM_CHECK_WIDTYPE(obj, widtype);
5257 Widget_Data *wd = elm_widget_data_get(obj);
5259 wd->effect_mode = emode;
5260 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5261 // evas_object_resize(wd->point_rect, 10, 25);
5262 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5263 // evas_object_show(wd->point_rect);
5264 // evas_object_hide(wd->point_rect);
5268 _create_tray_alpha_bg(const Evas_Object *obj)
5270 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5271 Widget_Data *wd = elm_widget_data_get(obj);
5272 if (!wd) return NULL;
5274 Evas_Object *bg = NULL;
5275 Evas_Coord ox, oy, ow, oh;
5277 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5278 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5279 evas_object_color_set(bg,0,0,0,0);
5280 evas_object_resize(bg , ow, oh);
5281 evas_object_move(bg , ox, oy);
5282 evas_object_show(bg);
5283 evas_object_hide(bg);
5290 struct timeval timev;
5292 gettimeofday(&timev, NULL);
5293 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5296 // added for item moving animation.
5298 _item_moving_effect_timer_cb(void *data)
5300 Widget_Data *wd = data;
5301 if (!wd) return EINA_FALSE;
5303 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5304 Elm_Genlist_Item *it = NULL, *it2;
5306 double time = 0.3, t;
5308 Eina_Bool check, end = EINA_FALSE;
5311 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5313 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5314 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5315 if (t > time) end = EINA_TRUE;
5317 it2 = elm_genlist_item_next_get(wd->expand_item);
5320 if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5321 it2 = elm_genlist_item_next_get(it2);
5326 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5327 dy = it2->scrl_y - it2->old_scrl_y;
5328 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5329 dy = wd->expand_item_gap;
5333 y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5342 EINA_INLIST_FOREACH(wd->blocks, itb)
5345 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5346 itb->y - wd->pan_y + oy,
5348 cvx, cvy, cvw, cvh))
5350 EINA_LIST_FOREACH(itb->items, l, it)
5352 if (it == it2) check = EINA_TRUE;
5353 if (!check) continue;
5355 if (!it->old_scrl_y)
5356 it->old_scrl_y = it->scrl_y;
5357 if (it->old_scrl_y + y < oy + oh)
5359 if (!it->realized) _item_realize(it, in, 0);
5361 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5362 it->old_scrl_y = it->scrl_y - y;
5365 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5366 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5368 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5371 evas_object_resize(VIEW(it), it->w, it->h);
5372 evas_object_move(VIEW(it), it->scrl_x, it->old_scrl_y + y);
5373 evas_object_show(VIEW(it));
5374 evas_object_raise(VIEW(it));
5377 if (it->group_item) evas_object_raise(it->group_item->base.view);
5383 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5385 it = elm_genlist_item_prev_get(it2);
5388 if (it->expanded_depth <= it2->expanded_depth) break;
5389 if ((it->scrl_y < it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5391 if (!it->effect_done)
5393 edje_object_signal_emit(VIEW(it), "flip_item", "");
5394 evas_object_show(VIEW(it));
5395 it->effect_done = EINA_TRUE;
5398 it = elm_genlist_item_prev_get(it);
5401 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5403 it = elm_genlist_item_prev_get(it2);
5406 if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5408 if (!it->effect_done)
5410 edje_object_signal_emit(VIEW(it), "elm,state,hide", "");
5411 it->effect_done = EINA_TRUE;
5416 it = elm_genlist_item_prev_get(it);
5423 int expand_order = 0;
5424 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5428 it = elm_genlist_item_next_get(it);
5430 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5434 if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
5435 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5437 if (!it->effect_done)
5439 if (t >= (((expand_order - 1) * time) / expand_num))
5441 edje_object_signal_emit(VIEW(it), "flip_item", "");
5442 evas_object_show(VIEW(it));
5443 it->effect_done = EINA_TRUE;
5447 it = elm_genlist_item_next_get(it);
5453 if (wd->item_moving_effect_timer)
5455 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5456 _item_subitems_clear(wd->expand_item);
5457 EINA_INLIST_FOREACH(wd->blocks, itb)
5459 EINA_LIST_FOREACH(itb->items, l, it)
5461 it->effect_done = EINA_TRUE;
5462 it->old_scrl_y = it->scrl_y;
5466 wd->item_moving_effect_timer = NULL;
5468 _item_auto_scroll(wd);
5469 evas_object_lower(wd->alpha_bg);
5470 evas_object_hide(wd->alpha_bg);
5471 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5472 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5474 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5475 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5476 evas_object_smart_changed(wd->pan_smart);
5477 return ECORE_CALLBACK_CANCEL;
5479 return ECORE_CALLBACK_RENEW;
5483 _emit_contract(Elm_Genlist_Item *it)
5485 Elm_Genlist_Item *it2;
5488 // printf("%p is emited contract\n", it);
5489 edje_object_signal_emit(VIEW(it), "elm,state,contract_flip", "");
5490 it->effect_done = EINA_FALSE;
5492 EINA_LIST_FOREACH(it->items, l, it2)
5494 _emit_contract(it2);
5497 // added for item moving animation.
5499 _item_flip_effect_show(Elm_Genlist_Item *it)
5501 Elm_Genlist_Item *it2;
5503 Widget_Data *wd = it->wd;
5504 Eina_Bool check = EINA_FALSE;
5506 it2 = elm_genlist_item_next_get(it);
5509 if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5510 it2 = elm_genlist_item_next_get(it2);
5512 EINA_LIST_FOREACH(it->items, l, it2)
5514 if (it2->parent && it == it2->parent)
5516 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5517 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5518 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5519 _emit_contract(it2);
5523 return ECORE_CALLBACK_CANCEL;
5528 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5530 printf("!!! NOW FIXING \n");
5535 * Set pinch zoom mode
5537 * @param obj The genlist object
5539 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5544 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5546 printf("!!! NOW FIXING \n");
5550 * Get pinch zoom mode
5552 * @param obj The genlist object
5553 * @return The pinch mode
5554 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5559 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
5561 printf("!!! NOW FIXING \n");
5566 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5568 printf("!!! NOW FIXING \n");
5572 ////////////////////////////////////////////////////////////////////////
5574 ////////////////////////////////////////////////////////////////////////
5577 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5579 if (!it->wd->edit_mode) return;
5580 evas_object_resize(it->edit_obj,it->w, it->h);
5581 evas_object_move(it->edit_obj, itx, ity);
5585 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5587 if ((it->effect_item_realized) || (it->delete_me)) return;
5591 _mode_finished_signal_cb(it, (Evas_Object *)elm_genlist_item_object_get(it), NULL, NULL);
5593 it->edit_obj = edje_object_add(evas_object_evas_get(WIDGET(it)));
5594 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(WIDGET(it)) *
5595 _elm_config->scale);
5596 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5597 elm_widget_sub_object_add(WIDGET(it), it->edit_obj);
5599 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5600 else strncpy(buf, "item", sizeof(buf));
5601 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5603 strncat(buf, "/", sizeof(buf) - strlen(buf));
5605 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5607 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
5608 _elm_theme_object_set(WIDGET(it), it->edit_obj, "genlist", buf, elm_widget_style_get(WIDGET(it)));
5612 _elm_theme_object_set(WIDGET(it), it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(WIDGET(it)));
5615 if (it->wd->reorder_mode)
5617 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
5618 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
5620 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
5621 else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
5623 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
5624 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
5627 if ((it->wd->edit_mode))
5629 if (it->itc->func.icon_get)
5634 if (it->renamed) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
5635 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5636 EINA_LIST_FOREACH(it->icons, l, key)
5638 Evas_Object *ic = it->itc->func.icon_get
5639 ((void *)it->base.data, WIDGET(it), l->data);
5643 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5644 edje_object_part_swallow(it->edit_obj, key, ic);
5645 evas_object_show(ic);
5646 elm_widget_sub_object_add(WIDGET(it), ic);
5648 elm_widget_disabled_set(ic, EINA_TRUE);
5653 edje_object_part_swallow(it->edit_obj, "original_edc", VIEW(it));
5654 _effect_item_controls(it,it->scrl_x, it->scrl_y);
5655 evas_object_show(it->edit_obj);
5657 it->effect_item_realized = EINA_TRUE;
5658 it->want_unrealize = EINA_FALSE;
5662 _effect_item_unrealize(Elm_Genlist_Item *it)
5666 if (!it->effect_item_realized) return;
5667 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5669 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
5670 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
5671 edje_object_message_signal_process(it->edit_obj);
5672 edje_object_part_unswallow(it->edit_obj, VIEW(it));
5673 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
5674 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
5675 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5676 // _item_cache_add(it);
5677 evas_object_del(it->edit_obj);
5678 it->edit_obj = NULL;
5679 EINA_LIST_FREE(it->edit_icon_objs, icon)
5680 evas_object_del(icon);
5682 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5683 it->effect_item_realized = EINA_FALSE;
5687 * Get Genlist edit mode
5689 * @param obj The genlist object
5690 * @return The edit mode status
5691 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5696 elm_genlist_edit_mode_get(const Evas_Object *obj)
5698 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5699 Widget_Data *wd = elm_widget_data_get(obj);
5700 if (!wd) return EINA_FALSE;
5702 if (wd->edit_mode) return EINA_TRUE;
5703 else return EINA_FALSE;
5707 * Set Genlist edit mode
5709 * This sets Genlist edit mode.
5711 * @param obj The Genlist object
5712 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5713 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5718 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5720 ELM_CHECK_WIDTYPE(obj, widtype);
5724 Elm_Genlist_Item *it;
5726 Widget_Data *wd = elm_widget_data_get(obj);
5728 if (wd->edit_mode == edit_mode) return;
5730 wd->edit_mode = edit_mode;
5733 EINA_INLIST_FOREACH(wd->blocks, itb)
5737 EINA_LIST_FOREACH(itb->items, l, it)
5739 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5741 _effect_item_unrealize(it);
5746 _item_cache_zero(wd);
5751 EINA_INLIST_FOREACH(wd->blocks, itb)
5755 EINA_LIST_FOREACH(itb->items, l, it)
5757 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5759 if(it->selected) _item_unselect(it);
5760 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
5767 if (wd->calc_job) ecore_job_del(wd->calc_job);
5768 wd->calc_job = ecore_job_add(_calc_job, wd);
5772 * Set a given item's rename mode
5774 * This renames the item's label from genlist
5776 * @param it The item
5777 * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
5782 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
5788 _item_unrealize(it, EINA_FALSE);
5789 it->renamed = EINA_TRUE;
5790 it->wd->rename_it = it;
5791 it->nocache = EINA_TRUE;
5792 if (it->selected) _item_unselect(it);
5794 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5795 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5801 it->renamed = EINA_FALSE;
5802 it->nocache = EINA_TRUE;
5803 it->wd->rename_it = NULL;
5804 _item_cache_zero(it->wd);
5805 elm_genlist_item_update(it);
5811 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
5813 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5814 return item->renamed;