2 #include <Elementary.h>
3 #include <Elementary_Cursor.h>
7 #define MAX_ITEMS_PER_BLOCK 32
8 #define REORDER_EFFECT_TIME 0.5
10 typedef struct _Widget_Data Widget_Data;
11 typedef struct _Item_Block Item_Block;
12 typedef struct _Pan Pan;
13 typedef struct _Item_Cache Item_Cache;
14 typedef enum _Elm_Genlist_Item_Move_effect_Mode
16 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
17 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
18 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
19 ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE = (1 << 2),
20 } Elm_Genlist_Item_Move_effect_Mode;
24 Evas_Object *obj, *scr, *pan_smart;
25 Eina_Inlist *items, *blocks;
26 Eina_List *group_items;
28 Evas_Coord pan_x, pan_y, old_pan_y, w, h, minw, minh, realminw, prev_viewport_w;
29 Ecore_Job *calc_job, *update_job;
30 Ecore_Idle_Enterer *queue_idle_enterer;
31 Ecore_Idler *must_recalc_idler;
32 Eina_List *queue, *selected;
33 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item, *reorder_it, *reorder_rel, *expand_item;
34 Eina_Inlist *item_cache;
35 Evas_Coord anchor_y, reorder_start_y;
37 Ecore_Timer *multi_timer, *scr_hold_timer;
38 Ecore_Animator *reorder_move_animator;
39 const char *mode_type;
40 unsigned int start_time;
41 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
42 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
43 Eina_Bool mouse_down : 1;
44 Eina_Bool multi_down : 1;
45 Eina_Bool multi_timeout : 1;
46 Eina_Bool multitouched : 1;
47 Eina_Bool on_hold : 1;
49 Eina_Bool always_select : 1;
50 Eina_Bool longpressed : 1;
51 Eina_Bool wasselected : 1;
52 Eina_Bool no_select : 1;
53 Eina_Bool bring_in : 1;
54 Eina_Bool compress : 1;
55 Eina_Bool height_for_width : 1;
56 Eina_Bool pan_resize : 1;
57 Eina_Bool homogeneous : 1;
58 Eina_Bool clear_me : 1;
60 Eina_Bool reorder_mode : 1;
61 Eina_Bool reorder_pan_move : 1;
62 Eina_List *dragging_queue;
66 } history[SWIPE_MOVES];
75 int group_item_height;
76 int max_items_per_block;
77 double longpress_timeout;
80 Eina_Bool reorder_deleted : 1;
81 Eina_Bool effect_mode : 1;
82 Eina_Bool auto_scrolled : 1;
84 Ecore_Animator *item_moving_effect_timer;
85 Evas_Object *alpha_bg;
86 Evas_Coord expand_item_end;
87 Evas_Coord expand_item_gap;
89 Ecore_Job *changed_job;
90 Elm_Genlist_Item *rename_it;
101 Evas_Coord x, y, w, h, minw, minh;
102 Eina_Bool want_unrealize : 1;
103 Eina_Bool realized : 1;
104 Eina_Bool changed : 1;
105 Eina_Bool updateme : 1;
106 Eina_Bool changeme : 1;
107 Eina_Bool showme : 1;
108 Eina_Bool must_recalc : 1;
111 struct _Elm_Genlist_Item
113 Elm_Widget_Item base;
118 Evas_Coord x, y, w, h, minw, minh;
119 const Elm_Genlist_Item_Class *itc;
120 Elm_Genlist_Item *parent;
121 Elm_Genlist_Item *group_item;
122 Elm_Genlist_Item_Flags flags;
130 Eina_List *labels, *icons, *states, *icon_objs;
131 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
132 Ecore_Timer *long_timer;
133 Ecore_Timer *swipe_timer;
135 Evas_Coord scrl_x, scrl_y;
137 Elm_Genlist_Item *rel;
138 Evas_Object *mode_view;
143 Elm_Tooltip_Item_Content_Cb content_cb;
144 Evas_Smart_Cb del_cb;
148 const char *mouse_cursor;
155 Eina_Bool before : 1;
157 Eina_Bool want_unrealize : 1;
158 Eina_Bool want_realize : 1;
159 Eina_Bool realized : 1;
160 Eina_Bool selected : 1;
161 Eina_Bool highlighted : 1;
162 Eina_Bool expanded : 1;
163 Eina_Bool disabled : 1;
164 Eina_Bool display_only : 1;
165 Eina_Bool mincalcd : 1;
166 Eina_Bool queued : 1;
167 Eina_Bool showme : 1;
168 Eina_Bool delete_me : 1;
170 Eina_Bool dragging : 1;
171 Eina_Bool updateme : 1;
172 Eina_Bool nocache : 1;
173 Eina_Bool move_effect_enabled : 1;
174 Eina_Bool defer_unrealize : 1;
177 Eina_Bool effect_done : 1;
178 Eina_Bool reordering : 1;
179 Eina_Bool renamed : 1;
180 Eina_Bool effect_item_realized : 1;
181 Eina_List *edit_icon_objs;
182 Evas_Object *edit_obj;
184 Ecore_Animator *item_moving_effect_timer;
185 Evas_Coord old_scrl_y;
192 Evas_Object *base_view, *spacer;
194 const char *item_style; // it->itc->item_style
195 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
196 Eina_Bool compress : 1; // it->wd->compress
197 Eina_Bool odd : 1; // in & 0x1
199 Eina_Bool selected : 1; // it->selected
200 Eina_Bool disabled : 1; // it->disabled
201 Eina_Bool expanded : 1; // it->expanded
204 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
205 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
209 Evas_Object_Smart_Clipped_Data __clipped_data;
211 Ecore_Job *resize_job;
214 static const char *widtype = NULL;
215 static void _item_cache_zero(Widget_Data *wd);
216 static void _del_hook(Evas_Object *obj);
217 static void _mirrored_set(Evas_Object *obj,
219 static void _theme_hook(Evas_Object *obj);
220 static void _show_region_hook(void *data,
222 static void _sizing_eval(Evas_Object *obj);
223 static void _item_realize(Elm_Genlist_Item *it,
226 static void _item_unrealize(Elm_Genlist_Item *it,
228 static void _item_block_unrealize(Item_Block *itb);
229 static void _calc_job(void *data);
230 static void _on_focus_hook(void *data,
232 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
233 static void _changed_job(void *data);
234 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
235 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
236 static Eina_Bool _item_single_select_up(Widget_Data *wd);
237 static Eina_Bool _item_single_select_down(Widget_Data *wd);
238 static Eina_Bool _event_hook(Evas_Object *obj,
240 Evas_Callback_Type type,
242 static void _signal_emit_hook(Evas_Object *obj,
243 const char *emission,
245 static Eina_Bool _deselect_all_items(Widget_Data *wd);
246 static void _pan_calculate(Evas_Object *obj);
247 static void _item_position(Elm_Genlist_Item *it,
251 static void _mode_item_realize(Elm_Genlist_Item *it);
252 static void _mode_item_unrealize(Elm_Genlist_Item *it);
253 static void _item_mode_set(Elm_Genlist_Item *it);
254 static void _item_mode_unset(Widget_Data *wd);
255 static void _group_items_recalc(void *data);
256 static void _item_move_after(Elm_Genlist_Item *it,
257 Elm_Genlist_Item *after);
258 static void _item_move_before(Elm_Genlist_Item *it,
259 Elm_Genlist_Item *before);
261 // TODO : refactoring
262 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
263 static unsigned int current_time_get();
264 static Eina_Bool _item_moving_effect_timer_cb(void *data);
265 static int _item_flip_effect_show(Elm_Genlist_Item *it);
266 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
267 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
268 static void _effect_item_unrealize(Elm_Genlist_Item *it);
269 static void _item_auto_scroll(void *data);
271 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
273 static const char SIG_ACTIVATED[] = "activated";
274 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
275 static const char SIG_SELECTED[] = "selected";
276 static const char SIG_UNSELECTED[] = "unselected";
277 static const char SIG_EXPANDED[] = "expanded";
278 static const char SIG_CONTRACTED[] = "contracted";
279 static const char SIG_EXPAND_REQUEST[] = "expand,request";
280 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
281 static const char SIG_REALIZED[] = "realized";
282 static const char SIG_UNREALIZED[] = "unrealized";
283 static const char SIG_DRAG_START_UP[] = "drag,start,up";
284 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
285 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
286 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
287 static const char SIG_DRAG_STOP[] = "drag,stop";
288 static const char SIG_DRAG[] = "drag";
289 static const char SIG_LONGPRESSED[] = "longpressed";
290 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
291 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
292 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
293 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
294 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
295 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
296 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
297 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
298 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
299 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
300 static const char SIG_SWIPE[] = "swipe";
302 static const Evas_Smart_Cb_Description _signals[] = {
303 {SIG_CLICKED_DOUBLE, ""},
306 {SIG_UNSELECTED, ""},
308 {SIG_CONTRACTED, ""},
309 {SIG_EXPAND_REQUEST, ""},
310 {SIG_CONTRACT_REQUEST, ""},
312 {SIG_UNREALIZED, ""},
313 {SIG_DRAG_START_UP, ""},
314 {SIG_DRAG_START_DOWN, ""},
315 {SIG_DRAG_START_LEFT, ""},
316 {SIG_DRAG_START_RIGHT, ""},
319 {SIG_LONGPRESSED, ""},
320 {SIG_SCROLL_EDGE_TOP, ""},
321 {SIG_SCROLL_EDGE_BOTTOM, ""},
322 {SIG_SCROLL_EDGE_LEFT, ""},
323 {SIG_SCROLL_EDGE_RIGHT, ""},
324 {SIG_MULTI_SWIPE_LEFT, ""},
325 {SIG_MULTI_SWIPE_RIGHT, ""},
326 {SIG_MULTI_SWIPE_UP, ""},
327 {SIG_MULTI_SWIPE_DOWN, ""},
328 {SIG_MULTI_PINCH_OUT, ""},
329 {SIG_MULTI_PINCH_IN, ""},
335 _event_hook(Evas_Object *obj,
336 Evas_Object *src __UNUSED__,
337 Evas_Callback_Type type,
340 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
341 Evas_Event_Key_Down *ev = event_info;
342 Widget_Data *wd = elm_widget_data_get(obj);
343 if (!wd) return EINA_FALSE;
344 if (!wd->items) return EINA_FALSE;
345 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
346 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
348 Elm_Genlist_Item *it = NULL;
351 Evas_Coord step_x = 0;
352 Evas_Coord step_y = 0;
355 Evas_Coord page_x = 0;
356 Evas_Coord page_y = 0;
358 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
359 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
360 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
361 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
363 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
367 else if ((!strcmp(ev->keyname, "Right")) ||
368 (!strcmp(ev->keyname, "KP_Right")))
372 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
374 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
375 (_item_multi_select_up(wd)))
376 || (_item_single_select_up(wd)))
378 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
384 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
386 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
387 (_item_multi_select_down(wd)))
388 || (_item_single_select_down(wd)))
390 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
396 else if ((!strcmp(ev->keyname, "Home")) ||
397 (!strcmp(ev->keyname, "KP_Home")))
399 it = elm_genlist_first_item_get(obj);
400 elm_genlist_item_bring_in(it);
401 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
404 else if ((!strcmp(ev->keyname, "End")) ||
405 (!strcmp(ev->keyname, "KP_End")))
407 it = elm_genlist_last_item_get(obj);
408 elm_genlist_item_bring_in(it);
409 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
412 else if ((!strcmp(ev->keyname, "Prior")) ||
413 (!strcmp(ev->keyname, "KP_Prior")))
416 y -= -(page_y * v_h) / 100;
420 else if ((!strcmp(ev->keyname, "Next")) ||
421 (!strcmp(ev->keyname, "KP_Next")))
424 y += -(page_y * v_h) / 100;
428 else if (((!strcmp(ev->keyname, "Return")) ||
429 (!strcmp(ev->keyname, "KP_Enter")) ||
430 (!strcmp(ev->keyname, "space")))
431 && (!wd->multi) && (wd->selected))
433 it = elm_genlist_selected_item_get(obj);
434 elm_genlist_item_expanded_set(it,
435 !elm_genlist_item_expanded_get(it));
436 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
438 else if (!strcmp(ev->keyname, "Escape"))
440 if (!_deselect_all_items(wd)) return EINA_FALSE;
441 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
444 else return EINA_FALSE;
446 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
447 elm_smart_scroller_child_pos_set(wd->scr, x, y);
452 _deselect_all_items(Widget_Data *wd)
454 if (!wd->selected) return EINA_FALSE;
456 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
462 _item_multi_select_up(Widget_Data *wd)
464 if (!wd->selected) return EINA_FALSE;
465 if (!wd->multi) return EINA_FALSE;
467 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
468 if (!prev) return EINA_TRUE;
470 if (elm_genlist_item_selected_get(prev))
472 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
473 wd->last_selected_item = prev;
474 elm_genlist_item_show(wd->last_selected_item);
478 elm_genlist_item_selected_set(prev, EINA_TRUE);
479 elm_genlist_item_show(prev);
485 _item_multi_select_down(Widget_Data *wd)
487 if (!wd->selected) return EINA_FALSE;
488 if (!wd->multi) return EINA_FALSE;
490 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
491 if (!next) return EINA_TRUE;
493 if (elm_genlist_item_selected_get(next))
495 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
496 wd->last_selected_item = next;
497 elm_genlist_item_show(wd->last_selected_item);
501 elm_genlist_item_selected_set(next, EINA_TRUE);
502 elm_genlist_item_show(next);
508 _item_single_select_up(Widget_Data *wd)
510 Elm_Genlist_Item *prev;
513 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
514 while ((prev) && (prev->delete_me))
515 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
517 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
519 if (!prev) return EINA_FALSE;
521 _deselect_all_items(wd);
523 elm_genlist_item_selected_set(prev, EINA_TRUE);
524 elm_genlist_item_show(prev);
529 _item_single_select_down(Widget_Data *wd)
531 Elm_Genlist_Item *next;
534 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
535 while ((next) && (next->delete_me))
536 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
538 else next = elm_genlist_item_next_get(wd->last_selected_item);
540 if (!next) return EINA_FALSE;
542 _deselect_all_items(wd);
544 elm_genlist_item_selected_set(next, EINA_TRUE);
545 elm_genlist_item_show(next);
550 _on_focus_hook(void *data __UNUSED__,
553 Widget_Data *wd = elm_widget_data_get(obj);
555 if (elm_widget_focus_get(obj))
557 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
558 evas_object_focus_set(wd->obj, EINA_TRUE);
559 if ((wd->selected) && (!wd->last_selected_item))
560 wd->last_selected_item = eina_list_data_get(wd->selected);
564 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
565 evas_object_focus_set(wd->obj, EINA_FALSE);
570 _del_hook(Evas_Object *obj)
572 Widget_Data *wd = elm_widget_data_get(obj);
574 _item_cache_zero(wd);
575 if (wd->calc_job) ecore_job_del(wd->calc_job);
576 if (wd->update_job) ecore_job_del(wd->update_job);
577 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
578 if (wd->changed_job) ecore_job_del(wd->changed_job);
579 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
580 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
581 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
582 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
586 elm_genlist_clear(obj);
592 _del_pre_hook(Evas_Object *obj)
594 Widget_Data *wd = elm_widget_data_get(obj);
596 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
597 elm_genlist_clear(obj);
598 evas_object_del(wd->pan_smart);
599 wd->pan_smart = NULL;
603 _mirrored_set(Evas_Object *obj,
606 Widget_Data *wd = elm_widget_data_get(obj);
608 _item_cache_zero(wd);
609 elm_smart_scroller_mirrored_set(wd->scr, rtl);
613 _theme_hook(Evas_Object *obj)
615 Widget_Data *wd = elm_widget_data_get(obj);
618 evas_event_freeze(evas_object_evas_get(wd->obj));
619 _item_cache_zero(wd);
620 _elm_widget_mirrored_reload(obj);
621 _mirrored_set(obj, elm_widget_mirrored_get(obj));
622 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
623 elm_widget_style_get(obj));
624 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
625 wd->item_width = wd->item_height = 0;
626 wd->group_item_width = wd->group_item_height = 0;
627 wd->minw = wd->minh = wd->realminw = 0;
628 EINA_INLIST_FOREACH(wd->blocks, itb)
631 Elm_Genlist_Item *it;
633 if (itb->realized) _item_block_unrealize(itb);
634 EINA_LIST_FOREACH(itb->items, l, it)
635 it->mincalcd = EINA_FALSE;
637 itb->changed = EINA_TRUE;
639 if (wd->calc_job) ecore_job_del(wd->calc_job);
640 wd->calc_job = ecore_job_add(_calc_job, wd);
642 evas_event_thaw(evas_object_evas_get(wd->obj));
643 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
647 _show_region_hook(void *data,
650 Widget_Data *wd = elm_widget_data_get(data);
651 Evas_Coord x, y, w, h;
653 elm_widget_show_region_get(obj, &x, &y, &w, &h);
654 //x & y are screen coordinates, Add with pan coordinates
657 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
661 _sizing_eval(Evas_Object *obj)
663 Widget_Data *wd = elm_widget_data_get(obj);
664 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
666 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
667 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
669 if (wd->height_for_width)
673 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
674 if ((vw != 0) && (vw != wd->prev_viewport_w))
678 wd->prev_viewport_w = vw;
679 EINA_INLIST_FOREACH(wd->blocks, itb)
681 itb->must_recalc = EINA_TRUE;
683 if (wd->calc_job) ecore_job_del(wd->calc_job);
684 wd->calc_job = ecore_job_add(_calc_job, wd);
687 if (wd->mode == ELM_LIST_LIMIT)
689 Evas_Coord vmw, vmh, vw, vh;
693 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
694 if ((minw > 0) && (vw < minw)) vw = minw;
695 else if ((maxw > 0) && (vw > maxw))
697 edje_object_size_min_calc
698 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
705 edje_object_size_min_calc
706 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
710 evas_object_size_hint_min_set(obj, minw, minh);
711 evas_object_size_hint_max_set(obj, maxw, maxh);
715 _signal_emit_hook(Evas_Object *obj,
716 const char *emission,
719 Widget_Data *wd = elm_widget_data_get(obj);
720 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
725 _item_highlight(Elm_Genlist_Item *it)
727 const char *selectraise;
728 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
729 (it->disabled) || (it->display_only) || (it->mode_view))
731 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
732 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
733 selectraise = edje_object_data_get(it->base.view, "selectraise");
734 if ((selectraise) && (!strcmp(selectraise, "on")))
736 if (it->edit_obj) evas_object_raise(it->edit_obj);
737 else evas_object_raise(it->base.view);
738 if ((it->group_item) && (it->group_item->realized))
739 evas_object_raise(it->group_item->base.view);
741 it->highlighted = EINA_TRUE;
745 _item_block_del(Elm_Genlist_Item *it)
748 Item_Block *itb = it->block;
750 itb->items = eina_list_remove(itb->items, it);
752 itb->changed = EINA_TRUE;
753 if (!it->wd->reorder_deleted)
755 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
756 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
760 il = EINA_INLIST_GET(itb);
761 Item_Block *itbn = (Item_Block *)(il->next);
763 it->parent->items = eina_list_remove(it->parent->items, it);
765 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
767 if (itbn) itbn->changed = EINA_TRUE;
771 if (itb->count < itb->wd->max_items_per_block/2)
773 il = EINA_INLIST_GET(itb);
774 Item_Block *itbp = (Item_Block *)(il->prev);
775 Item_Block *itbn = (Item_Block *)(il->next);
776 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
778 Elm_Genlist_Item *it2;
780 EINA_LIST_FREE(itb->items, it2)
783 itbp->items = eina_list_append(itbp->items, it2);
785 itbp->changed = EINA_TRUE;
787 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
788 EINA_INLIST_GET(itb));
791 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
795 Eina_List *last = eina_list_last(itb->items);
796 Elm_Genlist_Item *it2 = last->data;
799 itb->items = eina_list_remove_list(itb->items, last);
800 itbn->items = eina_list_prepend(itbn->items, it2);
802 itbn->changed = EINA_TRUE;
805 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
813 _item_subitems_clear(Elm_Genlist_Item *it)
816 Eina_List *tl = NULL, *l;
817 Elm_Genlist_Item *it2;
819 EINA_LIST_FOREACH(it->items, l, it2)
820 tl = eina_list_append(tl, it2);
822 EINA_LIST_FREE(tl, it2)
823 elm_genlist_item_del(it2);
827 _item_del(Elm_Genlist_Item *it)
829 Evas_Object *tob = it->wd->obj;
831 evas_event_freeze(evas_object_evas_get(tob));
832 elm_widget_item_pre_notify_del(it);
833 elm_genlist_item_subitems_clear(it);
834 it->wd->walking -= it->walking;
835 if (it->wd->show_item == it) it->wd->show_item = NULL;
836 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
837 if (it->realized) _item_unrealize(it, EINA_FALSE);
838 if (it->effect_item_realized) _effect_item_unrealize(it);
839 if (it->block) _item_block_del(it);
840 if ((!it->delete_me) && (it->itc->func.del))
841 it->itc->func.del((void *)it->base.data, it->base.widget);
842 it->delete_me = EINA_TRUE;
844 it->wd->queue = eina_list_remove(it->wd->queue, it);
846 if (it->wd->anchor_item == it)
848 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
849 if (!it->wd->anchor_item)
850 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
853 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
855 it->parent->items = eina_list_remove(it->parent->items, it);
856 if (it->flags & ELM_GENLIST_ITEM_GROUP)
857 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
858 if (it->long_timer) ecore_timer_del(it->long_timer);
859 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
861 if (it->tooltip.del_cb)
862 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
864 evas_event_thaw(evas_object_evas_get(tob));
865 evas_event_thaw_eval(evas_object_evas_get(tob));
867 elm_widget_item_del(it);
871 _item_select(Elm_Genlist_Item *it)
873 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
876 if (it->wd->always_select) goto call;
879 it->selected = EINA_TRUE;
880 it->wd->selected = eina_list_append(it->wd->selected, it);
886 Evas_Object *baseobj = it->base.widget;
887 const char *objtype = NULL;
888 it->func.func((void *)it->func.data, it->base.widget, it);
889 objtype = evas_object_type_get(baseobj);
890 if ((!objtype) || (!strcmp(objtype,""))) return;
893 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
896 if ((it->wd->clear_me) && (!it->wd->walking))
898 elm_genlist_clear(it->base.widget);
903 if ((!it->walking) && (it->delete_me))
905 if (!it->relcount) _item_del(it);
908 if (it && it->wd) it->wd->last_selected_item = it; // TODO: Remove 'if'?
912 _item_unselect(Elm_Genlist_Item *it)
914 const char *stacking, *selectraise;
916 if ((it->delete_me) || (!it->highlighted)) return;
917 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
918 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
919 stacking = edje_object_data_get(it->base.view, "stacking");
920 selectraise = edje_object_data_get(it->base.view, "selectraise");
921 if ((selectraise) && (!strcmp(selectraise, "on")))
923 if ((stacking) && (!strcmp(stacking, "below")))
924 evas_object_lower(it->base.view);
926 it->highlighted = EINA_FALSE;
929 it->selected = EINA_FALSE;
930 it->wd->selected = eina_list_remove(it->wd->selected, it);
931 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
936 _mouse_move(void *data,
937 Evas *evas __UNUSED__,
941 Elm_Genlist_Item *it = data;
942 Evas_Event_Mouse_Move *ev = event_info;
943 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
944 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
946 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
948 if (!it->wd->on_hold)
950 it->wd->on_hold = EINA_TRUE;
951 if (!it->wd->wasselected)
955 if (it->wd->multitouched)
957 it->wd->cur_x = ev->cur.canvas.x;
958 it->wd->cur_y = ev->cur.canvas.y;
961 if ((it->dragging) && (it->down))
963 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
966 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
967 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
968 if (abs((it->wd->history[it->wd->movements].x -
969 it->wd->history[0].x)) > 40)
970 it->wd->swipe = EINA_TRUE;
976 ecore_timer_del(it->long_timer);
977 it->long_timer = NULL;
979 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
982 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
986 ecore_timer_del(it->long_timer);
987 it->long_timer = NULL;
989 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
991 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
992 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
994 if (!it->wd->reorder_start_y)
995 it->wd->reorder_start_y = it->block->y + it->y;
999 else if (it_scrl_y + it->wd->reorder_it->h > oy + oh)
1000 y_pos = oy + oh - it->wd->reorder_it->h;
1005 _item_position(it, it->edit_obj, it->scrl_x, y_pos);
1007 _item_position(it, it->base.view, it->scrl_x, y_pos);
1008 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1009 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1013 if (!it->display_only)
1014 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1015 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1016 x = ev->cur.canvas.x - x;
1017 y = ev->cur.canvas.y - y;
1020 if (adx < 0) adx = -dx;
1023 if (ady < 0) ady = -dy;
1026 if ((adx > minw) || (ady > minh))
1028 it->dragging = EINA_TRUE;
1029 it->wd->dragging_queue = eina_list_append(it->wd->dragging_queue, it);
1032 ecore_timer_del(it->long_timer);
1033 it->long_timer = NULL;
1035 if (!it->wd->wasselected)
1040 evas_object_smart_callback_call(it->base.widget,
1041 SIG_DRAG_START_UP, it);
1045 evas_object_smart_callback_call(it->base.widget,
1046 SIG_DRAG_START_LEFT, it);
1048 evas_object_smart_callback_call(it->base.widget,
1049 SIG_DRAG_START_RIGHT, it);
1055 evas_object_smart_callback_call(it->base.widget,
1056 SIG_DRAG_START_DOWN, it);
1060 evas_object_smart_callback_call(it->base.widget,
1061 SIG_DRAG_START_LEFT, it);
1063 evas_object_smart_callback_call(it->base.widget,
1064 SIG_DRAG_START_RIGHT, it);
1071 _long_press(void *data)
1073 Elm_Genlist_Item *it = data, *it_tmp;
1074 Eina_List *list, *l;
1075 //static Eina_Bool contracted = EINA_FALSE;
1077 it->long_timer = NULL;
1078 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
1079 return ECORE_CALLBACK_CANCEL;
1080 it->wd->longpressed = EINA_TRUE;
1081 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1082 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1084 it->wd->reorder_it = it;
1085 it->wd->reorder_start_y = 0;
1087 evas_object_raise(it->edit_obj);
1089 evas_object_raise(it->base.view);
1090 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1091 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1093 list = elm_genlist_realized_items_get(it->wd->obj);
1094 EINA_LIST_FOREACH(list, l, it_tmp)
1096 if (it != it_tmp) _item_unselect(it_tmp);
1100 EINA_LIST_FOREACH(it->items, l, it_tmp)
1102 if (elm_genlist_item_expanded_get(it_tmp))
1104 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1105 return ECORE_CALLBACK_RENEW;
1109 if (elm_genlist_item_expanded_get(it))
1111 elm_genlist_item_expanded_set(it, EINA_FALSE);
1112 return ECORE_CALLBACK_RENEW;
1115 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1117 edje_object_signal_emit(it->base.view, "elm,state,reorder,enabled", "elm");
1119 return ECORE_CALLBACK_CANCEL;
1123 _swipe(Elm_Genlist_Item *it)
1128 if ((it->display_only) || (it->disabled)) return;
1129 it->wd->swipe = EINA_FALSE;
1130 for (i = 0; i < it->wd->movements; i++)
1132 sum += it->wd->history[i].x;
1133 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1136 sum /= it->wd->movements;
1137 if (abs(sum - it->wd->history[0].x) <= 10) return;
1138 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1142 _swipe_cancel(void *data)
1144 Elm_Genlist_Item *it = data;
1146 if (!it) return ECORE_CALLBACK_CANCEL;
1147 it->wd->swipe = EINA_FALSE;
1148 it->wd->movements = 0;
1149 return ECORE_CALLBACK_RENEW;
1153 _multi_cancel(void *data)
1155 Widget_Data *wd = data;
1157 if (!wd) return ECORE_CALLBACK_CANCEL;
1158 wd->multi_timeout = EINA_TRUE;
1159 return ECORE_CALLBACK_RENEW;
1163 _multi_touch_gesture_eval(void *data)
1165 Elm_Genlist_Item *it = data;
1167 it->wd->multitouched = EINA_FALSE;
1168 if (it->wd->multi_timer)
1170 ecore_timer_del(it->wd->multi_timer);
1171 it->wd->multi_timer = NULL;
1173 if (it->wd->multi_timeout)
1175 it->wd->multi_timeout = EINA_FALSE;
1179 Evas_Coord minw = 0, minh = 0;
1180 Evas_Coord off_x, off_y, off_mx, off_my;
1182 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1183 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1184 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1185 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1186 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1188 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1190 if ((off_x + off_mx) > (off_y + off_my))
1192 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1193 evas_object_smart_callback_call(it->base.widget,
1194 SIG_MULTI_SWIPE_RIGHT, it);
1195 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1196 evas_object_smart_callback_call(it->base.widget,
1197 SIG_MULTI_SWIPE_LEFT, it);
1198 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1199 evas_object_smart_callback_call(it->base.widget,
1200 SIG_MULTI_PINCH_OUT, it);
1202 evas_object_smart_callback_call(it->base.widget,
1203 SIG_MULTI_PINCH_IN, it);
1207 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1208 evas_object_smart_callback_call(it->base.widget,
1209 SIG_MULTI_SWIPE_DOWN, it);
1210 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1211 evas_object_smart_callback_call(it->base.widget,
1212 SIG_MULTI_SWIPE_UP, it);
1213 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1214 evas_object_smart_callback_call(it->base.widget,
1215 SIG_MULTI_PINCH_OUT, it);
1217 evas_object_smart_callback_call(it->base.widget,
1218 SIG_MULTI_PINCH_IN, it);
1221 it->wd->multi_timeout = EINA_FALSE;
1225 _multi_down(void *data,
1226 Evas *evas __UNUSED__,
1227 Evas_Object *obj __UNUSED__,
1230 Elm_Genlist_Item *it = data;
1231 Evas_Event_Multi_Down *ev = event_info;
1233 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1234 it->wd->multi_device = ev->device;
1235 it->wd->multi_down = EINA_TRUE;
1236 it->wd->multitouched = EINA_TRUE;
1237 it->wd->prev_mx = ev->canvas.x;
1238 it->wd->prev_my = ev->canvas.y;
1239 if (!it->wd->wasselected) _item_unselect(it);
1240 it->wd->wasselected = EINA_FALSE;
1241 it->wd->longpressed = EINA_FALSE;
1244 ecore_timer_del(it->long_timer);
1245 it->long_timer = NULL;
1249 it->dragging = EINA_FALSE;
1250 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1252 if (it->swipe_timer)
1254 ecore_timer_del(it->swipe_timer);
1255 it->swipe_timer = NULL;
1257 if (it->wd->on_hold)
1259 it->wd->swipe = EINA_FALSE;
1260 it->wd->movements = 0;
1261 it->wd->on_hold = EINA_FALSE;
1266 _multi_up(void *data,
1267 Evas *evas __UNUSED__,
1268 Evas_Object *obj __UNUSED__,
1271 Elm_Genlist_Item *it = data;
1272 Evas_Event_Multi_Up *ev = event_info;
1274 if (it->wd->multi_device != ev->device) return;
1275 it->wd->multi_device = 0;
1276 it->wd->multi_down = EINA_FALSE;
1277 if (it->wd->mouse_down) return;
1278 _multi_touch_gesture_eval(data);
1282 _multi_move(void *data,
1283 Evas *evas __UNUSED__,
1284 Evas_Object *obj __UNUSED__,
1287 Elm_Genlist_Item *it = data;
1288 Evas_Event_Multi_Move *ev = event_info;
1290 if (it->wd->multi_device != ev->device) return;
1291 it->wd->cur_mx = ev->cur.canvas.x;
1292 it->wd->cur_my = ev->cur.canvas.y;
1296 _mouse_down(void *data,
1297 Evas *evas __UNUSED__,
1301 Elm_Genlist_Item *it = data;
1302 Evas_Event_Mouse_Down *ev = event_info;
1305 if (ev->button != 1) return;
1306 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1308 it->wd->on_hold = EINA_TRUE;
1310 it->down = EINA_TRUE;
1311 it->dragging = EINA_FALSE;
1312 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1313 it->dx = ev->canvas.x - x;
1314 it->dy = ev->canvas.y - y;
1315 it->wd->mouse_down = EINA_TRUE;
1316 if (!it->wd->multitouched)
1318 it->wd->prev_x = ev->canvas.x;
1319 it->wd->prev_y = ev->canvas.y;
1320 it->wd->multi_timeout = EINA_FALSE;
1321 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1322 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1324 it->wd->longpressed = EINA_FALSE;
1325 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1326 else it->wd->on_hold = EINA_FALSE;
1327 if (it->wd->on_hold) return;
1328 it->wd->wasselected = it->selected;
1329 _item_highlight(it);
1330 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1331 if ((!it->disabled) && (!it->display_only))
1333 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1334 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
1336 if (it->long_timer) ecore_timer_del(it->long_timer);
1337 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1338 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1340 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1343 it->long_timer = NULL;
1344 it->wd->swipe = EINA_FALSE;
1345 it->wd->movements = 0;
1349 _mouse_up(void *data,
1350 Evas *evas __UNUSED__,
1351 Evas_Object *obj __UNUSED__,
1354 Elm_Genlist_Item *it = data;
1355 Evas_Event_Mouse_Up *ev = event_info;
1356 Eina_Bool dragged = EINA_FALSE;
1358 if (ev->button != 1) return;
1359 it->down = EINA_FALSE;
1360 it->wd->mouse_down = EINA_FALSE;
1361 if (it->wd->multitouched)
1363 // in single selection modes, some multi touching can make multi highlighted items.
1364 // if a item not selected and highlighted, it should be unhighlighted.
1365 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unselect(it);
1366 if (it->wd->multi_down) return;
1367 _multi_touch_gesture_eval(data);
1370 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1371 else it->wd->on_hold = EINA_FALSE;
1374 ecore_timer_del(it->long_timer);
1375 it->long_timer = NULL;
1377 while (it->wd->dragging_queue)
1379 Elm_Genlist_Item *dragging_it = NULL;
1380 dragging_it = eina_list_data_get(it->wd->dragging_queue);
1381 dragging_it->dragging = EINA_FALSE;
1382 evas_object_smart_callback_call(dragging_it->base.widget, SIG_DRAG_STOP, dragging_it);
1383 if (dragging_it->want_unrealize)
1385 _item_unrealize(dragging_it, EINA_FALSE);
1386 if (dragging_it->block->want_unrealize)
1387 _item_block_unrealize(it->block);
1389 it->wd->dragging_queue = eina_list_remove_list(it->wd->dragging_queue,it->wd->dragging_queue);
1392 if (it->swipe_timer)
1394 ecore_timer_del(it->swipe_timer);
1395 it->swipe_timer = NULL;
1397 if (it->wd->multi_timer)
1399 ecore_timer_del(it->wd->multi_timer);
1400 it->wd->multi_timer = NULL;
1401 it->wd->multi_timeout = EINA_FALSE;
1403 if (it->wd->on_hold)
1405 if (it->wd->swipe) _swipe(data);
1406 it->wd->longpressed = EINA_FALSE;
1407 it->wd->on_hold = EINA_FALSE;
1410 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1412 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1414 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1416 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1417 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1419 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1423 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1424 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1426 it->wd->reorder_deleted = EINA_FALSE;
1427 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1428 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1429 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1430 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1433 if (it->wd->longpressed)
1435 it->wd->longpressed = EINA_FALSE;
1436 if (!it->wd->wasselected)
1438 it->wd->wasselected = EINA_FALSE;
1441 if ((it->disabled) || (dragged) || (it->display_only)) return;
1442 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1447 _item_highlight(it);
1450 else _item_unselect(it);
1456 Widget_Data *wd = it->wd;
1459 while (wd->selected) _item_unselect(wd->selected->data);
1464 const Eina_List *l, *l_next;
1465 Elm_Genlist_Item *it2;
1467 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1468 if (it2 != it) _item_unselect(it2);
1469 //_item_highlight(it);
1472 _item_highlight(it);
1478 _signal_expand_toggle(void *data,
1479 Evas_Object *obj __UNUSED__,
1480 const char *emission __UNUSED__,
1481 const char *source __UNUSED__)
1483 Elm_Genlist_Item *it = data;
1486 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1488 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1492 _signal_expand(void *data,
1493 Evas_Object *obj __UNUSED__,
1494 const char *emission __UNUSED__,
1495 const char *source __UNUSED__)
1497 Elm_Genlist_Item *it = data;
1500 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1504 _signal_contract(void *data,
1505 Evas_Object *obj __UNUSED__,
1506 const char *emission __UNUSED__,
1507 const char *source __UNUSED__)
1509 Elm_Genlist_Item *it = data;
1512 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1516 _scr_hold_timer_cb(void *data)
1518 if (!data) return ECORE_CALLBACK_CANCEL;
1519 Widget_Data *wd = data;
1520 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1521 wd->scr_hold_timer = NULL;
1522 return ECORE_CALLBACK_CANCEL;
1526 _mode_finished_signal_cb(void *data,
1528 const char *emission __UNUSED__,
1529 const char *source __UNUSED__)
1533 Elm_Genlist_Item *it = data;
1534 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1536 Evas *te = evas_object_evas_get(obj);
1538 evas_event_freeze(te);
1539 it->nocache = EINA_FALSE;
1540 _mode_item_unrealize(it);
1541 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1542 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1543 evas_event_thaw(te);
1544 evas_event_thaw_eval(te);
1548 _item_cache_clean(Widget_Data *wd)
1550 evas_event_freeze(evas_object_evas_get(wd->obj));
1551 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1555 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1556 wd->item_cache = eina_inlist_remove(wd->item_cache,
1557 wd->item_cache->last);
1558 wd->item_cache_count--;
1559 if (itc->spacer) evas_object_del(itc->spacer);
1560 if (itc->base_view) evas_object_del(itc->base_view);
1561 if (itc->item_style) eina_stringshare_del(itc->item_style);
1564 evas_event_thaw(evas_object_evas_get(wd->obj));
1565 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1569 _item_cache_zero(Widget_Data *wd)
1571 int pmax = wd->item_cache_max;
1572 wd->item_cache_max = 0;
1573 _item_cache_clean(wd);
1574 wd->item_cache_max = pmax;
1578 _item_cache_add(Elm_Genlist_Item *it)
1582 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1583 if (it->wd->item_cache_max <= 0)
1585 evas_object_del(it->base.view);
1586 it->base.view = NULL;
1587 evas_object_del(it->spacer);
1589 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1590 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1594 it->wd->item_cache_count++;
1595 itc = calloc(1, sizeof(Item_Cache));
1598 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1599 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1602 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1603 EINA_INLIST_GET(itc));
1604 itc->spacer = it->spacer;
1606 itc->base_view = it->base.view;
1607 it->base.view = NULL;
1608 evas_object_hide(itc->base_view);
1609 evas_object_move(itc->base_view, -9999, -9999);
1610 itc->item_style = eina_stringshare_add(it->itc->item_style);
1611 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1612 itc->compress = (it->wd->compress);
1613 itc->odd = (it->order_num_in & 0x1);
1614 itc->selected = it->selected;
1615 itc->disabled = it->disabled;
1616 itc->expanded = it->expanded;
1619 ecore_timer_del(it->long_timer);
1620 it->long_timer = NULL;
1622 if (it->swipe_timer)
1624 ecore_timer_del(it->swipe_timer);
1625 it->swipe_timer = NULL;
1627 // FIXME: other callbacks?
1628 edje_object_signal_callback_del_full(itc->base_view,
1629 "elm,action,expand,toggle",
1630 "elm", _signal_expand_toggle, it);
1631 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1633 _signal_expand, it);
1634 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1635 "elm", _signal_contract, it);
1636 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1638 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1640 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1642 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1644 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1646 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1648 _item_cache_clean(it->wd);
1649 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1650 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1654 _item_cache_find(Elm_Genlist_Item *it)
1657 Eina_Bool tree = 0, odd;
1659 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1660 odd = (it->order_num_in & 0x1);
1661 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1663 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1665 if ((itc->tree == tree) &&
1666 (itc->odd == odd) &&
1667 (itc->compress == it->wd->compress) &&
1668 (!strcmp(it->itc->item_style, itc->item_style)))
1670 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1671 EINA_INLIST_GET(itc));
1672 it->wd->item_cache_count--;
1680 _item_cache_free(Item_Cache *itc)
1682 if (itc->spacer) evas_object_del(itc->spacer);
1683 if (itc->base_view) evas_object_del(itc->base_view);
1684 if (itc->item_style) eina_stringshare_del(itc->item_style);
1689 _icon_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1691 Elm_Genlist_Item *it = data;
1692 if (it) it->defer_unrealize = EINA_TRUE;
1696 _icon_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1698 Elm_Genlist_Item *it = data;
1699 if (it) it->defer_unrealize = EINA_FALSE;
1703 _item_realize(Elm_Genlist_Item *it,
1707 Elm_Genlist_Item *it2;
1708 const char *stacking;
1709 const char *treesize;
1711 int depth, tsize = 20;
1712 Item_Cache *itc = NULL;
1714 if ((it->realized) || (it->delete_me)) return;
1715 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1716 it->order_num_in = in;
1717 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1718 if ((it->nocache) && (!it->renamed))
1719 it->nocache = EINA_FALSE;
1721 itc = _item_cache_find(it);
1722 if (itc && (!it->wd->effect_mode))
1724 it->base.view = itc->base_view;
1725 itc->base_view = NULL;
1726 it->spacer = itc->spacer;
1731 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1732 edje_object_scale_set(it->base.view,
1733 elm_widget_scale_get(it->base.widget) *
1734 _elm_config->scale);
1735 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1736 elm_widget_sub_object_add(it->base.widget, it->base.view);
1738 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1739 strncpy(buf, "tree", sizeof(buf));
1740 else strncpy(buf, "item", sizeof(buf));
1741 if (it->wd->compress)
1742 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1744 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1745 strncat(buf, "/", sizeof(buf) - strlen(buf));
1746 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1748 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1749 elm_widget_style_get(it->base.widget));
1750 edje_object_mirrored_set(it->base.view,
1751 elm_widget_mirrored_get(it->base.widget));
1753 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1754 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1755 elm_widget_sub_object_add(it->base.widget, it->spacer);
1757 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1759 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1761 it->expanded_depth = depth;
1762 treesize = edje_object_data_get(it->base.view, "treesize");
1763 if (treesize) tsize = atoi(treesize);
1764 evas_object_size_hint_min_set(it->spacer,
1765 (depth * tsize) * _elm_config->scale, 1);
1766 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1769 edje_object_signal_callback_add(it->base.view,
1770 "elm,action,expand,toggle",
1771 "elm", _signal_expand_toggle, it);
1772 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1773 "elm", _signal_expand, it);
1774 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1775 "elm", _signal_contract, it);
1776 stacking = edje_object_data_get(it->base.view, "stacking");
1779 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1780 else if (!strcmp(stacking, "above"))
1781 evas_object_raise(it->base.view);
1783 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1785 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1787 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1789 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1791 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1793 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1796 if ((!it->edit_obj) &&(it->wd->edit_mode) &&
1797 (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
1798 _effect_item_realize(it, EINA_FALSE);
1802 if ((it->selected) && (it->selected != itc->selected))
1804 edje_object_signal_emit(it->base.view,
1805 "elm,state,selected", "elm");
1807 edje_object_signal_emit(it->edit_obj,
1808 "elm,state,selected", "elm");
1810 if ((it->disabled) && (it->disabled != itc->disabled))
1812 edje_object_signal_emit(it->base.view,
1813 "elm,state,disabled", "elm");
1815 edje_object_signal_emit(it->edit_obj,
1816 "elm,state,disabled", "elm");
1818 if ((it->expanded) && (it->expanded != itc->expanded))
1820 edje_object_signal_emit(it->base.view,
1821 "elm,state,expanded", "elm");
1823 edje_object_signal_emit(it->edit_obj,
1824 "elm,state,expanded", "elm");
1831 edje_object_signal_emit(it->base.view,
1832 "elm,state,selected", "elm");
1834 edje_object_signal_emit(it->edit_obj,
1835 "elm,state,selected", "elm");
1839 edje_object_signal_emit(it->base.view,
1840 "elm,state,disabled", "elm");
1842 edje_object_signal_emit(it->edit_obj,
1843 "elm,state,disabled", "elm");
1847 edje_object_signal_emit(it->base.view,
1848 "elm,state,expanded", "elm");
1850 edje_object_signal_emit(it->edit_obj,
1851 "elm,state,expanded", "elm");
1856 if ((calc) && (it->wd->homogeneous) &&
1857 ((it->wd->item_width) ||
1858 ((it->wd->item_width) && (it->wd->group_item_width))))
1860 /* homogenous genlist shortcut */
1863 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1865 it->w = it->minw = it->wd->group_item_width;
1866 it->h = it->minh = it->wd->group_item_height;
1870 it->w = it->minw = it->wd->item_width;
1871 it->h = it->minh = it->wd->item_height;
1873 it->mincalcd = EINA_TRUE;
1878 if (it->itc->func.label_get)
1884 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1886 EINA_LIST_FOREACH(it->labels, l, key)
1888 char *s = it->itc->func.label_get
1889 ((void *)it->base.data, it->base.widget, l->data);
1893 edje_object_part_text_set(it->base.view, l->data, s);
1897 edje_object_part_text_set(it->base.view, l->data, "");
1900 if (it->itc->func.icon_get)
1906 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1908 EINA_LIST_FOREACH(it->icons, l, key)
1910 Evas_Object *ic = it->itc->func.icon_get
1911 ((void *)it->base.data, it->base.widget, l->data);
1915 it->icon_objs = eina_list_append(it->icon_objs, ic);
1916 edje_object_part_swallow(it->base.view, key, ic);
1917 evas_object_show(ic);
1918 elm_widget_sub_object_add(it->base.widget, ic);
1919 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
1921 elm_widget_disabled_set(ic, EINA_TRUE);
1927 elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
1928 EINA_LIST_FOREACH(it->icons, l, key)
1930 Evas_Object *ic = it->itc->func.icon_get
1931 ((void *)it->base.data, it->base.widget, l->data);
1934 it->icon_objs = eina_list_append(it->icon_objs, ic);
1935 edje_object_part_swallow(it->base.view, key, ic);
1936 evas_object_show(ic);
1937 elm_widget_sub_object_add(it->base.widget, ic);
1938 // FIXME: if entry calcuates its cursor position correctly and conformant works,
1939 // genlist does not need to handle this focus thing.
1940 evas_object_smart_callback_add(ic, "focused", _icon_focused, it);
1941 evas_object_smart_callback_add(ic, "unfocused", _icon_unfocused, it);
1946 if (it->itc->func.state_get)
1952 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1954 EINA_LIST_FOREACH(it->states, l, key)
1956 Eina_Bool on = it->itc->func.state_get
1957 ((void *)it->base.data, it->base.widget, l->data);
1961 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1962 edje_object_signal_emit(it->base.view, buf, "elm");
1966 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1967 edje_object_signal_emit(it->base.view, buf, "elm");
1971 if (!it->mincalcd || it->wd->pan_resize)
1973 Evas_Coord mw = -1, mh = -1;
1975 if (it->wd->height_for_width) mw = it->wd->w; // TODO: Removed this. This was removed from upstream.
1977 if (!it->display_only)
1978 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1979 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1980 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1982 if (!it->display_only)
1983 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1984 it->w = it->minw = mw;
1985 it->h = it->minh = mh;
1986 it->mincalcd = EINA_TRUE;
1988 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1990 it->wd->group_item_width = mw;
1991 it->wd->group_item_height = mh;
1993 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1995 it->wd->item_width = mw;
1996 it->wd->item_height = mh;
1999 if (!calc) evas_object_show(it->base.view);
2002 if (it->tooltip.content_cb)
2004 elm_widget_item_tooltip_content_cb_set(it,
2005 it->tooltip.content_cb,
2006 it->tooltip.data, NULL);
2007 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2010 if (it->mouse_cursor)
2011 elm_widget_item_cursor_set(it, it->mouse_cursor);
2013 it->realized = EINA_TRUE;
2014 it->want_unrealize = EINA_FALSE;
2016 if (itc) _item_cache_free(itc);
2017 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2018 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2020 evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2021 if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
2023 if (it->itc->edit_item_style)
2025 if (!it->edit_obj) _effect_item_realize(it, EINA_FALSE);
2026 edje_object_message_signal_process(it->edit_obj);
2029 edje_object_message_signal_process(it->base.view);
2033 _item_unrealize(Elm_Genlist_Item *it,
2038 if (!it->realized) return;
2039 if (it->wd->reorder_it == it) return;
2040 if (it->defer_unrealize) return;
2041 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2043 evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2046 ecore_timer_del(it->long_timer);
2047 it->long_timer = NULL;
2051 evas_object_del(it->base.view);
2052 it->base.view = NULL;
2053 evas_object_del(it->spacer);
2058 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2059 _item_cache_add(it);
2061 elm_widget_stringlist_free(it->labels);
2063 elm_widget_stringlist_free(it->icons);
2065 elm_widget_stringlist_free(it->states);
2067 EINA_LIST_FREE(it->icon_objs, icon)
2068 evas_object_del(icon);
2070 _mode_item_unrealize(it);
2072 it->realized = EINA_FALSE;
2073 it->want_unrealize = EINA_FALSE;
2074 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2075 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2076 if (it->wd->edit_mode) _effect_item_unrealize(it);
2080 _item_block_recalc(Item_Block *itb,
2085 Elm_Genlist_Item *it;
2086 Evas_Coord minw = 0, minh = 0;
2087 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2090 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2092 EINA_LIST_FOREACH(itb->items, l, it)
2094 if (it->delete_me) continue;
2095 showme |= it->showme;
2100 if (!it->mincalcd) changed = EINA_TRUE;
2103 _item_realize(it, in, EINA_TRUE);
2104 _item_unrealize(it, EINA_TRUE);
2109 _item_realize(it, in, EINA_TRUE);
2110 _item_unrealize(it, EINA_TRUE);
2114 _item_realize(it, in, EINA_FALSE);
2116 if (minw < it->minw) minw = it->minw;
2124 itb->changed = EINA_FALSE;
2125 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2126 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2131 _item_block_realize(Item_Block *itb,
2136 Elm_Genlist_Item *it;
2138 if (itb->realized) return;
2139 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2140 EINA_LIST_FOREACH(itb->items, l, it)
2142 if (it->delete_me) continue;
2143 if (full) _item_realize(it, in, EINA_FALSE);
2146 itb->realized = EINA_TRUE;
2147 itb->want_unrealize = EINA_FALSE;
2148 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2149 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2153 _item_block_unrealize(Item_Block *itb)
2156 Elm_Genlist_Item *it;
2157 Eina_Bool dragging = EINA_FALSE;
2159 if (!itb->realized) return;
2160 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2161 EINA_LIST_FOREACH(itb->items, l, it)
2163 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2167 dragging = EINA_TRUE;
2168 it->want_unrealize = EINA_TRUE;
2171 _item_unrealize(it, EINA_FALSE);
2176 itb->realized = EINA_FALSE;
2177 itb->want_unrealize = EINA_TRUE;
2180 itb->want_unrealize = EINA_FALSE;
2181 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2182 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2186 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2188 Evas_Coord rox, roy, row, roh, oy, oh;
2189 Eina_Bool top = EINA_FALSE;
2190 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2191 if (!reorder_it) return 0;
2193 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2194 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2196 if ((it->wd->reorder_start_y < it->block->y) &&
2197 (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2199 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2200 if (it->block->count == 1)
2201 it->wd->reorder_rel = it;
2203 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2205 it->block->reorder_offset = it->wd->reorder_it->h;
2208 it->block->reorder_offset = 0;
2210 it->scrl_y += it->block->reorder_offset;
2212 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2213 rox, roy + (roh / 2), row, 1));
2216 it->wd->reorder_rel = it;
2217 it->scrl_y += it->wd->reorder_it->h;
2218 return it->wd->reorder_it->h;
2225 _reorder_move_animator_cb(void *data)
2227 Elm_Genlist_Item *it = data;
2228 Eina_Bool down = EINA_FALSE;
2230 int y, dy = it->h / 10 * _elm_config->scale, diff;
2232 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2234 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2237 diff = abs(it->old_scrl_y - it->scrl_y);
2238 if (diff > it->h) y = diff / 2;
2239 if (it->old_scrl_y < it->scrl_y)
2241 it->old_scrl_y += y;
2244 else if (it->old_scrl_y > it->scrl_y)
2246 it->old_scrl_y -= y;
2251 _item_position(it, it->edit_obj, it->scrl_x, it->old_scrl_y);
2253 _item_position(it, it->base.view, it->scrl_x, it->old_scrl_y);
2254 _group_items_recalc(it->wd);
2255 if ((it->wd->reorder_pan_move) ||
2256 (down && it->old_scrl_y >= it->scrl_y) ||
2257 (!down && it->old_scrl_y <= it->scrl_y))
2259 it->old_scrl_y = it->scrl_y;
2260 it->move_effect_enabled = EINA_FALSE;
2261 it->wd->reorder_move_animator = NULL;
2262 return ECORE_CALLBACK_CANCEL;
2264 return ECORE_CALLBACK_RENEW;
2268 _item_position(Elm_Genlist_Item *it,
2276 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2277 evas_object_resize(view, it->w, it->h);
2278 evas_object_move(view, it_x, it_y);
2279 evas_object_show(view);
2280 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2281 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2285 _item_block_position(Item_Block *itb,
2289 Elm_Genlist_Item *it;
2290 Elm_Genlist_Item *git;
2291 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2292 Evas_Coord minh = 0;
2295 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2296 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2297 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2299 EINA_LIST_FOREACH(itb->items, l, it)
2301 if (it->delete_me) continue;
2302 else if (it->wd->reorder_it == it) continue;
2307 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2308 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2310 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2311 cvx, cvy, cvw, cvh));
2312 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2314 if ((itb->realized))
2318 if (!it->realized) _item_realize(it, in, EINA_FALSE);
2321 if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
2322 edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
2330 if (it->wd->reorder_mode)
2331 y += _get_space_for_reorder_item(it);
2332 git = it->group_item;
2335 git->scrl_x = it->scrl_x;
2336 if (git->scrl_y < oy)
2338 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2339 git->scrl_y = (it->scrl_y + it->h) - git->h;
2340 git->want_realize = EINA_TRUE;
2342 if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2344 if (!it->move_effect_enabled)
2346 it->move_effect_enabled = EINA_TRUE;
2347 it->wd->reorder_move_animator =
2349 _reorder_move_animator_cb, it);
2352 if (!it->move_effect_enabled)
2353 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))
2355 if (it->wd->edit_mode && it->itc->edit_item_style)
2357 _item_position(it, it->edit_obj, it->scrl_x, it->scrl_y);
2361 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)))
2364 _item_position(it, it->mode_view, it->scrl_x,
2367 _item_position(it, it->base.view, it->scrl_x,
2372 evas_object_resize(it->base.view, it->w, it->h);
2373 evas_object_move(it->base.view, it->scrl_x, it->scrl_y);
2374 evas_object_hide(it->base.view);
2381 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2388 if (vis) it->want_realize = EINA_TRUE;
2390 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))
2392 it->old_scrl_y = it->scrl_y;
2397 if (!itb->wd->reorder_it) itb->minh = minh;
2398 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2399 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2403 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2405 Elm_Genlist_Item *it = data;
2407 it->mincalcd = EINA_FALSE;
2408 it->block->changeme = EINA_TRUE;
2409 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2410 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2414 _group_items_recalc(void *data)
2416 Widget_Data *wd = data;
2418 Elm_Genlist_Item *git;
2420 evas_event_freeze(evas_object_evas_get(wd->obj));
2421 EINA_LIST_FOREACH(wd->group_items, l, git)
2423 if (git->want_realize)
2426 _item_realize(git, 0, EINA_FALSE);
2427 evas_object_resize(git->base.view, wd->minw, git->h);
2428 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2429 evas_object_show(git->base.view);
2430 evas_object_raise(git->base.view);
2432 else if (!git->want_realize && git->realized)
2435 _item_unrealize(git, EINA_FALSE);
2438 evas_event_thaw(evas_object_evas_get(wd->obj));
2439 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2443 _must_recalc_idler(void *data)
2445 Widget_Data *wd = data;
2446 if (wd->calc_job) ecore_job_del(wd->calc_job);
2447 wd->calc_job = ecore_job_add(_calc_job, wd);
2448 wd->must_recalc_idler = NULL;
2449 return ECORE_CALLBACK_CANCEL;
2453 _calc_job(void *data)
2455 Widget_Data *wd = data;
2456 Item_Block *itb, *chb = NULL;
2457 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2458 int in = 0, minw_change = 0;
2459 Eina_Bool changed = EINA_FALSE;
2461 Eina_Bool did_must_recalc = EINA_FALSE;
2464 t0 = ecore_time_get();
2465 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2469 evas_event_freeze(evas_object_evas_get(wd->obj));
2470 EINA_INLIST_FOREACH(wd->blocks, itb)
2472 Eina_Bool showme = EINA_FALSE;
2475 showme = itb->showme;
2476 itb->showme = EINA_FALSE;
2479 if (itb->realized) _item_block_unrealize(itb);
2481 if ((itb->changed) || (changed) ||
2482 ((itb->must_recalc) && (!did_must_recalc)))
2484 if ((changed) || (itb->must_recalc))
2487 Elm_Genlist_Item *it;
2488 EINA_LIST_FOREACH(itb->items, l, it)
2489 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2490 itb->changed = EINA_TRUE;
2491 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2492 itb->must_recalc = EINA_FALSE;
2494 if (itb->realized) _item_block_unrealize(itb);
2495 showme = _item_block_recalc(itb, in, EINA_FALSE);
2501 if (minw == -1) minw = itb->minw;
2502 else if ((!itb->must_recalc) && (minw < itb->minw))
2505 minw_change = EINA_TRUE;
2511 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2513 wd->show_item->showme = EINA_FALSE;
2515 elm_smart_scroller_region_bring_in(wd->scr,
2517 wd->show_item->block->x,
2519 wd->show_item->block->y,
2520 wd->show_item->block->w,
2523 elm_smart_scroller_child_region_show(wd->scr,
2525 wd->show_item->block->x,
2527 wd->show_item->block->y,
2528 wd->show_item->block->w,
2530 wd->show_item = NULL;
2535 EINA_INLIST_FOREACH(wd->blocks, itb)
2541 if ((chb) && (EINA_INLIST_GET(chb)->next))
2543 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2545 if (itb->realized) _item_block_unrealize(itb);
2548 wd->realminw = minw;
2549 if (minw < wd->w) minw = wd->w;
2550 if ((minw != wd->minw) || (minh != wd->minh))
2554 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2555 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2556 _sizing_eval(wd->obj);
2558 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2560 Elm_Genlist_Item *it;
2563 it = wd->anchor_item;
2564 it_y = wd->anchor_y;
2565 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2566 it->block->y + it->y + it_y);
2567 wd->anchor_item = it;
2568 wd->anchor_y = it_y;
2572 t = ecore_time_get();
2573 if (did_must_recalc)
2575 if (!wd->must_recalc_idler)
2576 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2578 wd->calc_job = NULL;
2579 evas_object_smart_changed(wd->pan_smart);
2580 evas_event_thaw(evas_object_evas_get(wd->obj));
2581 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2585 _update_job(void *data)
2587 Widget_Data *wd = data;
2591 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2593 wd->update_job = NULL;
2596 evas_event_freeze(evas_object_evas_get(wd->obj));
2597 EINA_INLIST_FOREACH(wd->blocks, itb)
2599 Evas_Coord itminw, itminh;
2600 Elm_Genlist_Item *it;
2606 _item_block_position(itb, num);
2610 recalc = EINA_FALSE;
2611 EINA_LIST_FOREACH(itb->items, l2, it)
2618 it->updateme = EINA_FALSE;
2621 _item_unrealize(it, EINA_FALSE);
2622 _item_realize(it, num, EINA_FALSE);
2623 position = EINA_TRUE;
2627 _item_realize(it, num, EINA_TRUE);
2628 _item_unrealize(it, EINA_TRUE);
2630 if ((it->minw != itminw) || (it->minh != itminh))
2635 itb->updateme = EINA_FALSE;
2638 position = EINA_TRUE;
2639 itb->changed = EINA_TRUE;
2640 _item_block_recalc(itb, num0, EINA_FALSE);
2641 _item_block_position(itb, num0);
2646 if (wd->calc_job) ecore_job_del(wd->calc_job);
2647 wd->calc_job = ecore_job_add(_calc_job, wd);
2649 evas_event_thaw(evas_object_evas_get(wd->obj));
2650 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2654 _changed_job(void *data)
2656 Widget_Data *wd = data; Eina_List *l2;
2658 int num, num0, position = 0;
2659 Eina_Bool width_changed = EINA_FALSE, height_changed = EINA_FALSE;
2661 wd->changed_job = NULL;
2663 EINA_INLIST_FOREACH(wd->blocks, itb)
2665 Evas_Coord itminw, itminh;
2666 Elm_Genlist_Item *it;
2672 _item_block_position(itb, num);
2676 width_changed = height_changed = EINA_FALSE;
2677 EINA_LIST_FOREACH(itb->items, l2, it)
2679 if ((!it->mincalcd) && (it->realized))
2681 Evas_Coord mw = -1, mh = -1;
2685 if (it->wd->height_for_width) mw = it->wd->w;
2686 if (!it->display_only)
2687 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2688 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2689 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2690 if (!it->display_only)
2691 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2692 it->w = it->minw = mw;
2693 it->h = it->minh = mh;
2694 it->mincalcd = EINA_TRUE;
2696 //if ((it->minw != itminw) || (it->minh != itminh))
2697 //if ((it->minh != itminh))
2699 if ((it->minw != itminw))
2700 width_changed = EINA_TRUE;
2701 if ((it->minh != itminh))
2702 height_changed = EINA_TRUE;
2704 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2706 it->wd->group_item_width = mw;
2707 it->wd->group_item_height = mh;
2709 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2711 it->wd->item_width = mw;
2712 it->wd->item_height = mh;
2717 itb->changeme = EINA_FALSE;
2718 // TODO: why this is separated.
2722 itb->changed = EINA_TRUE;
2723 _item_block_recalc(itb, num0, 0);
2724 _item_block_position(itb, num0);
2726 else if (width_changed)
2728 _item_block_position(itb, num0);
2733 if (wd->calc_job) ecore_job_del(wd->calc_job);
2734 wd->calc_job = ecore_job_add(_calc_job, wd);
2739 _pan_set(Evas_Object *obj,
2743 Pan *sd = evas_object_smart_data_get(obj);
2749 // Evas_Coord ow, oh;
2750 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2751 // ow = sd->wd->minw - ow;
2752 // if (ow < 0) ow = 0;
2753 // oh = sd->wd->minh - oh;
2754 // if (oh < 0) oh = 0;
2755 // if (x < 0) x = 0;
2756 // if (y < 0) y = 0;
2757 // if (x > ow) x = ow;
2758 // if (y > oh) y = oh;
2759 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2764 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2766 if ((itb->y + itb->h) > y)
2768 Elm_Genlist_Item *it;
2771 EINA_LIST_FOREACH(itb->items, l2, it)
2773 if ((itb->y + it->y) >= y)
2775 sd->wd->anchor_item = it;
2776 sd->wd->anchor_y = -(itb->y + it->y - y);
2784 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2788 _pan_get(Evas_Object *obj,
2792 Pan *sd = evas_object_smart_data_get(obj);
2795 if (x) *x = sd->wd->pan_x;
2796 if (y) *y = sd->wd->pan_y;
2800 _pan_max_get(Evas_Object *obj,
2804 Pan *sd = evas_object_smart_data_get(obj);
2808 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2809 ow = sd->wd->minw - ow;
2811 oh = sd->wd->minh - oh;
2818 _pan_min_get(Evas_Object *obj __UNUSED__,
2827 _pan_child_size_get(Evas_Object *obj,
2831 Pan *sd = evas_object_smart_data_get(obj);
2834 if (w) *w = sd->wd->minw;
2835 if (h) *h = sd->wd->minh;
2839 _pan_add(Evas_Object *obj)
2842 Evas_Object_Smart_Clipped_Data *cd;
2845 cd = evas_object_smart_data_get(obj);
2848 sd->__clipped_data = *cd;
2850 evas_object_smart_data_set(obj, sd);
2854 _pan_del(Evas_Object *obj)
2856 Pan *sd = evas_object_smart_data_get(obj);
2861 ecore_job_del(sd->resize_job);
2862 sd->resize_job = NULL;
2868 _pan_resize_job(void *data)
2872 _sizing_eval(sd->wd->obj);
2873 sd->resize_job = NULL;
2877 _pan_resize(Evas_Object *obj,
2881 Pan *sd = evas_object_smart_data_get(obj);
2885 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2886 if ((ow == w) && (oh == h)) return;
2887 if ((sd->wd->height_for_width) && (ow != w))
2889 sd->wd->pan_resize = EINA_TRUE;
2890 if (sd->resize_job) ecore_job_del(sd->resize_job);
2891 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2893 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2894 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2898 _pan_calculate(Evas_Object *obj)
2900 Pan *sd = evas_object_smart_data_get(obj);
2902 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2904 Elm_Genlist_Item *git;
2908 evas_event_freeze(evas_object_evas_get(obj));
2909 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2910 sd->wd->prev_viewport_w = ow;
2911 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2912 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2914 git->want_realize = EINA_FALSE;
2916 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2918 itb->w = sd->wd->minw;
2919 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2920 itb->y - sd->wd->pan_y + oy,
2922 cvx, cvy, cvw, cvh))
2924 if ((!itb->realized) || (itb->changed))
2925 _item_block_realize(itb, in, 0);
2926 _item_block_position(itb, in);
2930 if (itb->realized) _item_block_unrealize(itb);
2934 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2935 _group_items_recalc(sd->wd);
2937 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2939 if (sd->wd->pan_y != sd->wd->old_pan_y)
2940 sd->wd->reorder_pan_move = EINA_TRUE;
2941 else sd->wd->reorder_pan_move = EINA_FALSE;
2942 evas_object_raise(sd->wd->reorder_it->edit_obj);
2943 sd->wd->old_pan_y = sd->wd->pan_y;
2944 sd->wd->start_time = ecore_loop_time_get();
2947 if (sd->wd->effect_mode &&
2948 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
2949 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
2950 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
2952 if (!sd->wd->item_moving_effect_timer)
2954 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2955 _item_flip_effect_show(sd->wd->expand_item);
2957 evas_object_raise(sd->wd->alpha_bg);
2958 evas_object_show(sd->wd->alpha_bg);
2959 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
2960 sd->wd->start_time = current_time_get();
2961 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2964 else _item_auto_scroll(sd->wd);
2965 sd->wd->pan_resize = EINA_FALSE;
2966 evas_event_thaw(evas_object_evas_get(obj));
2967 evas_event_thaw_eval(evas_object_evas_get(obj));
2971 _pan_move(Evas_Object *obj,
2972 Evas_Coord x __UNUSED__,
2973 Evas_Coord y __UNUSED__)
2975 Pan *sd = evas_object_smart_data_get(obj);
2978 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2979 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2983 _hold_on(void *data __UNUSED__,
2985 void *event_info __UNUSED__)
2987 Widget_Data *wd = elm_widget_data_get(obj);
2989 elm_smart_scroller_hold_set(wd->scr, 1);
2993 _hold_off(void *data __UNUSED__,
2995 void *event_info __UNUSED__)
2997 Widget_Data *wd = elm_widget_data_get(obj);
2999 elm_smart_scroller_hold_set(wd->scr, 0);
3003 _freeze_on(void *data __UNUSED__,
3005 void *event_info __UNUSED__)
3007 Widget_Data *wd = elm_widget_data_get(obj);
3009 elm_smart_scroller_freeze_set(wd->scr, 1);
3013 _freeze_off(void *data __UNUSED__,
3015 void *event_info __UNUSED__)
3017 Widget_Data *wd = elm_widget_data_get(obj);
3019 elm_smart_scroller_freeze_set(wd->scr, 0);
3023 _scroll_edge_left(void *data,
3024 Evas_Object *scr __UNUSED__,
3025 void *event_info __UNUSED__)
3027 Evas_Object *obj = data;
3028 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
3032 _scroll_edge_right(void *data,
3033 Evas_Object *scr __UNUSED__,
3034 void *event_info __UNUSED__)
3036 Evas_Object *obj = data;
3037 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
3041 _scroll_edge_top(void *data,
3042 Evas_Object *scr __UNUSED__,
3043 void *event_info __UNUSED__)
3045 Evas_Object *obj = data;
3046 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
3050 _scroll_edge_bottom(void *data,
3051 Evas_Object *scr __UNUSED__,
3052 void *event_info __UNUSED__)
3054 Evas_Object *obj = data;
3055 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
3059 _mode_item_realize(Elm_Genlist_Item *it)
3063 if ((it->mode_view) || (it->delete_me)) return;
3065 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3066 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
3067 edje_object_scale_set(it->mode_view,
3068 elm_widget_scale_get(it->base.widget) *
3069 _elm_config->scale);
3070 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
3071 elm_widget_sub_object_add(it->base.widget, it->mode_view);
3073 strncpy(buf, "item", sizeof(buf));
3074 if (it->wd->compress)
3075 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3077 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3078 strncat(buf, "/", sizeof(buf) - strlen(buf));
3079 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3081 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
3082 elm_widget_style_get(it->base.widget));
3083 edje_object_mirrored_set(it->mode_view,
3084 elm_widget_mirrored_get(it->base.widget));
3086 /* signal callback add */
3087 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3089 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3091 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3094 /* label_get, icon_get, state_get */
3095 if (it->itc->func.label_get)
3101 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3103 EINA_LIST_FOREACH(it->mode_labels, l, key)
3105 char *s = it->itc->func.label_get
3106 ((void *)it->base.data, it->base.widget, l->data);
3110 edje_object_part_text_set(it->mode_view, l->data, s);
3115 if (it->itc->func.icon_get)
3121 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3123 EINA_LIST_FOREACH(it->mode_icons, l, key)
3125 Evas_Object *ic = it->itc->func.icon_get
3126 ((void *)it->base.data, it->base.widget, l->data);
3130 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
3131 edje_object_part_swallow(it->mode_view, key, ic);
3132 evas_object_show(ic);
3133 elm_widget_sub_object_add(it->base.widget, ic);
3135 elm_widget_disabled_set(ic, EINA_TRUE);
3139 if (it->itc->func.state_get)
3145 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3147 EINA_LIST_FOREACH(it->mode_states, l, key)
3149 Eina_Bool on = it->itc->func.state_get
3150 ((void *)it->base.data, it->base.widget, l->data);
3154 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
3155 edje_object_signal_emit(it->mode_view, buf, "elm");
3160 edje_object_part_swallow(it->mode_view,
3161 edje_object_data_get(it->mode_view, "mode_part"),
3164 it->want_unrealize = EINA_FALSE;
3165 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3166 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3170 _mode_item_unrealize(Elm_Genlist_Item *it)
3172 Widget_Data *wd = it->wd;
3174 if (!it->mode_view) return;
3176 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3177 elm_widget_stringlist_free(it->mode_labels);
3178 it->mode_labels = NULL;
3179 elm_widget_stringlist_free(it->mode_icons);
3180 it->mode_icons = NULL;
3181 elm_widget_stringlist_free(it->mode_states);
3183 EINA_LIST_FREE(it->mode_icon_objs, icon)
3184 evas_object_del(icon);
3186 edje_object_part_unswallow(it->mode_view, it->base.view);
3187 evas_object_smart_member_add(it->base.view, wd->pan_smart);
3188 evas_object_del(it->mode_view);
3189 it->mode_view = NULL;
3191 if (wd->mode_item == it)
3192 wd->mode_item = NULL;
3193 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3194 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3198 _item_mode_set(Elm_Genlist_Item *it)
3201 Widget_Data *wd = it->wd;
3206 it->nocache = EINA_TRUE;
3208 if (wd->scr_hold_timer)
3210 ecore_timer_del(wd->scr_hold_timer);
3211 wd->scr_hold_timer = NULL;
3213 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3214 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3216 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3217 _mode_item_realize(it);
3218 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
3219 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3220 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3222 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3223 edje_object_signal_emit(it->mode_view, buf, "elm");
3227 _item_mode_unset(Widget_Data *wd)
3230 if (!wd->mode_item) return;
3231 char buf[1024], buf2[1024];
3232 Elm_Genlist_Item *it;
3235 it->nocache = EINA_TRUE;
3237 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3238 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3240 edje_object_signal_emit(it->mode_view, buf, "elm");
3241 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3243 wd->mode_item = NULL;
3247 elm_genlist_add(Evas_Object *parent)
3252 Evas_Coord minw, minh;
3253 static Evas_Smart *smart = NULL;
3257 static Evas_Smart_Class sc;
3259 evas_object_smart_clipped_smart_set(&_pan_sc);
3261 sc.name = "elm_genlist_pan";
3262 sc.version = EVAS_SMART_CLASS_VERSION;
3265 sc.resize = _pan_resize;
3266 sc.move = _pan_move;
3267 sc.calculate = _pan_calculate;
3268 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3271 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3273 ELM_SET_WIDTYPE(widtype, "genlist");
3274 elm_widget_type_set(obj, "genlist");
3275 elm_widget_sub_object_add(parent, obj);
3276 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3277 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3278 elm_widget_data_set(obj, wd);
3279 elm_widget_del_hook_set(obj, _del_hook);
3280 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3281 elm_widget_theme_hook_set(obj, _theme_hook);
3282 elm_widget_can_focus_set(obj, EINA_TRUE);
3283 elm_widget_event_hook_set(obj, _event_hook);
3284 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3286 wd->scr = elm_smart_scroller_add(e);
3287 elm_smart_scroller_widget_set(wd->scr, obj);
3288 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3289 elm_widget_style_get(obj));
3290 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3291 _elm_config->thumbscroll_bounce_enable);
3292 elm_widget_resize_object_set(obj, wd->scr);
3294 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3295 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3297 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3298 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3302 wd->mode = ELM_LIST_SCROLL;
3303 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3304 wd->item_cache_max = wd->max_items_per_block * 2;
3305 wd->longpress_timeout = _elm_config->longpress_timeout;
3306 wd->effect_mode = _elm_config->effect_enable;
3308 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3309 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3310 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3311 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3313 wd->pan_smart = evas_object_smart_add(e, smart);
3314 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3317 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3318 _pan_set, _pan_get, _pan_max_get,
3319 _pan_min_get, _pan_child_size_get);
3321 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3323 evas_object_size_hint_min_set(obj, minw, minh);
3325 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3326 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3331 static Elm_Genlist_Item *
3332 _item_new(Widget_Data *wd,
3333 const Elm_Genlist_Item_Class *itc,
3335 Elm_Genlist_Item *parent,
3336 Elm_Genlist_Item_Flags flags,
3338 const void *func_data)
3340 Elm_Genlist_Item *it;
3342 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3343 if (!it) return NULL;
3346 it->base.data = data;
3347 it->parent = parent;
3349 it->func.func = func;
3350 it->func.data = func_data;
3351 it->mouse_cursor = NULL;
3352 it->expanded_depth = 0;
3356 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3357 it->group_item = parent;
3358 else if (it->parent->group_item)
3359 it->group_item = it->parent->group_item;
3365 _item_block_add(Widget_Data *wd,
3366 Elm_Genlist_Item *it)
3368 Item_Block *itb = NULL;
3375 itb = calloc(1, sizeof(Item_Block));
3378 if (!it->rel->block)
3381 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3382 itb->items = eina_list_append(itb->items, it);
3388 wd->blocks = eina_inlist_prepend_relative
3389 (wd->blocks, EINA_INLIST_GET(itb),
3390 EINA_INLIST_GET(it->rel->block));
3392 eina_list_prepend_relative(itb->items, it, it->rel);
3396 wd->blocks = eina_inlist_append_relative
3397 (wd->blocks, EINA_INLIST_GET(itb),
3398 EINA_INLIST_GET(it->rel->block));
3400 eina_list_append_relative(itb->items, it, it->rel);
3410 itb = (Item_Block *)(wd->blocks);
3411 if (itb->count >= wd->max_items_per_block)
3413 itb = calloc(1, sizeof(Item_Block));
3417 eina_inlist_prepend(wd->blocks,
3418 EINA_INLIST_GET(itb));
3423 itb = calloc(1, sizeof(Item_Block));
3427 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3429 itb->items = eina_list_prepend(itb->items, it);
3435 itb = (Item_Block *)(wd->blocks->last);
3436 if (itb->count >= wd->max_items_per_block)
3438 itb = calloc(1, sizeof(Item_Block));
3442 eina_inlist_append(wd->blocks,
3443 EINA_INLIST_GET(itb));
3448 itb = calloc(1, sizeof(Item_Block));
3452 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3454 itb->items = eina_list_append(itb->items, it);
3460 itb = it->rel->block;
3461 if (!itb) goto newblock;
3463 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3465 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3468 itb->changed = EINA_TRUE;
3470 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3471 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3474 it->rel->relcount--;
3475 if ((it->rel->delete_me) && (!it->rel->relcount))
3479 if (itb->count > itb->wd->max_items_per_block)
3483 Elm_Genlist_Item *it2;
3485 newc = itb->count / 2;
3486 itb2 = calloc(1, sizeof(Item_Block));
3490 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3491 EINA_INLIST_GET(itb));
3492 itb2->changed = EINA_TRUE;
3493 while ((itb->count > newc) && (itb->items))
3497 l = eina_list_last(itb->items);
3499 itb->items = eina_list_remove_list(itb->items, l);
3502 itb2->items = eina_list_prepend(itb2->items, it2);
3510 _queue_process(Widget_Data *wd)
3513 Eina_Bool showme = EINA_FALSE;
3516 t0 = ecore_time_get();
3517 //evas_event_freeze(evas_object_evas_get(wd->obj));
3518 for (n = 0; (wd->queue) && (n < 128); n++)
3520 Elm_Genlist_Item *it;
3522 it = wd->queue->data;
3523 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3524 it->queued = EINA_FALSE;
3525 _item_block_add(wd, it);
3526 t = ecore_time_get();
3527 if (it->block->changed)
3529 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3530 it->block->changed = 0;
3532 if (showme) it->block->showme = EINA_TRUE;
3533 if (eina_inlist_count(wd->blocks) > 1)
3535 if ((t - t0) > (ecore_animator_frametime_get())) break;
3538 //evas_event_thaw(evas_object_evas_get(wd->obj));
3539 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3544 _idle_process(void *data, Eina_Bool *wakeup)
3546 Widget_Data *wd = data;
3549 //static double q_start = 0.0;
3550 //if (q_start == 0.0) q_start = ecore_time_get();
3552 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3556 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3558 return ECORE_CALLBACK_CANCEL;
3560 return ECORE_CALLBACK_RENEW;
3564 _item_idle_enterer(void *data)
3566 Widget_Data *wd = data;
3567 Eina_Bool wakeup = EINA_FALSE;
3568 Eina_Bool ok = _idle_process(data, &wakeup);
3573 if (wd->calc_job) ecore_job_del(wd->calc_job);
3574 wd->calc_job = ecore_job_add(_calc_job, wd);
3576 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3581 _item_queue(Widget_Data *wd,
3582 Elm_Genlist_Item *it)
3584 if (it->queued) return;
3585 it->queued = EINA_TRUE;
3586 wd->queue = eina_list_append(wd->queue, it);
3587 // FIXME: why does a freeze then thaw here cause some genlist
3588 // elm_genlist_item_append() to be much much slower?
3589 // evas_event_freeze(evas_object_evas_get(wd->obj));
3590 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3592 if (wd->queue_idle_enterer)
3594 ecore_idle_enterer_del(wd->queue_idle_enterer);
3595 wd->queue_idle_enterer = NULL;
3599 // evas_event_thaw(evas_object_evas_get(wd->obj));
3600 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3601 if (!wd->queue_idle_enterer)
3602 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3606 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3611 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3612 it->wd->reorder_deleted = EINA_TRUE;
3613 _item_block_del(it);
3615 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3617 it->rel->relcount++;
3618 it->before = EINA_FALSE;
3619 if (after->group_item) it->group_item = after->group_item;
3620 _item_queue(it->wd, it);
3622 // TODO: change this to smart callback
3623 if (it->itc->func.moved)
3624 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
3628 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3631 if (!before) return;
3633 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3634 it->wd->reorder_deleted = EINA_TRUE;
3635 _item_block_del(it);
3636 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3638 it->rel->relcount++;
3639 it->before = EINA_TRUE;
3640 if (before->group_item) it->group_item = before->group_item;
3641 _item_queue(it->wd, it);
3643 // TODO: change this to smart callback
3644 if (it->itc->func.moved)
3645 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
3648 EAPI Elm_Genlist_Item *
3649 elm_genlist_item_append(Evas_Object *obj,
3650 const Elm_Genlist_Item_Class *itc,
3652 Elm_Genlist_Item *parent,
3653 Elm_Genlist_Item_Flags flags,
3655 const void *func_data)
3657 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3658 Widget_Data *wd = elm_widget_data_get(obj);
3659 if (!wd) return NULL;
3660 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3662 if (!it) return NULL;
3665 if (flags & ELM_GENLIST_ITEM_GROUP)
3666 wd->group_items = eina_list_append(wd->group_items, it);
3667 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3672 Elm_Genlist_Item *it2 = NULL;
3673 Eina_List *ll = eina_list_last(it->parent->items);
3674 if (ll) it2 = ll->data;
3675 it->parent->items = eina_list_append(it->parent->items, it);
3676 if (!it2) it2 = it->parent;
3678 it2 = elm_genlist_item_prev_get(it2);
3680 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3681 EINA_INLIST_GET(it2));
3683 it->rel->relcount++;
3685 it->before = EINA_FALSE;
3686 _item_queue(wd, it);
3690 EAPI Elm_Genlist_Item *
3691 elm_genlist_item_prepend(Evas_Object *obj,
3692 const Elm_Genlist_Item_Class *itc,
3694 Elm_Genlist_Item *parent,
3695 Elm_Genlist_Item_Flags flags,
3697 const void *func_data)
3699 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3700 Widget_Data *wd = elm_widget_data_get(obj);
3701 if (!wd) return NULL;
3702 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3704 if (!it) return NULL;
3707 if (flags & ELM_GENLIST_ITEM_GROUP)
3708 wd->group_items = eina_list_prepend(wd->group_items, it);
3709 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3714 Elm_Genlist_Item *it2 = NULL;
3715 Eina_List *ll = it->parent->items;
3716 if (ll) it2 = ll->data;
3717 it->parent->items = eina_list_prepend(it->parent->items, it);
3718 if (!it2) it2 = it->parent;
3720 it2 = elm_genlist_item_next_get(it2);
3722 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3723 EINA_INLIST_GET(it2));
3725 it->rel->relcount++;
3727 it->before = EINA_TRUE;
3728 _item_queue(wd, it);
3732 EAPI Elm_Genlist_Item *
3733 elm_genlist_item_insert_after(Evas_Object *obj,
3734 const Elm_Genlist_Item_Class *itc,
3736 Elm_Genlist_Item *parent,
3737 Elm_Genlist_Item *after,
3738 Elm_Genlist_Item_Flags flags,
3740 const void *func_data)
3742 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3743 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3744 Widget_Data *wd = elm_widget_data_get(obj);
3745 if (!wd) return NULL;
3746 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3748 if (!it) return NULL;
3749 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3750 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3754 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3755 (after->flags & ELM_GENLIST_ITEM_GROUP))
3756 wd->group_items = eina_list_append_relative(wd->group_items, it,
3761 it->parent->items = eina_list_append_relative(it->parent->items, it,
3764 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3765 EINA_INLIST_GET(after));
3767 it->rel->relcount++;
3768 it->before = EINA_FALSE;
3769 _item_queue(wd, it);
3773 EAPI Elm_Genlist_Item *
3774 elm_genlist_item_insert_before(Evas_Object *obj,
3775 const Elm_Genlist_Item_Class *itc,
3777 Elm_Genlist_Item *parent,
3778 Elm_Genlist_Item *before,
3779 Elm_Genlist_Item_Flags flags,
3781 const void *func_data)
3783 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3784 EINA_SAFETY_ON_NULL_RETURN_VAL(before, 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;
3790 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
3791 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3795 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3796 (before->flags & ELM_GENLIST_ITEM_GROUP))
3797 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
3802 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3805 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3806 EINA_INLIST_GET(before));
3808 it->rel->relcount++;
3809 it->before = EINA_TRUE;
3810 _item_queue(wd, it);
3815 elm_genlist_clear(Evas_Object *obj)
3817 ELM_CHECK_WIDTYPE(obj, widtype);
3818 Widget_Data *wd = elm_widget_data_get(obj);
3820 if (wd->walking > 0)
3822 Elm_Genlist_Item *it;
3824 wd->clear_me = EINA_TRUE;
3825 EINA_INLIST_FOREACH(wd->items, it)
3827 it->delete_me = EINA_TRUE;
3831 evas_event_freeze(evas_object_evas_get(wd->obj));
3834 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3835 it->nocache = EINA_TRUE;
3836 it->highlighted = EINA_FALSE;
3838 if (wd->anchor_item == it)
3840 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3841 if (!wd->anchor_item)
3843 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3846 wd->items = eina_inlist_remove(wd->items, wd->items);
3847 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3848 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3849 elm_widget_item_pre_notify_del(it);
3850 if (it->realized) _item_unrealize(it, EINA_FALSE);
3851 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3852 it->itc->func.del((void *)it->base.data, it->base.widget);
3853 if (it->long_timer) ecore_timer_del(it->long_timer);
3854 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3855 elm_widget_item_del(it);
3857 wd->clear_me = EINA_FALSE;
3858 wd->anchor_item = NULL;
3861 Item_Block *itb = (Item_Block *)(wd->blocks);
3863 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3864 if (itb->items) eina_list_free(itb->items);
3869 ecore_job_del(wd->calc_job);
3870 wd->calc_job = NULL;
3872 if (wd->queue_idle_enterer)
3874 ecore_idle_enterer_del(wd->queue_idle_enterer);
3875 wd->queue_idle_enterer = NULL;
3877 if (wd->must_recalc_idler)
3879 ecore_idler_del(wd->must_recalc_idler);
3880 wd->must_recalc_idler = NULL;
3884 eina_list_free(wd->queue);
3889 eina_list_free(wd->selected);
3890 wd->selected = NULL;
3892 if (wd->reorder_move_animator)
3894 ecore_animator_del(wd->reorder_move_animator);
3895 wd->reorder_move_animator = NULL;
3897 wd->show_item = NULL;
3905 evas_object_del(wd->alpha_bg);
3906 wd->alpha_bg = NULL;
3910 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3911 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3914 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
3915 evas_event_thaw(evas_object_evas_get(wd->obj));
3916 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3920 elm_genlist_multi_select_set(Evas_Object *obj,
3923 ELM_CHECK_WIDTYPE(obj, widtype);
3924 Widget_Data *wd = elm_widget_data_get(obj);
3930 elm_genlist_multi_select_get(const Evas_Object *obj)
3932 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3933 Widget_Data *wd = elm_widget_data_get(obj);
3934 if (!wd) return EINA_FALSE;
3938 EAPI Elm_Genlist_Item *
3939 elm_genlist_selected_item_get(const Evas_Object *obj)
3941 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3942 Widget_Data *wd = elm_widget_data_get(obj);
3943 if (!wd) return NULL;
3944 if (wd->selected) return wd->selected->data;
3948 EAPI const Eina_List *
3949 elm_genlist_selected_items_get(const Evas_Object *obj)
3951 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3952 Widget_Data *wd = elm_widget_data_get(obj);
3953 if (!wd) return NULL;
3954 return wd->selected;
3958 elm_genlist_realized_items_get(const Evas_Object *obj)
3960 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3961 Widget_Data *wd = elm_widget_data_get(obj);
3962 Eina_List *list = NULL;
3964 Eina_Bool done = EINA_FALSE;
3965 if (!wd) return NULL;
3966 EINA_INLIST_FOREACH(wd->blocks, itb)
3971 Elm_Genlist_Item *it;
3974 EINA_LIST_FOREACH(itb->items, l, it)
3976 if (it->realized) list = eina_list_append(list, it);
3987 EAPI Elm_Genlist_Item *
3988 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3993 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3994 Widget_Data *wd = elm_widget_data_get(obj);
3995 Evas_Coord ox, oy, ow, oh;
3998 if (!wd) return NULL;
3999 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4001 EINA_INLIST_FOREACH(wd->blocks, itb)
4004 Elm_Genlist_Item *it;
4006 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4007 oy + itb->y - itb->wd->pan_y,
4008 itb->w, itb->h, x, y, 1, 1))
4010 EINA_LIST_FOREACH(itb->items, l, it)
4012 Evas_Coord itx, ity;
4014 itx = ox + itb->x + it->x - itb->wd->pan_x;
4015 ity = oy + itb->y + it->y - itb->wd->pan_y;
4016 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4020 if (y <= (ity + (it->h / 4))) *posret = -1;
4021 else if (y >= (ity + it->h - (it->h / 4)))
4027 lasty = ity + it->h;
4032 if (y > lasty) *posret = 1;
4038 EAPI Elm_Genlist_Item *
4039 elm_genlist_first_item_get(const Evas_Object *obj)
4041 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4042 Widget_Data *wd = elm_widget_data_get(obj);
4043 if (!wd) return NULL;
4044 if (!wd->items) return NULL;
4045 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4046 while ((it) && (it->delete_me))
4047 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4051 EAPI Elm_Genlist_Item *
4052 elm_genlist_last_item_get(const Evas_Object *obj)
4054 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4055 Widget_Data *wd = elm_widget_data_get(obj);
4056 if (!wd) return NULL;
4057 if (!wd->items) return NULL;
4058 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4059 while ((it) && (it->delete_me))
4060 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4064 EAPI Elm_Genlist_Item *
4065 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4067 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4070 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4071 if ((it) && (!it->delete_me)) break;
4073 return (Elm_Genlist_Item *)it;
4076 EAPI Elm_Genlist_Item *
4077 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4079 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4082 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4083 if ((it) && (!it->delete_me)) break;
4085 return (Elm_Genlist_Item *)it;
4089 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4091 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4092 return it->base.widget;
4095 EAPI Elm_Genlist_Item *
4096 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4098 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4103 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4105 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4106 Elm_Genlist_Item *it2;
4109 if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4110 _item_subitems_clear(it);
4113 if ((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4114 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4116 it->wd->expand_item = it;
4117 _item_flip_effect_show(it);
4118 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4119 it->wd->expand_item_end = y + h;
4123 it2 = elm_genlist_item_next_get(it2);
4125 } while (it2->expanded_depth > it->expanded_depth);
4127 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4129 it->wd->expand_item_gap = 0;
4131 evas_object_raise(it->wd->alpha_bg);
4132 evas_object_show(it->wd->alpha_bg);
4134 it->wd->start_time = current_time_get();
4135 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4138 _item_subitems_clear(it);
4143 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4146 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4147 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4149 if ((it->delete_me) || (it->disabled)) return;
4150 selected = !!selected;
4151 if (it->selected == selected) return;
4157 while (wd->selected)
4158 _item_unselect(wd->selected->data);
4160 _item_highlight(it);
4168 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4170 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4171 return it->selected;
4175 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4178 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4179 if (it->flags != ELM_GENLIST_ITEM_SUBITEMS) return;
4180 if (it->expanded == expanded) return;
4181 it->expanded = expanded;
4182 it->wd->expand_item = it;
4184 if (it->wd->effect_mode && !it->wd->alpha_bg)
4185 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4189 it->wd->auto_scrolled = EINA_FALSE;
4190 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4192 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4193 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4197 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4199 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4200 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4205 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4207 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4208 return it->expanded;
4212 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4214 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4215 return it->expanded_depth;
4219 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4222 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4225 if (it->disabled == disabled) return;
4226 if (it->delete_me) return;
4227 it->disabled = disabled;
4229 elm_genlist_item_selected_set(it, EINA_FALSE);
4234 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4236 edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
4240 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4242 edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
4244 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4245 elm_widget_disabled_set(obj, disabled);
4250 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4252 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4253 if (it->delete_me) return EINA_FALSE;
4254 return it->disabled;
4258 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4259 Eina_Bool display_only)
4261 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4262 if (it->display_only == display_only) return;
4263 if (it->delete_me) return;
4264 it->display_only = display_only;
4265 it->mincalcd = EINA_FALSE;
4266 it->updateme = EINA_TRUE;
4267 if (it->block) it->block->updateme = EINA_TRUE;
4268 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4269 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4273 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4275 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4276 if (it->delete_me) return EINA_FALSE;
4277 return it->display_only;
4281 elm_genlist_item_show(Elm_Genlist_Item *it)
4283 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4284 Evas_Coord gith = 0;
4285 if (it->delete_me) return;
4286 if ((it->queued) || (!it->mincalcd))
4288 it->wd->show_item = it;
4289 it->wd->bring_in = EINA_TRUE;
4290 it->showme = EINA_TRUE;
4293 if (it->wd->show_item)
4295 it->wd->show_item->showme = EINA_FALSE;
4296 it->wd->show_item = NULL;
4298 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4299 gith = it->group_item->h;
4300 elm_smart_scroller_child_region_show(it->wd->scr,
4301 it->x + it->block->x,
4302 it->y + it->block->y - gith,
4303 it->block->w, it->h);
4307 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4309 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4310 Evas_Coord gith = 0;
4311 if (it->delete_me) return;
4312 if ((it->queued) || (!it->mincalcd))
4314 it->wd->show_item = it;
4315 it->wd->bring_in = EINA_TRUE;
4316 it->showme = EINA_TRUE;
4319 if (it->wd->show_item)
4321 it->wd->show_item->showme = EINA_FALSE;
4322 it->wd->show_item = NULL;
4324 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4325 gith = it->group_item->h;
4326 elm_smart_scroller_region_bring_in(it->wd->scr,
4327 it->x + it->block->x,
4328 it->y + it->block->y - gith,
4329 it->block->w, it->h);
4333 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4335 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4337 Evas_Coord gith = 0;
4339 if (it->delete_me) return;
4340 if ((it->queued) || (!it->mincalcd))
4342 it->wd->show_item = it;
4343 it->wd->bring_in = EINA_TRUE;
4344 it->showme = EINA_TRUE;
4347 if (it->wd->show_item)
4349 it->wd->show_item->showme = EINA_FALSE;
4350 it->wd->show_item = NULL;
4352 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4353 if (it->group_item) gith = it->group_item->h;
4354 elm_smart_scroller_child_region_show(it->wd->scr,
4355 it->x + it->block->x,
4356 it->y + it->block->y - gith,
4361 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4363 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4365 Evas_Coord gith = 0;
4367 if (it->delete_me) return;
4368 if ((it->queued) || (!it->mincalcd))
4370 it->wd->show_item = it;
4371 it->wd->bring_in = EINA_TRUE;
4372 it->showme = EINA_TRUE;
4375 if (it->wd->show_item)
4377 it->wd->show_item->showme = EINA_FALSE;
4378 it->wd->show_item = NULL;
4380 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4381 if (it->group_item) gith = it->group_item->h;
4382 elm_smart_scroller_region_bring_in(it->wd->scr,
4383 it->x + it->block->x,
4384 it->y + it->block->y - gith,
4389 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4391 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4394 if (it->delete_me) return;
4395 if ((it->queued) || (!it->mincalcd))
4397 it->wd->show_item = it;
4398 it->wd->bring_in = EINA_TRUE;
4399 it->showme = EINA_TRUE;
4402 if (it->wd->show_item)
4404 it->wd->show_item->showme = EINA_FALSE;
4405 it->wd->show_item = NULL;
4407 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4408 elm_smart_scroller_child_region_show(it->wd->scr,
4409 it->x + it->block->x,
4410 it->y + it->block->y - oh / 2 +
4411 it->h / 2, it->block->w, oh);
4415 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4417 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4420 if (it->delete_me) return;
4421 if ((it->queued) || (!it->mincalcd))
4423 it->wd->show_item = it;
4424 it->wd->bring_in = EINA_TRUE;
4425 it->showme = EINA_TRUE;
4428 if (it->wd->show_item)
4430 it->wd->show_item->showme = EINA_FALSE;
4431 it->wd->show_item = NULL;
4433 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4434 elm_smart_scroller_region_bring_in(it->wd->scr,
4435 it->x + it->block->x,
4436 it->y + it->block->y - oh / 2 + it->h / 2,
4441 elm_genlist_item_del(Elm_Genlist_Item *it)
4443 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4444 if ((it->relcount > 0) || (it->walking > 0))
4446 elm_widget_item_pre_notify_del(it);
4447 elm_genlist_item_subitems_clear(it);
4448 it->delete_me = EINA_TRUE;
4449 if (it->wd->show_item == it) it->wd->show_item = NULL;
4451 it->wd->selected = eina_list_remove(it->wd->selected,
4455 if (it->realized) _item_unrealize(it, EINA_FALSE);
4456 it->block->changed = EINA_TRUE;
4457 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4458 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4460 if (it->itc->func.del)
4461 it->itc->func.del((void *)it->base.data, it->base.widget);
4468 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4471 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4472 elm_widget_item_data_set(it, data);
4473 elm_genlist_item_update(it);
4477 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4479 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4480 return elm_widget_item_data_get(it);
4484 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4487 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4488 EINA_LIST_FREE(it->icon_objs, icon)
4490 elm_widget_sub_object_del(it->base.widget, icon);
4491 evas_object_smart_member_del(icon);
4492 evas_object_hide(icon);
4496 EAPI const Evas_Object *
4497 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4499 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4500 return it->base.view;
4504 elm_genlist_item_update(Elm_Genlist_Item *it)
4506 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4507 if (!it->block) return;
4508 if (it->delete_me) return;
4509 it->mincalcd = EINA_FALSE;
4510 it->updateme = EINA_TRUE;
4511 it->block->updateme = EINA_TRUE;
4512 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4513 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4514 it->defer_unrealize = EINA_FALSE;
4518 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4519 const Elm_Genlist_Item_Class *itc)
4521 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4522 if (!it->block) return;
4523 EINA_SAFETY_ON_NULL_RETURN(itc);
4524 if (it->delete_me) return;
4526 it->nocache = EINA_TRUE;
4527 elm_genlist_item_update(it);
4530 EAPI const Elm_Genlist_Item_Class *
4531 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4533 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4534 if (it->delete_me) return NULL;
4537 static Evas_Object *
4538 _elm_genlist_item_label_create(void *data,
4540 void *item __UNUSED__)
4542 Evas_Object *label = elm_label_add(obj);
4545 elm_object_style_set(label, "tooltip");
4546 elm_object_text_set(label, data);
4551 _elm_genlist_item_label_del_cb(void *data,
4552 Evas_Object *obj __UNUSED__,
4553 void *event_info __UNUSED__)
4555 eina_stringshare_del(data);
4559 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4562 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4563 text = eina_stringshare_add(text);
4564 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4566 _elm_genlist_item_label_del_cb);
4570 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4571 Elm_Tooltip_Item_Content_Cb func,
4573 Evas_Smart_Cb del_cb)
4575 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4577 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4580 if (item->tooltip.del_cb)
4581 item->tooltip.del_cb((void *)item->tooltip.data,
4582 item->base.widget, item);
4584 item->tooltip.content_cb = func;
4585 item->tooltip.data = data;
4586 item->tooltip.del_cb = del_cb;
4588 if (item->base.view)
4590 elm_widget_item_tooltip_content_cb_set(item,
4591 item->tooltip.content_cb,
4592 item->tooltip.data, NULL);
4593 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4599 if (del_cb) del_cb((void *)data, NULL, NULL);
4603 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4605 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4606 if ((item->base.view) && (item->tooltip.content_cb))
4607 elm_widget_item_tooltip_unset(item);
4609 if (item->tooltip.del_cb)
4610 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4611 item->tooltip.del_cb = NULL;
4612 item->tooltip.content_cb = NULL;
4613 item->tooltip.data = NULL;
4614 if (item->tooltip.style)
4615 elm_genlist_item_tooltip_style_set(item, NULL);
4619 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4622 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4623 eina_stringshare_replace(&item->tooltip.style, style);
4624 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4628 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4630 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4631 return item->tooltip.style;
4635 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4638 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4639 eina_stringshare_replace(&item->mouse_cursor, cursor);
4640 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4644 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4646 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4647 return elm_widget_item_cursor_get(item);
4651 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4653 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4654 if (!item->mouse_cursor)
4657 if (item->base.view)
4658 elm_widget_item_cursor_unset(item);
4660 eina_stringshare_del(item->mouse_cursor);
4661 item->mouse_cursor = NULL;
4665 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4668 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4669 elm_widget_item_cursor_style_set(item, style);
4673 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4675 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4676 return elm_widget_item_cursor_style_get(item);
4680 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4681 Eina_Bool engine_only)
4683 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4684 elm_widget_item_cursor_engine_only_set(item, engine_only);
4688 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4690 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4691 return elm_widget_item_cursor_engine_only_get(item);
4695 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4698 ELM_CHECK_WIDTYPE(obj, widtype);
4699 Widget_Data *wd = elm_widget_data_get(obj);
4701 if (wd->mode == mode) return;
4707 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4709 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4710 Widget_Data *wd = elm_widget_data_get(obj);
4711 if (!wd) return ELM_LIST_LAST;
4716 elm_genlist_always_select_mode_set(Evas_Object *obj,
4717 Eina_Bool always_select)
4719 ELM_CHECK_WIDTYPE(obj, widtype);
4720 Widget_Data *wd = elm_widget_data_get(obj);
4722 wd->always_select = always_select;
4726 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4728 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4729 Widget_Data *wd = elm_widget_data_get(obj);
4730 if (!wd) return EINA_FALSE;
4731 return wd->always_select;
4735 elm_genlist_no_select_mode_set(Evas_Object *obj,
4736 Eina_Bool no_select)
4738 ELM_CHECK_WIDTYPE(obj, widtype);
4739 Widget_Data *wd = elm_widget_data_get(obj);
4741 wd->no_select = no_select;
4745 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4747 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4748 Widget_Data *wd = elm_widget_data_get(obj);
4749 if (!wd) return EINA_FALSE;
4750 return wd->no_select;
4754 elm_genlist_compress_mode_set(Evas_Object *obj,
4757 ELM_CHECK_WIDTYPE(obj, widtype);
4758 Widget_Data *wd = elm_widget_data_get(obj);
4760 wd->compress = compress;
4764 elm_genlist_compress_mode_get(const Evas_Object *obj)
4766 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4767 Widget_Data *wd = elm_widget_data_get(obj);
4768 if (!wd) return EINA_FALSE;
4769 return wd->compress;
4773 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4774 Eina_Bool height_for_width)
4776 ELM_CHECK_WIDTYPE(obj, widtype);
4777 Widget_Data *wd = elm_widget_data_get(obj);
4779 wd->height_for_width = !!height_for_width;
4780 if (wd->height_for_width)
4782 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4783 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4788 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4790 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4791 Widget_Data *wd = elm_widget_data_get(obj);
4792 if (!wd) return EINA_FALSE;
4793 return wd->height_for_width;
4797 elm_genlist_bounce_set(Evas_Object *obj,
4801 ELM_CHECK_WIDTYPE(obj, widtype);
4802 Widget_Data *wd = elm_widget_data_get(obj);
4804 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4808 elm_genlist_bounce_get(const Evas_Object *obj,
4809 Eina_Bool *h_bounce,
4810 Eina_Bool *v_bounce)
4812 ELM_CHECK_WIDTYPE(obj, widtype);
4813 Widget_Data *wd = elm_widget_data_get(obj);
4815 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4819 elm_genlist_homogeneous_set(Evas_Object *obj,
4820 Eina_Bool homogeneous)
4822 ELM_CHECK_WIDTYPE(obj, widtype);
4823 Widget_Data *wd = elm_widget_data_get(obj);
4825 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4826 wd->homogeneous = homogeneous;
4830 elm_genlist_homogeneous_get(const Evas_Object *obj)
4832 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4833 Widget_Data *wd = elm_widget_data_get(obj);
4834 if (!wd) return EINA_FALSE;
4835 return wd->homogeneous;
4839 elm_genlist_block_count_set(Evas_Object *obj,
4842 ELM_CHECK_WIDTYPE(obj, widtype);
4843 Widget_Data *wd = elm_widget_data_get(obj);
4845 wd->max_items_per_block = n;
4846 wd->item_cache_max = wd->max_items_per_block * 2;
4847 _item_cache_clean(wd);
4851 elm_genlist_block_count_get(const Evas_Object *obj)
4853 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4854 Widget_Data *wd = elm_widget_data_get(obj);
4856 return wd->max_items_per_block;
4860 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4863 ELM_CHECK_WIDTYPE(obj, widtype);
4864 Widget_Data *wd = elm_widget_data_get(obj);
4866 wd->longpress_timeout = timeout;
4870 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4872 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4873 Widget_Data *wd = elm_widget_data_get(obj);
4875 return wd->longpress_timeout;
4879 elm_genlist_scroller_policy_set(Evas_Object *obj,
4880 Elm_Scroller_Policy policy_h,
4881 Elm_Scroller_Policy policy_v)
4883 ELM_CHECK_WIDTYPE(obj, widtype);
4884 Widget_Data *wd = elm_widget_data_get(obj);
4886 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4887 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4890 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4894 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4895 Elm_Scroller_Policy *policy_h,
4896 Elm_Scroller_Policy *policy_v)
4898 ELM_CHECK_WIDTYPE(obj, widtype);
4899 Widget_Data *wd = elm_widget_data_get(obj);
4900 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4901 if ((!wd) || (!wd->scr)) return;
4902 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4903 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4904 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
4908 elm_genlist_realized_items_update(Evas_Object *obj)
4910 ELM_CHECK_WIDTYPE(obj, widtype);
4912 Eina_List *list, *l;
4913 Elm_Genlist_Item *it;
4915 list = elm_genlist_realized_items_get(obj);
4916 EINA_LIST_FOREACH(list, l, it)
4917 elm_genlist_item_update(it);
4921 * Set genlist item mode
4923 * @param item The genlist item
4924 * @param mode Mode name
4925 * @param mode_set Boolean to define set or unset mode.
4930 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
4931 const char *mode_type,
4934 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4935 Widget_Data *wd = it->wd;
4937 Elm_Genlist_Item *it2;
4940 if (!mode_type) return;
4941 if ((it->delete_me) || (it->disabled)) return;
4942 if (wd->edit_mode) return;
4944 if ((wd->mode_item == it) &&
4945 (!strcmp(mode_type, wd->mode_type)) &&
4948 if (!it->itc->mode_item_style) return;
4952 EINA_LIST_FOREACH(wd->selected, l, it2)
4954 elm_genlist_item_selected_set(it2, EINA_FALSE);
4958 it2 = elm_genlist_selected_item_get(wd->obj);
4959 if ((it2) && (it2->realized))
4960 elm_genlist_item_selected_set(it2, EINA_FALSE);
4963 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
4965 ((it == wd->mode_item) && (!mode_set)))
4966 _item_mode_unset(wd);
4968 eina_stringshare_replace(&wd->mode_type, mode_type);
4969 if (mode_set) _item_mode_set(it);
4973 * Get active genlist mode type
4975 * @param obj The genlist object
4980 elm_genlist_mode_get(const Evas_Object *obj)
4982 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4983 Widget_Data *wd = elm_widget_data_get(obj);
4984 if (!wd) return NULL;
4985 return wd->mode_type;
4989 * Get active genlist mode item
4991 * @param obj The genlist object
4995 EAPI const Elm_Genlist_Item *
4996 elm_genlist_mode_item_get(const Evas_Object *obj)
4998 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4999 Widget_Data *wd = elm_widget_data_get(obj);
5000 if (!wd) return NULL;
5001 return wd->mode_item;
5005 elm_genlist_reorder_mode_set(Evas_Object *obj,
5006 Eina_Bool reorder_mode)
5008 ELM_CHECK_WIDTYPE(obj, widtype);
5009 Widget_Data *wd = elm_widget_data_get(obj);
5011 wd->reorder_mode = reorder_mode;
5015 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5017 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5018 Widget_Data *wd = elm_widget_data_get(obj);
5019 if (!wd) return EINA_FALSE;
5020 return wd->reorder_mode;
5024 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
5030 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
5036 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5038 ELM_CHECK_WIDTYPE(obj, widtype);
5039 Widget_Data *wd = elm_widget_data_get(obj);
5041 wd->effect_mode = emode;
5042 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5043 // evas_object_resize(wd->point_rect, 10, 25);
5044 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5045 // evas_object_show(wd->point_rect);
5046 // evas_object_hide(wd->point_rect);
5050 _create_tray_alpha_bg(const Evas_Object *obj)
5052 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5053 Widget_Data *wd = elm_widget_data_get(obj);
5054 if (!wd) return NULL;
5056 Evas_Object *bg = NULL;
5057 Evas_Coord ox, oy, ow, oh;
5059 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5060 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5061 evas_object_color_set(bg,0,0,0,0);
5062 evas_object_resize(bg , ow, oh);
5063 evas_object_move(bg , ox, oy);
5064 evas_object_show(bg);
5065 evas_object_hide(bg);
5072 struct timeval timev;
5074 gettimeofday(&timev, NULL);
5075 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5078 // added for item moving animation.
5080 _item_moving_effect_timer_cb(void *data)
5082 Widget_Data *wd = data;
5083 if (!wd) return EINA_FALSE;
5085 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5086 Elm_Genlist_Item *it = NULL, *it2;
5088 double time = 0.3, t;
5090 Eina_Bool check, end = EINA_FALSE;
5093 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5095 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5096 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5097 if (t > time) end = EINA_TRUE;
5099 it2 = elm_genlist_item_next_get(wd->expand_item);
5102 if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5103 it2 = elm_genlist_item_next_get(it2);
5108 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5109 dy = it2->scrl_y - it2->old_scrl_y;
5110 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5111 dy = wd->expand_item_gap;
5115 y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5124 EINA_INLIST_FOREACH(wd->blocks, itb)
5127 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5128 itb->y - wd->pan_y + oy,
5130 cvx, cvy, cvw, cvh))
5132 EINA_LIST_FOREACH(itb->items, l, it)
5134 if (it == it2) check = EINA_TRUE;
5135 if (!check) continue;
5137 if (!it->old_scrl_y)
5138 it->old_scrl_y = it->scrl_y;
5139 if (it->old_scrl_y + y < oy + oh)
5141 if (!it->realized) _item_realize(it, in, 0);
5143 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5144 it->old_scrl_y = it->scrl_y - y;
5147 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5148 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5150 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5153 evas_object_resize(it->base.view, it->w, it->h);
5154 evas_object_move(it->base.view, it->scrl_x, it->old_scrl_y + y);
5155 evas_object_show(it->base.view);
5156 evas_object_raise(it->base.view);
5159 if (it->group_item) evas_object_raise(it->group_item->base.view);
5165 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5167 it = elm_genlist_item_prev_get(it2);
5170 if (it->expanded_depth <= it2->expanded_depth) break;
5171 if ((it->scrl_y < it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5173 if (!it->effect_done)
5175 edje_object_signal_emit(it->base.view, "flip_item", "");
5176 evas_object_show(it->base.view);
5177 it->effect_done = EINA_TRUE;
5180 it = elm_genlist_item_prev_get(it);
5183 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5185 it = elm_genlist_item_prev_get(it2);
5188 if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5190 if (!it->effect_done)
5192 edje_object_signal_emit(it->base.view, "elm,state,hide", "");
5193 it->effect_done = EINA_TRUE;
5198 it = elm_genlist_item_prev_get(it);
5205 int expand_order = 0;
5206 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5210 it = elm_genlist_item_next_get(it);
5212 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5216 if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
5217 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5219 if (!it->effect_done)
5221 if (t >= (((expand_order - 1) * time) / expand_num))
5223 edje_object_signal_emit(it->base.view, "flip_item", "");
5224 evas_object_show(it->base.view);
5225 it->effect_done = EINA_TRUE;
5229 it = elm_genlist_item_next_get(it);
5235 if (wd->item_moving_effect_timer)
5237 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5238 _item_subitems_clear(wd->expand_item);
5239 EINA_INLIST_FOREACH(wd->blocks, itb)
5241 EINA_LIST_FOREACH(itb->items, l, it)
5243 it->effect_done = EINA_TRUE;
5244 it->old_scrl_y = it->scrl_y;
5248 wd->item_moving_effect_timer = NULL;
5250 _item_auto_scroll(wd);
5251 evas_object_lower(wd->alpha_bg);
5252 evas_object_hide(wd->alpha_bg);
5253 if (wd->calc_job) ecore_job_del(wd->calc_job);
5254 wd->calc_job = ecore_job_add(_calc_job, wd);
5255 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5256 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5258 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5259 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5260 return ECORE_CALLBACK_CANCEL;
5262 return ECORE_CALLBACK_RENEW;
5266 _emit_contract(Elm_Genlist_Item *it)
5268 Elm_Genlist_Item *it2;
5271 // printf("%p is emited contract\n", it);
5272 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5273 it->effect_done = EINA_FALSE;
5275 EINA_LIST_FOREACH(it->items, l, it2)
5277 _emit_contract(it2);
5280 // added for item moving animation.
5282 _item_flip_effect_show(Elm_Genlist_Item *it)
5284 Elm_Genlist_Item *it2;
5286 Widget_Data *wd = it->wd;
5287 Eina_Bool check = EINA_FALSE;
5289 it2 = elm_genlist_item_next_get(it);
5292 if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5293 it2 = elm_genlist_item_next_get(it2);
5295 EINA_LIST_FOREACH(it->items, l, it2)
5297 if (it2->parent && it == it2->parent)
5299 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5300 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5301 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5302 _emit_contract(it2);
5306 return ECORE_CALLBACK_CANCEL;
5311 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5313 printf("!!! NOW FIXING \n");
5318 * Set pinch zoom mode
5320 * @param obj The genlist object
5322 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5327 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5329 printf("!!! NOW FIXING \n");
5333 * Get pinch zoom mode
5335 * @param obj The genlist object
5336 * @return The pinch mode
5337 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5342 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
5344 printf("!!! NOW FIXING \n");
5349 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5351 printf("!!! NOW FIXING \n");
5355 ////////////////////////////////////////////////////////////////////////
5357 ////////////////////////////////////////////////////////////////////////
5360 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5362 if (!it->wd->edit_mode) return;
5363 evas_object_resize(it->edit_obj,it->w, it->h);
5364 evas_object_move(it->edit_obj, itx, ity);
5368 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5370 if ((it->effect_item_realized) || (it->delete_me)) return;
5374 _mode_finished_signal_cb(it, (Evas_Object *)elm_genlist_item_object_get(it), NULL, NULL);
5376 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
5377 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
5378 _elm_config->scale);
5379 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5380 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
5382 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5383 else strncpy(buf, "item", sizeof(buf));
5384 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5386 strncat(buf, "/", sizeof(buf) - strlen(buf));
5388 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5390 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
5391 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
5395 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget));
5398 if (it->wd->reorder_mode)
5400 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
5401 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
5403 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
5404 else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
5406 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
5407 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
5410 if ((it->wd->edit_mode))
5412 if (it->itc->func.icon_get)
5417 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5418 EINA_LIST_FOREACH(it->icons, l, key)
5420 Evas_Object *ic = it->itc->func.icon_get
5421 ((void *)it->base.data, it->base.widget, l->data);
5425 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5426 edje_object_part_swallow(it->edit_obj, key, ic);
5427 evas_object_show(ic);
5428 elm_widget_sub_object_add(it->base.widget, ic);
5430 elm_widget_disabled_set(ic, EINA_TRUE);
5435 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
5436 _effect_item_controls(it,it->scrl_x, it->scrl_y);
5437 evas_object_show(it->edit_obj);
5439 it->effect_item_realized = EINA_TRUE;
5440 it->want_unrealize = EINA_FALSE;
5444 _effect_item_unrealize(Elm_Genlist_Item *it)
5448 if (!it->effect_item_realized) return;
5449 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5451 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
5452 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
5453 edje_object_message_signal_process(it->edit_obj);
5454 edje_object_part_unswallow(it->edit_obj, it->base.view);
5455 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
5456 elm_widget_sub_object_add(it->base.widget, it->base.view);
5457 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5458 // _item_cache_add(it);
5459 evas_object_del(it->edit_obj);
5460 it->edit_obj = NULL;
5461 EINA_LIST_FREE(it->edit_icon_objs, icon)
5462 evas_object_del(icon);
5464 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5465 it->effect_item_realized = EINA_FALSE;
5469 * Get Genlist edit mode
5471 * @param obj The genlist object
5472 * @return The edit mode status
5473 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5478 elm_genlist_edit_mode_get(const Evas_Object *obj)
5480 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5481 Widget_Data *wd = elm_widget_data_get(obj);
5482 if (!wd) return EINA_FALSE;
5484 if (wd->edit_mode) return EINA_TRUE;
5485 else return EINA_FALSE;
5489 * Set Genlist edit mode
5491 * This sets Genlist edit mode.
5493 * @param obj The Genlist object
5494 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5495 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5500 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5502 ELM_CHECK_WIDTYPE(obj, widtype);
5506 Elm_Genlist_Item *it;
5508 Widget_Data *wd = elm_widget_data_get(obj);
5510 if (wd->edit_mode == edit_mode) return;
5512 wd->edit_mode = edit_mode;
5515 EINA_INLIST_FOREACH(wd->blocks, itb)
5519 EINA_LIST_FOREACH(itb->items, l, it)
5521 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5523 _effect_item_unrealize(it);
5528 _item_cache_zero(wd);
5533 EINA_INLIST_FOREACH(wd->blocks, itb)
5537 EINA_LIST_FOREACH(itb->items, l, it)
5539 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5541 if(it->selected) _item_unselect(it);
5542 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
5549 if (wd->calc_job) ecore_job_del(wd->calc_job);
5550 wd->calc_job = ecore_job_add(_calc_job, wd);
5554 * Set a given item's rename mode
5556 * This renames the item's label from genlist
5558 * @param it The item
5559 * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
5564 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
5570 _item_unrealize(it, EINA_FALSE);
5571 it->renamed = EINA_TRUE;
5572 it->wd->rename_it = it;
5573 it->nocache = EINA_TRUE;
5574 if (it->selected) _item_unselect(it);
5576 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5577 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5583 it->renamed = EINA_FALSE;
5584 it->nocache = EINA_TRUE;
5585 it->wd->rename_it = NULL;
5586 _item_cache_zero(it->wd);
5587 elm_genlist_item_update(it);
5593 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
5595 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5596 return item->renamed;
5600 _item_auto_scroll(void *data)
5602 Widget_Data *wd = data;
5605 if ((wd->expand_item) && (!wd->auto_scrolled))
5607 Elm_Genlist_Item *it;
5609 Evas_Coord ox, oy, ow, oh;
5610 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
5612 wd->auto_scrolled = EINA_TRUE;
5613 if (wd->expand_item->scrl_y > (oh + oy) / 2)
5615 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
5617 elm_genlist_item_bring_in(it);