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 *focused_rename_it;
94 Evas_Coord current_scrl_x;
95 Evas_Coord current_scrl_y;
106 Evas_Coord x, y, w, h, minw, minh;
107 Eina_Bool want_unrealize : 1;
108 Eina_Bool realized : 1;
109 Eina_Bool changed : 1;
110 Eina_Bool updateme : 1;
111 Eina_Bool changeme : 1;
112 Eina_Bool showme : 1;
113 Eina_Bool must_recalc : 1;
116 struct _Elm_Genlist_Item
118 Elm_Widget_Item base;
123 Evas_Coord x, y, w, h, minw, minh;
124 const Elm_Genlist_Item_Class *itc;
125 Elm_Genlist_Item *parent;
126 Elm_Genlist_Item *group_item;
127 Elm_Genlist_Item_Flags flags;
135 Eina_List *labels, *icons, *states, *icon_objs;
136 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
137 Ecore_Timer *long_timer;
138 Ecore_Timer *swipe_timer;
140 Evas_Coord scrl_x, scrl_y;
142 Elm_Genlist_Item *rel;
143 Evas_Object *mode_view;
148 Elm_Tooltip_Item_Content_Cb content_cb;
149 Evas_Smart_Cb del_cb;
153 const char *mouse_cursor;
160 Eina_Bool before : 1;
162 Eina_Bool want_unrealize : 1;
163 Eina_Bool want_realize : 1;
164 Eina_Bool realized : 1;
165 Eina_Bool selected : 1;
166 Eina_Bool highlighted : 1;
167 Eina_Bool expanded : 1;
168 Eina_Bool disabled : 1;
169 Eina_Bool display_only : 1;
170 Eina_Bool mincalcd : 1;
171 Eina_Bool queued : 1;
172 Eina_Bool showme : 1;
173 Eina_Bool delete_me : 1;
175 Eina_Bool dragging : 1;
176 Eina_Bool updateme : 1;
177 Eina_Bool nocache : 1;
178 Eina_Bool move_effect_enabled : 1;
179 Eina_Bool defer_unrealize : 1;
182 Eina_Bool effect_done : 1;
183 Eina_Bool reordering : 1;
184 Eina_Bool renamed : 1;
185 Eina_Bool effect_item_realized : 1;
186 Eina_List *edit_icon_objs;
187 Evas_Object *edit_obj;
189 Ecore_Animator *item_moving_effect_timer;
190 Evas_Coord old_scrl_y;
197 Evas_Object *base_view, *spacer;
199 const char *item_style; // it->itc->item_style
200 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
201 Eina_Bool compress : 1; // it->wd->compress
202 Eina_Bool odd : 1; // in & 0x1
204 Eina_Bool selected : 1; // it->selected
205 Eina_Bool disabled : 1; // it->disabled
206 Eina_Bool expanded : 1; // it->expanded
209 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
210 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
214 Evas_Object_Smart_Clipped_Data __clipped_data;
216 Ecore_Job *resize_job;
219 static const char *widtype = NULL;
220 static void _item_cache_zero(Widget_Data *wd);
221 static void _del_hook(Evas_Object *obj);
222 static void _mirrored_set(Evas_Object *obj,
224 static void _theme_hook(Evas_Object *obj);
225 static void _show_region_hook(void *data,
227 static void _sizing_eval(Evas_Object *obj);
228 static void _item_realize(Elm_Genlist_Item *it,
231 static void _item_unrealize(Elm_Genlist_Item *it,
233 static void _item_block_unrealize(Item_Block *itb);
234 static void _calc_job(void *data);
235 static void _on_focus_hook(void *data,
237 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
238 static void _changed_job(void *data);
239 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
240 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
241 static Eina_Bool _item_single_select_up(Widget_Data *wd);
242 static Eina_Bool _item_single_select_down(Widget_Data *wd);
243 static Eina_Bool _event_hook(Evas_Object *obj,
245 Evas_Callback_Type type,
247 static void _signal_emit_hook(Evas_Object *obj,
248 const char *emission,
250 static Eina_Bool _deselect_all_items(Widget_Data *wd);
251 static void _pan_calculate(Evas_Object *obj);
252 static void _pan_max_get(Evas_Object *obj,
255 static void _item_position(Elm_Genlist_Item *it,
259 static void _mode_item_realize(Elm_Genlist_Item *it);
260 static void _mode_item_unrealize(Elm_Genlist_Item *it);
261 static void _item_mode_set(Elm_Genlist_Item *it);
262 static void _item_mode_unset(Widget_Data *wd);
263 static void _group_items_recalc(void *data);
264 static void _item_move_after(Elm_Genlist_Item *it,
265 Elm_Genlist_Item *after);
266 static void _item_move_before(Elm_Genlist_Item *it,
267 Elm_Genlist_Item *before);
269 // TODO : refactoring
270 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
271 static unsigned int current_time_get();
272 static Eina_Bool _item_moving_effect_timer_cb(void *data);
273 static int _item_flip_effect_show(Elm_Genlist_Item *it);
274 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
275 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
276 static void _effect_item_unrealize(Elm_Genlist_Item *it);
277 static void _item_auto_scroll(void *data);
279 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
281 static const char SIG_ACTIVATED[] = "activated";
282 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
283 static const char SIG_SELECTED[] = "selected";
284 static const char SIG_UNSELECTED[] = "unselected";
285 static const char SIG_EXPANDED[] = "expanded";
286 static const char SIG_CONTRACTED[] = "contracted";
287 static const char SIG_EXPAND_REQUEST[] = "expand,request";
288 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
289 static const char SIG_REALIZED[] = "realized";
290 static const char SIG_UNREALIZED[] = "unrealized";
291 static const char SIG_DRAG_START_UP[] = "drag,start,up";
292 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
293 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
294 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
295 static const char SIG_DRAG_STOP[] = "drag,stop";
296 static const char SIG_DRAG[] = "drag";
297 static const char SIG_LONGPRESSED[] = "longpressed";
298 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
299 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
300 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
301 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
302 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
303 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
304 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
305 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
306 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
307 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
308 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
309 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
310 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
311 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
312 static const char SIG_SWIPE[] = "swipe";
314 static const Evas_Smart_Cb_Description _signals[] = {
315 {SIG_CLICKED_DOUBLE, ""},
318 {SIG_UNSELECTED, ""},
320 {SIG_CONTRACTED, ""},
321 {SIG_EXPAND_REQUEST, ""},
322 {SIG_CONTRACT_REQUEST, ""},
324 {SIG_UNREALIZED, ""},
325 {SIG_DRAG_START_UP, ""},
326 {SIG_DRAG_START_DOWN, ""},
327 {SIG_DRAG_START_LEFT, ""},
328 {SIG_DRAG_START_RIGHT, ""},
331 {SIG_LONGPRESSED, ""},
332 {SIG_SCROLL_ANIM_START, ""},
333 {SIG_SCROLL_ANIM_STOP, ""},
334 {SIG_SCROLL_DRAG_START, ""},
335 {SIG_SCROLL_DRAG_STOP, ""},
336 {SIG_SCROLL_EDGE_TOP, ""},
337 {SIG_SCROLL_EDGE_BOTTOM, ""},
338 {SIG_SCROLL_EDGE_LEFT, ""},
339 {SIG_SCROLL_EDGE_RIGHT, ""},
340 {SIG_MULTI_SWIPE_LEFT, ""},
341 {SIG_MULTI_SWIPE_RIGHT, ""},
342 {SIG_MULTI_SWIPE_UP, ""},
343 {SIG_MULTI_SWIPE_DOWN, ""},
344 {SIG_MULTI_PINCH_OUT, ""},
345 {SIG_MULTI_PINCH_IN, ""},
351 _event_hook(Evas_Object *obj,
352 Evas_Object *src __UNUSED__,
353 Evas_Callback_Type type,
356 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
357 Evas_Event_Key_Down *ev = event_info;
358 Widget_Data *wd = elm_widget_data_get(obj);
359 Evas_Coord pan_max_x = 0, pan_max_y = 0;
360 if (!wd) return EINA_FALSE;
361 if (!wd->items) return EINA_FALSE;
362 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
363 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
365 Elm_Genlist_Item *it = NULL;
368 Evas_Coord step_x = 0;
369 Evas_Coord step_y = 0;
372 Evas_Coord page_x = 0;
373 Evas_Coord page_y = 0;
375 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
376 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
377 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
378 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
380 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
384 else if ((!strcmp(ev->keyname, "Right")) ||
385 (!strcmp(ev->keyname, "KP_Right")))
389 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
391 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
392 (_item_multi_select_up(wd)))
393 || (_item_single_select_up(wd)))
395 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
401 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
403 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
404 (_item_multi_select_down(wd)))
405 || (_item_single_select_down(wd)))
407 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
413 else if ((!strcmp(ev->keyname, "Home")) ||
414 (!strcmp(ev->keyname, "KP_Home")))
416 it = elm_genlist_first_item_get(obj);
417 elm_genlist_item_bring_in(it);
418 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
421 else if ((!strcmp(ev->keyname, "End")) ||
422 (!strcmp(ev->keyname, "KP_End")))
424 it = elm_genlist_last_item_get(obj);
425 elm_genlist_item_bring_in(it);
426 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
429 else if ((!strcmp(ev->keyname, "Prior")) ||
430 (!strcmp(ev->keyname, "KP_Prior")))
433 y -= -(page_y * v_h) / 100;
437 else if ((!strcmp(ev->keyname, "Next")) ||
438 (!strcmp(ev->keyname, "KP_Next")))
441 y += -(page_y * v_h) / 100;
445 else if (((!strcmp(ev->keyname, "Return")) ||
446 (!strcmp(ev->keyname, "KP_Enter")) ||
447 (!strcmp(ev->keyname, "space")))
448 && (!wd->multi) && (wd->selected))
450 it = elm_genlist_selected_item_get(obj);
451 elm_genlist_item_expanded_set(it,
452 !elm_genlist_item_expanded_get(it));
453 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
455 else if (!strcmp(ev->keyname, "Escape"))
457 if (!_deselect_all_items(wd)) return EINA_FALSE;
458 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
461 else return EINA_FALSE;
463 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
464 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
466 if (x > pan_max_x) x = pan_max_x;
468 if (y > pan_max_y) y = pan_max_y;
469 elm_smart_scroller_child_pos_set(wd->scr, x, y);
474 _deselect_all_items(Widget_Data *wd)
476 if (!wd->selected) return EINA_FALSE;
478 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
484 _item_multi_select_up(Widget_Data *wd)
486 if (!wd->selected) return EINA_FALSE;
487 if (!wd->multi) return EINA_FALSE;
489 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
490 if (!prev) return EINA_TRUE;
492 if (elm_genlist_item_selected_get(prev))
494 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
495 wd->last_selected_item = prev;
496 elm_genlist_item_show(wd->last_selected_item);
500 elm_genlist_item_selected_set(prev, EINA_TRUE);
501 elm_genlist_item_show(prev);
507 _item_multi_select_down(Widget_Data *wd)
509 if (!wd->selected) return EINA_FALSE;
510 if (!wd->multi) return EINA_FALSE;
512 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
513 if (!next) return EINA_TRUE;
515 if (elm_genlist_item_selected_get(next))
517 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
518 wd->last_selected_item = next;
519 elm_genlist_item_show(wd->last_selected_item);
523 elm_genlist_item_selected_set(next, EINA_TRUE);
524 elm_genlist_item_show(next);
530 _item_single_select_up(Widget_Data *wd)
532 Elm_Genlist_Item *prev;
535 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
536 while ((prev) && (prev->delete_me))
537 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
539 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
541 if (!prev) return EINA_FALSE;
543 _deselect_all_items(wd);
545 elm_genlist_item_selected_set(prev, EINA_TRUE);
546 elm_genlist_item_show(prev);
551 _item_single_select_down(Widget_Data *wd)
553 Elm_Genlist_Item *next;
556 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
557 while ((next) && (next->delete_me))
558 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
560 else next = elm_genlist_item_next_get(wd->last_selected_item);
562 if (!next) return EINA_FALSE;
564 _deselect_all_items(wd);
566 elm_genlist_item_selected_set(next, EINA_TRUE);
567 elm_genlist_item_show(next);
572 _on_focus_hook(void *data __UNUSED__,
575 Widget_Data *wd = elm_widget_data_get(obj);
577 if (elm_widget_focus_get(obj))
579 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
580 evas_object_focus_set(wd->obj, EINA_TRUE);
581 if ((wd->items) && (wd->selected) && (!wd->last_selected_item))
582 wd->last_selected_item = eina_list_data_get(wd->selected);
586 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
587 evas_object_focus_set(wd->obj, EINA_FALSE);
592 _del_hook(Evas_Object *obj)
594 Widget_Data *wd = elm_widget_data_get(obj);
596 _item_cache_zero(wd);
597 if (wd->calc_job) ecore_job_del(wd->calc_job);
598 if (wd->update_job) ecore_job_del(wd->update_job);
599 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
600 if (wd->changed_job) ecore_job_del(wd->changed_job);
601 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
602 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
603 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
604 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
609 _del_pre_hook(Evas_Object *obj)
611 Widget_Data *wd = elm_widget_data_get(obj);
613 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
614 elm_genlist_clear(obj);
615 evas_object_del(wd->pan_smart);
616 wd->pan_smart = NULL;
620 _mirrored_set(Evas_Object *obj,
623 Widget_Data *wd = elm_widget_data_get(obj);
625 _item_cache_zero(wd);
626 elm_smart_scroller_mirrored_set(wd->scr, rtl);
630 _theme_hook(Evas_Object *obj)
632 Widget_Data *wd = elm_widget_data_get(obj);
635 evas_event_freeze(evas_object_evas_get(wd->obj));
636 _item_cache_zero(wd);
637 _elm_widget_mirrored_reload(obj);
638 _mirrored_set(obj, elm_widget_mirrored_get(obj));
639 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
640 elm_widget_style_get(obj));
641 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
642 wd->item_width = wd->item_height = 0;
643 wd->group_item_width = wd->group_item_height = 0;
644 wd->minw = wd->minh = wd->realminw = 0;
645 EINA_INLIST_FOREACH(wd->blocks, itb)
648 Elm_Genlist_Item *it;
650 if (itb->realized) _item_block_unrealize(itb);
651 EINA_LIST_FOREACH(itb->items, l, it)
652 it->mincalcd = EINA_FALSE;
654 itb->changed = EINA_TRUE;
656 if (wd->calc_job) ecore_job_del(wd->calc_job);
657 wd->calc_job = ecore_job_add(_calc_job, wd);
659 evas_event_thaw(evas_object_evas_get(wd->obj));
660 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
664 _show_region_hook(void *data,
667 Widget_Data *wd = elm_widget_data_get(data);
668 Evas_Coord x, y, w, h;
669 Evas_Coord px, py, pw, ph;
670 Evas_Coord new_x, new_y;
672 elm_widget_show_region_get(obj, &x, &y, &w, &h);
673 evas_object_geometry_get(wd->pan_smart, &px, &py, &pw, &ph);
675 //x & y are screen coordinates, Add with pan coordinates
676 new_x = wd->current_scrl_x + x - pw + w;
677 new_y = wd->current_scrl_y + y - ph + h;
679 if (((new_y > 0) && wd->pan_changed && (y > ph)) || ((new_x > 0) && wd->pan_changed && (x > pw)))
680 elm_smart_scroller_child_pos_set(wd->scr, new_x, new_y);
682 elm_smart_scroller_child_pos_set(wd->scr, wd->current_scrl_x, wd->current_scrl_y);
686 _translate_hook(Evas_Object *obj)
688 evas_object_smart_callback_call(obj, "language,changed", NULL);
692 _sizing_eval(Evas_Object *obj)
694 Widget_Data *wd = elm_widget_data_get(obj);
695 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
697 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
698 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
700 if (wd->height_for_width)
704 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
705 if ((vw != 0) && (vw != wd->prev_viewport_w))
709 wd->prev_viewport_w = vw;
710 EINA_INLIST_FOREACH(wd->blocks, itb)
712 itb->must_recalc = EINA_TRUE;
714 if (wd->calc_job) ecore_job_del(wd->calc_job);
715 wd->calc_job = ecore_job_add(_calc_job, wd);
718 if (wd->mode == ELM_LIST_LIMIT)
720 Evas_Coord vmw, vmh, vw, vh;
724 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
725 if ((minw > 0) && (vw < minw)) vw = minw;
726 else if ((maxw > 0) && (vw > maxw))
728 edje_object_size_min_calc
729 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
736 edje_object_size_min_calc
737 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
741 evas_object_size_hint_min_set(obj, minw, minh);
742 evas_object_size_hint_max_set(obj, maxw, maxh);
746 _signal_emit_hook(Evas_Object *obj,
747 const char *emission,
750 Widget_Data *wd = elm_widget_data_get(obj);
751 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
756 _item_highlight(Elm_Genlist_Item *it)
758 const char *selectraise;
759 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
760 (it->disabled) || (it->display_only) || (it->mode_view))
762 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
763 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
764 selectraise = edje_object_data_get(VIEW(it), "selectraise");
765 if ((selectraise) && (!strcmp(selectraise, "on")))
767 if (it->edit_obj) evas_object_raise(it->edit_obj);
768 else evas_object_raise(VIEW(it));
769 if ((it->group_item) && (it->group_item->realized))
770 evas_object_raise(it->VIEW(group_item));
772 it->highlighted = EINA_TRUE;
776 _item_block_del(Elm_Genlist_Item *it)
779 Item_Block *itb = it->block;
781 itb->items = eina_list_remove(itb->items, it);
783 itb->changed = EINA_TRUE;
784 if (!it->wd->reorder_deleted)
786 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
787 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
791 il = EINA_INLIST_GET(itb);
792 Item_Block *itbn = (Item_Block *)(il->next);
794 it->parent->items = eina_list_remove(it->parent->items, it);
796 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
798 if (itbn) itbn->changed = EINA_TRUE;
802 if (itb->count < itb->wd->max_items_per_block/2)
804 il = EINA_INLIST_GET(itb);
805 Item_Block *itbp = (Item_Block *)(il->prev);
806 Item_Block *itbn = (Item_Block *)(il->next);
807 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
809 Elm_Genlist_Item *it2;
811 EINA_LIST_FREE(itb->items, it2)
814 itbp->items = eina_list_append(itbp->items, it2);
816 itbp->changed = EINA_TRUE;
818 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
819 EINA_INLIST_GET(itb));
822 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
826 Eina_List *last = eina_list_last(itb->items);
827 Elm_Genlist_Item *it2 = last->data;
830 itb->items = eina_list_remove_list(itb->items, last);
831 itbn->items = eina_list_prepend(itbn->items, it2);
833 itbn->changed = EINA_TRUE;
836 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
844 _item_subitems_clear(Elm_Genlist_Item *it)
847 Eina_List *tl = NULL, *l;
848 Elm_Genlist_Item *it2;
850 EINA_LIST_FOREACH(it->items, l, it2)
851 tl = eina_list_append(tl, it2);
853 EINA_LIST_FREE(tl, it2)
854 elm_genlist_item_del(it2);
858 _item_del(Elm_Genlist_Item *it)
860 Evas_Object *tob = it->wd->obj;
862 evas_event_freeze(evas_object_evas_get(tob));
863 elm_widget_item_pre_notify_del(it);
864 elm_genlist_item_subitems_clear(it);
865 it->wd->walking -= it->walking;
866 if (it->wd->show_item == it) it->wd->show_item = NULL;
867 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
868 if (it->realized) _item_unrealize(it, EINA_FALSE);
869 if (it->effect_item_realized) _effect_item_unrealize(it);
870 if (it->block) _item_block_del(it);
871 if ((!it->delete_me) && (it->itc->func.del))
872 it->itc->func.del((void *)it->base.data, WIDGET(it));
873 it->delete_me = EINA_TRUE;
875 it->wd->queue = eina_list_remove(it->wd->queue, it);
877 if (it->wd->anchor_item == it)
879 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
880 if (!it->wd->anchor_item)
881 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
884 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
886 it->parent->items = eina_list_remove(it->parent->items, it);
887 if (it->flags & ELM_GENLIST_ITEM_GROUP)
888 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
889 if (it->long_timer) ecore_timer_del(it->long_timer);
890 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
892 if (it->tooltip.del_cb)
893 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
895 evas_event_thaw(evas_object_evas_get(tob));
896 evas_event_thaw_eval(evas_object_evas_get(tob));
898 elm_widget_item_del(it);
902 _item_select(Elm_Genlist_Item *it)
906 Evas_Object *parent = WIDGET(it);
908 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
911 if (it->wd->always_select) goto call;
914 it->selected = EINA_TRUE;
915 it->wd->selected = eina_list_append(it->wd->selected, it);
917 evas_object_ref(parent);
920 if (it->wd->last_selected_item && (it != it->wd->last_selected_item))
922 EINA_LIST_FOREACH(it->wd->last_selected_item->icon_objs, l, obj)
923 elm_widget_focused_object_clear(obj);
925 if (it->func.func) it->func.func((void *)it->func.data, parent, it);
927 evas_object_smart_callback_call(parent, SIG_SELECTED, it);
930 if ((it->wd->clear_me) && (!it->wd->walking))
932 elm_genlist_clear(parent);
937 if ((!it->walking) && (it->delete_me))
939 if (!it->relcount) _item_del(it);
943 if (it && it->wd) it->wd->last_selected_item = it; // TODO: Remove 'if'?
945 evas_object_unref(parent);
949 _item_unselect(Elm_Genlist_Item *it)
951 const char *stacking, *selectraise;
953 if ((it->delete_me) || (!it->highlighted)) return;
954 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
955 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
956 stacking = edje_object_data_get(VIEW(it), "stacking");
957 selectraise = edje_object_data_get(VIEW(it), "selectraise");
958 if ((selectraise) && (!strcmp(selectraise, "on")))
960 if ((stacking) && (!strcmp(stacking, "below")))
961 evas_object_lower(VIEW(it));
963 it->highlighted = EINA_FALSE;
966 it->selected = EINA_FALSE;
967 it->wd->selected = eina_list_remove(it->wd->selected, it);
968 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
973 _mouse_move(void *data,
974 Evas *evas __UNUSED__,
978 Elm_Genlist_Item *it = data;
979 Evas_Event_Mouse_Move *ev = event_info;
980 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
981 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
983 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
985 if (!it->wd->on_hold)
987 it->wd->on_hold = EINA_TRUE;
988 if ((!it->wd->wasselected) && (!it->renamed))
992 if (it->wd->multitouched)
994 it->wd->cur_x = ev->cur.canvas.x;
995 it->wd->cur_y = ev->cur.canvas.y;
998 if ((it->dragging) && (it->down))
1000 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1003 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1004 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1005 if (abs((it->wd->history[it->wd->movements].x -
1006 it->wd->history[0].x)) > 40)
1007 it->wd->swipe = EINA_TRUE;
1009 it->wd->movements++;
1013 ecore_timer_del(it->long_timer);
1014 it->long_timer = NULL;
1016 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
1019 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1023 ecore_timer_del(it->long_timer);
1024 it->long_timer = NULL;
1026 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1028 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1029 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1031 if (!it->wd->reorder_start_y)
1032 it->wd->reorder_start_y = it->block->y + it->y;
1036 else if (it_scrl_y + it->wd->reorder_it->h > oy + oh)
1037 y_pos = oy + oh - it->wd->reorder_it->h;
1042 _item_position(it, it->edit_obj, it->scrl_x, y_pos);
1044 _item_position(it, VIEW(it), it->scrl_x, y_pos);
1046 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1047 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1051 if (!it->display_only)
1052 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1053 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1054 x = ev->cur.canvas.x - x;
1055 y = ev->cur.canvas.y - y;
1058 if (adx < 0) adx = -dx;
1061 if (ady < 0) ady = -dy;
1064 if ((adx > minw) || (ady > minh))
1066 it->dragging = EINA_TRUE;
1069 ecore_timer_del(it->long_timer);
1070 it->long_timer = NULL;
1072 if ((!it->wd->wasselected) && (!it->renamed))
1076 if ((ady > adx) && (!it->wd->drag_started))
1077 evas_object_smart_callback_call(WIDGET(it),
1078 SIG_DRAG_START_UP, it);
1082 evas_object_smart_callback_call(WIDGET(it),
1083 SIG_DRAG_START_LEFT, it);
1085 evas_object_smart_callback_call(WIDGET(it),
1086 SIG_DRAG_START_RIGHT, it);
1091 if ((ady > adx) && (!it->wd->drag_started))
1092 evas_object_smart_callback_call(WIDGET(it),
1093 SIG_DRAG_START_DOWN, it);
1097 evas_object_smart_callback_call(WIDGET(it),
1098 SIG_DRAG_START_LEFT, it);
1100 evas_object_smart_callback_call(WIDGET(it),
1101 SIG_DRAG_START_RIGHT, it);
1108 _long_press(void *data)
1110 Elm_Genlist_Item *it = data, *it_tmp;
1111 Eina_List *list, *l;
1113 it->long_timer = NULL;
1114 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->focused_rename_it))
1115 return ECORE_CALLBACK_CANCEL;
1116 it->wd->longpressed = EINA_TRUE;
1117 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
1118 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1120 it->wd->reorder_it = it;
1121 it->wd->reorder_start_y = 0;
1123 evas_object_raise(it->edit_obj);
1125 evas_object_raise(VIEW(it));
1127 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1128 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1130 list = elm_genlist_realized_items_get(it->wd->obj);
1131 EINA_LIST_FOREACH(list, l, it_tmp)
1133 if (it != it_tmp) _item_unselect(it_tmp);
1137 EINA_LIST_FOREACH(it->items, l, it_tmp)
1139 if (elm_genlist_item_expanded_get(it_tmp))
1141 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1142 return ECORE_CALLBACK_RENEW;
1146 if (elm_genlist_item_expanded_get(it))
1148 elm_genlist_item_expanded_set(it, EINA_FALSE);
1149 return ECORE_CALLBACK_RENEW;
1152 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1154 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
1156 return ECORE_CALLBACK_CANCEL;
1160 _swipe(Elm_Genlist_Item *it)
1165 if ((it->display_only) || (it->disabled)) return;
1166 it->wd->swipe = EINA_FALSE;
1167 for (i = 0; i < it->wd->movements; i++)
1169 sum += it->wd->history[i].x;
1170 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1173 sum /= it->wd->movements;
1174 if (abs(sum - it->wd->history[0].x) <= 10) return;
1175 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
1179 _swipe_cancel(void *data)
1181 Elm_Genlist_Item *it = data;
1183 if (!it) return ECORE_CALLBACK_CANCEL;
1184 it->wd->swipe = EINA_FALSE;
1185 it->wd->movements = 0;
1186 return ECORE_CALLBACK_RENEW;
1190 _multi_cancel(void *data)
1192 Widget_Data *wd = data;
1194 if (!wd) return ECORE_CALLBACK_CANCEL;
1195 wd->multi_timeout = EINA_TRUE;
1196 return ECORE_CALLBACK_RENEW;
1200 _multi_touch_gesture_eval(void *data)
1202 Elm_Genlist_Item *it = data;
1204 it->wd->multitouched = EINA_FALSE;
1205 if (it->wd->multi_timer)
1207 ecore_timer_del(it->wd->multi_timer);
1208 it->wd->multi_timer = NULL;
1210 if (it->wd->multi_timeout)
1212 it->wd->multi_timeout = EINA_FALSE;
1216 Evas_Coord minw = 0, minh = 0;
1217 Evas_Coord off_x, off_y, off_mx, off_my;
1219 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1220 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1221 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1222 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1223 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1225 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1227 if ((off_x + off_mx) > (off_y + off_my))
1229 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1230 evas_object_smart_callback_call(WIDGET(it),
1231 SIG_MULTI_SWIPE_RIGHT, it);
1232 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1233 evas_object_smart_callback_call(WIDGET(it),
1234 SIG_MULTI_SWIPE_LEFT, it);
1235 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1236 evas_object_smart_callback_call(WIDGET(it),
1237 SIG_MULTI_PINCH_OUT, it);
1239 evas_object_smart_callback_call(WIDGET(it),
1240 SIG_MULTI_PINCH_IN, it);
1244 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1245 evas_object_smart_callback_call(WIDGET(it),
1246 SIG_MULTI_SWIPE_DOWN, it);
1247 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1248 evas_object_smart_callback_call(WIDGET(it),
1249 SIG_MULTI_SWIPE_UP, it);
1250 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1251 evas_object_smart_callback_call(WIDGET(it),
1252 SIG_MULTI_PINCH_OUT, it);
1254 evas_object_smart_callback_call(WIDGET(it),
1255 SIG_MULTI_PINCH_IN, it);
1258 it->wd->multi_timeout = EINA_FALSE;
1262 _multi_down(void *data,
1263 Evas *evas __UNUSED__,
1264 Evas_Object *obj __UNUSED__,
1267 Elm_Genlist_Item *it = data;
1268 Evas_Event_Multi_Down *ev = event_info;
1270 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1271 it->wd->multi_device = ev->device;
1272 it->wd->multi_down = EINA_TRUE;
1273 it->wd->multitouched = EINA_TRUE;
1274 it->wd->prev_mx = ev->canvas.x;
1275 it->wd->prev_my = ev->canvas.y;
1276 if (!it->wd->wasselected) _item_unselect(it);
1277 it->wd->wasselected = EINA_FALSE;
1278 it->wd->longpressed = EINA_FALSE;
1281 ecore_timer_del(it->long_timer);
1282 it->long_timer = NULL;
1286 it->dragging = EINA_FALSE;
1287 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1289 if (it->swipe_timer)
1291 ecore_timer_del(it->swipe_timer);
1292 it->swipe_timer = NULL;
1294 if (it->wd->on_hold)
1296 it->wd->swipe = EINA_FALSE;
1297 it->wd->movements = 0;
1298 it->wd->on_hold = EINA_FALSE;
1303 _multi_up(void *data,
1304 Evas *evas __UNUSED__,
1305 Evas_Object *obj __UNUSED__,
1308 Elm_Genlist_Item *it = data;
1309 Evas_Event_Multi_Up *ev = event_info;
1311 if (it->wd->multi_device != ev->device) return;
1312 it->wd->multi_device = 0;
1313 it->wd->multi_down = EINA_FALSE;
1314 if (it->wd->mouse_down) return;
1315 _multi_touch_gesture_eval(data);
1319 _multi_move(void *data,
1320 Evas *evas __UNUSED__,
1321 Evas_Object *obj __UNUSED__,
1324 Elm_Genlist_Item *it = data;
1325 Evas_Event_Multi_Move *ev = event_info;
1327 if (it->wd->multi_device != ev->device) return;
1328 it->wd->cur_mx = ev->cur.canvas.x;
1329 it->wd->cur_my = ev->cur.canvas.y;
1333 _mouse_down(void *data,
1334 Evas *evas __UNUSED__,
1338 Elm_Genlist_Item *it = data;
1339 Evas_Event_Mouse_Down *ev = event_info;
1342 if (ev->button != 1) return;
1343 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1345 it->wd->on_hold = EINA_TRUE;
1347 it->down = EINA_TRUE;
1348 it->dragging = EINA_FALSE;
1349 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1350 it->dx = ev->canvas.x - x;
1351 it->dy = ev->canvas.y - y;
1352 it->wd->mouse_down = EINA_TRUE;
1353 if (!it->wd->multitouched)
1355 it->wd->prev_x = ev->canvas.x;
1356 it->wd->prev_y = ev->canvas.y;
1357 it->wd->multi_timeout = EINA_FALSE;
1358 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1359 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1361 it->wd->longpressed = EINA_FALSE;
1362 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1363 else it->wd->on_hold = EINA_FALSE;
1364 if (it->wd->on_hold) return;
1365 it->wd->wasselected = it->selected;
1366 _item_highlight(it);
1367 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1368 if ((!it->disabled) && (!it->display_only))
1370 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1371 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
1373 if (it->long_timer) ecore_timer_del(it->long_timer);
1374 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1375 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1377 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1380 it->long_timer = NULL;
1381 it->wd->swipe = EINA_FALSE;
1382 it->wd->movements = 0;
1386 _mouse_up(void *data,
1387 Evas *evas __UNUSED__,
1388 Evas_Object *obj __UNUSED__,
1391 Elm_Genlist_Item *it = data;
1392 Evas_Event_Mouse_Up *ev = event_info;
1393 Eina_Bool dragged = EINA_FALSE;
1395 if (ev->button != 1) return;
1396 it->down = EINA_FALSE;
1397 it->wd->mouse_down = EINA_FALSE;
1398 if (it->wd->multitouched)
1400 // in single selection modes, some multi touching can make multi highlighted items.
1401 // if a item not selected and highlighted, it should be unhighlighted.
1402 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unselect(it);
1403 if (it->wd->multi_down) return;
1404 _multi_touch_gesture_eval(data);
1407 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1408 else it->wd->on_hold = EINA_FALSE;
1411 ecore_timer_del(it->long_timer);
1412 it->long_timer = NULL;
1416 it->dragging = EINA_FALSE;
1417 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1420 if (it->swipe_timer)
1422 ecore_timer_del(it->swipe_timer);
1423 it->swipe_timer = NULL;
1425 if (it->wd->multi_timer)
1427 ecore_timer_del(it->wd->multi_timer);
1428 it->wd->multi_timer = NULL;
1429 it->wd->multi_timeout = EINA_FALSE;
1431 if (it->wd->on_hold)
1433 if (it->wd->swipe) _swipe(data);
1434 it->wd->longpressed = EINA_FALSE;
1435 it->wd->on_hold = EINA_FALSE;
1438 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1440 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1442 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1444 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1445 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1447 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1451 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1452 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1454 it->wd->reorder_deleted = EINA_FALSE;
1455 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1456 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1457 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1458 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1461 if (it->wd->longpressed)
1463 it->wd->longpressed = EINA_FALSE;
1464 if ((!it->wd->wasselected) && (!it->renamed))
1466 it->wd->wasselected = EINA_FALSE;
1471 if (it->want_unrealize)
1473 _item_unrealize(it, EINA_FALSE);
1474 if (it->block->want_unrealize)
1475 _item_block_unrealize(it->block);
1478 if ((it->disabled) || (dragged) || (it->display_only)) return;
1479 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1484 _item_highlight(it);
1487 else _item_unselect(it);
1493 Widget_Data *wd = it->wd;
1496 while (wd->selected) _item_unselect(wd->selected->data);
1501 const Eina_List *l, *l_next;
1502 Elm_Genlist_Item *it2;
1504 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1505 if (it2 != it) _item_unselect(it2);
1506 //_item_highlight(it);
1509 _item_highlight(it);
1515 _mouse_down_scroller(void *data,
1516 Evas *evas __UNUSED__,
1517 Evas_Object *obj __UNUSED__,
1518 void *event_info __UNUSED__)
1520 Widget_Data *wd = elm_widget_data_get(data);
1523 wd->drag_started = EINA_FALSE;
1527 _mouse_up_scroller(void *data,
1528 Evas *evas __UNUSED__,
1529 Evas_Object *obj __UNUSED__,
1530 void *event_info __UNUSED__)
1532 Widget_Data *wd = elm_widget_data_get(data);
1535 wd->drag_started = EINA_FALSE;
1539 _mouse_move_scroller(void *data,
1540 Evas *evas __UNUSED__,
1541 Evas_Object *obj __UNUSED__,
1544 Widget_Data *wd = elm_widget_data_get(data);
1545 Evas_Event_Mouse_Move *ev = event_info;
1546 Evas_Coord minw = 0, minh = 0, dx, dy, adx, ady;
1549 if (wd->drag_started) return;
1551 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1552 dx = ev->cur.canvas.x - ev->prev.canvas.x;
1553 dy = ev->cur.canvas.y - ev->prev.canvas.y;
1556 if (adx < 0) adx = -dx;
1557 if (ady < 0) ady = -dy;
1558 if (((ady < minh) && (ady > minh / 2)) && (ady > adx))
1562 evas_object_smart_callback_call(data, SIG_DRAG_START_UP, NULL);
1563 wd->drag_started = EINA_TRUE;
1567 evas_object_smart_callback_call(data, SIG_DRAG_START_DOWN, NULL);
1568 wd->drag_started = EINA_TRUE;
1574 _signal_expand_toggle(void *data,
1575 Evas_Object *obj __UNUSED__,
1576 const char *emission __UNUSED__,
1577 const char *source __UNUSED__)
1579 Elm_Genlist_Item *it = data;
1582 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1584 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1588 _signal_expand(void *data,
1589 Evas_Object *obj __UNUSED__,
1590 const char *emission __UNUSED__,
1591 const char *source __UNUSED__)
1593 Elm_Genlist_Item *it = data;
1596 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1600 _signal_contract(void *data,
1601 Evas_Object *obj __UNUSED__,
1602 const char *emission __UNUSED__,
1603 const char *source __UNUSED__)
1605 Elm_Genlist_Item *it = data;
1608 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1612 _scr_hold_timer_cb(void *data)
1614 if (!data) return ECORE_CALLBACK_CANCEL;
1615 Widget_Data *wd = data;
1616 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1617 wd->scr_hold_timer = NULL;
1618 return ECORE_CALLBACK_CANCEL;
1622 _mode_finished_signal_cb(void *data,
1624 const char *emission __UNUSED__,
1625 const char *source __UNUSED__)
1629 Elm_Genlist_Item *it = data;
1630 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1632 Evas *te = evas_object_evas_get(obj);
1634 evas_event_freeze(te);
1635 it->nocache = EINA_FALSE;
1636 _mode_item_unrealize(it);
1638 evas_object_raise(it->VIEW(group_item));
1639 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1640 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1641 evas_event_thaw(te);
1642 evas_event_thaw_eval(te);
1646 _item_cache_clean(Widget_Data *wd)
1648 evas_event_freeze(evas_object_evas_get(wd->obj));
1649 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1653 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1654 wd->item_cache = eina_inlist_remove(wd->item_cache,
1655 wd->item_cache->last);
1656 wd->item_cache_count--;
1657 if (itc->spacer) evas_object_del(itc->spacer);
1658 if (itc->base_view) evas_object_del(itc->base_view);
1659 if (itc->item_style) eina_stringshare_del(itc->item_style);
1662 evas_event_thaw(evas_object_evas_get(wd->obj));
1663 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1667 _item_cache_zero(Widget_Data *wd)
1669 int pmax = wd->item_cache_max;
1670 wd->item_cache_max = 0;
1671 _item_cache_clean(wd);
1672 wd->item_cache_max = pmax;
1676 _item_cache_add(Elm_Genlist_Item *it)
1680 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1681 if (it->wd->item_cache_max <= 0)
1683 evas_object_del(VIEW(it));
1685 evas_object_del(it->spacer);
1687 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1688 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1692 it->wd->item_cache_count++;
1693 itc = calloc(1, sizeof(Item_Cache));
1696 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1697 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1700 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1701 EINA_INLIST_GET(itc));
1702 itc->spacer = it->spacer;
1704 itc->base_view = VIEW(it);
1706 evas_object_hide(itc->base_view);
1707 evas_object_move(itc->base_view, -9999, -9999);
1708 itc->item_style = eina_stringshare_add(it->itc->item_style);
1709 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1710 itc->compress = (it->wd->compress);
1711 itc->odd = (it->order_num_in & 0x1);
1712 itc->selected = it->selected;
1713 itc->disabled = it->disabled;
1714 itc->expanded = it->expanded;
1717 ecore_timer_del(it->long_timer);
1718 it->long_timer = NULL;
1720 if (it->swipe_timer)
1722 ecore_timer_del(it->swipe_timer);
1723 it->swipe_timer = NULL;
1725 // FIXME: other callbacks?
1726 edje_object_signal_callback_del_full(itc->base_view,
1727 "elm,action,expand,toggle",
1728 "elm", _signal_expand_toggle, it);
1729 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1731 _signal_expand, it);
1732 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1733 "elm", _signal_contract, it);
1734 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1736 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1738 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1740 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1742 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1744 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1746 _item_cache_clean(it->wd);
1747 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1748 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1752 _item_cache_find(Elm_Genlist_Item *it)
1755 Eina_Bool tree = 0, odd;
1757 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1758 odd = (it->order_num_in & 0x1);
1759 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1761 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1763 if ((itc->tree == tree) &&
1764 (itc->odd == odd) &&
1765 (itc->compress == it->wd->compress) &&
1766 (!strcmp(it->itc->item_style, itc->item_style)))
1768 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1769 EINA_INLIST_GET(itc));
1770 it->wd->item_cache_count--;
1778 _item_cache_free(Item_Cache *itc)
1780 if (itc->spacer) evas_object_del(itc->spacer);
1781 if (itc->base_view) evas_object_del(itc->base_view);
1782 if (itc->item_style) eina_stringshare_del(itc->item_style);
1787 _item_label_hook(Elm_Genlist_Item *it, const char *part)
1789 if (!it->itc->func.label_get) return NULL;
1790 return edje_object_part_text_get(VIEW(it), part);
1794 _icon_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1796 Elm_Genlist_Item *it = data;
1797 if (it) it->defer_unrealize = EINA_TRUE;
1798 if (it->renamed && (it->wd->focused_rename_it != it)) it->wd->focused_rename_it = it;
1802 _icon_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1804 Elm_Genlist_Item *it = data;
1805 if (it) it->defer_unrealize = EINA_FALSE;
1806 if (it->renamed && (it->wd->focused_rename_it == it)) it->wd->focused_rename_it = NULL;
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;
3084 Evas_Coord scr_x, scr_y;
3086 Elm_Genlist_Item *git;
3090 evas_event_freeze(evas_object_evas_get(obj));
3091 elm_smart_scroller_child_pos_get(sd->wd->scr, &scr_x, &scr_y);
3092 sd->wd->current_scrl_x = scr_x;
3093 sd->wd->current_scrl_y = scr_y;
3094 if (sd->wd->pan_changed)
3097 sd->wd->pan_changed = EINA_FALSE;
3100 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3101 sd->wd->prev_viewport_w = ow;
3102 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
3103 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
3105 git->want_realize = EINA_FALSE;
3107 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
3109 itb->w = sd->wd->minw;
3110 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
3111 itb->y - sd->wd->pan_y + oy,
3113 cvx, cvy, cvw, cvh))
3115 if ((!itb->realized) || (itb->changed))
3116 _item_block_realize(itb);
3117 _item_block_position(itb, in);
3121 if (itb->realized) _item_block_unrealize(itb);
3125 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
3126 _group_items_recalc(sd->wd);
3128 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
3130 if (sd->wd->pan_y != sd->wd->old_pan_y)
3131 sd->wd->reorder_pan_move = EINA_TRUE;
3132 else sd->wd->reorder_pan_move = EINA_FALSE;
3133 evas_object_raise(sd->wd->reorder_it->edit_obj);
3134 sd->wd->old_pan_y = sd->wd->pan_y;
3135 sd->wd->start_time = ecore_loop_time_get();
3138 if (sd->wd->effect_mode &&
3139 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
3140 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
3141 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
3143 if (!sd->wd->item_moving_effect_timer)
3145 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
3146 _item_flip_effect_show(sd->wd->expand_item);
3148 evas_object_raise(sd->wd->alpha_bg);
3149 evas_object_show(sd->wd->alpha_bg);
3150 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
3151 sd->wd->start_time = current_time_get();
3152 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
3155 else _item_auto_scroll(sd->wd);
3156 sd->wd->pan_resize = EINA_FALSE;
3157 evas_event_thaw(evas_object_evas_get(obj));
3158 evas_event_thaw_eval(evas_object_evas_get(obj));
3162 _pan_move(Evas_Object *obj,
3163 Evas_Coord x __UNUSED__,
3164 Evas_Coord y __UNUSED__)
3166 Pan *sd = evas_object_smart_data_get(obj);
3170 sd->wd->pan_changed = EINA_TRUE;
3171 evas_object_smart_changed(obj);
3172 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3173 sd->wd->calc_job = NULL;
3177 _hold_on(void *data __UNUSED__,
3179 void *event_info __UNUSED__)
3181 Widget_Data *wd = elm_widget_data_get(obj);
3183 elm_smart_scroller_hold_set(wd->scr, 1);
3187 _hold_off(void *data __UNUSED__,
3189 void *event_info __UNUSED__)
3191 Widget_Data *wd = elm_widget_data_get(obj);
3193 elm_smart_scroller_hold_set(wd->scr, 0);
3197 _freeze_on(void *data __UNUSED__,
3199 void *event_info __UNUSED__)
3201 Widget_Data *wd = elm_widget_data_get(obj);
3203 elm_smart_scroller_freeze_set(wd->scr, 1);
3207 _freeze_off(void *data __UNUSED__,
3209 void *event_info __UNUSED__)
3211 Widget_Data *wd = elm_widget_data_get(obj);
3213 elm_smart_scroller_freeze_set(wd->scr, 0);
3217 _scr_anim_start(void *data,
3218 Evas_Object *obj __UNUSED__,
3219 void *event_info __UNUSED__)
3221 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
3225 _scr_anim_stop(void *data,
3226 Evas_Object *obj __UNUSED__,
3227 void *event_info __UNUSED__)
3229 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
3233 _scr_drag_start(void *data,
3234 Evas_Object *obj __UNUSED__,
3235 void *event_info __UNUSED__)
3237 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
3241 _scr_drag_stop(void *data,
3242 Evas_Object *obj __UNUSED__,
3243 void *event_info __UNUSED__)
3245 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
3249 _scroll_edge_left(void *data,
3250 Evas_Object *scr __UNUSED__,
3251 void *event_info __UNUSED__)
3253 Evas_Object *obj = data;
3254 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
3258 _scroll_edge_right(void *data,
3259 Evas_Object *scr __UNUSED__,
3260 void *event_info __UNUSED__)
3262 Evas_Object *obj = data;
3263 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
3267 _scroll_edge_top(void *data,
3268 Evas_Object *scr __UNUSED__,
3269 void *event_info __UNUSED__)
3271 Evas_Object *obj = data;
3272 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
3276 _scroll_edge_bottom(void *data,
3277 Evas_Object *scr __UNUSED__,
3278 void *event_info __UNUSED__)
3280 Evas_Object *obj = data;
3281 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
3285 _mode_item_realize(Elm_Genlist_Item *it)
3289 if ((it->mode_view) || (it->delete_me)) return;
3291 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3292 it->mode_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
3293 edje_object_scale_set(it->mode_view,
3294 elm_widget_scale_get(WIDGET(it)) *
3295 _elm_config->scale);
3296 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
3297 elm_widget_sub_object_add(WIDGET(it), it->mode_view);
3299 strncpy(buf, "item", sizeof(buf));
3300 if (it->wd->compress)
3301 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3303 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3304 strncat(buf, "/", sizeof(buf) - strlen(buf));
3305 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3307 _elm_theme_object_set(WIDGET(it), it->mode_view, "genlist", buf,
3308 elm_widget_style_get(WIDGET(it)));
3309 edje_object_mirrored_set(it->mode_view,
3310 elm_widget_mirrored_get(WIDGET(it)));
3312 /* signal callback add */
3313 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3315 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3317 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3320 /* label_get, icon_get, state_get */
3321 _item_label_realize(it, it->mode_view, &it->mode_labels, NULL);
3322 if (it->itc->func.icon_get)
3328 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3330 EINA_LIST_FOREACH(it->mode_icons, l, key)
3332 Evas_Object *ic = it->itc->func.icon_get
3333 ((void *)it->base.data, WIDGET(it), l->data);
3337 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
3338 edje_object_part_swallow(it->mode_view, key, ic);
3339 evas_object_show(ic);
3340 elm_widget_sub_object_add(WIDGET(it), ic);
3342 elm_widget_disabled_set(ic, EINA_TRUE);
3346 _item_state_realize(it, it->mode_view, &it->mode_states, NULL);
3347 edje_object_part_swallow(it->mode_view,
3348 edje_object_data_get(it->mode_view, "mode_part"),
3351 it->want_unrealize = EINA_FALSE;
3352 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3353 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3357 _mode_item_unrealize(Elm_Genlist_Item *it)
3359 Widget_Data *wd = it->wd;
3361 if (!it->mode_view) return;
3363 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3364 elm_widget_stringlist_free(it->mode_labels);
3365 it->mode_labels = NULL;
3366 elm_widget_stringlist_free(it->mode_icons);
3367 it->mode_icons = NULL;
3368 elm_widget_stringlist_free(it->mode_states);
3370 EINA_LIST_FREE(it->mode_icon_objs, icon)
3371 evas_object_del(icon);
3373 edje_object_part_unswallow(it->mode_view, VIEW(it));
3374 evas_object_smart_member_add(VIEW(it), wd->pan_smart);
3375 evas_object_del(it->mode_view);
3376 it->mode_view = NULL;
3378 if (wd->mode_item == it)
3379 wd->mode_item = NULL;
3380 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3381 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3385 _item_mode_set(Elm_Genlist_Item *it)
3388 Widget_Data *wd = it->wd;
3393 it->nocache = EINA_TRUE;
3395 if (wd->scr_hold_timer)
3397 ecore_timer_del(wd->scr_hold_timer);
3398 wd->scr_hold_timer = NULL;
3400 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3401 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3403 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3404 _mode_item_realize(it);
3406 evas_object_raise(it->VIEW(group_item));
3407 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
3408 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3409 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3411 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3412 edje_object_signal_emit(it->mode_view, buf, "elm");
3416 _item_mode_unset(Widget_Data *wd)
3419 if (!wd->mode_item) return;
3420 char buf[1024], buf2[1024];
3421 Elm_Genlist_Item *it;
3424 it->nocache = EINA_TRUE;
3426 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3427 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3429 edje_object_signal_emit(it->mode_view, buf, "elm");
3430 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3432 wd->mode_item = NULL;
3437 _item_auto_scroll(void *data)
3439 Widget_Data *wd = data;
3442 if ((wd->expand_item) && (!wd->auto_scrolled))
3444 Elm_Genlist_Item *it;
3446 Evas_Coord ox, oy, ow, oh;
3447 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3449 wd->auto_scrolled = EINA_TRUE;
3450 if (wd->expand_item->scrl_y > (oh + oy) / 2)
3452 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
3454 elm_genlist_item_bring_in(it);
3460 elm_genlist_add(Evas_Object *parent)
3465 Evas_Coord minw, minh;
3466 static Evas_Smart *smart = NULL;
3470 static Evas_Smart_Class sc;
3472 evas_object_smart_clipped_smart_set(&_pan_sc);
3474 sc.name = "elm_genlist_pan";
3475 sc.version = EVAS_SMART_CLASS_VERSION;
3478 sc.resize = _pan_resize;
3479 sc.move = _pan_move;
3480 sc.calculate = _pan_calculate;
3481 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3484 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3486 ELM_SET_WIDTYPE(widtype, "genlist");
3487 elm_widget_type_set(obj, "genlist");
3488 elm_widget_sub_object_add(parent, obj);
3489 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3490 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3491 elm_widget_data_set(obj, wd);
3492 elm_widget_del_hook_set(obj, _del_hook);
3493 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3494 elm_widget_theme_hook_set(obj, _theme_hook);
3495 elm_widget_can_focus_set(obj, EINA_TRUE);
3496 elm_widget_event_hook_set(obj, _event_hook);
3497 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3498 elm_widget_translate_hook_set(obj, _translate_hook);
3500 wd->scr = elm_smart_scroller_add(e);
3501 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_DOWN,
3502 _mouse_down_scroller, obj);
3503 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_UP,
3504 _mouse_up_scroller, obj);
3505 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_MOVE,
3506 _mouse_move_scroller, obj);
3507 elm_smart_scroller_widget_set(wd->scr, obj);
3508 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3509 elm_widget_style_get(obj));
3510 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3511 _elm_config->thumbscroll_bounce_enable);
3512 elm_widget_resize_object_set(obj, wd->scr);
3514 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3515 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3516 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3517 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3518 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3519 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3521 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3522 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3526 wd->mode = ELM_LIST_SCROLL;
3527 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3528 wd->item_cache_max = wd->max_items_per_block * 2;
3529 wd->longpress_timeout = _elm_config->longpress_timeout;
3530 wd->effect_mode = _elm_config->effect_enable;
3532 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3533 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3534 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3535 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3537 wd->pan_smart = evas_object_smart_add(e, smart);
3538 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3541 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3542 _pan_set, _pan_get, _pan_max_get,
3543 _pan_min_get, _pan_child_size_get);
3545 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3547 evas_object_size_hint_min_set(obj, minw, minh);
3549 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3550 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3555 static Elm_Genlist_Item *
3556 _item_new(Widget_Data *wd,
3557 const Elm_Genlist_Item_Class *itc,
3559 Elm_Genlist_Item *parent,
3560 Elm_Genlist_Item_Flags flags,
3562 const void *func_data)
3564 Elm_Genlist_Item *it;
3566 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3567 if (!it) return NULL;
3570 it->base.data = data;
3571 it->parent = parent;
3573 it->func.func = func;
3574 it->func.data = func_data;
3575 it->mouse_cursor = NULL;
3576 it->expanded_depth = 0;
3577 elm_widget_item_text_get_hook_set(it, _item_label_hook);
3578 elm_widget_item_del_cb_set(it, _item_del_hook);
3582 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3583 it->group_item = parent;
3584 else if (it->parent->group_item)
3585 it->group_item = it->parent->group_item;
3591 _item_block_add(Widget_Data *wd,
3592 Elm_Genlist_Item *it)
3594 Item_Block *itb = NULL;
3601 itb = calloc(1, sizeof(Item_Block));
3604 if (!it->rel->block)
3607 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3608 itb->items = eina_list_append(itb->items, it);
3614 wd->blocks = eina_inlist_prepend_relative
3615 (wd->blocks, EINA_INLIST_GET(itb),
3616 EINA_INLIST_GET(it->rel->block));
3618 eina_list_prepend_relative(itb->items, it, it->rel);
3622 wd->blocks = eina_inlist_append_relative
3623 (wd->blocks, EINA_INLIST_GET(itb),
3624 EINA_INLIST_GET(it->rel->block));
3626 eina_list_append_relative(itb->items, it, it->rel);
3636 itb = (Item_Block *)(wd->blocks);
3637 if (itb->count >= wd->max_items_per_block)
3639 itb = calloc(1, sizeof(Item_Block));
3643 eina_inlist_prepend(wd->blocks,
3644 EINA_INLIST_GET(itb));
3649 itb = calloc(1, sizeof(Item_Block));
3653 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3655 itb->items = eina_list_prepend(itb->items, it);
3661 itb = (Item_Block *)(wd->blocks->last);
3662 if (itb->count >= wd->max_items_per_block)
3664 itb = calloc(1, sizeof(Item_Block));
3668 eina_inlist_append(wd->blocks,
3669 EINA_INLIST_GET(itb));
3674 itb = calloc(1, sizeof(Item_Block));
3678 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3680 itb->items = eina_list_append(itb->items, it);
3686 itb = it->rel->block;
3687 if (!itb) goto newblock;
3689 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3691 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3694 itb->changed = EINA_TRUE;
3696 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3697 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3700 it->rel->relcount--;
3701 if ((it->rel->delete_me) && (!it->rel->relcount))
3705 if (itb->count > itb->wd->max_items_per_block)
3709 Elm_Genlist_Item *it2;
3711 newc = itb->count / 2;
3712 itb2 = calloc(1, sizeof(Item_Block));
3716 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3717 EINA_INLIST_GET(itb));
3718 itb2->changed = EINA_TRUE;
3719 while ((itb->count > newc) && (itb->items))
3723 l = eina_list_last(itb->items);
3725 itb->items = eina_list_remove_list(itb->items, l);
3728 itb2->items = eina_list_prepend(itb2->items, it2);
3736 _queue_process(Widget_Data *wd)
3739 Eina_Bool showme = EINA_FALSE;
3742 t0 = ecore_time_get();
3743 //evas_event_freeze(evas_object_evas_get(wd->obj));
3744 for (n = 0; (wd->queue) && (n < 128); n++)
3746 Elm_Genlist_Item *it;
3748 it = wd->queue->data;
3749 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3750 it->queued = EINA_FALSE;
3751 _item_block_add(wd, it);
3752 t = ecore_time_get();
3753 if (it->block->changed)
3755 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3756 it->block->changed = 0;
3759 if (wd->calc_job) ecore_job_del(wd->calc_job);
3760 wd->calc_job = NULL;
3762 wd->pan_changed = EINA_FALSE;
3765 if (showme) it->block->showme = EINA_TRUE;
3766 if (eina_inlist_count(wd->blocks) > 1)
3768 if ((t - t0) > (ecore_animator_frametime_get())) break;
3771 //evas_event_thaw(evas_object_evas_get(wd->obj));
3772 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3777 _idle_process(void *data, Eina_Bool *wakeup)
3779 Widget_Data *wd = data;
3782 //static double q_start = 0.0;
3783 //if (q_start == 0.0) q_start = ecore_time_get();
3785 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3789 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3791 return ECORE_CALLBACK_CANCEL;
3793 return ECORE_CALLBACK_RENEW;
3797 _item_idle_enterer(void *data)
3799 Widget_Data *wd = data;
3800 Eina_Bool wakeup = EINA_FALSE;
3801 Eina_Bool ok = _idle_process(data, &wakeup);
3806 if (wd->calc_job) ecore_job_del(wd->calc_job);
3807 wd->calc_job = ecore_job_add(_calc_job, wd);
3809 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3814 _item_queue(Widget_Data *wd,
3815 Elm_Genlist_Item *it)
3817 if (it->queued) return;
3818 it->queued = EINA_TRUE;
3819 wd->queue = eina_list_append(wd->queue, it);
3820 // FIXME: why does a freeze then thaw here cause some genlist
3821 // elm_genlist_item_append() to be much much slower?
3822 // evas_event_freeze(evas_object_evas_get(wd->obj));
3823 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3825 if (wd->queue_idle_enterer)
3827 ecore_idle_enterer_del(wd->queue_idle_enterer);
3828 wd->queue_idle_enterer = NULL;
3832 // evas_event_thaw(evas_object_evas_get(wd->obj));
3833 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3834 if (!wd->queue_idle_enterer)
3835 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3839 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3844 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3845 it->wd->reorder_deleted = EINA_TRUE;
3846 _item_block_del(it);
3848 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3850 it->rel->relcount++;
3851 it->before = EINA_FALSE;
3852 if (after->group_item) it->group_item = after->group_item;
3853 _item_queue(it->wd, it);
3855 // TODO: change this to smart callback
3856 if (it->itc->func.moved)
3857 it->itc->func.moved(WIDGET(it), it, after, EINA_TRUE);
3861 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3864 if (!before) return;
3866 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3867 it->wd->reorder_deleted = EINA_TRUE;
3868 _item_block_del(it);
3869 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3871 it->rel->relcount++;
3872 it->before = EINA_TRUE;
3873 if (before->group_item) it->group_item = before->group_item;
3874 _item_queue(it->wd, it);
3876 // TODO: change this to smart callback
3877 if (it->itc->func.moved)
3878 it->itc->func.moved(WIDGET(it), it, before, EINA_FALSE);
3881 EAPI Elm_Genlist_Item *
3882 elm_genlist_item_append(Evas_Object *obj,
3883 const Elm_Genlist_Item_Class *itc,
3885 Elm_Genlist_Item *parent,
3886 Elm_Genlist_Item_Flags flags,
3888 const void *func_data)
3890 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3891 Widget_Data *wd = elm_widget_data_get(obj);
3892 if (!wd) return NULL;
3893 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3895 if (!it) return NULL;
3898 if (flags & ELM_GENLIST_ITEM_GROUP)
3899 wd->group_items = eina_list_append(wd->group_items, it);
3900 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3905 Elm_Genlist_Item *it2 = NULL;
3906 Eina_List *ll = eina_list_last(it->parent->items);
3907 if (ll) it2 = ll->data;
3908 it->parent->items = eina_list_append(it->parent->items, it);
3909 if (!it2) it2 = it->parent;
3911 it2 = elm_genlist_item_prev_get(it2);
3913 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3914 EINA_INLIST_GET(it2));
3916 it->rel->relcount++;
3918 it->before = EINA_FALSE;
3919 _item_queue(wd, it);
3923 EAPI Elm_Genlist_Item *
3924 elm_genlist_item_prepend(Evas_Object *obj,
3925 const Elm_Genlist_Item_Class *itc,
3927 Elm_Genlist_Item *parent,
3928 Elm_Genlist_Item_Flags flags,
3930 const void *func_data)
3932 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3933 Widget_Data *wd = elm_widget_data_get(obj);
3934 if (!wd) return NULL;
3935 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3938 if (!it) return NULL;
3941 if (flags & ELM_GENLIST_ITEM_GROUP)
3942 wd->group_items = eina_list_prepend(wd->group_items, it);
3943 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3948 Elm_Genlist_Item *it2 = NULL;
3949 Eina_List *ll = it->parent->items;
3950 if (ll) it2 = ll->data;
3951 it->parent->items = eina_list_prepend(it->parent->items, it);
3952 if (!it2) it2 = it->parent;
3954 it2 = elm_genlist_item_next_get(it2);
3956 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3957 EINA_INLIST_GET(it2));
3959 it->rel->relcount++;
3961 it->before = EINA_TRUE;
3962 _item_queue(wd, it);
3966 EAPI Elm_Genlist_Item *
3967 elm_genlist_item_insert_after(Evas_Object *obj,
3968 const Elm_Genlist_Item_Class *itc,
3970 Elm_Genlist_Item *parent,
3971 Elm_Genlist_Item *after,
3972 Elm_Genlist_Item_Flags flags,
3974 const void *func_data)
3976 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3977 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3978 Widget_Data *wd = elm_widget_data_get(obj);
3979 if (!wd) return NULL;
3980 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3982 if (!it) return NULL;
3983 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3984 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3988 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3989 (after->flags & ELM_GENLIST_ITEM_GROUP))
3990 wd->group_items = eina_list_append_relative(wd->group_items, it,
3995 it->parent->items = eina_list_append_relative(it->parent->items, it,
3998 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3999 EINA_INLIST_GET(after));
4001 it->rel->relcount++;
4002 it->before = EINA_FALSE;
4003 _item_queue(wd, it);
4007 EAPI Elm_Genlist_Item *
4008 elm_genlist_item_insert_before(Evas_Object *obj,
4009 const Elm_Genlist_Item_Class *itc,
4011 Elm_Genlist_Item *parent,
4012 Elm_Genlist_Item *before,
4013 Elm_Genlist_Item_Flags flags,
4015 const void *func_data)
4017 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4018 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
4019 Widget_Data *wd = elm_widget_data_get(obj);
4020 if (!wd) return NULL;
4021 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
4023 if (!it) return NULL;
4024 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
4025 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
4029 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
4030 (before->flags & ELM_GENLIST_ITEM_GROUP))
4031 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
4036 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
4039 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
4040 EINA_INLIST_GET(before));
4042 it->rel->relcount++;
4043 it->before = EINA_TRUE;
4044 _item_queue(wd, it);
4049 elm_genlist_clear(Evas_Object *obj)
4051 ELM_CHECK_WIDTYPE(obj, widtype);
4052 Widget_Data *wd = elm_widget_data_get(obj);
4054 if (wd->walking > 0)
4056 Elm_Genlist_Item *it;
4058 wd->clear_me = EINA_TRUE;
4059 EINA_INLIST_FOREACH(wd->items, it)
4061 it->delete_me = EINA_TRUE;
4065 evas_event_freeze(evas_object_evas_get(wd->obj));
4068 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4069 it->nocache = EINA_TRUE;
4070 it->highlighted = EINA_FALSE;
4072 if (wd->anchor_item == it)
4074 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4075 if (!wd->anchor_item)
4077 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4080 wd->items = eina_inlist_remove(wd->items, wd->items);
4081 if (it->flags & ELM_GENLIST_ITEM_GROUP)
4082 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
4083 elm_widget_item_pre_notify_del(it);
4084 if (it->realized) _item_unrealize(it, EINA_FALSE);
4085 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
4086 it->itc->func.del((void *)it->base.data, WIDGET(it));
4087 if (it->long_timer) ecore_timer_del(it->long_timer);
4088 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
4089 elm_widget_item_del(it);
4091 wd->clear_me = EINA_FALSE;
4092 wd->anchor_item = NULL;
4095 Item_Block *itb = (Item_Block *)(wd->blocks);
4097 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
4098 if (itb->items) eina_list_free(itb->items);
4101 wd->pan_changed = EINA_TRUE;
4104 ecore_job_del(wd->calc_job);
4105 wd->calc_job = NULL;
4107 if (wd->queue_idle_enterer)
4109 ecore_idle_enterer_del(wd->queue_idle_enterer);
4110 wd->queue_idle_enterer = NULL;
4112 if (wd->must_recalc_idler)
4114 ecore_idler_del(wd->must_recalc_idler);
4115 wd->must_recalc_idler = NULL;
4119 eina_list_free(wd->queue);
4124 eina_list_free(wd->selected);
4125 wd->selected = NULL;
4127 if (wd->reorder_move_animator)
4129 ecore_animator_del(wd->reorder_move_animator);
4130 wd->reorder_move_animator = NULL;
4132 wd->show_item = NULL;
4140 evas_object_del(wd->alpha_bg);
4141 wd->alpha_bg = NULL;
4145 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4146 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4149 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
4150 evas_event_thaw(evas_object_evas_get(wd->obj));
4151 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4155 elm_genlist_multi_select_set(Evas_Object *obj,
4158 ELM_CHECK_WIDTYPE(obj, widtype);
4159 Widget_Data *wd = elm_widget_data_get(obj);
4165 elm_genlist_multi_select_get(const Evas_Object *obj)
4167 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4168 Widget_Data *wd = elm_widget_data_get(obj);
4169 if (!wd) return EINA_FALSE;
4173 EAPI Elm_Genlist_Item *
4174 elm_genlist_selected_item_get(const Evas_Object *obj)
4176 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4177 Widget_Data *wd = elm_widget_data_get(obj);
4178 if (!wd) return NULL;
4179 if (wd->selected) return wd->selected->data;
4183 EAPI const Eina_List *
4184 elm_genlist_selected_items_get(const Evas_Object *obj)
4186 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4187 Widget_Data *wd = elm_widget_data_get(obj);
4188 if (!wd) return NULL;
4189 return wd->selected;
4193 elm_genlist_realized_items_get(const Evas_Object *obj)
4195 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4196 Widget_Data *wd = elm_widget_data_get(obj);
4197 Eina_List *list = NULL;
4199 Eina_Bool done = EINA_FALSE;
4200 if (!wd) return NULL;
4201 EINA_INLIST_FOREACH(wd->blocks, itb)
4206 Elm_Genlist_Item *it;
4209 EINA_LIST_FOREACH(itb->items, l, it)
4211 if (it->realized) list = eina_list_append(list, it);
4222 EAPI Elm_Genlist_Item *
4223 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4228 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4229 Widget_Data *wd = elm_widget_data_get(obj);
4230 Evas_Coord ox, oy, ow, oh;
4233 if (!wd) return NULL;
4234 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4236 EINA_INLIST_FOREACH(wd->blocks, itb)
4239 Elm_Genlist_Item *it;
4241 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4242 oy + itb->y - itb->wd->pan_y,
4243 itb->w, itb->h, x, y, 1, 1))
4245 EINA_LIST_FOREACH(itb->items, l, it)
4247 Evas_Coord itx, ity;
4249 itx = ox + itb->x + it->x - itb->wd->pan_x;
4250 ity = oy + itb->y + it->y - itb->wd->pan_y;
4251 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4255 if (y <= (ity + (it->h / 4))) *posret = -1;
4256 else if (y >= (ity + it->h - (it->h / 4)))
4262 lasty = ity + it->h;
4267 if (y > lasty) *posret = 1;
4273 EAPI Elm_Genlist_Item *
4274 elm_genlist_first_item_get(const Evas_Object *obj)
4276 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4277 Widget_Data *wd = elm_widget_data_get(obj);
4278 if (!wd) return NULL;
4279 if (!wd->items) return NULL;
4280 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4281 while ((it) && (it->delete_me))
4282 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4286 EAPI Elm_Genlist_Item *
4287 elm_genlist_last_item_get(const Evas_Object *obj)
4289 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4290 Widget_Data *wd = elm_widget_data_get(obj);
4291 if (!wd) return NULL;
4292 if (!wd->items) return NULL;
4293 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4294 while ((it) && (it->delete_me))
4295 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4299 EAPI Elm_Genlist_Item *
4300 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4302 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4305 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4306 if ((it) && (!it->delete_me)) break;
4308 return (Elm_Genlist_Item *)it;
4311 EAPI Elm_Genlist_Item *
4312 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4314 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4317 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4318 if ((it) && (!it->delete_me)) break;
4320 return (Elm_Genlist_Item *)it;
4324 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4326 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4330 EAPI Elm_Genlist_Item *
4331 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4333 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4338 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4340 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4341 Elm_Genlist_Item *it2;
4344 if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4345 _item_subitems_clear(it);
4348 if ((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4349 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4351 it->wd->expand_item = it;
4352 _item_flip_effect_show(it);
4353 evas_object_geometry_get(VIEW(it), NULL, &y, NULL, &h);
4354 it->wd->expand_item_end = y + h;
4358 it2 = elm_genlist_item_next_get(it2);
4360 } while (it2->expanded_depth > it->expanded_depth);
4362 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4364 it->wd->expand_item_gap = 0;
4366 evas_object_raise(it->wd->alpha_bg);
4367 evas_object_show(it->wd->alpha_bg);
4369 it->wd->start_time = current_time_get();
4370 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4373 _item_subitems_clear(it);
4378 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4381 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4382 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
4384 if ((it->delete_me) || (it->disabled)) return;
4385 selected = !!selected;
4386 if (it->selected == selected) return;
4392 while (wd->selected)
4393 _item_unselect(wd->selected->data);
4395 _item_highlight(it);
4403 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4405 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4406 return it->selected;
4410 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4413 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4414 if (it->flags != ELM_GENLIST_ITEM_SUBITEMS) return;
4415 if (it->expanded == expanded) return;
4416 it->expanded = expanded;
4417 it->wd->expand_item = it;
4419 if (it->wd->effect_mode && !it->wd->alpha_bg)
4420 it->wd->alpha_bg = _create_tray_alpha_bg(WIDGET(it));
4424 it->wd->auto_scrolled = EINA_FALSE;
4425 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4427 edje_object_signal_emit(VIEW(it), "elm,state,expanded", "elm");
4428 evas_object_smart_callback_call(WIDGET(it), "expanded", it);
4432 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4434 edje_object_signal_emit(VIEW(it), "elm,state,contracted", "elm");
4435 evas_object_smart_callback_call(WIDGET(it), "contracted", it);
4440 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4442 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4443 return it->expanded;
4447 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4449 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4450 return it->expanded_depth;
4454 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4457 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4460 if (it->disabled == disabled) return;
4461 if (it->delete_me) return;
4462 it->disabled = !!disabled;
4464 elm_genlist_item_selected_set(it, EINA_FALSE);
4469 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
4471 edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
4475 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
4477 edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
4479 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4480 elm_widget_disabled_set(obj, disabled);
4485 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4487 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4488 if (it->delete_me) return EINA_FALSE;
4489 return it->disabled;
4493 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4494 Eina_Bool display_only)
4496 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4497 if (it->display_only == display_only) return;
4498 if (it->delete_me) return;
4499 it->display_only = display_only;
4500 it->mincalcd = EINA_FALSE;
4501 it->updateme = EINA_TRUE;
4502 if (it->block) it->block->updateme = EINA_TRUE;
4503 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4504 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4508 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4510 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4511 if (it->delete_me) return EINA_FALSE;
4512 return it->display_only;
4516 elm_genlist_item_show(Elm_Genlist_Item *it)
4518 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4519 Evas_Coord gith = 0;
4520 if (it->delete_me) return;
4521 if ((it->queued) || (!it->mincalcd))
4523 it->wd->show_item = it;
4524 it->wd->bring_in = EINA_TRUE;
4525 it->showme = EINA_TRUE;
4528 if (it->wd->show_item)
4530 it->wd->show_item->showme = EINA_FALSE;
4531 it->wd->show_item = NULL;
4533 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4534 gith = it->group_item->h;
4535 elm_smart_scroller_child_region_show(it->wd->scr,
4536 it->x + it->block->x,
4537 it->y + it->block->y - gith,
4538 it->block->w, it->h);
4542 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4544 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4545 Evas_Coord gith = 0;
4546 if (it->delete_me) return;
4547 if ((it->queued) || (!it->mincalcd))
4549 it->wd->show_item = it;
4550 it->wd->bring_in = EINA_TRUE;
4551 it->showme = EINA_TRUE;
4554 if (it->wd->show_item)
4556 it->wd->show_item->showme = EINA_FALSE;
4557 it->wd->show_item = NULL;
4559 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4560 gith = it->group_item->h;
4561 elm_smart_scroller_region_bring_in(it->wd->scr,
4562 it->x + it->block->x,
4563 it->y + it->block->y - gith,
4564 it->block->w, it->h);
4568 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4570 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4572 Evas_Coord gith = 0;
4574 if (it->delete_me) return;
4575 if ((it->queued) || (!it->mincalcd))
4577 it->wd->show_item = it;
4578 it->wd->bring_in = EINA_TRUE;
4579 it->showme = EINA_TRUE;
4582 if (it->wd->show_item)
4584 it->wd->show_item->showme = EINA_FALSE;
4585 it->wd->show_item = NULL;
4587 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4588 if (it->group_item) gith = it->group_item->h;
4589 elm_smart_scroller_child_region_show(it->wd->scr,
4590 it->x + it->block->x,
4591 it->y + it->block->y - gith,
4596 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4598 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4600 Evas_Coord gith = 0;
4602 if (it->delete_me) return;
4603 if ((it->queued) || (!it->mincalcd))
4605 it->wd->show_item = it;
4606 it->wd->bring_in = EINA_TRUE;
4607 it->showme = EINA_TRUE;
4610 if (it->wd->show_item)
4612 it->wd->show_item->showme = EINA_FALSE;
4613 it->wd->show_item = NULL;
4615 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4616 if (it->group_item) gith = it->group_item->h;
4617 elm_smart_scroller_region_bring_in(it->wd->scr,
4618 it->x + it->block->x,
4619 it->y + it->block->y - gith,
4624 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4626 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4629 if (it->delete_me) return;
4630 if ((it->queued) || (!it->mincalcd))
4632 it->wd->show_item = it;
4633 it->wd->bring_in = EINA_TRUE;
4634 it->showme = EINA_TRUE;
4637 if (it->wd->show_item)
4639 it->wd->show_item->showme = EINA_FALSE;
4640 it->wd->show_item = NULL;
4642 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4643 elm_smart_scroller_child_region_show(it->wd->scr,
4644 it->x + it->block->x,
4645 it->y + it->block->y - oh / 2 +
4646 it->h / 2, it->block->w, oh);
4650 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4652 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4655 if (it->delete_me) return;
4656 if ((it->queued) || (!it->mincalcd))
4658 it->wd->show_item = it;
4659 it->wd->bring_in = EINA_TRUE;
4660 it->showme = EINA_TRUE;
4663 if (it->wd->show_item)
4665 it->wd->show_item->showme = EINA_FALSE;
4666 it->wd->show_item = NULL;
4668 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4669 elm_smart_scroller_region_bring_in(it->wd->scr,
4670 it->x + it->block->x,
4671 it->y + it->block->y - oh / 2 + it->h / 2,
4676 elm_genlist_item_del(Elm_Genlist_Item *it)
4678 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4679 if ((it->relcount > 0) || (it->walking > 0))
4681 elm_widget_item_pre_notify_del(it);
4682 elm_genlist_item_subitems_clear(it);
4683 it->delete_me = EINA_TRUE;
4684 if (it->wd->show_item == it) it->wd->show_item = NULL;
4686 it->wd->selected = eina_list_remove(it->wd->selected,
4690 if (it->realized) _item_unrealize(it, EINA_FALSE);
4691 it->block->changed = EINA_TRUE;
4692 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4693 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4695 if (it->itc->func.del)
4696 it->itc->func.del((void *)it->base.data, WIDGET(it));
4703 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4706 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4707 elm_widget_item_data_set(it, data);
4708 elm_genlist_item_update(it);
4712 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4714 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4715 return elm_widget_item_data_get(it);
4719 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4722 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4723 EINA_LIST_FREE(it->icon_objs, icon)
4725 elm_widget_sub_object_del(WIDGET(it), icon);
4726 evas_object_smart_member_del(icon);
4727 evas_object_hide(icon);
4731 EAPI const Evas_Object *
4732 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4734 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4739 elm_genlist_item_update(Elm_Genlist_Item *it)
4741 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4742 if (!it->block) return;
4743 if (it->delete_me) return;
4744 it->mincalcd = EINA_FALSE;
4745 it->updateme = EINA_TRUE;
4746 it->block->updateme = EINA_TRUE;
4747 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4748 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4749 it->defer_unrealize = EINA_FALSE;
4753 elm_genlist_item_fields_update(Elm_Genlist_Item *it,
4755 Elm_Genlist_Item_Field_Flags itf)
4757 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4758 if (!it->block) return;
4759 if (it->delete_me) return;
4761 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_LABEL))
4762 _item_label_realize(it, VIEW(it), &it->labels, parts);
4763 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_ICON))
4765 it->icon_objs = _item_icon_unrealize(it, VIEW(it),
4767 it->icon_objs = _item_icon_realize(it, VIEW(it),
4770 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
4771 _item_state_realize(it, VIEW(it), &it->states, parts);
4775 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4776 const Elm_Genlist_Item_Class *itc)
4778 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4779 if (!it->block) return;
4780 EINA_SAFETY_ON_NULL_RETURN(itc);
4781 if (it->delete_me) return;
4783 it->nocache = EINA_TRUE;
4784 elm_genlist_item_update(it);
4787 EAPI const Elm_Genlist_Item_Class *
4788 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4790 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4791 if (it->delete_me) return NULL;
4794 static Evas_Object *
4795 _elm_genlist_item_label_create(void *data,
4797 void *item __UNUSED__)
4799 Evas_Object *label = elm_label_add(obj);
4802 elm_object_style_set(label, "tooltip");
4803 elm_object_text_set(label, data);
4808 _elm_genlist_item_label_del_cb(void *data,
4809 Evas_Object *obj __UNUSED__,
4810 void *event_info __UNUSED__)
4812 eina_stringshare_del(data);
4816 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4819 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4820 text = eina_stringshare_add(text);
4821 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4823 _elm_genlist_item_label_del_cb);
4827 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4828 Elm_Tooltip_Item_Content_Cb func,
4830 Evas_Smart_Cb del_cb)
4832 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4834 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4837 if (item->tooltip.del_cb)
4838 item->tooltip.del_cb((void *)item->tooltip.data,
4839 item->base.widget, item);
4841 item->tooltip.content_cb = func;
4842 item->tooltip.data = data;
4843 item->tooltip.del_cb = del_cb;
4847 elm_widget_item_tooltip_content_cb_set(item,
4848 item->tooltip.content_cb,
4849 item->tooltip.data, NULL);
4850 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4856 if (del_cb) del_cb((void *)data, NULL, NULL);
4860 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4862 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4863 if ((item->base.view) && (item->tooltip.content_cb))
4864 elm_widget_item_tooltip_unset(item);
4866 if (item->tooltip.del_cb)
4867 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4868 item->tooltip.del_cb = NULL;
4869 item->tooltip.content_cb = NULL;
4870 item->tooltip.data = NULL;
4871 if (item->tooltip.style)
4872 elm_genlist_item_tooltip_style_set(item, NULL);
4876 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4879 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4880 eina_stringshare_replace(&item->tooltip.style, style);
4881 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4885 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4887 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4888 return item->tooltip.style;
4892 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4895 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4896 eina_stringshare_replace(&item->mouse_cursor, cursor);
4897 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4901 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4903 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4904 return elm_widget_item_cursor_get(item);
4908 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4910 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4911 if (!item->mouse_cursor)
4915 elm_widget_item_cursor_unset(item);
4917 eina_stringshare_del(item->mouse_cursor);
4918 item->mouse_cursor = NULL;
4922 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4925 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4926 elm_widget_item_cursor_style_set(item, style);
4930 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4932 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4933 return elm_widget_item_cursor_style_get(item);
4937 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4938 Eina_Bool engine_only)
4940 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4941 elm_widget_item_cursor_engine_only_set(item, engine_only);
4945 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4947 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4948 return elm_widget_item_cursor_engine_only_get(item);
4952 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4955 ELM_CHECK_WIDTYPE(obj, widtype);
4956 Widget_Data *wd = elm_widget_data_get(obj);
4958 if (wd->mode == mode) return;
4964 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4966 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4967 Widget_Data *wd = elm_widget_data_get(obj);
4968 if (!wd) return ELM_LIST_LAST;
4973 elm_genlist_always_select_mode_set(Evas_Object *obj,
4974 Eina_Bool always_select)
4976 ELM_CHECK_WIDTYPE(obj, widtype);
4977 Widget_Data *wd = elm_widget_data_get(obj);
4979 wd->always_select = always_select;
4983 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4985 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4986 Widget_Data *wd = elm_widget_data_get(obj);
4987 if (!wd) return EINA_FALSE;
4988 return wd->always_select;
4992 elm_genlist_no_select_mode_set(Evas_Object *obj,
4993 Eina_Bool no_select)
4995 ELM_CHECK_WIDTYPE(obj, widtype);
4996 Widget_Data *wd = elm_widget_data_get(obj);
4998 wd->no_select = no_select;
5002 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5004 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5005 Widget_Data *wd = elm_widget_data_get(obj);
5006 if (!wd) return EINA_FALSE;
5007 return wd->no_select;
5011 elm_genlist_compress_mode_set(Evas_Object *obj,
5014 ELM_CHECK_WIDTYPE(obj, widtype);
5015 Widget_Data *wd = elm_widget_data_get(obj);
5017 wd->compress = compress;
5021 elm_genlist_compress_mode_get(const Evas_Object *obj)
5023 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5024 Widget_Data *wd = elm_widget_data_get(obj);
5025 if (!wd) return EINA_FALSE;
5026 return wd->compress;
5030 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5031 Eina_Bool height_for_width)
5033 ELM_CHECK_WIDTYPE(obj, widtype);
5034 Widget_Data *wd = elm_widget_data_get(obj);
5036 wd->height_for_width = !!height_for_width;
5037 if (wd->height_for_width)
5039 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5040 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5045 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5047 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5048 Widget_Data *wd = elm_widget_data_get(obj);
5049 if (!wd) return EINA_FALSE;
5050 return wd->height_for_width;
5054 elm_genlist_bounce_set(Evas_Object *obj,
5058 ELM_CHECK_WIDTYPE(obj, widtype);
5059 Widget_Data *wd = elm_widget_data_get(obj);
5061 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5065 elm_genlist_bounce_get(const Evas_Object *obj,
5066 Eina_Bool *h_bounce,
5067 Eina_Bool *v_bounce)
5069 ELM_CHECK_WIDTYPE(obj, widtype);
5070 Widget_Data *wd = elm_widget_data_get(obj);
5072 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
5076 elm_genlist_homogeneous_set(Evas_Object *obj,
5077 Eina_Bool homogeneous)
5079 ELM_CHECK_WIDTYPE(obj, widtype);
5080 Widget_Data *wd = elm_widget_data_get(obj);
5082 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5083 wd->homogeneous = homogeneous;
5087 elm_genlist_homogeneous_get(const Evas_Object *obj)
5089 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5090 Widget_Data *wd = elm_widget_data_get(obj);
5091 if (!wd) return EINA_FALSE;
5092 return wd->homogeneous;
5096 elm_genlist_block_count_set(Evas_Object *obj,
5099 ELM_CHECK_WIDTYPE(obj, widtype);
5100 Widget_Data *wd = elm_widget_data_get(obj);
5102 wd->max_items_per_block = n;
5103 wd->item_cache_max = wd->max_items_per_block * 2;
5104 _item_cache_clean(wd);
5108 elm_genlist_block_count_get(const Evas_Object *obj)
5110 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5111 Widget_Data *wd = elm_widget_data_get(obj);
5113 return wd->max_items_per_block;
5117 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5120 ELM_CHECK_WIDTYPE(obj, widtype);
5121 Widget_Data *wd = elm_widget_data_get(obj);
5123 wd->longpress_timeout = timeout;
5127 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5129 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5130 Widget_Data *wd = elm_widget_data_get(obj);
5132 return wd->longpress_timeout;
5136 elm_genlist_scroller_policy_set(Evas_Object *obj,
5137 Elm_Scroller_Policy policy_h,
5138 Elm_Scroller_Policy policy_v)
5140 ELM_CHECK_WIDTYPE(obj, widtype);
5141 Widget_Data *wd = elm_widget_data_get(obj);
5142 if ((!wd) || (!wd->scr)) return;
5143 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5144 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5146 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5150 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5151 Elm_Scroller_Policy *policy_h,
5152 Elm_Scroller_Policy *policy_v)
5154 ELM_CHECK_WIDTYPE(obj, widtype);
5155 Widget_Data *wd = elm_widget_data_get(obj);
5156 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5157 if ((!wd) || (!wd->scr)) return;
5158 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5159 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5160 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5164 elm_genlist_realized_items_update(Evas_Object *obj)
5166 ELM_CHECK_WIDTYPE(obj, widtype);
5168 Eina_List *list, *l;
5169 Elm_Genlist_Item *it;
5171 list = elm_genlist_realized_items_get(obj);
5172 EINA_LIST_FOREACH(list, l, it)
5173 elm_genlist_item_update(it);
5177 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5178 const char *mode_type,
5181 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5182 Widget_Data *wd = it->wd;
5184 Elm_Genlist_Item *it2;
5187 if (!mode_type) return;
5188 if ((it->delete_me) || (it->disabled)) return;
5189 if (wd->edit_mode) return;
5191 if ((wd->mode_item == it) &&
5192 (!strcmp(mode_type, wd->mode_type)) &&
5195 if (!it->itc->mode_item_style) return;
5199 EINA_LIST_FOREACH(wd->selected, l, it2)
5201 elm_genlist_item_selected_set(it2, EINA_FALSE);
5205 it2 = elm_genlist_selected_item_get(wd->obj);
5206 if ((it2) && (it2->realized))
5207 elm_genlist_item_selected_set(it2, EINA_FALSE);
5210 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5212 ((it == wd->mode_item) && (!mode_set)))
5213 _item_mode_unset(wd);
5215 eina_stringshare_replace(&wd->mode_type, mode_type);
5216 if (mode_set) _item_mode_set(it);
5220 elm_genlist_mode_get(const Evas_Object *obj)
5222 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5223 Widget_Data *wd = elm_widget_data_get(obj);
5224 if (!wd) return NULL;
5225 return wd->mode_type;
5228 EAPI const Elm_Genlist_Item *
5229 elm_genlist_mode_item_get(const Evas_Object *obj)
5231 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5232 Widget_Data *wd = elm_widget_data_get(obj);
5233 if (!wd) return NULL;
5234 return wd->mode_item;
5238 elm_genlist_reorder_mode_set(Evas_Object *obj,
5239 Eina_Bool reorder_mode)
5241 ELM_CHECK_WIDTYPE(obj, widtype);
5242 Widget_Data *wd = elm_widget_data_get(obj);
5244 wd->reorder_mode = reorder_mode;
5248 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5250 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5251 Widget_Data *wd = elm_widget_data_get(obj);
5252 if (!wd) return EINA_FALSE;
5253 return wd->reorder_mode;
5257 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
5263 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
5269 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5271 ELM_CHECK_WIDTYPE(obj, widtype);
5272 Widget_Data *wd = elm_widget_data_get(obj);
5274 wd->effect_mode = emode;
5275 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5276 // evas_object_resize(wd->point_rect, 10, 25);
5277 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5278 // evas_object_show(wd->point_rect);
5279 // evas_object_hide(wd->point_rect);
5283 _create_tray_alpha_bg(const Evas_Object *obj)
5285 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5286 Widget_Data *wd = elm_widget_data_get(obj);
5287 if (!wd) return NULL;
5289 Evas_Object *bg = NULL;
5290 Evas_Coord ox, oy, ow, oh;
5292 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5293 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5294 evas_object_color_set(bg,0,0,0,0);
5295 evas_object_resize(bg , ow, oh);
5296 evas_object_move(bg , ox, oy);
5297 evas_object_show(bg);
5298 evas_object_hide(bg);
5305 struct timeval timev;
5307 gettimeofday(&timev, NULL);
5308 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5311 // added for item moving animation.
5313 _item_moving_effect_timer_cb(void *data)
5315 Widget_Data *wd = data;
5316 if (!wd) return EINA_FALSE;
5318 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5319 Elm_Genlist_Item *it = NULL, *it2;
5321 double time = 0.3, t;
5323 Eina_Bool check, end = EINA_FALSE;
5326 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5328 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5329 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5330 if (t > time) end = EINA_TRUE;
5332 it2 = elm_genlist_item_next_get(wd->expand_item);
5335 if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5336 it2 = elm_genlist_item_next_get(it2);
5341 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5342 dy = it2->scrl_y - it2->old_scrl_y;
5343 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5344 dy = wd->expand_item_gap;
5348 y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5357 EINA_INLIST_FOREACH(wd->blocks, itb)
5360 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5361 itb->y - wd->pan_y + oy,
5363 cvx, cvy, cvw, cvh))
5365 EINA_LIST_FOREACH(itb->items, l, it)
5367 if (it == it2) check = EINA_TRUE;
5368 if (!check) continue;
5370 if (!it->old_scrl_y)
5371 it->old_scrl_y = it->scrl_y;
5372 if (it->old_scrl_y + y < oy + oh)
5374 if (!it->realized) _item_realize(it, in, 0);
5376 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5377 it->old_scrl_y = it->scrl_y - y;
5380 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5381 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5383 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5386 evas_object_resize(VIEW(it), it->w, it->h);
5387 evas_object_move(VIEW(it), it->scrl_x, it->old_scrl_y + y);
5388 evas_object_show(VIEW(it));
5389 evas_object_raise(VIEW(it));
5392 if (it->group_item) evas_object_raise(it->group_item->base.view);
5398 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5400 it = elm_genlist_item_prev_get(it2);
5403 if (it->expanded_depth <= it2->expanded_depth) break;
5404 if ((it->scrl_y < it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5406 if (!it->effect_done)
5408 edje_object_signal_emit(VIEW(it), "flip_item", "");
5409 evas_object_show(VIEW(it));
5410 it->effect_done = EINA_TRUE;
5413 it = elm_genlist_item_prev_get(it);
5416 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5418 it = elm_genlist_item_prev_get(it2);
5421 if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5423 if (!it->effect_done)
5425 edje_object_signal_emit(VIEW(it), "elm,state,hide", "");
5426 it->effect_done = EINA_TRUE;
5431 it = elm_genlist_item_prev_get(it);
5438 int expand_order = 0;
5439 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5443 it = elm_genlist_item_next_get(it);
5445 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5449 if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
5450 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5452 if (!it->effect_done)
5454 if (t >= (((expand_order - 1) * time) / expand_num))
5456 edje_object_signal_emit(VIEW(it), "flip_item", "");
5457 evas_object_show(VIEW(it));
5458 it->effect_done = EINA_TRUE;
5462 it = elm_genlist_item_next_get(it);
5468 if (wd->item_moving_effect_timer)
5470 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5471 _item_subitems_clear(wd->expand_item);
5472 EINA_INLIST_FOREACH(wd->blocks, itb)
5474 EINA_LIST_FOREACH(itb->items, l, it)
5476 it->effect_done = EINA_TRUE;
5477 it->old_scrl_y = it->scrl_y;
5481 wd->item_moving_effect_timer = NULL;
5483 _item_auto_scroll(wd);
5484 evas_object_lower(wd->alpha_bg);
5485 evas_object_hide(wd->alpha_bg);
5486 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5487 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5489 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5490 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5491 evas_object_smart_changed(wd->pan_smart);
5492 return ECORE_CALLBACK_CANCEL;
5494 return ECORE_CALLBACK_RENEW;
5498 _emit_contract(Elm_Genlist_Item *it)
5500 Elm_Genlist_Item *it2;
5503 // printf("%p is emited contract\n", it);
5504 edje_object_signal_emit(VIEW(it), "elm,state,contract_flip", "");
5505 it->effect_done = EINA_FALSE;
5507 EINA_LIST_FOREACH(it->items, l, it2)
5509 _emit_contract(it2);
5512 // added for item moving animation.
5514 _item_flip_effect_show(Elm_Genlist_Item *it)
5516 Elm_Genlist_Item *it2;
5518 Widget_Data *wd = it->wd;
5519 Eina_Bool check = EINA_FALSE;
5521 it2 = elm_genlist_item_next_get(it);
5524 if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5525 it2 = elm_genlist_item_next_get(it2);
5527 EINA_LIST_FOREACH(it->items, l, it2)
5529 if (it2->parent && it == it2->parent)
5531 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5532 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5533 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5534 _emit_contract(it2);
5538 return ECORE_CALLBACK_CANCEL;
5543 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5545 printf("!!! NOW FIXING \n");
5550 * Set pinch zoom mode
5552 * @param obj The genlist object
5554 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5559 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5561 printf("!!! NOW FIXING \n");
5565 * Get pinch zoom mode
5567 * @param obj The genlist object
5568 * @return The pinch mode
5569 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5574 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
5576 printf("!!! NOW FIXING \n");
5581 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5583 printf("!!! NOW FIXING \n");
5587 ////////////////////////////////////////////////////////////////////////
5589 ////////////////////////////////////////////////////////////////////////
5592 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5594 if (!it->wd->edit_mode) return;
5595 evas_object_resize(it->edit_obj,it->w, it->h);
5596 evas_object_move(it->edit_obj, itx, ity);
5600 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5602 if ((it->effect_item_realized) || (it->delete_me)) return;
5606 _mode_finished_signal_cb(it, (Evas_Object *)elm_genlist_item_object_get(it), NULL, NULL);
5608 it->edit_obj = edje_object_add(evas_object_evas_get(WIDGET(it)));
5609 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(WIDGET(it)) *
5610 _elm_config->scale);
5611 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5612 elm_widget_sub_object_add(WIDGET(it), it->edit_obj);
5614 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5615 else strncpy(buf, "item", sizeof(buf));
5616 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5618 strncat(buf, "/", sizeof(buf) - strlen(buf));
5620 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5622 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
5623 _elm_theme_object_set(WIDGET(it), it->edit_obj, "genlist", buf, elm_widget_style_get(WIDGET(it)));
5627 _elm_theme_object_set(WIDGET(it), it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(WIDGET(it)));
5630 if (it->wd->reorder_mode)
5632 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
5633 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
5635 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
5636 else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
5638 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
5639 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
5642 if ((it->wd->edit_mode))
5644 if (it->itc->func.icon_get)
5649 if (it->renamed) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
5650 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5651 EINA_LIST_FOREACH(it->icons, l, key)
5653 Evas_Object *ic = it->itc->func.icon_get
5654 ((void *)it->base.data, WIDGET(it), l->data);
5658 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5659 edje_object_part_swallow(it->edit_obj, key, ic);
5660 evas_object_show(ic);
5661 elm_widget_sub_object_add(WIDGET(it), ic);
5663 elm_widget_disabled_set(ic, EINA_TRUE);
5668 edje_object_part_swallow(it->edit_obj, "original_edc", VIEW(it));
5669 _effect_item_controls(it,it->scrl_x, it->scrl_y);
5670 evas_object_show(it->edit_obj);
5672 it->effect_item_realized = EINA_TRUE;
5673 it->want_unrealize = EINA_FALSE;
5677 _effect_item_unrealize(Elm_Genlist_Item *it)
5681 if (!it->effect_item_realized) return;
5682 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5684 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
5685 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
5686 edje_object_message_signal_process(it->edit_obj);
5687 edje_object_part_unswallow(it->edit_obj, VIEW(it));
5688 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
5689 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
5690 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5691 // _item_cache_add(it);
5692 evas_object_del(it->edit_obj);
5693 it->edit_obj = NULL;
5694 EINA_LIST_FREE(it->edit_icon_objs, icon)
5695 evas_object_del(icon);
5697 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5698 it->effect_item_realized = EINA_FALSE;
5702 * Get Genlist edit mode
5704 * @param obj The genlist object
5705 * @return The edit mode status
5706 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5711 elm_genlist_edit_mode_get(const Evas_Object *obj)
5713 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5714 Widget_Data *wd = elm_widget_data_get(obj);
5715 if (!wd) return EINA_FALSE;
5717 if (wd->edit_mode) return EINA_TRUE;
5718 else return EINA_FALSE;
5722 * Set Genlist edit mode
5724 * This sets Genlist edit mode.
5726 * @param obj The Genlist object
5727 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5728 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5733 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5735 ELM_CHECK_WIDTYPE(obj, widtype);
5739 Elm_Genlist_Item *it;
5741 Widget_Data *wd = elm_widget_data_get(obj);
5743 if (wd->edit_mode == edit_mode) return;
5745 wd->edit_mode = edit_mode;
5748 EINA_INLIST_FOREACH(wd->blocks, itb)
5752 EINA_LIST_FOREACH(itb->items, l, it)
5754 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5756 _effect_item_unrealize(it);
5761 _item_cache_zero(wd);
5766 EINA_INLIST_FOREACH(wd->blocks, itb)
5770 EINA_LIST_FOREACH(itb->items, l, it)
5772 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5774 if(it->selected) _item_unselect(it);
5775 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
5782 if (wd->calc_job) ecore_job_del(wd->calc_job);
5783 wd->calc_job = ecore_job_add(_calc_job, wd);
5787 * Set a given item's rename mode
5789 * This renames the item's label from genlist
5791 * @param it The item
5792 * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
5797 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
5803 _item_unrealize(it, EINA_FALSE);
5804 it->renamed = EINA_TRUE;
5805 it->nocache = EINA_TRUE;
5806 if (it->selected) _item_unselect(it);
5808 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5809 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5815 it->renamed = EINA_FALSE;
5816 it->nocache = EINA_TRUE;
5817 _item_cache_zero(it->wd);
5818 elm_genlist_item_update(it);
5824 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
5826 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5827 return item->renamed;