2 #include <Elementary.h>
3 #include <Elementary_Cursor.h>
7 #define MAX_ITEMS_PER_BLOCK 32
8 #define REORDER_EFFECT_TIME 0.5
10 typedef struct _Widget_Data Widget_Data;
11 typedef struct _Item_Block Item_Block;
12 typedef struct _Pan Pan;
13 typedef struct _Item_Cache Item_Cache;
14 typedef enum _Elm_Genlist_Item_Move_effect_Mode
16 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
17 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
18 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
19 ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE = (1 << 2),
20 } Elm_Genlist_Item_Move_effect_Mode;
24 Evas_Object *obj, *scr, *pan_smart;
25 Eina_Inlist *items, *blocks;
26 Eina_List *group_items;
28 Evas_Coord pan_x, pan_y, old_pan_y, w, h, minw, minh, realminw, prev_viewport_w;
29 Ecore_Job *calc_job, *update_job;
30 Ecore_Idle_Enterer *queue_idle_enterer;
31 Ecore_Idler *must_recalc_idler;
32 Eina_List *queue, *selected;
33 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item, *reorder_it, *reorder_rel, *expand_item;
34 Eina_Inlist *item_cache;
35 Evas_Coord anchor_y, reorder_start_y;
37 Ecore_Timer *multi_timer, *scr_hold_timer;
38 Ecore_Animator *reorder_move_animator;
39 const char *mode_type;
40 unsigned int start_time;
41 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
42 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
43 Eina_Bool mouse_down : 1;
44 Eina_Bool multi_down : 1;
45 Eina_Bool multi_timeout : 1;
46 Eina_Bool multitouched : 1;
47 Eina_Bool on_hold : 1;
49 Eina_Bool always_select : 1;
50 Eina_Bool longpressed : 1;
51 Eina_Bool wasselected : 1;
52 Eina_Bool no_select : 1;
53 Eina_Bool bring_in : 1;
54 Eina_Bool compress : 1;
55 Eina_Bool height_for_width : 1;
56 Eina_Bool pan_resize : 1;
57 Eina_Bool homogeneous : 1;
58 Eina_Bool clear_me : 1;
60 Eina_Bool reorder_mode : 1;
61 Eina_Bool reorder_pan_move : 1;
65 } history[SWIPE_MOVES];
74 int group_item_height;
75 int max_items_per_block;
76 double longpress_timeout;
79 Eina_Bool reorder_deleted : 1;
80 Eina_Bool effect_mode : 1;
81 Eina_Bool auto_scrolled : 1;
82 Eina_Bool pan_changed : 1;
83 Eina_Bool drag_started : 1;
85 Ecore_Animator *item_moving_effect_timer;
86 Evas_Object *alpha_bg;
87 Evas_Coord expand_item_end;
88 Evas_Coord expand_item_gap;
90 Ecore_Job *changed_job;
91 Elm_Genlist_Item *focused_rename_it;
92 Evas_Coord current_scrl_x;
93 Evas_Coord current_scrl_y;
104 Evas_Coord x, y, w, h, minw, minh;
105 Eina_Bool want_unrealize : 1;
106 Eina_Bool realized : 1;
107 Eina_Bool changed : 1;
108 Eina_Bool updateme : 1;
109 Eina_Bool changeme : 1;
110 Eina_Bool showme : 1;
111 Eina_Bool must_recalc : 1;
114 struct _Elm_Genlist_Item
116 Elm_Widget_Item base;
121 Evas_Coord x, y, w, h, minw, minh;
122 const Elm_Genlist_Item_Class *itc;
123 Elm_Genlist_Item *parent;
124 Elm_Genlist_Item *group_item;
125 Elm_Genlist_Item_Flags flags;
133 Eina_List *labels, *icons, *states, *icon_objs;
134 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
135 Ecore_Timer *long_timer;
136 Ecore_Timer *swipe_timer;
138 Evas_Coord scrl_x, scrl_y;
140 Elm_Genlist_Item *rel;
141 Evas_Object *mode_view;
146 Elm_Tooltip_Item_Content_Cb content_cb;
147 Evas_Smart_Cb del_cb;
151 const char *mouse_cursor;
158 Eina_Bool before : 1;
160 Eina_Bool want_unrealize : 1;
161 Eina_Bool want_realize : 1;
162 Eina_Bool realized : 1;
163 Eina_Bool selected : 1;
164 Eina_Bool highlighted : 1;
165 Eina_Bool expanded : 1;
166 Eina_Bool disabled : 1;
167 Eina_Bool display_only : 1;
168 Eina_Bool mincalcd : 1;
169 Eina_Bool queued : 1;
170 Eina_Bool showme : 1;
171 Eina_Bool delete_me : 1;
173 Eina_Bool dragging : 1;
174 Eina_Bool updateme : 1;
175 Eina_Bool nocache : 1;
176 Eina_Bool move_effect_enabled : 1;
177 Eina_Bool defer_unrealize : 1;
180 Eina_Bool effect_done : 1;
181 Eina_Bool reordering : 1;
182 Eina_Bool renamed : 1;
183 Eina_Bool effect_item_realized : 1;
184 Eina_List *edit_icon_objs;
185 Evas_Object *edit_obj;
187 Ecore_Animator *item_moving_effect_timer;
188 Evas_Coord old_scrl_y;
195 Evas_Object *base_view, *spacer;
197 const char *item_style; // it->itc->item_style
198 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
199 Eina_Bool compress : 1; // it->wd->compress
200 Eina_Bool odd : 1; // in & 0x1
202 Eina_Bool selected : 1; // it->selected
203 Eina_Bool disabled : 1; // it->disabled
204 Eina_Bool expanded : 1; // it->expanded
207 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
208 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
212 Evas_Object_Smart_Clipped_Data __clipped_data;
214 Ecore_Job *resize_job;
217 static const char *widtype = NULL;
218 static void _item_cache_zero(Widget_Data *wd);
219 static void _del_hook(Evas_Object *obj);
220 static void _mirrored_set(Evas_Object *obj,
222 static void _theme_hook(Evas_Object *obj);
223 static void _show_region_hook(void *data,
225 static void _sizing_eval(Evas_Object *obj);
226 static void _item_realize(Elm_Genlist_Item *it,
229 static void _item_unrealize(Elm_Genlist_Item *it,
231 static void _item_block_unrealize(Item_Block *itb);
232 static void _calc_job(void *data);
233 static void _on_focus_hook(void *data,
235 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
236 static void _changed_job(void *data);
237 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
238 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
239 static Eina_Bool _item_single_select_up(Widget_Data *wd);
240 static Eina_Bool _item_single_select_down(Widget_Data *wd);
241 static Eina_Bool _event_hook(Evas_Object *obj,
243 Evas_Callback_Type type,
245 static void _signal_emit_hook(Evas_Object *obj,
246 const char *emission,
248 static Eina_Bool _deselect_all_items(Widget_Data *wd);
249 static void _pan_calculate(Evas_Object *obj);
250 static void _pan_max_get(Evas_Object *obj,
253 static void _item_position(Elm_Genlist_Item *it,
257 static void _mode_item_realize(Elm_Genlist_Item *it);
258 static void _mode_item_unrealize(Elm_Genlist_Item *it);
259 static void _item_mode_set(Elm_Genlist_Item *it);
260 static void _item_mode_unset(Widget_Data *wd);
261 static void _group_items_recalc(void *data);
262 static void _item_move_after(Elm_Genlist_Item *it,
263 Elm_Genlist_Item *after);
264 static void _item_move_before(Elm_Genlist_Item *it,
265 Elm_Genlist_Item *before);
267 // TODO : refactoring
268 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
269 static unsigned int current_time_get();
270 static Eina_Bool _item_moving_effect_timer_cb(void *data);
271 static int _item_flip_effect_show(Elm_Genlist_Item *it);
272 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
273 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
274 static void _effect_item_unrealize(Elm_Genlist_Item *it);
275 static void _item_auto_scroll(void *data);
277 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
279 static const char SIG_ACTIVATED[] = "activated";
280 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
281 static const char SIG_SELECTED[] = "selected";
282 static const char SIG_UNSELECTED[] = "unselected";
283 static const char SIG_EXPANDED[] = "expanded";
284 static const char SIG_CONTRACTED[] = "contracted";
285 static const char SIG_EXPAND_REQUEST[] = "expand,request";
286 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
287 static const char SIG_REALIZED[] = "realized";
288 static const char SIG_UNREALIZED[] = "unrealized";
289 static const char SIG_DRAG_START_UP[] = "drag,start,up";
290 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
291 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
292 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
293 static const char SIG_DRAG_STOP[] = "drag,stop";
294 static const char SIG_DRAG[] = "drag";
295 static const char SIG_LONGPRESSED[] = "longpressed";
296 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
297 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
298 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
299 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
300 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
301 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
302 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
303 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
304 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
305 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
306 static const char SIG_SWIPE[] = "swipe";
308 static const Evas_Smart_Cb_Description _signals[] = {
309 {SIG_CLICKED_DOUBLE, ""},
312 {SIG_UNSELECTED, ""},
314 {SIG_CONTRACTED, ""},
315 {SIG_EXPAND_REQUEST, ""},
316 {SIG_CONTRACT_REQUEST, ""},
318 {SIG_UNREALIZED, ""},
319 {SIG_DRAG_START_UP, ""},
320 {SIG_DRAG_START_DOWN, ""},
321 {SIG_DRAG_START_LEFT, ""},
322 {SIG_DRAG_START_RIGHT, ""},
325 {SIG_LONGPRESSED, ""},
326 {SIG_SCROLL_EDGE_TOP, ""},
327 {SIG_SCROLL_EDGE_BOTTOM, ""},
328 {SIG_SCROLL_EDGE_LEFT, ""},
329 {SIG_SCROLL_EDGE_RIGHT, ""},
330 {SIG_MULTI_SWIPE_LEFT, ""},
331 {SIG_MULTI_SWIPE_RIGHT, ""},
332 {SIG_MULTI_SWIPE_UP, ""},
333 {SIG_MULTI_SWIPE_DOWN, ""},
334 {SIG_MULTI_PINCH_OUT, ""},
335 {SIG_MULTI_PINCH_IN, ""},
341 _event_hook(Evas_Object *obj,
342 Evas_Object *src __UNUSED__,
343 Evas_Callback_Type type,
346 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
347 Evas_Event_Key_Down *ev = event_info;
348 Widget_Data *wd = elm_widget_data_get(obj);
349 Evas_Coord pan_max_x = 0, pan_max_y = 0;
350 if (!wd) return EINA_FALSE;
351 if (!wd->items) return EINA_FALSE;
352 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
353 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
355 Elm_Genlist_Item *it = NULL;
358 Evas_Coord step_x = 0;
359 Evas_Coord step_y = 0;
362 Evas_Coord page_x = 0;
363 Evas_Coord page_y = 0;
365 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
366 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
367 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
368 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
370 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
374 else if ((!strcmp(ev->keyname, "Right")) ||
375 (!strcmp(ev->keyname, "KP_Right")))
379 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
381 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
382 (_item_multi_select_up(wd)))
383 || (_item_single_select_up(wd)))
385 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
391 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
393 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
394 (_item_multi_select_down(wd)))
395 || (_item_single_select_down(wd)))
397 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
403 else if ((!strcmp(ev->keyname, "Home")) ||
404 (!strcmp(ev->keyname, "KP_Home")))
406 it = elm_genlist_first_item_get(obj);
407 elm_genlist_item_bring_in(it);
408 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
411 else if ((!strcmp(ev->keyname, "End")) ||
412 (!strcmp(ev->keyname, "KP_End")))
414 it = elm_genlist_last_item_get(obj);
415 elm_genlist_item_bring_in(it);
416 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
419 else if ((!strcmp(ev->keyname, "Prior")) ||
420 (!strcmp(ev->keyname, "KP_Prior")))
423 y -= -(page_y * v_h) / 100;
427 else if ((!strcmp(ev->keyname, "Next")) ||
428 (!strcmp(ev->keyname, "KP_Next")))
431 y += -(page_y * v_h) / 100;
435 else if (((!strcmp(ev->keyname, "Return")) ||
436 (!strcmp(ev->keyname, "KP_Enter")) ||
437 (!strcmp(ev->keyname, "space")))
438 && (!wd->multi) && (wd->selected))
440 it = elm_genlist_selected_item_get(obj);
441 elm_genlist_item_expanded_set(it,
442 !elm_genlist_item_expanded_get(it));
443 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
445 else if (!strcmp(ev->keyname, "Escape"))
447 if (!_deselect_all_items(wd)) return EINA_FALSE;
448 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
451 else return EINA_FALSE;
453 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
454 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
456 if (x > pan_max_x) x = pan_max_x;
458 if (y > pan_max_y) y = pan_max_y;
459 elm_smart_scroller_child_pos_set(wd->scr, x, y);
464 _deselect_all_items(Widget_Data *wd)
466 if (!wd->selected) return EINA_FALSE;
468 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
474 _item_multi_select_up(Widget_Data *wd)
476 if (!wd->selected) return EINA_FALSE;
477 if (!wd->multi) return EINA_FALSE;
479 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
480 if (!prev) return EINA_TRUE;
482 if (elm_genlist_item_selected_get(prev))
484 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
485 wd->last_selected_item = prev;
486 elm_genlist_item_show(wd->last_selected_item);
490 elm_genlist_item_selected_set(prev, EINA_TRUE);
491 elm_genlist_item_show(prev);
497 _item_multi_select_down(Widget_Data *wd)
499 if (!wd->selected) return EINA_FALSE;
500 if (!wd->multi) return EINA_FALSE;
502 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
503 if (!next) return EINA_TRUE;
505 if (elm_genlist_item_selected_get(next))
507 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
508 wd->last_selected_item = next;
509 elm_genlist_item_show(wd->last_selected_item);
513 elm_genlist_item_selected_set(next, EINA_TRUE);
514 elm_genlist_item_show(next);
520 _item_single_select_up(Widget_Data *wd)
522 Elm_Genlist_Item *prev;
525 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
526 while ((prev) && (prev->delete_me))
527 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
529 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
531 if (!prev) return EINA_FALSE;
533 _deselect_all_items(wd);
535 elm_genlist_item_selected_set(prev, EINA_TRUE);
536 elm_genlist_item_show(prev);
541 _item_single_select_down(Widget_Data *wd)
543 Elm_Genlist_Item *next;
546 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
547 while ((next) && (next->delete_me))
548 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
550 else next = elm_genlist_item_next_get(wd->last_selected_item);
552 if (!next) return EINA_FALSE;
554 _deselect_all_items(wd);
556 elm_genlist_item_selected_set(next, EINA_TRUE);
557 elm_genlist_item_show(next);
562 _on_focus_hook(void *data __UNUSED__,
565 Widget_Data *wd = elm_widget_data_get(obj);
567 if (elm_widget_focus_get(obj))
569 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
570 evas_object_focus_set(wd->obj, EINA_TRUE);
571 if ((wd->selected) && (!wd->last_selected_item))
572 wd->last_selected_item = eina_list_data_get(wd->selected);
576 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
577 evas_object_focus_set(wd->obj, EINA_FALSE);
582 _del_hook(Evas_Object *obj)
584 Widget_Data *wd = elm_widget_data_get(obj);
586 _item_cache_zero(wd);
587 if (wd->calc_job) ecore_job_del(wd->calc_job);
588 if (wd->update_job) ecore_job_del(wd->update_job);
589 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
590 if (wd->changed_job) ecore_job_del(wd->changed_job);
591 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
592 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
593 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
594 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
599 _del_pre_hook(Evas_Object *obj)
601 Widget_Data *wd = elm_widget_data_get(obj);
603 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
604 elm_genlist_clear(obj);
605 evas_object_del(wd->pan_smart);
606 wd->pan_smart = NULL;
610 _mirrored_set(Evas_Object *obj,
613 Widget_Data *wd = elm_widget_data_get(obj);
615 _item_cache_zero(wd);
616 elm_smart_scroller_mirrored_set(wd->scr, rtl);
620 _theme_hook(Evas_Object *obj)
622 Widget_Data *wd = elm_widget_data_get(obj);
625 evas_event_freeze(evas_object_evas_get(wd->obj));
626 _item_cache_zero(wd);
627 _elm_widget_mirrored_reload(obj);
628 _mirrored_set(obj, elm_widget_mirrored_get(obj));
629 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
630 elm_widget_style_get(obj));
631 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
632 wd->item_width = wd->item_height = 0;
633 wd->group_item_width = wd->group_item_height = 0;
634 wd->minw = wd->minh = wd->realminw = 0;
635 EINA_INLIST_FOREACH(wd->blocks, itb)
638 Elm_Genlist_Item *it;
640 if (itb->realized) _item_block_unrealize(itb);
641 EINA_LIST_FOREACH(itb->items, l, it)
642 it->mincalcd = EINA_FALSE;
644 itb->changed = EINA_TRUE;
646 if (wd->calc_job) ecore_job_del(wd->calc_job);
647 wd->calc_job = ecore_job_add(_calc_job, wd);
649 evas_event_thaw(evas_object_evas_get(wd->obj));
650 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
654 _show_region_hook(void *data,
657 Widget_Data *wd = elm_widget_data_get(data);
658 Evas_Coord x, y, w, h;
659 Evas_Coord px, py, pw, ph;
660 Evas_Coord new_x, new_y;
662 elm_widget_show_region_get(obj, &x, &y, &w, &h);
663 evas_object_geometry_get(wd->pan_smart, &px, &py, &pw, &ph);
665 //x & y are screen coordinates, Add with pan coordinates
666 new_x = wd->current_scrl_x + x - pw + w;
667 new_y = wd->current_scrl_y + y - ph + h;
669 if (((new_y > 0) && wd->pan_changed && (y > ph)) || ((new_x > 0) && wd->pan_changed && (x > pw)))
670 elm_smart_scroller_child_pos_set(wd->scr, new_x, new_y);
672 elm_smart_scroller_child_pos_set(wd->scr, wd->current_scrl_x, wd->current_scrl_y);
676 _sizing_eval(Evas_Object *obj)
678 Widget_Data *wd = elm_widget_data_get(obj);
679 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
681 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
682 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
684 if (wd->height_for_width)
688 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
689 if ((vw != 0) && (vw != wd->prev_viewport_w))
693 wd->prev_viewport_w = vw;
694 EINA_INLIST_FOREACH(wd->blocks, itb)
696 itb->must_recalc = EINA_TRUE;
698 if (wd->calc_job) ecore_job_del(wd->calc_job);
699 wd->calc_job = ecore_job_add(_calc_job, wd);
702 if (wd->mode == ELM_LIST_LIMIT)
704 Evas_Coord vmw, vmh, vw, vh;
708 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
709 if ((minw > 0) && (vw < minw)) vw = minw;
710 else if ((maxw > 0) && (vw > maxw))
712 edje_object_size_min_calc
713 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
720 edje_object_size_min_calc
721 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
725 evas_object_size_hint_min_set(obj, minw, minh);
726 evas_object_size_hint_max_set(obj, maxw, maxh);
730 _signal_emit_hook(Evas_Object *obj,
731 const char *emission,
734 Widget_Data *wd = elm_widget_data_get(obj);
735 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
740 _item_highlight(Elm_Genlist_Item *it)
742 const char *selectraise;
743 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
744 (it->disabled) || (it->display_only) || (it->mode_view))
746 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
747 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
748 selectraise = edje_object_data_get(it->base.view, "selectraise");
749 if ((selectraise) && (!strcmp(selectraise, "on")))
751 if (it->edit_obj) evas_object_raise(it->edit_obj);
752 else evas_object_raise(it->base.view);
753 if ((it->group_item) && (it->group_item->realized))
754 evas_object_raise(it->group_item->base.view);
756 it->highlighted = EINA_TRUE;
760 _item_block_del(Elm_Genlist_Item *it)
763 Item_Block *itb = it->block;
765 itb->items = eina_list_remove(itb->items, it);
767 itb->changed = EINA_TRUE;
768 if (!it->wd->reorder_deleted)
770 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
771 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
775 il = EINA_INLIST_GET(itb);
776 Item_Block *itbn = (Item_Block *)(il->next);
778 it->parent->items = eina_list_remove(it->parent->items, it);
780 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
782 if (itbn) itbn->changed = EINA_TRUE;
786 if (itb->count < itb->wd->max_items_per_block/2)
788 il = EINA_INLIST_GET(itb);
789 Item_Block *itbp = (Item_Block *)(il->prev);
790 Item_Block *itbn = (Item_Block *)(il->next);
791 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
793 Elm_Genlist_Item *it2;
795 EINA_LIST_FREE(itb->items, it2)
798 itbp->items = eina_list_append(itbp->items, it2);
800 itbp->changed = EINA_TRUE;
802 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
803 EINA_INLIST_GET(itb));
806 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
810 Eina_List *last = eina_list_last(itb->items);
811 Elm_Genlist_Item *it2 = last->data;
814 itb->items = eina_list_remove_list(itb->items, last);
815 itbn->items = eina_list_prepend(itbn->items, it2);
817 itbn->changed = EINA_TRUE;
820 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
828 _item_subitems_clear(Elm_Genlist_Item *it)
831 Eina_List *tl = NULL, *l;
832 Elm_Genlist_Item *it2;
834 EINA_LIST_FOREACH(it->items, l, it2)
835 tl = eina_list_append(tl, it2);
837 EINA_LIST_FREE(tl, it2)
838 elm_genlist_item_del(it2);
842 _item_del(Elm_Genlist_Item *it)
844 Evas_Object *tob = it->wd->obj;
846 evas_event_freeze(evas_object_evas_get(tob));
847 elm_widget_item_pre_notify_del(it);
848 elm_genlist_item_subitems_clear(it);
849 it->wd->walking -= it->walking;
850 if (it->wd->show_item == it) it->wd->show_item = NULL;
851 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
852 if (it->realized) _item_unrealize(it, EINA_FALSE);
853 if (it->effect_item_realized) _effect_item_unrealize(it);
854 if (it->block) _item_block_del(it);
855 if ((!it->delete_me) && (it->itc->func.del))
856 it->itc->func.del((void *)it->base.data, it->base.widget);
857 it->delete_me = EINA_TRUE;
859 it->wd->queue = eina_list_remove(it->wd->queue, it);
861 if (it->wd->anchor_item == it)
863 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
864 if (!it->wd->anchor_item)
865 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
868 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
870 it->parent->items = eina_list_remove(it->parent->items, it);
871 if (it->flags & ELM_GENLIST_ITEM_GROUP)
872 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
873 if (it->long_timer) ecore_timer_del(it->long_timer);
874 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
876 if (it->tooltip.del_cb)
877 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
879 evas_event_thaw(evas_object_evas_get(tob));
880 evas_event_thaw_eval(evas_object_evas_get(tob));
882 elm_widget_item_del(it);
886 _item_select(Elm_Genlist_Item *it)
890 Evas_Object *parent = it->base.widget;
891 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
894 if (it->wd->always_select) goto call;
897 it->selected = EINA_TRUE;
898 it->wd->selected = eina_list_append(it->wd->selected, it);
900 evas_object_ref(parent);
903 if (it->wd->last_selected_item && (it != it->wd->last_selected_item))
905 EINA_LIST_FOREACH(it->wd->last_selected_item->icon_objs, l, obj)
906 elm_widget_focused_object_clear(obj);
908 if (it->func.func) it->func.func((void *)it->func.data, parent, it);
910 evas_object_smart_callback_call(parent, SIG_SELECTED, it);
913 if ((it->wd->clear_me) && (!it->wd->walking))
915 elm_genlist_clear(parent);
920 if ((!it->walking) && (it->delete_me))
922 if (!it->relcount) _item_del(it);
926 if (it && it->wd) it->wd->last_selected_item = it; // TODO: Remove 'if'?
928 evas_object_unref(parent);
932 _item_unselect(Elm_Genlist_Item *it)
934 const char *stacking, *selectraise;
936 if ((it->delete_me) || (!it->highlighted)) return;
937 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
938 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
939 stacking = edje_object_data_get(it->base.view, "stacking");
940 selectraise = edje_object_data_get(it->base.view, "selectraise");
941 if ((selectraise) && (!strcmp(selectraise, "on")))
943 if ((stacking) && (!strcmp(stacking, "below")))
944 evas_object_lower(it->base.view);
946 it->highlighted = EINA_FALSE;
949 it->selected = EINA_FALSE;
950 it->wd->selected = eina_list_remove(it->wd->selected, it);
951 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
956 _mouse_move(void *data,
957 Evas *evas __UNUSED__,
961 Elm_Genlist_Item *it = data;
962 Evas_Event_Mouse_Move *ev = event_info;
963 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
964 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
966 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
968 if (!it->wd->on_hold)
970 it->wd->on_hold = EINA_TRUE;
971 if (!it->wd->wasselected)
975 if (it->wd->multitouched)
977 it->wd->cur_x = ev->cur.canvas.x;
978 it->wd->cur_y = ev->cur.canvas.y;
981 if ((it->dragging) && (it->down))
983 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
986 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
987 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
988 if (abs((it->wd->history[it->wd->movements].x -
989 it->wd->history[0].x)) > 40)
990 it->wd->swipe = EINA_TRUE;
996 ecore_timer_del(it->long_timer);
997 it->long_timer = NULL;
999 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
1002 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1006 ecore_timer_del(it->long_timer);
1007 it->long_timer = NULL;
1009 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1011 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1012 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1014 if (!it->wd->reorder_start_y)
1015 it->wd->reorder_start_y = it->block->y + it->y;
1019 else if (it_scrl_y + it->wd->reorder_it->h > oy + oh)
1020 y_pos = oy + oh - it->wd->reorder_it->h;
1025 _item_position(it, it->edit_obj, it->scrl_x, y_pos);
1027 _item_position(it, it->base.view, it->scrl_x, y_pos);
1028 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1029 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1033 if (!it->display_only)
1034 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1035 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1036 x = ev->cur.canvas.x - x;
1037 y = ev->cur.canvas.y - y;
1040 if (adx < 0) adx = -dx;
1043 if (ady < 0) ady = -dy;
1046 if ((adx > minw) || (ady > minh))
1048 it->dragging = EINA_TRUE;
1051 ecore_timer_del(it->long_timer);
1052 it->long_timer = NULL;
1054 if (!it->wd->wasselected)
1058 if ((ady > adx) && (!it->wd->drag_started))
1059 evas_object_smart_callback_call(it->base.widget,
1060 SIG_DRAG_START_UP, it);
1064 evas_object_smart_callback_call(it->base.widget,
1065 SIG_DRAG_START_LEFT, it);
1067 evas_object_smart_callback_call(it->base.widget,
1068 SIG_DRAG_START_RIGHT, it);
1073 if ((ady > adx) && (!it->wd->drag_started))
1074 evas_object_smart_callback_call(it->base.widget,
1075 SIG_DRAG_START_DOWN, it);
1079 evas_object_smart_callback_call(it->base.widget,
1080 SIG_DRAG_START_LEFT, it);
1082 evas_object_smart_callback_call(it->base.widget,
1083 SIG_DRAG_START_RIGHT, it);
1090 _long_press(void *data)
1092 Elm_Genlist_Item *it = data, *it_tmp;
1093 Eina_List *list, *l;
1095 it->long_timer = NULL;
1096 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->focused_rename_it))
1097 return ECORE_CALLBACK_CANCEL;
1098 it->wd->longpressed = EINA_TRUE;
1099 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1100 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1102 it->wd->reorder_it = it;
1103 it->wd->reorder_start_y = 0;
1105 evas_object_raise(it->edit_obj);
1107 evas_object_raise(it->base.view);
1108 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1109 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1111 list = elm_genlist_realized_items_get(it->wd->obj);
1112 EINA_LIST_FOREACH(list, l, it_tmp)
1114 if (it != it_tmp) _item_unselect(it_tmp);
1118 EINA_LIST_FOREACH(it->items, l, it_tmp)
1120 if (elm_genlist_item_expanded_get(it_tmp))
1122 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1123 return ECORE_CALLBACK_RENEW;
1127 if (elm_genlist_item_expanded_get(it))
1129 elm_genlist_item_expanded_set(it, EINA_FALSE);
1130 return ECORE_CALLBACK_RENEW;
1133 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1135 edje_object_signal_emit(it->base.view, "elm,state,reorder,enabled", "elm");
1137 return ECORE_CALLBACK_CANCEL;
1141 _swipe(Elm_Genlist_Item *it)
1146 if ((it->display_only) || (it->disabled)) return;
1147 it->wd->swipe = EINA_FALSE;
1148 for (i = 0; i < it->wd->movements; i++)
1150 sum += it->wd->history[i].x;
1151 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1154 sum /= it->wd->movements;
1155 if (abs(sum - it->wd->history[0].x) <= 10) return;
1156 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1160 _swipe_cancel(void *data)
1162 Elm_Genlist_Item *it = data;
1164 if (!it) return ECORE_CALLBACK_CANCEL;
1165 it->wd->swipe = EINA_FALSE;
1166 it->wd->movements = 0;
1167 return ECORE_CALLBACK_RENEW;
1171 _multi_cancel(void *data)
1173 Widget_Data *wd = data;
1175 if (!wd) return ECORE_CALLBACK_CANCEL;
1176 wd->multi_timeout = EINA_TRUE;
1177 return ECORE_CALLBACK_RENEW;
1181 _multi_touch_gesture_eval(void *data)
1183 Elm_Genlist_Item *it = data;
1185 it->wd->multitouched = EINA_FALSE;
1186 if (it->wd->multi_timer)
1188 ecore_timer_del(it->wd->multi_timer);
1189 it->wd->multi_timer = NULL;
1191 if (it->wd->multi_timeout)
1193 it->wd->multi_timeout = EINA_FALSE;
1197 Evas_Coord minw = 0, minh = 0;
1198 Evas_Coord off_x, off_y, off_mx, off_my;
1200 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1201 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1202 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1203 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1204 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1206 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1208 if ((off_x + off_mx) > (off_y + off_my))
1210 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1211 evas_object_smart_callback_call(it->base.widget,
1212 SIG_MULTI_SWIPE_RIGHT, it);
1213 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1214 evas_object_smart_callback_call(it->base.widget,
1215 SIG_MULTI_SWIPE_LEFT, it);
1216 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1217 evas_object_smart_callback_call(it->base.widget,
1218 SIG_MULTI_PINCH_OUT, it);
1220 evas_object_smart_callback_call(it->base.widget,
1221 SIG_MULTI_PINCH_IN, it);
1225 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1226 evas_object_smart_callback_call(it->base.widget,
1227 SIG_MULTI_SWIPE_DOWN, it);
1228 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1229 evas_object_smart_callback_call(it->base.widget,
1230 SIG_MULTI_SWIPE_UP, it);
1231 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1232 evas_object_smart_callback_call(it->base.widget,
1233 SIG_MULTI_PINCH_OUT, it);
1235 evas_object_smart_callback_call(it->base.widget,
1236 SIG_MULTI_PINCH_IN, it);
1239 it->wd->multi_timeout = EINA_FALSE;
1243 _multi_down(void *data,
1244 Evas *evas __UNUSED__,
1245 Evas_Object *obj __UNUSED__,
1248 Elm_Genlist_Item *it = data;
1249 Evas_Event_Multi_Down *ev = event_info;
1251 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1252 it->wd->multi_device = ev->device;
1253 it->wd->multi_down = EINA_TRUE;
1254 it->wd->multitouched = EINA_TRUE;
1255 it->wd->prev_mx = ev->canvas.x;
1256 it->wd->prev_my = ev->canvas.y;
1257 if (!it->wd->wasselected) _item_unselect(it);
1258 it->wd->wasselected = EINA_FALSE;
1259 it->wd->longpressed = EINA_FALSE;
1262 ecore_timer_del(it->long_timer);
1263 it->long_timer = NULL;
1267 it->dragging = EINA_FALSE;
1268 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1270 if (it->swipe_timer)
1272 ecore_timer_del(it->swipe_timer);
1273 it->swipe_timer = NULL;
1275 if (it->wd->on_hold)
1277 it->wd->swipe = EINA_FALSE;
1278 it->wd->movements = 0;
1279 it->wd->on_hold = EINA_FALSE;
1284 _multi_up(void *data,
1285 Evas *evas __UNUSED__,
1286 Evas_Object *obj __UNUSED__,
1289 Elm_Genlist_Item *it = data;
1290 Evas_Event_Multi_Up *ev = event_info;
1292 if (it->wd->multi_device != ev->device) return;
1293 it->wd->multi_device = 0;
1294 it->wd->multi_down = EINA_FALSE;
1295 if (it->wd->mouse_down) return;
1296 _multi_touch_gesture_eval(data);
1300 _multi_move(void *data,
1301 Evas *evas __UNUSED__,
1302 Evas_Object *obj __UNUSED__,
1305 Elm_Genlist_Item *it = data;
1306 Evas_Event_Multi_Move *ev = event_info;
1308 if (it->wd->multi_device != ev->device) return;
1309 it->wd->cur_mx = ev->cur.canvas.x;
1310 it->wd->cur_my = ev->cur.canvas.y;
1314 _mouse_down(void *data,
1315 Evas *evas __UNUSED__,
1319 Elm_Genlist_Item *it = data;
1320 Evas_Event_Mouse_Down *ev = event_info;
1323 if (ev->button != 1) return;
1324 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1326 it->wd->on_hold = EINA_TRUE;
1328 it->down = EINA_TRUE;
1329 it->dragging = EINA_FALSE;
1330 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1331 it->dx = ev->canvas.x - x;
1332 it->dy = ev->canvas.y - y;
1333 it->wd->mouse_down = EINA_TRUE;
1334 if (!it->wd->multitouched)
1336 it->wd->prev_x = ev->canvas.x;
1337 it->wd->prev_y = ev->canvas.y;
1338 it->wd->multi_timeout = EINA_FALSE;
1339 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1340 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1342 it->wd->longpressed = EINA_FALSE;
1343 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1344 else it->wd->on_hold = EINA_FALSE;
1345 if (it->wd->on_hold) return;
1346 it->wd->wasselected = it->selected;
1347 _item_highlight(it);
1348 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1349 if ((!it->disabled) && (!it->display_only))
1351 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1352 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
1354 if (it->long_timer) ecore_timer_del(it->long_timer);
1355 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1356 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1358 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1361 it->long_timer = NULL;
1362 it->wd->swipe = EINA_FALSE;
1363 it->wd->movements = 0;
1367 _mouse_up(void *data,
1368 Evas *evas __UNUSED__,
1369 Evas_Object *obj __UNUSED__,
1372 Elm_Genlist_Item *it = data;
1373 Evas_Event_Mouse_Up *ev = event_info;
1374 Eina_Bool dragged = EINA_FALSE;
1376 if (ev->button != 1) return;
1377 it->down = EINA_FALSE;
1378 it->wd->mouse_down = EINA_FALSE;
1379 if (it->wd->multitouched)
1381 // in single selection modes, some multi touching can make multi highlighted items.
1382 // if a item not selected and highlighted, it should be unhighlighted.
1383 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unselect(it);
1384 if (it->wd->multi_down) return;
1385 _multi_touch_gesture_eval(data);
1388 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1389 else it->wd->on_hold = EINA_FALSE;
1392 ecore_timer_del(it->long_timer);
1393 it->long_timer = NULL;
1397 it->dragging = EINA_FALSE;
1398 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1401 if (it->swipe_timer)
1403 ecore_timer_del(it->swipe_timer);
1404 it->swipe_timer = NULL;
1406 if (it->wd->multi_timer)
1408 ecore_timer_del(it->wd->multi_timer);
1409 it->wd->multi_timer = NULL;
1410 it->wd->multi_timeout = EINA_FALSE;
1412 if (it->wd->on_hold)
1414 if (it->wd->swipe) _swipe(data);
1415 it->wd->longpressed = EINA_FALSE;
1416 it->wd->on_hold = EINA_FALSE;
1419 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1421 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1423 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1425 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1426 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1428 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1432 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1433 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1435 it->wd->reorder_deleted = EINA_FALSE;
1436 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1437 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1438 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1439 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1442 if (it->wd->longpressed)
1444 it->wd->longpressed = EINA_FALSE;
1445 if (!it->wd->wasselected)
1447 it->wd->wasselected = EINA_FALSE;
1452 if (it->want_unrealize)
1454 _item_unrealize(it, EINA_FALSE);
1455 if (it->block->want_unrealize)
1456 _item_block_unrealize(it->block);
1459 if ((it->disabled) || (dragged) || (it->display_only)) return;
1460 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1465 _item_highlight(it);
1468 else _item_unselect(it);
1474 Widget_Data *wd = it->wd;
1477 while (wd->selected) _item_unselect(wd->selected->data);
1482 const Eina_List *l, *l_next;
1483 Elm_Genlist_Item *it2;
1485 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1486 if (it2 != it) _item_unselect(it2);
1487 //_item_highlight(it);
1490 _item_highlight(it);
1496 _mouse_down_scroller(void *data,
1497 Evas *evas __UNUSED__,
1498 Evas_Object *obj __UNUSED__,
1499 void *event_info __UNUSED__)
1501 Widget_Data *wd = elm_widget_data_get(data);
1504 wd->drag_started = EINA_FALSE;
1508 _mouse_up_scroller(void *data,
1509 Evas *evas __UNUSED__,
1510 Evas_Object *obj __UNUSED__,
1511 void *event_info __UNUSED__)
1513 Widget_Data *wd = elm_widget_data_get(data);
1516 wd->drag_started = EINA_FALSE;
1520 _mouse_move_scroller(void *data,
1521 Evas *evas __UNUSED__,
1522 Evas_Object *obj __UNUSED__,
1525 Widget_Data *wd = elm_widget_data_get(data);
1526 Evas_Event_Mouse_Move *ev = event_info;
1527 Evas_Coord minw = 0, minh = 0, dx, dy, adx, ady;
1530 if (wd->drag_started) return;
1532 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1533 dx = ev->cur.canvas.x - ev->prev.canvas.x;
1534 dy = ev->cur.canvas.y - ev->prev.canvas.y;
1537 if (adx < 0) adx = -dx;
1538 if (ady < 0) ady = -dy;
1539 if (((ady < minh) && (ady > minh / 2)) && (ady > adx))
1543 evas_object_smart_callback_call(data, SIG_DRAG_START_UP, NULL);
1544 wd->drag_started = EINA_TRUE;
1548 evas_object_smart_callback_call(data, SIG_DRAG_START_DOWN, NULL);
1549 wd->drag_started = EINA_TRUE;
1555 _signal_expand_toggle(void *data,
1556 Evas_Object *obj __UNUSED__,
1557 const char *emission __UNUSED__,
1558 const char *source __UNUSED__)
1560 Elm_Genlist_Item *it = data;
1563 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1565 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1569 _signal_expand(void *data,
1570 Evas_Object *obj __UNUSED__,
1571 const char *emission __UNUSED__,
1572 const char *source __UNUSED__)
1574 Elm_Genlist_Item *it = data;
1577 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1581 _signal_contract(void *data,
1582 Evas_Object *obj __UNUSED__,
1583 const char *emission __UNUSED__,
1584 const char *source __UNUSED__)
1586 Elm_Genlist_Item *it = data;
1589 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1593 _scr_hold_timer_cb(void *data)
1595 if (!data) return ECORE_CALLBACK_CANCEL;
1596 Widget_Data *wd = data;
1597 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1598 wd->scr_hold_timer = NULL;
1599 return ECORE_CALLBACK_CANCEL;
1603 _mode_finished_signal_cb(void *data,
1605 const char *emission __UNUSED__,
1606 const char *source __UNUSED__)
1610 Elm_Genlist_Item *it = data;
1611 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1613 Evas *te = evas_object_evas_get(obj);
1615 evas_event_freeze(te);
1616 it->nocache = EINA_FALSE;
1617 _mode_item_unrealize(it);
1619 evas_object_raise(it->group_item->base.view);
1620 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1621 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1622 evas_event_thaw(te);
1623 evas_event_thaw_eval(te);
1627 _item_cache_clean(Widget_Data *wd)
1629 evas_event_freeze(evas_object_evas_get(wd->obj));
1630 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1634 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1635 wd->item_cache = eina_inlist_remove(wd->item_cache,
1636 wd->item_cache->last);
1637 wd->item_cache_count--;
1638 if (itc->spacer) evas_object_del(itc->spacer);
1639 if (itc->base_view) evas_object_del(itc->base_view);
1640 if (itc->item_style) eina_stringshare_del(itc->item_style);
1643 evas_event_thaw(evas_object_evas_get(wd->obj));
1644 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1648 _item_cache_zero(Widget_Data *wd)
1650 int pmax = wd->item_cache_max;
1651 wd->item_cache_max = 0;
1652 _item_cache_clean(wd);
1653 wd->item_cache_max = pmax;
1657 _item_cache_add(Elm_Genlist_Item *it)
1661 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1662 if (it->wd->item_cache_max <= 0)
1664 evas_object_del(it->base.view);
1665 it->base.view = NULL;
1666 evas_object_del(it->spacer);
1668 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1669 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1673 it->wd->item_cache_count++;
1674 itc = calloc(1, sizeof(Item_Cache));
1677 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1678 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1681 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1682 EINA_INLIST_GET(itc));
1683 itc->spacer = it->spacer;
1685 itc->base_view = it->base.view;
1686 it->base.view = NULL;
1687 evas_object_hide(itc->base_view);
1688 evas_object_move(itc->base_view, -9999, -9999);
1689 itc->item_style = eina_stringshare_add(it->itc->item_style);
1690 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1691 itc->compress = (it->wd->compress);
1692 itc->odd = (it->order_num_in & 0x1);
1693 itc->selected = it->selected;
1694 itc->disabled = it->disabled;
1695 itc->expanded = it->expanded;
1698 ecore_timer_del(it->long_timer);
1699 it->long_timer = NULL;
1701 if (it->swipe_timer)
1703 ecore_timer_del(it->swipe_timer);
1704 it->swipe_timer = NULL;
1706 // FIXME: other callbacks?
1707 edje_object_signal_callback_del_full(itc->base_view,
1708 "elm,action,expand,toggle",
1709 "elm", _signal_expand_toggle, it);
1710 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1712 _signal_expand, it);
1713 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1714 "elm", _signal_contract, it);
1715 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1717 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1719 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1721 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1723 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1725 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1727 _item_cache_clean(it->wd);
1728 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1729 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1733 _item_cache_find(Elm_Genlist_Item *it)
1736 Eina_Bool tree = 0, odd;
1738 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1739 odd = (it->order_num_in & 0x1);
1740 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1742 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1744 if ((itc->tree == tree) &&
1745 (itc->odd == odd) &&
1746 (itc->compress == it->wd->compress) &&
1747 (!strcmp(it->itc->item_style, itc->item_style)))
1749 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1750 EINA_INLIST_GET(itc));
1751 it->wd->item_cache_count--;
1759 _item_cache_free(Item_Cache *itc)
1761 if (itc->spacer) evas_object_del(itc->spacer);
1762 if (itc->base_view) evas_object_del(itc->base_view);
1763 if (itc->item_style) eina_stringshare_del(itc->item_style);
1768 _item_label_hook(Elm_Genlist_Item *it, const char *part)
1770 if (!it->itc->func.label_get) return NULL;
1771 return edje_object_part_text_get(it->base.view, part);
1775 _icon_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1777 Elm_Genlist_Item *it = data;
1778 if (it) it->defer_unrealize = EINA_TRUE;
1779 if (it->renamed && (it->wd->focused_rename_it != it)) it->wd->focused_rename_it = it;
1783 _icon_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1785 Elm_Genlist_Item *it = data;
1786 if (it) it->defer_unrealize = EINA_FALSE;
1787 if (it->renamed && (it->wd->focused_rename_it == it)) it->wd->focused_rename_it = NULL;
1791 _item_del_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1793 Elm_Genlist_Item *it = event_info;
1795 if (it->wd->last_selected_item == it)
1796 it->wd->last_selected_item = NULL;
1800 _item_label_realize(Elm_Genlist_Item *it,
1801 Evas_Object *target,
1804 if (it->itc->func.label_get)
1809 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1810 EINA_LIST_FOREACH(*source, l, key)
1812 char *s = it->itc->func.label_get
1813 ((void *)it->base.data, it->base.widget, key);
1817 edje_object_part_text_set(target, key, s);
1822 edje_object_part_text_set(target, key, "");
1829 _item_icon_realize(Elm_Genlist_Item *it,
1830 Evas_Object *target,
1833 Eina_List *res = NULL;
1835 if (it->itc->func.icon_get)
1840 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1841 EINA_LIST_FOREACH(*source, l, key)
1843 Evas_Object *ic = it->itc->func.icon_get
1844 ((void *)it->base.data, it->base.widget, key);
1848 res = eina_list_append(res, ic);
1849 edje_object_part_swallow(target, key, ic);
1850 evas_object_show(ic);
1851 elm_widget_sub_object_add(it->base.widget, ic);
1852 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
1854 elm_widget_disabled_set(ic, EINA_TRUE);
1863 _item_state_realize(Elm_Genlist_Item *it,
1864 Evas_Object *target,
1867 if (it->itc->func.state_get)
1873 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1874 EINA_LIST_FOREACH(*source, l, key)
1876 Eina_Bool on = it->itc->func.state_get
1877 ((void *)it->base.data, it->base.widget, key);
1881 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1882 edje_object_signal_emit(target, buf, "elm");
1886 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1887 edje_object_signal_emit(target, buf, "elm");
1894 _item_realize(Elm_Genlist_Item *it,
1898 Elm_Genlist_Item *it2;
1899 const char *stacking;
1900 const char *treesize;
1902 int depth, tsize = 20;
1903 Item_Cache *itc = NULL;
1905 if ((it->realized) || (it->delete_me)) return;
1906 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1907 it->order_num_in = in;
1908 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1909 if ((it->nocache) && (!it->renamed))
1910 it->nocache = EINA_FALSE;
1912 itc = _item_cache_find(it);
1913 if (itc && (!it->wd->effect_mode))
1915 it->base.view = itc->base_view;
1916 itc->base_view = NULL;
1917 it->spacer = itc->spacer;
1922 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1923 edje_object_scale_set(it->base.view,
1924 elm_widget_scale_get(it->base.widget) *
1925 _elm_config->scale);
1926 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1927 elm_widget_sub_object_add(it->base.widget, it->base.view);
1929 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1930 strncpy(buf, "tree", sizeof(buf));
1931 else strncpy(buf, "item", sizeof(buf));
1932 if (it->wd->compress)
1933 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1935 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1936 strncat(buf, "/", sizeof(buf) - strlen(buf));
1937 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1939 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1940 elm_widget_style_get(it->base.widget));
1941 edje_object_mirrored_set(it->base.view,
1942 elm_widget_mirrored_get(it->base.widget));
1944 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1945 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1946 elm_widget_sub_object_add(it->base.widget, it->spacer);
1948 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1950 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1952 it->expanded_depth = depth;
1953 treesize = edje_object_data_get(it->base.view, "treesize");
1954 if (treesize) tsize = atoi(treesize);
1955 evas_object_size_hint_min_set(it->spacer,
1956 (depth * tsize) * _elm_config->scale, 1);
1957 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1960 edje_object_signal_callback_add(it->base.view,
1961 "elm,action,expand,toggle",
1962 "elm", _signal_expand_toggle, it);
1963 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1964 "elm", _signal_expand, it);
1965 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1966 "elm", _signal_contract, it);
1967 stacking = edje_object_data_get(it->base.view, "stacking");
1970 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1971 else if (!strcmp(stacking, "above"))
1972 evas_object_raise(it->base.view);
1974 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1976 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1978 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1980 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1982 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1984 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1987 if ((!it->edit_obj) &&(it->wd->edit_mode) &&
1988 (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
1989 _effect_item_realize(it, EINA_FALSE);
1993 if ((it->selected) && (it->selected != itc->selected))
1995 edje_object_signal_emit(it->base.view,
1996 "elm,state,selected", "elm");
1998 edje_object_signal_emit(it->edit_obj,
1999 "elm,state,selected", "elm");
2001 if ((it->disabled) && (it->disabled != itc->disabled))
2003 edje_object_signal_emit(it->base.view,
2004 "elm,state,disabled", "elm");
2006 edje_object_signal_emit(it->edit_obj,
2007 "elm,state,disabled", "elm");
2009 if ((it->expanded) && (it->expanded != itc->expanded))
2011 edje_object_signal_emit(it->base.view,
2012 "elm,state,expanded", "elm");
2014 edje_object_signal_emit(it->edit_obj,
2015 "elm,state,expanded", "elm");
2022 edje_object_signal_emit(it->base.view,
2023 "elm,state,selected", "elm");
2025 edje_object_signal_emit(it->edit_obj,
2026 "elm,state,selected", "elm");
2030 edje_object_signal_emit(it->base.view,
2031 "elm,state,disabled", "elm");
2033 edje_object_signal_emit(it->edit_obj,
2034 "elm,state,disabled", "elm");
2038 edje_object_signal_emit(it->base.view,
2039 "elm,state,expanded", "elm");
2041 edje_object_signal_emit(it->edit_obj,
2042 "elm,state,expanded", "elm");
2047 if ((calc) && (it->wd->homogeneous) &&
2048 ((it->wd->item_width) ||
2049 ((it->wd->item_width) && (it->wd->group_item_width))))
2051 /* homogenous genlist shortcut */
2054 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2056 it->w = it->minw = it->wd->group_item_width;
2057 it->h = it->minh = it->wd->group_item_height;
2061 it->w = it->minw = it->wd->item_width;
2062 it->h = it->minh = it->wd->item_height;
2064 it->mincalcd = EINA_TRUE;
2069 _item_label_realize(it, it->base.view, &it->labels);
2070 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
2071 _item_state_realize(it, it->base.view, &it->states);
2072 if (it->itc->func.icon_get) // for rename mode
2079 elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
2080 EINA_LIST_FOREACH(it->icons, l, key)
2082 Evas_Object *ic = it->itc->func.icon_get
2083 ((void *)it->base.data, it->base.widget, l->data);
2086 it->icon_objs = eina_list_append(it->icon_objs, ic);
2087 edje_object_part_swallow(it->base.view, key, ic);
2088 evas_object_show(ic);
2089 elm_widget_sub_object_add(it->base.widget, ic);
2090 // FIXME: if entry calcuates its cursor position correctly and conformant works,
2091 // genlist does not need to handle this focus thing.
2092 evas_object_smart_callback_add(ic, "focused", _icon_focused, it);
2093 evas_object_smart_callback_add(ic, "unfocused", _icon_unfocused, it);
2098 if (!it->mincalcd || it->wd->pan_resize || ((it->wd->height_for_width) && (it->w != it->minw)))
2100 Evas_Coord mw = -1, mh = -1;
2102 if (it->wd->height_for_width) mw = it->wd->w; // TODO: Removed this. This was removed from upstream.
2104 if (!it->display_only)
2105 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2106 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2107 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2109 if (!it->display_only)
2110 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2111 it->w = it->minw = mw;
2112 it->h = it->minh = mh;
2113 it->mincalcd = EINA_TRUE;
2115 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2117 it->wd->group_item_width = mw;
2118 it->wd->group_item_height = mh;
2120 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2122 it->wd->item_width = mw;
2123 it->wd->item_height = mh;
2126 if (!calc) evas_object_show(it->base.view);
2129 if (it->tooltip.content_cb)
2131 elm_widget_item_tooltip_content_cb_set(it,
2132 it->tooltip.content_cb,
2133 it->tooltip.data, NULL);
2134 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2137 if (it->mouse_cursor)
2138 elm_widget_item_cursor_set(it, it->mouse_cursor);
2140 it->realized = EINA_TRUE;
2141 it->want_unrealize = EINA_FALSE;
2143 if (itc) _item_cache_free(itc);
2144 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2145 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2147 evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2148 if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
2150 if (it->itc->edit_item_style)
2152 if (!it->edit_obj) _effect_item_realize(it, EINA_FALSE);
2153 edje_object_message_signal_process(it->edit_obj);
2156 edje_object_message_signal_process(it->base.view);
2160 _item_unrealize(Elm_Genlist_Item *it,
2165 if (!it->realized) return;
2166 if (it->wd->reorder_it == it) return;
2167 if (it->defer_unrealize && !it->updateme) return;
2168 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2170 evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2173 ecore_timer_del(it->long_timer);
2174 it->long_timer = NULL;
2178 evas_object_del(it->base.view);
2179 it->base.view = NULL;
2180 evas_object_del(it->spacer);
2185 edje_object_mirrored_set(it->base.view,
2186 elm_widget_mirrored_get(it->base.widget));
2187 edje_object_scale_set(it->base.view,
2188 elm_widget_scale_get(it->base.widget)
2189 * _elm_config->scale);
2190 _item_cache_add(it);
2192 elm_widget_stringlist_free(it->labels);
2194 elm_widget_stringlist_free(it->icons);
2196 elm_widget_stringlist_free(it->states);
2198 EINA_LIST_FREE(it->icon_objs, icon)
2199 evas_object_del(icon);
2201 _mode_item_unrealize(it);
2203 it->realized = EINA_FALSE;
2204 it->want_unrealize = EINA_FALSE;
2205 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2206 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2207 if (it->wd->edit_mode) _effect_item_unrealize(it);
2211 _item_block_recalc(Item_Block *itb,
2216 Elm_Genlist_Item *it;
2217 Evas_Coord minw = 0, minh = 0;
2218 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2221 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2223 EINA_LIST_FOREACH(itb->items, l, it)
2225 if (it->delete_me) continue;
2226 showme |= it->showme;
2231 if (!it->mincalcd) changed = EINA_TRUE;
2234 _item_realize(it, in, EINA_TRUE);
2235 _item_unrealize(it, EINA_TRUE);
2240 _item_realize(it, in, EINA_TRUE);
2241 _item_unrealize(it, EINA_TRUE);
2245 _item_realize(it, in, EINA_FALSE);
2247 if (minw < it->minw) minw = it->minw;
2255 itb->changed = EINA_FALSE;
2256 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2257 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2262 _item_block_realize(Item_Block *itb)
2264 if (itb->realized) return;
2265 itb->realized = EINA_TRUE;
2266 itb->want_unrealize = EINA_FALSE;
2270 _item_block_unrealize(Item_Block *itb)
2273 Elm_Genlist_Item *it;
2274 Eina_Bool dragging = EINA_FALSE;
2276 if (!itb->realized) return;
2277 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2278 EINA_LIST_FOREACH(itb->items, l, it)
2280 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2284 dragging = EINA_TRUE;
2285 it->want_unrealize = EINA_TRUE;
2288 _item_unrealize(it, EINA_FALSE);
2293 itb->realized = EINA_FALSE;
2294 itb->want_unrealize = EINA_TRUE;
2297 itb->want_unrealize = EINA_FALSE;
2298 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2299 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2303 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2305 Evas_Coord rox, roy, row, roh, oy, oh;
2306 Eina_Bool top = EINA_FALSE;
2307 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2308 if (!reorder_it) return 0;
2310 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2311 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2313 if ((it->wd->reorder_start_y < it->block->y) &&
2314 (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2316 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2317 if (it->block->count == 1)
2318 it->wd->reorder_rel = it;
2320 else if ((it->wd->reorder_start_y >= it->block->y) &&
2321 (roy - oy + (roh / 2) <= it->block->y - it->wd->pan_y))
2323 it->block->reorder_offset = it->wd->reorder_it->h;
2326 it->block->reorder_offset = 0;
2328 it->scrl_y += it->block->reorder_offset;
2330 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2331 rox, roy + (roh / 2), row, 1));
2334 it->wd->reorder_rel = it;
2335 it->scrl_y += it->wd->reorder_it->h;
2336 return it->wd->reorder_it->h;
2343 _reorder_move_animator_cb(void *data)
2345 Elm_Genlist_Item *it = data;
2346 Eina_Bool down = EINA_FALSE;
2348 int y, dy = it->h / 10 * _elm_config->scale, diff;
2350 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2352 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2355 diff = abs(it->old_scrl_y - it->scrl_y);
2356 if (diff > it->h) y = diff / 2;
2357 if (it->old_scrl_y < it->scrl_y)
2359 it->old_scrl_y += y;
2362 else if (it->old_scrl_y > it->scrl_y)
2364 it->old_scrl_y -= y;
2369 _item_position(it, it->edit_obj, it->scrl_x, it->old_scrl_y);
2371 _item_position(it, it->base.view, it->scrl_x, it->old_scrl_y);
2372 _group_items_recalc(it->wd);
2373 if ((it->wd->reorder_pan_move) ||
2374 (down && it->old_scrl_y >= it->scrl_y) ||
2375 (!down && it->old_scrl_y <= it->scrl_y))
2377 it->old_scrl_y = it->scrl_y;
2378 it->move_effect_enabled = EINA_FALSE;
2379 it->wd->reorder_move_animator = NULL;
2380 return ECORE_CALLBACK_CANCEL;
2382 return ECORE_CALLBACK_RENEW;
2386 _item_position(Elm_Genlist_Item *it,
2394 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2395 evas_object_resize(view, it->w, it->h);
2396 evas_object_move(view, it_x, it_y);
2397 evas_object_show(view);
2398 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2399 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2403 _item_block_position(Item_Block *itb,
2407 Elm_Genlist_Item *it;
2408 Elm_Genlist_Item *git;
2409 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2410 Evas_Coord minh = 0;
2413 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2414 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2415 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2417 EINA_LIST_FOREACH(itb->items, l, it)
2419 if (it->delete_me) continue;
2420 else if (it->wd->reorder_it == it) continue;
2425 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2426 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2428 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2429 cvx, cvy, cvw, cvh));
2430 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2432 if ((itb->realized))
2436 if (!it->realized) _item_realize(it, in, EINA_FALSE);
2439 if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
2440 edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
2448 if (it->wd->reorder_mode)
2449 y += _get_space_for_reorder_item(it);
2450 git = it->group_item;
2453 git->scrl_x = it->scrl_x;
2454 if (git->scrl_y < oy)
2456 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2457 git->scrl_y = (it->scrl_y + it->h) - git->h;
2458 git->want_realize = EINA_TRUE;
2460 if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2462 if (!it->move_effect_enabled)
2464 it->move_effect_enabled = EINA_TRUE;
2465 it->wd->reorder_move_animator =
2467 _reorder_move_animator_cb, it);
2470 if (!it->move_effect_enabled)
2471 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))
2473 if (it->wd->edit_mode && it->itc->edit_item_style)
2475 _item_position(it, it->edit_obj, it->scrl_x, it->scrl_y);
2479 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)))
2482 _item_position(it, it->mode_view, it->scrl_x,
2485 _item_position(it, it->base.view, it->scrl_x,
2490 evas_object_resize(it->base.view, it->w, it->h);
2491 evas_object_move(it->base.view, it->scrl_x, it->scrl_y);
2492 evas_object_hide(it->base.view);
2499 if (!it->dragging && (!it->wd->item_moving_effect_timer)) _item_unrealize(it, EINA_FALSE);
2506 if (vis) it->want_realize = EINA_TRUE;
2508 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))
2510 it->old_scrl_y = it->scrl_y;
2515 if (!itb->wd->reorder_it) itb->minh = minh;
2516 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2517 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2521 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2523 Elm_Genlist_Item *it = data;
2525 it->mincalcd = EINA_FALSE;
2526 it->block->changeme = EINA_TRUE;
2527 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2528 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2532 _group_items_recalc(void *data)
2534 Widget_Data *wd = data;
2536 Elm_Genlist_Item *git;
2538 evas_event_freeze(evas_object_evas_get(wd->obj));
2539 EINA_LIST_FOREACH(wd->group_items, l, git)
2541 if (git->want_realize)
2544 _item_realize(git, 0, EINA_FALSE);
2545 evas_object_resize(git->base.view, wd->minw, git->h);
2546 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2547 evas_object_show(git->base.view);
2548 evas_object_raise(git->base.view);
2550 else if (!git->want_realize && git->realized)
2553 _item_unrealize(git, EINA_FALSE);
2556 evas_event_thaw(evas_object_evas_get(wd->obj));
2557 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2561 _must_recalc_idler(void *data)
2563 Widget_Data *wd = data;
2564 if (wd->calc_job) ecore_job_del(wd->calc_job);
2565 wd->calc_job = ecore_job_add(_calc_job, wd);
2566 wd->must_recalc_idler = NULL;
2567 return ECORE_CALLBACK_CANCEL;
2571 _calc_job(void *data)
2573 Widget_Data *wd = data;
2574 Item_Block *itb, *chb = NULL;
2575 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2578 Eina_Bool minw_change = EINA_FALSE;
2579 Eina_Bool did_must_recalc = EINA_FALSE;
2582 t0 = ecore_time_get();
2583 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2587 evas_event_freeze(evas_object_evas_get(wd->obj));
2588 EINA_INLIST_FOREACH(wd->blocks, itb)
2590 Eina_Bool showme = EINA_FALSE;
2593 showme = itb->showme;
2594 itb->showme = EINA_FALSE;
2597 if (itb->realized) _item_block_unrealize(itb);
2599 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2601 if (itb->must_recalc)
2604 Elm_Genlist_Item *it;
2605 EINA_LIST_FOREACH(itb->items, l, it)
2606 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2607 itb->changed = EINA_TRUE;
2608 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2609 itb->must_recalc = EINA_FALSE;
2610 if (itb->realized) _item_block_unrealize(itb);
2612 showme = _item_block_recalc(itb, in, EINA_FALSE);
2618 if (minw == -1) minw = itb->minw;
2619 else if ((!itb->must_recalc) && (minw < itb->minw))
2622 minw_change = EINA_TRUE;
2628 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2630 wd->show_item->showme = EINA_FALSE;
2632 elm_smart_scroller_region_bring_in(wd->scr,
2634 wd->show_item->block->x,
2636 wd->show_item->block->y,
2637 wd->show_item->block->w,
2640 elm_smart_scroller_child_region_show(wd->scr,
2642 wd->show_item->block->x,
2644 wd->show_item->block->y,
2645 wd->show_item->block->w,
2647 wd->show_item = NULL;
2652 EINA_INLIST_FOREACH(wd->blocks, itb)
2658 if ((chb) && (EINA_INLIST_GET(chb)->next))
2660 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2662 if (itb->realized) _item_block_unrealize(itb);
2665 wd->realminw = minw;
2666 if (minw < wd->w) minw = wd->w;
2667 if ((minw != wd->minw) || (minh != wd->minh))
2671 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2672 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2673 _sizing_eval(wd->obj);
2675 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2677 Elm_Genlist_Item *it;
2680 it = wd->anchor_item;
2681 it_y = wd->anchor_y;
2682 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2683 it->block->y + it->y + it_y);
2684 wd->anchor_item = it;
2685 wd->anchor_y = it_y;
2689 t = ecore_time_get();
2690 if (did_must_recalc)
2692 if (!wd->must_recalc_idler)
2693 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2695 wd->calc_job = NULL;
2696 evas_object_smart_changed(wd->pan_smart);
2697 evas_event_thaw(evas_object_evas_get(wd->obj));
2698 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2702 _update_job(void *data)
2704 Widget_Data *wd = data;
2708 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2710 wd->update_job = NULL;
2713 evas_event_freeze(evas_object_evas_get(wd->obj));
2714 EINA_INLIST_FOREACH(wd->blocks, itb)
2716 Evas_Coord itminw, itminh;
2717 Elm_Genlist_Item *it;
2723 _item_block_position(itb, num);
2727 recalc = EINA_FALSE;
2728 EINA_LIST_FOREACH(itb->items, l2, it)
2737 _item_unrealize(it, EINA_FALSE);
2738 _item_realize(it, num, EINA_FALSE);
2739 position = EINA_TRUE;
2743 _item_realize(it, num, EINA_TRUE);
2744 _item_unrealize(it, EINA_TRUE);
2746 if ((it->minw != itminw) || (it->minh != itminh))
2748 it->updateme = EINA_FALSE;
2752 itb->updateme = EINA_FALSE;
2755 position = EINA_TRUE;
2756 itb->changed = EINA_TRUE;
2757 _item_block_recalc(itb, num0, EINA_FALSE);
2758 _item_block_position(itb, num0);
2763 if (wd->calc_job) ecore_job_del(wd->calc_job);
2764 wd->calc_job = ecore_job_add(_calc_job, wd);
2766 evas_event_thaw(evas_object_evas_get(wd->obj));
2767 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2771 _changed_job(void *data)
2773 Widget_Data *wd = data; Eina_List *l2;
2775 int num, num0, position = 0;
2776 Eina_Bool width_changed = EINA_FALSE, height_changed = EINA_FALSE;
2778 wd->changed_job = NULL;
2780 EINA_INLIST_FOREACH(wd->blocks, itb)
2782 Evas_Coord itminw, itminh;
2783 Elm_Genlist_Item *it;
2789 _item_block_position(itb, num);
2793 width_changed = height_changed = EINA_FALSE;
2794 EINA_LIST_FOREACH(itb->items, l2, it)
2796 if ((!it->mincalcd) && (it->realized))
2798 Evas_Coord mw = -1, mh = -1;
2802 if (it->wd->height_for_width) mw = it->wd->w;
2803 if (!it->display_only)
2804 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2805 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2806 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2807 if (!it->display_only)
2808 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2809 it->w = it->minw = mw;
2810 it->h = it->minh = mh;
2811 it->mincalcd = EINA_TRUE;
2813 //if ((it->minw != itminw) || (it->minh != itminh))
2814 //if ((it->minh != itminh))
2816 if ((it->minw != itminw))
2817 width_changed = EINA_TRUE;
2818 if ((it->minh != itminh))
2819 height_changed = EINA_TRUE;
2821 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2823 it->wd->group_item_width = mw;
2824 it->wd->group_item_height = mh;
2826 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2828 it->wd->item_width = mw;
2829 it->wd->item_height = mh;
2834 itb->changeme = EINA_FALSE;
2835 // TODO: why this is separated.
2839 itb->changed = EINA_TRUE;
2840 _item_block_recalc(itb, num0, 0);
2841 _item_block_position(itb, num0);
2843 else if (width_changed)
2845 _item_block_position(itb, num0);
2850 if (wd->calc_job) ecore_job_del(wd->calc_job);
2851 wd->calc_job = ecore_job_add(_calc_job, wd);
2856 _pan_set(Evas_Object *obj,
2860 Pan *sd = evas_object_smart_data_get(obj);
2866 // Evas_Coord ow, oh;
2867 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2868 // ow = sd->wd->minw - ow;
2869 // if (ow < 0) ow = 0;
2870 // oh = sd->wd->minh - oh;
2871 // if (oh < 0) oh = 0;
2872 // if (x < 0) x = 0;
2873 // if (y < 0) y = 0;
2874 // if (x > ow) x = ow;
2875 // if (y > oh) y = oh;
2876 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2881 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2883 if ((itb->y + itb->h) > y)
2885 Elm_Genlist_Item *it;
2888 EINA_LIST_FOREACH(itb->items, l2, it)
2890 if ((itb->y + it->y) >= y)
2892 sd->wd->anchor_item = it;
2893 sd->wd->anchor_y = -(itb->y + it->y - y);
2901 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2905 _pan_get(Evas_Object *obj,
2909 Pan *sd = evas_object_smart_data_get(obj);
2912 if (x) *x = sd->wd->pan_x;
2913 if (y) *y = sd->wd->pan_y;
2917 _pan_max_get(Evas_Object *obj,
2921 Pan *sd = evas_object_smart_data_get(obj);
2925 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2926 ow = sd->wd->minw - ow;
2928 oh = sd->wd->minh - oh;
2935 _pan_min_get(Evas_Object *obj __UNUSED__,
2944 _pan_child_size_get(Evas_Object *obj,
2948 Pan *sd = evas_object_smart_data_get(obj);
2951 if (w) *w = sd->wd->minw;
2952 if (h) *h = sd->wd->minh;
2956 _pan_add(Evas_Object *obj)
2959 Evas_Object_Smart_Clipped_Data *cd;
2962 cd = evas_object_smart_data_get(obj);
2965 sd->__clipped_data = *cd;
2967 evas_object_smart_data_set(obj, sd);
2971 _pan_del(Evas_Object *obj)
2973 Pan *sd = evas_object_smart_data_get(obj);
2978 ecore_job_del(sd->resize_job);
2979 sd->resize_job = NULL;
2985 _pan_resize_job(void *data)
2989 _sizing_eval(sd->wd->obj);
2990 sd->resize_job = NULL;
2994 _pan_resize(Evas_Object *obj,
2998 Pan *sd = evas_object_smart_data_get(obj);
3002 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
3003 if ((ow == w) && (oh == h)) return;
3004 if ((sd->wd->height_for_width) && (ow != w))
3006 sd->wd->pan_resize = EINA_TRUE;
3007 if (sd->resize_job) ecore_job_del(sd->resize_job);
3008 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
3010 sd->wd->pan_changed = EINA_TRUE;
3011 evas_object_smart_changed(obj);
3012 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3013 sd->wd->calc_job = NULL;
3017 _pan_calculate(Evas_Object *obj)
3019 Pan *sd = evas_object_smart_data_get(obj);
3021 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
3022 Evas_Coord scr_x, scr_y;
3024 Elm_Genlist_Item *git;
3028 evas_event_freeze(evas_object_evas_get(obj));
3029 elm_smart_scroller_child_pos_get(sd->wd->scr, &scr_x, &scr_y);
3030 sd->wd->current_scrl_x = scr_x;
3031 sd->wd->current_scrl_y = scr_y;
3032 if (sd->wd->pan_changed)
3035 sd->wd->pan_changed = EINA_FALSE;
3038 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3039 sd->wd->prev_viewport_w = ow;
3040 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
3041 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
3043 git->want_realize = EINA_FALSE;
3045 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
3047 itb->w = sd->wd->minw;
3048 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
3049 itb->y - sd->wd->pan_y + oy,
3051 cvx, cvy, cvw, cvh))
3053 if ((!itb->realized) || (itb->changed))
3054 _item_block_realize(itb);
3055 _item_block_position(itb, in);
3059 if (itb->realized) _item_block_unrealize(itb);
3063 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
3064 _group_items_recalc(sd->wd);
3066 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
3068 if (sd->wd->pan_y != sd->wd->old_pan_y)
3069 sd->wd->reorder_pan_move = EINA_TRUE;
3070 else sd->wd->reorder_pan_move = EINA_FALSE;
3071 evas_object_raise(sd->wd->reorder_it->edit_obj);
3072 sd->wd->old_pan_y = sd->wd->pan_y;
3073 sd->wd->start_time = ecore_loop_time_get();
3076 if (sd->wd->effect_mode &&
3077 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
3078 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
3079 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
3081 if (!sd->wd->item_moving_effect_timer)
3083 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
3084 _item_flip_effect_show(sd->wd->expand_item);
3086 evas_object_raise(sd->wd->alpha_bg);
3087 evas_object_show(sd->wd->alpha_bg);
3088 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
3089 sd->wd->start_time = current_time_get();
3090 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
3093 else _item_auto_scroll(sd->wd);
3094 sd->wd->pan_resize = EINA_FALSE;
3095 evas_event_thaw(evas_object_evas_get(obj));
3096 evas_event_thaw_eval(evas_object_evas_get(obj));
3100 _pan_move(Evas_Object *obj,
3101 Evas_Coord x __UNUSED__,
3102 Evas_Coord y __UNUSED__)
3104 Pan *sd = evas_object_smart_data_get(obj);
3108 sd->wd->pan_changed = EINA_TRUE;
3109 evas_object_smart_changed(obj);
3110 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3111 sd->wd->calc_job = NULL;
3115 _hold_on(void *data __UNUSED__,
3117 void *event_info __UNUSED__)
3119 Widget_Data *wd = elm_widget_data_get(obj);
3121 elm_smart_scroller_hold_set(wd->scr, 1);
3125 _hold_off(void *data __UNUSED__,
3127 void *event_info __UNUSED__)
3129 Widget_Data *wd = elm_widget_data_get(obj);
3131 elm_smart_scroller_hold_set(wd->scr, 0);
3135 _freeze_on(void *data __UNUSED__,
3137 void *event_info __UNUSED__)
3139 Widget_Data *wd = elm_widget_data_get(obj);
3141 elm_smart_scroller_freeze_set(wd->scr, 1);
3145 _freeze_off(void *data __UNUSED__,
3147 void *event_info __UNUSED__)
3149 Widget_Data *wd = elm_widget_data_get(obj);
3151 elm_smart_scroller_freeze_set(wd->scr, 0);
3155 _scroll_edge_left(void *data,
3156 Evas_Object *scr __UNUSED__,
3157 void *event_info __UNUSED__)
3159 Evas_Object *obj = data;
3160 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
3164 _scroll_edge_right(void *data,
3165 Evas_Object *scr __UNUSED__,
3166 void *event_info __UNUSED__)
3168 Evas_Object *obj = data;
3169 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
3173 _scroll_edge_top(void *data,
3174 Evas_Object *scr __UNUSED__,
3175 void *event_info __UNUSED__)
3177 Evas_Object *obj = data;
3178 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
3182 _scroll_edge_bottom(void *data,
3183 Evas_Object *scr __UNUSED__,
3184 void *event_info __UNUSED__)
3186 Evas_Object *obj = data;
3187 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
3191 _mode_item_realize(Elm_Genlist_Item *it)
3195 if ((it->mode_view) || (it->delete_me)) return;
3197 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3198 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
3199 edje_object_scale_set(it->mode_view,
3200 elm_widget_scale_get(it->base.widget) *
3201 _elm_config->scale);
3202 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
3203 elm_widget_sub_object_add(it->base.widget, it->mode_view);
3205 strncpy(buf, "item", sizeof(buf));
3206 if (it->wd->compress)
3207 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3209 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3210 strncat(buf, "/", sizeof(buf) - strlen(buf));
3211 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3213 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
3214 elm_widget_style_get(it->base.widget));
3215 edje_object_mirrored_set(it->mode_view,
3216 elm_widget_mirrored_get(it->base.widget));
3218 /* signal callback add */
3219 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3221 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3223 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3226 /* label_get, icon_get, state_get */
3227 _item_label_realize(it, it->mode_view, &it->mode_labels);
3228 if (it->itc->func.icon_get)
3234 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3236 EINA_LIST_FOREACH(it->mode_icons, l, key)
3238 Evas_Object *ic = it->itc->func.icon_get
3239 ((void *)it->base.data, it->base.widget, l->data);
3243 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
3244 edje_object_part_swallow(it->mode_view, key, ic);
3245 evas_object_show(ic);
3246 elm_widget_sub_object_add(it->base.widget, ic);
3248 elm_widget_disabled_set(ic, EINA_TRUE);
3252 _item_state_realize(it, it->mode_view, &it->mode_states);
3253 edje_object_part_swallow(it->mode_view,
3254 edje_object_data_get(it->mode_view, "mode_part"),
3257 it->want_unrealize = EINA_FALSE;
3258 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3259 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3263 _mode_item_unrealize(Elm_Genlist_Item *it)
3265 Widget_Data *wd = it->wd;
3267 if (!it->mode_view) return;
3269 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3270 elm_widget_stringlist_free(it->mode_labels);
3271 it->mode_labels = NULL;
3272 elm_widget_stringlist_free(it->mode_icons);
3273 it->mode_icons = NULL;
3274 elm_widget_stringlist_free(it->mode_states);
3276 EINA_LIST_FREE(it->mode_icon_objs, icon)
3277 evas_object_del(icon);
3279 edje_object_part_unswallow(it->mode_view, it->base.view);
3280 evas_object_smart_member_add(it->base.view, wd->pan_smart);
3281 evas_object_del(it->mode_view);
3282 it->mode_view = NULL;
3284 if (wd->mode_item == it)
3285 wd->mode_item = NULL;
3286 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3287 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3291 _item_mode_set(Elm_Genlist_Item *it)
3294 Widget_Data *wd = it->wd;
3299 it->nocache = EINA_TRUE;
3301 if (wd->scr_hold_timer)
3303 ecore_timer_del(wd->scr_hold_timer);
3304 wd->scr_hold_timer = NULL;
3306 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3307 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3309 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3310 _mode_item_realize(it);
3312 evas_object_raise(it->group_item->base.view);
3313 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
3314 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3315 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3317 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3318 edje_object_signal_emit(it->mode_view, buf, "elm");
3322 _item_mode_unset(Widget_Data *wd)
3325 if (!wd->mode_item) return;
3326 char buf[1024], buf2[1024];
3327 Elm_Genlist_Item *it;
3330 it->nocache = EINA_TRUE;
3332 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3333 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3335 edje_object_signal_emit(it->mode_view, buf, "elm");
3336 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3338 wd->mode_item = NULL;
3343 _item_auto_scroll(void *data)
3345 Widget_Data *wd = data;
3348 if ((wd->expand_item) && (!wd->auto_scrolled))
3350 Elm_Genlist_Item *it;
3352 Evas_Coord ox, oy, ow, oh;
3353 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3355 wd->auto_scrolled = EINA_TRUE;
3356 if (wd->expand_item->scrl_y > (oh + oy) / 2)
3358 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
3360 elm_genlist_item_bring_in(it);
3366 elm_genlist_add(Evas_Object *parent)
3371 Evas_Coord minw, minh;
3372 static Evas_Smart *smart = NULL;
3376 static Evas_Smart_Class sc;
3378 evas_object_smart_clipped_smart_set(&_pan_sc);
3380 sc.name = "elm_genlist_pan";
3381 sc.version = EVAS_SMART_CLASS_VERSION;
3384 sc.resize = _pan_resize;
3385 sc.move = _pan_move;
3386 sc.calculate = _pan_calculate;
3387 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3390 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3392 ELM_SET_WIDTYPE(widtype, "genlist");
3393 elm_widget_type_set(obj, "genlist");
3394 elm_widget_sub_object_add(parent, obj);
3395 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3396 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3397 elm_widget_data_set(obj, wd);
3398 elm_widget_del_hook_set(obj, _del_hook);
3399 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3400 elm_widget_theme_hook_set(obj, _theme_hook);
3401 elm_widget_can_focus_set(obj, EINA_TRUE);
3402 elm_widget_event_hook_set(obj, _event_hook);
3403 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3405 wd->scr = elm_smart_scroller_add(e);
3406 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_DOWN,
3407 _mouse_down_scroller, obj);
3408 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_UP,
3409 _mouse_up_scroller, obj);
3410 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_MOVE,
3411 _mouse_move_scroller, obj);
3412 elm_smart_scroller_widget_set(wd->scr, obj);
3413 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3414 elm_widget_style_get(obj));
3415 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3416 _elm_config->thumbscroll_bounce_enable);
3417 elm_widget_resize_object_set(obj, wd->scr);
3419 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3420 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3422 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3423 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3427 wd->mode = ELM_LIST_SCROLL;
3428 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3429 wd->item_cache_max = wd->max_items_per_block * 2;
3430 wd->longpress_timeout = _elm_config->longpress_timeout;
3431 wd->effect_mode = _elm_config->effect_enable;
3433 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3434 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3435 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3436 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3438 wd->pan_smart = evas_object_smart_add(e, smart);
3439 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3442 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3443 _pan_set, _pan_get, _pan_max_get,
3444 _pan_min_get, _pan_child_size_get);
3446 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3448 evas_object_size_hint_min_set(obj, minw, minh);
3450 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3451 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3456 static Elm_Genlist_Item *
3457 _item_new(Widget_Data *wd,
3458 const Elm_Genlist_Item_Class *itc,
3460 Elm_Genlist_Item *parent,
3461 Elm_Genlist_Item_Flags flags,
3463 const void *func_data)
3465 Elm_Genlist_Item *it;
3467 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3468 if (!it) return NULL;
3471 it->base.data = data;
3472 it->parent = parent;
3474 it->func.func = func;
3475 it->func.data = func_data;
3476 it->mouse_cursor = NULL;
3477 it->expanded_depth = 0;
3478 elm_widget_item_text_get_hook_set(it, _item_label_hook);
3479 elm_widget_item_del_cb_set(it, _item_del_hook);
3483 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3484 it->group_item = parent;
3485 else if (it->parent->group_item)
3486 it->group_item = it->parent->group_item;
3492 _item_block_add(Widget_Data *wd,
3493 Elm_Genlist_Item *it)
3495 Item_Block *itb = NULL;
3502 itb = calloc(1, sizeof(Item_Block));
3505 if (!it->rel->block)
3508 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3509 itb->items = eina_list_append(itb->items, it);
3515 wd->blocks = eina_inlist_prepend_relative
3516 (wd->blocks, EINA_INLIST_GET(itb),
3517 EINA_INLIST_GET(it->rel->block));
3519 eina_list_prepend_relative(itb->items, it, it->rel);
3523 wd->blocks = eina_inlist_append_relative
3524 (wd->blocks, EINA_INLIST_GET(itb),
3525 EINA_INLIST_GET(it->rel->block));
3527 eina_list_append_relative(itb->items, it, it->rel);
3537 itb = (Item_Block *)(wd->blocks);
3538 if (itb->count >= wd->max_items_per_block)
3540 itb = calloc(1, sizeof(Item_Block));
3544 eina_inlist_prepend(wd->blocks,
3545 EINA_INLIST_GET(itb));
3550 itb = calloc(1, sizeof(Item_Block));
3554 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3556 itb->items = eina_list_prepend(itb->items, it);
3562 itb = (Item_Block *)(wd->blocks->last);
3563 if (itb->count >= wd->max_items_per_block)
3565 itb = calloc(1, sizeof(Item_Block));
3569 eina_inlist_append(wd->blocks,
3570 EINA_INLIST_GET(itb));
3575 itb = calloc(1, sizeof(Item_Block));
3579 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3581 itb->items = eina_list_append(itb->items, it);
3587 itb = it->rel->block;
3588 if (!itb) goto newblock;
3590 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3592 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3595 itb->changed = EINA_TRUE;
3597 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3598 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3601 it->rel->relcount--;
3602 if ((it->rel->delete_me) && (!it->rel->relcount))
3606 if (itb->count > itb->wd->max_items_per_block)
3610 Elm_Genlist_Item *it2;
3612 newc = itb->count / 2;
3613 itb2 = calloc(1, sizeof(Item_Block));
3617 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3618 EINA_INLIST_GET(itb));
3619 itb2->changed = EINA_TRUE;
3620 while ((itb->count > newc) && (itb->items))
3624 l = eina_list_last(itb->items);
3626 itb->items = eina_list_remove_list(itb->items, l);
3629 itb2->items = eina_list_prepend(itb2->items, it2);
3637 _queue_process(Widget_Data *wd)
3640 Eina_Bool showme = EINA_FALSE;
3643 t0 = ecore_time_get();
3644 //evas_event_freeze(evas_object_evas_get(wd->obj));
3645 for (n = 0; (wd->queue) && (n < 128); n++)
3647 Elm_Genlist_Item *it;
3649 it = wd->queue->data;
3650 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3651 it->queued = EINA_FALSE;
3652 _item_block_add(wd, it);
3653 t = ecore_time_get();
3654 if (it->block->changed)
3656 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3657 it->block->changed = 0;
3659 if (showme) it->block->showme = EINA_TRUE;
3660 if (eina_inlist_count(wd->blocks) > 1)
3662 if ((t - t0) > (ecore_animator_frametime_get())) break;
3665 //evas_event_thaw(evas_object_evas_get(wd->obj));
3666 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3671 _idle_process(void *data, Eina_Bool *wakeup)
3673 Widget_Data *wd = data;
3676 //static double q_start = 0.0;
3677 //if (q_start == 0.0) q_start = ecore_time_get();
3679 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3683 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3685 return ECORE_CALLBACK_CANCEL;
3687 return ECORE_CALLBACK_RENEW;
3691 _item_idle_enterer(void *data)
3693 Widget_Data *wd = data;
3694 Eina_Bool wakeup = EINA_FALSE;
3695 Eina_Bool ok = _idle_process(data, &wakeup);
3700 if (wd->calc_job) ecore_job_del(wd->calc_job);
3701 wd->calc_job = ecore_job_add(_calc_job, wd);
3703 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3708 _item_queue(Widget_Data *wd,
3709 Elm_Genlist_Item *it)
3711 if (it->queued) return;
3712 it->queued = EINA_TRUE;
3713 wd->queue = eina_list_append(wd->queue, it);
3714 // FIXME: why does a freeze then thaw here cause some genlist
3715 // elm_genlist_item_append() to be much much slower?
3716 // evas_event_freeze(evas_object_evas_get(wd->obj));
3717 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3719 if (wd->queue_idle_enterer)
3721 ecore_idle_enterer_del(wd->queue_idle_enterer);
3722 wd->queue_idle_enterer = NULL;
3726 // evas_event_thaw(evas_object_evas_get(wd->obj));
3727 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3728 if (!wd->queue_idle_enterer)
3729 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3733 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3738 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3739 it->wd->reorder_deleted = EINA_TRUE;
3740 _item_block_del(it);
3742 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3744 it->rel->relcount++;
3745 it->before = EINA_FALSE;
3746 if (after->group_item) it->group_item = after->group_item;
3747 _item_queue(it->wd, it);
3749 // TODO: change this to smart callback
3750 if (it->itc->func.moved)
3751 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
3755 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3758 if (!before) return;
3760 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3761 it->wd->reorder_deleted = EINA_TRUE;
3762 _item_block_del(it);
3763 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3765 it->rel->relcount++;
3766 it->before = EINA_TRUE;
3767 if (before->group_item) it->group_item = before->group_item;
3768 _item_queue(it->wd, it);
3770 // TODO: change this to smart callback
3771 if (it->itc->func.moved)
3772 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
3775 EAPI Elm_Genlist_Item *
3776 elm_genlist_item_append(Evas_Object *obj,
3777 const Elm_Genlist_Item_Class *itc,
3779 Elm_Genlist_Item *parent,
3780 Elm_Genlist_Item_Flags flags,
3782 const void *func_data)
3784 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3785 Widget_Data *wd = elm_widget_data_get(obj);
3786 if (!wd) return NULL;
3787 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3789 if (!it) return NULL;
3792 if (flags & ELM_GENLIST_ITEM_GROUP)
3793 wd->group_items = eina_list_append(wd->group_items, it);
3794 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3799 Elm_Genlist_Item *it2 = NULL;
3800 Eina_List *ll = eina_list_last(it->parent->items);
3801 if (ll) it2 = ll->data;
3802 it->parent->items = eina_list_append(it->parent->items, it);
3803 if (!it2) it2 = it->parent;
3805 it2 = elm_genlist_item_prev_get(it2);
3807 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3808 EINA_INLIST_GET(it2));
3810 it->rel->relcount++;
3812 it->before = EINA_FALSE;
3813 _item_queue(wd, it);
3817 EAPI Elm_Genlist_Item *
3818 elm_genlist_item_prepend(Evas_Object *obj,
3819 const Elm_Genlist_Item_Class *itc,
3821 Elm_Genlist_Item *parent,
3822 Elm_Genlist_Item_Flags flags,
3824 const void *func_data)
3826 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3827 Widget_Data *wd = elm_widget_data_get(obj);
3828 if (!wd) return NULL;
3829 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3831 if (!it) return NULL;
3834 if (flags & ELM_GENLIST_ITEM_GROUP)
3835 wd->group_items = eina_list_prepend(wd->group_items, it);
3836 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3841 Elm_Genlist_Item *it2 = NULL;
3842 Eina_List *ll = it->parent->items;
3843 if (ll) it2 = ll->data;
3844 it->parent->items = eina_list_prepend(it->parent->items, it);
3845 if (!it2) it2 = it->parent;
3847 it2 = elm_genlist_item_next_get(it2);
3849 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3850 EINA_INLIST_GET(it2));
3852 it->rel->relcount++;
3854 it->before = EINA_TRUE;
3855 _item_queue(wd, it);
3859 EAPI Elm_Genlist_Item *
3860 elm_genlist_item_insert_after(Evas_Object *obj,
3861 const Elm_Genlist_Item_Class *itc,
3863 Elm_Genlist_Item *parent,
3864 Elm_Genlist_Item *after,
3865 Elm_Genlist_Item_Flags flags,
3867 const void *func_data)
3869 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3870 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3871 Widget_Data *wd = elm_widget_data_get(obj);
3872 if (!wd) return NULL;
3873 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3875 if (!it) return NULL;
3876 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3877 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3881 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3882 (after->flags & ELM_GENLIST_ITEM_GROUP))
3883 wd->group_items = eina_list_append_relative(wd->group_items, it,
3888 it->parent->items = eina_list_append_relative(it->parent->items, it,
3891 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3892 EINA_INLIST_GET(after));
3894 it->rel->relcount++;
3895 it->before = EINA_FALSE;
3896 _item_queue(wd, it);
3900 EAPI Elm_Genlist_Item *
3901 elm_genlist_item_insert_before(Evas_Object *obj,
3902 const Elm_Genlist_Item_Class *itc,
3904 Elm_Genlist_Item *parent,
3905 Elm_Genlist_Item *before,
3906 Elm_Genlist_Item_Flags flags,
3908 const void *func_data)
3910 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3911 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3912 Widget_Data *wd = elm_widget_data_get(obj);
3913 if (!wd) return NULL;
3914 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3916 if (!it) return NULL;
3917 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
3918 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3922 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3923 (before->flags & ELM_GENLIST_ITEM_GROUP))
3924 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
3929 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3932 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3933 EINA_INLIST_GET(before));
3935 it->rel->relcount++;
3936 it->before = EINA_TRUE;
3937 _item_queue(wd, it);
3942 elm_genlist_clear(Evas_Object *obj)
3944 ELM_CHECK_WIDTYPE(obj, widtype);
3945 Widget_Data *wd = elm_widget_data_get(obj);
3947 if (wd->walking > 0)
3949 Elm_Genlist_Item *it;
3951 wd->clear_me = EINA_TRUE;
3952 EINA_INLIST_FOREACH(wd->items, it)
3954 it->delete_me = EINA_TRUE;
3958 evas_event_freeze(evas_object_evas_get(wd->obj));
3961 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3962 it->nocache = EINA_TRUE;
3963 it->highlighted = EINA_FALSE;
3965 if (wd->anchor_item == it)
3967 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3968 if (!wd->anchor_item)
3970 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3973 wd->items = eina_inlist_remove(wd->items, wd->items);
3974 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3975 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3976 elm_widget_item_pre_notify_del(it);
3977 if (it->realized) _item_unrealize(it, EINA_FALSE);
3978 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3979 it->itc->func.del((void *)it->base.data, it->base.widget);
3980 if (it->long_timer) ecore_timer_del(it->long_timer);
3981 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3982 elm_widget_item_del(it);
3984 wd->clear_me = EINA_FALSE;
3985 wd->anchor_item = NULL;
3988 Item_Block *itb = (Item_Block *)(wd->blocks);
3990 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3991 if (itb->items) eina_list_free(itb->items);
3996 ecore_job_del(wd->calc_job);
3997 wd->calc_job = NULL;
3999 if (wd->queue_idle_enterer)
4001 ecore_idle_enterer_del(wd->queue_idle_enterer);
4002 wd->queue_idle_enterer = NULL;
4004 if (wd->must_recalc_idler)
4006 ecore_idler_del(wd->must_recalc_idler);
4007 wd->must_recalc_idler = NULL;
4011 eina_list_free(wd->queue);
4016 eina_list_free(wd->selected);
4017 wd->selected = NULL;
4019 if (wd->reorder_move_animator)
4021 ecore_animator_del(wd->reorder_move_animator);
4022 wd->reorder_move_animator = NULL;
4024 wd->show_item = NULL;
4032 evas_object_del(wd->alpha_bg);
4033 wd->alpha_bg = NULL;
4037 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4038 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4041 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
4042 evas_event_thaw(evas_object_evas_get(wd->obj));
4043 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4047 elm_genlist_multi_select_set(Evas_Object *obj,
4050 ELM_CHECK_WIDTYPE(obj, widtype);
4051 Widget_Data *wd = elm_widget_data_get(obj);
4057 elm_genlist_multi_select_get(const Evas_Object *obj)
4059 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4060 Widget_Data *wd = elm_widget_data_get(obj);
4061 if (!wd) return EINA_FALSE;
4065 EAPI Elm_Genlist_Item *
4066 elm_genlist_selected_item_get(const Evas_Object *obj)
4068 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4069 Widget_Data *wd = elm_widget_data_get(obj);
4070 if (!wd) return NULL;
4071 if (wd->selected) return wd->selected->data;
4075 EAPI const Eina_List *
4076 elm_genlist_selected_items_get(const Evas_Object *obj)
4078 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4079 Widget_Data *wd = elm_widget_data_get(obj);
4080 if (!wd) return NULL;
4081 return wd->selected;
4085 elm_genlist_realized_items_get(const Evas_Object *obj)
4087 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4088 Widget_Data *wd = elm_widget_data_get(obj);
4089 Eina_List *list = NULL;
4091 Eina_Bool done = EINA_FALSE;
4092 if (!wd) return NULL;
4093 EINA_INLIST_FOREACH(wd->blocks, itb)
4098 Elm_Genlist_Item *it;
4101 EINA_LIST_FOREACH(itb->items, l, it)
4103 if (it->realized) list = eina_list_append(list, it);
4114 EAPI Elm_Genlist_Item *
4115 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4120 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4121 Widget_Data *wd = elm_widget_data_get(obj);
4122 Evas_Coord ox, oy, ow, oh;
4125 if (!wd) return NULL;
4126 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4128 EINA_INLIST_FOREACH(wd->blocks, itb)
4131 Elm_Genlist_Item *it;
4133 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4134 oy + itb->y - itb->wd->pan_y,
4135 itb->w, itb->h, x, y, 1, 1))
4137 EINA_LIST_FOREACH(itb->items, l, it)
4139 Evas_Coord itx, ity;
4141 itx = ox + itb->x + it->x - itb->wd->pan_x;
4142 ity = oy + itb->y + it->y - itb->wd->pan_y;
4143 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4147 if (y <= (ity + (it->h / 4))) *posret = -1;
4148 else if (y >= (ity + it->h - (it->h / 4)))
4154 lasty = ity + it->h;
4159 if (y > lasty) *posret = 1;
4165 EAPI Elm_Genlist_Item *
4166 elm_genlist_first_item_get(const Evas_Object *obj)
4168 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4169 Widget_Data *wd = elm_widget_data_get(obj);
4170 if (!wd) return NULL;
4171 if (!wd->items) return NULL;
4172 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4173 while ((it) && (it->delete_me))
4174 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4178 EAPI Elm_Genlist_Item *
4179 elm_genlist_last_item_get(const Evas_Object *obj)
4181 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4182 Widget_Data *wd = elm_widget_data_get(obj);
4183 if (!wd) return NULL;
4184 if (!wd->items) return NULL;
4185 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4186 while ((it) && (it->delete_me))
4187 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4191 EAPI Elm_Genlist_Item *
4192 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4194 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4197 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4198 if ((it) && (!it->delete_me)) break;
4200 return (Elm_Genlist_Item *)it;
4203 EAPI Elm_Genlist_Item *
4204 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4206 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4209 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4210 if ((it) && (!it->delete_me)) break;
4212 return (Elm_Genlist_Item *)it;
4216 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4218 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4219 return it->base.widget;
4222 EAPI Elm_Genlist_Item *
4223 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4225 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4230 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4232 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4233 Elm_Genlist_Item *it2;
4236 if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4237 _item_subitems_clear(it);
4240 if ((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4241 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4243 it->wd->expand_item = it;
4244 _item_flip_effect_show(it);
4245 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4246 it->wd->expand_item_end = y + h;
4250 it2 = elm_genlist_item_next_get(it2);
4252 } while (it2->expanded_depth > it->expanded_depth);
4254 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4256 it->wd->expand_item_gap = 0;
4258 evas_object_raise(it->wd->alpha_bg);
4259 evas_object_show(it->wd->alpha_bg);
4261 it->wd->start_time = current_time_get();
4262 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4265 _item_subitems_clear(it);
4270 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4273 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4274 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4276 if ((it->delete_me) || (it->disabled)) return;
4277 selected = !!selected;
4278 if (it->selected == selected) return;
4284 while (wd->selected)
4285 _item_unselect(wd->selected->data);
4287 _item_highlight(it);
4295 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4297 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4298 return it->selected;
4302 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4305 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4306 if (it->flags != ELM_GENLIST_ITEM_SUBITEMS) return;
4307 if (it->expanded == expanded) return;
4308 it->expanded = expanded;
4309 it->wd->expand_item = it;
4311 if (it->wd->effect_mode && !it->wd->alpha_bg)
4312 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4316 it->wd->auto_scrolled = EINA_FALSE;
4317 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4319 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4320 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4324 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4326 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4327 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4332 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4334 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4335 return it->expanded;
4339 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4341 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4342 return it->expanded_depth;
4346 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4349 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4352 if (it->disabled == disabled) return;
4353 if (it->delete_me) return;
4354 it->disabled = !!disabled;
4356 elm_genlist_item_selected_set(it, EINA_FALSE);
4361 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4363 edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
4367 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4369 edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
4371 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4372 elm_widget_disabled_set(obj, disabled);
4377 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4379 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4380 if (it->delete_me) return EINA_FALSE;
4381 return it->disabled;
4385 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4386 Eina_Bool display_only)
4388 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4389 if (it->display_only == display_only) return;
4390 if (it->delete_me) return;
4391 it->display_only = display_only;
4392 it->mincalcd = EINA_FALSE;
4393 it->updateme = EINA_TRUE;
4394 if (it->block) it->block->updateme = EINA_TRUE;
4395 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4396 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4400 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4402 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4403 if (it->delete_me) return EINA_FALSE;
4404 return it->display_only;
4408 elm_genlist_item_show(Elm_Genlist_Item *it)
4410 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4411 Evas_Coord gith = 0;
4412 if (it->delete_me) return;
4413 if ((it->queued) || (!it->mincalcd))
4415 it->wd->show_item = it;
4416 it->wd->bring_in = EINA_TRUE;
4417 it->showme = EINA_TRUE;
4420 if (it->wd->show_item)
4422 it->wd->show_item->showme = EINA_FALSE;
4423 it->wd->show_item = NULL;
4425 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4426 gith = it->group_item->h;
4427 elm_smart_scroller_child_region_show(it->wd->scr,
4428 it->x + it->block->x,
4429 it->y + it->block->y - gith,
4430 it->block->w, it->h);
4434 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4436 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4437 Evas_Coord gith = 0;
4438 if (it->delete_me) return;
4439 if ((it->queued) || (!it->mincalcd))
4441 it->wd->show_item = it;
4442 it->wd->bring_in = EINA_TRUE;
4443 it->showme = EINA_TRUE;
4446 if (it->wd->show_item)
4448 it->wd->show_item->showme = EINA_FALSE;
4449 it->wd->show_item = NULL;
4451 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4452 gith = it->group_item->h;
4453 elm_smart_scroller_region_bring_in(it->wd->scr,
4454 it->x + it->block->x,
4455 it->y + it->block->y - gith,
4456 it->block->w, it->h);
4460 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4462 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4464 Evas_Coord gith = 0;
4466 if (it->delete_me) return;
4467 if ((it->queued) || (!it->mincalcd))
4469 it->wd->show_item = it;
4470 it->wd->bring_in = EINA_TRUE;
4471 it->showme = EINA_TRUE;
4474 if (it->wd->show_item)
4476 it->wd->show_item->showme = EINA_FALSE;
4477 it->wd->show_item = NULL;
4479 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4480 if (it->group_item) gith = it->group_item->h;
4481 elm_smart_scroller_child_region_show(it->wd->scr,
4482 it->x + it->block->x,
4483 it->y + it->block->y - gith,
4488 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4490 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4492 Evas_Coord gith = 0;
4494 if (it->delete_me) return;
4495 if ((it->queued) || (!it->mincalcd))
4497 it->wd->show_item = it;
4498 it->wd->bring_in = EINA_TRUE;
4499 it->showme = EINA_TRUE;
4502 if (it->wd->show_item)
4504 it->wd->show_item->showme = EINA_FALSE;
4505 it->wd->show_item = NULL;
4507 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4508 if (it->group_item) gith = it->group_item->h;
4509 elm_smart_scroller_region_bring_in(it->wd->scr,
4510 it->x + it->block->x,
4511 it->y + it->block->y - gith,
4516 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4518 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4521 if (it->delete_me) return;
4522 if ((it->queued) || (!it->mincalcd))
4524 it->wd->show_item = it;
4525 it->wd->bring_in = EINA_TRUE;
4526 it->showme = EINA_TRUE;
4529 if (it->wd->show_item)
4531 it->wd->show_item->showme = EINA_FALSE;
4532 it->wd->show_item = NULL;
4534 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4535 elm_smart_scroller_child_region_show(it->wd->scr,
4536 it->x + it->block->x,
4537 it->y + it->block->y - oh / 2 +
4538 it->h / 2, it->block->w, oh);
4542 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4544 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4547 if (it->delete_me) return;
4548 if ((it->queued) || (!it->mincalcd))
4550 it->wd->show_item = it;
4551 it->wd->bring_in = EINA_TRUE;
4552 it->showme = EINA_TRUE;
4555 if (it->wd->show_item)
4557 it->wd->show_item->showme = EINA_FALSE;
4558 it->wd->show_item = NULL;
4560 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4561 elm_smart_scroller_region_bring_in(it->wd->scr,
4562 it->x + it->block->x,
4563 it->y + it->block->y - oh / 2 + it->h / 2,
4568 elm_genlist_item_del(Elm_Genlist_Item *it)
4570 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4571 if ((it->relcount > 0) || (it->walking > 0))
4573 elm_widget_item_pre_notify_del(it);
4574 elm_genlist_item_subitems_clear(it);
4575 it->delete_me = EINA_TRUE;
4576 if (it->wd->show_item == it) it->wd->show_item = NULL;
4578 it->wd->selected = eina_list_remove(it->wd->selected,
4582 if (it->realized) _item_unrealize(it, EINA_FALSE);
4583 it->block->changed = EINA_TRUE;
4584 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4585 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4587 if (it->itc->func.del)
4588 it->itc->func.del((void *)it->base.data, it->base.widget);
4595 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4598 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4599 elm_widget_item_data_set(it, data);
4600 elm_genlist_item_update(it);
4604 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4606 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4607 return elm_widget_item_data_get(it);
4611 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4614 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4615 EINA_LIST_FREE(it->icon_objs, icon)
4617 elm_widget_sub_object_del(it->base.widget, icon);
4618 evas_object_smart_member_del(icon);
4619 evas_object_hide(icon);
4623 EAPI const Evas_Object *
4624 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4626 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4627 return it->base.view;
4631 elm_genlist_item_update(Elm_Genlist_Item *it)
4633 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4634 if (!it->block) return;
4635 if (it->delete_me) return;
4636 it->mincalcd = EINA_FALSE;
4637 it->updateme = EINA_TRUE;
4638 it->block->updateme = EINA_TRUE;
4639 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4640 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4641 it->defer_unrealize = EINA_FALSE;
4645 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4646 const Elm_Genlist_Item_Class *itc)
4648 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4649 if (!it->block) return;
4650 EINA_SAFETY_ON_NULL_RETURN(itc);
4651 if (it->delete_me) return;
4653 it->nocache = EINA_TRUE;
4654 elm_genlist_item_update(it);
4657 EAPI const Elm_Genlist_Item_Class *
4658 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4660 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4661 if (it->delete_me) return NULL;
4664 static Evas_Object *
4665 _elm_genlist_item_label_create(void *data,
4667 void *item __UNUSED__)
4669 Evas_Object *label = elm_label_add(obj);
4672 elm_object_style_set(label, "tooltip");
4673 elm_object_text_set(label, data);
4678 _elm_genlist_item_label_del_cb(void *data,
4679 Evas_Object *obj __UNUSED__,
4680 void *event_info __UNUSED__)
4682 eina_stringshare_del(data);
4686 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4689 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4690 text = eina_stringshare_add(text);
4691 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4693 _elm_genlist_item_label_del_cb);
4697 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4698 Elm_Tooltip_Item_Content_Cb func,
4700 Evas_Smart_Cb del_cb)
4702 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4704 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4707 if (item->tooltip.del_cb)
4708 item->tooltip.del_cb((void *)item->tooltip.data,
4709 item->base.widget, item);
4711 item->tooltip.content_cb = func;
4712 item->tooltip.data = data;
4713 item->tooltip.del_cb = del_cb;
4715 if (item->base.view)
4717 elm_widget_item_tooltip_content_cb_set(item,
4718 item->tooltip.content_cb,
4719 item->tooltip.data, NULL);
4720 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4726 if (del_cb) del_cb((void *)data, NULL, NULL);
4730 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4732 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4733 if ((item->base.view) && (item->tooltip.content_cb))
4734 elm_widget_item_tooltip_unset(item);
4736 if (item->tooltip.del_cb)
4737 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4738 item->tooltip.del_cb = NULL;
4739 item->tooltip.content_cb = NULL;
4740 item->tooltip.data = NULL;
4741 if (item->tooltip.style)
4742 elm_genlist_item_tooltip_style_set(item, NULL);
4746 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4749 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4750 eina_stringshare_replace(&item->tooltip.style, style);
4751 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4755 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4757 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4758 return item->tooltip.style;
4762 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4765 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4766 eina_stringshare_replace(&item->mouse_cursor, cursor);
4767 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4771 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4773 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4774 return elm_widget_item_cursor_get(item);
4778 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4780 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4781 if (!item->mouse_cursor)
4784 if (item->base.view)
4785 elm_widget_item_cursor_unset(item);
4787 eina_stringshare_del(item->mouse_cursor);
4788 item->mouse_cursor = NULL;
4792 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4795 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4796 elm_widget_item_cursor_style_set(item, style);
4800 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4802 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4803 return elm_widget_item_cursor_style_get(item);
4807 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4808 Eina_Bool engine_only)
4810 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4811 elm_widget_item_cursor_engine_only_set(item, engine_only);
4815 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4817 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4818 return elm_widget_item_cursor_engine_only_get(item);
4822 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4825 ELM_CHECK_WIDTYPE(obj, widtype);
4826 Widget_Data *wd = elm_widget_data_get(obj);
4828 if (wd->mode == mode) return;
4834 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4836 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4837 Widget_Data *wd = elm_widget_data_get(obj);
4838 if (!wd) return ELM_LIST_LAST;
4843 elm_genlist_always_select_mode_set(Evas_Object *obj,
4844 Eina_Bool always_select)
4846 ELM_CHECK_WIDTYPE(obj, widtype);
4847 Widget_Data *wd = elm_widget_data_get(obj);
4849 wd->always_select = always_select;
4853 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4855 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4856 Widget_Data *wd = elm_widget_data_get(obj);
4857 if (!wd) return EINA_FALSE;
4858 return wd->always_select;
4862 elm_genlist_no_select_mode_set(Evas_Object *obj,
4863 Eina_Bool no_select)
4865 ELM_CHECK_WIDTYPE(obj, widtype);
4866 Widget_Data *wd = elm_widget_data_get(obj);
4868 wd->no_select = no_select;
4872 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4874 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4875 Widget_Data *wd = elm_widget_data_get(obj);
4876 if (!wd) return EINA_FALSE;
4877 return wd->no_select;
4881 elm_genlist_compress_mode_set(Evas_Object *obj,
4884 ELM_CHECK_WIDTYPE(obj, widtype);
4885 Widget_Data *wd = elm_widget_data_get(obj);
4887 wd->compress = compress;
4891 elm_genlist_compress_mode_get(const Evas_Object *obj)
4893 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4894 Widget_Data *wd = elm_widget_data_get(obj);
4895 if (!wd) return EINA_FALSE;
4896 return wd->compress;
4900 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4901 Eina_Bool height_for_width)
4903 ELM_CHECK_WIDTYPE(obj, widtype);
4904 Widget_Data *wd = elm_widget_data_get(obj);
4906 wd->height_for_width = !!height_for_width;
4907 if (wd->height_for_width)
4909 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4910 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4915 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4917 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4918 Widget_Data *wd = elm_widget_data_get(obj);
4919 if (!wd) return EINA_FALSE;
4920 return wd->height_for_width;
4924 elm_genlist_bounce_set(Evas_Object *obj,
4928 ELM_CHECK_WIDTYPE(obj, widtype);
4929 Widget_Data *wd = elm_widget_data_get(obj);
4931 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4935 elm_genlist_bounce_get(const Evas_Object *obj,
4936 Eina_Bool *h_bounce,
4937 Eina_Bool *v_bounce)
4939 ELM_CHECK_WIDTYPE(obj, widtype);
4940 Widget_Data *wd = elm_widget_data_get(obj);
4942 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
4946 elm_genlist_homogeneous_set(Evas_Object *obj,
4947 Eina_Bool homogeneous)
4949 ELM_CHECK_WIDTYPE(obj, widtype);
4950 Widget_Data *wd = elm_widget_data_get(obj);
4952 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4953 wd->homogeneous = homogeneous;
4957 elm_genlist_homogeneous_get(const Evas_Object *obj)
4959 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4960 Widget_Data *wd = elm_widget_data_get(obj);
4961 if (!wd) return EINA_FALSE;
4962 return wd->homogeneous;
4966 elm_genlist_block_count_set(Evas_Object *obj,
4969 ELM_CHECK_WIDTYPE(obj, widtype);
4970 Widget_Data *wd = elm_widget_data_get(obj);
4972 wd->max_items_per_block = n;
4973 wd->item_cache_max = wd->max_items_per_block * 2;
4974 _item_cache_clean(wd);
4978 elm_genlist_block_count_get(const Evas_Object *obj)
4980 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4981 Widget_Data *wd = elm_widget_data_get(obj);
4983 return wd->max_items_per_block;
4987 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4990 ELM_CHECK_WIDTYPE(obj, widtype);
4991 Widget_Data *wd = elm_widget_data_get(obj);
4993 wd->longpress_timeout = timeout;
4997 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4999 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5000 Widget_Data *wd = elm_widget_data_get(obj);
5002 return wd->longpress_timeout;
5006 elm_genlist_scroller_policy_set(Evas_Object *obj,
5007 Elm_Scroller_Policy policy_h,
5008 Elm_Scroller_Policy policy_v)
5010 ELM_CHECK_WIDTYPE(obj, widtype);
5011 Widget_Data *wd = elm_widget_data_get(obj);
5012 if ((!wd) || (!wd->scr)) return;
5013 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5014 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5016 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5020 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5021 Elm_Scroller_Policy *policy_h,
5022 Elm_Scroller_Policy *policy_v)
5024 ELM_CHECK_WIDTYPE(obj, widtype);
5025 Widget_Data *wd = elm_widget_data_get(obj);
5026 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5027 if ((!wd) || (!wd->scr)) return;
5028 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5029 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5030 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5034 elm_genlist_realized_items_update(Evas_Object *obj)
5036 ELM_CHECK_WIDTYPE(obj, widtype);
5038 Eina_List *list, *l;
5039 Elm_Genlist_Item *it;
5041 list = elm_genlist_realized_items_get(obj);
5042 EINA_LIST_FOREACH(list, l, it)
5043 elm_genlist_item_update(it);
5047 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5048 const char *mode_type,
5051 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5052 Widget_Data *wd = it->wd;
5054 Elm_Genlist_Item *it2;
5057 if (!mode_type) return;
5058 if ((it->delete_me) || (it->disabled)) return;
5059 if (wd->edit_mode) return;
5061 if ((wd->mode_item == it) &&
5062 (!strcmp(mode_type, wd->mode_type)) &&
5065 if (!it->itc->mode_item_style) return;
5069 EINA_LIST_FOREACH(wd->selected, l, it2)
5071 elm_genlist_item_selected_set(it2, EINA_FALSE);
5075 it2 = elm_genlist_selected_item_get(wd->obj);
5076 if ((it2) && (it2->realized))
5077 elm_genlist_item_selected_set(it2, EINA_FALSE);
5080 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5082 ((it == wd->mode_item) && (!mode_set)))
5083 _item_mode_unset(wd);
5085 eina_stringshare_replace(&wd->mode_type, mode_type);
5086 if (mode_set) _item_mode_set(it);
5090 elm_genlist_mode_get(const Evas_Object *obj)
5092 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5093 Widget_Data *wd = elm_widget_data_get(obj);
5094 if (!wd) return NULL;
5095 return wd->mode_type;
5098 EAPI const Elm_Genlist_Item *
5099 elm_genlist_mode_item_get(const Evas_Object *obj)
5101 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5102 Widget_Data *wd = elm_widget_data_get(obj);
5103 if (!wd) return NULL;
5104 return wd->mode_item;
5108 elm_genlist_reorder_mode_set(Evas_Object *obj,
5109 Eina_Bool reorder_mode)
5111 ELM_CHECK_WIDTYPE(obj, widtype);
5112 Widget_Data *wd = elm_widget_data_get(obj);
5114 wd->reorder_mode = reorder_mode;
5118 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5120 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5121 Widget_Data *wd = elm_widget_data_get(obj);
5122 if (!wd) return EINA_FALSE;
5123 return wd->reorder_mode;
5127 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
5133 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
5139 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5141 ELM_CHECK_WIDTYPE(obj, widtype);
5142 Widget_Data *wd = elm_widget_data_get(obj);
5144 wd->effect_mode = emode;
5145 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5146 // evas_object_resize(wd->point_rect, 10, 25);
5147 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5148 // evas_object_show(wd->point_rect);
5149 // evas_object_hide(wd->point_rect);
5153 _create_tray_alpha_bg(const Evas_Object *obj)
5155 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5156 Widget_Data *wd = elm_widget_data_get(obj);
5157 if (!wd) return NULL;
5159 Evas_Object *bg = NULL;
5160 Evas_Coord ox, oy, ow, oh;
5162 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5163 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5164 evas_object_color_set(bg,0,0,0,0);
5165 evas_object_resize(bg , ow, oh);
5166 evas_object_move(bg , ox, oy);
5167 evas_object_show(bg);
5168 evas_object_hide(bg);
5175 struct timeval timev;
5177 gettimeofday(&timev, NULL);
5178 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5181 // added for item moving animation.
5183 _item_moving_effect_timer_cb(void *data)
5185 Widget_Data *wd = data;
5186 if (!wd) return EINA_FALSE;
5188 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5189 Elm_Genlist_Item *it = NULL, *it2;
5191 double time = 0.3, t;
5193 Eina_Bool check, end = EINA_FALSE;
5196 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5198 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5199 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5200 if (t > time) end = EINA_TRUE;
5202 it2 = elm_genlist_item_next_get(wd->expand_item);
5205 if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5206 it2 = elm_genlist_item_next_get(it2);
5211 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5212 dy = it2->scrl_y - it2->old_scrl_y;
5213 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5214 dy = wd->expand_item_gap;
5218 y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5227 EINA_INLIST_FOREACH(wd->blocks, itb)
5230 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5231 itb->y - wd->pan_y + oy,
5233 cvx, cvy, cvw, cvh))
5235 EINA_LIST_FOREACH(itb->items, l, it)
5237 if (it == it2) check = EINA_TRUE;
5238 if (!check) continue;
5240 if (!it->old_scrl_y)
5241 it->old_scrl_y = it->scrl_y;
5242 if (it->old_scrl_y + y < oy + oh)
5244 if (!it->realized) _item_realize(it, in, 0);
5246 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5247 it->old_scrl_y = it->scrl_y - y;
5250 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5251 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5253 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5256 evas_object_resize(it->base.view, it->w, it->h);
5257 evas_object_move(it->base.view, it->scrl_x, it->old_scrl_y + y);
5258 evas_object_show(it->base.view);
5259 evas_object_raise(it->base.view);
5262 if (it->group_item) evas_object_raise(it->group_item->base.view);
5268 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5270 it = elm_genlist_item_prev_get(it2);
5273 if (it->expanded_depth <= it2->expanded_depth) break;
5274 if ((it->scrl_y < it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5276 if (!it->effect_done)
5278 edje_object_signal_emit(it->base.view, "flip_item", "");
5279 evas_object_show(it->base.view);
5280 it->effect_done = EINA_TRUE;
5283 it = elm_genlist_item_prev_get(it);
5286 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5288 it = elm_genlist_item_prev_get(it2);
5291 if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5293 if (!it->effect_done)
5295 edje_object_signal_emit(it->base.view, "elm,state,hide", "");
5296 it->effect_done = EINA_TRUE;
5301 it = elm_genlist_item_prev_get(it);
5304 if (wd->calc_job) ecore_job_del(wd->calc_job);
5305 wd->calc_job = ecore_job_add(_calc_job, wd);
5310 int expand_order = 0;
5311 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5315 it = elm_genlist_item_next_get(it);
5317 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5321 if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
5322 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5324 if (!it->effect_done)
5326 if (t >= (((expand_order - 1) * time) / expand_num))
5328 edje_object_signal_emit(it->base.view, "flip_item", "");
5329 evas_object_show(it->base.view);
5330 it->effect_done = EINA_TRUE;
5334 it = elm_genlist_item_next_get(it);
5340 if (wd->item_moving_effect_timer)
5342 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5343 _item_subitems_clear(wd->expand_item);
5344 EINA_INLIST_FOREACH(wd->blocks, itb)
5346 EINA_LIST_FOREACH(itb->items, l, it)
5348 it->effect_done = EINA_TRUE;
5349 it->old_scrl_y = it->scrl_y;
5353 wd->item_moving_effect_timer = NULL;
5355 _item_auto_scroll(wd);
5356 evas_object_lower(wd->alpha_bg);
5357 evas_object_hide(wd->alpha_bg);
5358 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5359 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5361 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5362 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5363 return ECORE_CALLBACK_CANCEL;
5365 return ECORE_CALLBACK_RENEW;
5369 _emit_contract(Elm_Genlist_Item *it)
5371 Elm_Genlist_Item *it2;
5374 // printf("%p is emited contract\n", it);
5375 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5376 it->effect_done = EINA_FALSE;
5378 EINA_LIST_FOREACH(it->items, l, it2)
5380 _emit_contract(it2);
5383 // added for item moving animation.
5385 _item_flip_effect_show(Elm_Genlist_Item *it)
5387 Elm_Genlist_Item *it2;
5389 Widget_Data *wd = it->wd;
5390 Eina_Bool check = EINA_FALSE;
5392 it2 = elm_genlist_item_next_get(it);
5395 if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5396 it2 = elm_genlist_item_next_get(it2);
5398 EINA_LIST_FOREACH(it->items, l, it2)
5400 if (it2->parent && it == it2->parent)
5402 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5403 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5404 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5405 _emit_contract(it2);
5409 return ECORE_CALLBACK_CANCEL;
5414 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5416 printf("!!! NOW FIXING \n");
5421 * Set pinch zoom mode
5423 * @param obj The genlist object
5425 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5430 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5432 printf("!!! NOW FIXING \n");
5436 * Get pinch zoom mode
5438 * @param obj The genlist object
5439 * @return The pinch mode
5440 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5445 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
5447 printf("!!! NOW FIXING \n");
5452 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5454 printf("!!! NOW FIXING \n");
5458 ////////////////////////////////////////////////////////////////////////
5460 ////////////////////////////////////////////////////////////////////////
5463 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5465 if (!it->wd->edit_mode) return;
5466 evas_object_resize(it->edit_obj,it->w, it->h);
5467 evas_object_move(it->edit_obj, itx, ity);
5471 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5473 if ((it->effect_item_realized) || (it->delete_me)) return;
5477 _mode_finished_signal_cb(it, (Evas_Object *)elm_genlist_item_object_get(it), NULL, NULL);
5479 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
5480 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
5481 _elm_config->scale);
5482 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5483 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
5485 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5486 else strncpy(buf, "item", sizeof(buf));
5487 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5489 strncat(buf, "/", sizeof(buf) - strlen(buf));
5491 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5493 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
5494 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
5498 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget));
5501 if (it->wd->reorder_mode)
5503 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
5504 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
5506 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
5507 else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
5509 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
5510 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
5513 if ((it->wd->edit_mode))
5515 if (it->itc->func.icon_get)
5520 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5521 EINA_LIST_FOREACH(it->icons, l, key)
5523 Evas_Object *ic = it->itc->func.icon_get
5524 ((void *)it->base.data, it->base.widget, l->data);
5528 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5529 edje_object_part_swallow(it->edit_obj, key, ic);
5530 evas_object_show(ic);
5531 elm_widget_sub_object_add(it->base.widget, ic);
5533 elm_widget_disabled_set(ic, EINA_TRUE);
5538 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
5539 _effect_item_controls(it,it->scrl_x, it->scrl_y);
5540 evas_object_show(it->edit_obj);
5542 it->effect_item_realized = EINA_TRUE;
5543 it->want_unrealize = EINA_FALSE;
5547 _effect_item_unrealize(Elm_Genlist_Item *it)
5551 if (!it->effect_item_realized) return;
5552 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5554 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
5555 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
5556 edje_object_message_signal_process(it->edit_obj);
5557 edje_object_part_unswallow(it->edit_obj, it->base.view);
5558 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
5559 elm_widget_sub_object_add(it->base.widget, it->base.view);
5560 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5561 // _item_cache_add(it);
5562 evas_object_del(it->edit_obj);
5563 it->edit_obj = NULL;
5564 EINA_LIST_FREE(it->edit_icon_objs, icon)
5565 evas_object_del(icon);
5567 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5568 it->effect_item_realized = EINA_FALSE;
5572 * Get Genlist edit mode
5574 * @param obj The genlist object
5575 * @return The edit mode status
5576 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5581 elm_genlist_edit_mode_get(const Evas_Object *obj)
5583 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5584 Widget_Data *wd = elm_widget_data_get(obj);
5585 if (!wd) return EINA_FALSE;
5587 if (wd->edit_mode) return EINA_TRUE;
5588 else return EINA_FALSE;
5592 * Set Genlist edit mode
5594 * This sets Genlist edit mode.
5596 * @param obj The Genlist object
5597 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5598 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5603 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5605 ELM_CHECK_WIDTYPE(obj, widtype);
5609 Elm_Genlist_Item *it;
5611 Widget_Data *wd = elm_widget_data_get(obj);
5613 if (wd->edit_mode == edit_mode) return;
5615 wd->edit_mode = edit_mode;
5618 EINA_INLIST_FOREACH(wd->blocks, itb)
5622 EINA_LIST_FOREACH(itb->items, l, it)
5624 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5626 _effect_item_unrealize(it);
5631 _item_cache_zero(wd);
5636 EINA_INLIST_FOREACH(wd->blocks, itb)
5640 EINA_LIST_FOREACH(itb->items, l, it)
5642 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5644 if(it->selected) _item_unselect(it);
5645 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
5652 if (wd->calc_job) ecore_job_del(wd->calc_job);
5653 wd->calc_job = ecore_job_add(_calc_job, wd);
5657 * Set a given item's rename mode
5659 * This renames the item's label from genlist
5661 * @param it The item
5662 * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
5667 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
5673 _item_unrealize(it, EINA_FALSE);
5674 it->renamed = EINA_TRUE;
5675 it->nocache = EINA_TRUE;
5676 if (it->selected) _item_unselect(it);
5678 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5679 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5685 it->renamed = EINA_FALSE;
5686 it->nocache = EINA_TRUE;
5687 _item_cache_zero(it->wd);
5688 elm_genlist_item_update(it);
5694 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
5696 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5697 return item->renamed;