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;
176 Eina_Bool effect_done : 1;
177 Eina_Bool reordering : 1;
178 Eina_Bool renamed : 1;
179 Eina_Bool effect_item_realized : 1;
180 Eina_List *edit_icon_objs;
181 Evas_Object *edit_obj;
183 Ecore_Animator *item_moving_effect_timer;
184 Evas_Coord old_scrl_y;
191 Evas_Object *base_view, *spacer;
193 const char *item_style; // it->itc->item_style
194 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
195 Eina_Bool compress : 1; // it->wd->compress
196 Eina_Bool odd : 1; // in & 0x1
198 Eina_Bool selected : 1; // it->selected
199 Eina_Bool disabled : 1; // it->disabled
200 Eina_Bool expanded : 1; // it->expanded
203 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
204 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
208 Evas_Object_Smart_Clipped_Data __clipped_data;
210 Ecore_Job *resize_job;
213 static const char *widtype = NULL;
214 static void _item_cache_zero(Widget_Data *wd);
215 static void _del_hook(Evas_Object *obj);
216 static void _mirrored_set(Evas_Object *obj,
218 static void _theme_hook(Evas_Object *obj);
219 static void _show_region_hook(void *data,
221 static void _sizing_eval(Evas_Object *obj);
222 static void _item_realize(Elm_Genlist_Item *it,
225 static void _item_unrealize(Elm_Genlist_Item *it,
227 static void _item_block_unrealize(Item_Block *itb);
228 static void _calc_job(void *data);
229 static void _on_focus_hook(void *data,
231 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
232 static void _changed_job(void *data);
233 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
234 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
235 static Eina_Bool _item_single_select_up(Widget_Data *wd);
236 static Eina_Bool _item_single_select_down(Widget_Data *wd);
237 static Eina_Bool _event_hook(Evas_Object *obj,
239 Evas_Callback_Type type,
241 static void _signal_emit_hook(Evas_Object *obj,
242 const char *emission,
244 static Eina_Bool _deselect_all_items(Widget_Data *wd);
245 static void _pan_calculate(Evas_Object *obj);
246 static void _item_position(Elm_Genlist_Item *it,
250 static void _mode_item_realize(Elm_Genlist_Item *it);
251 static void _mode_item_unrealize(Elm_Genlist_Item *it);
252 static void _item_mode_set(Elm_Genlist_Item *it);
253 static void _item_mode_unset(Widget_Data *wd);
254 static void _group_items_recalc(void *data);
255 static void _item_move_after(Elm_Genlist_Item *it,
256 Elm_Genlist_Item *after);
257 static void _item_move_before(Elm_Genlist_Item *it,
258 Elm_Genlist_Item *before);
260 // TODO : refactoring
261 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
262 static unsigned int current_time_get();
263 static Eina_Bool _item_moving_effect_timer_cb(void *data);
264 static int _item_flip_effect_show(Elm_Genlist_Item *it);
265 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
266 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
267 static void _effect_item_unrealize(Elm_Genlist_Item *it);
268 static void _item_auto_scroll(void *data);
270 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
272 static const char SIG_ACTIVATED[] = "activated";
273 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
274 static const char SIG_SELECTED[] = "selected";
275 static const char SIG_UNSELECTED[] = "unselected";
276 static const char SIG_EXPANDED[] = "expanded";
277 static const char SIG_CONTRACTED[] = "contracted";
278 static const char SIG_EXPAND_REQUEST[] = "expand,request";
279 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
280 static const char SIG_REALIZED[] = "realized";
281 static const char SIG_UNREALIZED[] = "unrealized";
282 static const char SIG_DRAG_START_UP[] = "drag,start,up";
283 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
284 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
285 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
286 static const char SIG_DRAG_STOP[] = "drag,stop";
287 static const char SIG_DRAG[] = "drag";
288 static const char SIG_LONGPRESSED[] = "longpressed";
289 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
290 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
291 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
292 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
293 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
294 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
295 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
296 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
297 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
298 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
299 static const char SIG_SWIPE[] = "swipe";
301 static const Evas_Smart_Cb_Description _signals[] = {
302 {SIG_CLICKED_DOUBLE, ""},
305 {SIG_UNSELECTED, ""},
307 {SIG_CONTRACTED, ""},
308 {SIG_EXPAND_REQUEST, ""},
309 {SIG_CONTRACT_REQUEST, ""},
311 {SIG_UNREALIZED, ""},
312 {SIG_DRAG_START_UP, ""},
313 {SIG_DRAG_START_DOWN, ""},
314 {SIG_DRAG_START_LEFT, ""},
315 {SIG_DRAG_START_RIGHT, ""},
318 {SIG_LONGPRESSED, ""},
319 {SIG_SCROLL_EDGE_TOP, ""},
320 {SIG_SCROLL_EDGE_BOTTOM, ""},
321 {SIG_SCROLL_EDGE_LEFT, ""},
322 {SIG_SCROLL_EDGE_RIGHT, ""},
323 {SIG_MULTI_SWIPE_LEFT, ""},
324 {SIG_MULTI_SWIPE_RIGHT, ""},
325 {SIG_MULTI_SWIPE_UP, ""},
326 {SIG_MULTI_SWIPE_DOWN, ""},
327 {SIG_MULTI_PINCH_OUT, ""},
328 {SIG_MULTI_PINCH_IN, ""},
334 _event_hook(Evas_Object *obj,
335 Evas_Object *src __UNUSED__,
336 Evas_Callback_Type type,
339 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
340 Evas_Event_Key_Down *ev = event_info;
341 Widget_Data *wd = elm_widget_data_get(obj);
342 if (!wd) return EINA_FALSE;
343 if (!wd->items) return EINA_FALSE;
344 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
345 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
347 Elm_Genlist_Item *it = NULL;
350 Evas_Coord step_x = 0;
351 Evas_Coord step_y = 0;
354 Evas_Coord page_x = 0;
355 Evas_Coord page_y = 0;
357 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
358 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
359 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
360 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
362 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
366 else if ((!strcmp(ev->keyname, "Right")) ||
367 (!strcmp(ev->keyname, "KP_Right")))
371 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
373 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
374 (_item_multi_select_up(wd)))
375 || (_item_single_select_up(wd)))
377 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
383 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
385 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
386 (_item_multi_select_down(wd)))
387 || (_item_single_select_down(wd)))
389 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
395 else if ((!strcmp(ev->keyname, "Home")) ||
396 (!strcmp(ev->keyname, "KP_Home")))
398 it = elm_genlist_first_item_get(obj);
399 elm_genlist_item_bring_in(it);
400 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
403 else if ((!strcmp(ev->keyname, "End")) ||
404 (!strcmp(ev->keyname, "KP_End")))
406 it = elm_genlist_last_item_get(obj);
407 elm_genlist_item_bring_in(it);
408 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
411 else if ((!strcmp(ev->keyname, "Prior")) ||
412 (!strcmp(ev->keyname, "KP_Prior")))
415 y -= -(page_y * v_h) / 100;
419 else if ((!strcmp(ev->keyname, "Next")) ||
420 (!strcmp(ev->keyname, "KP_Next")))
423 y += -(page_y * v_h) / 100;
427 else if (((!strcmp(ev->keyname, "Return")) ||
428 (!strcmp(ev->keyname, "KP_Enter")) ||
429 (!strcmp(ev->keyname, "space")))
430 && (!wd->multi) && (wd->selected))
432 it = elm_genlist_selected_item_get(obj);
433 elm_genlist_item_expanded_set(it,
434 !elm_genlist_item_expanded_get(it));
435 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
437 else if (!strcmp(ev->keyname, "Escape"))
439 if (!_deselect_all_items(wd)) return EINA_FALSE;
440 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
443 else return EINA_FALSE;
445 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
446 elm_smart_scroller_child_pos_set(wd->scr, x, y);
451 _deselect_all_items(Widget_Data *wd)
453 if (!wd->selected) return EINA_FALSE;
455 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
461 _item_multi_select_up(Widget_Data *wd)
463 if (!wd->selected) return EINA_FALSE;
464 if (!wd->multi) return EINA_FALSE;
466 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
467 if (!prev) return EINA_TRUE;
469 if (elm_genlist_item_selected_get(prev))
471 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
472 wd->last_selected_item = prev;
473 elm_genlist_item_show(wd->last_selected_item);
477 elm_genlist_item_selected_set(prev, EINA_TRUE);
478 elm_genlist_item_show(prev);
484 _item_multi_select_down(Widget_Data *wd)
486 if (!wd->selected) return EINA_FALSE;
487 if (!wd->multi) return EINA_FALSE;
489 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
490 if (!next) return EINA_TRUE;
492 if (elm_genlist_item_selected_get(next))
494 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
495 wd->last_selected_item = next;
496 elm_genlist_item_show(wd->last_selected_item);
500 elm_genlist_item_selected_set(next, EINA_TRUE);
501 elm_genlist_item_show(next);
507 _item_single_select_up(Widget_Data *wd)
509 Elm_Genlist_Item *prev;
512 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
513 while ((prev) && (prev->delete_me))
514 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
516 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
518 if (!prev) return EINA_FALSE;
520 _deselect_all_items(wd);
522 elm_genlist_item_selected_set(prev, EINA_TRUE);
523 elm_genlist_item_show(prev);
528 _item_single_select_down(Widget_Data *wd)
530 Elm_Genlist_Item *next;
533 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
534 while ((next) && (next->delete_me))
535 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
537 else next = elm_genlist_item_next_get(wd->last_selected_item);
539 if (!next) return EINA_FALSE;
541 _deselect_all_items(wd);
543 elm_genlist_item_selected_set(next, EINA_TRUE);
544 elm_genlist_item_show(next);
549 _on_focus_hook(void *data __UNUSED__,
552 Widget_Data *wd = elm_widget_data_get(obj);
554 if (elm_widget_focus_get(obj))
556 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
557 evas_object_focus_set(wd->obj, EINA_TRUE);
558 if ((wd->selected) && (!wd->last_selected_item))
559 wd->last_selected_item = eina_list_data_get(wd->selected);
563 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
564 evas_object_focus_set(wd->obj, EINA_FALSE);
569 _del_hook(Evas_Object *obj)
571 Widget_Data *wd = elm_widget_data_get(obj);
573 _item_cache_zero(wd);
574 if (wd->calc_job) ecore_job_del(wd->calc_job);
575 if (wd->update_job) ecore_job_del(wd->update_job);
576 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
577 if (wd->changed_job) ecore_job_del(wd->changed_job);
578 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
579 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
580 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
581 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
585 elm_genlist_clear(obj);
591 _del_pre_hook(Evas_Object *obj)
593 Widget_Data *wd = elm_widget_data_get(obj);
595 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
596 elm_genlist_clear(obj);
597 evas_object_del(wd->pan_smart);
598 wd->pan_smart = NULL;
602 _mirrored_set(Evas_Object *obj,
605 Widget_Data *wd = elm_widget_data_get(obj);
607 _item_cache_zero(wd);
608 elm_smart_scroller_mirrored_set(wd->scr, rtl);
612 _theme_hook(Evas_Object *obj)
614 Widget_Data *wd = elm_widget_data_get(obj);
617 evas_event_freeze(evas_object_evas_get(wd->obj));
618 _item_cache_zero(wd);
619 _elm_widget_mirrored_reload(obj);
620 _mirrored_set(obj, elm_widget_mirrored_get(obj));
621 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
622 elm_widget_style_get(obj));
623 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
624 wd->item_width = wd->item_height = 0;
625 wd->group_item_width = wd->group_item_height = 0;
626 wd->minw = wd->minh = wd->realminw = 0;
627 EINA_INLIST_FOREACH(wd->blocks, itb)
630 Elm_Genlist_Item *it;
632 if (itb->realized) _item_block_unrealize(itb);
633 EINA_LIST_FOREACH(itb->items, l, it)
634 it->mincalcd = EINA_FALSE;
636 itb->changed = EINA_TRUE;
638 if (wd->calc_job) ecore_job_del(wd->calc_job);
639 wd->calc_job = ecore_job_add(_calc_job, wd);
641 evas_event_thaw(evas_object_evas_get(wd->obj));
642 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
646 _show_region_hook(void *data,
649 Widget_Data *wd = elm_widget_data_get(data);
650 Evas_Coord x, y, w, h;
652 elm_widget_show_region_get(obj, &x, &y, &w, &h);
653 //x & y are screen coordinates, Add with pan coordinates
656 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
660 _sizing_eval(Evas_Object *obj)
662 Widget_Data *wd = elm_widget_data_get(obj);
663 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
665 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
666 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
668 if (wd->height_for_width)
672 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
673 if ((vw != 0) && (vw != wd->prev_viewport_w))
677 wd->prev_viewport_w = vw;
678 EINA_INLIST_FOREACH(wd->blocks, itb)
680 itb->must_recalc = EINA_TRUE;
682 if (wd->calc_job) ecore_job_del(wd->calc_job);
683 wd->calc_job = ecore_job_add(_calc_job, wd);
686 if (wd->mode == ELM_LIST_LIMIT)
688 Evas_Coord vmw, vmh, vw, vh;
692 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
693 if ((minw > 0) && (vw < minw)) vw = minw;
694 else if ((maxw > 0) && (vw > maxw))
696 edje_object_size_min_calc
697 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
704 edje_object_size_min_calc
705 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
709 evas_object_size_hint_min_set(obj, minw, minh);
710 evas_object_size_hint_max_set(obj, maxw, maxh);
714 _signal_emit_hook(Evas_Object *obj,
715 const char *emission,
718 Widget_Data *wd = elm_widget_data_get(obj);
719 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
724 _item_highlight(Elm_Genlist_Item *it)
726 const char *selectraise;
727 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
728 (it->disabled) || (it->display_only) || (it->mode_view))
730 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
731 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
732 selectraise = edje_object_data_get(it->base.view, "selectraise");
733 if ((selectraise) && (!strcmp(selectraise, "on")))
735 if (it->edit_obj) evas_object_raise(it->edit_obj);
736 else evas_object_raise(it->base.view);
737 if ((it->group_item) && (it->group_item->realized))
738 evas_object_raise(it->group_item->base.view);
740 it->highlighted = EINA_TRUE;
744 _item_block_del(Elm_Genlist_Item *it)
747 Item_Block *itb = it->block;
749 itb->items = eina_list_remove(itb->items, it);
751 itb->changed = EINA_TRUE;
752 if (!it->wd->reorder_deleted)
754 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
755 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
759 il = EINA_INLIST_GET(itb);
760 Item_Block *itbn = (Item_Block *)(il->next);
762 it->parent->items = eina_list_remove(it->parent->items, it);
764 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
766 if (itbn) itbn->changed = EINA_TRUE;
770 if (itb->count < itb->wd->max_items_per_block/2)
772 il = EINA_INLIST_GET(itb);
773 Item_Block *itbp = (Item_Block *)(il->prev);
774 Item_Block *itbn = (Item_Block *)(il->next);
775 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
777 Elm_Genlist_Item *it2;
779 EINA_LIST_FREE(itb->items, it2)
782 itbp->items = eina_list_append(itbp->items, it2);
784 itbp->changed = EINA_TRUE;
786 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
787 EINA_INLIST_GET(itb));
790 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
794 Eina_List *last = eina_list_last(itb->items);
795 Elm_Genlist_Item *it2 = last->data;
798 itb->items = eina_list_remove_list(itb->items, last);
799 itbn->items = eina_list_prepend(itbn->items, it2);
801 itbn->changed = EINA_TRUE;
804 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
812 _item_subitems_clear(Elm_Genlist_Item *it)
815 Eina_List *tl = NULL, *l;
816 Elm_Genlist_Item *it2;
818 EINA_LIST_FOREACH(it->items, l, it2)
819 tl = eina_list_append(tl, it2);
821 EINA_LIST_FREE(tl, it2)
822 elm_genlist_item_del(it2);
826 _item_del(Elm_Genlist_Item *it)
828 Evas_Object *tob = it->wd->obj;
830 evas_event_freeze(evas_object_evas_get(tob));
831 elm_widget_item_pre_notify_del(it);
832 elm_genlist_item_subitems_clear(it);
833 it->wd->walking -= it->walking;
834 if (it->wd->show_item == it) it->wd->show_item = NULL;
835 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
836 if (it->realized) _item_unrealize(it, EINA_FALSE);
837 if (it->effect_item_realized) _effect_item_unrealize(it);
838 if (it->block) _item_block_del(it);
839 if ((!it->delete_me) && (it->itc->func.del))
840 it->itc->func.del((void *)it->base.data, it->base.widget);
841 it->delete_me = EINA_TRUE;
843 it->wd->queue = eina_list_remove(it->wd->queue, it);
845 if (it->wd->anchor_item == it)
847 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
848 if (!it->wd->anchor_item)
849 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
852 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
854 it->parent->items = eina_list_remove(it->parent->items, it);
855 if (it->flags & ELM_GENLIST_ITEM_GROUP)
856 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
857 if (it->long_timer) ecore_timer_del(it->long_timer);
858 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
860 if (it->tooltip.del_cb)
861 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
863 evas_event_thaw(evas_object_evas_get(tob));
864 evas_event_thaw_eval(evas_object_evas_get(tob));
866 elm_widget_item_del(it);
870 _item_select(Elm_Genlist_Item *it)
872 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
875 if (it->wd->always_select) goto call;
878 it->selected = EINA_TRUE;
879 it->wd->selected = eina_list_append(it->wd->selected, it);
885 Evas_Object *baseobj = it->base.widget;
886 const char *objtype = NULL;
887 it->func.func((void *)it->func.data, it->base.widget, it);
888 objtype = evas_object_type_get(baseobj);
889 if ((!objtype) || (!strcmp(objtype,""))) return;
892 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
895 if ((it->wd->clear_me) && (!it->wd->walking))
897 elm_genlist_clear(it->base.widget);
902 if ((!it->walking) && (it->delete_me))
904 if (!it->relcount) _item_del(it);
907 if (it && it->wd) it->wd->last_selected_item = it; // TODO: Remove 'if'?
911 _item_unselect(Elm_Genlist_Item *it)
913 const char *stacking, *selectraise;
915 if ((it->delete_me) || (!it->highlighted)) return;
916 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
917 if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
918 stacking = edje_object_data_get(it->base.view, "stacking");
919 selectraise = edje_object_data_get(it->base.view, "selectraise");
920 if ((selectraise) && (!strcmp(selectraise, "on")))
922 if ((stacking) && (!strcmp(stacking, "below")))
923 evas_object_lower(it->base.view);
925 it->highlighted = EINA_FALSE;
928 it->selected = EINA_FALSE;
929 it->wd->selected = eina_list_remove(it->wd->selected, it);
930 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
935 _mouse_move(void *data,
936 Evas *evas __UNUSED__,
940 Elm_Genlist_Item *it = data;
941 Evas_Event_Mouse_Move *ev = event_info;
942 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
943 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
945 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
947 if (!it->wd->on_hold)
949 it->wd->on_hold = EINA_TRUE;
950 if (!it->wd->wasselected)
954 if (it->wd->multitouched)
956 it->wd->cur_x = ev->cur.canvas.x;
957 it->wd->cur_y = ev->cur.canvas.y;
960 if ((it->dragging) && (it->down))
962 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
965 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
966 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
967 if (abs((it->wd->history[it->wd->movements].x -
968 it->wd->history[0].x)) > 40)
969 it->wd->swipe = EINA_TRUE;
975 ecore_timer_del(it->long_timer);
976 it->long_timer = NULL;
978 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
981 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
985 ecore_timer_del(it->long_timer);
986 it->long_timer = NULL;
988 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
990 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
991 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
993 if (!it->wd->reorder_start_y)
994 it->wd->reorder_start_y = it->block->y + it->y;
998 else if (it_scrl_y + it->wd->reorder_it->h > oy + oh)
999 y_pos = oy + oh - it->wd->reorder_it->h;
1004 _item_position(it, it->edit_obj, it->scrl_x, y_pos);
1006 _item_position(it, it->base.view, it->scrl_x, y_pos);
1007 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1008 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1012 if (!it->display_only)
1013 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1014 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1015 x = ev->cur.canvas.x - x;
1016 y = ev->cur.canvas.y - y;
1019 if (adx < 0) adx = -dx;
1022 if (ady < 0) ady = -dy;
1025 if ((adx > minw) || (ady > minh))
1027 it->dragging = EINA_TRUE;
1028 it->wd->dragging_queue = eina_list_append(it->wd->dragging_queue, it);
1031 ecore_timer_del(it->long_timer);
1032 it->long_timer = NULL;
1034 if (!it->wd->wasselected)
1039 evas_object_smart_callback_call(it->base.widget,
1040 SIG_DRAG_START_UP, it);
1044 evas_object_smart_callback_call(it->base.widget,
1045 SIG_DRAG_START_LEFT, it);
1047 evas_object_smart_callback_call(it->base.widget,
1048 SIG_DRAG_START_RIGHT, it);
1054 evas_object_smart_callback_call(it->base.widget,
1055 SIG_DRAG_START_DOWN, it);
1059 evas_object_smart_callback_call(it->base.widget,
1060 SIG_DRAG_START_LEFT, it);
1062 evas_object_smart_callback_call(it->base.widget,
1063 SIG_DRAG_START_RIGHT, it);
1070 _long_press(void *data)
1072 Elm_Genlist_Item *it = data, *it_tmp;
1073 Eina_List *list, *l;
1074 //static Eina_Bool contracted = EINA_FALSE;
1076 it->long_timer = NULL;
1077 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
1078 return ECORE_CALLBACK_CANCEL;
1079 it->wd->longpressed = EINA_TRUE;
1080 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1081 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1083 it->wd->reorder_it = it;
1084 it->wd->reorder_start_y = 0;
1086 evas_object_raise(it->edit_obj);
1088 evas_object_raise(it->base.view);
1089 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1090 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
1092 list = elm_genlist_realized_items_get(it->wd->obj);
1093 EINA_LIST_FOREACH(list, l, it_tmp)
1095 if (it != it_tmp) _item_unselect(it_tmp);
1099 EINA_LIST_FOREACH(it->items, l, it_tmp)
1101 if (elm_genlist_item_expanded_get(it_tmp))
1103 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1104 return ECORE_CALLBACK_RENEW;
1108 if (elm_genlist_item_expanded_get(it))
1110 elm_genlist_item_expanded_set(it, EINA_FALSE);
1111 return ECORE_CALLBACK_RENEW;
1114 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1116 edje_object_signal_emit(it->base.view, "elm,state,reorder,enabled", "elm");
1118 return ECORE_CALLBACK_CANCEL;
1122 _swipe(Elm_Genlist_Item *it)
1127 if ((it->display_only) || (it->disabled)) return;
1128 it->wd->swipe = EINA_FALSE;
1129 for (i = 0; i < it->wd->movements; i++)
1131 sum += it->wd->history[i].x;
1132 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1135 sum /= it->wd->movements;
1136 if (abs(sum - it->wd->history[0].x) <= 10) return;
1137 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1141 _swipe_cancel(void *data)
1143 Elm_Genlist_Item *it = data;
1145 if (!it) return ECORE_CALLBACK_CANCEL;
1146 it->wd->swipe = EINA_FALSE;
1147 it->wd->movements = 0;
1148 return ECORE_CALLBACK_RENEW;
1152 _multi_cancel(void *data)
1154 Widget_Data *wd = data;
1156 if (!wd) return ECORE_CALLBACK_CANCEL;
1157 wd->multi_timeout = EINA_TRUE;
1158 return ECORE_CALLBACK_RENEW;
1162 _multi_touch_gesture_eval(void *data)
1164 Elm_Genlist_Item *it = data;
1166 it->wd->multitouched = EINA_FALSE;
1167 if (it->wd->multi_timer)
1169 ecore_timer_del(it->wd->multi_timer);
1170 it->wd->multi_timer = NULL;
1172 if (it->wd->multi_timeout)
1174 it->wd->multi_timeout = EINA_FALSE;
1178 Evas_Coord minw = 0, minh = 0;
1179 Evas_Coord off_x, off_y, off_mx, off_my;
1181 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1182 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1183 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1184 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1185 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1187 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1189 if ((off_x + off_mx) > (off_y + off_my))
1191 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1192 evas_object_smart_callback_call(it->base.widget,
1193 SIG_MULTI_SWIPE_RIGHT, it);
1194 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1195 evas_object_smart_callback_call(it->base.widget,
1196 SIG_MULTI_SWIPE_LEFT, it);
1197 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1198 evas_object_smart_callback_call(it->base.widget,
1199 SIG_MULTI_PINCH_OUT, it);
1201 evas_object_smart_callback_call(it->base.widget,
1202 SIG_MULTI_PINCH_IN, it);
1206 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1207 evas_object_smart_callback_call(it->base.widget,
1208 SIG_MULTI_SWIPE_DOWN, it);
1209 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1210 evas_object_smart_callback_call(it->base.widget,
1211 SIG_MULTI_SWIPE_UP, it);
1212 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1213 evas_object_smart_callback_call(it->base.widget,
1214 SIG_MULTI_PINCH_OUT, it);
1216 evas_object_smart_callback_call(it->base.widget,
1217 SIG_MULTI_PINCH_IN, it);
1220 it->wd->multi_timeout = EINA_FALSE;
1224 _multi_down(void *data,
1225 Evas *evas __UNUSED__,
1226 Evas_Object *obj __UNUSED__,
1229 Elm_Genlist_Item *it = data;
1230 Evas_Event_Multi_Down *ev = event_info;
1232 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1233 it->wd->multi_device = ev->device;
1234 it->wd->multi_down = EINA_TRUE;
1235 it->wd->multitouched = EINA_TRUE;
1236 it->wd->prev_mx = ev->canvas.x;
1237 it->wd->prev_my = ev->canvas.y;
1238 if (!it->wd->wasselected) _item_unselect(it);
1239 it->wd->wasselected = EINA_FALSE;
1240 it->wd->longpressed = EINA_FALSE;
1243 ecore_timer_del(it->long_timer);
1244 it->long_timer = NULL;
1248 it->dragging = EINA_FALSE;
1249 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1251 if (it->swipe_timer)
1253 ecore_timer_del(it->swipe_timer);
1254 it->swipe_timer = NULL;
1256 if (it->wd->on_hold)
1258 it->wd->swipe = EINA_FALSE;
1259 it->wd->movements = 0;
1260 it->wd->on_hold = EINA_FALSE;
1265 _multi_up(void *data,
1266 Evas *evas __UNUSED__,
1267 Evas_Object *obj __UNUSED__,
1270 Elm_Genlist_Item *it = data;
1271 Evas_Event_Multi_Up *ev = event_info;
1273 if (it->wd->multi_device != ev->device) return;
1274 it->wd->multi_device = 0;
1275 it->wd->multi_down = EINA_FALSE;
1276 if (it->wd->mouse_down) return;
1277 _multi_touch_gesture_eval(data);
1281 _multi_move(void *data,
1282 Evas *evas __UNUSED__,
1283 Evas_Object *obj __UNUSED__,
1286 Elm_Genlist_Item *it = data;
1287 Evas_Event_Multi_Move *ev = event_info;
1289 if (it->wd->multi_device != ev->device) return;
1290 it->wd->cur_mx = ev->cur.canvas.x;
1291 it->wd->cur_my = ev->cur.canvas.y;
1295 _mouse_down(void *data,
1296 Evas *evas __UNUSED__,
1300 Elm_Genlist_Item *it = data;
1301 Evas_Event_Mouse_Down *ev = event_info;
1304 if (ev->button != 1) return;
1305 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1307 it->wd->on_hold = EINA_TRUE;
1309 it->down = EINA_TRUE;
1310 it->dragging = EINA_FALSE;
1311 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1312 it->dx = ev->canvas.x - x;
1313 it->dy = ev->canvas.y - y;
1314 it->wd->mouse_down = EINA_TRUE;
1315 if (!it->wd->multitouched)
1317 it->wd->prev_x = ev->canvas.x;
1318 it->wd->prev_y = ev->canvas.y;
1319 it->wd->multi_timeout = EINA_FALSE;
1320 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1321 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1323 it->wd->longpressed = EINA_FALSE;
1324 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1325 else it->wd->on_hold = EINA_FALSE;
1326 if (it->wd->on_hold) return;
1327 it->wd->wasselected = it->selected;
1328 _item_highlight(it);
1329 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1330 if ((!it->disabled) && (!it->display_only))
1332 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1333 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
1335 if (it->long_timer) ecore_timer_del(it->long_timer);
1336 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1337 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1339 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1342 it->long_timer = NULL;
1343 it->wd->swipe = EINA_FALSE;
1344 it->wd->movements = 0;
1348 _mouse_up(void *data,
1349 Evas *evas __UNUSED__,
1350 Evas_Object *obj __UNUSED__,
1353 Elm_Genlist_Item *it = data;
1354 Evas_Event_Mouse_Up *ev = event_info;
1355 Eina_Bool dragged = EINA_FALSE;
1357 if (ev->button != 1) return;
1358 it->down = EINA_FALSE;
1359 it->wd->mouse_down = EINA_FALSE;
1360 if (it->wd->multitouched)
1362 // in single selection modes, some multi touching can make multi highlighted items.
1363 // if a item not selected and highlighted, it should be unhighlighted.
1364 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unselect(it);
1365 if (it->wd->multi_down) return;
1366 _multi_touch_gesture_eval(data);
1369 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1370 else it->wd->on_hold = EINA_FALSE;
1373 ecore_timer_del(it->long_timer);
1374 it->long_timer = NULL;
1376 while (it->wd->dragging_queue)
1378 Elm_Genlist_Item *dragging_it = NULL;
1379 dragging_it = eina_list_data_get(it->wd->dragging_queue);
1380 dragging_it->dragging = EINA_FALSE;
1381 evas_object_smart_callback_call(dragging_it->base.widget, SIG_DRAG_STOP, dragging_it);
1382 if (dragging_it->want_unrealize)
1384 _item_unrealize(dragging_it, EINA_FALSE);
1385 if (dragging_it->block->want_unrealize)
1386 _item_block_unrealize(it->block);
1388 it->wd->dragging_queue = eina_list_remove_list(it->wd->dragging_queue,it->wd->dragging_queue);
1391 if (it->swipe_timer)
1393 ecore_timer_del(it->swipe_timer);
1394 it->swipe_timer = NULL;
1396 if (it->wd->multi_timer)
1398 ecore_timer_del(it->wd->multi_timer);
1399 it->wd->multi_timer = NULL;
1400 it->wd->multi_timeout = EINA_FALSE;
1402 if (it->wd->on_hold)
1404 if (it->wd->swipe) _swipe(data);
1405 it->wd->longpressed = EINA_FALSE;
1406 it->wd->on_hold = EINA_FALSE;
1409 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1411 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1413 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1415 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1416 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1418 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1422 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1423 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1425 it->wd->reorder_deleted = EINA_FALSE;
1426 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1427 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1428 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1429 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1432 if (it->wd->longpressed)
1434 it->wd->longpressed = EINA_FALSE;
1435 if (!it->wd->wasselected)
1437 it->wd->wasselected = EINA_FALSE;
1440 if ((it->disabled) || (dragged) || (it->display_only)) return;
1441 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1446 _item_highlight(it);
1449 else _item_unselect(it);
1455 Widget_Data *wd = it->wd;
1458 while (wd->selected) _item_unselect(wd->selected->data);
1463 const Eina_List *l, *l_next;
1464 Elm_Genlist_Item *it2;
1466 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1467 if (it2 != it) _item_unselect(it2);
1468 //_item_highlight(it);
1471 _item_highlight(it);
1477 _signal_expand_toggle(void *data,
1478 Evas_Object *obj __UNUSED__,
1479 const char *emission __UNUSED__,
1480 const char *source __UNUSED__)
1482 Elm_Genlist_Item *it = data;
1485 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1487 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1491 _signal_expand(void *data,
1492 Evas_Object *obj __UNUSED__,
1493 const char *emission __UNUSED__,
1494 const char *source __UNUSED__)
1496 Elm_Genlist_Item *it = data;
1499 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1503 _signal_contract(void *data,
1504 Evas_Object *obj __UNUSED__,
1505 const char *emission __UNUSED__,
1506 const char *source __UNUSED__)
1508 Elm_Genlist_Item *it = data;
1511 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1515 _scr_hold_timer_cb(void *data)
1517 if (!data) return ECORE_CALLBACK_CANCEL;
1518 Widget_Data *wd = data;
1519 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1520 wd->scr_hold_timer = NULL;
1521 return ECORE_CALLBACK_CANCEL;
1525 _mode_finished_signal_cb(void *data,
1527 const char *emission __UNUSED__,
1528 const char *source __UNUSED__)
1532 Elm_Genlist_Item *it = data;
1533 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1535 Evas *te = evas_object_evas_get(obj);
1537 evas_event_freeze(te);
1538 it->nocache = EINA_FALSE;
1539 _mode_item_unrealize(it);
1540 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1541 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1542 evas_event_thaw(te);
1543 evas_event_thaw_eval(te);
1547 _item_cache_clean(Widget_Data *wd)
1549 evas_event_freeze(evas_object_evas_get(wd->obj));
1550 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1554 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1555 wd->item_cache = eina_inlist_remove(wd->item_cache,
1556 wd->item_cache->last);
1557 wd->item_cache_count--;
1558 if (itc->spacer) evas_object_del(itc->spacer);
1559 if (itc->base_view) evas_object_del(itc->base_view);
1560 if (itc->item_style) eina_stringshare_del(itc->item_style);
1563 evas_event_thaw(evas_object_evas_get(wd->obj));
1564 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1568 _item_cache_zero(Widget_Data *wd)
1570 int pmax = wd->item_cache_max;
1571 wd->item_cache_max = 0;
1572 _item_cache_clean(wd);
1573 wd->item_cache_max = pmax;
1577 _item_cache_add(Elm_Genlist_Item *it)
1581 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1582 if (it->wd->item_cache_max <= 0)
1584 evas_object_del(it->base.view);
1585 it->base.view = NULL;
1586 evas_object_del(it->spacer);
1588 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1589 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1593 it->wd->item_cache_count++;
1594 itc = calloc(1, sizeof(Item_Cache));
1597 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1598 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1601 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1602 EINA_INLIST_GET(itc));
1603 itc->spacer = it->spacer;
1605 itc->base_view = it->base.view;
1606 it->base.view = NULL;
1607 evas_object_hide(itc->base_view);
1608 evas_object_move(itc->base_view, -9999, -9999);
1609 itc->item_style = eina_stringshare_add(it->itc->item_style);
1610 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1611 itc->compress = (it->wd->compress);
1612 itc->odd = (it->order_num_in & 0x1);
1613 itc->selected = it->selected;
1614 itc->disabled = it->disabled;
1615 itc->expanded = it->expanded;
1618 ecore_timer_del(it->long_timer);
1619 it->long_timer = NULL;
1621 if (it->swipe_timer)
1623 ecore_timer_del(it->swipe_timer);
1624 it->swipe_timer = NULL;
1626 // FIXME: other callbacks?
1627 edje_object_signal_callback_del_full(itc->base_view,
1628 "elm,action,expand,toggle",
1629 "elm", _signal_expand_toggle, it);
1630 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1632 _signal_expand, it);
1633 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1634 "elm", _signal_contract, it);
1635 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1637 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1639 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1641 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1643 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1645 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1647 _item_cache_clean(it->wd);
1648 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1649 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1653 _item_cache_find(Elm_Genlist_Item *it)
1656 Eina_Bool tree = 0, odd;
1658 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1659 odd = (it->order_num_in & 0x1);
1660 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1662 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1664 if ((itc->tree == tree) &&
1665 (itc->odd == odd) &&
1666 (itc->compress == it->wd->compress) &&
1667 (!strcmp(it->itc->item_style, itc->item_style)))
1669 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1670 EINA_INLIST_GET(itc));
1671 it->wd->item_cache_count--;
1679 _item_cache_free(Item_Cache *itc)
1681 if (itc->spacer) evas_object_del(itc->spacer);
1682 if (itc->base_view) evas_object_del(itc->base_view);
1683 if (itc->item_style) eina_stringshare_del(itc->item_style);
1688 _item_realize(Elm_Genlist_Item *it,
1692 Elm_Genlist_Item *it2;
1693 const char *stacking;
1694 const char *treesize;
1696 int depth, tsize = 20;
1697 Item_Cache *itc = NULL;
1699 if ((it->realized) || (it->delete_me)) return;
1700 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1701 it->order_num_in = in;
1702 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1703 if ((it->nocache) && (!it->renamed))
1704 it->nocache = EINA_FALSE;
1706 itc = _item_cache_find(it);
1707 if (itc && (!it->wd->effect_mode))
1709 it->base.view = itc->base_view;
1710 itc->base_view = NULL;
1711 it->spacer = itc->spacer;
1716 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1717 edje_object_scale_set(it->base.view,
1718 elm_widget_scale_get(it->base.widget) *
1719 _elm_config->scale);
1720 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1721 elm_widget_sub_object_add(it->base.widget, it->base.view);
1723 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1724 strncpy(buf, "tree", sizeof(buf));
1725 else strncpy(buf, "item", sizeof(buf));
1726 if (it->wd->compress)
1727 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1729 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1730 strncat(buf, "/", sizeof(buf) - strlen(buf));
1731 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1733 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1734 elm_widget_style_get(it->base.widget));
1735 edje_object_mirrored_set(it->base.view,
1736 elm_widget_mirrored_get(it->base.widget));
1738 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1739 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1740 elm_widget_sub_object_add(it->base.widget, it->spacer);
1742 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1744 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1746 it->expanded_depth = depth;
1747 treesize = edje_object_data_get(it->base.view, "treesize");
1748 if (treesize) tsize = atoi(treesize);
1749 evas_object_size_hint_min_set(it->spacer,
1750 (depth * tsize) * _elm_config->scale, 1);
1751 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1754 edje_object_signal_callback_add(it->base.view,
1755 "elm,action,expand,toggle",
1756 "elm", _signal_expand_toggle, it);
1757 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1758 "elm", _signal_expand, it);
1759 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1760 "elm", _signal_contract, it);
1761 stacking = edje_object_data_get(it->base.view, "stacking");
1764 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1765 else if (!strcmp(stacking, "above"))
1766 evas_object_raise(it->base.view);
1768 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1770 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1772 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1774 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1776 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1778 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1781 if ((!it->edit_obj) &&(it->wd->edit_mode) &&
1782 (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
1783 _effect_item_realize(it, EINA_FALSE);
1787 if ((it->selected) && (it->selected != itc->selected))
1789 edje_object_signal_emit(it->base.view,
1790 "elm,state,selected", "elm");
1792 edje_object_signal_emit(it->edit_obj,
1793 "elm,state,selected", "elm");
1795 if ((it->disabled) && (it->disabled != itc->disabled))
1797 edje_object_signal_emit(it->base.view,
1798 "elm,state,disabled", "elm");
1800 edje_object_signal_emit(it->edit_obj,
1801 "elm,state,disabled", "elm");
1803 if ((it->expanded) && (it->expanded != itc->expanded))
1805 edje_object_signal_emit(it->base.view,
1806 "elm,state,expanded", "elm");
1808 edje_object_signal_emit(it->edit_obj,
1809 "elm,state,expanded", "elm");
1816 edje_object_signal_emit(it->base.view,
1817 "elm,state,selected", "elm");
1819 edje_object_signal_emit(it->edit_obj,
1820 "elm,state,selected", "elm");
1824 edje_object_signal_emit(it->base.view,
1825 "elm,state,disabled", "elm");
1827 edje_object_signal_emit(it->edit_obj,
1828 "elm,state,disabled", "elm");
1832 edje_object_signal_emit(it->base.view,
1833 "elm,state,expanded", "elm");
1835 edje_object_signal_emit(it->edit_obj,
1836 "elm,state,expanded", "elm");
1841 if ((calc) && (it->wd->homogeneous) &&
1842 ((it->wd->item_width) ||
1843 ((it->wd->item_width) && (it->wd->group_item_width))))
1845 /* homogenous genlist shortcut */
1848 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1850 it->w = it->minw = it->wd->group_item_width;
1851 it->h = it->minh = it->wd->group_item_height;
1855 it->w = it->minw = it->wd->item_width;
1856 it->h = it->minh = it->wd->item_height;
1858 it->mincalcd = EINA_TRUE;
1863 if (it->itc->func.label_get)
1869 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1871 EINA_LIST_FOREACH(it->labels, l, key)
1873 char *s = it->itc->func.label_get
1874 ((void *)it->base.data, it->base.widget, l->data);
1878 edje_object_part_text_set(it->base.view, l->data, s);
1882 edje_object_part_text_set(it->base.view, l->data, "");
1885 if (it->itc->func.icon_get)
1891 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1893 EINA_LIST_FOREACH(it->icons, l, key)
1895 Evas_Object *ic = it->itc->func.icon_get
1896 ((void *)it->base.data, it->base.widget, l->data);
1900 it->icon_objs = eina_list_append(it->icon_objs, ic);
1901 edje_object_part_swallow(it->base.view, key, ic);
1902 evas_object_show(ic);
1903 elm_widget_sub_object_add(it->base.widget, ic);
1904 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
1906 elm_widget_disabled_set(ic, EINA_TRUE);
1912 elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
1913 EINA_LIST_FOREACH(it->icons, l, key)
1915 Evas_Object *ic = it->itc->func.icon_get
1916 ((void *)it->base.data, it->base.widget, l->data);
1919 it->icon_objs = eina_list_append(it->icon_objs, ic);
1920 edje_object_part_swallow(it->base.view, key, ic);
1921 evas_object_show(ic);
1922 elm_widget_sub_object_add(it->base.widget, ic);
1927 if (it->itc->func.state_get)
1933 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1935 EINA_LIST_FOREACH(it->states, l, key)
1937 Eina_Bool on = it->itc->func.state_get
1938 ((void *)it->base.data, it->base.widget, l->data);
1942 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1943 edje_object_signal_emit(it->base.view, buf, "elm");
1947 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1948 edje_object_signal_emit(it->base.view, buf, "elm");
1952 if (!it->mincalcd || it->wd->pan_resize)
1954 Evas_Coord mw = -1, mh = -1;
1956 if (it->wd->height_for_width) mw = it->wd->w; // TODO: Removed this. This was removed from upstream.
1958 if (!it->display_only)
1959 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1960 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1961 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1963 if (!it->display_only)
1964 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1965 it->w = it->minw = mw;
1966 it->h = it->minh = mh;
1967 it->mincalcd = EINA_TRUE;
1969 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1971 it->wd->group_item_width = mw;
1972 it->wd->group_item_height = mh;
1974 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1976 it->wd->item_width = mw;
1977 it->wd->item_height = mh;
1980 if (!calc) evas_object_show(it->base.view);
1983 if (it->tooltip.content_cb)
1985 elm_widget_item_tooltip_content_cb_set(it,
1986 it->tooltip.content_cb,
1987 it->tooltip.data, NULL);
1988 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1991 if (it->mouse_cursor)
1992 elm_widget_item_cursor_set(it, it->mouse_cursor);
1994 it->realized = EINA_TRUE;
1995 it->want_unrealize = EINA_FALSE;
1997 if (itc) _item_cache_free(itc);
1998 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1999 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2001 evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2002 if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
2004 if (it->itc->edit_item_style)
2006 if (!it->edit_obj) _effect_item_realize(it, EINA_FALSE);
2007 edje_object_message_signal_process(it->edit_obj);
2010 edje_object_message_signal_process(it->base.view);
2014 _item_unrealize(Elm_Genlist_Item *it,
2019 if (!it->realized) return;
2020 if (it->wd->reorder_it == it) return;
2021 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2023 evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2026 ecore_timer_del(it->long_timer);
2027 it->long_timer = NULL;
2031 evas_object_del(it->base.view);
2032 it->base.view = NULL;
2033 evas_object_del(it->spacer);
2038 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2039 _item_cache_add(it);
2041 elm_widget_stringlist_free(it->labels);
2043 elm_widget_stringlist_free(it->icons);
2045 elm_widget_stringlist_free(it->states);
2047 EINA_LIST_FREE(it->icon_objs, icon)
2048 evas_object_del(icon);
2050 _mode_item_unrealize(it);
2052 it->realized = EINA_FALSE;
2053 it->want_unrealize = EINA_FALSE;
2054 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2055 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2056 if (it->wd->edit_mode) _effect_item_unrealize(it);
2060 _item_block_recalc(Item_Block *itb,
2065 Elm_Genlist_Item *it;
2066 Evas_Coord minw = 0, minh = 0;
2067 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2070 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2072 EINA_LIST_FOREACH(itb->items, l, it)
2074 if (it->delete_me) continue;
2075 showme |= it->showme;
2080 if (!it->mincalcd) changed = EINA_TRUE;
2083 _item_realize(it, in, EINA_TRUE);
2084 _item_unrealize(it, EINA_TRUE);
2089 _item_realize(it, in, EINA_TRUE);
2090 _item_unrealize(it, EINA_TRUE);
2094 _item_realize(it, in, EINA_FALSE);
2096 if (minw < it->minw) minw = it->minw;
2104 itb->changed = EINA_FALSE;
2105 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2106 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2111 _item_block_realize(Item_Block *itb,
2116 Elm_Genlist_Item *it;
2118 if (itb->realized) return;
2119 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2120 EINA_LIST_FOREACH(itb->items, l, it)
2122 if (it->delete_me) continue;
2123 if (full) _item_realize(it, in, EINA_FALSE);
2126 itb->realized = EINA_TRUE;
2127 itb->want_unrealize = EINA_FALSE;
2128 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2129 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2133 _item_block_unrealize(Item_Block *itb)
2136 Elm_Genlist_Item *it;
2137 Eina_Bool dragging = EINA_FALSE;
2139 if (!itb->realized) return;
2140 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2141 EINA_LIST_FOREACH(itb->items, l, it)
2143 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2147 dragging = EINA_TRUE;
2148 it->want_unrealize = EINA_TRUE;
2151 _item_unrealize(it, EINA_FALSE);
2156 itb->realized = EINA_FALSE;
2157 itb->want_unrealize = EINA_TRUE;
2160 itb->want_unrealize = EINA_FALSE;
2161 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2162 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2166 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2168 Evas_Coord rox, roy, row, roh, oy, oh;
2169 Eina_Bool top = EINA_FALSE;
2170 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2171 if (!reorder_it) return 0;
2173 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2174 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2176 if ((it->wd->reorder_start_y < it->block->y) &&
2177 (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2179 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2180 if (it->block->count == 1)
2181 it->wd->reorder_rel = it;
2183 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2185 it->block->reorder_offset = it->wd->reorder_it->h;
2188 it->block->reorder_offset = 0;
2190 it->scrl_y += it->block->reorder_offset;
2192 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2193 rox, roy + (roh / 2), row, 1));
2196 it->wd->reorder_rel = it;
2197 it->scrl_y += it->wd->reorder_it->h;
2198 return it->wd->reorder_it->h;
2205 _reorder_move_animator_cb(void *data)
2207 Elm_Genlist_Item *it = data;
2208 Eina_Bool down = EINA_FALSE;
2210 int y, dy = it->h / 10 * _elm_config->scale, diff;
2212 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2214 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2217 diff = abs(it->old_scrl_y - it->scrl_y);
2218 if (diff > it->h) y = diff / 2;
2219 if (it->old_scrl_y < it->scrl_y)
2221 it->old_scrl_y += y;
2224 else if (it->old_scrl_y > it->scrl_y)
2226 it->old_scrl_y -= y;
2231 _item_position(it, it->edit_obj, it->scrl_x, it->old_scrl_y);
2233 _item_position(it, it->base.view, it->scrl_x, it->old_scrl_y);
2234 _group_items_recalc(it->wd);
2235 if ((it->wd->reorder_pan_move) ||
2236 (down && it->old_scrl_y >= it->scrl_y) ||
2237 (!down && it->old_scrl_y <= it->scrl_y))
2239 it->old_scrl_y = it->scrl_y;
2240 it->move_effect_enabled = EINA_FALSE;
2241 it->wd->reorder_move_animator = NULL;
2242 return ECORE_CALLBACK_CANCEL;
2244 return ECORE_CALLBACK_RENEW;
2248 _item_position(Elm_Genlist_Item *it,
2256 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2257 evas_object_resize(view, it->w, it->h);
2258 evas_object_move(view, it_x, it_y);
2259 evas_object_show(view);
2260 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2261 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2265 _item_block_position(Item_Block *itb,
2269 Elm_Genlist_Item *it;
2270 Elm_Genlist_Item *git;
2271 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2272 Evas_Coord minh = 0;
2275 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2276 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2277 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2279 EINA_LIST_FOREACH(itb->items, l, it)
2281 if (it->delete_me) continue;
2282 else if (it->wd->reorder_it == it) continue;
2287 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2288 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2290 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2291 cvx, cvy, cvw, cvh));
2292 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2294 if ((itb->realized))
2298 if (!it->realized) _item_realize(it, in, EINA_FALSE);
2301 if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
2302 edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
2310 if (it->wd->reorder_mode)
2311 y += _get_space_for_reorder_item(it);
2312 git = it->group_item;
2315 git->scrl_x = it->scrl_x;
2316 if (git->scrl_y < oy)
2318 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2319 git->scrl_y = (it->scrl_y + it->h) - git->h;
2320 git->want_realize = EINA_TRUE;
2322 if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2324 if (!it->move_effect_enabled)
2326 it->move_effect_enabled = EINA_TRUE;
2327 it->wd->reorder_move_animator =
2329 _reorder_move_animator_cb, it);
2332 if (!it->move_effect_enabled)
2333 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))
2335 if (it->wd->edit_mode && it->itc->edit_item_style)
2337 _item_position(it, it->edit_obj, it->scrl_x, it->scrl_y);
2341 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)))
2344 _item_position(it, it->mode_view, it->scrl_x,
2347 _item_position(it, it->base.view, it->scrl_x,
2352 evas_object_resize(it->base.view, it->w, it->h);
2353 evas_object_move(it->base.view, it->scrl_x, it->scrl_y);
2354 evas_object_hide(it->base.view);
2361 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2368 if (vis) it->want_realize = EINA_TRUE;
2370 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))
2372 it->old_scrl_y = it->scrl_y;
2377 if (!itb->wd->reorder_it) itb->minh = minh;
2378 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2379 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2383 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2385 Elm_Genlist_Item *it = data;
2387 it->mincalcd = EINA_FALSE;
2388 it->block->changeme = EINA_TRUE;
2389 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2390 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2394 _group_items_recalc(void *data)
2396 Widget_Data *wd = data;
2398 Elm_Genlist_Item *git;
2400 evas_event_freeze(evas_object_evas_get(wd->obj));
2401 EINA_LIST_FOREACH(wd->group_items, l, git)
2403 if (git->want_realize)
2406 _item_realize(git, 0, EINA_FALSE);
2407 evas_object_resize(git->base.view, wd->minw, git->h);
2408 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2409 evas_object_show(git->base.view);
2410 evas_object_raise(git->base.view);
2412 else if (!git->want_realize && git->realized)
2415 _item_unrealize(git, EINA_FALSE);
2418 evas_event_thaw(evas_object_evas_get(wd->obj));
2419 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2423 _must_recalc_idler(void *data)
2425 Widget_Data *wd = data;
2426 if (wd->calc_job) ecore_job_del(wd->calc_job);
2427 wd->calc_job = ecore_job_add(_calc_job, wd);
2428 wd->must_recalc_idler = NULL;
2429 return ECORE_CALLBACK_CANCEL;
2433 _calc_job(void *data)
2435 Widget_Data *wd = data;
2436 Item_Block *itb, *chb = NULL;
2437 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2438 int in = 0, minw_change = 0;
2439 Eina_Bool changed = EINA_FALSE;
2441 Eina_Bool did_must_recalc = EINA_FALSE;
2444 t0 = ecore_time_get();
2445 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2449 evas_event_freeze(evas_object_evas_get(wd->obj));
2450 EINA_INLIST_FOREACH(wd->blocks, itb)
2452 Eina_Bool showme = EINA_FALSE;
2455 showme = itb->showme;
2456 itb->showme = EINA_FALSE;
2459 if (itb->realized) _item_block_unrealize(itb);
2461 if ((itb->changed) || (changed) ||
2462 ((itb->must_recalc) && (!did_must_recalc)))
2464 if ((changed) || (itb->must_recalc))
2467 Elm_Genlist_Item *it;
2468 EINA_LIST_FOREACH(itb->items, l, it)
2469 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2470 itb->changed = EINA_TRUE;
2471 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2472 itb->must_recalc = EINA_FALSE;
2474 if (itb->realized) _item_block_unrealize(itb);
2475 showme = _item_block_recalc(itb, in, EINA_FALSE);
2481 if (minw == -1) minw = itb->minw;
2482 else if ((!itb->must_recalc) && (minw < itb->minw))
2485 minw_change = EINA_TRUE;
2491 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2493 wd->show_item->showme = EINA_FALSE;
2495 elm_smart_scroller_region_bring_in(wd->scr,
2497 wd->show_item->block->x,
2499 wd->show_item->block->y,
2500 wd->show_item->block->w,
2503 elm_smart_scroller_child_region_show(wd->scr,
2505 wd->show_item->block->x,
2507 wd->show_item->block->y,
2508 wd->show_item->block->w,
2510 wd->show_item = NULL;
2515 EINA_INLIST_FOREACH(wd->blocks, itb)
2521 if ((chb) && (EINA_INLIST_GET(chb)->next))
2523 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2525 if (itb->realized) _item_block_unrealize(itb);
2528 wd->realminw = minw;
2529 if (minw < wd->w) minw = wd->w;
2530 if ((minw != wd->minw) || (minh != wd->minh))
2534 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2535 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2536 _sizing_eval(wd->obj);
2538 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2540 Elm_Genlist_Item *it;
2543 it = wd->anchor_item;
2544 it_y = wd->anchor_y;
2545 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2546 it->block->y + it->y + it_y);
2547 wd->anchor_item = it;
2548 wd->anchor_y = it_y;
2552 t = ecore_time_get();
2553 if (did_must_recalc)
2555 if (!wd->must_recalc_idler)
2556 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2558 wd->calc_job = NULL;
2559 evas_object_smart_changed(wd->pan_smart);
2560 evas_event_thaw(evas_object_evas_get(wd->obj));
2561 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2565 _update_job(void *data)
2567 Widget_Data *wd = data;
2571 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2573 wd->update_job = NULL;
2576 evas_event_freeze(evas_object_evas_get(wd->obj));
2577 EINA_INLIST_FOREACH(wd->blocks, itb)
2579 Evas_Coord itminw, itminh;
2580 Elm_Genlist_Item *it;
2586 _item_block_position(itb, num);
2590 recalc = EINA_FALSE;
2591 EINA_LIST_FOREACH(itb->items, l2, it)
2598 it->updateme = EINA_FALSE;
2601 _item_unrealize(it, EINA_FALSE);
2602 _item_realize(it, num, EINA_FALSE);
2603 position = EINA_TRUE;
2607 _item_realize(it, num, EINA_TRUE);
2608 _item_unrealize(it, EINA_TRUE);
2610 if ((it->minw != itminw) || (it->minh != itminh))
2615 itb->updateme = EINA_FALSE;
2618 position = EINA_TRUE;
2619 itb->changed = EINA_TRUE;
2620 _item_block_recalc(itb, num0, EINA_FALSE);
2621 _item_block_position(itb, num0);
2626 if (wd->calc_job) ecore_job_del(wd->calc_job);
2627 wd->calc_job = ecore_job_add(_calc_job, wd);
2629 evas_event_thaw(evas_object_evas_get(wd->obj));
2630 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2634 _changed_job(void *data)
2636 Widget_Data *wd = data; Eina_List *l2;
2638 int num, num0, position = 0;
2639 Eina_Bool width_changed = EINA_FALSE, height_changed = EINA_FALSE;
2641 wd->changed_job = NULL;
2643 EINA_INLIST_FOREACH(wd->blocks, itb)
2645 Evas_Coord itminw, itminh;
2646 Elm_Genlist_Item *it;
2652 _item_block_position(itb, num);
2656 width_changed = height_changed = EINA_FALSE;
2657 EINA_LIST_FOREACH(itb->items, l2, it)
2659 if ((!it->mincalcd) && (it->realized))
2661 Evas_Coord mw = -1, mh = -1;
2665 if (it->wd->height_for_width) mw = it->wd->w;
2666 if (!it->display_only)
2667 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2668 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2669 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2670 if (!it->display_only)
2671 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2672 it->w = it->minw = mw;
2673 it->h = it->minh = mh;
2674 it->mincalcd = EINA_TRUE;
2676 //if ((it->minw != itminw) || (it->minh != itminh))
2677 //if ((it->minh != itminh))
2679 if ((it->minw != itminw))
2680 width_changed = EINA_TRUE;
2681 if ((it->minh != itminh))
2682 height_changed = EINA_TRUE;
2684 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2686 it->wd->group_item_width = mw;
2687 it->wd->group_item_height = mh;
2689 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2691 it->wd->item_width = mw;
2692 it->wd->item_height = mh;
2697 itb->changeme = EINA_FALSE;
2698 // TODO: why this is separated.
2702 itb->changed = EINA_TRUE;
2703 _item_block_recalc(itb, num0, 0);
2704 _item_block_position(itb, num0);
2706 else if (width_changed)
2708 _item_block_position(itb, num0);
2713 if (wd->calc_job) ecore_job_del(wd->calc_job);
2714 wd->calc_job = ecore_job_add(_calc_job, wd);
2719 _pan_set(Evas_Object *obj,
2723 Pan *sd = evas_object_smart_data_get(obj);
2729 // Evas_Coord ow, oh;
2730 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2731 // ow = sd->wd->minw - ow;
2732 // if (ow < 0) ow = 0;
2733 // oh = sd->wd->minh - oh;
2734 // if (oh < 0) oh = 0;
2735 // if (x < 0) x = 0;
2736 // if (y < 0) y = 0;
2737 // if (x > ow) x = ow;
2738 // if (y > oh) y = oh;
2739 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2744 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2746 if ((itb->y + itb->h) > y)
2748 Elm_Genlist_Item *it;
2751 EINA_LIST_FOREACH(itb->items, l2, it)
2753 if ((itb->y + it->y) >= y)
2755 sd->wd->anchor_item = it;
2756 sd->wd->anchor_y = -(itb->y + it->y - y);
2764 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2768 _pan_get(Evas_Object *obj,
2772 Pan *sd = evas_object_smart_data_get(obj);
2775 if (x) *x = sd->wd->pan_x;
2776 if (y) *y = sd->wd->pan_y;
2780 _pan_max_get(Evas_Object *obj,
2784 Pan *sd = evas_object_smart_data_get(obj);
2788 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2789 ow = sd->wd->minw - ow;
2791 oh = sd->wd->minh - oh;
2798 _pan_min_get(Evas_Object *obj __UNUSED__,
2807 _pan_child_size_get(Evas_Object *obj,
2811 Pan *sd = evas_object_smart_data_get(obj);
2814 if (w) *w = sd->wd->minw;
2815 if (h) *h = sd->wd->minh;
2819 _pan_add(Evas_Object *obj)
2822 Evas_Object_Smart_Clipped_Data *cd;
2825 cd = evas_object_smart_data_get(obj);
2828 sd->__clipped_data = *cd;
2830 evas_object_smart_data_set(obj, sd);
2834 _pan_del(Evas_Object *obj)
2836 Pan *sd = evas_object_smart_data_get(obj);
2841 ecore_job_del(sd->resize_job);
2842 sd->resize_job = NULL;
2848 _pan_resize_job(void *data)
2852 _sizing_eval(sd->wd->obj);
2853 sd->resize_job = NULL;
2857 _pan_resize(Evas_Object *obj,
2861 Pan *sd = evas_object_smart_data_get(obj);
2865 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2866 if ((ow == w) && (oh == h)) return;
2867 if ((sd->wd->height_for_width) && (ow != w))
2869 sd->wd->pan_resize = EINA_TRUE;
2870 if (sd->resize_job) ecore_job_del(sd->resize_job);
2871 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2873 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2874 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2878 _pan_calculate(Evas_Object *obj)
2880 Pan *sd = evas_object_smart_data_get(obj);
2882 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2884 Elm_Genlist_Item *git;
2888 evas_event_freeze(evas_object_evas_get(obj));
2889 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2890 sd->wd->prev_viewport_w = ow;
2891 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2892 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2894 git->want_realize = EINA_FALSE;
2896 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2898 itb->w = sd->wd->minw;
2899 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2900 itb->y - sd->wd->pan_y + oy,
2902 cvx, cvy, cvw, cvh))
2904 if ((!itb->realized) || (itb->changed))
2905 _item_block_realize(itb, in, 0);
2906 _item_block_position(itb, in);
2910 if (itb->realized) _item_block_unrealize(itb);
2914 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2915 _group_items_recalc(sd->wd);
2917 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2919 if (sd->wd->pan_y != sd->wd->old_pan_y)
2920 sd->wd->reorder_pan_move = EINA_TRUE;
2921 else sd->wd->reorder_pan_move = EINA_FALSE;
2922 evas_object_raise(sd->wd->reorder_it->edit_obj);
2923 sd->wd->old_pan_y = sd->wd->pan_y;
2924 sd->wd->start_time = ecore_loop_time_get();
2927 if (sd->wd->effect_mode &&
2928 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
2929 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
2930 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
2932 if (!sd->wd->item_moving_effect_timer)
2934 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2935 _item_flip_effect_show(sd->wd->expand_item);
2937 evas_object_raise(sd->wd->alpha_bg);
2938 evas_object_show(sd->wd->alpha_bg);
2939 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
2940 sd->wd->start_time = current_time_get();
2941 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2944 else _item_auto_scroll(sd->wd);
2945 sd->wd->pan_resize = EINA_FALSE;
2946 evas_event_thaw(evas_object_evas_get(obj));
2947 evas_event_thaw_eval(evas_object_evas_get(obj));
2951 _pan_move(Evas_Object *obj,
2952 Evas_Coord x __UNUSED__,
2953 Evas_Coord y __UNUSED__)
2955 Pan *sd = evas_object_smart_data_get(obj);
2958 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2959 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2963 _hold_on(void *data __UNUSED__,
2965 void *event_info __UNUSED__)
2967 Widget_Data *wd = elm_widget_data_get(obj);
2969 elm_smart_scroller_hold_set(wd->scr, 1);
2973 _hold_off(void *data __UNUSED__,
2975 void *event_info __UNUSED__)
2977 Widget_Data *wd = elm_widget_data_get(obj);
2979 elm_smart_scroller_hold_set(wd->scr, 0);
2983 _freeze_on(void *data __UNUSED__,
2985 void *event_info __UNUSED__)
2987 Widget_Data *wd = elm_widget_data_get(obj);
2989 elm_smart_scroller_freeze_set(wd->scr, 1);
2993 _freeze_off(void *data __UNUSED__,
2995 void *event_info __UNUSED__)
2997 Widget_Data *wd = elm_widget_data_get(obj);
2999 elm_smart_scroller_freeze_set(wd->scr, 0);
3003 _scroll_edge_left(void *data,
3004 Evas_Object *scr __UNUSED__,
3005 void *event_info __UNUSED__)
3007 Evas_Object *obj = data;
3008 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
3012 _scroll_edge_right(void *data,
3013 Evas_Object *scr __UNUSED__,
3014 void *event_info __UNUSED__)
3016 Evas_Object *obj = data;
3017 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
3021 _scroll_edge_top(void *data,
3022 Evas_Object *scr __UNUSED__,
3023 void *event_info __UNUSED__)
3025 Evas_Object *obj = data;
3026 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
3030 _scroll_edge_bottom(void *data,
3031 Evas_Object *scr __UNUSED__,
3032 void *event_info __UNUSED__)
3034 Evas_Object *obj = data;
3035 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
3039 _mode_item_realize(Elm_Genlist_Item *it)
3043 if ((it->mode_view) || (it->delete_me)) return;
3045 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3046 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
3047 edje_object_scale_set(it->mode_view,
3048 elm_widget_scale_get(it->base.widget) *
3049 _elm_config->scale);
3050 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
3051 elm_widget_sub_object_add(it->base.widget, it->mode_view);
3053 strncpy(buf, "item", sizeof(buf));
3054 if (it->wd->compress)
3055 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3057 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3058 strncat(buf, "/", sizeof(buf) - strlen(buf));
3059 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3061 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
3062 elm_widget_style_get(it->base.widget));
3063 edje_object_mirrored_set(it->mode_view,
3064 elm_widget_mirrored_get(it->base.widget));
3066 /* signal callback add */
3067 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3069 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3071 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3074 /* label_get, icon_get, state_get */
3075 if (it->itc->func.label_get)
3081 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3083 EINA_LIST_FOREACH(it->mode_labels, l, key)
3085 char *s = it->itc->func.label_get
3086 ((void *)it->base.data, it->base.widget, l->data);
3090 edje_object_part_text_set(it->mode_view, l->data, s);
3095 if (it->itc->func.icon_get)
3101 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3103 EINA_LIST_FOREACH(it->mode_icons, l, key)
3105 Evas_Object *ic = it->itc->func.icon_get
3106 ((void *)it->base.data, it->base.widget, l->data);
3110 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
3111 edje_object_part_swallow(it->mode_view, key, ic);
3112 evas_object_show(ic);
3113 elm_widget_sub_object_add(it->base.widget, ic);
3115 elm_widget_disabled_set(ic, EINA_TRUE);
3119 if (it->itc->func.state_get)
3125 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3127 EINA_LIST_FOREACH(it->mode_states, l, key)
3129 Eina_Bool on = it->itc->func.state_get
3130 ((void *)it->base.data, it->base.widget, l->data);
3134 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
3135 edje_object_signal_emit(it->mode_view, buf, "elm");
3140 edje_object_part_swallow(it->mode_view,
3141 edje_object_data_get(it->mode_view, "mode_part"),
3144 it->want_unrealize = EINA_FALSE;
3145 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3146 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3150 _mode_item_unrealize(Elm_Genlist_Item *it)
3152 Widget_Data *wd = it->wd;
3154 if (!it->mode_view) return;
3156 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3157 elm_widget_stringlist_free(it->mode_labels);
3158 it->mode_labels = NULL;
3159 elm_widget_stringlist_free(it->mode_icons);
3160 it->mode_icons = NULL;
3161 elm_widget_stringlist_free(it->mode_states);
3163 EINA_LIST_FREE(it->mode_icon_objs, icon)
3164 evas_object_del(icon);
3166 edje_object_part_unswallow(it->mode_view, it->base.view);
3167 evas_object_smart_member_add(it->base.view, wd->pan_smart);
3168 evas_object_del(it->mode_view);
3169 it->mode_view = NULL;
3171 if (wd->mode_item == it)
3172 wd->mode_item = NULL;
3173 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3174 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3178 _item_mode_set(Elm_Genlist_Item *it)
3181 Widget_Data *wd = it->wd;
3186 it->nocache = EINA_TRUE;
3188 if (wd->scr_hold_timer)
3190 ecore_timer_del(wd->scr_hold_timer);
3191 wd->scr_hold_timer = NULL;
3193 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3194 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3196 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3197 _mode_item_realize(it);
3198 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
3199 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3200 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3202 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3203 edje_object_signal_emit(it->mode_view, buf, "elm");
3207 _item_mode_unset(Widget_Data *wd)
3210 if (!wd->mode_item) return;
3211 char buf[1024], buf2[1024];
3212 Elm_Genlist_Item *it;
3215 it->nocache = EINA_TRUE;
3217 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3218 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3220 edje_object_signal_emit(it->mode_view, buf, "elm");
3221 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3223 wd->mode_item = NULL;
3227 elm_genlist_add(Evas_Object *parent)
3232 Evas_Coord minw, minh;
3233 static Evas_Smart *smart = NULL;
3237 static Evas_Smart_Class sc;
3239 evas_object_smart_clipped_smart_set(&_pan_sc);
3241 sc.name = "elm_genlist_pan";
3242 sc.version = EVAS_SMART_CLASS_VERSION;
3245 sc.resize = _pan_resize;
3246 sc.move = _pan_move;
3247 sc.calculate = _pan_calculate;
3248 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3251 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3253 ELM_SET_WIDTYPE(widtype, "genlist");
3254 elm_widget_type_set(obj, "genlist");
3255 elm_widget_sub_object_add(parent, obj);
3256 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3257 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3258 elm_widget_data_set(obj, wd);
3259 elm_widget_del_hook_set(obj, _del_hook);
3260 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3261 elm_widget_theme_hook_set(obj, _theme_hook);
3262 elm_widget_can_focus_set(obj, EINA_TRUE);
3263 elm_widget_event_hook_set(obj, _event_hook);
3264 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3266 wd->scr = elm_smart_scroller_add(e);
3267 elm_smart_scroller_widget_set(wd->scr, obj);
3268 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3269 elm_widget_style_get(obj));
3270 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3271 _elm_config->thumbscroll_bounce_enable);
3272 elm_widget_resize_object_set(obj, wd->scr);
3274 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3275 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3277 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3278 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3282 wd->mode = ELM_LIST_SCROLL;
3283 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3284 wd->item_cache_max = wd->max_items_per_block * 2;
3285 wd->longpress_timeout = _elm_config->longpress_timeout;
3286 wd->effect_mode = _elm_config->effect_enable;
3288 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3289 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3290 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3291 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3293 wd->pan_smart = evas_object_smart_add(e, smart);
3294 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3297 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3298 _pan_set, _pan_get, _pan_max_get,
3299 _pan_min_get, _pan_child_size_get);
3301 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3303 evas_object_size_hint_min_set(obj, minw, minh);
3305 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3306 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3311 static Elm_Genlist_Item *
3312 _item_new(Widget_Data *wd,
3313 const Elm_Genlist_Item_Class *itc,
3315 Elm_Genlist_Item *parent,
3316 Elm_Genlist_Item_Flags flags,
3318 const void *func_data)
3320 Elm_Genlist_Item *it;
3322 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3323 if (!it) return NULL;
3326 it->base.data = data;
3327 it->parent = parent;
3329 it->func.func = func;
3330 it->func.data = func_data;
3331 it->mouse_cursor = NULL;
3332 it->expanded_depth = 0;
3336 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3337 it->group_item = parent;
3338 else if (it->parent->group_item)
3339 it->group_item = it->parent->group_item;
3345 _item_block_add(Widget_Data *wd,
3346 Elm_Genlist_Item *it)
3348 Item_Block *itb = NULL;
3355 itb = calloc(1, sizeof(Item_Block));
3358 if (!it->rel->block)
3361 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3362 itb->items = eina_list_append(itb->items, it);
3368 wd->blocks = eina_inlist_prepend_relative
3369 (wd->blocks, EINA_INLIST_GET(itb),
3370 EINA_INLIST_GET(it->rel->block));
3372 eina_list_prepend_relative(itb->items, it, it->rel);
3376 wd->blocks = eina_inlist_append_relative
3377 (wd->blocks, EINA_INLIST_GET(itb),
3378 EINA_INLIST_GET(it->rel->block));
3380 eina_list_append_relative(itb->items, it, it->rel);
3390 itb = (Item_Block *)(wd->blocks);
3391 if (itb->count >= wd->max_items_per_block)
3393 itb = calloc(1, sizeof(Item_Block));
3397 eina_inlist_prepend(wd->blocks,
3398 EINA_INLIST_GET(itb));
3403 itb = calloc(1, sizeof(Item_Block));
3407 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3409 itb->items = eina_list_prepend(itb->items, it);
3415 itb = (Item_Block *)(wd->blocks->last);
3416 if (itb->count >= wd->max_items_per_block)
3418 itb = calloc(1, sizeof(Item_Block));
3422 eina_inlist_append(wd->blocks,
3423 EINA_INLIST_GET(itb));
3428 itb = calloc(1, sizeof(Item_Block));
3432 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3434 itb->items = eina_list_append(itb->items, it);
3440 itb = it->rel->block;
3441 if (!itb) goto newblock;
3443 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3445 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3448 itb->changed = EINA_TRUE;
3450 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3451 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3454 it->rel->relcount--;
3455 if ((it->rel->delete_me) && (!it->rel->relcount))
3459 if (itb->count > itb->wd->max_items_per_block)
3463 Elm_Genlist_Item *it2;
3465 newc = itb->count / 2;
3466 itb2 = calloc(1, sizeof(Item_Block));
3470 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3471 EINA_INLIST_GET(itb));
3472 itb2->changed = EINA_TRUE;
3473 while ((itb->count > newc) && (itb->items))
3477 l = eina_list_last(itb->items);
3479 itb->items = eina_list_remove_list(itb->items, l);
3482 itb2->items = eina_list_prepend(itb2->items, it2);
3490 _queue_process(Widget_Data *wd)
3493 Eina_Bool showme = EINA_FALSE;
3496 t0 = ecore_time_get();
3497 //evas_event_freeze(evas_object_evas_get(wd->obj));
3498 for (n = 0; (wd->queue) && (n < 128); n++)
3500 Elm_Genlist_Item *it;
3502 it = wd->queue->data;
3503 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3504 it->queued = EINA_FALSE;
3505 _item_block_add(wd, it);
3506 t = ecore_time_get();
3507 if (it->block->changed)
3509 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3510 it->block->changed = 0;
3512 if (showme) it->block->showme = EINA_TRUE;
3513 if (eina_inlist_count(wd->blocks) > 1)
3515 if ((t - t0) > (ecore_animator_frametime_get())) break;
3518 //evas_event_thaw(evas_object_evas_get(wd->obj));
3519 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3524 _idle_process(void *data, Eina_Bool *wakeup)
3526 Widget_Data *wd = data;
3529 //static double q_start = 0.0;
3530 //if (q_start == 0.0) q_start = ecore_time_get();
3532 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3536 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3538 return ECORE_CALLBACK_CANCEL;
3540 return ECORE_CALLBACK_RENEW;
3544 _item_idle_enterer(void *data)
3546 Widget_Data *wd = data;
3547 Eina_Bool wakeup = EINA_FALSE;
3548 Eina_Bool ok = _idle_process(data, &wakeup);
3553 if (wd->calc_job) ecore_job_del(wd->calc_job);
3554 wd->calc_job = ecore_job_add(_calc_job, wd);
3556 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3561 _item_queue(Widget_Data *wd,
3562 Elm_Genlist_Item *it)
3564 if (it->queued) return;
3565 it->queued = EINA_TRUE;
3566 wd->queue = eina_list_append(wd->queue, it);
3567 // FIXME: why does a freeze then thaw here cause some genlist
3568 // elm_genlist_item_append() to be much much slower?
3569 // evas_event_freeze(evas_object_evas_get(wd->obj));
3570 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3572 if (wd->queue_idle_enterer)
3574 ecore_idle_enterer_del(wd->queue_idle_enterer);
3575 wd->queue_idle_enterer = NULL;
3579 // evas_event_thaw(evas_object_evas_get(wd->obj));
3580 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3581 if (!wd->queue_idle_enterer)
3582 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3586 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3591 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3592 it->wd->reorder_deleted = EINA_TRUE;
3593 _item_block_del(it);
3595 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3597 it->rel->relcount++;
3598 it->before = EINA_FALSE;
3599 if (after->group_item) it->group_item = after->group_item;
3600 _item_queue(it->wd, it);
3602 // TODO: change this to smart callback
3603 if (it->itc->func.moved)
3604 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
3608 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3611 if (!before) return;
3613 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3614 it->wd->reorder_deleted = EINA_TRUE;
3615 _item_block_del(it);
3616 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3618 it->rel->relcount++;
3619 it->before = EINA_TRUE;
3620 if (before->group_item) it->group_item = before->group_item;
3621 _item_queue(it->wd, it);
3623 // TODO: change this to smart callback
3624 if (it->itc->func.moved)
3625 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
3628 EAPI Elm_Genlist_Item *
3629 elm_genlist_item_append(Evas_Object *obj,
3630 const Elm_Genlist_Item_Class *itc,
3632 Elm_Genlist_Item *parent,
3633 Elm_Genlist_Item_Flags flags,
3635 const void *func_data)
3637 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3638 Widget_Data *wd = elm_widget_data_get(obj);
3639 if (!wd) return NULL;
3640 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3642 if (!it) return NULL;
3645 if (flags & ELM_GENLIST_ITEM_GROUP)
3646 wd->group_items = eina_list_append(wd->group_items, it);
3647 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3652 Elm_Genlist_Item *it2 = NULL;
3653 Eina_List *ll = eina_list_last(it->parent->items);
3654 if (ll) it2 = ll->data;
3655 it->parent->items = eina_list_append(it->parent->items, it);
3656 if (!it2) it2 = it->parent;
3658 it2 = elm_genlist_item_prev_get(it2);
3660 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3661 EINA_INLIST_GET(it2));
3663 it->rel->relcount++;
3665 it->before = EINA_FALSE;
3666 _item_queue(wd, it);
3670 EAPI Elm_Genlist_Item *
3671 elm_genlist_item_prepend(Evas_Object *obj,
3672 const Elm_Genlist_Item_Class *itc,
3674 Elm_Genlist_Item *parent,
3675 Elm_Genlist_Item_Flags flags,
3677 const void *func_data)
3679 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3680 Widget_Data *wd = elm_widget_data_get(obj);
3681 if (!wd) return NULL;
3682 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3684 if (!it) return NULL;
3687 if (flags & ELM_GENLIST_ITEM_GROUP)
3688 wd->group_items = eina_list_prepend(wd->group_items, it);
3689 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3694 Elm_Genlist_Item *it2 = NULL;
3695 Eina_List *ll = it->parent->items;
3696 if (ll) it2 = ll->data;
3697 it->parent->items = eina_list_prepend(it->parent->items, it);
3698 if (!it2) it2 = it->parent;
3700 it2 = elm_genlist_item_next_get(it2);
3702 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3703 EINA_INLIST_GET(it2));
3705 it->rel->relcount++;
3707 it->before = EINA_TRUE;
3708 _item_queue(wd, it);
3712 EAPI Elm_Genlist_Item *
3713 elm_genlist_item_insert_after(Evas_Object *obj,
3714 const Elm_Genlist_Item_Class *itc,
3716 Elm_Genlist_Item *parent,
3717 Elm_Genlist_Item *after,
3718 Elm_Genlist_Item_Flags flags,
3720 const void *func_data)
3722 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3723 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3724 Widget_Data *wd = elm_widget_data_get(obj);
3725 if (!wd) return NULL;
3726 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3728 if (!it) return NULL;
3729 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3730 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3734 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3735 (after->flags & ELM_GENLIST_ITEM_GROUP))
3736 wd->group_items = eina_list_append_relative(wd->group_items, it,
3741 it->parent->items = eina_list_append_relative(it->parent->items, it,
3744 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3745 EINA_INLIST_GET(after));
3747 it->rel->relcount++;
3748 it->before = EINA_FALSE;
3749 _item_queue(wd, it);
3753 EAPI Elm_Genlist_Item *
3754 elm_genlist_item_insert_before(Evas_Object *obj,
3755 const Elm_Genlist_Item_Class *itc,
3757 Elm_Genlist_Item *parent,
3758 Elm_Genlist_Item *before,
3759 Elm_Genlist_Item_Flags flags,
3761 const void *func_data)
3763 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3764 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3765 Widget_Data *wd = elm_widget_data_get(obj);
3766 if (!wd) return NULL;
3767 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3769 if (!it) return NULL;
3770 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
3771 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3775 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3776 (before->flags & ELM_GENLIST_ITEM_GROUP))
3777 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
3782 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3785 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3786 EINA_INLIST_GET(before));
3788 it->rel->relcount++;
3789 it->before = EINA_TRUE;
3790 _item_queue(wd, it);
3795 elm_genlist_clear(Evas_Object *obj)
3797 ELM_CHECK_WIDTYPE(obj, widtype);
3798 Widget_Data *wd = elm_widget_data_get(obj);
3800 if (wd->walking > 0)
3802 Elm_Genlist_Item *it;
3804 wd->clear_me = EINA_TRUE;
3805 EINA_INLIST_FOREACH(wd->items, it)
3807 it->delete_me = EINA_TRUE;
3811 evas_event_freeze(evas_object_evas_get(wd->obj));
3814 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3815 it->nocache = EINA_TRUE;
3816 it->highlighted = EINA_FALSE;
3818 if (wd->anchor_item == it)
3820 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3821 if (!wd->anchor_item)
3823 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3826 wd->items = eina_inlist_remove(wd->items, wd->items);
3827 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3828 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3829 elm_widget_item_pre_notify_del(it);
3830 if (it->realized) _item_unrealize(it, EINA_FALSE);
3831 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3832 it->itc->func.del((void *)it->base.data, it->base.widget);
3833 if (it->long_timer) ecore_timer_del(it->long_timer);
3834 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3835 elm_widget_item_del(it);
3837 wd->clear_me = EINA_FALSE;
3838 wd->anchor_item = NULL;
3841 Item_Block *itb = (Item_Block *)(wd->blocks);
3843 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3844 if (itb->items) eina_list_free(itb->items);
3849 ecore_job_del(wd->calc_job);
3850 wd->calc_job = NULL;
3852 if (wd->queue_idle_enterer)
3854 ecore_idle_enterer_del(wd->queue_idle_enterer);
3855 wd->queue_idle_enterer = NULL;
3857 if (wd->must_recalc_idler)
3859 ecore_idler_del(wd->must_recalc_idler);
3860 wd->must_recalc_idler = NULL;
3864 eina_list_free(wd->queue);
3869 eina_list_free(wd->selected);
3870 wd->selected = NULL;
3872 if (wd->reorder_move_animator)
3874 ecore_animator_del(wd->reorder_move_animator);
3875 wd->reorder_move_animator = NULL;
3877 wd->show_item = NULL;
3885 evas_object_del(wd->alpha_bg);
3886 wd->alpha_bg = NULL;
3890 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3891 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3894 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
3895 evas_event_thaw(evas_object_evas_get(wd->obj));
3896 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3900 elm_genlist_multi_select_set(Evas_Object *obj,
3903 ELM_CHECK_WIDTYPE(obj, widtype);
3904 Widget_Data *wd = elm_widget_data_get(obj);
3910 elm_genlist_multi_select_get(const Evas_Object *obj)
3912 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3913 Widget_Data *wd = elm_widget_data_get(obj);
3914 if (!wd) return EINA_FALSE;
3918 EAPI Elm_Genlist_Item *
3919 elm_genlist_selected_item_get(const Evas_Object *obj)
3921 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3922 Widget_Data *wd = elm_widget_data_get(obj);
3923 if (!wd) return NULL;
3924 if (wd->selected) return wd->selected->data;
3928 EAPI const Eina_List *
3929 elm_genlist_selected_items_get(const Evas_Object *obj)
3931 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3932 Widget_Data *wd = elm_widget_data_get(obj);
3933 if (!wd) return NULL;
3934 return wd->selected;
3938 elm_genlist_realized_items_get(const Evas_Object *obj)
3940 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3941 Widget_Data *wd = elm_widget_data_get(obj);
3942 Eina_List *list = NULL;
3944 Eina_Bool done = EINA_FALSE;
3945 if (!wd) return NULL;
3946 EINA_INLIST_FOREACH(wd->blocks, itb)
3951 Elm_Genlist_Item *it;
3954 EINA_LIST_FOREACH(itb->items, l, it)
3956 if (it->realized) list = eina_list_append(list, it);
3967 EAPI Elm_Genlist_Item *
3968 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3973 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3974 Widget_Data *wd = elm_widget_data_get(obj);
3975 Evas_Coord ox, oy, ow, oh;
3978 if (!wd) return NULL;
3979 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3981 EINA_INLIST_FOREACH(wd->blocks, itb)
3984 Elm_Genlist_Item *it;
3986 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3987 oy + itb->y - itb->wd->pan_y,
3988 itb->w, itb->h, x, y, 1, 1))
3990 EINA_LIST_FOREACH(itb->items, l, it)
3992 Evas_Coord itx, ity;
3994 itx = ox + itb->x + it->x - itb->wd->pan_x;
3995 ity = oy + itb->y + it->y - itb->wd->pan_y;
3996 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4000 if (y <= (ity + (it->h / 4))) *posret = -1;
4001 else if (y >= (ity + it->h - (it->h / 4)))
4007 lasty = ity + it->h;
4012 if (y > lasty) *posret = 1;
4018 EAPI Elm_Genlist_Item *
4019 elm_genlist_first_item_get(const Evas_Object *obj)
4021 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4022 Widget_Data *wd = elm_widget_data_get(obj);
4023 if (!wd) return NULL;
4024 if (!wd->items) return NULL;
4025 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4026 while ((it) && (it->delete_me))
4027 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4031 EAPI Elm_Genlist_Item *
4032 elm_genlist_last_item_get(const Evas_Object *obj)
4034 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4035 Widget_Data *wd = elm_widget_data_get(obj);
4036 if (!wd) return NULL;
4037 if (!wd->items) return NULL;
4038 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4039 while ((it) && (it->delete_me))
4040 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4044 EAPI Elm_Genlist_Item *
4045 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4047 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4050 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4051 if ((it) && (!it->delete_me)) break;
4053 return (Elm_Genlist_Item *)it;
4056 EAPI Elm_Genlist_Item *
4057 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4059 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4062 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4063 if ((it) && (!it->delete_me)) break;
4065 return (Elm_Genlist_Item *)it;
4069 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4071 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4072 return it->base.widget;
4075 EAPI Elm_Genlist_Item *
4076 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4078 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4083 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4085 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4086 Elm_Genlist_Item *it2;
4089 if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4090 _item_subitems_clear(it);
4093 if ((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4094 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4096 it->wd->expand_item = it;
4097 _item_flip_effect_show(it);
4098 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4099 it->wd->expand_item_end = y + h;
4103 it2 = elm_genlist_item_next_get(it2);
4105 } while (it2->expanded_depth > it->expanded_depth);
4107 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4109 it->wd->expand_item_gap = 0;
4111 evas_object_raise(it->wd->alpha_bg);
4112 evas_object_show(it->wd->alpha_bg);
4114 it->wd->start_time = current_time_get();
4115 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4118 _item_subitems_clear(it);
4123 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4126 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4127 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4129 if ((it->delete_me) || (it->disabled)) return;
4130 selected = !!selected;
4131 if (it->selected == selected) return;
4137 while (wd->selected)
4138 _item_unselect(wd->selected->data);
4140 _item_highlight(it);
4148 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4150 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4151 return it->selected;
4155 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4158 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4159 if (it->flags != ELM_GENLIST_ITEM_SUBITEMS) return;
4160 if (it->expanded == expanded) return;
4161 it->expanded = expanded;
4162 it->wd->expand_item = it;
4164 if (it->wd->effect_mode && !it->wd->alpha_bg)
4165 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4169 it->wd->auto_scrolled = EINA_FALSE;
4170 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4172 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4173 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4177 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4179 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4180 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4185 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4187 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4188 return it->expanded;
4192 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4194 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4195 return it->expanded_depth;
4199 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4202 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4205 if (it->disabled == disabled) return;
4206 if (it->delete_me) return;
4207 it->disabled = disabled;
4209 elm_genlist_item_selected_set(it, EINA_FALSE);
4214 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4216 edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
4220 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4222 edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
4224 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4225 elm_widget_disabled_set(obj, disabled);
4230 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4232 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4233 if (it->delete_me) return EINA_FALSE;
4234 return it->disabled;
4238 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4239 Eina_Bool display_only)
4241 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4242 if (it->display_only == display_only) return;
4243 if (it->delete_me) return;
4244 it->display_only = display_only;
4245 it->mincalcd = EINA_FALSE;
4246 it->updateme = EINA_TRUE;
4247 if (it->block) it->block->updateme = EINA_TRUE;
4248 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4249 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4253 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4255 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4256 if (it->delete_me) return EINA_FALSE;
4257 return it->display_only;
4261 elm_genlist_item_show(Elm_Genlist_Item *it)
4263 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4264 Evas_Coord gith = 0;
4265 if (it->delete_me) return;
4266 if ((it->queued) || (!it->mincalcd))
4268 it->wd->show_item = it;
4269 it->wd->bring_in = EINA_TRUE;
4270 it->showme = EINA_TRUE;
4273 if (it->wd->show_item)
4275 it->wd->show_item->showme = EINA_FALSE;
4276 it->wd->show_item = NULL;
4278 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4279 gith = it->group_item->h;
4280 elm_smart_scroller_child_region_show(it->wd->scr,
4281 it->x + it->block->x,
4282 it->y + it->block->y - gith,
4283 it->block->w, it->h);
4287 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4289 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4290 Evas_Coord gith = 0;
4291 if (it->delete_me) return;
4292 if ((it->queued) || (!it->mincalcd))
4294 it->wd->show_item = it;
4295 it->wd->bring_in = EINA_TRUE;
4296 it->showme = EINA_TRUE;
4299 if (it->wd->show_item)
4301 it->wd->show_item->showme = EINA_FALSE;
4302 it->wd->show_item = NULL;
4304 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4305 gith = it->group_item->h;
4306 elm_smart_scroller_region_bring_in(it->wd->scr,
4307 it->x + it->block->x,
4308 it->y + it->block->y - gith,
4309 it->block->w, it->h);
4313 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4315 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4317 Evas_Coord gith = 0;
4319 if (it->delete_me) return;
4320 if ((it->queued) || (!it->mincalcd))
4322 it->wd->show_item = it;
4323 it->wd->bring_in = EINA_TRUE;
4324 it->showme = EINA_TRUE;
4327 if (it->wd->show_item)
4329 it->wd->show_item->showme = EINA_FALSE;
4330 it->wd->show_item = NULL;
4332 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4333 if (it->group_item) gith = it->group_item->h;
4334 elm_smart_scroller_child_region_show(it->wd->scr,
4335 it->x + it->block->x,
4336 it->y + it->block->y - gith,
4341 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4343 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4345 Evas_Coord gith = 0;
4347 if (it->delete_me) return;
4348 if ((it->queued) || (!it->mincalcd))
4350 it->wd->show_item = it;
4351 it->wd->bring_in = EINA_TRUE;
4352 it->showme = EINA_TRUE;
4355 if (it->wd->show_item)
4357 it->wd->show_item->showme = EINA_FALSE;
4358 it->wd->show_item = NULL;
4360 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4361 if (it->group_item) gith = it->group_item->h;
4362 elm_smart_scroller_region_bring_in(it->wd->scr,
4363 it->x + it->block->x,
4364 it->y + it->block->y - gith,
4369 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4371 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4374 if (it->delete_me) return;
4375 if ((it->queued) || (!it->mincalcd))
4377 it->wd->show_item = it;
4378 it->wd->bring_in = EINA_TRUE;
4379 it->showme = EINA_TRUE;
4382 if (it->wd->show_item)
4384 it->wd->show_item->showme = EINA_FALSE;
4385 it->wd->show_item = NULL;
4387 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4388 elm_smart_scroller_child_region_show(it->wd->scr,
4389 it->x + it->block->x,
4390 it->y + it->block->y - oh / 2 +
4391 it->h / 2, it->block->w, oh);
4395 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4397 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4400 if (it->delete_me) return;
4401 if ((it->queued) || (!it->mincalcd))
4403 it->wd->show_item = it;
4404 it->wd->bring_in = EINA_TRUE;
4405 it->showme = EINA_TRUE;
4408 if (it->wd->show_item)
4410 it->wd->show_item->showme = EINA_FALSE;
4411 it->wd->show_item = NULL;
4413 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4414 elm_smart_scroller_region_bring_in(it->wd->scr,
4415 it->x + it->block->x,
4416 it->y + it->block->y - oh / 2 + it->h / 2,
4421 elm_genlist_item_del(Elm_Genlist_Item *it)
4423 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4424 if ((it->relcount > 0) || (it->walking > 0))
4426 elm_widget_item_pre_notify_del(it);
4427 elm_genlist_item_subitems_clear(it);
4428 it->delete_me = EINA_TRUE;
4429 if (it->wd->show_item == it) it->wd->show_item = NULL;
4431 it->wd->selected = eina_list_remove(it->wd->selected,
4435 if (it->realized) _item_unrealize(it, EINA_FALSE);
4436 it->block->changed = EINA_TRUE;
4437 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4438 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4440 if (it->itc->func.del)
4441 it->itc->func.del((void *)it->base.data, it->base.widget);
4448 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4451 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4452 elm_widget_item_data_set(it, data);
4453 elm_genlist_item_update(it);
4457 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4459 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4460 return elm_widget_item_data_get(it);
4464 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4467 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4468 EINA_LIST_FREE(it->icon_objs, icon)
4470 elm_widget_sub_object_del(it->base.widget, icon);
4471 evas_object_smart_member_del(icon);
4472 evas_object_hide(icon);
4476 EAPI const Evas_Object *
4477 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4479 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4480 return it->base.view;
4484 elm_genlist_item_update(Elm_Genlist_Item *it)
4486 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4487 if (!it->block) return;
4488 if (it->delete_me) return;
4489 it->mincalcd = EINA_FALSE;
4490 it->updateme = EINA_TRUE;
4491 it->block->updateme = EINA_TRUE;
4492 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4493 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4497 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4498 const Elm_Genlist_Item_Class *itc)
4500 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4501 if (!it->block) return;
4502 EINA_SAFETY_ON_NULL_RETURN(itc);
4503 if (it->delete_me) return;
4505 it->nocache = EINA_TRUE;
4506 elm_genlist_item_update(it);
4509 EAPI const Elm_Genlist_Item_Class *
4510 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4512 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4513 if (it->delete_me) return NULL;
4516 static Evas_Object *
4517 _elm_genlist_item_label_create(void *data,
4519 void *item __UNUSED__)
4521 Evas_Object *label = elm_label_add(obj);
4524 elm_object_style_set(label, "tooltip");
4525 elm_object_text_set(label, data);
4530 _elm_genlist_item_label_del_cb(void *data,
4531 Evas_Object *obj __UNUSED__,
4532 void *event_info __UNUSED__)
4534 eina_stringshare_del(data);
4538 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4541 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4542 text = eina_stringshare_add(text);
4543 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4545 _elm_genlist_item_label_del_cb);
4549 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4550 Elm_Tooltip_Item_Content_Cb func,
4552 Evas_Smart_Cb del_cb)
4554 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4556 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4559 if (item->tooltip.del_cb)
4560 item->tooltip.del_cb((void *)item->tooltip.data,
4561 item->base.widget, item);
4563 item->tooltip.content_cb = func;
4564 item->tooltip.data = data;
4565 item->tooltip.del_cb = del_cb;
4567 if (item->base.view)
4569 elm_widget_item_tooltip_content_cb_set(item,
4570 item->tooltip.content_cb,
4571 item->tooltip.data, NULL);
4572 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4578 if (del_cb) del_cb((void *)data, NULL, NULL);
4582 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4584 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4585 if ((item->base.view) && (item->tooltip.content_cb))
4586 elm_widget_item_tooltip_unset(item);
4588 if (item->tooltip.del_cb)
4589 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4590 item->tooltip.del_cb = NULL;
4591 item->tooltip.content_cb = NULL;
4592 item->tooltip.data = NULL;
4593 if (item->tooltip.style)
4594 elm_genlist_item_tooltip_style_set(item, NULL);
4598 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4601 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4602 eina_stringshare_replace(&item->tooltip.style, style);
4603 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4607 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4609 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4610 return item->tooltip.style;
4614 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4617 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4618 eina_stringshare_replace(&item->mouse_cursor, cursor);
4619 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4623 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4625 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4626 return elm_widget_item_cursor_get(item);
4630 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4632 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4633 if (!item->mouse_cursor)
4636 if (item->base.view)
4637 elm_widget_item_cursor_unset(item);
4639 eina_stringshare_del(item->mouse_cursor);
4640 item->mouse_cursor = NULL;
4644 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4647 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4648 elm_widget_item_cursor_style_set(item, style);
4652 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4654 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4655 return elm_widget_item_cursor_style_get(item);
4659 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4660 Eina_Bool engine_only)
4662 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4663 elm_widget_item_cursor_engine_only_set(item, engine_only);
4667 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4669 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4670 return elm_widget_item_cursor_engine_only_get(item);
4674 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4677 ELM_CHECK_WIDTYPE(obj, widtype);
4678 Widget_Data *wd = elm_widget_data_get(obj);
4680 if (wd->mode == mode) return;
4686 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4688 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4689 Widget_Data *wd = elm_widget_data_get(obj);
4690 if (!wd) return ELM_LIST_LAST;
4695 elm_genlist_always_select_mode_set(Evas_Object *obj,
4696 Eina_Bool always_select)
4698 ELM_CHECK_WIDTYPE(obj, widtype);
4699 Widget_Data *wd = elm_widget_data_get(obj);
4701 wd->always_select = always_select;
4705 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4707 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4708 Widget_Data *wd = elm_widget_data_get(obj);
4709 if (!wd) return EINA_FALSE;
4710 return wd->always_select;
4714 elm_genlist_no_select_mode_set(Evas_Object *obj,
4715 Eina_Bool no_select)
4717 ELM_CHECK_WIDTYPE(obj, widtype);
4718 Widget_Data *wd = elm_widget_data_get(obj);
4720 wd->no_select = no_select;
4724 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4726 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4727 Widget_Data *wd = elm_widget_data_get(obj);
4728 if (!wd) return EINA_FALSE;
4729 return wd->no_select;
4733 elm_genlist_compress_mode_set(Evas_Object *obj,
4736 ELM_CHECK_WIDTYPE(obj, widtype);
4737 Widget_Data *wd = elm_widget_data_get(obj);
4739 wd->compress = compress;
4743 elm_genlist_compress_mode_get(const Evas_Object *obj)
4745 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4746 Widget_Data *wd = elm_widget_data_get(obj);
4747 if (!wd) return EINA_FALSE;
4748 return wd->compress;
4752 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4753 Eina_Bool height_for_width)
4755 ELM_CHECK_WIDTYPE(obj, widtype);
4756 Widget_Data *wd = elm_widget_data_get(obj);
4758 wd->height_for_width = !!height_for_width;
4759 if (wd->height_for_width)
4761 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4762 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4767 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4769 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4770 Widget_Data *wd = elm_widget_data_get(obj);
4771 if (!wd) return EINA_FALSE;
4772 return wd->height_for_width;
4776 elm_genlist_bounce_set(Evas_Object *obj,
4780 ELM_CHECK_WIDTYPE(obj, widtype);
4781 Widget_Data *wd = elm_widget_data_get(obj);
4783 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4787 elm_genlist_bounce_get(const Evas_Object *obj,
4788 Eina_Bool *h_bounce,
4789 Eina_Bool *v_bounce)
4791 ELM_CHECK_WIDTYPE(obj, widtype);
4792 Widget_Data *wd = elm_widget_data_get(obj);
4794 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4798 elm_genlist_homogeneous_set(Evas_Object *obj,
4799 Eina_Bool homogeneous)
4801 ELM_CHECK_WIDTYPE(obj, widtype);
4802 Widget_Data *wd = elm_widget_data_get(obj);
4804 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4805 wd->homogeneous = homogeneous;
4809 elm_genlist_homogeneous_get(const Evas_Object *obj)
4811 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4812 Widget_Data *wd = elm_widget_data_get(obj);
4813 if (!wd) return EINA_FALSE;
4814 return wd->homogeneous;
4818 elm_genlist_block_count_set(Evas_Object *obj,
4821 ELM_CHECK_WIDTYPE(obj, widtype);
4822 Widget_Data *wd = elm_widget_data_get(obj);
4824 wd->max_items_per_block = n;
4825 wd->item_cache_max = wd->max_items_per_block * 2;
4826 _item_cache_clean(wd);
4830 elm_genlist_block_count_get(const Evas_Object *obj)
4832 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4833 Widget_Data *wd = elm_widget_data_get(obj);
4835 return wd->max_items_per_block;
4839 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4842 ELM_CHECK_WIDTYPE(obj, widtype);
4843 Widget_Data *wd = elm_widget_data_get(obj);
4845 wd->longpress_timeout = timeout;
4849 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4851 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4852 Widget_Data *wd = elm_widget_data_get(obj);
4854 return wd->longpress_timeout;
4858 elm_genlist_scroller_policy_set(Evas_Object *obj,
4859 Elm_Scroller_Policy policy_h,
4860 Elm_Scroller_Policy policy_v)
4862 ELM_CHECK_WIDTYPE(obj, widtype);
4863 Widget_Data *wd = elm_widget_data_get(obj);
4865 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4866 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4869 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4873 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4874 Elm_Scroller_Policy *policy_h,
4875 Elm_Scroller_Policy *policy_v)
4877 ELM_CHECK_WIDTYPE(obj, widtype);
4878 Widget_Data *wd = elm_widget_data_get(obj);
4879 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4880 if ((!wd) || (!wd->scr)) return;
4881 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4882 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4883 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
4887 elm_genlist_realized_items_update(Evas_Object *obj)
4889 ELM_CHECK_WIDTYPE(obj, widtype);
4891 Eina_List *list, *l;
4892 Elm_Genlist_Item *it;
4894 list = elm_genlist_realized_items_get(obj);
4895 EINA_LIST_FOREACH(list, l, it)
4896 elm_genlist_item_update(it);
4900 * Set genlist item mode
4902 * @param item The genlist item
4903 * @param mode Mode name
4904 * @param mode_set Boolean to define set or unset mode.
4909 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
4910 const char *mode_type,
4913 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4914 Widget_Data *wd = it->wd;
4916 Elm_Genlist_Item *it2;
4919 if (!mode_type) return;
4920 if ((it->delete_me) || (it->disabled)) return;
4921 if (wd->edit_mode) return;
4923 if ((wd->mode_item == it) &&
4924 (!strcmp(mode_type, wd->mode_type)) &&
4927 if (!it->itc->mode_item_style) return;
4931 EINA_LIST_FOREACH(wd->selected, l, it2)
4933 elm_genlist_item_selected_set(it2, EINA_FALSE);
4937 it2 = elm_genlist_selected_item_get(wd->obj);
4938 if ((it2) && (it2->realized))
4939 elm_genlist_item_selected_set(it2, EINA_FALSE);
4942 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
4944 ((it == wd->mode_item) && (!mode_set)))
4945 _item_mode_unset(wd);
4947 eina_stringshare_replace(&wd->mode_type, mode_type);
4948 if (mode_set) _item_mode_set(it);
4952 * Get active genlist mode type
4954 * @param obj The genlist object
4959 elm_genlist_mode_get(const Evas_Object *obj)
4961 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4962 Widget_Data *wd = elm_widget_data_get(obj);
4963 if (!wd) return NULL;
4964 return wd->mode_type;
4968 * Get active genlist mode item
4970 * @param obj The genlist object
4974 EAPI const Elm_Genlist_Item *
4975 elm_genlist_mode_item_get(const Evas_Object *obj)
4977 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4978 Widget_Data *wd = elm_widget_data_get(obj);
4979 if (!wd) return NULL;
4980 return wd->mode_item;
4984 elm_genlist_reorder_mode_set(Evas_Object *obj,
4985 Eina_Bool reorder_mode)
4987 ELM_CHECK_WIDTYPE(obj, widtype);
4988 Widget_Data *wd = elm_widget_data_get(obj);
4990 wd->reorder_mode = reorder_mode;
4994 elm_genlist_reorder_mode_get(const Evas_Object *obj)
4996 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4997 Widget_Data *wd = elm_widget_data_get(obj);
4998 if (!wd) return EINA_FALSE;
4999 return wd->reorder_mode;
5003 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
5009 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
5015 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5017 ELM_CHECK_WIDTYPE(obj, widtype);
5018 Widget_Data *wd = elm_widget_data_get(obj);
5020 wd->effect_mode = emode;
5021 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5022 // evas_object_resize(wd->point_rect, 10, 25);
5023 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5024 // evas_object_show(wd->point_rect);
5025 // evas_object_hide(wd->point_rect);
5029 _create_tray_alpha_bg(const Evas_Object *obj)
5031 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5032 Widget_Data *wd = elm_widget_data_get(obj);
5033 if (!wd) return NULL;
5035 Evas_Object *bg = NULL;
5036 Evas_Coord ox, oy, ow, oh;
5038 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5039 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5040 evas_object_color_set(bg,0,0,0,0);
5041 evas_object_resize(bg , ow, oh);
5042 evas_object_move(bg , ox, oy);
5043 evas_object_show(bg);
5044 evas_object_hide(bg);
5051 struct timeval timev;
5053 gettimeofday(&timev, NULL);
5054 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5057 // added for item moving animation.
5059 _item_moving_effect_timer_cb(void *data)
5061 Widget_Data *wd = data;
5062 if (!wd) return EINA_FALSE;
5064 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5065 Elm_Genlist_Item *it = NULL, *it2;
5067 double time = 0.3, t;
5069 Eina_Bool check, end = EINA_FALSE;
5072 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5074 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5075 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5076 if (t > time) end = EINA_TRUE;
5078 it2 = elm_genlist_item_next_get(wd->expand_item);
5081 if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5082 it2 = elm_genlist_item_next_get(it2);
5087 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5088 dy = it2->scrl_y - it2->old_scrl_y;
5089 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5090 dy = wd->expand_item_gap;
5094 y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5103 EINA_INLIST_FOREACH(wd->blocks, itb)
5106 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5107 itb->y - wd->pan_y + oy,
5109 cvx, cvy, cvw, cvh))
5111 EINA_LIST_FOREACH(itb->items, l, it)
5113 if (it == it2) check = EINA_TRUE;
5114 if (!check) continue;
5116 if (!it->old_scrl_y)
5117 it->old_scrl_y = it->scrl_y;
5118 if (it->old_scrl_y + y < oy + oh)
5120 if (!it->realized) _item_realize(it, in, 0);
5122 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5123 it->old_scrl_y = it->scrl_y - y;
5126 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5127 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5129 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5132 evas_object_resize(it->base.view, it->w, it->h);
5133 evas_object_move(it->base.view, it->scrl_x, it->old_scrl_y + y);
5134 evas_object_show(it->base.view);
5135 evas_object_raise(it->base.view);
5138 if (it->group_item) evas_object_raise(it->group_item->base.view);
5144 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5146 it = elm_genlist_item_prev_get(it2);
5149 if (it->expanded_depth <= it2->expanded_depth) break;
5150 if ((it->scrl_y < it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5152 if (!it->effect_done)
5154 edje_object_signal_emit(it->base.view, "flip_item", "");
5155 evas_object_show(it->base.view);
5156 it->effect_done = EINA_TRUE;
5159 it = elm_genlist_item_prev_get(it);
5162 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5164 it = elm_genlist_item_prev_get(it2);
5167 if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5169 if (!it->effect_done)
5171 edje_object_signal_emit(it->base.view, "elm,state,hide", "");
5172 it->effect_done = EINA_TRUE;
5177 it = elm_genlist_item_prev_get(it);
5184 int expand_order = 0;
5185 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5189 it = elm_genlist_item_next_get(it);
5191 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5195 if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
5196 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5198 if (!it->effect_done)
5200 if (t >= (((expand_order - 1) * time) / expand_num))
5202 edje_object_signal_emit(it->base.view, "flip_item", "");
5203 evas_object_show(it->base.view);
5204 it->effect_done = EINA_TRUE;
5208 it = elm_genlist_item_next_get(it);
5214 if (wd->item_moving_effect_timer)
5216 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5217 _item_subitems_clear(wd->expand_item);
5218 EINA_INLIST_FOREACH(wd->blocks, itb)
5220 EINA_LIST_FOREACH(itb->items, l, it)
5222 it->effect_done = EINA_TRUE;
5223 it->old_scrl_y = it->scrl_y;
5227 wd->item_moving_effect_timer = NULL;
5229 _item_auto_scroll(wd);
5230 evas_object_lower(wd->alpha_bg);
5231 evas_object_hide(wd->alpha_bg);
5232 if (wd->calc_job) ecore_job_del(wd->calc_job);
5233 wd->calc_job = ecore_job_add(_calc_job, wd);
5234 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5235 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5237 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5238 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5239 return ECORE_CALLBACK_CANCEL;
5241 return ECORE_CALLBACK_RENEW;
5245 _emit_contract(Elm_Genlist_Item *it)
5247 Elm_Genlist_Item *it2;
5250 // printf("%p is emited contract\n", it);
5251 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5252 it->effect_done = EINA_FALSE;
5254 EINA_LIST_FOREACH(it->items, l, it2)
5256 _emit_contract(it2);
5259 // added for item moving animation.
5261 _item_flip_effect_show(Elm_Genlist_Item *it)
5263 Elm_Genlist_Item *it2;
5265 Widget_Data *wd = it->wd;
5266 Eina_Bool check = EINA_FALSE;
5268 it2 = elm_genlist_item_next_get(it);
5271 if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5272 it2 = elm_genlist_item_next_get(it2);
5274 EINA_LIST_FOREACH(it->items, l, it2)
5276 if (it2->parent && it == it2->parent)
5278 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5279 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5280 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5281 _emit_contract(it2);
5285 return ECORE_CALLBACK_CANCEL;
5290 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5292 printf("!!! NOW FIXING \n");
5297 * Set pinch zoom mode
5299 * @param obj The genlist object
5301 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5306 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5308 printf("!!! NOW FIXING \n");
5312 * Get pinch zoom mode
5314 * @param obj The genlist object
5315 * @return The pinch mode
5316 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5321 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
5323 printf("!!! NOW FIXING \n");
5328 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5330 printf("!!! NOW FIXING \n");
5334 ////////////////////////////////////////////////////////////////////////
5336 ////////////////////////////////////////////////////////////////////////
5339 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5341 if (!it->wd->edit_mode) return;
5342 evas_object_resize(it->edit_obj,it->w, it->h);
5343 evas_object_move(it->edit_obj, itx, ity);
5347 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5349 if ((it->effect_item_realized) || (it->delete_me)) return;
5353 _mode_finished_signal_cb(it, (Evas_Object *)elm_genlist_item_object_get(it), NULL, NULL);
5355 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
5356 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
5357 _elm_config->scale);
5358 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5359 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
5361 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5362 else strncpy(buf, "item", sizeof(buf));
5363 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5365 strncat(buf, "/", sizeof(buf) - strlen(buf));
5367 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5369 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
5370 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
5374 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget));
5377 if (it->wd->reorder_mode)
5379 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
5380 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
5382 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
5383 else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
5385 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
5386 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
5389 if ((it->wd->edit_mode))
5391 if (it->itc->func.icon_get)
5396 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5397 EINA_LIST_FOREACH(it->icons, l, key)
5399 Evas_Object *ic = it->itc->func.icon_get
5400 ((void *)it->base.data, it->base.widget, l->data);
5404 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5405 edje_object_part_swallow(it->edit_obj, key, ic);
5406 evas_object_show(ic);
5407 elm_widget_sub_object_add(it->base.widget, ic);
5409 elm_widget_disabled_set(ic, EINA_TRUE);
5414 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
5415 _effect_item_controls(it,it->scrl_x, it->scrl_y);
5416 evas_object_show(it->edit_obj);
5418 it->effect_item_realized = EINA_TRUE;
5419 it->want_unrealize = EINA_FALSE;
5423 _effect_item_unrealize(Elm_Genlist_Item *it)
5427 if (!it->effect_item_realized) return;
5428 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5430 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
5431 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
5432 edje_object_message_signal_process(it->edit_obj);
5433 edje_object_part_unswallow(it->edit_obj, it->base.view);
5434 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
5435 elm_widget_sub_object_add(it->base.widget, it->base.view);
5436 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5437 // _item_cache_add(it);
5438 evas_object_del(it->edit_obj);
5439 it->edit_obj = NULL;
5440 EINA_LIST_FREE(it->edit_icon_objs, icon)
5441 evas_object_del(icon);
5443 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5444 it->effect_item_realized = EINA_FALSE;
5448 * Get Genlist edit mode
5450 * @param obj The genlist object
5451 * @return The edit mode status
5452 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5457 elm_genlist_edit_mode_get(const Evas_Object *obj)
5459 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5460 Widget_Data *wd = elm_widget_data_get(obj);
5461 if (!wd) return EINA_FALSE;
5463 if (wd->edit_mode) return EINA_TRUE;
5464 else return EINA_FALSE;
5468 * Set Genlist edit mode
5470 * This sets Genlist edit mode.
5472 * @param obj The Genlist object
5473 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5474 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5479 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5481 ELM_CHECK_WIDTYPE(obj, widtype);
5485 Elm_Genlist_Item *it;
5487 Widget_Data *wd = elm_widget_data_get(obj);
5489 if (wd->edit_mode == edit_mode) return;
5491 wd->edit_mode = edit_mode;
5494 EINA_INLIST_FOREACH(wd->blocks, itb)
5498 EINA_LIST_FOREACH(itb->items, l, it)
5500 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5502 _effect_item_unrealize(it);
5507 _item_cache_zero(wd);
5512 EINA_INLIST_FOREACH(wd->blocks, itb)
5516 EINA_LIST_FOREACH(itb->items, l, it)
5518 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5520 if(it->selected) _item_unselect(it);
5521 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
5528 if (wd->calc_job) ecore_job_del(wd->calc_job);
5529 wd->calc_job = ecore_job_add(_calc_job, wd);
5533 * Set a given item's rename mode
5535 * This renames the item's label from genlist
5537 * @param it The item
5538 * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
5543 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
5549 _item_unrealize(it, EINA_FALSE);
5550 it->renamed = EINA_TRUE;
5551 it->wd->rename_it = it;
5552 it->nocache = EINA_TRUE;
5553 if (it->selected) _item_unselect(it);
5555 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5556 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5562 it->renamed = EINA_FALSE;
5563 it->nocache = EINA_TRUE;
5564 it->wd->rename_it = NULL;
5565 _item_cache_zero(it->wd);
5566 elm_genlist_item_update(it);
5572 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
5574 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5575 return item->renamed;
5579 _item_auto_scroll(void *data)
5581 Widget_Data *wd = data;
5584 if ((wd->expand_item) && (!wd->auto_scrolled))
5586 Elm_Genlist_Item *it;
5588 Evas_Coord ox, oy, ow, oh;
5589 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
5591 wd->auto_scrolled = EINA_TRUE;
5592 if (wd->expand_item->scrl_y > (oh + oy) / 2)
5594 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
5596 elm_genlist_item_bring_in(it);