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;
178 Eina_Bool can_focus : 1;
181 Eina_Bool effect_done : 1;
182 Eina_Bool reordering : 1;
183 Eina_Bool renamed : 1;
184 Eina_Bool effect_item_realized : 1;
185 Eina_List *edit_icon_objs;
186 Evas_Object *edit_obj;
188 Ecore_Animator *item_moving_effect_timer;
189 Evas_Coord old_scrl_y;
196 Evas_Object *base_view, *spacer;
198 const char *item_style; // it->itc->item_style
199 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
200 Eina_Bool compress : 1; // it->wd->compress
201 Eina_Bool odd : 1; // in & 0x1
203 Eina_Bool selected : 1; // it->selected
204 Eina_Bool disabled : 1; // it->disabled
205 Eina_Bool expanded : 1; // it->expanded
208 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
209 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
213 Evas_Object_Smart_Clipped_Data __clipped_data;
215 Ecore_Job *resize_job;
218 static const char *widtype = NULL;
219 static void _item_cache_zero(Widget_Data *wd);
220 static void _del_hook(Evas_Object *obj);
221 static void _mirrored_set(Evas_Object *obj,
223 static void _theme_hook(Evas_Object *obj);
224 static void _show_region_hook(void *data,
226 static void _sizing_eval(Evas_Object *obj);
227 static void _item_realize(Elm_Genlist_Item *it,
230 static void _item_unrealize(Elm_Genlist_Item *it,
232 static void _item_block_unrealize(Item_Block *itb);
233 static void _calc_job(void *data);
234 static void _on_focus_hook(void *data,
236 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
237 static void _changed_job(void *data);
238 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
239 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
240 static Eina_Bool _item_single_select_up(Widget_Data *wd);
241 static Eina_Bool _item_single_select_down(Widget_Data *wd);
242 static Eina_Bool _event_hook(Evas_Object *obj,
244 Evas_Callback_Type type,
246 static void _signal_emit_hook(Evas_Object *obj,
247 const char *emission,
249 static Eina_Bool _deselect_all_items(Widget_Data *wd);
250 static void _pan_calculate(Evas_Object *obj);
251 static void _pan_max_get(Evas_Object *obj,
254 static void _item_position(Elm_Genlist_Item *it,
258 static void _mode_item_realize(Elm_Genlist_Item *it);
259 static void _mode_item_unrealize(Elm_Genlist_Item *it);
260 static void _item_mode_set(Elm_Genlist_Item *it);
261 static void _item_mode_unset(Widget_Data *wd);
262 static void _group_items_recalc(void *data);
263 static void _item_move_after(Elm_Genlist_Item *it,
264 Elm_Genlist_Item *after);
265 static void _item_move_before(Elm_Genlist_Item *it,
266 Elm_Genlist_Item *before);
268 // TODO : refactoring
269 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
270 static unsigned int current_time_get();
271 static Eina_Bool _item_moving_effect_timer_cb(void *data);
272 static int _item_flip_effect_show(Elm_Genlist_Item *it);
273 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
274 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
275 static void _effect_item_unrealize(Elm_Genlist_Item *it);
276 static void _item_auto_scroll(void *data);
278 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
280 static const char SIG_ACTIVATED[] = "activated";
281 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
282 static const char SIG_SELECTED[] = "selected";
283 static const char SIG_UNSELECTED[] = "unselected";
284 static const char SIG_EXPANDED[] = "expanded";
285 static const char SIG_CONTRACTED[] = "contracted";
286 static const char SIG_EXPAND_REQUEST[] = "expand,request";
287 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
288 static const char SIG_REALIZED[] = "realized";
289 static const char SIG_UNREALIZED[] = "unrealized";
290 static const char SIG_DRAG_START_UP[] = "drag,start,up";
291 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
292 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
293 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
294 static const char SIG_DRAG_STOP[] = "drag,stop";
295 static const char SIG_DRAG[] = "drag";
296 static const char SIG_LONGPRESSED[] = "longpressed";
297 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
298 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
299 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
300 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
301 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
302 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
303 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
304 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
305 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
306 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
307 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
308 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
309 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
310 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
311 static const char SIG_SWIPE[] = "swipe";
313 static const Evas_Smart_Cb_Description _signals[] = {
314 {SIG_CLICKED_DOUBLE, ""},
317 {SIG_UNSELECTED, ""},
319 {SIG_CONTRACTED, ""},
320 {SIG_EXPAND_REQUEST, ""},
321 {SIG_CONTRACT_REQUEST, ""},
323 {SIG_UNREALIZED, ""},
324 {SIG_DRAG_START_UP, ""},
325 {SIG_DRAG_START_DOWN, ""},
326 {SIG_DRAG_START_LEFT, ""},
327 {SIG_DRAG_START_RIGHT, ""},
330 {SIG_LONGPRESSED, ""},
331 {SIG_SCROLL_ANIM_START, ""},
332 {SIG_SCROLL_ANIM_STOP, ""},
333 {SIG_SCROLL_DRAG_START, ""},
334 {SIG_SCROLL_DRAG_STOP, ""},
335 {SIG_SCROLL_EDGE_TOP, ""},
336 {SIG_SCROLL_EDGE_BOTTOM, ""},
337 {SIG_SCROLL_EDGE_LEFT, ""},
338 {SIG_SCROLL_EDGE_RIGHT, ""},
339 {SIG_MULTI_SWIPE_LEFT, ""},
340 {SIG_MULTI_SWIPE_RIGHT, ""},
341 {SIG_MULTI_SWIPE_UP, ""},
342 {SIG_MULTI_SWIPE_DOWN, ""},
343 {SIG_MULTI_PINCH_OUT, ""},
344 {SIG_MULTI_PINCH_IN, ""},
350 _event_hook(Evas_Object *obj,
351 Evas_Object *src __UNUSED__,
352 Evas_Callback_Type type,
355 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
356 Evas_Event_Key_Down *ev = event_info;
357 Widget_Data *wd = elm_widget_data_get(obj);
358 Evas_Coord pan_max_x = 0, pan_max_y = 0;
359 if (!wd) return EINA_FALSE;
360 if (!wd->items) return EINA_FALSE;
361 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
362 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
364 Elm_Genlist_Item *it = NULL;
367 Evas_Coord step_x = 0;
368 Evas_Coord step_y = 0;
371 Evas_Coord page_x = 0;
372 Evas_Coord page_y = 0;
374 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
375 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
376 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
377 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
379 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
383 else if ((!strcmp(ev->keyname, "Right")) ||
384 (!strcmp(ev->keyname, "KP_Right")))
388 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
390 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
391 (_item_multi_select_up(wd)))
392 || (_item_single_select_up(wd)))
394 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
400 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
402 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
403 (_item_multi_select_down(wd)))
404 || (_item_single_select_down(wd)))
406 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
412 else if ((!strcmp(ev->keyname, "Home")) ||
413 (!strcmp(ev->keyname, "KP_Home")))
415 it = elm_genlist_first_item_get(obj);
416 elm_genlist_item_bring_in(it);
417 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
420 else if ((!strcmp(ev->keyname, "End")) ||
421 (!strcmp(ev->keyname, "KP_End")))
423 it = elm_genlist_last_item_get(obj);
424 elm_genlist_item_bring_in(it);
425 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
428 else if ((!strcmp(ev->keyname, "Prior")) ||
429 (!strcmp(ev->keyname, "KP_Prior")))
432 y -= -(page_y * v_h) / 100;
436 else if ((!strcmp(ev->keyname, "Next")) ||
437 (!strcmp(ev->keyname, "KP_Next")))
440 y += -(page_y * v_h) / 100;
444 else if (((!strcmp(ev->keyname, "Return")) ||
445 (!strcmp(ev->keyname, "KP_Enter")) ||
446 (!strcmp(ev->keyname, "space")))
447 && (!wd->multi) && (wd->selected))
449 it = elm_genlist_selected_item_get(obj);
450 elm_genlist_item_expanded_set(it,
451 !elm_genlist_item_expanded_get(it));
452 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
454 else if (!strcmp(ev->keyname, "Escape"))
456 if (!_deselect_all_items(wd)) return EINA_FALSE;
457 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
460 else return EINA_FALSE;
462 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
463 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
465 if (x > pan_max_x) x = pan_max_x;
467 if (y > pan_max_y) y = pan_max_y;
468 elm_smart_scroller_child_pos_set(wd->scr, x, y);
473 _deselect_all_items(Widget_Data *wd)
475 if (!wd->selected) return EINA_FALSE;
477 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
483 _item_multi_select_up(Widget_Data *wd)
485 if (!wd->selected) return EINA_FALSE;
486 if (!wd->multi) return EINA_FALSE;
488 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
489 if (!prev) return EINA_TRUE;
491 if (elm_genlist_item_selected_get(prev))
493 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
494 wd->last_selected_item = prev;
495 elm_genlist_item_show(wd->last_selected_item);
499 elm_genlist_item_selected_set(prev, EINA_TRUE);
500 elm_genlist_item_show(prev);
506 _item_multi_select_down(Widget_Data *wd)
508 if (!wd->selected) return EINA_FALSE;
509 if (!wd->multi) return EINA_FALSE;
511 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
512 if (!next) return EINA_TRUE;
514 if (elm_genlist_item_selected_get(next))
516 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
517 wd->last_selected_item = next;
518 elm_genlist_item_show(wd->last_selected_item);
522 elm_genlist_item_selected_set(next, EINA_TRUE);
523 elm_genlist_item_show(next);
529 _item_single_select_up(Widget_Data *wd)
531 Elm_Genlist_Item *prev;
534 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
535 while ((prev) && (prev->delete_me))
536 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
538 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
540 if (!prev) return EINA_FALSE;
542 _deselect_all_items(wd);
544 elm_genlist_item_selected_set(prev, EINA_TRUE);
545 elm_genlist_item_show(prev);
550 _item_single_select_down(Widget_Data *wd)
552 Elm_Genlist_Item *next;
555 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
556 while ((next) && (next->delete_me))
557 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
559 else next = elm_genlist_item_next_get(wd->last_selected_item);
561 if (!next) return EINA_FALSE;
563 _deselect_all_items(wd);
565 elm_genlist_item_selected_set(next, EINA_TRUE);
566 elm_genlist_item_show(next);
571 _on_focus_hook(void *data __UNUSED__,
574 Widget_Data *wd = elm_widget_data_get(obj);
576 if (elm_widget_focus_get(obj))
578 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
579 evas_object_focus_set(wd->obj, EINA_TRUE);
580 if ((wd->items) && (wd->selected) && (!wd->last_selected_item))
581 wd->last_selected_item = eina_list_data_get(wd->selected);
585 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
586 evas_object_focus_set(wd->obj, EINA_FALSE);
591 _del_hook(Evas_Object *obj)
593 Widget_Data *wd = elm_widget_data_get(obj);
595 _item_cache_zero(wd);
596 if (wd->calc_job) ecore_job_del(wd->calc_job);
597 if (wd->update_job) ecore_job_del(wd->update_job);
598 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
599 if (wd->changed_job) ecore_job_del(wd->changed_job);
600 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
601 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
602 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
603 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
608 _del_pre_hook(Evas_Object *obj)
610 Widget_Data *wd = elm_widget_data_get(obj);
612 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
613 elm_genlist_clear(obj);
614 evas_object_del(wd->pan_smart);
615 wd->pan_smart = NULL;
619 _mirrored_set(Evas_Object *obj,
622 Widget_Data *wd = elm_widget_data_get(obj);
624 _item_cache_zero(wd);
625 elm_smart_scroller_mirrored_set(wd->scr, rtl);
629 _theme_hook(Evas_Object *obj)
631 Widget_Data *wd = elm_widget_data_get(obj);
634 evas_event_freeze(evas_object_evas_get(wd->obj));
635 _item_cache_zero(wd);
636 _elm_widget_mirrored_reload(obj);
637 _mirrored_set(obj, elm_widget_mirrored_get(obj));
638 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
639 elm_widget_style_get(obj));
640 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
641 wd->item_width = wd->item_height = 0;
642 wd->group_item_width = wd->group_item_height = 0;
643 wd->minw = wd->minh = wd->realminw = 0;
644 EINA_INLIST_FOREACH(wd->blocks, itb)
647 Elm_Genlist_Item *it;
649 if (itb->realized) _item_block_unrealize(itb);
650 EINA_LIST_FOREACH(itb->items, l, it)
651 it->mincalcd = EINA_FALSE;
653 itb->changed = EINA_TRUE;
655 if (wd->calc_job) ecore_job_del(wd->calc_job);
656 wd->calc_job = ecore_job_add(_calc_job, wd);
658 evas_event_thaw(evas_object_evas_get(wd->obj));
659 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
663 _show_region_hook(void *data,
666 Widget_Data *wd = elm_widget_data_get(data);
667 Evas_Coord x, y, w, h;
669 elm_widget_show_region_get(obj, &x, &y, &w, &h);
670 //x & y are screen coordinates, Add with pan coordinates
673 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
677 _translate_hook(Evas_Object *obj)
679 evas_object_smart_callback_call(obj, "language,changed", NULL);
683 _sizing_eval(Evas_Object *obj)
685 Widget_Data *wd = elm_widget_data_get(obj);
686 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
688 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
689 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
691 if (wd->height_for_width)
695 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
696 if ((vw != 0) && (vw != wd->prev_viewport_w))
700 wd->prev_viewport_w = vw;
701 EINA_INLIST_FOREACH(wd->blocks, itb)
703 itb->must_recalc = EINA_TRUE;
705 if (wd->calc_job) ecore_job_del(wd->calc_job);
706 wd->calc_job = ecore_job_add(_calc_job, wd);
709 if (wd->mode == ELM_LIST_LIMIT)
715 elm_smart_scroller_child_viewport_size_get(wd->scr, &vmw, &vmh);
716 edje_object_size_min_calc
717 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
724 edje_object_size_min_calc
725 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
729 evas_object_size_hint_min_set(obj, minw, minh);
730 evas_object_size_hint_max_set(obj, maxw, maxh);
734 _signal_emit_hook(Evas_Object *obj,
735 const char *emission,
738 Widget_Data *wd = elm_widget_data_get(obj);
739 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
744 _item_highlight(Elm_Genlist_Item *it)
746 const char *selectraise;
747 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
748 (it->disabled) || (it->display_only) || (it->mode_view))
750 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
751 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
752 selectraise = edje_object_data_get(VIEW(it), "selectraise");
753 if ((selectraise) && (!strcmp(selectraise, "on")))
755 if (it->edit_obj) evas_object_raise(it->edit_obj);
756 else evas_object_raise(VIEW(it));
757 if ((it->group_item) && (it->group_item->realized))
758 evas_object_raise(it->VIEW(group_item));
760 it->highlighted = EINA_TRUE;
764 _item_block_del(Elm_Genlist_Item *it)
767 Item_Block *itb = it->block;
769 itb->items = eina_list_remove(itb->items, it);
771 itb->changed = EINA_TRUE;
772 if (!it->wd->reorder_deleted)
774 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
775 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
779 il = EINA_INLIST_GET(itb);
780 Item_Block *itbn = (Item_Block *)(il->next);
782 it->parent->items = eina_list_remove(it->parent->items, it);
784 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
786 if (itbn) itbn->changed = EINA_TRUE;
790 if (itb->count < itb->wd->max_items_per_block/2)
792 il = EINA_INLIST_GET(itb);
793 Item_Block *itbp = (Item_Block *)(il->prev);
794 Item_Block *itbn = (Item_Block *)(il->next);
795 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
797 Elm_Genlist_Item *it2;
799 EINA_LIST_FREE(itb->items, it2)
802 itbp->items = eina_list_append(itbp->items, it2);
804 itbp->changed = EINA_TRUE;
806 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
807 EINA_INLIST_GET(itb));
810 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
814 Eina_List *last = eina_list_last(itb->items);
815 Elm_Genlist_Item *it2 = last->data;
818 itb->items = eina_list_remove_list(itb->items, last);
819 itbn->items = eina_list_prepend(itbn->items, it2);
821 itbn->changed = EINA_TRUE;
824 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
832 _item_subitems_clear(Elm_Genlist_Item *it)
835 Eina_List *tl = NULL, *l;
836 Elm_Genlist_Item *it2;
838 EINA_LIST_FOREACH(it->items, l, it2)
839 tl = eina_list_append(tl, it2);
841 EINA_LIST_FREE(tl, it2)
842 elm_genlist_item_del(it2);
846 _item_del(Elm_Genlist_Item *it)
848 Evas_Object *tob = it->wd->obj;
850 evas_event_freeze(evas_object_evas_get(tob));
851 elm_widget_item_pre_notify_del(it);
852 elm_genlist_item_subitems_clear(it);
853 it->wd->walking -= it->walking;
854 if (it->wd->show_item == it) it->wd->show_item = NULL;
855 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
856 if (it->realized) _item_unrealize(it, EINA_FALSE);
857 if (it->effect_item_realized) _effect_item_unrealize(it);
858 if (it->block) _item_block_del(it);
859 if ((!it->delete_me) && (it->itc->func.del))
860 it->itc->func.del((void *)it->base.data, WIDGET(it));
861 it->delete_me = EINA_TRUE;
863 it->wd->queue = eina_list_remove(it->wd->queue, it);
865 if (it->wd->anchor_item == it)
867 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
868 if (!it->wd->anchor_item)
869 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
872 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
874 it->parent->items = eina_list_remove(it->parent->items, it);
875 if (it->flags & ELM_GENLIST_ITEM_GROUP)
876 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
877 if (it->long_timer) ecore_timer_del(it->long_timer);
878 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
880 if (it->tooltip.del_cb)
881 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
883 evas_event_thaw(evas_object_evas_get(tob));
884 evas_event_thaw_eval(evas_object_evas_get(tob));
886 elm_widget_item_del(it);
890 _item_select(Elm_Genlist_Item *it)
894 Evas_Object *parent = WIDGET(it);
896 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
899 if (it->wd->always_select) goto call;
902 it->selected = EINA_TRUE;
903 it->wd->selected = eina_list_append(it->wd->selected, it);
905 evas_object_ref(parent);
908 if (it->wd->last_selected_item && (it != it->wd->last_selected_item))
910 EINA_LIST_FOREACH(it->wd->last_selected_item->icon_objs, l, obj)
912 elm_widget_focused_object_clear(obj);
913 elm_widget_tree_unfocusable_set(obj, EINA_TRUE);
915 it->wd->last_selected_item->can_focus = EINA_FALSE;
917 if (it->func.func) it->func.func((void *)it->func.data, parent, it);
919 evas_object_smart_callback_call(parent, SIG_SELECTED, it);
922 if ((it->wd->clear_me) && (!it->wd->walking))
924 elm_genlist_clear(parent);
929 if ((!it->walking) && (it->delete_me))
931 if (!it->relcount) _item_del(it);
935 if (it && it->wd) it->wd->last_selected_item = it; // TODO: Remove 'if'?
937 evas_object_unref(parent);
941 _item_unselect(Elm_Genlist_Item *it)
943 const char *stacking, *selectraise;
945 if ((it->delete_me) || ((!it->highlighted) && (!it->selected))) return;
946 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
947 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
948 stacking = edje_object_data_get(VIEW(it), "stacking");
949 selectraise = edje_object_data_get(VIEW(it), "selectraise");
950 if ((selectraise) && (!strcmp(selectraise, "on")))
952 if ((stacking) && (!strcmp(stacking, "below")))
953 evas_object_lower(VIEW(it));
955 it->highlighted = EINA_FALSE;
958 it->selected = EINA_FALSE;
959 it->wd->selected = eina_list_remove(it->wd->selected, it);
960 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
965 _mouse_move(void *data,
966 Evas *evas __UNUSED__,
970 Elm_Genlist_Item *it = data;
971 Evas_Event_Mouse_Move *ev = event_info;
972 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
973 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
975 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
977 if (!it->wd->on_hold)
979 it->wd->on_hold = EINA_TRUE;
980 if ((!it->wd->wasselected) && (!it->renamed))
984 if (it->wd->multitouched)
986 it->wd->cur_x = ev->cur.canvas.x;
987 it->wd->cur_y = ev->cur.canvas.y;
990 if ((it->dragging) && (it->down))
992 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
995 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
996 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
997 if (abs((it->wd->history[it->wd->movements].x -
998 it->wd->history[0].x)) > 40)
999 it->wd->swipe = EINA_TRUE;
1001 it->wd->movements++;
1005 ecore_timer_del(it->long_timer);
1006 it->long_timer = NULL;
1008 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
1011 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1015 ecore_timer_del(it->long_timer);
1016 it->long_timer = NULL;
1018 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1020 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1021 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1023 if (!it->wd->reorder_start_y)
1024 it->wd->reorder_start_y = it->block->y + it->y;
1028 else if (it_scrl_y + it->wd->reorder_it->h > oy + oh)
1029 y_pos = oy + oh - it->wd->reorder_it->h;
1034 _item_position(it, it->edit_obj, it->scrl_x, y_pos);
1036 _item_position(it, VIEW(it), it->scrl_x, y_pos);
1038 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1039 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1043 if (!it->display_only)
1044 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1045 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1046 x = ev->cur.canvas.x - x;
1047 y = ev->cur.canvas.y - y;
1050 if (adx < 0) adx = -dx;
1053 if (ady < 0) ady = -dy;
1056 if ((adx > minw) || (ady > minh))
1058 it->dragging = EINA_TRUE;
1061 ecore_timer_del(it->long_timer);
1062 it->long_timer = NULL;
1064 if ((!it->wd->wasselected) && (!it->renamed))
1068 if ((ady > adx) && (!it->wd->drag_started))
1069 evas_object_smart_callback_call(WIDGET(it),
1070 SIG_DRAG_START_UP, it);
1074 evas_object_smart_callback_call(WIDGET(it),
1075 SIG_DRAG_START_LEFT, it);
1077 evas_object_smart_callback_call(WIDGET(it),
1078 SIG_DRAG_START_RIGHT, it);
1083 if ((ady > adx) && (!it->wd->drag_started))
1084 evas_object_smart_callback_call(WIDGET(it),
1085 SIG_DRAG_START_DOWN, it);
1089 evas_object_smart_callback_call(WIDGET(it),
1090 SIG_DRAG_START_LEFT, it);
1092 evas_object_smart_callback_call(WIDGET(it),
1093 SIG_DRAG_START_RIGHT, it);
1100 _long_press(void *data)
1102 Elm_Genlist_Item *it = data, *it_tmp;
1103 Eina_List *list, *l;
1105 it->long_timer = NULL;
1106 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
1107 return ECORE_CALLBACK_CANCEL;
1108 it->wd->longpressed = EINA_TRUE;
1109 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
1110 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1112 it->wd->reorder_it = it;
1113 it->wd->reorder_start_y = 0;
1115 evas_object_raise(it->edit_obj);
1117 evas_object_raise(VIEW(it));
1119 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1120 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1122 list = elm_genlist_realized_items_get(it->wd->obj);
1123 EINA_LIST_FOREACH(list, l, it_tmp)
1125 if (it != it_tmp) _item_unselect(it_tmp);
1129 EINA_LIST_FOREACH(it->items, l, it_tmp)
1131 if (elm_genlist_item_expanded_get(it_tmp))
1133 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1134 return ECORE_CALLBACK_RENEW;
1138 if (elm_genlist_item_expanded_get(it))
1140 elm_genlist_item_expanded_set(it, EINA_FALSE);
1141 return ECORE_CALLBACK_RENEW;
1144 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1146 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
1148 return ECORE_CALLBACK_CANCEL;
1152 _swipe(Elm_Genlist_Item *it)
1157 if ((it->display_only) || (it->disabled)) return;
1158 it->wd->swipe = EINA_FALSE;
1159 for (i = 0; i < it->wd->movements; i++)
1161 sum += it->wd->history[i].x;
1162 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1165 sum /= it->wd->movements;
1166 if (abs(sum - it->wd->history[0].x) <= 10) return;
1167 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
1171 _swipe_cancel(void *data)
1173 Elm_Genlist_Item *it = data;
1175 if (!it) return ECORE_CALLBACK_CANCEL;
1176 it->wd->swipe = EINA_FALSE;
1177 it->wd->movements = 0;
1178 return ECORE_CALLBACK_RENEW;
1182 _multi_cancel(void *data)
1184 Widget_Data *wd = data;
1186 if (!wd) return ECORE_CALLBACK_CANCEL;
1187 wd->multi_timeout = EINA_TRUE;
1188 return ECORE_CALLBACK_RENEW;
1192 _multi_touch_gesture_eval(void *data)
1194 Elm_Genlist_Item *it = data;
1196 it->wd->multitouched = EINA_FALSE;
1197 if (it->wd->multi_timer)
1199 ecore_timer_del(it->wd->multi_timer);
1200 it->wd->multi_timer = NULL;
1202 if (it->wd->multi_timeout)
1204 it->wd->multi_timeout = EINA_FALSE;
1208 Evas_Coord minw = 0, minh = 0;
1209 Evas_Coord off_x, off_y, off_mx, off_my;
1211 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1212 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1213 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1214 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1215 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1217 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1219 if ((off_x + off_mx) > (off_y + off_my))
1221 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1222 evas_object_smart_callback_call(WIDGET(it),
1223 SIG_MULTI_SWIPE_RIGHT, it);
1224 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1225 evas_object_smart_callback_call(WIDGET(it),
1226 SIG_MULTI_SWIPE_LEFT, it);
1227 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1228 evas_object_smart_callback_call(WIDGET(it),
1229 SIG_MULTI_PINCH_OUT, it);
1231 evas_object_smart_callback_call(WIDGET(it),
1232 SIG_MULTI_PINCH_IN, it);
1236 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1237 evas_object_smart_callback_call(WIDGET(it),
1238 SIG_MULTI_SWIPE_DOWN, it);
1239 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1240 evas_object_smart_callback_call(WIDGET(it),
1241 SIG_MULTI_SWIPE_UP, it);
1242 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1243 evas_object_smart_callback_call(WIDGET(it),
1244 SIG_MULTI_PINCH_OUT, it);
1246 evas_object_smart_callback_call(WIDGET(it),
1247 SIG_MULTI_PINCH_IN, it);
1250 it->wd->multi_timeout = EINA_FALSE;
1254 _multi_down(void *data,
1255 Evas *evas __UNUSED__,
1256 Evas_Object *obj __UNUSED__,
1259 Elm_Genlist_Item *it = data;
1260 Evas_Event_Multi_Down *ev = event_info;
1262 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1263 it->wd->multi_device = ev->device;
1264 it->wd->multi_down = EINA_TRUE;
1265 it->wd->multitouched = EINA_TRUE;
1266 it->wd->prev_mx = ev->canvas.x;
1267 it->wd->prev_my = ev->canvas.y;
1268 if (!it->wd->wasselected) _item_unselect(it);
1269 it->wd->wasselected = EINA_FALSE;
1270 it->wd->longpressed = EINA_FALSE;
1273 ecore_timer_del(it->long_timer);
1274 it->long_timer = NULL;
1278 it->dragging = EINA_FALSE;
1279 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1281 if (it->swipe_timer)
1283 ecore_timer_del(it->swipe_timer);
1284 it->swipe_timer = NULL;
1286 if (it->wd->on_hold)
1288 it->wd->swipe = EINA_FALSE;
1289 it->wd->movements = 0;
1290 it->wd->on_hold = EINA_FALSE;
1295 _multi_up(void *data,
1296 Evas *evas __UNUSED__,
1297 Evas_Object *obj __UNUSED__,
1300 Elm_Genlist_Item *it = data;
1301 Evas_Event_Multi_Up *ev = event_info;
1303 if (it->wd->multi_device != ev->device) return;
1304 it->wd->multi_device = 0;
1305 it->wd->multi_down = EINA_FALSE;
1306 if (it->wd->mouse_down) return;
1307 _multi_touch_gesture_eval(data);
1311 _multi_move(void *data,
1312 Evas *evas __UNUSED__,
1313 Evas_Object *obj __UNUSED__,
1316 Elm_Genlist_Item *it = data;
1317 Evas_Event_Multi_Move *ev = event_info;
1319 if (it->wd->multi_device != ev->device) return;
1320 it->wd->cur_mx = ev->cur.canvas.x;
1321 it->wd->cur_my = ev->cur.canvas.y;
1325 _mouse_down(void *data,
1326 Evas *evas __UNUSED__,
1330 Elm_Genlist_Item *it = data;
1331 Evas_Event_Mouse_Down *ev = event_info;
1336 if (ev->button != 1) return;
1339 EINA_LIST_FOREACH(it->icon_objs, l, iobj)
1341 elm_widget_tree_unfocusable_set(iobj, EINA_FALSE);
1343 it->can_focus = EINA_TRUE;
1345 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1347 it->wd->on_hold = EINA_TRUE;
1349 it->down = EINA_TRUE;
1350 it->dragging = EINA_FALSE;
1351 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1352 it->dx = ev->canvas.x - x;
1353 it->dy = ev->canvas.y - y;
1354 it->wd->mouse_down = EINA_TRUE;
1355 if (!it->wd->multitouched)
1357 it->wd->prev_x = ev->canvas.x;
1358 it->wd->prev_y = ev->canvas.y;
1359 it->wd->multi_timeout = EINA_FALSE;
1360 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1361 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1363 it->wd->longpressed = EINA_FALSE;
1364 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1365 else it->wd->on_hold = EINA_FALSE;
1366 if (it->wd->on_hold) return;
1367 it->wd->wasselected = it->selected;
1368 _item_highlight(it);
1369 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1370 if ((!it->disabled) && (!it->display_only))
1372 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1373 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
1375 if (it->long_timer) ecore_timer_del(it->long_timer);
1376 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1377 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1379 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1382 it->long_timer = NULL;
1383 it->wd->swipe = EINA_FALSE;
1384 it->wd->movements = 0;
1388 _mouse_up(void *data,
1389 Evas *evas __UNUSED__,
1390 Evas_Object *obj __UNUSED__,
1393 Elm_Genlist_Item *it = data;
1394 Evas_Event_Mouse_Up *ev = event_info;
1395 Eina_Bool dragged = EINA_FALSE;
1397 if (ev->button != 1) return;
1398 it->down = EINA_FALSE;
1399 it->wd->mouse_down = EINA_FALSE;
1400 if (it->wd->multitouched)
1402 // in single selection modes, some multi touching can make multi highlighted items.
1403 // if a item not selected and highlighted, it should be unhighlighted.
1404 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unselect(it);
1405 if (it->wd->multi_down) return;
1406 _multi_touch_gesture_eval(data);
1409 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1410 else it->wd->on_hold = EINA_FALSE;
1413 ecore_timer_del(it->long_timer);
1414 it->long_timer = NULL;
1418 it->dragging = EINA_FALSE;
1419 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1422 if (it->swipe_timer)
1424 ecore_timer_del(it->swipe_timer);
1425 it->swipe_timer = NULL;
1427 if (it->wd->multi_timer)
1429 ecore_timer_del(it->wd->multi_timer);
1430 it->wd->multi_timer = NULL;
1431 it->wd->multi_timeout = EINA_FALSE;
1433 if (it->wd->on_hold)
1435 if (it->wd->swipe) _swipe(data);
1436 it->wd->longpressed = EINA_FALSE;
1437 it->wd->on_hold = EINA_FALSE;
1440 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1442 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1444 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1446 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1447 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1449 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1453 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1454 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1456 it->wd->reorder_deleted = EINA_FALSE;
1457 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1458 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1459 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1460 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1463 if (it->wd->longpressed)
1465 it->wd->longpressed = EINA_FALSE;
1466 if ((!it->wd->wasselected) && (!it->renamed))
1468 it->wd->wasselected = EINA_FALSE;
1473 if (it->want_unrealize)
1475 _item_unrealize(it, EINA_FALSE);
1476 if (it->block->want_unrealize)
1477 _item_block_unrealize(it->block);
1480 if ((it->disabled) || (dragged) || (it->display_only)) return;
1481 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1486 _item_highlight(it);
1489 else _item_unselect(it);
1495 Widget_Data *wd = it->wd;
1498 while (wd->selected) _item_unselect(wd->selected->data);
1503 const Eina_List *l, *l_next;
1504 Elm_Genlist_Item *it2;
1506 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1507 if (it2 != it) _item_unselect(it2);
1508 //_item_highlight(it);
1511 _item_highlight(it);
1517 _mouse_down_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_up_scroller(void *data,
1530 Evas *evas __UNUSED__,
1531 Evas_Object *obj __UNUSED__,
1532 void *event_info __UNUSED__)
1534 Widget_Data *wd = elm_widget_data_get(data);
1537 wd->drag_started = EINA_FALSE;
1541 _mouse_move_scroller(void *data,
1542 Evas *evas __UNUSED__,
1543 Evas_Object *obj __UNUSED__,
1546 Widget_Data *wd = elm_widget_data_get(data);
1547 Evas_Event_Mouse_Move *ev = event_info;
1548 Evas_Coord minw = 0, minh = 0, dx, dy, adx, ady;
1551 if (wd->drag_started) return;
1553 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1554 dx = ev->cur.canvas.x - ev->prev.canvas.x;
1555 dy = ev->cur.canvas.y - ev->prev.canvas.y;
1558 if (adx < 0) adx = -dx;
1559 if (ady < 0) ady = -dy;
1560 if (((ady < minh) && (ady > minh / 2)) && (ady > adx))
1564 evas_object_smart_callback_call(data, SIG_DRAG_START_UP, NULL);
1565 wd->drag_started = EINA_TRUE;
1569 evas_object_smart_callback_call(data, SIG_DRAG_START_DOWN, NULL);
1570 wd->drag_started = EINA_TRUE;
1576 _signal_expand_toggle(void *data,
1577 Evas_Object *obj __UNUSED__,
1578 const char *emission __UNUSED__,
1579 const char *source __UNUSED__)
1581 Elm_Genlist_Item *it = data;
1584 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1586 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1590 _signal_expand(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_EXPAND_REQUEST, it);
1602 _signal_contract(void *data,
1603 Evas_Object *obj __UNUSED__,
1604 const char *emission __UNUSED__,
1605 const char *source __UNUSED__)
1607 Elm_Genlist_Item *it = data;
1610 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1614 _scr_hold_timer_cb(void *data)
1616 if (!data) return ECORE_CALLBACK_CANCEL;
1617 Widget_Data *wd = data;
1618 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1619 wd->scr_hold_timer = NULL;
1620 return ECORE_CALLBACK_CANCEL;
1624 _mode_finished_signal_cb(void *data,
1626 const char *emission __UNUSED__,
1627 const char *source __UNUSED__)
1631 Elm_Genlist_Item *it = data;
1632 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1634 Evas *te = evas_object_evas_get(obj);
1636 evas_event_freeze(te);
1637 it->nocache = EINA_FALSE;
1638 _mode_item_unrealize(it);
1640 evas_object_raise(it->VIEW(group_item));
1641 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1642 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1643 evas_event_thaw(te);
1644 evas_event_thaw_eval(te);
1648 _item_cache_clean(Widget_Data *wd)
1650 evas_event_freeze(evas_object_evas_get(wd->obj));
1651 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1655 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1656 wd->item_cache = eina_inlist_remove(wd->item_cache,
1657 wd->item_cache->last);
1658 wd->item_cache_count--;
1659 if (itc->spacer) evas_object_del(itc->spacer);
1660 if (itc->base_view) evas_object_del(itc->base_view);
1661 if (itc->item_style) eina_stringshare_del(itc->item_style);
1664 evas_event_thaw(evas_object_evas_get(wd->obj));
1665 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1669 _item_cache_zero(Widget_Data *wd)
1671 int pmax = wd->item_cache_max;
1672 wd->item_cache_max = 0;
1673 _item_cache_clean(wd);
1674 wd->item_cache_max = pmax;
1678 _item_cache_add(Elm_Genlist_Item *it)
1682 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1683 if (it->wd->item_cache_max <= 0)
1685 evas_object_del(VIEW(it));
1687 evas_object_del(it->spacer);
1689 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1690 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1694 it->wd->item_cache_count++;
1695 itc = calloc(1, sizeof(Item_Cache));
1698 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1699 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1702 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1703 EINA_INLIST_GET(itc));
1704 itc->spacer = it->spacer;
1706 itc->base_view = VIEW(it);
1708 evas_object_hide(itc->base_view);
1709 evas_object_move(itc->base_view, -9999, -9999);
1710 itc->item_style = eina_stringshare_add(it->itc->item_style);
1711 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1712 itc->compress = (it->wd->compress);
1713 itc->odd = (it->order_num_in & 0x1);
1714 itc->selected = it->selected;
1715 itc->disabled = it->disabled;
1716 itc->expanded = it->expanded;
1719 ecore_timer_del(it->long_timer);
1720 it->long_timer = NULL;
1722 if (it->swipe_timer)
1724 ecore_timer_del(it->swipe_timer);
1725 it->swipe_timer = NULL;
1727 // FIXME: other callbacks?
1728 edje_object_signal_callback_del_full(itc->base_view,
1729 "elm,action,expand,toggle",
1730 "elm", _signal_expand_toggle, it);
1731 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1733 _signal_expand, it);
1734 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1735 "elm", _signal_contract, it);
1736 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1738 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1740 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1742 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1744 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1746 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1748 _item_cache_clean(it->wd);
1749 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1750 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1754 _item_cache_find(Elm_Genlist_Item *it)
1757 Eina_Bool tree = 0, odd;
1759 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1760 odd = (it->order_num_in & 0x1);
1761 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1763 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1765 if ((itc->tree == tree) &&
1766 (itc->odd == odd) &&
1767 (itc->compress == it->wd->compress) &&
1768 (!strcmp(it->itc->item_style, itc->item_style)))
1770 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1771 EINA_INLIST_GET(itc));
1772 it->wd->item_cache_count--;
1780 _item_cache_free(Item_Cache *itc)
1782 if (itc->spacer) evas_object_del(itc->spacer);
1783 if (itc->base_view) evas_object_del(itc->base_view);
1784 if (itc->item_style) eina_stringshare_del(itc->item_style);
1789 _item_label_hook(Elm_Genlist_Item *it, const char *part)
1791 if (!it->itc->func.label_get) return NULL;
1792 return edje_object_part_text_get(VIEW(it), part);
1796 _icon_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1798 Elm_Genlist_Item *it = data;
1799 if (it) it->defer_unrealize = EINA_TRUE;
1803 _icon_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1805 Elm_Genlist_Item *it = data;
1806 if (it) it->defer_unrealize = EINA_FALSE;
1810 _item_del_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1812 Elm_Genlist_Item *it = event_info;
1814 if (it->wd->last_selected_item == it)
1815 it->wd->last_selected_item = NULL;
1819 _item_label_realize(Elm_Genlist_Item *it,
1820 Evas_Object *target,
1824 if (it->itc->func.label_get)
1829 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1830 EINA_LIST_FOREACH(*source, l, key)
1832 if (parts && fnmatch(parts, key, FNM_PERIOD))
1835 char *s = it->itc->func.label_get
1836 ((void *)it->base.data, WIDGET(it), key);
1840 edje_object_part_text_set(target, key, s);
1845 edje_object_part_text_set(target, key, "");
1853 _item_icon_unrealize(Elm_Genlist_Item *it,
1854 Evas_Object *target,
1858 Eina_List *res = it->icon_objs;
1860 if (it->itc->func.icon_get)
1864 Evas_Object *ic = NULL;
1866 EINA_LIST_FOREACH(*source, l, key)
1868 if (parts && fnmatch(parts, key, FNM_PERIOD))
1871 ic = edje_object_part_swallow_get(target, key);
1874 res = eina_list_remove(res, ic);
1875 edje_object_part_unswallow(target, ic);
1876 evas_object_del(ic);
1885 _item_icon_realize(Elm_Genlist_Item *it,
1886 Evas_Object *target,
1890 Eina_List *res = NULL;
1892 if (it->itc->func.icon_get)
1897 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1898 if (parts && (eina_list_count(*source) != eina_list_count(it->icon_objs)))
1899 res = it->icon_objs;
1900 EINA_LIST_FOREACH(*source, l, key)
1902 if (parts && fnmatch(parts, key, FNM_PERIOD))
1905 Evas_Object *ic = it->itc->func.icon_get
1906 ((void *)it->base.data, WIDGET(it), key);
1910 res = eina_list_append(res, ic);
1911 edje_object_part_swallow(target, key, ic);
1912 evas_object_show(ic);
1913 elm_widget_sub_object_add(WIDGET(it), ic);
1914 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
1916 elm_widget_disabled_set(ic, EINA_TRUE);
1925 _item_state_realize(Elm_Genlist_Item *it,
1926 Evas_Object *target,
1930 if (it->itc->func.state_get)
1936 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1937 EINA_LIST_FOREACH(*source, l, key)
1939 if (parts && fnmatch(parts, key, FNM_PERIOD))
1942 Eina_Bool on = it->itc->func.state_get
1943 ((void *)it->base.data, WIDGET(it), key);
1947 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1948 edje_object_signal_emit(target, buf, "elm");
1952 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1953 edje_object_signal_emit(target, buf, "elm");
1960 _item_realize(Elm_Genlist_Item *it,
1964 Elm_Genlist_Item *it2;
1965 const char *stacking;
1966 const char *treesize;
1968 int depth, tsize = 20;
1969 Item_Cache *itc = NULL;
1971 if ((it->realized) || (it->delete_me)) return;
1972 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1973 it->order_num_in = in;
1974 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1975 if ((it->nocache) && (!it->renamed))
1976 it->nocache = EINA_FALSE;
1978 itc = _item_cache_find(it);
1979 if (itc && (!it->wd->effect_mode))
1981 VIEW(it) = itc->base_view;
1982 itc->base_view = NULL;
1983 it->spacer = itc->spacer;
1988 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
1989 edje_object_scale_set(VIEW(it),
1990 elm_widget_scale_get(WIDGET(it)) *
1991 _elm_config->scale);
1992 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
1993 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
1995 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1996 strncpy(buf, "tree", sizeof(buf));
1997 else strncpy(buf, "item", sizeof(buf));
1998 if (it->wd->compress)
1999 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2001 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2002 strncat(buf, "/", sizeof(buf) - strlen(buf));
2003 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
2005 _elm_theme_object_set(WIDGET(it), VIEW(it), "genlist", buf,
2006 elm_widget_style_get(WIDGET(it)));
2007 edje_object_mirrored_set(VIEW(it),
2008 elm_widget_mirrored_get(WIDGET(it)));
2010 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
2011 evas_object_color_set(it->spacer, 0, 0, 0, 0);
2012 elm_widget_sub_object_add(WIDGET(it), it->spacer);
2014 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
2016 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
2018 it->expanded_depth = depth;
2019 treesize = edje_object_data_get(VIEW(it), "treesize");
2020 if (treesize) tsize = atoi(treesize);
2021 evas_object_size_hint_min_set(it->spacer,
2022 (depth * tsize) * _elm_config->scale, 1);
2023 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
2026 edje_object_signal_callback_add(VIEW(it),
2027 "elm,action,expand,toggle",
2028 "elm", _signal_expand_toggle, it);
2029 edje_object_signal_callback_add(VIEW(it), "elm,action,expand",
2030 "elm", _signal_expand, it);
2031 edje_object_signal_callback_add(VIEW(it), "elm,action,contract",
2032 "elm", _signal_contract, it);
2033 stacking = edje_object_data_get(VIEW(it), "stacking");
2036 if (!strcmp(stacking, "below")) evas_object_lower(VIEW(it));
2037 else if (!strcmp(stacking, "above"))
2038 evas_object_raise(VIEW(it));
2040 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
2042 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
2044 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
2046 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_DOWN,
2048 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_UP,
2050 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_MOVE,
2053 if ((!it->edit_obj) &&(it->wd->edit_mode) &&
2054 (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
2055 _effect_item_realize(it, EINA_FALSE);
2059 if ((it->selected) && (it->selected != itc->selected))
2061 edje_object_signal_emit(VIEW(it),
2062 "elm,state,selected", "elm");
2064 edje_object_signal_emit(it->edit_obj,
2065 "elm,state,selected", "elm");
2067 if ((it->disabled) && (it->disabled != itc->disabled))
2069 edje_object_signal_emit(VIEW(it),
2070 "elm,state,disabled", "elm");
2072 edje_object_signal_emit(it->edit_obj,
2073 "elm,state,disabled", "elm");
2075 if ((it->expanded) && (it->expanded != itc->expanded))
2077 edje_object_signal_emit(VIEW(it),
2078 "elm,state,expanded", "elm");
2080 edje_object_signal_emit(it->edit_obj,
2081 "elm,state,expanded", "elm");
2088 edje_object_signal_emit(VIEW(it),
2089 "elm,state,selected", "elm");
2091 edje_object_signal_emit(it->edit_obj,
2092 "elm,state,selected", "elm");
2096 edje_object_signal_emit(VIEW(it),
2097 "elm,state,disabled", "elm");
2099 edje_object_signal_emit(it->edit_obj,
2100 "elm,state,disabled", "elm");
2104 edje_object_signal_emit(VIEW(it),
2105 "elm,state,expanded", "elm");
2107 edje_object_signal_emit(it->edit_obj,
2108 "elm,state,expanded", "elm");
2113 if ((calc) && (it->wd->homogeneous) &&
2114 ((it->wd->item_width) ||
2115 ((it->wd->item_width) && (it->wd->group_item_width))))
2117 /* homogenous genlist shortcut */
2120 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2122 it->w = it->minw = it->wd->group_item_width;
2123 it->h = it->minh = it->wd->group_item_height;
2127 it->w = it->minw = it->wd->item_width;
2128 it->h = it->minh = it->wd->item_height;
2130 it->mincalcd = EINA_TRUE;
2135 _item_label_realize(it, VIEW(it), &it->labels, NULL);
2136 it->icon_objs = _item_icon_realize(it, VIEW(it), &it->icons, NULL);
2137 _item_state_realize(it, VIEW(it), &it->states, NULL);
2138 if (it->itc->func.icon_get) // for rename mode
2144 edje_object_signal_emit(VIEW(it), "elm,state,rename,enabled", "elm");
2146 elm_widget_stringlist_get(edje_object_data_get(VIEW(it), "renames"));
2147 EINA_LIST_FOREACH(it->icons, l, key)
2149 Evas_Object *ic = it->itc->func.icon_get
2150 ((void *)it->base.data, WIDGET(it), l->data);
2153 it->icon_objs = eina_list_append(it->icon_objs, ic);
2154 edje_object_part_swallow(VIEW(it), key, ic);
2155 evas_object_show(ic);
2156 elm_widget_sub_object_add(WIDGET(it), ic);
2157 // FIXME: if entry calcuates its cursor position correctly and conformant works,
2158 // genlist does not need to handle this focus thing.
2159 evas_object_smart_callback_add(ic, "focused", _icon_focused, it);
2160 evas_object_smart_callback_add(ic, "unfocused", _icon_unfocused, it);
2165 if (!it->mincalcd || it->wd->pan_resize || ((it->wd->height_for_width) && (it->w != it->minw)))
2167 Evas_Coord mw = -1, mh = -1;
2169 if (it->wd->height_for_width) mw = it->wd->w; // TODO: Removed this. This was removed from upstream.
2171 if (!it->display_only)
2172 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2173 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2174 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
2176 if (!it->display_only)
2177 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2178 it->w = it->minw = mw;
2179 it->h = it->minh = mh;
2180 it->mincalcd = EINA_TRUE;
2182 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2184 it->wd->group_item_width = mw;
2185 it->wd->group_item_height = mh;
2187 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2189 it->wd->item_width = mw;
2190 it->wd->item_height = mh;
2193 if (!calc) evas_object_show(VIEW(it));
2196 if (it->tooltip.content_cb)
2198 elm_widget_item_tooltip_content_cb_set(it,
2199 it->tooltip.content_cb,
2200 it->tooltip.data, NULL);
2201 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2204 if (it->mouse_cursor)
2205 elm_widget_item_cursor_set(it, it->mouse_cursor);
2207 it->realized = EINA_TRUE;
2208 it->want_unrealize = EINA_FALSE;
2210 if (itc) _item_cache_free(itc);
2211 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2212 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2214 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
2215 if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
2217 if (it->itc->edit_item_style)
2219 if (!it->edit_obj) _effect_item_realize(it, EINA_FALSE);
2220 edje_object_message_signal_process(it->edit_obj);
2223 edje_object_message_signal_process(VIEW(it));
2227 _item_unrealize(Elm_Genlist_Item *it,
2232 if (!it->realized) return;
2233 if (it->wd->reorder_it == it) return;
2234 if (it->defer_unrealize && !it->updateme) return;
2235 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2237 evas_object_smart_callback_call(WIDGET(it), SIG_UNREALIZED, it);
2240 ecore_timer_del(it->long_timer);
2241 it->long_timer = NULL;
2245 evas_object_del(VIEW(it));
2247 evas_object_del(it->spacer);
2252 edje_object_mirrored_set(VIEW(it),
2253 elm_widget_mirrored_get(WIDGET(it)));
2254 edje_object_scale_set(VIEW(it),
2255 elm_widget_scale_get(WIDGET(it))
2256 * _elm_config->scale);
2257 _item_cache_add(it);
2259 elm_widget_stringlist_free(it->labels);
2261 elm_widget_stringlist_free(it->icons);
2263 elm_widget_stringlist_free(it->states);
2265 EINA_LIST_FREE(it->icon_objs, icon)
2266 evas_object_del(icon);
2268 _mode_item_unrealize(it);
2270 it->realized = EINA_FALSE;
2271 it->want_unrealize = EINA_FALSE;
2272 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2273 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2274 if (it->wd->edit_mode) _effect_item_unrealize(it);
2278 _item_block_recalc(Item_Block *itb,
2283 Elm_Genlist_Item *it;
2284 Evas_Coord minw = 0, minh = 0;
2285 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2288 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2290 EINA_LIST_FOREACH(itb->items, l, it)
2292 if (it->delete_me) continue;
2293 showme |= it->showme;
2298 if (!it->mincalcd) changed = EINA_TRUE;
2301 _item_realize(it, in, EINA_TRUE);
2302 _item_unrealize(it, EINA_TRUE);
2307 _item_realize(it, in, EINA_TRUE);
2308 _item_unrealize(it, EINA_TRUE);
2312 _item_realize(it, in, EINA_FALSE);
2314 if (minw < it->minw) minw = it->minw;
2322 itb->changed = EINA_FALSE;
2323 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2324 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2329 _item_block_realize(Item_Block *itb)
2331 if (itb->realized) return;
2332 itb->realized = EINA_TRUE;
2333 itb->want_unrealize = EINA_FALSE;
2337 _item_block_unrealize(Item_Block *itb)
2340 Elm_Genlist_Item *it;
2341 Eina_Bool dragging = EINA_FALSE;
2343 if (!itb->realized) return;
2344 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2345 EINA_LIST_FOREACH(itb->items, l, it)
2347 if (itb->must_recalc || it->flags != ELM_GENLIST_ITEM_GROUP)
2351 dragging = EINA_TRUE;
2352 it->want_unrealize = EINA_TRUE;
2355 _item_unrealize(it, EINA_FALSE);
2360 itb->realized = EINA_FALSE;
2361 itb->want_unrealize = EINA_TRUE;
2364 itb->want_unrealize = EINA_FALSE;
2365 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2366 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2370 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2372 Evas_Coord rox, roy, row, roh, oy, oh;
2373 Eina_Bool top = EINA_FALSE;
2374 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2375 if (!reorder_it) return 0;
2377 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2378 evas_object_geometry_get(it->wd->VIEW(reorder_it), &rox, &roy, &row, &roh);
2380 if ((it->wd->reorder_start_y < it->block->y) &&
2381 (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2383 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2384 if (it->block->count == 1)
2385 it->wd->reorder_rel = it;
2387 else if ((it->wd->reorder_start_y >= it->block->y) &&
2388 (roy - oy + (roh / 2) <= it->block->y - it->wd->pan_y))
2390 it->block->reorder_offset = it->wd->reorder_it->h;
2393 it->block->reorder_offset = 0;
2395 it->scrl_y += it->block->reorder_offset;
2397 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2398 rox, roy + (roh / 2), row, 1));
2401 it->wd->reorder_rel = it;
2402 it->scrl_y += it->wd->reorder_it->h;
2403 return it->wd->reorder_it->h;
2410 _reorder_move_animator_cb(void *data)
2412 Elm_Genlist_Item *it = data;
2413 Eina_Bool down = EINA_FALSE;
2415 int y, dy = it->h / 10 * _elm_config->scale, diff;
2417 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2419 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2422 diff = abs(it->old_scrl_y - it->scrl_y);
2423 if (diff > it->h) y = diff / 2;
2424 if (it->old_scrl_y < it->scrl_y)
2426 it->old_scrl_y += y;
2429 else if (it->old_scrl_y > it->scrl_y)
2431 it->old_scrl_y -= y;
2436 _item_position(it, it->edit_obj, it->scrl_x, it->old_scrl_y);
2438 _item_position(it, VIEW(it), it->scrl_x, it->old_scrl_y);
2439 _group_items_recalc(it->wd);
2440 if ((it->wd->reorder_pan_move) ||
2441 (down && it->old_scrl_y >= it->scrl_y) ||
2442 (!down && it->old_scrl_y <= it->scrl_y))
2444 it->old_scrl_y = it->scrl_y;
2445 it->move_effect_enabled = EINA_FALSE;
2446 it->wd->reorder_move_animator = NULL;
2447 return ECORE_CALLBACK_CANCEL;
2449 return ECORE_CALLBACK_RENEW;
2453 _item_position(Elm_Genlist_Item *it,
2461 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2462 evas_object_resize(view, it->w, it->h);
2463 evas_object_move(view, it_x, it_y);
2464 evas_object_show(view);
2465 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2466 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2470 _item_block_position(Item_Block *itb,
2474 Elm_Genlist_Item *it;
2475 Elm_Genlist_Item *git;
2476 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2477 Evas_Coord minh = 0;
2480 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2481 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2482 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2484 EINA_LIST_FOREACH(itb->items, l, it)
2486 if (it->delete_me) continue;
2487 else if (it->wd->reorder_it == it) continue;
2492 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2493 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2495 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2496 cvx, cvy, cvw, cvh));
2497 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2499 if ((itb->realized))
2503 if (!it->realized) _item_realize(it, in, EINA_FALSE);
2510 if (it->wd->reorder_mode)
2511 y += _get_space_for_reorder_item(it);
2512 git = it->group_item;
2515 git->scrl_x = it->scrl_x;
2516 if (git->scrl_y < oy)
2518 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2519 git->scrl_y = (it->scrl_y + it->h) - git->h;
2520 git->want_realize = EINA_TRUE;
2522 if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2524 if (!it->move_effect_enabled)
2526 it->move_effect_enabled = EINA_TRUE;
2527 it->wd->reorder_move_animator =
2529 _reorder_move_animator_cb, it);
2532 if (!it->move_effect_enabled)
2533 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))
2535 if (it->wd->edit_mode && it->itc->edit_item_style)
2537 _item_position(it, it->edit_obj, it->scrl_x, it->scrl_y);
2541 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)))
2544 _item_position(it, it->mode_view, it->scrl_x,
2547 _item_position(it, VIEW(it), it->scrl_x,
2552 evas_object_resize(VIEW(it), it->w, it->h);
2553 evas_object_move(VIEW(it), it->scrl_x, it->scrl_y);
2554 evas_object_hide(VIEW(it));
2561 if (!it->dragging && (!it->wd->item_moving_effect_timer)) _item_unrealize(it, EINA_FALSE);
2568 if (vis) it->want_realize = EINA_TRUE;
2570 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))
2572 it->old_scrl_y = it->scrl_y;
2577 if (!itb->wd->reorder_it) itb->minh = minh;
2578 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2579 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2583 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2585 Elm_Genlist_Item *it = data;
2587 it->mincalcd = EINA_FALSE;
2588 it->block->changeme = EINA_TRUE;
2589 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2590 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2594 _group_items_recalc(void *data)
2596 Widget_Data *wd = data;
2598 Elm_Genlist_Item *git;
2600 evas_event_freeze(evas_object_evas_get(wd->obj));
2601 EINA_LIST_FOREACH(wd->group_items, l, git)
2603 if (git->want_realize)
2606 _item_realize(git, 0, EINA_FALSE);
2607 evas_object_resize(VIEW(git), wd->minw, git->h);
2608 evas_object_move(VIEW(git), git->scrl_x, git->scrl_y);
2609 evas_object_show(VIEW(git));
2610 evas_object_raise(VIEW(git));
2612 else if (!git->want_realize && git->realized)
2615 _item_unrealize(git, EINA_FALSE);
2618 evas_event_thaw(evas_object_evas_get(wd->obj));
2619 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2623 _must_recalc_idler(void *data)
2625 Widget_Data *wd = data;
2626 if (wd->calc_job) ecore_job_del(wd->calc_job);
2627 wd->calc_job = ecore_job_add(_calc_job, wd);
2628 wd->must_recalc_idler = NULL;
2629 return ECORE_CALLBACK_CANCEL;
2633 _calc_job(void *data)
2635 Widget_Data *wd = data;
2636 Item_Block *itb, *chb = NULL;
2637 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2640 Eina_Bool minw_change = EINA_FALSE;
2641 Eina_Bool did_must_recalc = EINA_FALSE;
2644 t0 = ecore_time_get();
2645 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2649 evas_event_freeze(evas_object_evas_get(wd->obj));
2650 EINA_INLIST_FOREACH(wd->blocks, itb)
2652 Eina_Bool showme = EINA_FALSE;
2655 showme = itb->showme;
2656 itb->showme = EINA_FALSE;
2659 if (itb->realized) _item_block_unrealize(itb);
2661 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2663 if (itb->must_recalc)
2666 Elm_Genlist_Item *it;
2667 EINA_LIST_FOREACH(itb->items, l, it)
2668 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2669 itb->changed = EINA_TRUE;
2670 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2671 if (itb->realized) _item_block_unrealize(itb);
2672 itb->must_recalc = EINA_FALSE;
2674 showme = _item_block_recalc(itb, in, EINA_FALSE);
2680 if (minw == -1) minw = itb->minw;
2681 else if ((!itb->must_recalc) && (minw < itb->minw))
2684 minw_change = EINA_TRUE;
2690 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2692 wd->show_item->showme = EINA_FALSE;
2694 elm_smart_scroller_region_bring_in(wd->scr,
2696 wd->show_item->block->x,
2698 wd->show_item->block->y,
2699 wd->show_item->block->w,
2702 elm_smart_scroller_child_region_show(wd->scr,
2704 wd->show_item->block->x,
2706 wd->show_item->block->y,
2707 wd->show_item->block->w,
2709 wd->show_item = NULL;
2714 EINA_INLIST_FOREACH(wd->blocks, itb)
2720 if ((chb) && (EINA_INLIST_GET(chb)->next))
2722 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2724 if (itb->realized) _item_block_unrealize(itb);
2727 wd->realminw = minw;
2728 if (minw < wd->w) minw = wd->w;
2729 if ((minw != wd->minw) || (minh != wd->minh))
2733 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2734 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2735 _sizing_eval(wd->obj);
2737 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2739 Elm_Genlist_Item *it;
2742 it = wd->anchor_item;
2743 it_y = wd->anchor_y;
2744 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2745 it->block->y + it->y + it_y);
2746 wd->anchor_item = it;
2747 wd->anchor_y = it_y;
2751 t = ecore_time_get();
2752 if (did_must_recalc)
2754 if (!wd->must_recalc_idler)
2755 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2757 wd->calc_job = NULL;
2758 evas_object_smart_changed(wd->pan_smart);
2759 evas_event_thaw(evas_object_evas_get(wd->obj));
2760 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2764 _update_job(void *data)
2766 Widget_Data *wd = data;
2770 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2772 wd->update_job = NULL;
2775 evas_event_freeze(evas_object_evas_get(wd->obj));
2776 EINA_INLIST_FOREACH(wd->blocks, itb)
2778 Evas_Coord itminw, itminh;
2779 Elm_Genlist_Item *it;
2785 _item_block_position(itb, num);
2789 recalc = EINA_FALSE;
2790 EINA_LIST_FOREACH(itb->items, l2, it)
2799 _item_unrealize(it, EINA_FALSE);
2800 _item_realize(it, num, EINA_FALSE);
2801 position = EINA_TRUE;
2805 _item_realize(it, num, EINA_TRUE);
2806 _item_unrealize(it, EINA_TRUE);
2808 if ((it->minw != itminw) || (it->minh != itminh))
2810 it->updateme = EINA_FALSE;
2814 itb->updateme = EINA_FALSE;
2817 position = EINA_TRUE;
2818 itb->changed = EINA_TRUE;
2819 _item_block_recalc(itb, num0, EINA_FALSE);
2820 _item_block_position(itb, num0);
2825 if (wd->calc_job) ecore_job_del(wd->calc_job);
2826 wd->calc_job = ecore_job_add(_calc_job, wd);
2828 evas_event_thaw(evas_object_evas_get(wd->obj));
2829 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2833 _changed_job(void *data)
2835 Widget_Data *wd = data; Eina_List *l2;
2837 int num, num0, position = 0;
2838 Eina_Bool width_changed = EINA_FALSE, height_changed = EINA_FALSE;
2840 wd->changed_job = NULL;
2842 EINA_INLIST_FOREACH(wd->blocks, itb)
2844 Evas_Coord itminw, itminh;
2845 Elm_Genlist_Item *it;
2851 _item_block_position(itb, num);
2855 width_changed = height_changed = EINA_FALSE;
2856 EINA_LIST_FOREACH(itb->items, l2, it)
2858 if ((!it->mincalcd) && (it->realized))
2860 Evas_Coord mw = -1, mh = -1;
2864 if (it->wd->height_for_width) mw = it->wd->w;
2865 if (!it->display_only)
2866 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2867 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2868 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
2869 if (!it->display_only)
2870 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2871 it->w = it->minw = mw;
2872 it->h = it->minh = mh;
2873 it->mincalcd = EINA_TRUE;
2875 //if ((it->minw != itminw) || (it->minh != itminh))
2876 //if ((it->minh != itminh))
2878 if ((it->minw != itminw))
2879 width_changed = EINA_TRUE;
2880 if ((it->minh != itminh))
2881 height_changed = EINA_TRUE;
2883 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2885 it->wd->group_item_width = mw;
2886 it->wd->group_item_height = mh;
2888 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2890 it->wd->item_width = mw;
2891 it->wd->item_height = mh;
2896 itb->changeme = EINA_FALSE;
2897 // TODO: why this is separated.
2901 itb->changed = EINA_TRUE;
2902 _item_block_recalc(itb, num0, 0);
2903 _item_block_position(itb, num0);
2905 else if (width_changed)
2907 _item_block_position(itb, num0);
2912 if (wd->calc_job) ecore_job_del(wd->calc_job);
2913 wd->calc_job = ecore_job_add(_calc_job, wd);
2918 _pan_set(Evas_Object *obj,
2922 Pan *sd = evas_object_smart_data_get(obj);
2928 // Evas_Coord ow, oh;
2929 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2930 // ow = sd->wd->minw - ow;
2931 // if (ow < 0) ow = 0;
2932 // oh = sd->wd->minh - oh;
2933 // if (oh < 0) oh = 0;
2934 // if (x < 0) x = 0;
2935 // if (y < 0) y = 0;
2936 // if (x > ow) x = ow;
2937 // if (y > oh) y = oh;
2938 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2943 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2945 if ((itb->y + itb->h) > y)
2947 Elm_Genlist_Item *it;
2950 EINA_LIST_FOREACH(itb->items, l2, it)
2952 if ((itb->y + it->y) >= y)
2954 sd->wd->anchor_item = it;
2955 sd->wd->anchor_y = -(itb->y + it->y - y);
2963 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2967 _pan_get(Evas_Object *obj,
2971 Pan *sd = evas_object_smart_data_get(obj);
2974 if (x) *x = sd->wd->pan_x;
2975 if (y) *y = sd->wd->pan_y;
2979 _pan_max_get(Evas_Object *obj,
2983 Pan *sd = evas_object_smart_data_get(obj);
2987 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2988 ow = sd->wd->minw - ow;
2990 oh = sd->wd->minh - oh;
2997 _pan_min_get(Evas_Object *obj __UNUSED__,
3006 _pan_child_size_get(Evas_Object *obj,
3010 Pan *sd = evas_object_smart_data_get(obj);
3013 if (w) *w = sd->wd->minw;
3014 if (h) *h = sd->wd->minh;
3018 _pan_add(Evas_Object *obj)
3021 Evas_Object_Smart_Clipped_Data *cd;
3024 cd = evas_object_smart_data_get(obj);
3027 sd->__clipped_data = *cd;
3029 evas_object_smart_data_set(obj, sd);
3033 _pan_del(Evas_Object *obj)
3035 Pan *sd = evas_object_smart_data_get(obj);
3040 ecore_job_del(sd->resize_job);
3041 sd->resize_job = NULL;
3047 _pan_resize_job(void *data)
3051 _sizing_eval(sd->wd->obj);
3052 sd->resize_job = NULL;
3056 _pan_resize(Evas_Object *obj,
3060 Pan *sd = evas_object_smart_data_get(obj);
3064 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
3065 if ((ow == w) && (oh == h)) return;
3066 if ((sd->wd->height_for_width) && (ow != w))
3068 sd->wd->pan_resize = EINA_TRUE;
3069 if (sd->resize_job) ecore_job_del(sd->resize_job);
3070 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
3072 sd->wd->pan_changed = EINA_TRUE;
3073 evas_object_smart_changed(obj);
3074 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3075 sd->wd->calc_job = NULL;
3079 _pan_calculate(Evas_Object *obj)
3081 Pan *sd = evas_object_smart_data_get(obj);
3083 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
3085 Elm_Genlist_Item *git;
3089 evas_event_freeze(evas_object_evas_get(obj));
3091 if (sd->wd->pan_changed)
3094 sd->wd->pan_changed = EINA_FALSE;
3097 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3098 sd->wd->prev_viewport_w = ow;
3099 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
3100 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
3102 git->want_realize = EINA_FALSE;
3104 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
3106 itb->w = sd->wd->minw;
3107 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
3108 itb->y - sd->wd->pan_y + oy,
3110 cvx, cvy, cvw, cvh))
3112 if ((!itb->realized) || (itb->changed))
3113 _item_block_realize(itb);
3114 _item_block_position(itb, in);
3118 if (itb->realized) _item_block_unrealize(itb);
3122 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
3123 _group_items_recalc(sd->wd);
3125 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
3127 if (sd->wd->pan_y != sd->wd->old_pan_y)
3128 sd->wd->reorder_pan_move = EINA_TRUE;
3129 else sd->wd->reorder_pan_move = EINA_FALSE;
3130 evas_object_raise(sd->wd->reorder_it->edit_obj);
3131 sd->wd->old_pan_y = sd->wd->pan_y;
3132 sd->wd->start_time = ecore_loop_time_get();
3135 if (sd->wd->effect_mode &&
3136 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
3137 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
3138 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
3140 if (!sd->wd->item_moving_effect_timer)
3142 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
3143 _item_flip_effect_show(sd->wd->expand_item);
3145 evas_object_raise(sd->wd->alpha_bg);
3146 evas_object_show(sd->wd->alpha_bg);
3147 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
3148 sd->wd->start_time = current_time_get();
3149 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
3152 else _item_auto_scroll(sd->wd);
3153 sd->wd->pan_resize = EINA_FALSE;
3154 evas_event_thaw(evas_object_evas_get(obj));
3155 evas_event_thaw_eval(evas_object_evas_get(obj));
3159 _pan_move(Evas_Object *obj,
3160 Evas_Coord x __UNUSED__,
3161 Evas_Coord y __UNUSED__)
3163 Pan *sd = evas_object_smart_data_get(obj);
3167 sd->wd->pan_changed = EINA_TRUE;
3168 evas_object_smart_changed(obj);
3169 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3170 sd->wd->calc_job = NULL;
3174 _hold_on(void *data __UNUSED__,
3176 void *event_info __UNUSED__)
3178 Widget_Data *wd = elm_widget_data_get(obj);
3180 elm_smart_scroller_hold_set(wd->scr, 1);
3184 _hold_off(void *data __UNUSED__,
3186 void *event_info __UNUSED__)
3188 Widget_Data *wd = elm_widget_data_get(obj);
3190 elm_smart_scroller_hold_set(wd->scr, 0);
3194 _freeze_on(void *data __UNUSED__,
3196 void *event_info __UNUSED__)
3198 Widget_Data *wd = elm_widget_data_get(obj);
3200 elm_smart_scroller_freeze_set(wd->scr, 1);
3204 _freeze_off(void *data __UNUSED__,
3206 void *event_info __UNUSED__)
3208 Widget_Data *wd = elm_widget_data_get(obj);
3210 elm_smart_scroller_freeze_set(wd->scr, 0);
3214 _scr_anim_start(void *data,
3215 Evas_Object *obj __UNUSED__,
3216 void *event_info __UNUSED__)
3218 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
3222 _scr_anim_stop(void *data,
3223 Evas_Object *obj __UNUSED__,
3224 void *event_info __UNUSED__)
3226 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
3230 _scr_drag_start(void *data,
3231 Evas_Object *obj __UNUSED__,
3232 void *event_info __UNUSED__)
3234 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
3238 _scr_drag_stop(void *data,
3239 Evas_Object *obj __UNUSED__,
3240 void *event_info __UNUSED__)
3242 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
3246 _scroll_edge_left(void *data,
3247 Evas_Object *scr __UNUSED__,
3248 void *event_info __UNUSED__)
3250 Evas_Object *obj = data;
3251 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
3255 _scroll_edge_right(void *data,
3256 Evas_Object *scr __UNUSED__,
3257 void *event_info __UNUSED__)
3259 Evas_Object *obj = data;
3260 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
3264 _scroll_edge_top(void *data,
3265 Evas_Object *scr __UNUSED__,
3266 void *event_info __UNUSED__)
3268 Evas_Object *obj = data;
3269 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
3273 _scroll_edge_bottom(void *data,
3274 Evas_Object *scr __UNUSED__,
3275 void *event_info __UNUSED__)
3277 Evas_Object *obj = data;
3278 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
3282 _mode_item_realize(Elm_Genlist_Item *it)
3286 if ((it->mode_view) || (it->delete_me)) return;
3288 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3289 it->mode_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
3290 edje_object_scale_set(it->mode_view,
3291 elm_widget_scale_get(WIDGET(it)) *
3292 _elm_config->scale);
3293 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
3294 elm_widget_sub_object_add(WIDGET(it), it->mode_view);
3296 strncpy(buf, "item", sizeof(buf));
3297 if (it->wd->compress)
3298 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3300 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3301 strncat(buf, "/", sizeof(buf) - strlen(buf));
3302 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3304 _elm_theme_object_set(WIDGET(it), it->mode_view, "genlist", buf,
3305 elm_widget_style_get(WIDGET(it)));
3306 edje_object_mirrored_set(it->mode_view,
3307 elm_widget_mirrored_get(WIDGET(it)));
3309 /* signal callback add */
3310 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3312 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3314 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3317 /* label_get, icon_get, state_get */
3318 _item_label_realize(it, it->mode_view, &it->mode_labels, NULL);
3319 if (it->itc->func.icon_get)
3325 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3327 EINA_LIST_FOREACH(it->mode_icons, l, key)
3329 Evas_Object *ic = it->itc->func.icon_get
3330 ((void *)it->base.data, WIDGET(it), l->data);
3334 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
3335 edje_object_part_swallow(it->mode_view, key, ic);
3336 evas_object_show(ic);
3337 elm_widget_sub_object_add(WIDGET(it), ic);
3339 elm_widget_disabled_set(ic, EINA_TRUE);
3343 _item_state_realize(it, it->mode_view, &it->mode_states, NULL);
3344 edje_object_part_swallow(it->mode_view,
3345 edje_object_data_get(it->mode_view, "mode_part"),
3348 it->want_unrealize = EINA_FALSE;
3349 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3350 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3354 _mode_item_unrealize(Elm_Genlist_Item *it)
3356 Widget_Data *wd = it->wd;
3358 if (!it->mode_view) return;
3360 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3361 elm_widget_stringlist_free(it->mode_labels);
3362 it->mode_labels = NULL;
3363 elm_widget_stringlist_free(it->mode_icons);
3364 it->mode_icons = NULL;
3365 elm_widget_stringlist_free(it->mode_states);
3367 EINA_LIST_FREE(it->mode_icon_objs, icon)
3368 evas_object_del(icon);
3370 edje_object_part_unswallow(it->mode_view, VIEW(it));
3371 evas_object_smart_member_add(VIEW(it), wd->pan_smart);
3372 evas_object_del(it->mode_view);
3373 it->mode_view = NULL;
3375 if (wd->mode_item == it)
3376 wd->mode_item = NULL;
3377 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3378 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3382 _item_mode_set(Elm_Genlist_Item *it)
3385 Widget_Data *wd = it->wd;
3390 it->nocache = EINA_TRUE;
3392 if (wd->scr_hold_timer)
3394 ecore_timer_del(wd->scr_hold_timer);
3395 wd->scr_hold_timer = NULL;
3397 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3398 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3400 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3401 _mode_item_realize(it);
3403 evas_object_raise(it->VIEW(group_item));
3404 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
3405 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3406 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3408 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3409 edje_object_signal_emit(it->mode_view, buf, "elm");
3413 _item_mode_unset(Widget_Data *wd)
3416 if (!wd->mode_item) return;
3417 char buf[1024], buf2[1024];
3418 Elm_Genlist_Item *it;
3421 it->nocache = EINA_TRUE;
3423 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3424 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3426 edje_object_signal_emit(it->mode_view, buf, "elm");
3427 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3429 wd->mode_item = NULL;
3434 _item_auto_scroll(void *data)
3436 Widget_Data *wd = data;
3439 if ((wd->expand_item) && (!wd->auto_scrolled))
3441 Elm_Genlist_Item *it;
3443 Evas_Coord ox, oy, ow, oh;
3444 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3446 wd->auto_scrolled = EINA_TRUE;
3447 if (wd->expand_item->scrl_y > (oh + oy) / 2)
3449 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
3451 elm_genlist_item_bring_in(it);
3457 elm_genlist_add(Evas_Object *parent)
3462 Evas_Coord minw, minh;
3463 static Evas_Smart *smart = NULL;
3467 static Evas_Smart_Class sc;
3469 evas_object_smart_clipped_smart_set(&_pan_sc);
3471 sc.name = "elm_genlist_pan";
3472 sc.version = EVAS_SMART_CLASS_VERSION;
3475 sc.resize = _pan_resize;
3476 sc.move = _pan_move;
3477 sc.calculate = _pan_calculate;
3478 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3481 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3483 ELM_SET_WIDTYPE(widtype, "genlist");
3484 elm_widget_type_set(obj, "genlist");
3485 elm_widget_sub_object_add(parent, obj);
3486 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3487 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3488 elm_widget_data_set(obj, wd);
3489 elm_widget_del_hook_set(obj, _del_hook);
3490 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3491 elm_widget_theme_hook_set(obj, _theme_hook);
3492 elm_widget_can_focus_set(obj, EINA_TRUE);
3493 elm_widget_event_hook_set(obj, _event_hook);
3494 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3495 elm_widget_translate_hook_set(obj, _translate_hook);
3497 wd->scr = elm_smart_scroller_add(e);
3498 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_DOWN,
3499 _mouse_down_scroller, obj);
3500 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_UP,
3501 _mouse_up_scroller, obj);
3502 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_MOVE,
3503 _mouse_move_scroller, obj);
3504 elm_smart_scroller_widget_set(wd->scr, obj);
3505 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3506 elm_widget_style_get(obj));
3507 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3508 _elm_config->thumbscroll_bounce_enable);
3509 elm_widget_resize_object_set(obj, wd->scr);
3511 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3512 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3513 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3514 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3515 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3516 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3518 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3519 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3523 wd->mode = ELM_LIST_SCROLL;
3524 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3525 wd->item_cache_max = wd->max_items_per_block * 2;
3526 wd->longpress_timeout = _elm_config->longpress_timeout;
3527 wd->effect_mode = _elm_config->effect_enable;
3529 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3530 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3531 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3532 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3534 wd->pan_smart = evas_object_smart_add(e, smart);
3535 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3538 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3539 _pan_set, _pan_get, _pan_max_get,
3540 _pan_min_get, _pan_child_size_get);
3542 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3544 evas_object_size_hint_min_set(obj, minw, minh);
3546 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3547 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3552 static Elm_Genlist_Item *
3553 _item_new(Widget_Data *wd,
3554 const Elm_Genlist_Item_Class *itc,
3556 Elm_Genlist_Item *parent,
3557 Elm_Genlist_Item_Flags flags,
3559 const void *func_data)
3561 Elm_Genlist_Item *it;
3563 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3564 if (!it) return NULL;
3567 it->base.data = data;
3568 it->parent = parent;
3570 it->func.func = func;
3571 it->func.data = func_data;
3572 it->mouse_cursor = NULL;
3573 it->expanded_depth = 0;
3574 it->can_focus = EINA_TRUE;
3575 elm_widget_item_text_get_hook_set(it, _item_label_hook);
3576 elm_widget_item_del_cb_set(it, _item_del_hook);
3580 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3581 it->group_item = parent;
3582 else if (it->parent->group_item)
3583 it->group_item = it->parent->group_item;
3589 _item_block_add(Widget_Data *wd,
3590 Elm_Genlist_Item *it)
3592 Item_Block *itb = NULL;
3599 itb = calloc(1, sizeof(Item_Block));
3602 if (!it->rel->block)
3605 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3606 itb->items = eina_list_append(itb->items, it);
3612 wd->blocks = eina_inlist_prepend_relative
3613 (wd->blocks, EINA_INLIST_GET(itb),
3614 EINA_INLIST_GET(it->rel->block));
3616 eina_list_prepend_relative(itb->items, it, it->rel);
3620 wd->blocks = eina_inlist_append_relative
3621 (wd->blocks, EINA_INLIST_GET(itb),
3622 EINA_INLIST_GET(it->rel->block));
3624 eina_list_append_relative(itb->items, it, it->rel);
3634 itb = (Item_Block *)(wd->blocks);
3635 if (itb->count >= wd->max_items_per_block)
3637 itb = calloc(1, sizeof(Item_Block));
3641 eina_inlist_prepend(wd->blocks,
3642 EINA_INLIST_GET(itb));
3647 itb = calloc(1, sizeof(Item_Block));
3651 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3653 itb->items = eina_list_prepend(itb->items, it);
3659 itb = (Item_Block *)(wd->blocks->last);
3660 if (itb->count >= wd->max_items_per_block)
3662 itb = calloc(1, sizeof(Item_Block));
3666 eina_inlist_append(wd->blocks,
3667 EINA_INLIST_GET(itb));
3672 itb = calloc(1, sizeof(Item_Block));
3676 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3678 itb->items = eina_list_append(itb->items, it);
3684 itb = it->rel->block;
3685 if (!itb) goto newblock;
3687 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3689 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3692 itb->changed = EINA_TRUE;
3694 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3695 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3698 it->rel->relcount--;
3699 if ((it->rel->delete_me) && (!it->rel->relcount))
3703 if (itb->count > itb->wd->max_items_per_block)
3707 Elm_Genlist_Item *it2;
3709 newc = itb->count / 2;
3710 itb2 = calloc(1, sizeof(Item_Block));
3714 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3715 EINA_INLIST_GET(itb));
3716 itb2->changed = EINA_TRUE;
3717 while ((itb->count > newc) && (itb->items))
3721 l = eina_list_last(itb->items);
3723 itb->items = eina_list_remove_list(itb->items, l);
3726 itb2->items = eina_list_prepend(itb2->items, it2);
3734 _queue_process(Widget_Data *wd)
3737 Eina_Bool showme = EINA_FALSE;
3740 t0 = ecore_time_get();
3741 //evas_event_freeze(evas_object_evas_get(wd->obj));
3742 for (n = 0; (wd->queue) && (n < 128); n++)
3744 Elm_Genlist_Item *it;
3746 it = wd->queue->data;
3747 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3748 it->queued = EINA_FALSE;
3749 _item_block_add(wd, it);
3750 t = ecore_time_get();
3751 if (it->block->changed)
3753 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3754 it->block->changed = 0;
3757 if (wd->calc_job) ecore_job_del(wd->calc_job);
3758 wd->calc_job = NULL;
3760 wd->pan_changed = EINA_FALSE;
3763 if (showme) it->block->showme = EINA_TRUE;
3764 if (eina_inlist_count(wd->blocks) > 1)
3766 if ((t - t0) > (ecore_animator_frametime_get())) break;
3769 //evas_event_thaw(evas_object_evas_get(wd->obj));
3770 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3775 _idle_process(void *data, Eina_Bool *wakeup)
3777 Widget_Data *wd = data;
3780 //static double q_start = 0.0;
3781 //if (q_start == 0.0) q_start = ecore_time_get();
3783 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3787 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3789 return ECORE_CALLBACK_CANCEL;
3791 return ECORE_CALLBACK_RENEW;
3795 _item_idle_enterer(void *data)
3797 Widget_Data *wd = data;
3798 Eina_Bool wakeup = EINA_FALSE;
3799 Eina_Bool ok = _idle_process(data, &wakeup);
3804 if (wd->calc_job) ecore_job_del(wd->calc_job);
3805 wd->calc_job = ecore_job_add(_calc_job, wd);
3807 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3812 _item_queue(Widget_Data *wd,
3813 Elm_Genlist_Item *it)
3815 if (it->queued) return;
3816 it->queued = EINA_TRUE;
3817 wd->queue = eina_list_append(wd->queue, it);
3818 // FIXME: why does a freeze then thaw here cause some genlist
3819 // elm_genlist_item_append() to be much much slower?
3820 // evas_event_freeze(evas_object_evas_get(wd->obj));
3821 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3823 if (wd->queue_idle_enterer)
3825 ecore_idle_enterer_del(wd->queue_idle_enterer);
3826 wd->queue_idle_enterer = NULL;
3830 // evas_event_thaw(evas_object_evas_get(wd->obj));
3831 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3832 if (!wd->queue_idle_enterer)
3833 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3837 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3842 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3843 it->wd->reorder_deleted = EINA_TRUE;
3844 _item_block_del(it);
3846 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3848 it->rel->relcount++;
3849 it->before = EINA_FALSE;
3850 if (after->group_item) it->group_item = after->group_item;
3851 _item_queue(it->wd, it);
3853 // TODO: change this to smart callback
3854 if (it->itc->func.moved)
3855 it->itc->func.moved(WIDGET(it), it, after, EINA_TRUE);
3859 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3862 if (!before) return;
3864 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3865 it->wd->reorder_deleted = EINA_TRUE;
3866 _item_block_del(it);
3867 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3869 it->rel->relcount++;
3870 it->before = EINA_TRUE;
3871 if (before->group_item) it->group_item = before->group_item;
3872 _item_queue(it->wd, it);
3874 // TODO: change this to smart callback
3875 if (it->itc->func.moved)
3876 it->itc->func.moved(WIDGET(it), it, before, EINA_FALSE);
3879 EAPI Elm_Genlist_Item *
3880 elm_genlist_item_append(Evas_Object *obj,
3881 const Elm_Genlist_Item_Class *itc,
3883 Elm_Genlist_Item *parent,
3884 Elm_Genlist_Item_Flags flags,
3886 const void *func_data)
3888 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3889 Widget_Data *wd = elm_widget_data_get(obj);
3890 if (!wd) return NULL;
3891 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3893 if (!it) return NULL;
3896 if (flags & ELM_GENLIST_ITEM_GROUP)
3897 wd->group_items = eina_list_append(wd->group_items, it);
3898 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3903 Elm_Genlist_Item *it2 = NULL;
3904 Eina_List *ll = eina_list_last(it->parent->items);
3905 if (ll) it2 = ll->data;
3906 it->parent->items = eina_list_append(it->parent->items, it);
3907 if (!it2) it2 = it->parent;
3909 it2 = elm_genlist_item_prev_get(it2);
3911 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3912 EINA_INLIST_GET(it2));
3914 it->rel->relcount++;
3916 it->before = EINA_FALSE;
3917 _item_queue(wd, it);
3921 EAPI Elm_Genlist_Item *
3922 elm_genlist_item_prepend(Evas_Object *obj,
3923 const Elm_Genlist_Item_Class *itc,
3925 Elm_Genlist_Item *parent,
3926 Elm_Genlist_Item_Flags flags,
3928 const void *func_data)
3930 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3931 Widget_Data *wd = elm_widget_data_get(obj);
3932 if (!wd) return NULL;
3933 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3936 if (!it) return NULL;
3939 if (flags & ELM_GENLIST_ITEM_GROUP)
3940 wd->group_items = eina_list_prepend(wd->group_items, it);
3941 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3946 Elm_Genlist_Item *it2 = NULL;
3947 Eina_List *ll = it->parent->items;
3948 if (ll) it2 = ll->data;
3949 it->parent->items = eina_list_prepend(it->parent->items, it);
3950 if (!it2) it2 = it->parent;
3952 it2 = elm_genlist_item_next_get(it2);
3954 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3955 EINA_INLIST_GET(it2));
3957 it->rel->relcount++;
3959 it->before = EINA_TRUE;
3960 _item_queue(wd, it);
3964 EAPI Elm_Genlist_Item *
3965 elm_genlist_item_insert_after(Evas_Object *obj,
3966 const Elm_Genlist_Item_Class *itc,
3968 Elm_Genlist_Item *parent,
3969 Elm_Genlist_Item *after,
3970 Elm_Genlist_Item_Flags flags,
3972 const void *func_data)
3974 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3975 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3976 Widget_Data *wd = elm_widget_data_get(obj);
3977 if (!wd) return NULL;
3978 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3979 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3981 if (!it) return NULL;
3985 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3986 (after->flags & ELM_GENLIST_ITEM_GROUP))
3987 wd->group_items = eina_list_append_relative(wd->group_items, it,
3992 it->parent->items = eina_list_append_relative(it->parent->items, it,
3995 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3996 EINA_INLIST_GET(after));
3998 it->rel->relcount++;
3999 it->before = EINA_FALSE;
4000 _item_queue(wd, it);
4004 EAPI Elm_Genlist_Item *
4005 elm_genlist_item_insert_before(Evas_Object *obj,
4006 const Elm_Genlist_Item_Class *itc,
4008 Elm_Genlist_Item *parent,
4009 Elm_Genlist_Item *before,
4010 Elm_Genlist_Item_Flags flags,
4012 const void *func_data)
4014 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4015 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
4016 Widget_Data *wd = elm_widget_data_get(obj);
4017 if (!wd) return NULL;
4018 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4019 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
4021 if (!it) return NULL;
4025 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
4026 (before->flags & ELM_GENLIST_ITEM_GROUP))
4027 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
4032 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
4035 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4036 EINA_INLIST_GET(before));
4038 it->rel->relcount++;
4039 it->before = EINA_TRUE;
4040 _item_queue(wd, it);
4045 elm_genlist_clear(Evas_Object *obj)
4047 ELM_CHECK_WIDTYPE(obj, widtype);
4048 Widget_Data *wd = elm_widget_data_get(obj);
4050 if (wd->walking > 0)
4052 Elm_Genlist_Item *it;
4054 wd->clear_me = EINA_TRUE;
4055 EINA_INLIST_FOREACH(wd->items, it)
4057 it->delete_me = EINA_TRUE;
4061 evas_event_freeze(evas_object_evas_get(wd->obj));
4064 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4065 it->nocache = EINA_TRUE;
4066 it->highlighted = EINA_FALSE;
4068 if (wd->anchor_item == it)
4070 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4071 if (!wd->anchor_item)
4073 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4076 wd->items = eina_inlist_remove(wd->items, wd->items);
4077 if (it->flags & ELM_GENLIST_ITEM_GROUP)
4078 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
4079 elm_widget_item_pre_notify_del(it);
4080 if (it->realized) _item_unrealize(it, EINA_FALSE);
4081 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
4082 it->itc->func.del((void *)it->base.data, WIDGET(it));
4083 if (it->long_timer) ecore_timer_del(it->long_timer);
4084 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
4085 elm_widget_item_del(it);
4087 wd->clear_me = EINA_FALSE;
4088 wd->anchor_item = NULL;
4091 Item_Block *itb = (Item_Block *)(wd->blocks);
4093 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
4094 if (itb->items) eina_list_free(itb->items);
4097 wd->pan_changed = EINA_TRUE;
4100 ecore_job_del(wd->calc_job);
4101 wd->calc_job = NULL;
4103 if (wd->queue_idle_enterer)
4105 ecore_idle_enterer_del(wd->queue_idle_enterer);
4106 wd->queue_idle_enterer = NULL;
4108 if (wd->must_recalc_idler)
4110 ecore_idler_del(wd->must_recalc_idler);
4111 wd->must_recalc_idler = NULL;
4115 eina_list_free(wd->queue);
4120 eina_list_free(wd->selected);
4121 wd->selected = NULL;
4123 if (wd->reorder_move_animator)
4125 ecore_animator_del(wd->reorder_move_animator);
4126 wd->reorder_move_animator = NULL;
4128 wd->show_item = NULL;
4136 evas_object_del(wd->alpha_bg);
4137 wd->alpha_bg = NULL;
4141 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4142 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4145 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
4146 evas_event_thaw(evas_object_evas_get(wd->obj));
4147 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4151 elm_genlist_multi_select_set(Evas_Object *obj,
4154 ELM_CHECK_WIDTYPE(obj, widtype);
4155 Widget_Data *wd = elm_widget_data_get(obj);
4161 elm_genlist_multi_select_get(const Evas_Object *obj)
4163 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4164 Widget_Data *wd = elm_widget_data_get(obj);
4165 if (!wd) return EINA_FALSE;
4169 EAPI Elm_Genlist_Item *
4170 elm_genlist_selected_item_get(const Evas_Object *obj)
4172 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4173 Widget_Data *wd = elm_widget_data_get(obj);
4174 if (!wd) return NULL;
4175 if (wd->selected) return wd->selected->data;
4179 EAPI const Eina_List *
4180 elm_genlist_selected_items_get(const Evas_Object *obj)
4182 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4183 Widget_Data *wd = elm_widget_data_get(obj);
4184 if (!wd) return NULL;
4185 return wd->selected;
4189 elm_genlist_realized_items_get(const Evas_Object *obj)
4191 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4192 Widget_Data *wd = elm_widget_data_get(obj);
4193 Eina_List *list = NULL;
4195 Eina_Bool done = EINA_FALSE;
4196 if (!wd) return NULL;
4197 EINA_INLIST_FOREACH(wd->blocks, itb)
4202 Elm_Genlist_Item *it;
4205 EINA_LIST_FOREACH(itb->items, l, it)
4207 if (it->realized) list = eina_list_append(list, it);
4218 EAPI Elm_Genlist_Item *
4219 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4224 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4225 Widget_Data *wd = elm_widget_data_get(obj);
4226 Evas_Coord ox, oy, ow, oh;
4229 if (!wd) return NULL;
4230 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4232 EINA_INLIST_FOREACH(wd->blocks, itb)
4235 Elm_Genlist_Item *it;
4237 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4238 oy + itb->y - itb->wd->pan_y,
4239 itb->w, itb->h, x, y, 1, 1))
4241 EINA_LIST_FOREACH(itb->items, l, it)
4243 Evas_Coord itx, ity;
4245 itx = ox + itb->x + it->x - itb->wd->pan_x;
4246 ity = oy + itb->y + it->y - itb->wd->pan_y;
4247 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4251 if (y <= (ity + (it->h / 4))) *posret = -1;
4252 else if (y >= (ity + it->h - (it->h / 4)))
4258 lasty = ity + it->h;
4263 if (y > lasty) *posret = 1;
4269 EAPI Elm_Genlist_Item *
4270 elm_genlist_first_item_get(const Evas_Object *obj)
4272 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4273 Widget_Data *wd = elm_widget_data_get(obj);
4274 if (!wd) return NULL;
4275 if (!wd->items) return NULL;
4276 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4277 while ((it) && (it->delete_me))
4278 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4282 EAPI Elm_Genlist_Item *
4283 elm_genlist_last_item_get(const Evas_Object *obj)
4285 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4286 Widget_Data *wd = elm_widget_data_get(obj);
4287 if (!wd) return NULL;
4288 if (!wd->items) return NULL;
4289 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4290 while ((it) && (it->delete_me))
4291 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4295 EAPI Elm_Genlist_Item *
4296 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4298 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4301 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4302 if ((it) && (!it->delete_me)) break;
4304 return (Elm_Genlist_Item *)it;
4307 EAPI Elm_Genlist_Item *
4308 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4310 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4313 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4314 if ((it) && (!it->delete_me)) break;
4316 return (Elm_Genlist_Item *)it;
4320 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4322 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4326 EAPI Elm_Genlist_Item *
4327 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4329 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4334 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4336 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4337 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
4339 Elm_Genlist_Item *it2;
4342 if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4343 _item_subitems_clear(it);
4346 if ((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4347 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4349 it->wd->expand_item = it;
4350 _item_flip_effect_show(it);
4351 evas_object_geometry_get(VIEW(it), NULL, &y, NULL, &h);
4352 it->wd->expand_item_end = y + h;
4356 it2 = elm_genlist_item_next_get(it2);
4358 } while (it2->expanded_depth > it->expanded_depth);
4362 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), NULL, &vy, NULL, &vh);
4363 it2->old_scrl_y = ((it2->old_scrl_y > vy + vh) ? vy + vh : it2->old_scrl_y);
4364 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4367 it->wd->expand_item_gap = 0;
4369 evas_object_raise(it->wd->alpha_bg);
4370 evas_object_show(it->wd->alpha_bg);
4372 it->wd->start_time = current_time_get();
4373 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4376 _item_subitems_clear(it);
4381 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4384 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4385 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
4387 if ((it->delete_me) || (it->disabled)) return;
4388 selected = !!selected;
4389 if (it->selected == selected) return;
4395 while (wd->selected)
4396 _item_unselect(wd->selected->data);
4398 _item_highlight(it);
4406 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4408 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4409 return it->selected;
4413 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4416 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4417 if (it->flags != ELM_GENLIST_ITEM_SUBITEMS) return;
4418 if (it->expanded == expanded) return;
4419 it->expanded = expanded;
4420 it->wd->expand_item = it;
4422 if (it->wd->effect_mode && !it->wd->alpha_bg)
4423 it->wd->alpha_bg = _create_tray_alpha_bg(WIDGET(it));
4427 it->wd->auto_scrolled = EINA_FALSE;
4428 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4430 edje_object_signal_emit(VIEW(it), "elm,state,expanded", "elm");
4431 evas_object_smart_callback_call(WIDGET(it), "expanded", it);
4435 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4437 edje_object_signal_emit(VIEW(it), "elm,state,contracted", "elm");
4438 evas_object_smart_callback_call(WIDGET(it), "contracted", it);
4443 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4445 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4446 return it->expanded;
4450 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4452 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4453 return it->expanded_depth;
4457 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4460 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4463 if (it->disabled == disabled) return;
4464 if (it->delete_me) return;
4465 it->disabled = !!disabled;
4467 elm_genlist_item_selected_set(it, EINA_FALSE);
4472 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
4474 edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
4478 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
4480 edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
4482 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4483 elm_widget_disabled_set(obj, disabled);
4488 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4490 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4491 if (it->delete_me) return EINA_FALSE;
4492 return it->disabled;
4496 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4497 Eina_Bool display_only)
4499 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4500 if (it->display_only == display_only) return;
4501 if (it->delete_me) return;
4502 it->display_only = display_only;
4503 it->mincalcd = EINA_FALSE;
4504 it->updateme = EINA_TRUE;
4505 if (it->block) it->block->updateme = EINA_TRUE;
4506 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4507 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4511 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4513 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4514 if (it->delete_me) return EINA_FALSE;
4515 return it->display_only;
4519 elm_genlist_item_show(Elm_Genlist_Item *it)
4521 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4522 Evas_Coord gith = 0;
4523 if (it->delete_me) return;
4524 if ((it->queued) || (!it->mincalcd))
4526 it->wd->show_item = it;
4527 it->wd->bring_in = EINA_TRUE;
4528 it->showme = EINA_TRUE;
4531 if (it->wd->show_item)
4533 it->wd->show_item->showme = EINA_FALSE;
4534 it->wd->show_item = NULL;
4536 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4537 gith = it->group_item->h;
4538 elm_smart_scroller_child_region_show(it->wd->scr,
4539 it->x + it->block->x,
4540 it->y + it->block->y - gith,
4541 it->block->w, it->h);
4545 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4547 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4548 Evas_Coord gith = 0;
4549 if (it->delete_me) return;
4550 if ((it->queued) || (!it->mincalcd))
4552 it->wd->show_item = it;
4553 it->wd->bring_in = EINA_TRUE;
4554 it->showme = EINA_TRUE;
4557 if (it->wd->show_item)
4559 it->wd->show_item->showme = EINA_FALSE;
4560 it->wd->show_item = NULL;
4562 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4563 gith = it->group_item->h;
4564 elm_smart_scroller_region_bring_in(it->wd->scr,
4565 it->x + it->block->x,
4566 it->y + it->block->y - gith,
4567 it->block->w, it->h);
4571 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4573 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4575 Evas_Coord gith = 0;
4577 if (it->delete_me) return;
4578 if ((it->queued) || (!it->mincalcd))
4580 it->wd->show_item = it;
4581 it->wd->bring_in = EINA_TRUE;
4582 it->showme = EINA_TRUE;
4585 if (it->wd->show_item)
4587 it->wd->show_item->showme = EINA_FALSE;
4588 it->wd->show_item = NULL;
4590 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4591 if (it->group_item) gith = it->group_item->h;
4592 elm_smart_scroller_child_region_show(it->wd->scr,
4593 it->x + it->block->x,
4594 it->y + it->block->y - gith,
4599 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4601 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4603 Evas_Coord gith = 0;
4605 if (it->delete_me) return;
4606 if ((it->queued) || (!it->mincalcd))
4608 it->wd->show_item = it;
4609 it->wd->bring_in = EINA_TRUE;
4610 it->showme = EINA_TRUE;
4613 if (it->wd->show_item)
4615 it->wd->show_item->showme = EINA_FALSE;
4616 it->wd->show_item = NULL;
4618 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4619 if (it->group_item) gith = it->group_item->h;
4620 elm_smart_scroller_region_bring_in(it->wd->scr,
4621 it->x + it->block->x,
4622 it->y + it->block->y - gith,
4627 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4629 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4632 if (it->delete_me) return;
4633 if ((it->queued) || (!it->mincalcd))
4635 it->wd->show_item = it;
4636 it->wd->bring_in = EINA_TRUE;
4637 it->showme = EINA_TRUE;
4640 if (it->wd->show_item)
4642 it->wd->show_item->showme = EINA_FALSE;
4643 it->wd->show_item = NULL;
4645 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4646 elm_smart_scroller_child_region_show(it->wd->scr,
4647 it->x + it->block->x,
4648 it->y + it->block->y - oh / 2 +
4649 it->h / 2, it->block->w, oh);
4653 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4655 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4658 if (it->delete_me) return;
4659 if ((it->queued) || (!it->mincalcd))
4661 it->wd->show_item = it;
4662 it->wd->bring_in = EINA_TRUE;
4663 it->showme = EINA_TRUE;
4666 if (it->wd->show_item)
4668 it->wd->show_item->showme = EINA_FALSE;
4669 it->wd->show_item = NULL;
4671 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4672 elm_smart_scroller_region_bring_in(it->wd->scr,
4673 it->x + it->block->x,
4674 it->y + it->block->y - oh / 2 + it->h / 2,
4679 elm_genlist_item_del(Elm_Genlist_Item *it)
4681 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4682 if ((it->relcount > 0) || (it->walking > 0))
4684 elm_widget_item_pre_notify_del(it);
4685 elm_genlist_item_subitems_clear(it);
4686 it->delete_me = EINA_TRUE;
4687 if (it->wd->show_item == it) it->wd->show_item = NULL;
4689 it->wd->selected = eina_list_remove(it->wd->selected,
4693 if (it->realized) _item_unrealize(it, EINA_FALSE);
4694 it->block->changed = EINA_TRUE;
4695 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4696 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4698 if (it->itc->func.del)
4699 it->itc->func.del((void *)it->base.data, WIDGET(it));
4706 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4709 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4710 elm_widget_item_data_set(it, data);
4714 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4716 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4717 return elm_widget_item_data_get(it);
4721 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4724 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4725 EINA_LIST_FREE(it->icon_objs, icon)
4727 elm_widget_sub_object_del(WIDGET(it), icon);
4728 evas_object_smart_member_del(icon);
4729 evas_object_hide(icon);
4733 EAPI const Evas_Object *
4734 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4736 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4741 elm_genlist_item_update(Elm_Genlist_Item *it)
4743 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4744 if (!it->block) return;
4745 if (it->delete_me) return;
4746 it->mincalcd = EINA_FALSE;
4747 it->updateme = EINA_TRUE;
4748 it->block->updateme = EINA_TRUE;
4749 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4750 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4751 it->defer_unrealize = EINA_FALSE;
4755 elm_genlist_item_fields_update(Elm_Genlist_Item *it,
4757 Elm_Genlist_Item_Field_Flags itf)
4759 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4760 if (!it->block) return;
4761 if (it->delete_me) return;
4763 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_LABEL))
4764 _item_label_realize(it, VIEW(it), &it->labels, parts);
4765 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_ICON))
4767 it->icon_objs = _item_icon_unrealize(it, VIEW(it),
4769 it->icon_objs = _item_icon_realize(it, VIEW(it),
4772 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
4773 _item_state_realize(it, VIEW(it), &it->states, parts);
4777 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4778 const Elm_Genlist_Item_Class *itc)
4780 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4781 if (!it->block) return;
4782 EINA_SAFETY_ON_NULL_RETURN(itc);
4783 if (it->delete_me) return;
4785 it->nocache = EINA_TRUE;
4786 elm_genlist_item_update(it);
4789 EAPI const Elm_Genlist_Item_Class *
4790 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4792 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4793 if (it->delete_me) return NULL;
4796 static Evas_Object *
4797 _elm_genlist_item_label_create(void *data,
4799 void *item __UNUSED__)
4801 Evas_Object *label = elm_label_add(obj);
4804 elm_object_style_set(label, "tooltip");
4805 elm_object_text_set(label, data);
4810 _elm_genlist_item_label_del_cb(void *data,
4811 Evas_Object *obj __UNUSED__,
4812 void *event_info __UNUSED__)
4814 eina_stringshare_del(data);
4818 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4821 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4822 text = eina_stringshare_add(text);
4823 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4825 _elm_genlist_item_label_del_cb);
4829 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4830 Elm_Tooltip_Item_Content_Cb func,
4832 Evas_Smart_Cb del_cb)
4834 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4836 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4839 if (item->tooltip.del_cb)
4840 item->tooltip.del_cb((void *)item->tooltip.data,
4841 item->base.widget, item);
4843 item->tooltip.content_cb = func;
4844 item->tooltip.data = data;
4845 item->tooltip.del_cb = del_cb;
4849 elm_widget_item_tooltip_content_cb_set(item,
4850 item->tooltip.content_cb,
4851 item->tooltip.data, NULL);
4852 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4858 if (del_cb) del_cb((void *)data, NULL, NULL);
4862 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4864 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4865 if ((item->base.view) && (item->tooltip.content_cb))
4866 elm_widget_item_tooltip_unset(item);
4868 if (item->tooltip.del_cb)
4869 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4870 item->tooltip.del_cb = NULL;
4871 item->tooltip.content_cb = NULL;
4872 item->tooltip.data = NULL;
4873 if (item->tooltip.style)
4874 elm_genlist_item_tooltip_style_set(item, NULL);
4878 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4881 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4882 eina_stringshare_replace(&item->tooltip.style, style);
4883 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4887 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4889 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4890 return item->tooltip.style;
4894 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4897 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4898 eina_stringshare_replace(&item->mouse_cursor, cursor);
4899 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4903 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4905 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4906 return elm_widget_item_cursor_get(item);
4910 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4912 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4913 if (!item->mouse_cursor)
4917 elm_widget_item_cursor_unset(item);
4919 eina_stringshare_del(item->mouse_cursor);
4920 item->mouse_cursor = NULL;
4924 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4927 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4928 elm_widget_item_cursor_style_set(item, style);
4932 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4934 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4935 return elm_widget_item_cursor_style_get(item);
4939 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4940 Eina_Bool engine_only)
4942 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4943 elm_widget_item_cursor_engine_only_set(item, engine_only);
4947 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4949 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4950 return elm_widget_item_cursor_engine_only_get(item);
4954 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4957 ELM_CHECK_WIDTYPE(obj, widtype);
4958 Widget_Data *wd = elm_widget_data_get(obj);
4960 if (wd->mode == mode) return;
4966 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4968 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4969 Widget_Data *wd = elm_widget_data_get(obj);
4970 if (!wd) return ELM_LIST_LAST;
4975 elm_genlist_always_select_mode_set(Evas_Object *obj,
4976 Eina_Bool always_select)
4978 ELM_CHECK_WIDTYPE(obj, widtype);
4979 Widget_Data *wd = elm_widget_data_get(obj);
4981 wd->always_select = always_select;
4985 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4987 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4988 Widget_Data *wd = elm_widget_data_get(obj);
4989 if (!wd) return EINA_FALSE;
4990 return wd->always_select;
4994 elm_genlist_no_select_mode_set(Evas_Object *obj,
4995 Eina_Bool no_select)
4997 ELM_CHECK_WIDTYPE(obj, widtype);
4998 Widget_Data *wd = elm_widget_data_get(obj);
5000 wd->no_select = no_select;
5004 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5006 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5007 Widget_Data *wd = elm_widget_data_get(obj);
5008 if (!wd) return EINA_FALSE;
5009 return wd->no_select;
5013 elm_genlist_compress_mode_set(Evas_Object *obj,
5016 ELM_CHECK_WIDTYPE(obj, widtype);
5017 Widget_Data *wd = elm_widget_data_get(obj);
5019 wd->compress = compress;
5023 elm_genlist_compress_mode_get(const Evas_Object *obj)
5025 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5026 Widget_Data *wd = elm_widget_data_get(obj);
5027 if (!wd) return EINA_FALSE;
5028 return wd->compress;
5032 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5033 Eina_Bool height_for_width)
5035 ELM_CHECK_WIDTYPE(obj, widtype);
5036 Widget_Data *wd = elm_widget_data_get(obj);
5038 wd->height_for_width = !!height_for_width;
5039 if (wd->height_for_width)
5041 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5042 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5047 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5049 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5050 Widget_Data *wd = elm_widget_data_get(obj);
5051 if (!wd) return EINA_FALSE;
5052 return wd->height_for_width;
5056 elm_genlist_bounce_set(Evas_Object *obj,
5060 ELM_CHECK_WIDTYPE(obj, widtype);
5061 Widget_Data *wd = elm_widget_data_get(obj);
5063 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5067 elm_genlist_bounce_get(const Evas_Object *obj,
5068 Eina_Bool *h_bounce,
5069 Eina_Bool *v_bounce)
5071 ELM_CHECK_WIDTYPE(obj, widtype);
5072 Widget_Data *wd = elm_widget_data_get(obj);
5074 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
5078 elm_genlist_homogeneous_set(Evas_Object *obj,
5079 Eina_Bool homogeneous)
5081 ELM_CHECK_WIDTYPE(obj, widtype);
5082 Widget_Data *wd = elm_widget_data_get(obj);
5084 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5085 wd->homogeneous = homogeneous;
5089 elm_genlist_homogeneous_get(const Evas_Object *obj)
5091 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5092 Widget_Data *wd = elm_widget_data_get(obj);
5093 if (!wd) return EINA_FALSE;
5094 return wd->homogeneous;
5098 elm_genlist_block_count_set(Evas_Object *obj,
5101 ELM_CHECK_WIDTYPE(obj, widtype);
5102 Widget_Data *wd = elm_widget_data_get(obj);
5104 wd->max_items_per_block = n;
5105 wd->item_cache_max = wd->max_items_per_block * 2;
5106 _item_cache_clean(wd);
5110 elm_genlist_block_count_get(const Evas_Object *obj)
5112 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5113 Widget_Data *wd = elm_widget_data_get(obj);
5115 return wd->max_items_per_block;
5119 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5122 ELM_CHECK_WIDTYPE(obj, widtype);
5123 Widget_Data *wd = elm_widget_data_get(obj);
5125 wd->longpress_timeout = timeout;
5129 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5131 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5132 Widget_Data *wd = elm_widget_data_get(obj);
5134 return wd->longpress_timeout;
5138 elm_genlist_scroller_policy_set(Evas_Object *obj,
5139 Elm_Scroller_Policy policy_h,
5140 Elm_Scroller_Policy policy_v)
5142 ELM_CHECK_WIDTYPE(obj, widtype);
5143 Widget_Data *wd = elm_widget_data_get(obj);
5144 if ((!wd) || (!wd->scr)) return;
5145 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5146 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5148 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5152 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5153 Elm_Scroller_Policy *policy_h,
5154 Elm_Scroller_Policy *policy_v)
5156 ELM_CHECK_WIDTYPE(obj, widtype);
5157 Widget_Data *wd = elm_widget_data_get(obj);
5158 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5159 if ((!wd) || (!wd->scr)) return;
5160 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5161 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5162 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5166 elm_genlist_realized_items_update(Evas_Object *obj)
5168 ELM_CHECK_WIDTYPE(obj, widtype);
5170 Eina_List *list, *l;
5171 Elm_Genlist_Item *it;
5173 list = elm_genlist_realized_items_get(obj);
5174 EINA_LIST_FOREACH(list, l, it)
5175 elm_genlist_item_update(it);
5179 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5180 const char *mode_type,
5183 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5184 Widget_Data *wd = it->wd;
5186 Elm_Genlist_Item *it2;
5189 if (!mode_type) return;
5190 if ((it->delete_me) || (it->disabled)) return;
5191 if (wd->edit_mode) return;
5193 if ((wd->mode_item == it) &&
5194 (!strcmp(mode_type, wd->mode_type)) &&
5197 if (!it->itc->mode_item_style) return;
5201 EINA_LIST_FOREACH(wd->selected, l, it2)
5203 elm_genlist_item_selected_set(it2, EINA_FALSE);
5207 it2 = elm_genlist_selected_item_get(wd->obj);
5208 if ((it2) && (it2->realized))
5209 elm_genlist_item_selected_set(it2, EINA_FALSE);
5212 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5214 ((it == wd->mode_item) && (!mode_set)))
5215 _item_mode_unset(wd);
5217 eina_stringshare_replace(&wd->mode_type, mode_type);
5218 if (mode_set) _item_mode_set(it);
5222 elm_genlist_mode_get(const Evas_Object *obj)
5224 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5225 Widget_Data *wd = elm_widget_data_get(obj);
5226 if (!wd) return NULL;
5227 return wd->mode_type;
5230 EAPI const Elm_Genlist_Item *
5231 elm_genlist_mode_item_get(const Evas_Object *obj)
5233 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5234 Widget_Data *wd = elm_widget_data_get(obj);
5235 if (!wd) return NULL;
5236 return wd->mode_item;
5240 elm_genlist_reorder_mode_set(Evas_Object *obj,
5241 Eina_Bool reorder_mode)
5243 ELM_CHECK_WIDTYPE(obj, widtype);
5244 Widget_Data *wd = elm_widget_data_get(obj);
5246 wd->reorder_mode = reorder_mode;
5250 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5252 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5253 Widget_Data *wd = elm_widget_data_get(obj);
5254 if (!wd) return EINA_FALSE;
5255 return wd->reorder_mode;
5259 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
5265 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
5271 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5273 ELM_CHECK_WIDTYPE(obj, widtype);
5274 Widget_Data *wd = elm_widget_data_get(obj);
5276 wd->effect_mode = emode;
5277 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5278 // evas_object_resize(wd->point_rect, 10, 25);
5279 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5280 // evas_object_show(wd->point_rect);
5281 // evas_object_hide(wd->point_rect);
5285 _create_tray_alpha_bg(const Evas_Object *obj)
5287 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5288 Widget_Data *wd = elm_widget_data_get(obj);
5289 if (!wd) return NULL;
5291 Evas_Object *bg = NULL;
5292 Evas_Coord ox, oy, ow, oh;
5294 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5295 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5296 evas_object_color_set(bg,0,0,0,0);
5297 evas_object_resize(bg , ow, oh);
5298 evas_object_move(bg , ox, oy);
5299 evas_object_show(bg);
5300 evas_object_hide(bg);
5307 struct timeval timev;
5309 gettimeofday(&timev, NULL);
5310 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5313 // added for item moving animation.
5315 _item_moving_effect_timer_cb(void *data)
5317 Widget_Data *wd = data;
5318 if (!wd) return EINA_FALSE;
5320 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5321 Elm_Genlist_Item *it = NULL, *it2;
5323 double time = 0.5, t;
5325 Eina_Bool check, end = EINA_FALSE;
5328 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5330 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5331 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5332 if (t > time) end = EINA_TRUE;
5334 it2 = elm_genlist_item_next_get(wd->expand_item);
5337 if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5338 it2 = elm_genlist_item_next_get(it2);
5343 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5344 dy = ((it2->scrl_y > cvy + cvh) ? cvy + cvh : it2->scrl_y) - it2->old_scrl_y;
5345 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5346 dy = wd->expand_item_gap;
5350 y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5359 EINA_INLIST_FOREACH(wd->blocks, itb)
5362 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5363 itb->y - wd->pan_y + oy,
5365 cvx, cvy, cvw, cvh))
5367 EINA_LIST_FOREACH(itb->items, l, it)
5369 if (it == it2) check = EINA_TRUE;
5370 if (!check) continue;
5372 if (!it->old_scrl_y)
5373 it->old_scrl_y = it->scrl_y;
5374 if (it->old_scrl_y + y < oy + oh)
5376 if (!it->realized) _item_realize(it, in, 0);
5378 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5379 it->old_scrl_y = it->scrl_y - y;
5382 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5383 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5385 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5388 evas_object_resize(VIEW(it), it->w, it->h);
5389 evas_object_move(VIEW(it), it->scrl_x, it->old_scrl_y + y);
5390 evas_object_show(VIEW(it));
5391 evas_object_raise(VIEW(it));
5394 if (it->group_item) evas_object_raise(it->group_item->base.view);
5400 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5402 it = elm_genlist_item_prev_get(it2);
5405 if (it->expanded_depth <= it2->expanded_depth) break;
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), "flip_item", "");
5411 evas_object_show(VIEW(it));
5412 it->effect_done = EINA_TRUE;
5415 it = elm_genlist_item_prev_get(it);
5418 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5420 it = elm_genlist_item_prev_get(it2);
5423 if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5425 if (!it->effect_done)
5427 edje_object_signal_emit(VIEW(it), "elm,state,hide", "");
5428 it->effect_done = EINA_TRUE;
5433 it = elm_genlist_item_prev_get(it);
5440 int expand_order = 0;
5441 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5445 it = elm_genlist_item_next_get(it);
5447 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5451 if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
5452 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5454 if (!it->effect_done)
5456 if (t >= (((expand_order - 1) * time) / expand_num))
5458 edje_object_signal_emit(VIEW(it), "flip_item", "");
5459 evas_object_show(VIEW(it));
5460 it->effect_done = EINA_TRUE;
5464 it = elm_genlist_item_next_get(it);
5470 if (wd->item_moving_effect_timer)
5472 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5473 _item_subitems_clear(wd->expand_item);
5474 EINA_INLIST_FOREACH(wd->blocks, itb)
5476 EINA_LIST_FOREACH(itb->items, l, it)
5478 it->effect_done = EINA_TRUE;
5479 it->old_scrl_y = it->scrl_y;
5483 wd->item_moving_effect_timer = NULL;
5485 _item_auto_scroll(wd);
5486 evas_object_lower(wd->alpha_bg);
5487 evas_object_hide(wd->alpha_bg);
5488 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5489 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5491 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5492 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5493 evas_object_smart_changed(wd->pan_smart);
5494 return ECORE_CALLBACK_CANCEL;
5496 return ECORE_CALLBACK_RENEW;
5500 _emit_contract(Elm_Genlist_Item *it)
5502 Elm_Genlist_Item *it2;
5505 // printf("%p is emited contract\n", it);
5506 edje_object_signal_emit(VIEW(it), "elm,state,contract_flip", "");
5507 it->effect_done = EINA_FALSE;
5509 EINA_LIST_FOREACH(it->items, l, it2)
5511 _emit_contract(it2);
5514 // added for item moving animation.
5516 _item_flip_effect_show(Elm_Genlist_Item *it)
5518 Elm_Genlist_Item *it2;
5520 Widget_Data *wd = it->wd;
5521 Eina_Bool check = EINA_FALSE;
5523 it2 = elm_genlist_item_next_get(it);
5526 if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5527 it2 = elm_genlist_item_next_get(it2);
5529 EINA_LIST_FOREACH(it->items, l, it2)
5531 if (it2->parent && it == it2->parent)
5533 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5534 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5535 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5536 _emit_contract(it2);
5540 return ECORE_CALLBACK_CANCEL;
5545 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5547 printf("!!! NOW FIXING \n");
5552 * Set pinch zoom mode
5554 * @param obj The genlist object
5556 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5561 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5563 printf("!!! NOW FIXING \n");
5567 * Get pinch zoom mode
5569 * @param obj The genlist object
5570 * @return The pinch mode
5571 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5576 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
5578 printf("!!! NOW FIXING \n");
5583 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5585 printf("!!! NOW FIXING \n");
5589 ////////////////////////////////////////////////////////////////////////
5591 ////////////////////////////////////////////////////////////////////////
5594 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5596 if (!it->wd->edit_mode) return;
5597 evas_object_resize(it->edit_obj,it->w, it->h);
5598 evas_object_move(it->edit_obj, itx, ity);
5602 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5604 if ((it->effect_item_realized) || (it->delete_me)) return;
5608 _mode_finished_signal_cb(it, (Evas_Object *)elm_genlist_item_object_get(it), NULL, NULL);
5610 it->edit_obj = edje_object_add(evas_object_evas_get(WIDGET(it)));
5611 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(WIDGET(it)) *
5612 _elm_config->scale);
5613 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5614 elm_widget_sub_object_add(WIDGET(it), it->edit_obj);
5616 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5617 else strncpy(buf, "item", sizeof(buf));
5618 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5620 strncat(buf, "/", sizeof(buf) - strlen(buf));
5622 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5624 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
5625 _elm_theme_object_set(WIDGET(it), it->edit_obj, "genlist", buf, elm_widget_style_get(WIDGET(it)));
5629 _elm_theme_object_set(WIDGET(it), it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(WIDGET(it)));
5632 if (it->wd->reorder_mode)
5634 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
5635 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
5637 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
5638 else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
5640 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
5641 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
5644 if ((it->wd->edit_mode))
5646 if (it->itc->func.icon_get)
5651 if (it->renamed) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
5652 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5653 EINA_LIST_FOREACH(it->icons, l, key)
5655 Evas_Object *ic = it->itc->func.icon_get
5656 ((void *)it->base.data, WIDGET(it), l->data);
5660 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5661 edje_object_part_swallow(it->edit_obj, key, ic);
5662 evas_object_show(ic);
5663 elm_widget_sub_object_add(WIDGET(it), ic);
5665 elm_widget_disabled_set(ic, EINA_TRUE);
5670 edje_object_part_swallow(it->edit_obj, "original_edc", VIEW(it));
5671 _effect_item_controls(it,it->scrl_x, it->scrl_y);
5672 evas_object_show(it->edit_obj);
5674 it->effect_item_realized = EINA_TRUE;
5675 it->want_unrealize = EINA_FALSE;
5679 _effect_item_unrealize(Elm_Genlist_Item *it)
5683 if (!it->effect_item_realized) return;
5684 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5686 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
5687 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
5688 edje_object_message_signal_process(it->edit_obj);
5689 edje_object_part_unswallow(it->edit_obj, VIEW(it));
5690 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
5691 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
5692 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5693 // _item_cache_add(it);
5694 evas_object_del(it->edit_obj);
5695 it->edit_obj = NULL;
5696 EINA_LIST_FREE(it->edit_icon_objs, icon)
5697 evas_object_del(icon);
5699 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5700 it->effect_item_realized = EINA_FALSE;
5704 * Get Genlist edit mode
5706 * @param obj The genlist object
5707 * @return The edit mode status
5708 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5713 elm_genlist_edit_mode_get(const Evas_Object *obj)
5715 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5716 Widget_Data *wd = elm_widget_data_get(obj);
5717 if (!wd) return EINA_FALSE;
5719 if (wd->edit_mode) return EINA_TRUE;
5720 else return EINA_FALSE;
5724 * Set Genlist edit mode
5726 * This sets Genlist edit mode.
5728 * @param obj The Genlist object
5729 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5730 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5735 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5737 ELM_CHECK_WIDTYPE(obj, widtype);
5741 Elm_Genlist_Item *it;
5743 Widget_Data *wd = elm_widget_data_get(obj);
5745 if (wd->edit_mode == edit_mode) return;
5747 wd->edit_mode = edit_mode;
5750 EINA_INLIST_FOREACH(wd->blocks, itb)
5754 EINA_LIST_FOREACH(itb->items, l, it)
5756 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5758 _effect_item_unrealize(it);
5763 _item_cache_zero(wd);
5768 EINA_INLIST_FOREACH(wd->blocks, itb)
5772 EINA_LIST_FOREACH(itb->items, l, it)
5774 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5776 if(it->selected) _item_unselect(it);
5777 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
5784 if (wd->calc_job) ecore_job_del(wd->calc_job);
5785 wd->calc_job = ecore_job_add(_calc_job, wd);
5789 * Set a given item's rename mode
5791 * This renames the item's label from genlist
5793 * @param it The item
5794 * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
5799 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
5805 _item_unrealize(it, EINA_FALSE);
5806 it->renamed = EINA_TRUE;
5807 it->wd->rename_it = it;
5808 it->nocache = EINA_TRUE;
5809 if (it->selected) _item_unselect(it);
5811 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5812 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5818 it->renamed = EINA_FALSE;
5819 it->nocache = EINA_TRUE;
5820 it->wd->rename_it = NULL;
5821 _item_cache_zero(it->wd);
5822 elm_genlist_item_update(it);
5828 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
5830 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5831 return item->renamed;