Merge "[elm_multibuttonentry]Fix logic : entry cursor doesn't show up after pause...
[framework/uifw/elementary.git] / src / lib / elm_genlist.c
1 #include <assert.h>
2 #include <Elementary.h>
3 #include <Elementary_Cursor.h>
4 #include "elm_priv.h"
5
6 #define SWIPE_MOVES         12
7 #define MAX_ITEMS_PER_BLOCK 32
8 #define REORDER_EFFECT_TIME 0.5
9
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
15 {
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;
21
22 struct _Widget_Data
23 {
24    Evas_Object      *obj, *scr, *pan_smart;
25    Eina_Inlist      *items, *blocks;
26    Eina_List        *group_items;
27    Pan              *pan;
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;
36    Elm_List_Mode     mode;
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;
48    Eina_Bool         multi : 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;
59    Eina_Bool         swipe : 1;
60    Eina_Bool         reorder_mode : 1;
61    Eina_Bool         reorder_pan_move : 1;
62    Eina_List        *dragging_queue;
63    struct
64    {
65       Evas_Coord x, y;
66    } history[SWIPE_MOVES];
67    int               multi_device;
68    int               item_cache_count;
69    int               item_cache_max;
70    int               movements;
71    int               walking;
72    int               item_width;
73    int               item_height;
74    int               group_item_width;
75    int               group_item_height;
76    int               max_items_per_block;
77    double            longpress_timeout;
78
79    // TODO : refactoring
80    Eina_Bool         reorder_deleted : 1;
81    Eina_Bool         effect_mode : 1;
82    Eina_Bool         auto_scrolled : 1;
83    int               edit_mode;
84    Ecore_Animator   *item_moving_effect_timer;
85    Evas_Object      *alpha_bg;
86    Evas_Coord        expand_item_end;
87    Evas_Coord        expand_item_gap;
88    int               move_effect_mode;
89    Ecore_Job        *changed_job;
90    Elm_Genlist_Item *rename_it;
91 };
92
93 struct _Item_Block
94 {
95    EINA_INLIST;
96    int          count;
97    int          num;
98    int          reorder_offset;
99    Widget_Data *wd;
100    Eina_List   *items;
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;
109 };
110
111 struct _Elm_Genlist_Item
112 {
113    Elm_Widget_Item               base;
114    EINA_INLIST;
115    Widget_Data                  *wd;
116    Item_Block                   *block;
117    Eina_List                    *items;
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;
123    struct
124    {
125       Evas_Smart_Cb func;
126       const void   *data;
127    } func;
128
129    Evas_Object                  *spacer;
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;
134    Evas_Coord                    dx, dy;
135    Evas_Coord                    scrl_x, scrl_y;
136
137    Elm_Genlist_Item             *rel;
138    Evas_Object                  *mode_view;
139
140    struct
141    {
142       const void                 *data;
143       Elm_Tooltip_Item_Content_Cb content_cb;
144       Evas_Smart_Cb               del_cb;
145       const char                 *style;
146    } tooltip;
147
148    const char                   *mouse_cursor;
149
150    int                           relcount;
151    int                           walking;
152    int                           expanded_depth;
153    int                           order_num_in;
154
155    Eina_Bool                     before : 1;
156
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;
169    Eina_Bool                     down : 1;
170    Eina_Bool                     dragging : 1;
171    Eina_Bool                     updateme : 1;
172    Eina_Bool                     nocache : 1;
173    Eina_Bool                     move_effect_enabled : 1;
174
175    // TODO: refactoring
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;
182    int         num;
183    Ecore_Animator *item_moving_effect_timer;
184    Evas_Coord  old_scrl_y;
185 };
186
187 struct _Item_Cache
188 {
189    EINA_INLIST;
190
191    Evas_Object *base_view, *spacer;
192
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
197
198    Eina_Bool    selected : 1; // it->selected
199    Eina_Bool    disabled : 1; // it->disabled
200    Eina_Bool    expanded : 1; // it->expanded
201 };
202
203 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
204   ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
205
206 struct _Pan
207 {
208    Evas_Object_Smart_Clipped_Data __clipped_data;
209    Widget_Data                   *wd;
210    Ecore_Job                     *resize_job;
211 };
212
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,
217                                Eina_Bool    rtl);
218 static void      _theme_hook(Evas_Object *obj);
219 static void      _show_region_hook(void        *data,
220                                    Evas_Object *obj);
221 static void      _sizing_eval(Evas_Object *obj);
222 static void      _item_realize(Elm_Genlist_Item *it,
223                                int               in,
224                                Eina_Bool         calc);
225 static void      _item_unrealize(Elm_Genlist_Item *it,
226                                  Eina_Bool         calc);
227 static void      _item_block_unrealize(Item_Block *itb);
228 static void      _calc_job(void *data);
229 static void      _on_focus_hook(void        *data,
230                                 Evas_Object *obj);
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,
238                              Evas_Object       *src,
239                              Evas_Callback_Type type,
240                              void              *event_info);
241 static void      _signal_emit_hook(Evas_Object *obj,
242                                    const char *emission,
243                                    const char *source);
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,
247                                 Evas_Object      *obj,
248                                 Evas_Coord        it_x,
249                                 Evas_Coord        it_y);
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);
259
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);
269
270 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
271
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";
300
301 static const Evas_Smart_Cb_Description _signals[] = {
302    {SIG_CLICKED_DOUBLE, ""},
303    {SIG_ACTIVATED, ""},
304    {SIG_SELECTED, ""},
305    {SIG_UNSELECTED, ""},
306    {SIG_EXPANDED, ""},
307    {SIG_CONTRACTED, ""},
308    {SIG_EXPAND_REQUEST, ""},
309    {SIG_CONTRACT_REQUEST, ""},
310    {SIG_REALIZED, ""},
311    {SIG_UNREALIZED, ""},
312    {SIG_DRAG_START_UP, ""},
313    {SIG_DRAG_START_DOWN, ""},
314    {SIG_DRAG_START_LEFT, ""},
315    {SIG_DRAG_START_RIGHT, ""},
316    {SIG_DRAG_STOP, ""},
317    {SIG_DRAG, ""},
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, ""},
329    {SIG_SWIPE, ""},
330    {NULL, NULL}
331 };
332
333 static Eina_Bool
334 _event_hook(Evas_Object       *obj,
335             Evas_Object       *src __UNUSED__,
336             Evas_Callback_Type type,
337             void              *event_info)
338 {
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;
346
347    Elm_Genlist_Item *it = NULL;
348    Evas_Coord x = 0;
349    Evas_Coord y = 0;
350    Evas_Coord step_x = 0;
351    Evas_Coord step_y = 0;
352    Evas_Coord v_w = 0;
353    Evas_Coord v_h = 0;
354    Evas_Coord page_x = 0;
355    Evas_Coord page_y = 0;
356
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);
361
362    if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
363      {
364         x -= step_x;
365      }
366    else if ((!strcmp(ev->keyname, "Right")) ||
367             (!strcmp(ev->keyname, "KP_Right")))
368      {
369         x += step_x;
370      }
371    else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
372      {
373         if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
374              (_item_multi_select_up(wd)))
375             || (_item_single_select_up(wd)))
376           {
377              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
378              return EINA_TRUE;
379           }
380         else
381           y -= step_y;
382      }
383    else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
384      {
385         if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
386              (_item_multi_select_down(wd)))
387             || (_item_single_select_down(wd)))
388           {
389              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
390              return EINA_TRUE;
391           }
392         else
393           y += step_y;
394      }
395    else if ((!strcmp(ev->keyname, "Home")) ||
396             (!strcmp(ev->keyname, "KP_Home")))
397      {
398         it = elm_genlist_first_item_get(obj);
399         elm_genlist_item_bring_in(it);
400         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
401         return EINA_TRUE;
402      }
403    else if ((!strcmp(ev->keyname, "End")) ||
404             (!strcmp(ev->keyname, "KP_End")))
405      {
406         it = elm_genlist_last_item_get(obj);
407         elm_genlist_item_bring_in(it);
408         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
409         return EINA_TRUE;
410      }
411    else if ((!strcmp(ev->keyname, "Prior")) ||
412             (!strcmp(ev->keyname, "KP_Prior")))
413      {
414         if (page_y < 0)
415           y -= -(page_y * v_h) / 100;
416         else
417           y -= page_y;
418      }
419    else if ((!strcmp(ev->keyname, "Next")) ||
420             (!strcmp(ev->keyname, "KP_Next")))
421      {
422         if (page_y < 0)
423           y += -(page_y * v_h) / 100;
424         else
425           y += page_y;
426      }
427    else if (((!strcmp(ev->keyname, "Return")) ||
428             (!strcmp(ev->keyname, "KP_Enter")) ||
429             (!strcmp(ev->keyname, "space")))
430            && (!wd->multi) && (wd->selected))
431      {
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);
436      }
437    else if (!strcmp(ev->keyname, "Escape"))
438      {
439         if (!_deselect_all_items(wd)) return EINA_FALSE;
440         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
441         return EINA_TRUE;
442      }
443    else return EINA_FALSE;
444
445    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
446    elm_smart_scroller_child_pos_set(wd->scr, x, y);
447    return EINA_TRUE;
448 }
449
450 static Eina_Bool
451 _deselect_all_items(Widget_Data *wd)
452 {
453    if (!wd->selected) return EINA_FALSE;
454    while (wd->selected)
455      elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
456
457    return EINA_TRUE;
458 }
459
460 static Eina_Bool
461 _item_multi_select_up(Widget_Data *wd)
462 {
463    if (!wd->selected) return EINA_FALSE;
464    if (!wd->multi) return EINA_FALSE;
465
466    Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
467    if (!prev) return EINA_TRUE;
468
469    if (elm_genlist_item_selected_get(prev))
470      {
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);
474      }
475    else
476      {
477         elm_genlist_item_selected_set(prev, EINA_TRUE);
478         elm_genlist_item_show(prev);
479      }
480    return EINA_TRUE;
481 }
482
483 static Eina_Bool
484 _item_multi_select_down(Widget_Data *wd)
485 {
486    if (!wd->selected) return EINA_FALSE;
487    if (!wd->multi) return EINA_FALSE;
488
489    Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
490    if (!next) return EINA_TRUE;
491
492    if (elm_genlist_item_selected_get(next))
493      {
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);
497      }
498    else
499      {
500         elm_genlist_item_selected_set(next, EINA_TRUE);
501         elm_genlist_item_show(next);
502      }
503    return EINA_TRUE;
504 }
505
506 static Eina_Bool
507 _item_single_select_up(Widget_Data *wd)
508 {
509    Elm_Genlist_Item *prev;
510    if (!wd->selected)
511      {
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);
515      }
516    else prev = elm_genlist_item_prev_get(wd->last_selected_item);
517
518    if (!prev) return EINA_FALSE;
519
520    _deselect_all_items(wd);
521
522    elm_genlist_item_selected_set(prev, EINA_TRUE);
523    elm_genlist_item_show(prev);
524    return EINA_TRUE;
525 }
526
527 static Eina_Bool
528 _item_single_select_down(Widget_Data *wd)
529 {
530    Elm_Genlist_Item *next;
531    if (!wd->selected)
532      {
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);
536      }
537    else next = elm_genlist_item_next_get(wd->last_selected_item);
538
539    if (!next) return EINA_FALSE;
540
541    _deselect_all_items(wd);
542
543    elm_genlist_item_selected_set(next, EINA_TRUE);
544    elm_genlist_item_show(next);
545    return EINA_TRUE;
546 }
547
548 static void
549 _on_focus_hook(void        *data __UNUSED__,
550                Evas_Object *obj)
551 {
552    Widget_Data *wd = elm_widget_data_get(obj);
553    if (!wd) return;
554    if (elm_widget_focus_get(obj))
555      {
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);
560      }
561    else
562      {
563         elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
564         evas_object_focus_set(wd->obj, EINA_FALSE);
565      }
566 }
567
568 static void
569 _del_hook(Evas_Object *obj)
570 {
571    Widget_Data *wd = elm_widget_data_get(obj);
572    if (!wd) return;
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);
582    if (wd->walking > 0)
583      {
584         wd->walking = 0;
585         elm_genlist_clear(obj);
586      }
587    free(wd);
588 }
589
590 static void
591 _del_pre_hook(Evas_Object *obj)
592 {
593    Widget_Data *wd = elm_widget_data_get(obj);
594    if (!wd) return;
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;
599 }
600
601 static void
602 _mirrored_set(Evas_Object *obj,
603               Eina_Bool    rtl)
604 {
605    Widget_Data *wd = elm_widget_data_get(obj);
606    if (!wd) return;
607    _item_cache_zero(wd);
608    elm_smart_scroller_mirrored_set(wd->scr, rtl);
609 }
610
611 static void
612 _theme_hook(Evas_Object *obj)
613 {
614    Widget_Data *wd = elm_widget_data_get(obj);
615    Item_Block *itb;
616    if (!wd) return;
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)
628      {
629         Eina_List *l;
630         Elm_Genlist_Item *it;
631
632         if (itb->realized) _item_block_unrealize(itb);
633         EINA_LIST_FOREACH(itb->items, l, it)
634           it->mincalcd = EINA_FALSE;
635
636         itb->changed = EINA_TRUE;
637      }
638    if (wd->calc_job) ecore_job_del(wd->calc_job);
639    wd->calc_job = ecore_job_add(_calc_job, wd);
640    _sizing_eval(obj);
641    evas_event_thaw(evas_object_evas_get(wd->obj));
642    evas_event_thaw_eval(evas_object_evas_get(wd->obj));
643 }
644
645 static void
646 _show_region_hook(void        *data,
647                   Evas_Object *obj)
648 {
649    Widget_Data *wd = elm_widget_data_get(data);
650    Evas_Coord x, y, w, h;
651    if (!wd) return;
652    elm_widget_show_region_get(obj, &x, &y, &w, &h);
653    //x & y are screen coordinates, Add with pan coordinates
654    x += wd->pan_x;
655    y += wd->pan_y;
656    elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
657 }
658
659 static void
660 _sizing_eval(Evas_Object *obj)
661 {
662    Widget_Data *wd = elm_widget_data_get(obj);
663    Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
664    if (!wd) return;
665    evas_object_size_hint_min_get(wd->scr, &minw, &minh);
666    evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
667    minh = -1;
668    if (wd->height_for_width)
669      {
670         Evas_Coord vw, vh;
671
672         elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
673         if ((vw != 0) && (vw != wd->prev_viewport_w))
674           {
675              Item_Block *itb;
676
677              wd->prev_viewport_w = vw;
678              EINA_INLIST_FOREACH(wd->blocks, itb)
679                {
680                   itb->must_recalc = EINA_TRUE;
681                }
682              if (wd->calc_job) ecore_job_del(wd->calc_job);
683              wd->calc_job = ecore_job_add(_calc_job, wd);
684           }
685      }
686    if (wd->mode == ELM_LIST_LIMIT)
687      {
688         Evas_Coord vmw, vmh, vw, vh;
689
690         minw = wd->realminw;
691         maxw = -1;
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))
695           vw = maxw;
696         edje_object_size_min_calc
697           (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
698         minw = vmw + minw;
699      }
700    else
701      {
702         Evas_Coord vmw, vmh;
703
704         edje_object_size_min_calc
705           (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
706         minw = vmw;
707         minh = vmh;
708      }
709    evas_object_size_hint_min_set(obj, minw, minh);
710    evas_object_size_hint_max_set(obj, maxw, maxh);
711 }
712
713 static void
714 _signal_emit_hook(Evas_Object *obj,
715                   const char  *emission,
716                   const char  *source)
717 {
718    Widget_Data *wd = elm_widget_data_get(obj);
719    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
720                            emission, source);
721 }
722
723 static void
724 _item_highlight(Elm_Genlist_Item *it)
725 {
726    const char *selectraise;
727    if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
728        (it->disabled) || (it->display_only) || (it->mode_view))
729      return;
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")))
734      {
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);
739      }
740    it->highlighted = EINA_TRUE;
741 }
742
743 static void
744 _item_block_del(Elm_Genlist_Item *it)
745 {
746    Eina_Inlist *il;
747    Item_Block *itb = it->block;
748
749    itb->items = eina_list_remove(itb->items, it);
750    itb->count--;
751    itb->changed = EINA_TRUE;
752    if (!it->wd->reorder_deleted)
753      {
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);
756      }
757    if (itb->count < 1)
758      {
759         il = EINA_INLIST_GET(itb);
760         Item_Block *itbn = (Item_Block *)(il->next);
761         if (it->parent)
762           it->parent->items = eina_list_remove(it->parent->items, it);
763         else
764           it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
765         free(itb);
766         if (itbn) itbn->changed = EINA_TRUE;
767      }
768    else
769      {
770         if (itb->count < itb->wd->max_items_per_block/2)
771           {
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))
776                {
777                   Elm_Genlist_Item *it2;
778
779                   EINA_LIST_FREE(itb->items, it2)
780                     {
781                        it2->block = itbp;
782                        itbp->items = eina_list_append(itbp->items, it2);
783                        itbp->count++;
784                        itbp->changed = EINA_TRUE;
785                     }
786                   it->wd->blocks = eina_inlist_remove(it->wd->blocks,
787                                                       EINA_INLIST_GET(itb));
788                   free(itb);
789                }
790              else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
791                {
792                   while (itb->items)
793                     {
794                        Eina_List *last = eina_list_last(itb->items);
795                        Elm_Genlist_Item *it2 = last->data;
796
797                        it2->block = itbn;
798                        itb->items = eina_list_remove_list(itb->items, last);
799                        itbn->items = eina_list_prepend(itbn->items, it2);
800                        itbn->count++;
801                        itbn->changed = EINA_TRUE;
802                     }
803                   it->wd->blocks =
804                     eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
805                   free(itb);
806                }
807           }
808      }
809 }
810
811 static void
812 _item_subitems_clear(Elm_Genlist_Item *it)
813 {
814    if (!it) return;
815    Eina_List *tl = NULL, *l;
816    Elm_Genlist_Item *it2;
817
818    EINA_LIST_FOREACH(it->items, l, it2)
819       tl = eina_list_append(tl, it2);
820
821    EINA_LIST_FREE(tl, it2)
822      elm_genlist_item_del(it2);
823 }
824
825 static void
826 _item_del(Elm_Genlist_Item *it)
827 {
828    Evas_Object *tob = it->wd->obj;
829
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;
842    if (it->queued)
843      it->wd->queue = eina_list_remove(it->wd->queue, it);
844 #ifdef ANCHOR_ITEM
845    if (it->wd->anchor_item == it)
846      {
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);
850      }
851 #endif
852    it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
853    if (it->parent)
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);
859
860    if (it->tooltip.del_cb)
861      it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
862
863    evas_event_thaw(evas_object_evas_get(tob));
864    evas_event_thaw_eval(evas_object_evas_get(tob));
865
866    elm_widget_item_del(it);
867 }
868
869 static void
870 _item_select(Elm_Genlist_Item *it)
871 {
872    if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
873    if (it->selected)
874      {
875         if (it->wd->always_select) goto call;
876         return;
877      }
878    it->selected = EINA_TRUE;
879    it->wd->selected = eina_list_append(it->wd->selected, it);
880 call:
881    it->walking++;
882    it->wd->walking++;
883    if (it->func.func)
884      {
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;
890      }
891    if (!it->delete_me)
892      evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
893    it->walking--;
894    it->wd->walking--;
895    if ((it->wd->clear_me) && (!it->wd->walking))
896      {
897         elm_genlist_clear(it->base.widget);
898         return;
899      }
900    else
901      {
902         if ((!it->walking) && (it->delete_me))
903           {
904              if (!it->relcount) _item_del(it);
905           }
906      }
907    if (it && it->wd) it->wd->last_selected_item = it; // TODO: Remove 'if'?
908 }
909
910 static void
911 _item_unselect(Elm_Genlist_Item *it)
912 {
913    const char *stacking, *selectraise;
914
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")))
921      {
922         if ((stacking) && (!strcmp(stacking, "below")))
923           evas_object_lower(it->base.view);
924      }
925    it->highlighted = EINA_FALSE;
926    if (it->selected)
927      {
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);
931      }
932 }
933
934 static void
935 _mouse_move(void        *data,
936             Evas        *evas __UNUSED__,
937             Evas_Object *obj,
938             void        *event_info)
939 {
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;
944
945    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
946      {
947         if (!it->wd->on_hold)
948           {
949              it->wd->on_hold = EINA_TRUE;
950              if (!it->wd->wasselected)
951                _item_unselect(it);
952           }
953      }
954    if (it->wd->multitouched)
955      {
956         it->wd->cur_x = ev->cur.canvas.x;
957         it->wd->cur_y = ev->cur.canvas.y;
958         return;
959      }
960    if ((it->dragging) && (it->down))
961      {
962         if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
963         else
964           {
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;
970              else
971                it->wd->movements++;
972           }
973         if (it->long_timer)
974           {
975              ecore_timer_del(it->long_timer);
976              it->long_timer = NULL;
977           }
978         evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
979         return;
980      }
981    if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
982      {
983         if (it->long_timer)
984           {
985              ecore_timer_del(it->long_timer);
986              it->long_timer = NULL;
987           }
988         if ((it->wd->reorder_mode) && (it->wd->reorder_it))
989           {
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;
992
993              if (!it->wd->reorder_start_y)
994                it->wd->reorder_start_y = it->block->y + it->y;
995
996              if (it_scrl_y < oy)
997                y_pos = oy;
998              else if (it_scrl_y + it->wd->reorder_it->h > oy + oh)
999                y_pos = oy + oh - it->wd->reorder_it->h;
1000              else
1001                y_pos = it_scrl_y;
1002
1003              if (it->edit_obj)
1004                _item_position(it, it->edit_obj, it->scrl_x, y_pos);
1005              else
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);
1009           }
1010         return;
1011      }
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;
1017    dx = x - it->dx;
1018    adx = dx;
1019    if (adx < 0) adx = -dx;
1020    dy = y - it->dy;
1021    ady = dy;
1022    if (ady < 0) ady = -dy;
1023    minw /= 2;
1024    minh /= 2;
1025    if ((adx > minw) || (ady > minh))
1026      {
1027         it->dragging = EINA_TRUE;
1028         it->wd->dragging_queue = eina_list_append(it->wd->dragging_queue, it);
1029         if (it->long_timer)
1030           {
1031              ecore_timer_del(it->long_timer);
1032              it->long_timer = NULL;
1033           }
1034         if (!it->wd->wasselected)
1035           _item_unselect(it);
1036         if (dy < 0)
1037           {
1038              if (ady > adx)
1039                evas_object_smart_callback_call(it->base.widget,
1040                                                SIG_DRAG_START_UP, it);
1041              else
1042                {
1043                   if (dx < 0)
1044                     evas_object_smart_callback_call(it->base.widget,
1045                                                     SIG_DRAG_START_LEFT, it);
1046                   else
1047                     evas_object_smart_callback_call(it->base.widget,
1048                                                     SIG_DRAG_START_RIGHT, it);
1049                }
1050           }
1051         else
1052           {
1053              if (ady > adx)
1054                evas_object_smart_callback_call(it->base.widget,
1055                                                SIG_DRAG_START_DOWN, it);
1056              else
1057                {
1058                   if (dx < 0)
1059                     evas_object_smart_callback_call(it->base.widget,
1060                                                     SIG_DRAG_START_LEFT, it);
1061                   else
1062                     evas_object_smart_callback_call(it->base.widget,
1063                                                     SIG_DRAG_START_RIGHT, it);
1064                }
1065           }
1066      }
1067 }
1068
1069 static Eina_Bool
1070 _long_press(void *data)
1071 {
1072    Elm_Genlist_Item *it = data, *it_tmp;
1073    Eina_List *list, *l;
1074    //static Eina_Bool contracted = EINA_FALSE;
1075
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))
1082      {
1083         it->wd->reorder_it = it;
1084         it->wd->reorder_start_y = 0;
1085         if (it->edit_obj)
1086           evas_object_raise(it->edit_obj);
1087         else
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);
1091
1092         list = elm_genlist_realized_items_get(it->wd->obj);
1093         EINA_LIST_FOREACH(list, l, it_tmp)
1094           {
1095              if (it != it_tmp) _item_unselect(it_tmp);
1096           }
1097         if (it->items)
1098           {
1099              EINA_LIST_FOREACH(it->items, l, it_tmp)
1100                {
1101                   if (elm_genlist_item_expanded_get(it_tmp))
1102                     {
1103                        elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1104                        return ECORE_CALLBACK_RENEW;
1105                     }
1106                }
1107           }
1108         if (elm_genlist_item_expanded_get(it))
1109           {
1110              elm_genlist_item_expanded_set(it, EINA_FALSE);
1111              return ECORE_CALLBACK_RENEW;
1112           }
1113         if (it->edit_obj)
1114           edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1115         else
1116           edje_object_signal_emit(it->base.view, "elm,state,reorder,enabled", "elm");
1117      }
1118    return ECORE_CALLBACK_CANCEL;
1119 }
1120
1121 static void
1122 _swipe(Elm_Genlist_Item *it)
1123 {
1124    int i, sum = 0;
1125
1126    if (!it) return;
1127    if ((it->display_only) || (it->disabled)) return;
1128    it->wd->swipe = EINA_FALSE;
1129    for (i = 0; i < it->wd->movements; i++)
1130      {
1131         sum += it->wd->history[i].x;
1132         if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1133      }
1134
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);
1138 }
1139
1140 static Eina_Bool
1141 _swipe_cancel(void *data)
1142 {
1143    Elm_Genlist_Item *it = data;
1144
1145    if (!it) return ECORE_CALLBACK_CANCEL;
1146    it->wd->swipe = EINA_FALSE;
1147    it->wd->movements = 0;
1148    return ECORE_CALLBACK_RENEW;
1149 }
1150
1151 static Eina_Bool
1152 _multi_cancel(void *data)
1153 {
1154    Widget_Data *wd = data;
1155
1156    if (!wd) return ECORE_CALLBACK_CANCEL;
1157    wd->multi_timeout = EINA_TRUE;
1158    return ECORE_CALLBACK_RENEW;
1159 }
1160
1161 static void
1162 _multi_touch_gesture_eval(void *data)
1163 {
1164    Elm_Genlist_Item *it = data;
1165
1166    it->wd->multitouched = EINA_FALSE;
1167    if (it->wd->multi_timer)
1168      {
1169         ecore_timer_del(it->wd->multi_timer);
1170         it->wd->multi_timer = NULL;
1171      }
1172    if (it->wd->multi_timeout)
1173      {
1174         it->wd->multi_timeout = EINA_FALSE;
1175         return;
1176      }
1177
1178    Evas_Coord minw = 0, minh = 0;
1179    Evas_Coord off_x, off_y, off_mx, off_my;
1180
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);
1186
1187    if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1188      {
1189         if ((off_x + off_mx) > (off_y + off_my))
1190           {
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);
1200              else
1201                evas_object_smart_callback_call(it->base.widget,
1202                                                SIG_MULTI_PINCH_IN, it);
1203           }
1204         else
1205           {
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);
1215              else
1216                evas_object_smart_callback_call(it->base.widget,
1217                                                SIG_MULTI_PINCH_IN, it);
1218           }
1219      }
1220    it->wd->multi_timeout = EINA_FALSE;
1221 }
1222
1223 static void
1224 _multi_down(void        *data,
1225             Evas        *evas __UNUSED__,
1226             Evas_Object *obj __UNUSED__,
1227             void        *event_info)
1228 {
1229    Elm_Genlist_Item *it = data;
1230    Evas_Event_Multi_Down *ev = event_info;
1231
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;
1241    if (it->long_timer)
1242      {
1243         ecore_timer_del(it->long_timer);
1244         it->long_timer = NULL;
1245      }
1246    if (it->dragging)
1247      {
1248         it->dragging = EINA_FALSE;
1249         evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1250      }
1251    if (it->swipe_timer)
1252      {
1253         ecore_timer_del(it->swipe_timer);
1254         it->swipe_timer = NULL;
1255      }
1256    if (it->wd->on_hold)
1257      {
1258         it->wd->swipe = EINA_FALSE;
1259         it->wd->movements = 0;
1260         it->wd->on_hold = EINA_FALSE;
1261      }
1262 }
1263
1264 static void
1265 _multi_up(void        *data,
1266           Evas        *evas __UNUSED__,
1267           Evas_Object *obj __UNUSED__,
1268           void        *event_info)
1269 {
1270    Elm_Genlist_Item *it = data;
1271    Evas_Event_Multi_Up *ev = event_info;
1272
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);
1278 }
1279
1280 static void
1281 _multi_move(void        *data,
1282             Evas        *evas __UNUSED__,
1283             Evas_Object *obj __UNUSED__,
1284             void        *event_info)
1285 {
1286    Elm_Genlist_Item *it = data;
1287    Evas_Event_Multi_Move *ev = event_info;
1288
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;
1292 }
1293
1294 static void
1295 _mouse_down(void        *data,
1296             Evas        *evas __UNUSED__,
1297             Evas_Object *obj,
1298             void        *event_info)
1299 {
1300    Elm_Genlist_Item *it = data;
1301    Evas_Event_Mouse_Down *ev = event_info;
1302    Evas_Coord x, y;
1303
1304    if (ev->button != 1) return;
1305    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1306      {
1307         it->wd->on_hold = EINA_TRUE;
1308      }
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)
1316      {
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);
1322      }
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))
1331        {
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);
1334        }
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);
1338    if (it->realized)
1339      it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1340                                       it);
1341    else
1342      it->long_timer = NULL;
1343    it->wd->swipe = EINA_FALSE;
1344    it->wd->movements = 0;
1345 }
1346
1347 static void
1348 _mouse_up(void        *data,
1349           Evas        *evas __UNUSED__,
1350           Evas_Object *obj __UNUSED__,
1351           void        *event_info)
1352 {
1353    Elm_Genlist_Item *it = data;
1354    Evas_Event_Mouse_Up *ev = event_info;
1355    Eina_Bool dragged = EINA_FALSE;
1356
1357    if (ev->button != 1) return;
1358    it->down = EINA_FALSE;
1359    it->wd->mouse_down = EINA_FALSE;
1360    if (it->wd->multitouched)
1361      {
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);
1367         return;
1368      }
1369    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1370    else it->wd->on_hold = EINA_FALSE;
1371    if (it->long_timer)
1372      {
1373         ecore_timer_del(it->long_timer);
1374         it->long_timer = NULL;
1375      }
1376    while (it->wd->dragging_queue)
1377      {
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)
1383           {
1384              _item_unrealize(dragging_it, EINA_FALSE);
1385              if (dragging_it->block->want_unrealize)
1386                _item_block_unrealize(it->block);
1387           }
1388         it->wd->dragging_queue = eina_list_remove_list(it->wd->dragging_queue,it->wd->dragging_queue);
1389         dragged = 1;
1390      }
1391    if (it->swipe_timer)
1392      {
1393         ecore_timer_del(it->swipe_timer);
1394         it->swipe_timer = NULL;
1395      }
1396    if (it->wd->multi_timer)
1397      {
1398         ecore_timer_del(it->wd->multi_timer);
1399         it->wd->multi_timer = NULL;
1400         it->wd->multi_timeout = EINA_FALSE;
1401      }
1402    if (it->wd->on_hold)
1403      {
1404         if (it->wd->swipe) _swipe(data);
1405         it->wd->longpressed = EINA_FALSE;
1406         it->wd->on_hold = EINA_FALSE;
1407         return;
1408      }
1409    if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1410      {
1411         Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1412
1413         if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1414           {
1415              if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1416                _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1417              else
1418                _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1419           }
1420         else
1421           {
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);
1424           }
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);
1430
1431      }
1432    if (it->wd->longpressed)
1433      {
1434         it->wd->longpressed = EINA_FALSE;
1435         if (!it->wd->wasselected)
1436           _item_unselect(it);
1437         it->wd->wasselected = EINA_FALSE;
1438         return;
1439      }
1440    if ((it->disabled) || (dragged) || (it->display_only)) return;
1441    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1442    if (it->wd->multi)
1443      {
1444         if (!it->selected)
1445           {
1446              _item_highlight(it);
1447              _item_select(it);
1448           }
1449         else _item_unselect(it);
1450      }
1451    else
1452      {
1453         if (!it->selected)
1454           {
1455              Widget_Data *wd = it->wd;
1456              if (wd)
1457                {
1458                   while (wd->selected) _item_unselect(wd->selected->data);
1459                }
1460           }
1461         else
1462           {
1463              const Eina_List *l, *l_next;
1464              Elm_Genlist_Item *it2;
1465
1466              EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1467                if (it2 != it) _item_unselect(it2);
1468              //_item_highlight(it);
1469              //_item_select(it);
1470           }
1471         _item_highlight(it);
1472         _item_select(it);
1473      }
1474 }
1475
1476 static void
1477 _signal_expand_toggle(void        *data,
1478                       Evas_Object *obj __UNUSED__,
1479                       const char  *emission __UNUSED__,
1480                       const char  *source __UNUSED__)
1481 {
1482    Elm_Genlist_Item *it = data;
1483
1484    if (it->expanded)
1485      evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1486    else
1487      evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1488 }
1489
1490 static void
1491 _signal_expand(void        *data,
1492                Evas_Object *obj __UNUSED__,
1493                const char  *emission __UNUSED__,
1494                const char  *source __UNUSED__)
1495 {
1496    Elm_Genlist_Item *it = data;
1497
1498    if (!it->expanded)
1499      evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1500 }
1501
1502 static void
1503 _signal_contract(void        *data,
1504                  Evas_Object *obj __UNUSED__,
1505                  const char  *emission __UNUSED__,
1506                  const char  *source __UNUSED__)
1507 {
1508    Elm_Genlist_Item *it = data;
1509
1510    if (it->expanded)
1511      evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1512 }
1513
1514 static Eina_Bool
1515 _scr_hold_timer_cb(void *data)
1516 {
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;
1522 }
1523
1524 static void
1525 _mode_finished_signal_cb(void        *data,
1526                          Evas_Object *obj,
1527                          const char  *emission __UNUSED__,
1528                          const char  *source __UNUSED__)
1529 {
1530    if (!data) return;
1531    if (!obj) return;
1532    Elm_Genlist_Item *it = data;
1533    if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1534    char buf[1024];
1535    Evas *te = evas_object_evas_get(obj);
1536
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);
1544 }
1545
1546 static void
1547 _item_cache_clean(Widget_Data *wd)
1548 {
1549    evas_event_freeze(evas_object_evas_get(wd->obj));
1550    while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1551      {
1552         Item_Cache *itc;
1553
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);
1561         free(itc);
1562      }
1563    evas_event_thaw(evas_object_evas_get(wd->obj));
1564    evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1565 }
1566
1567 static void
1568 _item_cache_zero(Widget_Data *wd)
1569 {
1570    int pmax = wd->item_cache_max;
1571    wd->item_cache_max = 0;
1572    _item_cache_clean(wd);
1573    wd->item_cache_max = pmax;
1574 }
1575
1576 static void
1577 _item_cache_add(Elm_Genlist_Item *it)
1578 {
1579    Item_Cache *itc;
1580
1581    evas_event_freeze(evas_object_evas_get(it->wd->obj));
1582    if (it->wd->item_cache_max <= 0)
1583      {
1584         evas_object_del(it->base.view);
1585         it->base.view = NULL;
1586         evas_object_del(it->spacer);
1587         it->spacer = NULL;
1588         evas_event_thaw(evas_object_evas_get(it->wd->obj));
1589         evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1590         return;
1591      }
1592
1593    it->wd->item_cache_count++;
1594    itc = calloc(1, sizeof(Item_Cache));
1595    if (!itc)
1596      {
1597         evas_event_thaw(evas_object_evas_get(it->wd->obj));
1598         evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1599         return;
1600      }
1601    it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1602                                             EINA_INLIST_GET(itc));
1603    itc->spacer = it->spacer;
1604    it->spacer = NULL;
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;
1616    if (it->long_timer)
1617      {
1618         ecore_timer_del(it->long_timer);
1619         it->long_timer = NULL;
1620      }
1621    if (it->swipe_timer)
1622      {
1623         ecore_timer_del(it->swipe_timer);
1624         it->swipe_timer = NULL;
1625      }
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",
1631                                         "elm",
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,
1636                                        _mouse_down, it);
1637    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1638                                        _mouse_up, it);
1639    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1640                                        _mouse_move, it);
1641    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1642                                        _multi_down, it);
1643    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1644                                        _multi_up, it);
1645    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1646                                        _multi_move, it);
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));
1650 }
1651
1652 static Item_Cache *
1653 _item_cache_find(Elm_Genlist_Item *it)
1654 {
1655    Item_Cache *itc;
1656    Eina_Bool tree = 0, odd;
1657
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)
1661      {
1662         if ((itc->selected) || (itc->disabled) || (itc->expanded))
1663           continue;
1664         if ((itc->tree == tree) &&
1665             (itc->odd == odd) &&
1666             (itc->compress == it->wd->compress) &&
1667             (!strcmp(it->itc->item_style, itc->item_style)))
1668           {
1669              it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1670                                                      EINA_INLIST_GET(itc));
1671              it->wd->item_cache_count--;
1672              return itc;
1673           }
1674      }
1675    return NULL;
1676 }
1677
1678 static void
1679 _item_cache_free(Item_Cache *itc)
1680 {
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);
1684    free(itc);
1685 }
1686
1687 static void
1688 _item_realize(Elm_Genlist_Item *it,
1689               int               in,
1690               Eina_Bool         calc)
1691 {
1692    Elm_Genlist_Item *it2;
1693    const char *stacking;
1694    const char *treesize;
1695    char buf[1024];
1696    int depth, tsize = 20;
1697    Item_Cache *itc = NULL;
1698
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;
1705    else
1706      itc = _item_cache_find(it);
1707    if (itc && (!it->wd->effect_mode))
1708      {
1709         it->base.view = itc->base_view;
1710         itc->base_view = NULL;
1711         it->spacer = itc->spacer;
1712         itc->spacer = NULL;
1713      }
1714    else
1715      {
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);
1722
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));
1728
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));
1732
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));
1737         it->spacer =
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);
1741      }
1742    for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1743      {
1744         if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1745      }
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);
1752    if (!calc)
1753      {
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");
1762         if (stacking)
1763           {
1764              if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1765              else if (!strcmp(stacking, "above"))
1766                evas_object_raise(it->base.view);
1767           }
1768         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1769                                        _mouse_down, it);
1770         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1771                                        _mouse_up, it);
1772         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1773                                        _mouse_move, it);
1774         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1775                                        _multi_down, it);
1776         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1777                                        _multi_up, it);
1778         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1779                                        _multi_move, it);
1780
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);
1784
1785         if (itc)
1786           {
1787              if ((it->selected) && (it->selected != itc->selected))
1788                {
1789                   edje_object_signal_emit(it->base.view,
1790                                           "elm,state,selected", "elm");
1791                   if (it->edit_obj)
1792                     edje_object_signal_emit(it->edit_obj,
1793                                             "elm,state,selected", "elm");
1794                }
1795              if ((it->disabled) && (it->disabled != itc->disabled))
1796                {
1797                   edje_object_signal_emit(it->base.view,
1798                                           "elm,state,disabled", "elm");
1799                   if (it->edit_obj)
1800                     edje_object_signal_emit(it->edit_obj,
1801                                             "elm,state,disabled", "elm");
1802                }
1803              if ((it->expanded) && (it->expanded != itc->expanded))
1804                {
1805                   edje_object_signal_emit(it->base.view,
1806                                           "elm,state,expanded", "elm");
1807                   if (it->edit_obj)
1808                     edje_object_signal_emit(it->edit_obj,
1809                                             "elm,state,expanded", "elm");
1810                }
1811           }
1812         else
1813           {
1814              if (it->selected)
1815                {
1816                   edje_object_signal_emit(it->base.view,
1817                                           "elm,state,selected", "elm");
1818                   if (it->edit_obj)
1819                     edje_object_signal_emit(it->edit_obj,
1820                                             "elm,state,selected", "elm");
1821                }
1822              if (it->disabled)
1823                {
1824                   edje_object_signal_emit(it->base.view,
1825                                           "elm,state,disabled", "elm");
1826                   if (it->edit_obj)
1827                     edje_object_signal_emit(it->edit_obj,
1828                                             "elm,state,disabled", "elm");
1829                }
1830              if (it->expanded)
1831                {
1832                   edje_object_signal_emit(it->base.view,
1833                                           "elm,state,expanded", "elm");
1834                   if (it->edit_obj)
1835                     edje_object_signal_emit(it->edit_obj,
1836                                             "elm,state,expanded", "elm");
1837                }
1838           }
1839      }
1840
1841    if ((calc) && (it->wd->homogeneous) &&
1842        ((it->wd->item_width) ||
1843         ((it->wd->item_width) && (it->wd->group_item_width))))
1844      {
1845         /* homogenous genlist shortcut */
1846         if (!it->mincalcd)
1847           {
1848              if (it->flags & ELM_GENLIST_ITEM_GROUP)
1849                {
1850                   it->w = it->minw = it->wd->group_item_width;
1851                   it->h = it->minh = it->wd->group_item_height;
1852                }
1853              else
1854                {
1855                   it->w = it->minw = it->wd->item_width;
1856                   it->h = it->minh = it->wd->item_height;
1857                }
1858              it->mincalcd = EINA_TRUE;
1859           }
1860      }
1861    else
1862      {
1863         if (it->itc->func.label_get)
1864           {
1865              const Eina_List *l;
1866              const char *key;
1867
1868              it->labels =
1869                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1870                                                               "labels"));
1871              EINA_LIST_FOREACH(it->labels, l, key)
1872                {
1873                   char *s = it->itc->func.label_get
1874                       ((void *)it->base.data, it->base.widget, l->data);
1875
1876                   if (s)
1877                     {
1878                        edje_object_part_text_set(it->base.view, l->data, s);
1879                        free(s);
1880                     }
1881                   else if (itc)
1882                     edje_object_part_text_set(it->base.view, l->data, "");
1883                }
1884           }
1885         if (it->itc->func.icon_get)
1886           {
1887              const Eina_List *l;
1888              const char *key;
1889
1890              it->icons =
1891                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1892                                                               "icons"));
1893              EINA_LIST_FOREACH(it->icons, l, key)
1894                {
1895                   Evas_Object *ic = it->itc->func.icon_get
1896                       ((void *)it->base.data, it->base.widget, l->data);
1897
1898                   if (ic)
1899                     {
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);
1905                        if (it->disabled)
1906                          elm_widget_disabled_set(ic, EINA_TRUE);
1907                     }
1908                }
1909              if (it->renamed)
1910                {
1911                   it->icons =
1912                       elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
1913                   EINA_LIST_FOREACH(it->icons, l, key)
1914                     {
1915                        Evas_Object *ic = it->itc->func.icon_get
1916                                          ((void *)it->base.data, it->base.widget, l->data);
1917                        if (ic)
1918                          {
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);
1923                          }
1924                     }
1925               }
1926           }
1927         if (it->itc->func.state_get)
1928           {
1929              const Eina_List *l;
1930              const char *key;
1931
1932              it->states =
1933                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1934                                                               "states"));
1935              EINA_LIST_FOREACH(it->states, l, key)
1936                {
1937                   Eina_Bool on = it->itc->func.state_get
1938                       ((void *)it->base.data, it->base.widget, l->data);
1939
1940                   if (on)
1941                     {
1942                        snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1943                        edje_object_signal_emit(it->base.view, buf, "elm");
1944                     }
1945                   else if (itc)
1946                     {
1947                        snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1948                        edje_object_signal_emit(it->base.view, buf, "elm");
1949                     }
1950                }
1951           }
1952         if (!it->mincalcd || it->wd->pan_resize)
1953           {
1954              Evas_Coord mw = -1, mh = -1;
1955
1956              if (it->wd->height_for_width) mw = it->wd->w; // TODO: Removed this. This was removed from upstream.
1957
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,
1962                                                   mh);
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;
1968
1969              if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1970                {
1971                   it->wd->group_item_width = mw;
1972                   it->wd->group_item_height = mh;
1973                }
1974              else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1975                {
1976                   it->wd->item_width = mw;
1977                   it->wd->item_height = mh;
1978                }
1979           }
1980         if (!calc) evas_object_show(it->base.view);
1981      }
1982
1983    if (it->tooltip.content_cb)
1984      {
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);
1989      }
1990
1991    if (it->mouse_cursor)
1992      elm_widget_item_cursor_set(it, it->mouse_cursor);
1993
1994    it->realized = EINA_TRUE;
1995    it->want_unrealize = EINA_FALSE;
1996
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));
2000    if (!calc)
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))
2003      {
2004         if (it->itc->edit_item_style)
2005           {
2006              if (!it->edit_obj) _effect_item_realize(it, EINA_FALSE);
2007              edje_object_message_signal_process(it->edit_obj);
2008           }
2009      }
2010    edje_object_message_signal_process(it->base.view);
2011 }
2012
2013 static void
2014 _item_unrealize(Elm_Genlist_Item *it,
2015                 Eina_Bool         calc)
2016 {
2017    Evas_Object *icon;
2018
2019    if (!it->realized) return;
2020    if (it->wd->reorder_it == it) return;
2021    evas_event_freeze(evas_object_evas_get(it->wd->obj));
2022    if (!calc)
2023      evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2024    if (it->long_timer)
2025      {
2026         ecore_timer_del(it->long_timer);
2027         it->long_timer = NULL;
2028      }
2029    if (it->nocache)
2030      {
2031         evas_object_del(it->base.view);
2032         it->base.view = NULL;
2033         evas_object_del(it->spacer);
2034         it->spacer = NULL;
2035      }
2036    else
2037      {
2038         edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2039         _item_cache_add(it);
2040      }
2041    elm_widget_stringlist_free(it->labels);
2042    it->labels = NULL;
2043    elm_widget_stringlist_free(it->icons);
2044    it->icons = NULL;
2045    elm_widget_stringlist_free(it->states);
2046
2047    EINA_LIST_FREE(it->icon_objs, icon)
2048      evas_object_del(icon);
2049
2050    _mode_item_unrealize(it);
2051    it->states = NULL;
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);
2057 }
2058
2059 static Eina_Bool
2060 _item_block_recalc(Item_Block *itb,
2061                    int         in,
2062                    Eina_Bool   qadd)
2063 {
2064    const Eina_List *l;
2065    Elm_Genlist_Item *it;
2066    Evas_Coord minw = 0, minh = 0;
2067    Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2068    Evas_Coord y = 0;
2069
2070    evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2071    itb->num = in;
2072    EINA_LIST_FOREACH(itb->items, l, it)
2073      {
2074         if (it->delete_me) continue;
2075         showme |= it->showme;
2076         if (!itb->realized)
2077           {
2078              if (qadd)
2079                {
2080                   if (!it->mincalcd) changed = EINA_TRUE;
2081                   if (changed)
2082                     {
2083                        _item_realize(it, in, EINA_TRUE);
2084                        _item_unrealize(it, EINA_TRUE);
2085                     }
2086                }
2087              else
2088                {
2089                   _item_realize(it, in, EINA_TRUE);
2090                   _item_unrealize(it, EINA_TRUE);
2091                }
2092           }
2093         else
2094           _item_realize(it, in, EINA_FALSE);
2095         minh += it->minh;
2096         if (minw < it->minw) minw = it->minw;
2097         in++;
2098         it->x = 0;
2099         it->y = y;
2100         y += it->h;
2101      }
2102    itb->minw = minw;
2103    itb->minh = minh;
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));
2107    return showme;
2108 }
2109
2110 static void
2111 _item_block_realize(Item_Block *itb,
2112                     int         in,
2113                     int         full)
2114 {
2115    const Eina_List *l;
2116    Elm_Genlist_Item *it;
2117
2118    if (itb->realized) return;
2119    evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2120    EINA_LIST_FOREACH(itb->items, l, it)
2121      {
2122         if (it->delete_me) continue;
2123         if (full) _item_realize(it, in, EINA_FALSE);
2124         in++;
2125      }
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));
2130 }
2131
2132 static void
2133 _item_block_unrealize(Item_Block *itb)
2134 {
2135    const Eina_List *l;
2136    Elm_Genlist_Item *it;
2137    Eina_Bool dragging = EINA_FALSE;
2138
2139    if (!itb->realized) return;
2140    evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2141    EINA_LIST_FOREACH(itb->items, l, it)
2142      {
2143         if (it->flags != ELM_GENLIST_ITEM_GROUP)
2144           {
2145              if (it->dragging)
2146                {
2147                   dragging = EINA_TRUE;
2148                   it->want_unrealize = EINA_TRUE;
2149                }
2150              else
2151                _item_unrealize(it, EINA_FALSE);
2152           }
2153      }
2154    if (!dragging)
2155      {
2156         itb->realized = EINA_FALSE;
2157         itb->want_unrealize = EINA_TRUE;
2158      }
2159    else
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));
2163 }
2164
2165 static int
2166 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2167 {
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;
2172
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);
2175
2176    if ((it->wd->reorder_start_y < it->block->y) &&
2177        (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2178      {
2179         it->block->reorder_offset = it->wd->reorder_it->h * -1;
2180         if (it->block->count == 1)
2181           it->wd->reorder_rel = it;
2182      }
2183    else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2  <=  it->block->y -  it->wd->pan_y))
2184      {
2185         it->block->reorder_offset = it->wd->reorder_it->h;
2186      }
2187    else
2188      it->block->reorder_offset = 0;
2189
2190    it->scrl_y += it->block->reorder_offset;
2191
2192    top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2193                               rox, roy + (roh / 2), row, 1));
2194    if (top)
2195      {
2196         it->wd->reorder_rel = it;
2197         it->scrl_y += it->wd->reorder_it->h;
2198         return it->wd->reorder_it->h;
2199      }
2200    else
2201      return 0;
2202 }
2203
2204 static Eina_Bool
2205 _reorder_move_animator_cb(void *data)
2206 {
2207    Elm_Genlist_Item *it = data;
2208    Eina_Bool down = EINA_FALSE;
2209    double t;
2210    int y, dy = it->h / 10 * _elm_config->scale, diff;
2211
2212    t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2213
2214    if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2215    else y = dy;
2216
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)
2220      {
2221         it->old_scrl_y += y;
2222         down = EINA_TRUE;
2223      }
2224    else if (it->old_scrl_y > it->scrl_y)
2225      {
2226         it->old_scrl_y -= y;
2227         down = EINA_FALSE;
2228      }
2229
2230    if (it->edit_obj)
2231      _item_position(it, it->edit_obj, it->scrl_x, it->old_scrl_y);
2232    else
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))
2238      {
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;
2243      }
2244    return ECORE_CALLBACK_RENEW;
2245 }
2246
2247 static void
2248 _item_position(Elm_Genlist_Item *it,
2249                Evas_Object      *view,
2250                Evas_Coord        it_x,
2251                Evas_Coord        it_y)
2252 {
2253    if (!it) return;
2254    if (!view) return;
2255
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));
2262 }
2263
2264 static void
2265 _item_block_position(Item_Block *itb,
2266                      int         in)
2267 {
2268    const Eina_List *l;
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;
2273    int vis = 0;
2274
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,
2278                             &cvw, &cvh);
2279    EINA_LIST_FOREACH(itb->items, l, it)
2280      {
2281         if (it->delete_me) continue;
2282         else if (it->wd->reorder_it == it) continue;
2283
2284         it->x = 0;
2285         it->y = y;
2286         it->w = itb->w;
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;
2289
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)
2293           {
2294              if ((itb->realized))
2295                {
2296                   if (vis)
2297                     {
2298                        if (!it->realized) _item_realize(it, in, EINA_FALSE);
2299                        if (it->renamed)
2300                          {
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");
2303                          }
2304                     }
2305                }
2306              if (it->realized)
2307                {
2308                   if (vis)
2309                     {
2310                        if (it->wd->reorder_mode)
2311                          y += _get_space_for_reorder_item(it);
2312                        git = it->group_item;
2313                        if (git)
2314                          {
2315                             git->scrl_x = it->scrl_x;
2316                             if (git->scrl_y < oy)
2317                               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;
2321                          }
2322                        if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2323                          {
2324                             if (!it->move_effect_enabled)
2325                               {
2326                                  it->move_effect_enabled = EINA_TRUE;
2327                                  it->wd->reorder_move_animator =
2328                                     ecore_animator_add(
2329                                        _reorder_move_animator_cb, it);
2330                               }
2331                          }
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))
2334                             {
2335                               if (it->wd->edit_mode && it->itc->edit_item_style)
2336                                 {
2337                                    _item_position(it, it->edit_obj, it->scrl_x, it->scrl_y);
2338                                 }
2339                               else
2340                                {
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)))
2342                                     {
2343                                        if (it->mode_view)
2344                                          _item_position(it, it->mode_view, it->scrl_x,
2345                                                         it->scrl_y);
2346                                        else
2347                                          _item_position(it, it->base.view, it->scrl_x,
2348                                                         it->scrl_y);
2349                                     }
2350                                   else
2351                                     {
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);
2355                                     }
2356                                }
2357                             }
2358                     }
2359                   else
2360                     {
2361                        if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2362                     }
2363                }
2364              in++;
2365           }
2366         else
2367           {
2368              if (vis) it->want_realize = EINA_TRUE;
2369           }
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))
2371           {
2372              it->old_scrl_y = it->scrl_y;
2373           }
2374         y += it->h;
2375         minh += it->minh;
2376      }
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));
2380 }
2381
2382 static void
2383 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2384 {
2385    Elm_Genlist_Item *it = data;
2386    if (!it) return;
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);
2391 }
2392
2393 static void
2394 _group_items_recalc(void *data)
2395 {
2396    Widget_Data *wd = data;
2397    Eina_List *l;
2398    Elm_Genlist_Item *git;
2399
2400    evas_event_freeze(evas_object_evas_get(wd->obj));
2401    EINA_LIST_FOREACH(wd->group_items, l, git)
2402      {
2403         if (git->want_realize)
2404           {
2405              if (!git->realized)
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);
2411           }
2412         else if (!git->want_realize && git->realized)
2413           {
2414              if (!git->dragging)
2415                _item_unrealize(git, EINA_FALSE);
2416           }
2417      }
2418    evas_event_thaw(evas_object_evas_get(wd->obj));
2419    evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2420 }
2421
2422 static Eina_Bool
2423 _must_recalc_idler(void *data)
2424 {
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;
2430 }
2431
2432 static void
2433 _calc_job(void *data)
2434 {
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;
2440    double t0, t;
2441    Eina_Bool did_must_recalc = EINA_FALSE;
2442    if (!wd) return;
2443
2444    t0 = ecore_time_get();
2445    evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2446    if (wd->w != ow)
2447      wd->w = ow;
2448
2449    evas_event_freeze(evas_object_evas_get(wd->obj));
2450    EINA_INLIST_FOREACH(wd->blocks, itb)
2451      {
2452         Eina_Bool showme = EINA_FALSE;
2453
2454         itb->num = in;
2455         showme = itb->showme;
2456         itb->showme = EINA_FALSE;
2457         if (chb)
2458           {
2459              if (itb->realized) _item_block_unrealize(itb);
2460           }
2461         if ((itb->changed) || (changed) ||
2462             ((itb->must_recalc) && (!did_must_recalc)))
2463           {
2464              if ((changed) || (itb->must_recalc))
2465                {
2466                   Eina_List *l;
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;
2473                }
2474              if (itb->realized) _item_block_unrealize(itb);
2475              showme = _item_block_recalc(itb, in, EINA_FALSE);
2476              chb = itb;
2477           }
2478         itb->y = y;
2479         itb->x = 0;
2480         minh += itb->minh;
2481         if (minw == -1) minw = itb->minw;
2482         else if ((!itb->must_recalc) && (minw < itb->minw))
2483           {
2484              minw = itb->minw;
2485              minw_change = EINA_TRUE;
2486           }
2487         itb->w = minw;
2488         itb->h = itb->minh;
2489         y += itb->h;
2490         in += itb->count;
2491         if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2492           {
2493              wd->show_item->showme = EINA_FALSE;
2494              if (wd->bring_in)
2495                elm_smart_scroller_region_bring_in(wd->scr,
2496                                                   wd->show_item->x +
2497                                                   wd->show_item->block->x,
2498                                                   wd->show_item->y +
2499                                                   wd->show_item->block->y,
2500                                                   wd->show_item->block->w,
2501                                                   wd->show_item->h);
2502              else
2503                elm_smart_scroller_child_region_show(wd->scr,
2504                                                     wd->show_item->x +
2505                                                     wd->show_item->block->x,
2506                                                     wd->show_item->y +
2507                                                     wd->show_item->block->y,
2508                                                     wd->show_item->block->w,
2509                                                     wd->show_item->h);
2510              wd->show_item = NULL;
2511           }
2512      }
2513    if (minw_change)
2514      {
2515         EINA_INLIST_FOREACH(wd->blocks, itb)
2516           {
2517              itb->minw = minw;
2518              itb->w = itb->minw;
2519           }
2520      }
2521    if ((chb) && (EINA_INLIST_GET(chb)->next))
2522      {
2523         EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2524           {
2525              if (itb->realized) _item_block_unrealize(itb);
2526           }
2527      }
2528    wd->realminw = minw;
2529    if (minw < wd->w) minw = wd->w;
2530    if ((minw != wd->minw) || (minh != wd->minh))
2531      {
2532         wd->minw = minw;
2533         wd->minh = 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);
2537 #ifdef ANCHOR_ITEM
2538         if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2539           {
2540              Elm_Genlist_Item *it;
2541              Evas_Coord it_y;
2542
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;
2549           }
2550 #endif
2551      }
2552    t = ecore_time_get();
2553    if (did_must_recalc)
2554      {
2555         if (!wd->must_recalc_idler)
2556           wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2557      }
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));
2562 }
2563
2564 static void
2565 _update_job(void *data)
2566 {
2567    Widget_Data *wd = data;
2568    Eina_List *l2;
2569    Item_Block *itb;
2570    int num, num0;
2571    Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2572    if (!wd) return;
2573    wd->update_job = NULL;
2574    num = 0;
2575
2576    evas_event_freeze(evas_object_evas_get(wd->obj));
2577    EINA_INLIST_FOREACH(wd->blocks, itb)
2578      {
2579         Evas_Coord itminw, itminh;
2580         Elm_Genlist_Item *it;
2581
2582         if (!itb->updateme)
2583           {
2584              num += itb->count;
2585              if (position)
2586                _item_block_position(itb, num);
2587              continue;
2588           }
2589         num0 = num;
2590         recalc = EINA_FALSE;
2591         EINA_LIST_FOREACH(itb->items, l2, it)
2592           {
2593              if (it->updateme)
2594                {
2595                   itminw = it->minw;
2596                   itminh = it->minh;
2597
2598                   it->updateme = EINA_FALSE;
2599                   if (it->realized)
2600                     {
2601                        _item_unrealize(it, EINA_FALSE);
2602                        _item_realize(it, num, EINA_FALSE);
2603                        position = EINA_TRUE;
2604                     }
2605                   else
2606                     {
2607                        _item_realize(it, num, EINA_TRUE);
2608                        _item_unrealize(it, EINA_TRUE);
2609                     }
2610                   if ((it->minw != itminw) || (it->minh != itminh))
2611                     recalc = EINA_TRUE;
2612                }
2613              num++;
2614           }
2615         itb->updateme = EINA_FALSE;
2616         if (recalc)
2617           {
2618              position = EINA_TRUE;
2619              itb->changed = EINA_TRUE;
2620              _item_block_recalc(itb, num0, EINA_FALSE);
2621              _item_block_position(itb, num0);
2622           }
2623      }
2624    if (position)
2625      {
2626         if (wd->calc_job) ecore_job_del(wd->calc_job);
2627         wd->calc_job = ecore_job_add(_calc_job, wd);
2628      }
2629    evas_event_thaw(evas_object_evas_get(wd->obj));
2630    evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2631 }
2632
2633 static void
2634 _changed_job(void *data)
2635 {
2636    Widget_Data *wd = data; Eina_List *l2;
2637    Item_Block *itb;
2638    int num, num0, position = 0;
2639    Eina_Bool width_changed = EINA_FALSE, height_changed = EINA_FALSE;
2640    if (!wd) return;
2641    wd->changed_job = NULL;
2642    num = 0;
2643    EINA_INLIST_FOREACH(wd->blocks, itb)
2644      {
2645         Evas_Coord itminw, itminh;
2646         Elm_Genlist_Item *it;
2647
2648         if (!itb->changeme)
2649           {
2650              num += itb->count;
2651              if (position)
2652                _item_block_position(itb, num);
2653              continue;
2654           }
2655         num0 = num;
2656         width_changed = height_changed = EINA_FALSE;
2657         EINA_LIST_FOREACH(itb->items, l2, it)
2658           {
2659              if ((!it->mincalcd) && (it->realized))
2660                {
2661                   Evas_Coord mw = -1, mh = -1;
2662                   itminw = it->minw;
2663                   itminh = it->minh;
2664
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;
2675
2676                   //if ((it->minw != itminw) || (it->minh != itminh))
2677                   //if ((it->minh != itminh))
2678                   //  recalc = 1;
2679                   if ((it->minw != itminw))
2680                     width_changed = EINA_TRUE;
2681                   if ((it->minh != itminh))
2682                     height_changed = EINA_TRUE;
2683
2684                   if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2685                     {
2686                        it->wd->group_item_width = mw;
2687                        it->wd->group_item_height = mh;
2688                     }
2689                   else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2690                     {
2691                        it->wd->item_width = mw;
2692                        it->wd->item_height = mh;
2693                     }
2694                }
2695              num++;
2696           }
2697         itb->changeme = EINA_FALSE;
2698         // TODO: why this is separated.
2699         if (height_changed)
2700           {
2701              position = 1;
2702              itb->changed = EINA_TRUE;
2703              _item_block_recalc(itb, num0, 0);
2704              _item_block_position(itb, num0);
2705           }
2706         else if (width_changed)
2707           {
2708              _item_block_position(itb, num0);
2709           }
2710      }
2711    if (position)
2712      {
2713         if (wd->calc_job) ecore_job_del(wd->calc_job);
2714         wd->calc_job = ecore_job_add(_calc_job, wd);
2715      }
2716 }
2717
2718 static void
2719 _pan_set(Evas_Object *obj,
2720          Evas_Coord   x,
2721          Evas_Coord   y)
2722 {
2723    Pan *sd = evas_object_smart_data_get(obj);
2724 #ifdef ANCHOR_ITEM
2725    Item_Block *itb;
2726 #endif
2727
2728    if (!sd) return;
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;
2740    sd->wd->pan_x = x;
2741    sd->wd->pan_y = y;
2742
2743 #ifdef ANCHOR_ITEM
2744    EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2745      {
2746         if ((itb->y + itb->h) > y)
2747           {
2748              Elm_Genlist_Item *it;
2749              Eina_List *l2;
2750
2751              EINA_LIST_FOREACH(itb->items, l2, it)
2752                {
2753                   if ((itb->y + it->y) >= y)
2754                     {
2755                        sd->wd->anchor_item = it;
2756                        sd->wd->anchor_y = -(itb->y + it->y - y);
2757                        goto done;
2758                     }
2759                }
2760           }
2761      }
2762 done:
2763 #endif
2764    if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2765 }
2766
2767 static void
2768 _pan_get(Evas_Object *obj,
2769          Evas_Coord  *x,
2770          Evas_Coord  *y)
2771 {
2772    Pan *sd = evas_object_smart_data_get(obj);
2773
2774    if (!sd) return;
2775    if (x) *x = sd->wd->pan_x;
2776    if (y) *y = sd->wd->pan_y;
2777 }
2778
2779 static void
2780 _pan_max_get(Evas_Object *obj,
2781              Evas_Coord  *x,
2782              Evas_Coord  *y)
2783 {
2784    Pan *sd = evas_object_smart_data_get(obj);
2785    Evas_Coord ow, oh;
2786
2787    if (!sd) return;
2788    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2789    ow = sd->wd->minw - ow;
2790    if (ow < 0) ow = 0;
2791    oh = sd->wd->minh - oh;
2792    if (oh < 0) oh = 0;
2793    if (x) *x = ow;
2794    if (y) *y = oh;
2795 }
2796
2797 static void
2798 _pan_min_get(Evas_Object *obj __UNUSED__,
2799              Evas_Coord  *x,
2800              Evas_Coord  *y)
2801 {
2802    if (x) *x = 0;
2803    if (y) *y = 0;
2804 }
2805
2806 static void
2807 _pan_child_size_get(Evas_Object *obj,
2808                     Evas_Coord  *w,
2809                     Evas_Coord  *h)
2810 {
2811    Pan *sd = evas_object_smart_data_get(obj);
2812
2813    if (!sd) return;
2814    if (w) *w = sd->wd->minw;
2815    if (h) *h = sd->wd->minh;
2816 }
2817
2818 static void
2819 _pan_add(Evas_Object *obj)
2820 {
2821    Pan *sd;
2822    Evas_Object_Smart_Clipped_Data *cd;
2823
2824    _pan_sc.add(obj);
2825    cd = evas_object_smart_data_get(obj);
2826    sd = ELM_NEW(Pan);
2827    if (!sd) return;
2828    sd->__clipped_data = *cd;
2829    free(cd);
2830    evas_object_smart_data_set(obj, sd);
2831 }
2832
2833 static void
2834 _pan_del(Evas_Object *obj)
2835 {
2836    Pan *sd = evas_object_smart_data_get(obj);
2837
2838    if (!sd) return;
2839    if (sd->resize_job)
2840      {
2841         ecore_job_del(sd->resize_job);
2842         sd->resize_job = NULL;
2843      }
2844    _pan_sc.del(obj);
2845 }
2846
2847 static void
2848 _pan_resize_job(void *data)
2849 {
2850    Pan *sd = data;
2851    if (!sd) return;
2852    _sizing_eval(sd->wd->obj);
2853    sd->resize_job = NULL;
2854 }
2855
2856 static void
2857 _pan_resize(Evas_Object *obj,
2858             Evas_Coord   w,
2859             Evas_Coord   h)
2860 {
2861    Pan *sd = evas_object_smart_data_get(obj);
2862    Evas_Coord ow, oh;
2863
2864    if (!sd) return;
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))
2868      {
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);
2872      }
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);
2875 }
2876
2877 static void
2878 _pan_calculate(Evas_Object *obj)
2879 {
2880    Pan *sd = evas_object_smart_data_get(obj);
2881    Item_Block *itb;
2882    Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2883    int in = 0;
2884    Elm_Genlist_Item *git;
2885    Eina_List *l;
2886
2887    if (!sd) return;
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)
2893      {
2894         git->want_realize = EINA_FALSE;
2895      }
2896    EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2897      {
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,
2901                                 itb->w, itb->h,
2902                                 cvx, cvy, cvw, cvh))
2903           {
2904              if ((!itb->realized) || (itb->changed))
2905                _item_block_realize(itb, in, 0);
2906              _item_block_position(itb, in);
2907           }
2908         else
2909           {
2910              if (itb->realized) _item_block_unrealize(itb);
2911           }
2912         in += itb->count;
2913      }
2914    if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2915       _group_items_recalc(sd->wd);
2916
2917    if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2918      {
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();
2925      }
2926
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)))
2931         {
2932            if (!sd->wd->item_moving_effect_timer)
2933              {
2934                 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2935                    _item_flip_effect_show(sd->wd->expand_item);
2936
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);
2942              }
2943         }
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));
2948 }
2949
2950 static void
2951 _pan_move(Evas_Object *obj,
2952           Evas_Coord   x __UNUSED__,
2953           Evas_Coord   y __UNUSED__)
2954 {
2955    Pan *sd = evas_object_smart_data_get(obj);
2956
2957    if (!sd) return;
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);
2960 }
2961
2962 static void
2963 _hold_on(void        *data __UNUSED__,
2964          Evas_Object *obj,
2965          void        *event_info __UNUSED__)
2966 {
2967    Widget_Data *wd = elm_widget_data_get(obj);
2968    if (!wd) return;
2969    elm_smart_scroller_hold_set(wd->scr, 1);
2970 }
2971
2972 static void
2973 _hold_off(void        *data __UNUSED__,
2974           Evas_Object *obj,
2975           void        *event_info __UNUSED__)
2976 {
2977    Widget_Data *wd = elm_widget_data_get(obj);
2978    if (!wd) return;
2979    elm_smart_scroller_hold_set(wd->scr, 0);
2980 }
2981
2982 static void
2983 _freeze_on(void        *data __UNUSED__,
2984            Evas_Object *obj,
2985            void        *event_info __UNUSED__)
2986 {
2987    Widget_Data *wd = elm_widget_data_get(obj);
2988    if (!wd) return;
2989    elm_smart_scroller_freeze_set(wd->scr, 1);
2990 }
2991
2992 static void
2993 _freeze_off(void        *data __UNUSED__,
2994             Evas_Object *obj,
2995             void        *event_info __UNUSED__)
2996 {
2997    Widget_Data *wd = elm_widget_data_get(obj);
2998    if (!wd) return;
2999    elm_smart_scroller_freeze_set(wd->scr, 0);
3000 }
3001
3002 static void
3003 _scroll_edge_left(void        *data,
3004                   Evas_Object *scr __UNUSED__,
3005                   void        *event_info __UNUSED__)
3006 {
3007    Evas_Object *obj = data;
3008    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
3009 }
3010
3011 static void
3012 _scroll_edge_right(void        *data,
3013                    Evas_Object *scr __UNUSED__,
3014                    void        *event_info __UNUSED__)
3015 {
3016    Evas_Object *obj = data;
3017    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
3018 }
3019
3020 static void
3021 _scroll_edge_top(void        *data,
3022                  Evas_Object *scr __UNUSED__,
3023                  void        *event_info __UNUSED__)
3024 {
3025    Evas_Object *obj = data;
3026    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
3027 }
3028
3029 static void
3030 _scroll_edge_bottom(void        *data,
3031                     Evas_Object *scr __UNUSED__,
3032                     void        *event_info __UNUSED__)
3033 {
3034    Evas_Object *obj = data;
3035    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
3036 }
3037
3038 static void
3039 _mode_item_realize(Elm_Genlist_Item *it)
3040 {
3041    char buf[1024];
3042
3043    if ((it->mode_view) || (it->delete_me)) return;
3044
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);
3052
3053    strncpy(buf, "item", sizeof(buf));
3054    if (it->wd->compress)
3055      strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3056
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));
3060
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));
3065
3066    /* signal callback add */
3067    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3068                                   _mouse_down, it);
3069    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3070                                   _mouse_up, it);
3071    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3072                                   _mouse_move, it);
3073
3074    /* label_get, icon_get, state_get */
3075    if (it->itc->func.label_get)
3076      {
3077         const Eina_List *l;
3078         const char *key;
3079
3080         it->mode_labels =
3081            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3082                                                           "labels"));
3083         EINA_LIST_FOREACH(it->mode_labels, l, key)
3084           {
3085              char *s = it->itc->func.label_get
3086                 ((void *)it->base.data, it->base.widget, l->data);
3087
3088              if (s)
3089                {
3090                   edje_object_part_text_set(it->mode_view, l->data, s);
3091                   free(s);
3092                }
3093           }
3094      }
3095    if (it->itc->func.icon_get)
3096      {
3097         const Eina_List *l;
3098         const char *key;
3099
3100         it->mode_icons =
3101            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3102                                                           "icons"));
3103         EINA_LIST_FOREACH(it->mode_icons, l, key)
3104          {
3105            Evas_Object *ic = it->itc->func.icon_get
3106                 ((void *)it->base.data, it->base.widget, l->data);
3107
3108              if (ic)
3109                {
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);
3114                   if (it->disabled)
3115                     elm_widget_disabled_set(ic, EINA_TRUE);
3116                }
3117           }
3118      }
3119    if (it->itc->func.state_get)
3120      {
3121         const Eina_List *l;
3122         const char *key;
3123
3124         it->mode_states =
3125            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3126                                                           "states"));
3127         EINA_LIST_FOREACH(it->mode_states, l, key)
3128           {
3129              Eina_Bool on = it->itc->func.state_get
3130                 ((void *)it->base.data, it->base.widget, l->data);
3131
3132              if (on)
3133                {
3134                   snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
3135                   edje_object_signal_emit(it->mode_view, buf, "elm");
3136                }
3137           }
3138      }
3139
3140    edje_object_part_swallow(it->mode_view,
3141                             edje_object_data_get(it->mode_view, "mode_part"),
3142                             it->base.view);
3143
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));
3147 }
3148
3149 static void
3150 _mode_item_unrealize(Elm_Genlist_Item *it)
3151 {
3152    Widget_Data *wd = it->wd;
3153    Evas_Object *icon;
3154    if (!it->mode_view) return;
3155
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);
3162
3163    EINA_LIST_FREE(it->mode_icon_objs, icon)
3164      evas_object_del(icon);
3165
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;
3170
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));
3175 }
3176
3177 static void
3178 _item_mode_set(Elm_Genlist_Item *it)
3179 {
3180    if (!it) return;
3181    Widget_Data *wd = it->wd;
3182    if (!wd) return;
3183    char buf[1024];
3184
3185    wd->mode_item = it;
3186    it->nocache = EINA_TRUE;
3187
3188    if (wd->scr_hold_timer)
3189      {
3190         ecore_timer_del(wd->scr_hold_timer);
3191         wd->scr_hold_timer = NULL;
3192      }
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);
3195
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));
3201
3202    snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3203    edje_object_signal_emit(it->mode_view, buf, "elm");
3204 }
3205
3206 static void
3207 _item_mode_unset(Widget_Data *wd)
3208 {
3209    if (!wd) return;
3210    if (!wd->mode_item) return;
3211    char buf[1024], buf2[1024];
3212    Elm_Genlist_Item *it;
3213
3214    it = wd->mode_item;
3215    it->nocache = EINA_TRUE;
3216
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);
3219
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);
3222
3223    wd->mode_item = NULL;
3224 }
3225
3226 EAPI Evas_Object *
3227 elm_genlist_add(Evas_Object *parent)
3228 {
3229    Evas_Object *obj;
3230    Evas *e;
3231    Widget_Data *wd;
3232    Evas_Coord minw, minh;
3233    static Evas_Smart *smart = NULL;
3234
3235    if (!smart)
3236      {
3237         static Evas_Smart_Class sc;
3238
3239         evas_object_smart_clipped_smart_set(&_pan_sc);
3240         sc = _pan_sc;
3241         sc.name = "elm_genlist_pan";
3242         sc.version = EVAS_SMART_CLASS_VERSION;
3243         sc.add = _pan_add;
3244         sc.del = _pan_del;
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;
3249      }
3250
3251    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3252
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);
3265
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);
3273
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,
3276                                   obj);
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,
3279                                   obj);
3280
3281    wd->obj = obj;
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;
3287
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);
3292
3293    wd->pan_smart = evas_object_smart_add(e, smart);
3294    wd->pan = evas_object_smart_data_get(wd->pan_smart);
3295    wd->pan->wd = wd;
3296
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);
3300
3301    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3302                              &minw, &minh);
3303    evas_object_size_hint_min_set(obj, minw, minh);
3304
3305    evas_object_smart_callbacks_descriptions_set(obj, _signals);
3306    _mirrored_set(obj, elm_widget_mirrored_get(obj));
3307    _sizing_eval(obj);
3308    return obj;
3309 }
3310
3311 static Elm_Genlist_Item *
3312 _item_new(Widget_Data                  *wd,
3313           const Elm_Genlist_Item_Class *itc,
3314           const void                   *data,
3315           Elm_Genlist_Item             *parent,
3316           Elm_Genlist_Item_Flags        flags,
3317           Evas_Smart_Cb                 func,
3318           const void                   *func_data)
3319 {
3320    Elm_Genlist_Item *it;
3321
3322    it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3323    if (!it) return NULL;
3324    it->wd = wd;
3325    it->itc = itc;
3326    it->base.data = data;
3327    it->parent = parent;
3328    it->flags = flags;
3329    it->func.func = func;
3330    it->func.data = func_data;
3331    it->mouse_cursor = NULL;
3332    it->expanded_depth = 0;
3333
3334    if (it->parent)
3335      {
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;
3340      }
3341    return it;
3342 }
3343
3344 static void
3345 _item_block_add(Widget_Data      *wd,
3346                 Elm_Genlist_Item *it)
3347 {
3348    Item_Block *itb = NULL;
3349
3350    if (!it->rel)
3351      {
3352 newblock:
3353         if (it->rel)
3354           {
3355              itb = calloc(1, sizeof(Item_Block));
3356              if (!itb) return;
3357              itb->wd = wd;
3358              if (!it->rel->block)
3359                {
3360                   wd->blocks =
3361                     eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3362                   itb->items = eina_list_append(itb->items, it);
3363                }
3364              else
3365                {
3366                   if (it->before)
3367                     {
3368                        wd->blocks = eina_inlist_prepend_relative
3369                            (wd->blocks, EINA_INLIST_GET(itb),
3370                            EINA_INLIST_GET(it->rel->block));
3371                        itb->items =
3372                          eina_list_prepend_relative(itb->items, it, it->rel);
3373                     }
3374                   else
3375                     {
3376                        wd->blocks = eina_inlist_append_relative
3377                            (wd->blocks, EINA_INLIST_GET(itb),
3378                            EINA_INLIST_GET(it->rel->block));
3379                        itb->items =
3380                          eina_list_append_relative(itb->items, it, it->rel);
3381                     }
3382                }
3383           }
3384         else
3385           {
3386              if (it->before)
3387                {
3388                   if (wd->blocks)
3389                     {
3390                        itb = (Item_Block *)(wd->blocks);
3391                        if (itb->count >= wd->max_items_per_block)
3392                          {
3393                             itb = calloc(1, sizeof(Item_Block));
3394                             if (!itb) return;
3395                             itb->wd = wd;
3396                             wd->blocks =
3397                               eina_inlist_prepend(wd->blocks,
3398                                                   EINA_INLIST_GET(itb));
3399                          }
3400                     }
3401                   else
3402                     {
3403                        itb = calloc(1, sizeof(Item_Block));
3404                        if (!itb) return;
3405                        itb->wd = wd;
3406                        wd->blocks =
3407                          eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3408                     }
3409                   itb->items = eina_list_prepend(itb->items, it);
3410                }
3411              else
3412                {
3413                   if (wd->blocks)
3414                     {
3415                        itb = (Item_Block *)(wd->blocks->last);
3416                        if (itb->count >= wd->max_items_per_block)
3417                          {
3418                             itb = calloc(1, sizeof(Item_Block));
3419                             if (!itb) return;
3420                             itb->wd = wd;
3421                             wd->blocks =
3422                               eina_inlist_append(wd->blocks,
3423                                                  EINA_INLIST_GET(itb));
3424                          }
3425                     }
3426                   else
3427                     {
3428                        itb = calloc(1, sizeof(Item_Block));
3429                        if (!itb) return;
3430                        itb->wd = wd;
3431                        wd->blocks =
3432                          eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3433                     }
3434                   itb->items = eina_list_append(itb->items, it);
3435                }
3436           }
3437      }
3438    else
3439      {
3440         itb = it->rel->block;
3441         if (!itb) goto newblock;
3442         if (it->before)
3443           itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3444         else
3445           itb->items = eina_list_append_relative(itb->items, it, it->rel);
3446      }
3447    itb->count++;
3448    itb->changed = EINA_TRUE;
3449    it->block = itb;
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);
3452    if (it->rel)
3453      {
3454         it->rel->relcount--;
3455         if ((it->rel->delete_me) && (!it->rel->relcount))
3456           _item_del(it->rel);
3457         it->rel = NULL;
3458      }
3459    if (itb->count > itb->wd->max_items_per_block)
3460      {
3461         int newc;
3462         Item_Block *itb2;
3463         Elm_Genlist_Item *it2;
3464
3465         newc = itb->count / 2;
3466         itb2 = calloc(1, sizeof(Item_Block));
3467         if (!itb2) return;
3468         itb2->wd = wd;
3469         wd->blocks =
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))
3474           {
3475              Eina_List *l;
3476
3477              l = eina_list_last(itb->items);
3478              it2 = l->data;
3479              itb->items = eina_list_remove_list(itb->items, l);
3480              itb->count--;
3481
3482              itb2->items = eina_list_prepend(itb2->items, it2);
3483              it2->block = itb2;
3484              itb2->count++;
3485           }
3486      }
3487 }
3488
3489 static int
3490 _queue_process(Widget_Data *wd)
3491 {
3492    int n;
3493    Eina_Bool showme = EINA_FALSE;
3494    double t0, t;
3495
3496    t0 = ecore_time_get();
3497    //evas_event_freeze(evas_object_evas_get(wd->obj));
3498    for (n = 0; (wd->queue) && (n < 128); n++)
3499      {
3500         Elm_Genlist_Item *it;
3501
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)
3508           {
3509              showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3510              it->block->changed = 0;
3511           }
3512         if (showme) it->block->showme = EINA_TRUE;
3513         if (eina_inlist_count(wd->blocks) > 1)
3514           {
3515              if ((t - t0) > (ecore_animator_frametime_get())) break;
3516           }
3517      }
3518    //evas_event_thaw(evas_object_evas_get(wd->obj));
3519    //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3520    return n;
3521 }
3522
3523 static Eina_Bool
3524 _idle_process(void *data, Eina_Bool *wakeup)
3525 {
3526    Widget_Data *wd = data;
3527
3528    //xxx
3529    //static double q_start = 0.0;
3530    //if (q_start == 0.0) q_start = ecore_time_get();
3531    //xxx
3532    if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3533    if (!wd->queue)
3534      {
3535         //xxx
3536         //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3537         //xxx
3538         return ECORE_CALLBACK_CANCEL;
3539      }
3540    return ECORE_CALLBACK_RENEW;
3541 }
3542
3543 static Eina_Bool
3544 _item_idle_enterer(void *data)
3545 {
3546    Widget_Data *wd = data;
3547    Eina_Bool wakeup = EINA_FALSE;
3548    Eina_Bool ok = _idle_process(data, &wakeup);
3549
3550    if (wakeup)
3551      {
3552         // wake up mainloop
3553         if (wd->calc_job) ecore_job_del(wd->calc_job);
3554         wd->calc_job = ecore_job_add(_calc_job, wd);
3555      }
3556    if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3557    return ok;
3558 }
3559
3560 static void
3561 _item_queue(Widget_Data      *wd,
3562             Elm_Genlist_Item *it)
3563 {
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)))
3571      {
3572         if (wd->queue_idle_enterer)
3573           {
3574              ecore_idle_enterer_del(wd->queue_idle_enterer);
3575              wd->queue_idle_enterer = NULL;
3576           }
3577         _queue_process(wd);
3578      }
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);
3583 }
3584
3585 static void
3586 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3587 {
3588    if (!it) return;
3589    if (!after) return;
3590
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);
3594
3595    it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3596    it->rel = 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);
3601
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);
3605 }
3606
3607 static void
3608 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3609 {
3610    if (!it) return;
3611    if (!before) return;
3612
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));
3617    it->rel = 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);
3622
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);
3626 }
3627
3628 EAPI Elm_Genlist_Item *
3629 elm_genlist_item_append(Evas_Object                  *obj,
3630                         const Elm_Genlist_Item_Class *itc,
3631                         const void                   *data,
3632                         Elm_Genlist_Item             *parent,
3633                         Elm_Genlist_Item_Flags        flags,
3634                         Evas_Smart_Cb                 func,
3635                         const void                   *func_data)
3636 {
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,
3641                                     func_data);
3642    if (!it) return NULL;
3643    if (!it->parent)
3644      {
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));
3648         it->rel = NULL;
3649      }
3650    else
3651      {
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;
3657         if (it2->delete_me)
3658            it2 = elm_genlist_item_prev_get(it2);
3659         wd->items =
3660           eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3661                                       EINA_INLIST_GET(it2));
3662         it->rel = it2;
3663         it->rel->relcount++;
3664      }
3665    it->before = EINA_FALSE;
3666    _item_queue(wd, it);
3667    return it;
3668 }
3669
3670 EAPI Elm_Genlist_Item *
3671 elm_genlist_item_prepend(Evas_Object                  *obj,
3672                          const Elm_Genlist_Item_Class *itc,
3673                          const void                   *data,
3674                          Elm_Genlist_Item             *parent,
3675                          Elm_Genlist_Item_Flags        flags,
3676                          Evas_Smart_Cb                 func,
3677                          const void                   *func_data)
3678 {
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,
3683                                     func_data);
3684    if (!it) return NULL;
3685    if (!it->parent)
3686      {
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));
3690         it->rel = NULL;
3691      }
3692    else
3693      {
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;
3699         if (it2->delete_me)
3700            it2 = elm_genlist_item_next_get(it2);
3701         wd->items =
3702           eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3703                                        EINA_INLIST_GET(it2));
3704         it->rel = it2;
3705         it->rel->relcount++;
3706      }
3707    it->before = EINA_TRUE;
3708    _item_queue(wd, it);
3709    return it;
3710 }
3711
3712 EAPI Elm_Genlist_Item *
3713 elm_genlist_item_insert_after(Evas_Object                  *obj,
3714                               const Elm_Genlist_Item_Class *itc,
3715                               const void                   *data,
3716                               Elm_Genlist_Item             *parent,
3717                               Elm_Genlist_Item             *after,
3718                               Elm_Genlist_Item_Flags        flags,
3719                               Evas_Smart_Cb                 func,
3720                               const void                   *func_data)
3721 {
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,
3727                                     func_data);
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);
3731
3732    if (!it->parent)
3733      {
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,
3737                                                       after);
3738      }
3739    else
3740      {
3741         it->parent->items = eina_list_append_relative(it->parent->items, it,
3742                                                       after);
3743      }
3744    wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3745                                            EINA_INLIST_GET(after));
3746    it->rel = after;
3747    it->rel->relcount++;
3748    it->before = EINA_FALSE;
3749    _item_queue(wd, it);
3750    return it;
3751 }
3752
3753 EAPI Elm_Genlist_Item *
3754 elm_genlist_item_insert_before(Evas_Object                  *obj,
3755                                const Elm_Genlist_Item_Class *itc,
3756                                const void                   *data,
3757                                Elm_Genlist_Item             *parent,
3758                                Elm_Genlist_Item             *before,
3759                                Elm_Genlist_Item_Flags        flags,
3760                                Evas_Smart_Cb                 func,
3761                                const void                   *func_data)
3762 {
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,
3768                                     func_data);
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);
3772
3773    if (!it->parent)
3774      {
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,
3778                                                        before);
3779      }
3780    else
3781      {
3782         it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3783                                                        before);
3784      }
3785    wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3786                                             EINA_INLIST_GET(before));
3787    it->rel = before;
3788    it->rel->relcount++;
3789    it->before = EINA_TRUE;
3790    _item_queue(wd, it);
3791    return it;
3792 }
3793
3794 EAPI void
3795 elm_genlist_clear(Evas_Object *obj)
3796 {
3797    ELM_CHECK_WIDTYPE(obj, widtype);
3798    Widget_Data *wd = elm_widget_data_get(obj);
3799    if (!wd) return;
3800    if (wd->walking > 0)
3801      {
3802         Elm_Genlist_Item *it;
3803
3804         wd->clear_me = EINA_TRUE;
3805         EINA_INLIST_FOREACH(wd->items, it)
3806           {
3807              it->delete_me = EINA_TRUE;
3808           }
3809         return;
3810      }
3811    evas_event_freeze(evas_object_evas_get(wd->obj));
3812    while (wd->items)
3813      {
3814         Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3815         it->nocache = EINA_TRUE;
3816         it->highlighted = EINA_FALSE;
3817 #ifdef ANCHOR_ITEM
3818         if (wd->anchor_item == it)
3819           {
3820              wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3821              if (!wd->anchor_item)
3822                wd->anchor_item =
3823                  ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3824           }
3825 #endif
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);
3836      }
3837    wd->clear_me = EINA_FALSE;
3838    wd->anchor_item = NULL;
3839    while (wd->blocks)
3840      {
3841         Item_Block *itb = (Item_Block *)(wd->blocks);
3842
3843         wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3844         if (itb->items) eina_list_free(itb->items);
3845         free(itb);
3846      }
3847    if (wd->calc_job)
3848      {
3849         ecore_job_del(wd->calc_job);
3850         wd->calc_job = NULL;
3851      }
3852    if (wd->queue_idle_enterer)
3853      {
3854         ecore_idle_enterer_del(wd->queue_idle_enterer);
3855         wd->queue_idle_enterer = NULL;
3856      }
3857    if (wd->must_recalc_idler)
3858      {
3859         ecore_idler_del(wd->must_recalc_idler);
3860         wd->must_recalc_idler = NULL;
3861      }
3862    if (wd->queue)
3863      {
3864         eina_list_free(wd->queue);
3865         wd->queue = NULL;
3866      }
3867    if (wd->selected)
3868      {
3869         eina_list_free(wd->selected);
3870         wd->selected = NULL;
3871      }
3872    if (wd->reorder_move_animator)
3873      {
3874         ecore_animator_del(wd->reorder_move_animator);
3875         wd->reorder_move_animator = NULL;
3876      }
3877    wd->show_item = NULL;
3878    wd->pan_x = 0;
3879    wd->pan_y = 0;
3880    wd->old_pan_y = 0;
3881    wd->minw = 0;
3882    wd->minh = 0;
3883
3884    if (wd->alpha_bg)
3885       evas_object_del(wd->alpha_bg);
3886    wd->alpha_bg = NULL;
3887
3888    if (wd->pan_smart)
3889      {
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);
3892      }
3893    _sizing_eval(obj);
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));
3897 }
3898
3899 EAPI void
3900 elm_genlist_multi_select_set(Evas_Object *obj,
3901                              Eina_Bool    multi)
3902 {
3903    ELM_CHECK_WIDTYPE(obj, widtype);
3904    Widget_Data *wd = elm_widget_data_get(obj);
3905    if (!wd) return;
3906    wd->multi = multi;
3907 }
3908
3909 EAPI Eina_Bool
3910 elm_genlist_multi_select_get(const Evas_Object *obj)
3911 {
3912    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3913    Widget_Data *wd = elm_widget_data_get(obj);
3914    if (!wd) return EINA_FALSE;
3915    return wd->multi;
3916 }
3917
3918 EAPI Elm_Genlist_Item *
3919 elm_genlist_selected_item_get(const Evas_Object *obj)
3920 {
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;
3925    return NULL;
3926 }
3927
3928 EAPI const Eina_List *
3929 elm_genlist_selected_items_get(const Evas_Object *obj)
3930 {
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;
3935 }
3936
3937 EAPI Eina_List *
3938 elm_genlist_realized_items_get(const Evas_Object *obj)
3939 {
3940    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3941    Widget_Data *wd = elm_widget_data_get(obj);
3942    Eina_List *list = NULL;
3943    Item_Block *itb;
3944    Eina_Bool done = EINA_FALSE;
3945    if (!wd) return NULL;
3946    EINA_INLIST_FOREACH(wd->blocks, itb)
3947      {
3948         if (itb->realized)
3949           {
3950              Eina_List *l;
3951              Elm_Genlist_Item *it;
3952
3953              done = 1;
3954              EINA_LIST_FOREACH(itb->items, l, it)
3955                {
3956                   if (it->realized) list = eina_list_append(list, it);
3957                }
3958           }
3959         else
3960           {
3961              if (done) break;
3962           }
3963      }
3964    return list;
3965 }
3966
3967 EAPI Elm_Genlist_Item *
3968 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3969                            Evas_Coord         x,
3970                            Evas_Coord         y,
3971                            int               *posret)
3972 {
3973    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3974    Widget_Data *wd = elm_widget_data_get(obj);
3975    Evas_Coord ox, oy, ow, oh;
3976    Item_Block *itb;
3977    Evas_Coord lasty;
3978    if (!wd) return NULL;
3979    evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3980    lasty = oy;
3981    EINA_INLIST_FOREACH(wd->blocks, itb)
3982      {
3983         Eina_List *l;
3984         Elm_Genlist_Item *it;
3985
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))
3989           continue;
3990         EINA_LIST_FOREACH(itb->items, l, it)
3991           {
3992              Evas_Coord itx, ity;
3993
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))
3997                {
3998                   if (posret)
3999                     {
4000                        if (y <= (ity + (it->h / 4))) *posret = -1;
4001                        else if (y >= (ity + it->h - (it->h / 4)))
4002                          *posret = 1;
4003                        else *posret = 0;
4004                     }
4005                   return it;
4006                }
4007              lasty = ity + it->h;
4008           }
4009      }
4010    if (posret)
4011      {
4012         if (y > lasty) *posret = 1;
4013         else *posret = -1;
4014      }
4015    return NULL;
4016 }
4017
4018 EAPI Elm_Genlist_Item *
4019 elm_genlist_first_item_get(const Evas_Object *obj)
4020 {
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);
4028    return it;
4029 }
4030
4031 EAPI Elm_Genlist_Item *
4032 elm_genlist_last_item_get(const Evas_Object *obj)
4033 {
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);
4041    return it;
4042 }
4043
4044 EAPI Elm_Genlist_Item *
4045 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4046 {
4047    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4048    while (it)
4049      {
4050         it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4051         if ((it) && (!it->delete_me)) break;
4052      }
4053    return (Elm_Genlist_Item *)it;
4054 }
4055
4056 EAPI Elm_Genlist_Item *
4057 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4058 {
4059    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4060    while (it)
4061      {
4062         it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4063         if ((it) && (!it->delete_me)) break;
4064      }
4065    return (Elm_Genlist_Item *)it;
4066 }
4067
4068 EAPI Evas_Object *
4069 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4070 {
4071    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4072    return it->base.widget;
4073 }
4074
4075 EAPI Elm_Genlist_Item *
4076 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4077 {
4078    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4079    return it->parent;
4080 }
4081
4082 EAPI void
4083 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4084 {
4085    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4086    Elm_Genlist_Item *it2;
4087    Evas_Coord y, h;
4088
4089    if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4090       _item_subitems_clear(it);
4091    else
4092      {
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    )
4095           {
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;
4100
4101               it2= it;
4102              do {
4103                   it2 = elm_genlist_item_next_get(it2);
4104                   if (!it2) break;
4105              } while (it2->expanded_depth > it->expanded_depth);
4106              if (it2)
4107                 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4108              else
4109                 it->wd->expand_item_gap = 0;
4110
4111              evas_object_raise(it->wd->alpha_bg);
4112              evas_object_show(it->wd->alpha_bg);
4113
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);
4116           }
4117         else
4118            _item_subitems_clear(it);
4119      }
4120 }
4121
4122 EAPI void
4123 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4124                               Eina_Bool         selected)
4125 {
4126    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4127    Widget_Data *wd = elm_widget_data_get(it->base.widget);
4128    if (!wd) return;
4129    if ((it->delete_me) || (it->disabled)) return;
4130    selected = !!selected;
4131    if (it->selected == selected) return;
4132
4133    if (selected)
4134      {
4135         if (!wd->multi)
4136           {
4137              while (wd->selected)
4138                _item_unselect(wd->selected->data);
4139           }
4140         _item_highlight(it);
4141         _item_select(it);
4142      }
4143    else
4144      _item_unselect(it);
4145 }
4146
4147 EAPI Eina_Bool
4148 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4149 {
4150    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4151    return it->selected;
4152 }
4153
4154 EAPI void
4155 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4156                               Eina_Bool         expanded)
4157 {
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;
4163
4164    if (it->wd->effect_mode && !it->wd->alpha_bg)
4165       it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4166
4167    if (it->expanded)
4168      {
4169         it->wd->auto_scrolled = EINA_FALSE;
4170         it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4171         if (it->realized)
4172           edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4173         evas_object_smart_callback_call(it->base.widget, "expanded", it);
4174      }
4175    else
4176      {
4177         it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4178         if (it->realized)
4179           edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4180         evas_object_smart_callback_call(it->base.widget, "contracted", it);
4181      }
4182 }
4183
4184 EAPI Eina_Bool
4185 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4186 {
4187    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4188    return it->expanded;
4189 }
4190
4191 EAPI int
4192 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4193 {
4194    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4195    return it->expanded_depth;
4196 }
4197
4198 EAPI void
4199 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4200                               Eina_Bool         disabled)
4201 {
4202    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4203    Eina_List *l;
4204    Evas_Object *obj;
4205    if (it->disabled == disabled) return;
4206    if (it->delete_me) return;
4207    it->disabled = disabled;
4208    if (it->selected)
4209      elm_genlist_item_selected_set(it, EINA_FALSE);
4210    if (it->realized)
4211      {
4212         if (it->disabled)
4213           {
4214              edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4215              if (it->edit_obj)
4216                edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
4217           }
4218         else
4219           {
4220              edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4221              if (it->edit_obj)
4222                edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
4223           }
4224         EINA_LIST_FOREACH(it->icon_objs, l, obj)
4225            elm_widget_disabled_set(obj, disabled);
4226      }
4227 }
4228
4229 EAPI Eina_Bool
4230 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4231 {
4232    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4233    if (it->delete_me) return EINA_FALSE;
4234    return it->disabled;
4235 }
4236
4237 EAPI void
4238 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4239                                   Eina_Bool         display_only)
4240 {
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);
4250 }
4251
4252 EAPI Eina_Bool
4253 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4254 {
4255    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4256    if (it->delete_me) return EINA_FALSE;
4257    return it->display_only;
4258 }
4259
4260 EAPI void
4261 elm_genlist_item_show(Elm_Genlist_Item *it)
4262 {
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))
4267      {
4268         it->wd->show_item = it;
4269         it->wd->bring_in = EINA_TRUE;
4270         it->showme = EINA_TRUE;
4271         return;
4272      }
4273    if (it->wd->show_item)
4274      {
4275         it->wd->show_item->showme = EINA_FALSE;
4276         it->wd->show_item = NULL;
4277      }
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);
4284 }
4285
4286 EAPI void
4287 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4288 {
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))
4293      {
4294         it->wd->show_item = it;
4295         it->wd->bring_in = EINA_TRUE;
4296         it->showme = EINA_TRUE;
4297         return;
4298      }
4299    if (it->wd->show_item)
4300      {
4301         it->wd->show_item->showme = EINA_FALSE;
4302         it->wd->show_item = NULL;
4303      }
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);
4310 }
4311
4312 EAPI void
4313 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4314 {
4315    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4316    Evas_Coord ow, oh;
4317    Evas_Coord gith = 0;
4318
4319    if (it->delete_me) return;
4320    if ((it->queued) || (!it->mincalcd))
4321      {
4322         it->wd->show_item = it;
4323         it->wd->bring_in = EINA_TRUE;
4324         it->showme = EINA_TRUE;
4325         return;
4326      }
4327    if (it->wd->show_item)
4328      {
4329         it->wd->show_item->showme = EINA_FALSE;
4330         it->wd->show_item = NULL;
4331      }
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,
4337                                         it->block->w, oh);
4338 }
4339
4340 EAPI void
4341 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4342 {
4343    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4344    Evas_Coord ow, oh;
4345    Evas_Coord gith = 0;
4346
4347    if (it->delete_me) return;
4348    if ((it->queued) || (!it->mincalcd))
4349      {
4350         it->wd->show_item = it;
4351         it->wd->bring_in = EINA_TRUE;
4352         it->showme = EINA_TRUE;
4353         return;
4354      }
4355    if (it->wd->show_item)
4356      {
4357         it->wd->show_item->showme = EINA_FALSE;
4358         it->wd->show_item = NULL;
4359      }
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,
4365                                       it->block->w, oh);
4366 }
4367
4368 EAPI void
4369 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4370 {
4371    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4372    Evas_Coord ow, oh;
4373
4374    if (it->delete_me) return;
4375    if ((it->queued) || (!it->mincalcd))
4376      {
4377         it->wd->show_item = it;
4378         it->wd->bring_in = EINA_TRUE;
4379         it->showme = EINA_TRUE;
4380         return;
4381      }
4382    if (it->wd->show_item)
4383      {
4384         it->wd->show_item->showme = EINA_FALSE;
4385         it->wd->show_item = NULL;
4386      }
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);
4392 }
4393
4394 EAPI void
4395 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4396 {
4397    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4398    Evas_Coord ow, oh;
4399
4400    if (it->delete_me) return;
4401    if ((it->queued) || (!it->mincalcd))
4402      {
4403         it->wd->show_item = it;
4404         it->wd->bring_in = EINA_TRUE;
4405         it->showme = EINA_TRUE;
4406         return;
4407      }
4408    if (it->wd->show_item)
4409      {
4410         it->wd->show_item->showme = EINA_FALSE;
4411         it->wd->show_item = NULL;
4412      }
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,
4417                                       it->block->w, oh);
4418 }
4419
4420 EAPI void
4421 elm_genlist_item_del(Elm_Genlist_Item *it)
4422 {
4423    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4424    if ((it->relcount > 0) || (it->walking > 0))
4425      {
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;
4430         if (it->selected)
4431           it->wd->selected = eina_list_remove(it->wd->selected,
4432                                               it);
4433         if (it->block)
4434           {
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);
4439           }
4440         if (it->itc->func.del)
4441           it->itc->func.del((void *)it->base.data, it->base.widget);
4442         return;
4443      }
4444    _item_del(it);
4445 }
4446
4447 EAPI void
4448 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4449                           const void       *data)
4450 {
4451    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4452    elm_widget_item_data_set(it, data);
4453    elm_genlist_item_update(it);
4454 }
4455
4456 EAPI void *
4457 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4458 {
4459    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4460    return elm_widget_item_data_get(it);
4461 }
4462
4463 EAPI void
4464 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4465 {
4466    Evas_Object *icon;
4467    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4468    EINA_LIST_FREE(it->icon_objs, icon)
4469      {
4470         elm_widget_sub_object_del(it->base.widget, icon);
4471         evas_object_smart_member_del(icon);
4472         evas_object_hide(icon);
4473      }
4474 }
4475
4476 EAPI const Evas_Object *
4477 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4478 {
4479    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4480    return it->base.view;
4481 }
4482
4483 EAPI void
4484 elm_genlist_item_update(Elm_Genlist_Item *it)
4485 {
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);
4494 }
4495
4496 EAPI void
4497 elm_genlist_item_item_class_update(Elm_Genlist_Item             *it,
4498                                    const Elm_Genlist_Item_Class *itc)
4499 {
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;
4504    it->itc = itc;
4505    it->nocache = EINA_TRUE;
4506    elm_genlist_item_update(it);
4507 }
4508
4509 EAPI const Elm_Genlist_Item_Class *
4510 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4511 {
4512    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4513    if (it->delete_me) return NULL;
4514    return it->itc;
4515 }
4516 static Evas_Object *
4517 _elm_genlist_item_label_create(void        *data,
4518                                Evas_Object *obj,
4519                                void        *item __UNUSED__)
4520 {
4521    Evas_Object *label = elm_label_add(obj);
4522    if (!label)
4523      return NULL;
4524    elm_object_style_set(label, "tooltip");
4525    elm_object_text_set(label, data);
4526    return label;
4527 }
4528
4529 static void
4530 _elm_genlist_item_label_del_cb(void        *data,
4531                                Evas_Object *obj __UNUSED__,
4532                                void        *event_info __UNUSED__)
4533 {
4534    eina_stringshare_del(data);
4535 }
4536
4537 EAPI void
4538 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4539                                   const char       *text)
4540 {
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,
4544                                            text,
4545                                            _elm_genlist_item_label_del_cb);
4546 }
4547
4548 EAPI void
4549 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item           *item,
4550                                         Elm_Tooltip_Item_Content_Cb func,
4551                                         const void                 *data,
4552                                         Evas_Smart_Cb               del_cb)
4553 {
4554    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4555
4556    if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4557      return;
4558
4559    if (item->tooltip.del_cb)
4560      item->tooltip.del_cb((void *)item->tooltip.data,
4561                           item->base.widget, item);
4562
4563    item->tooltip.content_cb = func;
4564    item->tooltip.data = data;
4565    item->tooltip.del_cb = del_cb;
4566
4567    if (item->base.view)
4568      {
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);
4573      }
4574
4575    return;
4576
4577 error:
4578    if (del_cb) del_cb((void *)data, NULL, NULL);
4579 }
4580
4581 EAPI void
4582 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4583 {
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);
4587
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);
4595 }
4596
4597 EAPI void
4598 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4599                                    const char       *style)
4600 {
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);
4604 }
4605
4606 EAPI const char *
4607 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4608 {
4609    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4610    return item->tooltip.style;
4611 }
4612
4613 EAPI void
4614 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4615                             const char       *cursor)
4616 {
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);
4620 }
4621
4622 EAPI const char *
4623 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4624 {
4625    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4626    return elm_widget_item_cursor_get(item);
4627 }
4628
4629 EAPI void
4630 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4631 {
4632    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4633    if (!item->mouse_cursor)
4634      return;
4635
4636    if (item->base.view)
4637      elm_widget_item_cursor_unset(item);
4638
4639    eina_stringshare_del(item->mouse_cursor);
4640    item->mouse_cursor = NULL;
4641 }
4642
4643 EAPI void
4644 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4645                                   const char       *style)
4646 {
4647    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4648    elm_widget_item_cursor_style_set(item, style);
4649 }
4650
4651 EAPI const char *
4652 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4653 {
4654    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4655    return elm_widget_item_cursor_style_get(item);
4656 }
4657
4658 EAPI void
4659 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4660                                         Eina_Bool         engine_only)
4661 {
4662    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4663    elm_widget_item_cursor_engine_only_set(item, engine_only);
4664 }
4665
4666 EAPI Eina_Bool
4667 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4668 {
4669    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4670    return elm_widget_item_cursor_engine_only_get(item);
4671 }
4672
4673 EAPI void
4674 elm_genlist_horizontal_mode_set(Evas_Object  *obj,
4675                                 Elm_List_Mode mode)
4676 {
4677    ELM_CHECK_WIDTYPE(obj, widtype);
4678    Widget_Data *wd = elm_widget_data_get(obj);
4679    if (!wd) return;
4680    if (wd->mode == mode) return;
4681    wd->mode = mode;
4682    _sizing_eval(obj);
4683 }
4684
4685 EAPI Elm_List_Mode
4686 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4687 {
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;
4691    return wd->mode;
4692 }
4693
4694 EAPI void
4695 elm_genlist_always_select_mode_set(Evas_Object *obj,
4696                                    Eina_Bool    always_select)
4697 {
4698    ELM_CHECK_WIDTYPE(obj, widtype);
4699    Widget_Data *wd = elm_widget_data_get(obj);
4700    if (!wd) return;
4701    wd->always_select = always_select;
4702 }
4703
4704 EAPI Eina_Bool
4705 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4706 {
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;
4711 }
4712
4713 EAPI void
4714 elm_genlist_no_select_mode_set(Evas_Object *obj,
4715                                Eina_Bool    no_select)
4716 {
4717    ELM_CHECK_WIDTYPE(obj, widtype);
4718    Widget_Data *wd = elm_widget_data_get(obj);
4719    if (!wd) return;
4720    wd->no_select = no_select;
4721 }
4722
4723 EAPI Eina_Bool
4724 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4725 {
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;
4730 }
4731
4732 EAPI void
4733 elm_genlist_compress_mode_set(Evas_Object *obj,
4734                               Eina_Bool    compress)
4735 {
4736    ELM_CHECK_WIDTYPE(obj, widtype);
4737    Widget_Data *wd = elm_widget_data_get(obj);
4738    if (!wd) return;
4739    wd->compress = compress;
4740 }
4741
4742 EAPI Eina_Bool
4743 elm_genlist_compress_mode_get(const Evas_Object *obj)
4744 {
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;
4749 }
4750
4751 EAPI void
4752 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4753                                       Eina_Bool    height_for_width)
4754 {
4755    ELM_CHECK_WIDTYPE(obj, widtype);
4756    Widget_Data *wd = elm_widget_data_get(obj);
4757    if (!wd) return;
4758    wd->height_for_width = !!height_for_width;
4759    if (wd->height_for_width)
4760      {
4761         elm_genlist_homogeneous_set(obj, EINA_FALSE);
4762         elm_genlist_compress_mode_set(obj, EINA_TRUE);
4763      }
4764 }
4765
4766 EAPI Eina_Bool
4767 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4768 {
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;
4773 }
4774
4775 EAPI void
4776 elm_genlist_bounce_set(Evas_Object *obj,
4777                        Eina_Bool    h_bounce,
4778                        Eina_Bool    v_bounce)
4779 {
4780    ELM_CHECK_WIDTYPE(obj, widtype);
4781    Widget_Data *wd = elm_widget_data_get(obj);
4782    if (!wd) return;
4783    elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4784 }
4785
4786 EAPI void
4787 elm_genlist_bounce_get(const Evas_Object *obj,
4788                        Eina_Bool         *h_bounce,
4789                        Eina_Bool         *v_bounce)
4790 {
4791    ELM_CHECK_WIDTYPE(obj, widtype);
4792    Widget_Data *wd = elm_widget_data_get(obj);
4793    if (!wd) return;
4794    elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4795 }
4796
4797 EAPI void
4798 elm_genlist_homogeneous_set(Evas_Object *obj,
4799                             Eina_Bool    homogeneous)
4800 {
4801    ELM_CHECK_WIDTYPE(obj, widtype);
4802    Widget_Data *wd = elm_widget_data_get(obj);
4803    if (!wd) return;
4804    if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4805    wd->homogeneous = homogeneous;
4806 }
4807
4808 EAPI Eina_Bool
4809 elm_genlist_homogeneous_get(const Evas_Object *obj)
4810 {
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;
4815 }
4816
4817 EAPI void
4818 elm_genlist_block_count_set(Evas_Object *obj,
4819                             int          n)
4820 {
4821    ELM_CHECK_WIDTYPE(obj, widtype);
4822    Widget_Data *wd = elm_widget_data_get(obj);
4823    if (!wd) return;
4824    wd->max_items_per_block = n;
4825    wd->item_cache_max = wd->max_items_per_block * 2;
4826    _item_cache_clean(wd);
4827 }
4828
4829 EAPI int
4830 elm_genlist_block_count_get(const Evas_Object *obj)
4831 {
4832    ELM_CHECK_WIDTYPE(obj, widtype) 0;
4833    Widget_Data *wd = elm_widget_data_get(obj);
4834    if (!wd) return 0;
4835    return wd->max_items_per_block;
4836 }
4837
4838 EAPI void
4839 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4840                                   double       timeout)
4841 {
4842    ELM_CHECK_WIDTYPE(obj, widtype);
4843    Widget_Data *wd = elm_widget_data_get(obj);
4844    if (!wd) return;
4845    wd->longpress_timeout = timeout;
4846 }
4847
4848 EAPI double
4849 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4850 {
4851    ELM_CHECK_WIDTYPE(obj, widtype) 0;
4852    Widget_Data *wd = elm_widget_data_get(obj);
4853    if (!wd) return 0;
4854    return wd->longpress_timeout;
4855 }
4856
4857 EAPI void
4858 elm_genlist_scroller_policy_set(Evas_Object        *obj,
4859                                 Elm_Scroller_Policy policy_h,
4860                                 Elm_Scroller_Policy policy_v)
4861 {
4862    ELM_CHECK_WIDTYPE(obj, widtype);
4863    Widget_Data *wd = elm_widget_data_get(obj);
4864    if (!wd) return;
4865    if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4866        (policy_v >= ELM_SCROLLER_POLICY_LAST))
4867      return;
4868    if (wd->scr)
4869      elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4870 }
4871
4872 EAPI void
4873 elm_genlist_scroller_policy_get(const Evas_Object   *obj,
4874                                 Elm_Scroller_Policy *policy_h,
4875                                 Elm_Scroller_Policy *policy_v)
4876 {
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;
4884 }
4885
4886 EAPI void
4887 elm_genlist_realized_items_update(Evas_Object *obj)
4888 {
4889    ELM_CHECK_WIDTYPE(obj, widtype);
4890
4891    Eina_List *list, *l;
4892    Elm_Genlist_Item *it;
4893
4894    list = elm_genlist_realized_items_get(obj);
4895    EINA_LIST_FOREACH(list, l, it)
4896      elm_genlist_item_update(it);
4897 }
4898
4899 /**
4900  * Set genlist item mode
4901  *
4902  * @param item The genlist item
4903  * @param mode Mode name
4904  * @param mode_set Boolean to define set or unset mode.
4905  *
4906  * @ingroup Genlist
4907  */
4908 EAPI void
4909 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
4910                           const char       *mode_type,
4911                           Eina_Bool         mode_set)
4912 {
4913    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4914    Widget_Data *wd = it->wd;
4915    Eina_List *l;
4916    Elm_Genlist_Item *it2;
4917
4918    if (!wd) return;
4919    if (!mode_type) return;
4920    if ((it->delete_me) || (it->disabled)) return;
4921    if (wd->edit_mode) return;
4922
4923    if ((wd->mode_item == it) &&
4924        (!strcmp(mode_type, wd->mode_type)) &&
4925        (mode_set))
4926       return;
4927    if (!it->itc->mode_item_style) return;
4928
4929    if (wd->multi)
4930      {
4931         EINA_LIST_FOREACH(wd->selected, l, it2)
4932           if (it2->realized)
4933             elm_genlist_item_selected_set(it2, EINA_FALSE);
4934      }
4935    else
4936      {
4937         it2 = elm_genlist_selected_item_get(wd->obj);
4938         if ((it2) && (it2->realized))
4939           elm_genlist_item_selected_set(it2, EINA_FALSE);
4940      }
4941
4942    if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
4943        (mode_set) ||
4944        ((it == wd->mode_item) && (!mode_set)))
4945      _item_mode_unset(wd);
4946
4947    eina_stringshare_replace(&wd->mode_type, mode_type);
4948    if (mode_set) _item_mode_set(it);
4949 }
4950
4951 /**
4952  * Get active genlist mode type
4953  *
4954  * @param obj The genlist object
4955  *
4956  * @ingroup Genlist
4957  */
4958 EAPI const char *
4959 elm_genlist_mode_get(const Evas_Object *obj)
4960 {
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;
4965 }
4966
4967 /**
4968  * Get active genlist mode item
4969  *
4970  * @param obj The genlist object
4971  *
4972  * @ingroup Genlist
4973  */
4974 EAPI const Elm_Genlist_Item *
4975 elm_genlist_mode_item_get(const Evas_Object *obj)
4976 {
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;
4981 }
4982
4983 EAPI void
4984 elm_genlist_reorder_mode_set(Evas_Object *obj,
4985                              Eina_Bool    reorder_mode)
4986 {
4987    ELM_CHECK_WIDTYPE(obj, widtype);
4988    Widget_Data *wd = elm_widget_data_get(obj);
4989    if (!wd) return;
4990    wd->reorder_mode = reorder_mode;
4991 }
4992
4993 EAPI Eina_Bool
4994 elm_genlist_reorder_mode_get(const Evas_Object *obj)
4995 {
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;
5000 }
5001
5002 EAPI void
5003 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
5004 {
5005    return;
5006 }
5007
5008 EAPI void
5009 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
5010 {
5011    return;
5012 }
5013
5014 EAPI void
5015 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5016 {
5017    ELM_CHECK_WIDTYPE(obj, widtype);
5018    Widget_Data *wd = elm_widget_data_get(obj);
5019    if (!wd) return;
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);
5026 }
5027
5028 static Evas_Object*
5029 _create_tray_alpha_bg(const Evas_Object *obj)
5030 {
5031    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5032    Widget_Data *wd = elm_widget_data_get(obj);
5033    if (!wd) return NULL;
5034
5035    Evas_Object *bg = NULL;
5036    Evas_Coord ox, oy, ow, oh;
5037
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);
5045    return bg ;
5046 }
5047
5048 static unsigned int
5049 current_time_get()
5050 {
5051    struct timeval timev;
5052
5053    gettimeofday(&timev, NULL);
5054    return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5055 }
5056
5057 // added for item moving animation.
5058 static Eina_Bool
5059 _item_moving_effect_timer_cb(void *data)
5060 {
5061    Widget_Data *wd = data;
5062    if (!wd) return EINA_FALSE;
5063    Item_Block *itb;
5064    Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5065    Elm_Genlist_Item *it = NULL, *it2;
5066    const Eina_List *l;
5067    double time = 0.3, t;
5068    int y, dy;
5069    Eina_Bool check, end = EINA_FALSE;
5070    int in = 0;
5071
5072    t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5073
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;
5077
5078    it2 = elm_genlist_item_next_get(wd->expand_item);
5079    while (it2)
5080      {
5081         if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5082         it2 = elm_genlist_item_next_get(it2);
5083      }
5084    dy = 0;
5085    if (it2)
5086      {
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;
5091
5092         if (t <= time)
5093           {
5094              y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5095           }
5096         else
5097           {
5098              end = EINA_TRUE;
5099              y = dy;
5100           }
5101
5102         check = EINA_FALSE;
5103         EINA_INLIST_FOREACH(wd->blocks, itb)
5104           {
5105              itb->w = wd->minw;
5106              if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5107                                      itb->y - wd->pan_y + oy,
5108                                      itb->w, itb->h,
5109                                      cvx, cvy, cvw, cvh))
5110                {
5111                   EINA_LIST_FOREACH(itb->items, l, it)
5112                     {
5113                        if (it == it2) check = EINA_TRUE;
5114                        if (!check) continue;
5115
5116                        if (!it->old_scrl_y)
5117                          it->old_scrl_y  = it->scrl_y;
5118                        if (it->old_scrl_y + y < oy + oh)
5119                          {
5120                             if (!it->realized) _item_realize(it, in, 0);
5121                          }
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;
5124                        in++;
5125
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))
5128                          {
5129                             if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5130                             else
5131                               {
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);
5136                               }
5137
5138                             if (it->group_item) evas_object_raise(it->group_item->base.view);
5139                          }
5140                     }
5141                }
5142           }
5143
5144         if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5145           {
5146              it = elm_genlist_item_prev_get(it2);
5147              while (it)
5148                {
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))
5151                     {
5152                        if (!it->effect_done)
5153                          {
5154                             edje_object_signal_emit(it->base.view, "flip_item", "");
5155                             evas_object_show(it->base.view);
5156                             it->effect_done = EINA_TRUE;
5157                          }
5158                     }
5159                   it = elm_genlist_item_prev_get(it);
5160                }
5161           }
5162         else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5163           {
5164              it = elm_genlist_item_prev_get(it2);
5165              while (it)
5166                {
5167                   if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5168                     {
5169                        if (!it->effect_done)
5170                          {
5171                             edje_object_signal_emit(it->base.view, "elm,state,hide", "");
5172                             it->effect_done = EINA_TRUE;
5173                          }
5174                     }
5175                   else
5176                     break;
5177                   it = elm_genlist_item_prev_get(it);
5178                }
5179           }
5180      }
5181    else
5182      {
5183         int expand_num = 0;
5184         int expand_order = 0;
5185         if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5186         while (it)
5187           {
5188              expand_num++;
5189              it = elm_genlist_item_next_get(it);
5190           }
5191         if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5192         while (it)
5193           {
5194              expand_order++;
5195              if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
5196              if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5197                {
5198                   if (!it->effect_done)
5199                     {
5200                        if (t >= (((expand_order - 1) * time) / expand_num))
5201                          {
5202                             edje_object_signal_emit(it->base.view, "flip_item", "");
5203                             evas_object_show(it->base.view);
5204                             it->effect_done = EINA_TRUE;
5205                          }
5206                     }
5207                }
5208              it = elm_genlist_item_next_get(it);
5209           }
5210      }
5211
5212    if (end)
5213      {
5214         if (wd->item_moving_effect_timer)
5215           {
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)
5219                {
5220                   EINA_LIST_FOREACH(itb->items, l, it)
5221                     {
5222                        it->effect_done = EINA_TRUE;
5223                        it->old_scrl_y = it->scrl_y;
5224                     }
5225                }
5226           }
5227         wd->item_moving_effect_timer = NULL;
5228
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;
5236
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;
5240      }
5241    return ECORE_CALLBACK_RENEW;
5242 }
5243
5244 static void
5245 _emit_contract(Elm_Genlist_Item *it)
5246 {
5247    Elm_Genlist_Item *it2;
5248    Eina_List *l;
5249
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;
5253
5254    EINA_LIST_FOREACH(it->items, l, it2)
5255       if (it2)
5256          _emit_contract(it2);
5257 }
5258
5259 // added for item moving animation.
5260 static int
5261 _item_flip_effect_show(Elm_Genlist_Item *it)
5262 {
5263    Elm_Genlist_Item *it2;
5264    Eina_List *l;
5265    Widget_Data *wd = it->wd;
5266    Eina_Bool check = EINA_FALSE;
5267
5268    it2 = elm_genlist_item_next_get(it);
5269    while (it2)
5270      {
5271         if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5272         it2 = elm_genlist_item_next_get(it2);
5273      }
5274    EINA_LIST_FOREACH(it->items, l, it2)
5275      {
5276         if (it2->parent && it == it2->parent)
5277           {
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);
5282           }
5283      }
5284
5285    return ECORE_CALLBACK_CANCEL;
5286 }
5287
5288 /*
5289 static void
5290 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5291 {
5292    printf("!!! NOW FIXING \n");
5293 }
5294 */
5295
5296 /**
5297  * Set pinch zoom mode
5298  *
5299  * @param obj The genlist object
5300  * @param emode
5301  * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5302  *
5303  * @ingroup Genlist
5304  */
5305 EAPI void
5306 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5307 {
5308    printf("!!! NOW FIXING \n");
5309 }
5310
5311 /**
5312  * Get pinch zoom mode
5313  *
5314  * @param obj The genlist object
5315  * @return The pinch mode
5316  * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5317  *
5318  * @ingroup Genlist
5319  */
5320 EAPI Eina_Bool
5321 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
5322 {
5323    printf("!!! NOW FIXING \n");
5324    return EINA_FALSE;
5325 }
5326
5327 EAPI void
5328 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5329 {
5330    printf("!!! NOW FIXING \n");
5331 }
5332
5333
5334 ////////////////////////////////////////////////////////////////////////
5335 //  EDIT  MODE
5336 ////////////////////////////////////////////////////////////////////////
5337
5338 static void
5339 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5340 {
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);
5344 }
5345
5346 static void
5347 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5348 {
5349    if ((it->effect_item_realized) || (it->delete_me)) return;
5350    char buf[1024];
5351
5352    if (it->mode_view)
5353      _mode_finished_signal_cb(it, (Evas_Object *)elm_genlist_item_object_get(it), NULL, NULL);
5354
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);
5360
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));
5364
5365    strncat(buf, "/", sizeof(buf) - strlen(buf));
5366
5367    if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5368      {
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));
5371      }
5372    else
5373      {
5374         _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget));
5375      }
5376
5377    if (it->wd->reorder_mode)
5378      {
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");
5381      }
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");
5384
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");
5387
5388
5389    if ((it->wd->edit_mode))
5390      {
5391         if (it->itc->func.icon_get)
5392           {
5393              const Eina_List *l;
5394              const char *key;
5395
5396              it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5397              EINA_LIST_FOREACH(it->icons, l, key)
5398                {
5399                   Evas_Object *ic = it->itc->func.icon_get
5400                      ((void *)it->base.data, it->base.widget, l->data);
5401
5402                   if (ic)
5403                     {
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);
5408                        if (it->disabled)
5409                          elm_widget_disabled_set(ic, EINA_TRUE);
5410                     }
5411                }
5412           }
5413      }
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);
5417
5418    it->effect_item_realized = EINA_TRUE;
5419    it->want_unrealize = EINA_FALSE;
5420 }
5421
5422 static void
5423 _effect_item_unrealize(Elm_Genlist_Item *it)
5424 {
5425    Evas_Object *icon;
5426
5427    if (!it->effect_item_realized) return;
5428    if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5429
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);
5442
5443 //   edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5444    it->effect_item_realized = EINA_FALSE;
5445 }
5446
5447 /**
5448  * Get Genlist edit mode
5449  *
5450  * @param obj The genlist object
5451  * @return The edit mode status
5452  * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5453  *
5454  * @ingroup Genlist
5455  */
5456 EAPI Eina_Bool
5457 elm_genlist_edit_mode_get(const Evas_Object *obj)
5458 {
5459    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5460    Widget_Data *wd = elm_widget_data_get(obj);
5461    if (!wd) return EINA_FALSE;
5462
5463    if (wd->edit_mode) return EINA_TRUE;
5464    else return EINA_FALSE;
5465 }
5466
5467 /**
5468  * Set Genlist edit mode
5469  *
5470  * This sets Genlist edit mode.
5471  *
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)
5475  *
5476  * @ingroup Genlist
5477  */
5478 EAPI void
5479 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5480 {
5481    ELM_CHECK_WIDTYPE(obj, widtype);
5482
5483    Item_Block *itb;
5484    Eina_List *l;
5485    Elm_Genlist_Item *it;
5486
5487    Widget_Data *wd = elm_widget_data_get(obj);
5488    if (!wd) return;
5489    if (wd->edit_mode == edit_mode) return;
5490
5491    wd->edit_mode = edit_mode;
5492    if (!wd->edit_mode)
5493      {
5494         EINA_INLIST_FOREACH(wd->blocks, itb)
5495           {
5496              if (itb->realized)
5497                {
5498                   EINA_LIST_FOREACH(itb->items, l, it)
5499                     {
5500                        if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5501                          {
5502                             _effect_item_unrealize(it);
5503                          }
5504                     }
5505                }
5506           }
5507         _item_cache_zero(wd);
5508      }
5509    else
5510      {
5511
5512         EINA_INLIST_FOREACH(wd->blocks, itb)
5513           {
5514              if (itb->realized)
5515                {
5516                   EINA_LIST_FOREACH(itb->items, l, it)
5517                     {
5518                        if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5519                          {
5520                             if(it->selected) _item_unselect(it);
5521                             if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
5522                          }
5523                     }
5524                 }
5525            }
5526       }
5527
5528    if (wd->calc_job) ecore_job_del(wd->calc_job);
5529    wd->calc_job = ecore_job_add(_calc_job, wd);
5530 }
5531
5532 /**
5533  * Set a given item's rename mode
5534  *
5535  * This renames the item's label from genlist
5536  *
5537  * @param it The item
5538  * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
5539  *
5540  * @ingroup Genlist
5541  */
5542 EAPI void
5543 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
5544 {
5545    if (!it) return;
5546
5547    if (renamed)
5548      {
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);
5554
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);
5557      }
5558    else
5559      {
5560         if (it->renamed)
5561           {
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);
5567           }
5568      }
5569 }
5570
5571 EAPI Eina_Bool
5572 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
5573 {
5574    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5575    return item->renamed;
5576 }
5577
5578 static void
5579 _item_auto_scroll(void *data)
5580 {
5581    Widget_Data *wd = data;
5582    if (!wd) return;
5583
5584    if ((wd->expand_item) && (!wd->auto_scrolled))
5585      {
5586         Elm_Genlist_Item  *it;
5587         Eina_List *l;
5588         Evas_Coord ox, oy, ow, oh;
5589         evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
5590
5591         wd->auto_scrolled = EINA_TRUE;
5592         if (wd->expand_item->scrl_y > (oh + oy) / 2)
5593           {
5594             EINA_LIST_FOREACH(wd->expand_item->items, l, it)
5595               {
5596                  elm_genlist_item_bring_in(it);
5597               }
5598           }
5599      }
5600 }