Merge "[Refactoring] Removed calendar/colorpalette/datefield/icon/multibuttonentry...
[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, 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    const char       *mode_type;
39    unsigned int      start_time;
40    Evas_Coord        prev_x, prev_y, prev_mx, prev_my;
41    Evas_Coord        cur_x, cur_y, cur_mx, cur_my;
42    Eina_Bool         mouse_down : 1;
43    Eina_Bool         multi_down : 1;
44    Eina_Bool         multi_timeout : 1;
45    Eina_Bool         multitouched : 1;
46    Eina_Bool         on_hold : 1;
47    Eina_Bool         multi : 1;
48    Eina_Bool         always_select : 1;
49    Eina_Bool         longpressed : 1;
50    Eina_Bool         wasselected : 1;
51    Eina_Bool         no_select : 1;
52    Eina_Bool         bring_in : 1;
53    Eina_Bool         compress : 1;
54    Eina_Bool         height_for_width : 1;
55    Eina_Bool         homogeneous : 1;
56    Eina_Bool         clear_me : 1;
57    Eina_Bool         swipe : 1;
58    Eina_Bool         reorder_mode : 1;
59    Eina_Bool         reorder_pan_move : 1;
60    Eina_List        *dragging_queue;
61    struct
62    {
63       Evas_Coord x, y;
64    } history[SWIPE_MOVES];
65    int               multi_device;
66    int               item_cache_count;
67    int               item_cache_max;
68    int               movements;
69    int               walking;
70    int               item_width;
71    int               item_height;
72    int               group_item_width;
73    int               group_item_height;
74    int               max_items_per_block;
75    double            longpress_timeout;
76
77    // TODO : refactoring
78    Eina_Bool         reorder_deleted : 1;
79    Eina_Bool         effect_mode : 1;
80    Eina_Bool         auto_scrolled : 1;
81    int               edit_mode;
82    Ecore_Animator   *item_moving_effect_timer;
83    Evas_Object      *alpha_bg;
84    Evas_Coord        expand_item_end;
85    Evas_Coord        expand_item_gap;
86    int               move_effect_mode;
87    Ecore_Job        *changed_job;
88    Elm_Genlist_Item *rename_it;
89 };
90
91 struct _Item_Block
92 {
93    EINA_INLIST;
94    int          count;
95    int          num;
96    int          reorder_offset;
97    Widget_Data *wd;
98    Eina_List   *items;
99    Evas_Coord   x, y, w, h, minw, minh;
100    Eina_Bool    want_unrealize : 1;
101    Eina_Bool    realized : 1;
102    Eina_Bool    changed : 1;
103    Eina_Bool    updateme : 1;
104    Eina_Bool    changeme : 1;
105    Eina_Bool    showme : 1;
106    Eina_Bool    must_recalc : 1;
107 };
108
109 struct _Elm_Genlist_Item
110 {
111    Elm_Widget_Item               base;
112    EINA_INLIST;
113    Widget_Data                  *wd;
114    Item_Block                   *block;
115    Eina_List                    *items;
116    Evas_Coord                    x, y, w, h, minw, minh;
117    const Elm_Genlist_Item_Class *itc;
118    Elm_Genlist_Item             *parent;
119    Elm_Genlist_Item             *group_item;
120    Elm_Genlist_Item_Flags        flags;
121    struct
122    {
123       Evas_Smart_Cb func;
124       const void   *data;
125    } func;
126
127    Evas_Object                  *spacer;
128    Eina_List                    *labels, *icons, *states, *icon_objs;
129    Eina_List                    *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
130    Ecore_Timer                  *long_timer;
131    Ecore_Timer                  *swipe_timer;
132    Evas_Coord                    dx, dy;
133    Evas_Coord                    scrl_x, scrl_y;
134
135    Elm_Genlist_Item             *rel;
136    Evas_Object                  *mode_view;
137
138    struct
139    {
140       const void                 *data;
141       Elm_Tooltip_Item_Content_Cb content_cb;
142       Evas_Smart_Cb               del_cb;
143       const char                 *style;
144    } tooltip;
145
146    const char                   *mouse_cursor;
147
148    int                           relcount;
149    int                           walking;
150    int                           expanded_depth;
151    int                           order_num_in;
152
153    Eina_Bool                     before : 1;
154
155    Eina_Bool                     want_unrealize : 1;
156    Eina_Bool                     want_realize : 1;
157    Eina_Bool                     realized : 1;
158    Eina_Bool                     selected : 1;
159    Eina_Bool                     highlighted : 1;
160    Eina_Bool                     expanded : 1;
161    Eina_Bool                     disabled : 1;
162    Eina_Bool                     display_only : 1;
163    Eina_Bool                     mincalcd : 1;
164    Eina_Bool                     queued : 1;
165    Eina_Bool                     showme : 1;
166    Eina_Bool                     delete_me : 1;
167    Eina_Bool                     down : 1;
168    Eina_Bool                     dragging : 1;
169    Eina_Bool                     updateme : 1;
170    Eina_Bool                     nocache : 1;
171
172    // TODO: refactoring
173    Eina_Bool   move_effect_me : 1;
174    Eina_Bool   effect_done : 1;
175    Eina_Bool   reordering : 1;
176    Eina_Bool   renamed : 1;
177    Eina_Bool   effect_item_realized : 1;
178    Eina_List  *edit_icon_objs;
179    Evas_Object *edit_obj;
180    int         num;
181    Ecore_Animator *item_moving_effect_timer;
182    Evas_Coord  old_scrl_y;
183 };
184
185 struct _Item_Cache
186 {
187    EINA_INLIST;
188
189    Evas_Object *base_view, *spacer;
190
191    const char  *item_style; // it->itc->item_style
192    Eina_Bool    tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
193    Eina_Bool    compress : 1; // it->wd->compress
194    Eina_Bool    odd : 1; // in & 0x1
195
196    Eina_Bool    selected : 1; // it->selected
197    Eina_Bool    disabled : 1; // it->disabled
198    Eina_Bool    expanded : 1; // it->expanded
199 };
200
201 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
202   ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
203
204 struct _Pan
205 {
206    Evas_Object_Smart_Clipped_Data __clipped_data;
207    Widget_Data                   *wd;
208    Ecore_Job                     *resize_job;
209 };
210
211 static const char *widtype = NULL;
212 static void      _item_cache_zero(Widget_Data *wd);
213 static void      _del_hook(Evas_Object *obj);
214 static void      _mirrored_set(Evas_Object *obj,
215                                Eina_Bool    rtl);
216 static void      _theme_hook(Evas_Object *obj);
217 static void      _show_region_hook(void        *data,
218                                    Evas_Object *obj);
219 static void      _sizing_eval(Evas_Object *obj);
220 static void      _item_realize(Elm_Genlist_Item *it,
221                                int               in,
222                                Eina_Bool         calc);
223 static void      _item_unrealize(Elm_Genlist_Item *it,
224                                  Eina_Bool         calc);
225 static void      _item_block_unrealize(Item_Block *itb);
226 static void      _calc_job(void *data);
227 static void      _on_focus_hook(void        *data,
228                                 Evas_Object *obj);
229 static void      _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
230 static void      _changed_job(void *data);
231 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
232 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
233 static Eina_Bool _item_single_select_up(Widget_Data *wd);
234 static Eina_Bool _item_single_select_down(Widget_Data *wd);
235 static Eina_Bool _event_hook(Evas_Object       *obj,
236                              Evas_Object       *src,
237                              Evas_Callback_Type type,
238                              void              *event_info);
239 static void      _signal_emit_hook(Evas_Object *obj,
240                                    const char *emission,
241                                    const char *source);
242 static Eina_Bool _deselect_all_items(Widget_Data *wd);
243 static void      _pan_calculate(Evas_Object *obj);
244 static void      _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
245 static void      _mode_item_realize(Elm_Genlist_Item *it);
246 static void      _mode_item_unrealize(Elm_Genlist_Item *it);
247 static void      _item_mode_set(Elm_Genlist_Item *it);
248 static void      _item_mode_unset(Widget_Data *wd);
249 static void      _group_items_recalc(void *data);
250
251 // TODO : refactoring
252 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
253 static unsigned int current_time_get();
254 static Eina_Bool _item_moving_effect_timer_cb(void *data);
255 static int _item_flip_effect_show(Elm_Genlist_Item *it);
256 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
257 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
258 static void _effect_item_unrealize(Elm_Genlist_Item *it);
259 static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after);
260 static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before);
261 static void _item_auto_scroll(void *data);
262
263 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
264
265 static const char SIG_ACTIVATED[] = "activated";
266 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
267 static const char SIG_SELECTED[] = "selected";
268 static const char SIG_UNSELECTED[] = "unselected";
269 static const char SIG_EXPANDED[] = "expanded";
270 static const char SIG_CONTRACTED[] = "contracted";
271 static const char SIG_EXPAND_REQUEST[] = "expand,request";
272 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
273 static const char SIG_REALIZED[] = "realized";
274 static const char SIG_UNREALIZED[] = "unrealized";
275 static const char SIG_DRAG_START_UP[] = "drag,start,up";
276 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
277 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
278 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
279 static const char SIG_DRAG_STOP[] = "drag,stop";
280 static const char SIG_DRAG[] = "drag";
281 static const char SIG_LONGPRESSED[] = "longpressed";
282 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
283 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
284 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
285 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
286 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
287 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
288 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
289 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
290 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
291 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
292 static const char SIG_SWIPE[] = "swipe";
293
294 static const Evas_Smart_Cb_Description _signals[] = {
295    {SIG_CLICKED_DOUBLE, ""},
296    {SIG_ACTIVATED, ""},
297    {SIG_SELECTED, ""},
298    {SIG_UNSELECTED, ""},
299    {SIG_EXPANDED, ""},
300    {SIG_CONTRACTED, ""},
301    {SIG_EXPAND_REQUEST, ""},
302    {SIG_CONTRACT_REQUEST, ""},
303    {SIG_REALIZED, ""},
304    {SIG_UNREALIZED, ""},
305    {SIG_DRAG_START_UP, ""},
306    {SIG_DRAG_START_DOWN, ""},
307    {SIG_DRAG_START_LEFT, ""},
308    {SIG_DRAG_START_RIGHT, ""},
309    {SIG_DRAG_STOP, ""},
310    {SIG_DRAG, ""},
311    {SIG_LONGPRESSED, ""},
312    {SIG_SCROLL_EDGE_TOP, ""},
313    {SIG_SCROLL_EDGE_BOTTOM, ""},
314    {SIG_SCROLL_EDGE_LEFT, ""},
315    {SIG_SCROLL_EDGE_RIGHT, ""},
316    {SIG_MULTI_SWIPE_LEFT, ""},
317    {SIG_MULTI_SWIPE_RIGHT, ""},
318    {SIG_MULTI_SWIPE_UP, ""},
319    {SIG_MULTI_SWIPE_DOWN, ""},
320    {SIG_MULTI_PINCH_OUT, ""},
321    {SIG_MULTI_PINCH_IN, ""},
322    {SIG_SWIPE, ""},
323    {NULL, NULL}
324 };
325
326 static Eina_Bool
327 _event_hook(Evas_Object       *obj,
328             Evas_Object       *src __UNUSED__,
329             Evas_Callback_Type type,
330             void              *event_info)
331 {
332    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
333    Evas_Event_Key_Down *ev = event_info;
334    Widget_Data *wd = elm_widget_data_get(obj);
335    if (!wd) return EINA_FALSE;
336    if (!wd->items) return EINA_FALSE;
337    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
338    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
339
340    Elm_Genlist_Item *it = NULL;
341    Evas_Coord x = 0;
342    Evas_Coord y = 0;
343    Evas_Coord step_x = 0;
344    Evas_Coord step_y = 0;
345    Evas_Coord v_w = 0;
346    Evas_Coord v_h = 0;
347    Evas_Coord page_x = 0;
348    Evas_Coord page_y = 0;
349
350    elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
351    elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
352    elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
353    elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
354
355    if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
356      {
357         x -= step_x;
358      }
359    else if ((!strcmp(ev->keyname, "Right")) ||
360             (!strcmp(ev->keyname, "KP_Right")))
361      {
362         x += step_x;
363      }
364    else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
365      {
366         if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
367              (_item_multi_select_up(wd)))
368             || (_item_single_select_up(wd)))
369           {
370              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
371              return EINA_TRUE;
372           }
373         else
374           y -= step_y;
375      }
376    else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
377      {
378         if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
379              (_item_multi_select_down(wd)))
380             || (_item_single_select_down(wd)))
381           {
382              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
383              return EINA_TRUE;
384           }
385         else
386           y += step_y;
387      }
388    else if ((!strcmp(ev->keyname, "Home")) ||
389             (!strcmp(ev->keyname, "KP_Home")))
390      {
391         it = elm_genlist_first_item_get(obj);
392         elm_genlist_item_bring_in(it);
393         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
394         return EINA_TRUE;
395      }
396    else if ((!strcmp(ev->keyname, "End")) ||
397             (!strcmp(ev->keyname, "KP_End")))
398      {
399         it = elm_genlist_last_item_get(obj);
400         elm_genlist_item_bring_in(it);
401         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
402         return EINA_TRUE;
403      }
404    else if ((!strcmp(ev->keyname, "Prior")) ||
405             (!strcmp(ev->keyname, "KP_Prior")))
406      {
407         if (page_y < 0)
408           y -= -(page_y * v_h) / 100;
409         else
410           y -= page_y;
411      }
412    else if ((!strcmp(ev->keyname, "Next")) ||
413             (!strcmp(ev->keyname, "KP_Next")))
414      {
415         if (page_y < 0)
416           y += -(page_y * v_h) / 100;
417         else
418           y += page_y;
419      }
420    else if (((!strcmp(ev->keyname, "Return")) ||
421             (!strcmp(ev->keyname, "KP_Enter")) ||
422             (!strcmp(ev->keyname, "space")))
423            && (!wd->multi) && (wd->selected))
424      {
425         it = elm_genlist_selected_item_get(obj);
426         elm_genlist_item_expanded_set(it,
427                                       !elm_genlist_item_expanded_get(it));
428         evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
429      }
430    else if (!strcmp(ev->keyname, "Escape"))
431      {
432         if (!_deselect_all_items(wd)) return EINA_FALSE;
433         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
434         return EINA_TRUE;
435      }
436    else return EINA_FALSE;
437
438    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
439    elm_smart_scroller_child_pos_set(wd->scr, x, y);
440    return EINA_TRUE;
441 }
442
443 static Eina_Bool
444 _deselect_all_items(Widget_Data *wd)
445 {
446    if (!wd->selected) return EINA_FALSE;
447    while (wd->selected)
448      elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
449
450    return EINA_TRUE;
451 }
452
453 static Eina_Bool
454 _item_multi_select_up(Widget_Data *wd)
455 {
456    if (!wd->selected) return EINA_FALSE;
457    if (!wd->multi) return EINA_FALSE;
458
459    Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
460    if (!prev) return EINA_TRUE;
461
462    if (elm_genlist_item_selected_get(prev))
463      {
464         elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
465         wd->last_selected_item = prev;
466         elm_genlist_item_show(wd->last_selected_item);
467      }
468    else
469      {
470         elm_genlist_item_selected_set(prev, EINA_TRUE);
471         elm_genlist_item_show(prev);
472      }
473    return EINA_TRUE;
474 }
475
476 static Eina_Bool
477 _item_multi_select_down(Widget_Data *wd)
478 {
479    if (!wd->selected) return EINA_FALSE;
480    if (!wd->multi) return EINA_FALSE;
481
482    Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
483    if (!next) return EINA_TRUE;
484
485    if (elm_genlist_item_selected_get(next))
486      {
487         elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
488         wd->last_selected_item = next;
489         elm_genlist_item_show(wd->last_selected_item);
490      }
491    else
492      {
493         elm_genlist_item_selected_set(next, EINA_TRUE);
494         elm_genlist_item_show(next);
495      }
496    return EINA_TRUE;
497 }
498
499 static Eina_Bool
500 _item_single_select_up(Widget_Data *wd)
501 {
502    Elm_Genlist_Item *prev;
503    if (!wd->selected)
504      {
505         prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
506         while ((prev) && (prev->delete_me))
507           prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
508      }
509    else prev = elm_genlist_item_prev_get(wd->last_selected_item);
510
511    if (!prev) return EINA_FALSE;
512
513    _deselect_all_items(wd);
514
515    elm_genlist_item_selected_set(prev, EINA_TRUE);
516    elm_genlist_item_show(prev);
517    return EINA_TRUE;
518 }
519
520 static Eina_Bool
521 _item_single_select_down(Widget_Data *wd)
522 {
523    Elm_Genlist_Item *next;
524    if (!wd->selected)
525      {
526         next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
527         while ((next) && (next->delete_me))
528           next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
529      }
530    else next = elm_genlist_item_next_get(wd->last_selected_item);
531
532    if (!next) return EINA_FALSE;
533
534    _deselect_all_items(wd);
535
536    elm_genlist_item_selected_set(next, EINA_TRUE);
537    elm_genlist_item_show(next);
538    return EINA_TRUE;
539 }
540
541 static void
542 _on_focus_hook(void        *data __UNUSED__,
543                Evas_Object *obj)
544 {
545    Widget_Data *wd = elm_widget_data_get(obj);
546    if (!wd) return;
547    if (elm_widget_focus_get(obj))
548      {
549         elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
550         evas_object_focus_set(wd->obj, EINA_TRUE);
551         if ((wd->selected) && (!wd->last_selected_item))
552           wd->last_selected_item = eina_list_data_get(wd->selected);
553      }
554    else
555      {
556         elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
557         evas_object_focus_set(wd->obj, EINA_FALSE);
558      }
559 }
560
561 static void
562 _del_hook(Evas_Object *obj)
563 {
564    Widget_Data *wd = elm_widget_data_get(obj);
565    if (!wd) return;
566    _item_cache_zero(wd);
567    if (wd->calc_job) ecore_job_del(wd->calc_job);
568    if (wd->update_job) ecore_job_del(wd->update_job);
569    if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
570    if (wd->changed_job) ecore_job_del(wd->changed_job);
571    if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
572    if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
573    if (wd->mode_type) eina_stringshare_del(wd->mode_type);
574    if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
575    if (wd->walking > 0)
576      {
577         wd->walking = 0;
578         elm_genlist_clear(obj);
579      }
580    free(wd);
581 }
582
583 static void
584 _del_pre_hook(Evas_Object *obj)
585 {
586    Widget_Data *wd = elm_widget_data_get(obj);
587    if (!wd) return;
588    if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
589    evas_object_del(wd->pan_smart);
590    wd->pan_smart = NULL;
591    elm_genlist_clear(obj);
592 }
593
594 static void
595 _mirrored_set(Evas_Object *obj,
596               Eina_Bool    rtl)
597 {
598    Widget_Data *wd = elm_widget_data_get(obj);
599    if (!wd) return;
600    _item_cache_zero(wd);
601    elm_smart_scroller_mirrored_set(wd->scr, rtl);
602 }
603
604 static void
605 _theme_hook(Evas_Object *obj)
606 {
607    Widget_Data *wd = elm_widget_data_get(obj);
608    Item_Block *itb;
609    if (!wd) return;
610    evas_event_freeze(evas_object_evas_get(wd->obj));
611    _item_cache_zero(wd);
612    _elm_widget_mirrored_reload(obj);
613    _mirrored_set(obj, elm_widget_mirrored_get(obj));
614    elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
615                                        elm_widget_style_get(obj));
616    //   edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
617    wd->item_width = wd->item_height = 0;
618    wd->group_item_width = wd->group_item_height = 0;
619    wd->minw = wd->minh = wd->realminw = 0;
620    EINA_INLIST_FOREACH(wd->blocks, itb)
621      {
622         Eina_List *l;
623         Elm_Genlist_Item *it;
624
625         if (itb->realized) _item_block_unrealize(itb);
626         EINA_LIST_FOREACH(itb->items, l, it)
627           it->mincalcd = EINA_FALSE;
628
629         itb->changed = EINA_TRUE;
630      }
631    if (wd->calc_job) ecore_job_del(wd->calc_job);
632    wd->calc_job = ecore_job_add(_calc_job, wd);
633    _sizing_eval(obj);
634    evas_event_thaw(evas_object_evas_get(wd->obj));
635    evas_event_thaw_eval(evas_object_evas_get(wd->obj));
636 }
637
638 static void
639 _show_region_hook(void        *data,
640                   Evas_Object *obj)
641 {
642    Widget_Data *wd = elm_widget_data_get(data);
643    Evas_Coord x, y, w, h;
644    if (!wd) return;
645    elm_widget_show_region_get(obj, &x, &y, &w, &h);
646    //x & y are screen coordinates, Add with pan coordinates
647    x += wd->pan_x;
648    y += wd->pan_y;
649    elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
650 }
651
652 static void
653 _sizing_eval(Evas_Object *obj)
654 {
655    Widget_Data *wd = elm_widget_data_get(obj);
656    Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
657    if (!wd) return;
658    evas_object_size_hint_min_get(wd->scr, &minw, &minh);
659    evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
660    minh = -1;
661    if (wd->height_for_width)
662      {
663         Evas_Coord vw, vh;
664
665         elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
666         if ((vw != 0) && (vw != wd->prev_viewport_w))
667           {
668              Item_Block *itb;
669
670              wd->prev_viewport_w = vw;
671              EINA_INLIST_FOREACH(wd->blocks, itb)
672                {
673                   itb->must_recalc = EINA_TRUE;
674                }
675              if (wd->calc_job) ecore_job_del(wd->calc_job);
676              wd->calc_job = ecore_job_add(_calc_job, wd);
677           }
678      }
679    if (wd->mode == ELM_LIST_LIMIT)
680      {
681         Evas_Coord vmw, vmh, vw, vh;
682
683         minw = wd->realminw;
684         maxw = -1;
685         elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
686         if ((minw > 0) && (vw < minw)) vw = minw;
687         else if ((maxw > 0) && (vw > maxw))
688           vw = maxw;
689         edje_object_size_min_calc
690           (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
691         minw = vmw + minw;
692      }
693    else
694      {
695         Evas_Coord vmw, vmh;
696
697         edje_object_size_min_calc
698           (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
699         minw = vmw;
700         minh = vmh;
701      }
702    evas_object_size_hint_min_set(obj, minw, minh);
703    evas_object_size_hint_max_set(obj, maxw, maxh);
704 }
705
706 static void
707 _signal_emit_hook(Evas_Object *obj,
708                   const char  *emission,
709                   const char  *source)
710 {
711    Widget_Data *wd = elm_widget_data_get(obj);
712    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
713                            emission, source);
714 }
715
716 static void
717 _item_highlight(Elm_Genlist_Item *it)
718 {
719    const char *selectraise;
720    if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
721        (it->disabled) || (it->display_only) || (it->mode_view))
722      return;
723    edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
724    if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,selected", "elm");
725    selectraise = edje_object_data_get(it->base.view, "selectraise");
726    if ((selectraise) && (!strcmp(selectraise, "on")))
727      {
728         if (it->edit_obj) evas_object_raise(it->edit_obj);
729         else evas_object_raise(it->base.view);
730         if ((it->group_item) && (it->group_item->realized))
731           evas_object_raise(it->group_item->base.view);
732      }
733    it->highlighted = EINA_TRUE;
734 }
735
736 static void
737 _item_block_del(Elm_Genlist_Item *it)
738 {
739    Eina_Inlist *il;
740    Item_Block *itb = it->block;
741
742    itb->items = eina_list_remove(itb->items, it);
743    itb->count--;
744    itb->changed = EINA_TRUE;
745    if (!it->wd->reorder_deleted)
746      {
747         if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
748         it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
749      }
750    if (itb->count < 1)
751      {
752         il = EINA_INLIST_GET(itb);
753         Item_Block *itbn = (Item_Block *)(il->next);
754         if (it->parent)
755           it->parent->items = eina_list_remove(it->parent->items, it);
756         else
757           it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
758         free(itb);
759         if (itbn) itbn->changed = EINA_TRUE;
760      }
761    else
762      {
763         if (itb->count < itb->wd->max_items_per_block/2)
764           {
765              il = EINA_INLIST_GET(itb);
766              Item_Block *itbp = (Item_Block *)(il->prev);
767              Item_Block *itbn = (Item_Block *)(il->next);
768              if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
769                {
770                   Elm_Genlist_Item *it2;
771
772                   EINA_LIST_FREE(itb->items, it2)
773                     {
774                        it2->block = itbp;
775                        itbp->items = eina_list_append(itbp->items, it2);
776                        itbp->count++;
777                        itbp->changed = EINA_TRUE;
778                     }
779                   it->wd->blocks = eina_inlist_remove(it->wd->blocks,
780                                                       EINA_INLIST_GET(itb));
781                   free(itb);
782                }
783              else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
784                {
785                   while (itb->items)
786                     {
787                        Eina_List *last = eina_list_last(itb->items);
788                        Elm_Genlist_Item *it2 = last->data;
789
790                        it2->block = itbn;
791                        itb->items = eina_list_remove_list(itb->items, last);
792                        itbn->items = eina_list_prepend(itbn->items, it2);
793                        itbn->count++;
794                        itbn->changed = EINA_TRUE;
795                     }
796                   it->wd->blocks =
797                     eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
798                   free(itb);
799                }
800           }
801      }
802 }
803
804 static void
805 _item_subitems_clear(Elm_Genlist_Item *it)
806 {
807    if (!it) return;
808    Eina_List *tl = NULL, *l;
809    Elm_Genlist_Item *it2;
810
811    EINA_LIST_FOREACH(it->items, l, it2)
812       tl = eina_list_append(tl, it2);
813
814    EINA_LIST_FREE(tl, it2)
815      elm_genlist_item_del(it2);
816 }
817
818 static void
819 _item_del(Elm_Genlist_Item *it)
820 {
821    Evas_Object *tob = it->wd->obj;
822
823    evas_event_freeze(evas_object_evas_get(tob));
824    elm_widget_item_pre_notify_del(it);
825    elm_genlist_item_subitems_clear(it);
826    it->wd->walking -= it->walking;
827    if (it->wd->show_item == it) it->wd->show_item = NULL;
828    if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
829    if (it->realized) _item_unrealize(it, EINA_FALSE);
830    if (it->effect_item_realized) _effect_item_unrealize(it);
831    if (it->block) _item_block_del(it);
832    if ((!it->delete_me) && (it->itc->func.del))
833      it->itc->func.del((void *)it->base.data, it->base.widget);
834    it->delete_me = EINA_TRUE;
835    if (it->queued)
836      it->wd->queue = eina_list_remove(it->wd->queue, it);
837 #ifdef ANCHOR_ITEM
838    if (it->wd->anchor_item == it)
839      {
840         it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
841         if (!it->wd->anchor_item)
842           it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
843      }
844 #endif
845    it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
846    if (it->parent)
847      it->parent->items = eina_list_remove(it->parent->items, it);
848    if (it->flags & ELM_GENLIST_ITEM_GROUP)
849      it->wd->group_items = eina_list_remove(it->wd->group_items, it);
850    if (it->long_timer) ecore_timer_del(it->long_timer);
851    if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
852
853    if (it->tooltip.del_cb)
854      it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
855
856    evas_event_thaw(evas_object_evas_get(tob));
857    evas_event_thaw_eval(evas_object_evas_get(tob));
858
859    elm_widget_item_del(it);
860 }
861
862 static void
863 _item_select(Elm_Genlist_Item *it)
864 {
865    if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
866    if (it->selected)
867      {
868         if (it->wd->always_select) goto call;
869         return;
870      }
871    it->selected = EINA_TRUE;
872    it->wd->selected = eina_list_append(it->wd->selected, it);
873 call:
874    it->walking++;
875    it->wd->walking++;
876    if (it->func.func)
877      {
878         Evas_Object *baseobj = it->base.widget;
879         const char *objtype = NULL;
880         it->func.func((void *)it->func.data, it->base.widget, it);
881         objtype = evas_object_type_get(baseobj);
882         if ((!objtype) || (!strcmp(objtype,""))) return;
883      }
884    if (!it->delete_me)
885      evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
886    it->walking--;
887    it->wd->walking--;
888    if ((it->wd->clear_me) && (!it->wd->walking))
889      {
890         elm_genlist_clear(it->base.widget);
891         return;
892      }
893    else
894      {
895         if ((!it->walking) && (it->delete_me))
896           {
897              if (!it->relcount) _item_del(it);
898           }
899      }
900    if (it && it->wd) it->wd->last_selected_item = it; // TODO: Remove 'if'?
901 }
902
903 static void
904 _item_unselect(Elm_Genlist_Item *it)
905 {
906    const char *stacking, *selectraise;
907
908    if ((it->delete_me) || (!it->highlighted)) return;
909    edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
910    if (it->edit_obj) edje_object_signal_emit(it->edit_obj, "elm,state,unselected", "elm");
911    stacking = edje_object_data_get(it->base.view, "stacking");
912    selectraise = edje_object_data_get(it->base.view, "selectraise");
913    if ((selectraise) && (!strcmp(selectraise, "on")))
914      {
915         if ((stacking) && (!strcmp(stacking, "below")))
916           evas_object_lower(it->base.view);
917      }
918    it->highlighted = EINA_FALSE;
919    if (it->selected)
920      {
921         it->selected = EINA_FALSE;
922         it->wd->selected = eina_list_remove(it->wd->selected, it);
923         evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
924      }
925 }
926
927 static void
928 _mouse_move(void        *data,
929             Evas        *evas __UNUSED__,
930             Evas_Object *obj,
931             void        *event_info)
932 {
933    Elm_Genlist_Item *it = data;
934    Evas_Event_Mouse_Move *ev = event_info;
935    Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
936
937    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
938      {
939         if (!it->wd->on_hold)
940           {
941              it->wd->on_hold = EINA_TRUE;
942              if (!it->wd->wasselected)
943                _item_unselect(it);
944           }
945      }
946    if (it->wd->multitouched)
947      {
948         it->wd->cur_x = ev->cur.canvas.x;
949         it->wd->cur_y = ev->cur.canvas.y;
950         return;
951      }
952    if ((it->dragging) && (it->down))
953      {
954         if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
955         else
956           {
957              it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
958              it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
959              if (abs((it->wd->history[it->wd->movements].x -
960                       it->wd->history[0].x)) > 40)
961                it->wd->swipe = EINA_TRUE;
962              else
963                it->wd->movements++;
964           }
965         if (it->long_timer)
966           {
967              ecore_timer_del(it->long_timer);
968              it->long_timer = NULL;
969           }
970         evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
971         return;
972      }
973    if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
974      {
975         if (it->long_timer)
976           {
977              ecore_timer_del(it->long_timer);
978              it->long_timer = NULL;
979           }
980         if ((it->wd->reorder_mode) && (it->wd->reorder_it))
981           {
982              Evas_Coord ox,oy,oh,ow;
983              evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
984              int it_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
985              if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y;
986
987              if (it_y < oy) _effect_item_controls(it, it->scrl_x, oy);
988              else if (it_y + it->wd->reorder_it->h > oy+oh) _effect_item_controls(it, it->scrl_x, oy + oh - it->wd->reorder_it->h);
989              else _effect_item_controls(it, it->scrl_x, it_y);
990
991              if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
992              it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
993           }
994         return;
995      }
996    if (!it->display_only)
997      elm_coords_finger_size_adjust(1, &minw, 1, &minh);
998    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
999    x = ev->cur.canvas.x - x;
1000    y = ev->cur.canvas.y - y;
1001    dx = x - it->dx;
1002    adx = dx;
1003    if (adx < 0) adx = -dx;
1004    dy = y - it->dy;
1005    ady = dy;
1006    if (ady < 0) ady = -dy;
1007    minw /= 2;
1008    minh /= 2;
1009    if ((adx > minw) || (ady > minh))
1010      {
1011         it->dragging = EINA_TRUE;
1012         it->wd->dragging_queue = eina_list_append(it->wd->dragging_queue, it);
1013         if (it->long_timer)
1014           {
1015              ecore_timer_del(it->long_timer);
1016              it->long_timer = NULL;
1017           }
1018         if (!it->wd->wasselected)
1019           _item_unselect(it);
1020         if (dy < 0)
1021           {
1022              if (ady > adx)
1023                evas_object_smart_callback_call(it->base.widget,
1024                                                SIG_DRAG_START_UP, it);
1025              else
1026                {
1027                   if (dx < 0)
1028                     evas_object_smart_callback_call(it->base.widget,
1029                                                     SIG_DRAG_START_LEFT, it);
1030                   else
1031                     evas_object_smart_callback_call(it->base.widget,
1032                                                     SIG_DRAG_START_RIGHT, it);
1033                }
1034           }
1035         else
1036           {
1037              if (ady > adx)
1038                evas_object_smart_callback_call(it->base.widget,
1039                                                SIG_DRAG_START_DOWN, it);
1040              else
1041                {
1042                   if (dx < 0)
1043                     evas_object_smart_callback_call(it->base.widget,
1044                                                     SIG_DRAG_START_LEFT, it);
1045                   else
1046                     evas_object_smart_callback_call(it->base.widget,
1047                                                     SIG_DRAG_START_RIGHT, it);
1048                }
1049           }
1050      }
1051 }
1052
1053 static Eina_Bool
1054 _long_press(void *data)
1055 {
1056    Elm_Genlist_Item *it = data;
1057    Elm_Genlist_Item *it_tmp;
1058    static Eina_Bool done = EINA_FALSE;
1059    //static Eina_Bool contracted = EINA_FALSE;
1060    Eina_List *l;
1061    Item_Block *itb;
1062
1063    it->long_timer = NULL;
1064    if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
1065      return ECORE_CALLBACK_CANCEL;
1066    it->wd->longpressed = EINA_TRUE;
1067    evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1068    if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1069      {
1070         it->wd->reorder_it = it;
1071         it->wd->reorder_start_y = 0;
1072         evas_object_raise(it->edit_obj);
1073         elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1074         edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1075
1076         EINA_INLIST_FOREACH(it->wd->blocks, itb)
1077           {
1078              if (itb->realized)
1079                {
1080                   done = 1;
1081                   EINA_LIST_FOREACH(itb->items, l, it_tmp)
1082                     {
1083                        if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1084                          {
1085                             _item_unselect(it_tmp);
1086                          }
1087                     }
1088                }
1089              else
1090                {
1091                   if (done) break;
1092                }
1093           }
1094
1095         if (it->items)
1096           {
1097              EINA_LIST_FOREACH(it->items, l, it_tmp)
1098                {
1099                   if (elm_genlist_item_expanded_get(it_tmp))
1100                     {
1101                        elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1102                        return ECORE_CALLBACK_RENEW;
1103                     }
1104                }
1105           }
1106         if (elm_genlist_item_expanded_get(it)) {
1107              elm_genlist_item_expanded_set(it, EINA_FALSE);
1108              return ECORE_CALLBACK_RENEW;
1109         }
1110      }
1111
1112    return ECORE_CALLBACK_CANCEL;
1113 }
1114
1115 static void
1116 _swipe(Elm_Genlist_Item *it)
1117 {
1118    int i, sum = 0;
1119
1120    if (!it) return;
1121    if ((it->display_only) || (it->disabled)) return;
1122    it->wd->swipe = EINA_FALSE;
1123    for (i = 0; i < it->wd->movements; i++)
1124      {
1125         sum += it->wd->history[i].x;
1126         if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1127      }
1128
1129    sum /= it->wd->movements;
1130    if (abs(sum - it->wd->history[0].x) <= 10) return;
1131    evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1132 }
1133
1134 static Eina_Bool
1135 _swipe_cancel(void *data)
1136 {
1137    Elm_Genlist_Item *it = data;
1138
1139    if (!it) return ECORE_CALLBACK_CANCEL;
1140    it->wd->swipe = EINA_FALSE;
1141    it->wd->movements = 0;
1142    return ECORE_CALLBACK_RENEW;
1143 }
1144
1145 static Eina_Bool
1146 _multi_cancel(void *data)
1147 {
1148    Widget_Data *wd = data;
1149
1150    if (!wd) return ECORE_CALLBACK_CANCEL;
1151    wd->multi_timeout = EINA_TRUE;
1152    return ECORE_CALLBACK_RENEW;
1153 }
1154
1155 static void
1156 _multi_touch_gesture_eval(void *data)
1157 {
1158    Elm_Genlist_Item *it = data;
1159
1160    it->wd->multitouched = EINA_FALSE;
1161    if (it->wd->multi_timer)
1162      {
1163         ecore_timer_del(it->wd->multi_timer);
1164         it->wd->multi_timer = NULL;
1165      }
1166    if (it->wd->multi_timeout)
1167      {
1168         it->wd->multi_timeout = EINA_FALSE;
1169         return;
1170      }
1171
1172    Evas_Coord minw = 0, minh = 0;
1173    Evas_Coord off_x, off_y, off_mx, off_my;
1174
1175    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1176    off_x = abs(it->wd->cur_x - it->wd->prev_x);
1177    off_y = abs(it->wd->cur_y - it->wd->prev_y);
1178    off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1179    off_my = abs(it->wd->cur_my - it->wd->prev_my);
1180
1181    if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1182      {
1183         if ((off_x + off_mx) > (off_y + off_my))
1184           {
1185              if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1186                evas_object_smart_callback_call(it->base.widget,
1187                                                SIG_MULTI_SWIPE_RIGHT, it);
1188              else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1189                evas_object_smart_callback_call(it->base.widget,
1190                                                SIG_MULTI_SWIPE_LEFT, it);
1191              else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1192                evas_object_smart_callback_call(it->base.widget,
1193                                                SIG_MULTI_PINCH_OUT, it);
1194              else
1195                evas_object_smart_callback_call(it->base.widget,
1196                                                SIG_MULTI_PINCH_IN, it);
1197           }
1198         else
1199           {
1200              if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1201                evas_object_smart_callback_call(it->base.widget,
1202                                                SIG_MULTI_SWIPE_DOWN, it);
1203              else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1204                evas_object_smart_callback_call(it->base.widget,
1205                                                SIG_MULTI_SWIPE_UP, it);
1206              else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1207                evas_object_smart_callback_call(it->base.widget,
1208                                                SIG_MULTI_PINCH_OUT, it);
1209              else
1210                evas_object_smart_callback_call(it->base.widget,
1211                                                SIG_MULTI_PINCH_IN, it);
1212           }
1213      }
1214    it->wd->multi_timeout = EINA_FALSE;
1215 }
1216
1217 static void
1218 _multi_down(void        *data,
1219             Evas        *evas __UNUSED__,
1220             Evas_Object *obj __UNUSED__,
1221             void        *event_info)
1222 {
1223    Elm_Genlist_Item *it = data;
1224    Evas_Event_Multi_Down *ev = event_info;
1225
1226    if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1227    it->wd->multi_device = ev->device;
1228    it->wd->multi_down = EINA_TRUE;
1229    it->wd->multitouched = EINA_TRUE;
1230    it->wd->prev_mx = ev->canvas.x;
1231    it->wd->prev_my = ev->canvas.y;
1232    if (!it->wd->wasselected) _item_unselect(it);
1233    it->wd->wasselected = EINA_FALSE;
1234    it->wd->longpressed = EINA_FALSE;
1235    if (it->long_timer)
1236      {
1237         ecore_timer_del(it->long_timer);
1238         it->long_timer = NULL;
1239      }
1240    if (it->dragging)
1241      {
1242         it->dragging = EINA_FALSE;
1243         evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1244      }
1245    if (it->swipe_timer)
1246      {
1247         ecore_timer_del(it->swipe_timer);
1248         it->swipe_timer = NULL;
1249      }
1250    if (it->wd->on_hold)
1251      {
1252         it->wd->swipe = EINA_FALSE;
1253         it->wd->movements = 0;
1254         it->wd->on_hold = EINA_FALSE;
1255      }
1256 }
1257
1258 static void
1259 _multi_up(void        *data,
1260           Evas        *evas __UNUSED__,
1261           Evas_Object *obj __UNUSED__,
1262           void        *event_info)
1263 {
1264    Elm_Genlist_Item *it = data;
1265    Evas_Event_Multi_Up *ev = event_info;
1266
1267    if (it->wd->multi_device != ev->device) return;
1268    it->wd->multi_device = 0;
1269    it->wd->multi_down = EINA_FALSE;
1270    if (it->wd->mouse_down) return;
1271    _multi_touch_gesture_eval(data);
1272 }
1273
1274 static void
1275 _multi_move(void        *data,
1276             Evas        *evas __UNUSED__,
1277             Evas_Object *obj __UNUSED__,
1278             void        *event_info)
1279 {
1280    Elm_Genlist_Item *it = data;
1281    Evas_Event_Multi_Move *ev = event_info;
1282
1283    if (it->wd->multi_device != ev->device) return;
1284    it->wd->cur_mx = ev->cur.canvas.x;
1285    it->wd->cur_my = ev->cur.canvas.y;
1286 }
1287
1288 static void
1289 _mouse_down(void        *data,
1290             Evas        *evas __UNUSED__,
1291             Evas_Object *obj,
1292             void        *event_info)
1293 {
1294    Elm_Genlist_Item *it = data;
1295    Evas_Event_Mouse_Down *ev = event_info;
1296    Evas_Coord x, y;
1297
1298    if (ev->button != 1) return;
1299    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1300      {
1301         it->wd->on_hold = EINA_TRUE;
1302      }
1303    it->down = EINA_TRUE;
1304    it->dragging = EINA_FALSE;
1305    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1306    it->dx = ev->canvas.x - x;
1307    it->dy = ev->canvas.y - y;
1308    it->wd->mouse_down = EINA_TRUE;
1309    if (!it->wd->multitouched)
1310      {
1311         it->wd->prev_x = ev->canvas.x;
1312         it->wd->prev_y = ev->canvas.y;
1313         it->wd->multi_timeout = EINA_FALSE;
1314         if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1315         it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1316      }
1317    it->wd->longpressed = EINA_FALSE;
1318    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1319    else it->wd->on_hold = EINA_FALSE;
1320    if (it->wd->on_hold) return;
1321    it->wd->wasselected = it->selected;
1322    _item_highlight(it);
1323    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1324      if ((!it->disabled) && (!it->display_only))
1325        {
1326           evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1327           evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
1328        }
1329    if (it->long_timer) ecore_timer_del(it->long_timer);
1330    if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1331    it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1332    if (it->realized)
1333      it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1334                                       it);
1335    else
1336      it->long_timer = NULL;
1337    it->wd->swipe = EINA_FALSE;
1338    it->wd->movements = 0;
1339 }
1340
1341 static void
1342 _mouse_up(void        *data,
1343           Evas        *evas __UNUSED__,
1344           Evas_Object *obj __UNUSED__,
1345           void        *event_info)
1346 {
1347    Elm_Genlist_Item *it = data;
1348    Evas_Event_Mouse_Up *ev = event_info;
1349    Eina_Bool dragged = EINA_FALSE;
1350
1351    if (ev->button != 1) return;
1352    it->down = EINA_FALSE;
1353    it->wd->mouse_down = EINA_FALSE;
1354    if (it->wd->multitouched)
1355      {
1356         // in single selection modes, some multi touching can make multi highlighted items.
1357         // if a item not selected and highlighted, it should be unhighlighted.
1358         if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unselect(it);
1359         if (it->wd->multi_down) return;
1360         _multi_touch_gesture_eval(data);
1361         return;
1362      }
1363    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1364    else it->wd->on_hold = EINA_FALSE;
1365    if (it->long_timer)
1366      {
1367         ecore_timer_del(it->long_timer);
1368         it->long_timer = NULL;
1369      }
1370    while (it->wd->dragging_queue)
1371      {
1372         Elm_Genlist_Item *dragging_it = NULL;
1373         dragging_it = eina_list_data_get(it->wd->dragging_queue);
1374         dragging_it->dragging = EINA_FALSE;
1375         evas_object_smart_callback_call(dragging_it->base.widget, SIG_DRAG_STOP, dragging_it);
1376         if (dragging_it->want_unrealize)
1377           {
1378              _item_unrealize(dragging_it, EINA_FALSE);
1379              if (dragging_it->block->want_unrealize)
1380                _item_block_unrealize(it->block);
1381           }
1382         it->wd->dragging_queue = eina_list_remove_list(it->wd->dragging_queue,it->wd->dragging_queue);
1383         dragged = 1;
1384      }
1385    if (it->swipe_timer)
1386      {
1387         ecore_timer_del(it->swipe_timer);
1388         it->swipe_timer = NULL;
1389      }
1390    if (it->wd->multi_timer)
1391      {
1392         ecore_timer_del(it->wd->multi_timer);
1393         it->wd->multi_timer = NULL;
1394         it->wd->multi_timeout = EINA_FALSE;
1395      }
1396    if (it->wd->on_hold)
1397      {
1398         if (it->wd->swipe) _swipe(data);
1399         it->wd->longpressed = EINA_FALSE;
1400         it->wd->on_hold = EINA_FALSE;
1401         return;
1402      }
1403    if (it->wd->reorder_mode)
1404      {
1405         Evas_Coord rox, roy, row, roh;
1406         Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1407         if (reorder_it)
1408           {
1409              Evas_Coord ox,oy,oh,ow;
1410              evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1411              evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1412              if (it->wd->reorder_rel)
1413                {
1414                   if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent)  // todo : refactoring
1415                     {
1416                        if (roy + oy <= it->wd->reorder_rel->scrl_y)
1417                           _effect_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1418                        else
1419                           _effect_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1420                     }
1421                }
1422             it->wd->reorder_deleted = EINA_FALSE;
1423             it->wd->reorder_it = it->wd->reorder_rel = NULL;
1424             elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1425             edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1426          }
1427       }
1428    if (it->wd->longpressed)
1429      {
1430         it->wd->longpressed = EINA_FALSE;
1431         if (!it->wd->wasselected)
1432           _item_unselect(it);
1433         it->wd->wasselected = EINA_FALSE;
1434         return;
1435      }
1436    if ((it->disabled) || (dragged) || (it->display_only)) return;
1437    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1438    if (it->wd->multi)
1439      {
1440         if (!it->selected)
1441           {
1442              _item_highlight(it);
1443              _item_select(it);
1444           }
1445         else _item_unselect(it);
1446      }
1447    else
1448      {
1449         if (!it->selected)
1450           {
1451              Widget_Data *wd = it->wd;
1452              if (wd)
1453                {
1454                   while (wd->selected) _item_unselect(wd->selected->data);
1455                }
1456           }
1457         else
1458           {
1459              const Eina_List *l, *l_next;
1460              Elm_Genlist_Item *it2;
1461
1462              EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1463                if (it2 != it) _item_unselect(it2);
1464              //_item_highlight(it);
1465              //_item_select(it);
1466           }
1467         _item_highlight(it);
1468         _item_select(it);
1469      }
1470 }
1471
1472 static void
1473 _signal_expand_toggle(void        *data,
1474                       Evas_Object *obj __UNUSED__,
1475                       const char  *emission __UNUSED__,
1476                       const char  *source __UNUSED__)
1477 {
1478    Elm_Genlist_Item *it = data;
1479
1480    if (it->expanded)
1481      evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1482    else
1483      evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1484 }
1485
1486 static void
1487 _signal_expand(void        *data,
1488                Evas_Object *obj __UNUSED__,
1489                const char  *emission __UNUSED__,
1490                const char  *source __UNUSED__)
1491 {
1492    Elm_Genlist_Item *it = data;
1493
1494    if (!it->expanded)
1495      evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1496 }
1497
1498 static void
1499 _signal_contract(void        *data,
1500                  Evas_Object *obj __UNUSED__,
1501                  const char  *emission __UNUSED__,
1502                  const char  *source __UNUSED__)
1503 {
1504    Elm_Genlist_Item *it = data;
1505
1506    if (it->expanded)
1507      evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1508 }
1509
1510 static Eina_Bool
1511 _scr_hold_timer_cb(void *data)
1512 {
1513    if (!data) return ECORE_CALLBACK_CANCEL;
1514    Widget_Data *wd = data;
1515    elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1516    wd->scr_hold_timer = NULL;
1517    return ECORE_CALLBACK_CANCEL;
1518 }
1519
1520 static void
1521 _mode_finished_signal_cb(void        *data,
1522                          Evas_Object *obj,
1523                          const char  *emission __UNUSED__,
1524                          const char  *source __UNUSED__)
1525 {
1526    if (!data) return;
1527    if (!obj) return;
1528    Elm_Genlist_Item *it = data;
1529    if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1530    char buf[1024];
1531    Evas *te = evas_object_evas_get(obj);
1532
1533    evas_event_freeze(te);
1534    it->nocache = EINA_FALSE;
1535    _mode_item_unrealize(it);
1536    snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1537    edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1538    evas_event_thaw(te);
1539    evas_event_thaw_eval(te);
1540 }
1541
1542 static void
1543 _item_cache_clean(Widget_Data *wd)
1544 {
1545    evas_event_freeze(evas_object_evas_get(wd->obj));
1546    while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1547      {
1548         Item_Cache *itc;
1549
1550         itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1551         wd->item_cache = eina_inlist_remove(wd->item_cache,
1552                                             wd->item_cache->last);
1553         wd->item_cache_count--;
1554         if (itc->spacer) evas_object_del(itc->spacer);
1555         if (itc->base_view) evas_object_del(itc->base_view);
1556         if (itc->item_style) eina_stringshare_del(itc->item_style);
1557         free(itc);
1558      }
1559    evas_event_thaw(evas_object_evas_get(wd->obj));
1560    evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1561 }
1562
1563 static void
1564 _item_cache_zero(Widget_Data *wd)
1565 {
1566    int pmax = wd->item_cache_max;
1567    wd->item_cache_max = 0;
1568    _item_cache_clean(wd);
1569    wd->item_cache_max = pmax;
1570 }
1571
1572 static void
1573 _item_cache_add(Elm_Genlist_Item *it)
1574 {
1575    Item_Cache *itc;
1576
1577    evas_event_freeze(evas_object_evas_get(it->wd->obj));
1578    if (it->wd->item_cache_max <= 0)
1579      {
1580         evas_object_del(it->base.view);
1581         it->base.view = NULL;
1582         evas_object_del(it->spacer);
1583         it->spacer = NULL;
1584         evas_event_thaw(evas_object_evas_get(it->wd->obj));
1585         evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1586         return;
1587      }
1588
1589    it->wd->item_cache_count++;
1590    itc = calloc(1, sizeof(Item_Cache));
1591    if (!itc)
1592      {
1593         evas_event_thaw(evas_object_evas_get(it->wd->obj));
1594         evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1595         return;
1596      }
1597    it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1598                                             EINA_INLIST_GET(itc));
1599    itc->spacer = it->spacer;
1600    it->spacer = NULL;
1601    itc->base_view = it->base.view;
1602    it->base.view = NULL;
1603    evas_object_hide(itc->base_view);
1604    evas_object_move(itc->base_view, -9999, -9999);
1605    itc->item_style = eina_stringshare_add(it->itc->item_style);
1606    if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1607    itc->compress = (it->wd->compress);
1608    itc->odd = (it->order_num_in & 0x1);
1609    itc->selected = it->selected;
1610    itc->disabled = it->disabled;
1611    itc->expanded = it->expanded;
1612    if (it->long_timer)
1613      {
1614         ecore_timer_del(it->long_timer);
1615         it->long_timer = NULL;
1616      }
1617    if (it->swipe_timer)
1618      {
1619         ecore_timer_del(it->swipe_timer);
1620         it->swipe_timer = NULL;
1621      }
1622    // FIXME: other callbacks?
1623    edje_object_signal_callback_del_full(itc->base_view,
1624                                         "elm,action,expand,toggle",
1625                                         "elm", _signal_expand_toggle, it);
1626    edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1627                                         "elm",
1628                                         _signal_expand, it);
1629    edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1630                                         "elm", _signal_contract, it);
1631    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1632                                        _mouse_down, it);
1633    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1634                                        _mouse_up, it);
1635    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1636                                        _mouse_move, it);
1637    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1638                                        _multi_down, it);
1639    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1640                                        _multi_up, it);
1641    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1642                                        _multi_move, it);
1643    _item_cache_clean(it->wd);
1644    evas_event_thaw(evas_object_evas_get(it->wd->obj));
1645    evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1646 }
1647
1648 static Item_Cache *
1649 _item_cache_find(Elm_Genlist_Item *it)
1650 {
1651    Item_Cache *itc;
1652    Eina_Bool tree = 0, odd;
1653
1654    if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1655    odd = (it->order_num_in & 0x1);
1656    EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1657      {
1658         if ((itc->selected) || (itc->disabled) || (itc->expanded))
1659           continue;
1660         if ((itc->tree == tree) &&
1661             (itc->odd == odd) &&
1662             (itc->compress == it->wd->compress) &&
1663             (!strcmp(it->itc->item_style, itc->item_style)))
1664           {
1665              it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1666                                                      EINA_INLIST_GET(itc));
1667              it->wd->item_cache_count--;
1668              return itc;
1669           }
1670      }
1671    return NULL;
1672 }
1673
1674 static void
1675 _item_cache_free(Item_Cache *itc)
1676 {
1677    if (itc->spacer) evas_object_del(itc->spacer);
1678    if (itc->base_view) evas_object_del(itc->base_view);
1679    if (itc->item_style) eina_stringshare_del(itc->item_style);
1680    free(itc);
1681 }
1682
1683 static void
1684 _item_realize(Elm_Genlist_Item *it,
1685               int               in,
1686               Eina_Bool         calc)
1687 {
1688    Elm_Genlist_Item *it2;
1689    const char *stacking;
1690    const char *treesize;
1691    char buf[1024];
1692    int depth, tsize = 20;
1693    Item_Cache *itc = NULL;
1694
1695    if ((it->realized) || (it->delete_me)) return;
1696    evas_event_freeze(evas_object_evas_get(it->wd->obj));
1697    it->order_num_in = in;
1698    if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1699    if ((it->nocache) && (!it->renamed))
1700      it->nocache = EINA_FALSE;
1701    else
1702      itc = _item_cache_find(it);
1703    if (itc && (!it->wd->effect_mode))
1704      {
1705         it->base.view = itc->base_view;
1706         itc->base_view = NULL;
1707         it->spacer = itc->spacer;
1708         itc->spacer = NULL;
1709      }
1710    else
1711      {
1712         it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1713         edje_object_scale_set(it->base.view,
1714                               elm_widget_scale_get(it->base.widget) *
1715                               _elm_config->scale);
1716         evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1717         elm_widget_sub_object_add(it->base.widget, it->base.view);
1718
1719         if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1720           strncpy(buf, "tree", sizeof(buf));
1721         else strncpy(buf, "item", sizeof(buf));
1722         if (it->wd->compress)
1723           strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1724
1725         if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1726         strncat(buf, "/", sizeof(buf) - strlen(buf));
1727         strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1728
1729         _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1730                               elm_widget_style_get(it->base.widget));
1731         edje_object_mirrored_set(it->base.view,
1732                                  elm_widget_mirrored_get(it->base.widget));
1733         it->spacer =
1734           evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1735         evas_object_color_set(it->spacer, 0, 0, 0, 0);
1736         elm_widget_sub_object_add(it->base.widget, it->spacer);
1737      }
1738    for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1739      {
1740         if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1741      }
1742    it->expanded_depth = depth;
1743    treesize = edje_object_data_get(it->base.view, "treesize");
1744    if (treesize) tsize = atoi(treesize);
1745    evas_object_size_hint_min_set(it->spacer,
1746                                  (depth * tsize) * _elm_config->scale, 1);
1747    edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1748    if (!calc)
1749      {
1750         edje_object_signal_callback_add(it->base.view,
1751                                         "elm,action,expand,toggle",
1752                                         "elm", _signal_expand_toggle, it);
1753         edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1754                                         "elm", _signal_expand, it);
1755         edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1756                                         "elm", _signal_contract, it);
1757         stacking = edje_object_data_get(it->base.view, "stacking");
1758         if (stacking)
1759           {
1760              if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1761              else if (!strcmp(stacking, "above"))
1762                evas_object_raise(it->base.view);
1763           }
1764         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1765                                        _mouse_down, it);
1766         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1767                                        _mouse_up, it);
1768         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1769                                        _mouse_move, it);
1770         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1771                                        _multi_down, it);
1772         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1773                                        _multi_up, it);
1774         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1775                                        _multi_move, it);
1776
1777         if ((!it->edit_obj) &&(it->wd->edit_mode) &&
1778             (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
1779           _effect_item_realize(it, EINA_FALSE);
1780
1781         if (itc)
1782           {
1783              if ((it->selected) && (it->selected != itc->selected))
1784                {
1785                   edje_object_signal_emit(it->base.view,
1786                                           "elm,state,selected", "elm");
1787                   if (it->edit_obj)
1788                     edje_object_signal_emit(it->edit_obj,
1789                                             "elm,state,selected", "elm");
1790                }
1791              if ((it->disabled) && (it->disabled != itc->disabled))
1792                {
1793                   edje_object_signal_emit(it->base.view,
1794                                           "elm,state,disabled", "elm");
1795                   if (it->edit_obj)
1796                     edje_object_signal_emit(it->edit_obj,
1797                                             "elm,state,disabled", "elm");
1798                }
1799              if ((it->expanded) && (it->expanded != itc->expanded))
1800                {
1801                   edje_object_signal_emit(it->base.view,
1802                                           "elm,state,expanded", "elm");
1803                   if (it->edit_obj)
1804                     edje_object_signal_emit(it->edit_obj,
1805                                             "elm,state,expanded", "elm");
1806                }
1807           }
1808         else
1809           {
1810              if (it->selected)
1811                {
1812                   edje_object_signal_emit(it->base.view,
1813                                           "elm,state,selected", "elm");
1814                   if (it->edit_obj)
1815                     edje_object_signal_emit(it->edit_obj,
1816                                             "elm,state,selected", "elm");
1817                }
1818              if (it->disabled)
1819                {
1820                   edje_object_signal_emit(it->base.view,
1821                                           "elm,state,disabled", "elm");
1822                   if (it->edit_obj)
1823                     edje_object_signal_emit(it->edit_obj,
1824                                             "elm,state,disabled", "elm");
1825                }
1826              if (it->expanded)
1827                {
1828                   edje_object_signal_emit(it->base.view,
1829                                           "elm,state,expanded", "elm");
1830                   if (it->edit_obj)
1831                     edje_object_signal_emit(it->edit_obj,
1832                                             "elm,state,expanded", "elm");
1833                }
1834           }
1835      }
1836
1837    if ((calc) && (it->wd->homogeneous) &&
1838        ((it->wd->item_width) ||
1839         ((it->wd->item_width) && (it->wd->group_item_width))))
1840      {
1841         /* homogenous genlist shortcut */
1842         if (!it->mincalcd)
1843           {
1844              if (it->flags & ELM_GENLIST_ITEM_GROUP)
1845                {
1846                   it->w = it->minw = it->wd->group_item_width;
1847                   it->h = it->minh = it->wd->group_item_height;
1848                }
1849              else
1850                {
1851                   it->w = it->minw = it->wd->item_width;
1852                   it->h = it->minh = it->wd->item_height;
1853                }
1854              it->mincalcd = EINA_TRUE;
1855           }
1856      }
1857    else
1858      {
1859         if (it->itc->func.label_get)
1860           {
1861              const Eina_List *l;
1862              const char *key;
1863
1864              it->labels =
1865                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1866                                                               "labels"));
1867              EINA_LIST_FOREACH(it->labels, l, key)
1868                {
1869                   char *s = it->itc->func.label_get
1870                       ((void *)it->base.data, it->base.widget, l->data);
1871
1872                   if (s)
1873                     {
1874                        edje_object_part_text_set(it->base.view, l->data, s);
1875                        free(s);
1876                     }
1877                   else if (itc)
1878                     edje_object_part_text_set(it->base.view, l->data, "");
1879                }
1880           }
1881         if (it->itc->func.icon_get)
1882           {
1883              const Eina_List *l;
1884              const char *key;
1885
1886              it->icons =
1887                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1888                                                               "icons"));
1889              EINA_LIST_FOREACH(it->icons, l, key)
1890                {
1891                   Evas_Object *ic = it->itc->func.icon_get
1892                       ((void *)it->base.data, it->base.widget, l->data);
1893
1894                   if (ic)
1895                     {
1896                        it->icon_objs = eina_list_append(it->icon_objs, ic);
1897                        edje_object_part_swallow(it->base.view, key, ic);
1898                        evas_object_show(ic);
1899                        elm_widget_sub_object_add(it->base.widget, ic);
1900                        evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
1901                        if (it->disabled)
1902                          elm_widget_disabled_set(ic, EINA_TRUE);
1903                     }
1904                }
1905              if (it->renamed)
1906                {
1907                   it->icons =
1908                       elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
1909                   EINA_LIST_FOREACH(it->icons, l, key)
1910                     {
1911                        Evas_Object *ic = it->itc->func.icon_get
1912                                          ((void *)it->base.data, it->base.widget, l->data);
1913                        if (ic)
1914                          {
1915                              it->icon_objs = eina_list_append(it->icon_objs, ic);
1916                              edje_object_part_swallow(it->base.view, key, ic);
1917                              evas_object_show(ic);
1918                              elm_widget_sub_object_add(it->base.widget, ic);
1919                          }
1920                     }
1921               }
1922           }
1923         if (it->itc->func.state_get)
1924           {
1925              const Eina_List *l;
1926              const char *key;
1927
1928              it->states =
1929                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1930                                                               "states"));
1931              EINA_LIST_FOREACH(it->states, l, key)
1932                {
1933                   Eina_Bool on = it->itc->func.state_get
1934                       ((void *)it->base.data, it->base.widget, l->data);
1935
1936                   if (on)
1937                     {
1938                        snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1939                        edje_object_signal_emit(it->base.view, buf, "elm");
1940                     }
1941                   else if (itc)
1942                     {
1943                        snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1944                        edje_object_signal_emit(it->base.view, buf, "elm");
1945                     }
1946                }
1947           }
1948         if (!it->mincalcd)
1949           {
1950              Evas_Coord mw = -1, mh = -1;
1951
1952              if (it->wd->height_for_width) mw = it->wd->w; // TODO: Removed this. This was removed from upstream.
1953
1954              if (!it->display_only)
1955                elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1956              if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1957              edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1958                                                   mh);
1959              if (!it->display_only)
1960                elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1961              it->w = it->minw = mw;
1962              it->h = it->minh = mh;
1963              it->mincalcd = EINA_TRUE;
1964
1965              if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1966                {
1967                   it->wd->group_item_width = mw;
1968                   it->wd->group_item_height = mh;
1969                }
1970              else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1971                {
1972                   it->wd->item_width = mw;
1973                   it->wd->item_height = mh;
1974                }
1975           }
1976         if (!calc) evas_object_show(it->base.view);
1977      }
1978
1979    if (it->tooltip.content_cb)
1980      {
1981         elm_widget_item_tooltip_content_cb_set(it,
1982                                                it->tooltip.content_cb,
1983                                                it->tooltip.data, NULL);
1984         elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1985      }
1986
1987    if (it->mouse_cursor)
1988      elm_widget_item_cursor_set(it, it->mouse_cursor);
1989
1990    it->realized = EINA_TRUE;
1991    it->want_unrealize = EINA_FALSE;
1992
1993    if (itc) _item_cache_free(itc);
1994    evas_event_thaw(evas_object_evas_get(it->wd->obj));
1995    evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1996    if (!calc)
1997      evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
1998    if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1999      {
2000         if (it->itc->edit_item_style)
2001           {
2002              if (!it->edit_obj) _effect_item_realize(it, EINA_FALSE);
2003              edje_object_message_signal_process(it->edit_obj);
2004           }
2005      }
2006    edje_object_message_signal_process(it->base.view);
2007 }
2008
2009 static void
2010 _item_unrealize(Elm_Genlist_Item *it,
2011                 Eina_Bool         calc)
2012 {
2013    Evas_Object *icon;
2014
2015    if (!it->realized) return;
2016    if (it->wd->reorder_it == it) return;
2017    evas_event_freeze(evas_object_evas_get(it->wd->obj));
2018    if (!calc)
2019      evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2020    if (it->long_timer)
2021      {
2022         ecore_timer_del(it->long_timer);
2023         it->long_timer = NULL;
2024      }
2025    if (it->nocache)
2026      {
2027         evas_object_del(it->base.view);
2028         it->base.view = NULL;
2029         evas_object_del(it->spacer);
2030         it->spacer = NULL;
2031      }
2032    else
2033      {
2034         edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2035         _item_cache_add(it);
2036      }
2037    elm_widget_stringlist_free(it->labels);
2038    it->labels = NULL;
2039    elm_widget_stringlist_free(it->icons);
2040    it->icons = NULL;
2041    elm_widget_stringlist_free(it->states);
2042
2043    EINA_LIST_FREE(it->icon_objs, icon)
2044      evas_object_del(icon);
2045
2046    _mode_item_unrealize(it);
2047    it->states = NULL;
2048    it->realized = EINA_FALSE;
2049    it->want_unrealize = EINA_FALSE;
2050    evas_event_thaw(evas_object_evas_get(it->wd->obj));
2051    evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2052    if (it->wd->edit_mode) _effect_item_unrealize(it);
2053 }
2054
2055 static Eina_Bool
2056 _item_block_recalc(Item_Block *itb,
2057                    int         in,
2058                    Eina_Bool   qadd)
2059 {
2060    const Eina_List *l;
2061    Elm_Genlist_Item *it;
2062    Evas_Coord minw = 0, minh = 0;
2063    Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2064    Evas_Coord y = 0;
2065
2066    evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2067    itb->num = in;
2068    EINA_LIST_FOREACH(itb->items, l, it)
2069      {
2070         if (it->delete_me) continue;
2071         showme |= it->showme;
2072         if (!itb->realized)
2073           {
2074              if (qadd)
2075                {
2076                   if (!it->mincalcd) changed = EINA_TRUE;
2077                   if (changed)
2078                     {
2079                        _item_realize(it, in, EINA_TRUE);
2080                        _item_unrealize(it, EINA_TRUE);
2081                     }
2082                }
2083              else
2084                {
2085                   _item_realize(it, in, EINA_TRUE);
2086                   _item_unrealize(it, EINA_TRUE);
2087                }
2088           }
2089         else
2090           _item_realize(it, in, EINA_FALSE);
2091         minh += it->minh;
2092         if (minw < it->minw) minw = it->minw;
2093         in++;
2094         it->x = 0;
2095         it->y = y;
2096         y += it->h;
2097      }
2098    itb->minw = minw;
2099    itb->minh = minh;
2100    itb->changed = EINA_FALSE;
2101    evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2102    evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2103    return showme;
2104 }
2105
2106 static void
2107 _item_block_realize(Item_Block *itb,
2108                     int         in,
2109                     int         full)
2110 {
2111    const Eina_List *l;
2112    Elm_Genlist_Item *it;
2113
2114    if (itb->realized) return;
2115    evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2116    EINA_LIST_FOREACH(itb->items, l, it)
2117      {
2118         if (it->delete_me) continue;
2119         if (full) _item_realize(it, in, EINA_FALSE);
2120         in++;
2121      }
2122    itb->realized = EINA_TRUE;
2123    itb->want_unrealize = EINA_FALSE;
2124    evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2125    evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2126 }
2127
2128 static void
2129 _item_block_unrealize(Item_Block *itb)
2130 {
2131    const Eina_List *l;
2132    Elm_Genlist_Item *it;
2133    Eina_Bool dragging = EINA_FALSE;
2134
2135    if (!itb->realized) return;
2136    evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2137    EINA_LIST_FOREACH(itb->items, l, it)
2138      {
2139         if (it->flags != ELM_GENLIST_ITEM_GROUP)
2140           {
2141              if (it->dragging)
2142                {
2143                   dragging = EINA_TRUE;
2144                   it->want_unrealize = EINA_TRUE;
2145                }
2146              else
2147                _item_unrealize(it, EINA_FALSE);
2148           }
2149      }
2150    if (!dragging)
2151      {
2152         itb->realized = EINA_FALSE;
2153         itb->want_unrealize = EINA_TRUE;
2154      }
2155    else
2156      itb->want_unrealize = EINA_FALSE;
2157    evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2158    evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2159 }
2160
2161 static int
2162 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2163 {
2164    Evas_Coord rox, roy, row, roh;
2165    Eina_Bool top = EINA_FALSE;
2166    Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2167    if (!reorder_it) return 0;
2168
2169    Evas_Coord   ox,oy,oh,ow;
2170    evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
2171    evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2172
2173    if ((it->wd->reorder_start_y < it->block->y) && (roy - oy + roh/2 >= it->block->y -  it->wd->pan_y))
2174      {
2175         it->block->reorder_offset = it->wd->reorder_it->h * -1;
2176         if (it->block->count == 1)
2177            it->wd->reorder_rel = it;
2178      }
2179    else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2  <=  it->block->y -  it->wd->pan_y))
2180      {
2181         it->block->reorder_offset = it->wd->reorder_it->h;
2182      }
2183    else
2184      it->block->reorder_offset = 0;
2185
2186    it->scrl_y += it->block->reorder_offset;
2187
2188    top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2189                                             rox, roy+roh/2, row, 1));
2190    if (top)
2191      {
2192         it->wd->reorder_rel = it;
2193         it->scrl_y+=it->wd->reorder_it->h;
2194         return it->wd->reorder_it->h;
2195      }
2196    else
2197      return 0;
2198 }
2199
2200 static Eina_Bool
2201 _reorder_item_moving_effect_timer_cb(void *data)
2202 {
2203    Elm_Genlist_Item *it = data;
2204           Eina_Bool down = EINA_FALSE;
2205    double time = 0.4, t;
2206    int y, dy = 4;
2207    t = ((0.0 > (t = current_time_get() -  it->wd->start_time)) ? 0.0 : t) / 1000;
2208
2209    if (t <= time)
2210       y = (1 * sin((t / time) * (M_PI / 2)) * dy);
2211    else
2212       y = dy;
2213
2214    if (it->old_scrl_y < it->scrl_y)
2215      {
2216         it->old_scrl_y += y;
2217         down = EINA_TRUE;
2218      }
2219    else if (it->old_scrl_y > it->scrl_y)
2220      {
2221         it->old_scrl_y -= y;
2222         down = EINA_FALSE;
2223      }
2224
2225    _effect_item_controls(it,  it->scrl_x, it->old_scrl_y);
2226
2227    _group_items_recalc(it->wd);
2228    if (!it->wd->reorder_it || it->wd->reorder_pan_move)
2229      {
2230         it->old_scrl_y = it->scrl_y;
2231         it->move_effect_me = EINA_FALSE;
2232         it->wd->item_moving_effect_timer = NULL;
2233         return ECORE_CALLBACK_CANCEL;
2234      }
2235    if ((down && it->old_scrl_y >= it->scrl_y) || (!down && it->old_scrl_y <= it->scrl_y))
2236      {
2237         it->old_scrl_y = it->scrl_y;
2238         it->move_effect_me = EINA_FALSE;
2239         it->wd->item_moving_effect_timer = NULL;
2240         return ECORE_CALLBACK_CANCEL;
2241      }
2242    return ECORE_CALLBACK_RENEW;
2243 }
2244
2245 static void
2246 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2247 {
2248    if (!it) return;
2249    if (!view) return;
2250
2251    evas_event_freeze(evas_object_evas_get(it->wd->obj));
2252    evas_object_resize(view, it->w, it->h);
2253    evas_object_move(view, it->scrl_x, it->scrl_y);
2254    evas_object_show(view);
2255    evas_event_thaw(evas_object_evas_get(it->wd->obj));
2256    evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2257 }
2258
2259 static void
2260 _item_block_position(Item_Block *itb,
2261                      int         in)
2262 {
2263    const Eina_List *l;
2264    Elm_Genlist_Item *it;
2265    Elm_Genlist_Item *git;
2266    Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2267    int vis = 0;
2268
2269    evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2270    evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2271    evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2272                             &cvw, &cvh);
2273    EINA_LIST_FOREACH(itb->items, l, it)
2274      {
2275         if (it->delete_me) continue;
2276         else if (it->wd->reorder_it == it) continue;
2277
2278         it->x = 0;
2279         it->y = y;
2280         it->w = itb->w;
2281         it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2282         it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2283
2284         vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2285                                    cvx, cvy, cvw, cvh));
2286         if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2287           {
2288              if ((itb->realized))
2289                {
2290                   if (vis)
2291                     {
2292                        if (!it->realized) _item_realize(it, in, EINA_FALSE);
2293                        if (it->renamed)
2294                          {
2295                             if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
2296                             edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
2297                          }
2298                     }
2299                }
2300              if (it->realized)
2301                {
2302                   if (vis)
2303                     {
2304                        if (it->wd->reorder_mode)
2305                           y += _get_space_for_reorder_item(it);
2306                        git = it->group_item;
2307                        if (git)
2308                          {
2309                             git->scrl_x = it->scrl_x;
2310                             if (git->scrl_y < oy)
2311                               git->scrl_y = oy;
2312                             if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2313                               git->scrl_y = (it->scrl_y + it->h) - git->h;
2314                             git->want_realize = EINA_TRUE;
2315                          }
2316                        if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2317                          {
2318                             if (!it->move_effect_me)
2319                               {
2320                                  it->move_effect_me = EINA_TRUE;
2321                                  it->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
2322                               }
2323
2324                          }
2325                        if (!it->move_effect_me )
2326                             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))
2327                             {
2328                               if (it->wd->edit_mode && it->itc->edit_item_style)
2329                                 {
2330                                   _effect_item_controls(it,  it->scrl_x, it->scrl_y);
2331                                 }
2332                               else
2333                                {
2334                                   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)))
2335                                     {
2336                                        if (it->mode_view)
2337                                          _item_position(it, it->mode_view);
2338                                        else
2339                                          _item_position(it, it->base.view);
2340                                     }
2341                                   else
2342                                     {
2343                                        evas_object_resize(it->base.view, it->w, it->h);
2344                                        evas_object_move(it->base.view, it->scrl_x, it->scrl_y);
2345                                        evas_object_hide(it->base.view);
2346                                     }
2347                                }
2348                             }
2349                     }
2350                   else
2351                     {
2352                        if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2353                     }
2354                }
2355              in++;
2356           }
2357         else
2358           {
2359              if (vis) it->want_realize = EINA_TRUE;
2360           }
2361         if (!it->wd->effect_mode || it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE || ((it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) && it->parent == it->wd->expand_item))
2362           {
2363              it->old_scrl_y = it->scrl_y;
2364           }
2365         y += it->h;
2366      }
2367    evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2368    evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2369 }
2370
2371 static void
2372 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2373 {
2374    Elm_Genlist_Item *it = data;
2375    if (!it) return;
2376    it->mincalcd = EINA_FALSE;
2377    it->block->changeme = EINA_TRUE;
2378    if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2379    it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2380 }
2381
2382 static void
2383 _group_items_recalc(void *data)
2384 {
2385    Widget_Data *wd = data;
2386    Eina_List *l;
2387    Elm_Genlist_Item *git;
2388
2389    evas_event_freeze(evas_object_evas_get(wd->obj));
2390    EINA_LIST_FOREACH(wd->group_items, l, git)
2391      {
2392         if (git->want_realize)
2393           {
2394              if (!git->realized)
2395                _item_realize(git, 0, EINA_FALSE);
2396              evas_object_resize(git->base.view, wd->minw, git->h);
2397              evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2398              evas_object_show(git->base.view);
2399              evas_object_raise(git->base.view);
2400           }
2401         else if (!git->want_realize && git->realized)
2402           {
2403              if (!git->dragging)
2404                _item_unrealize(git, EINA_FALSE);
2405           }
2406      }
2407    evas_event_thaw(evas_object_evas_get(wd->obj));
2408    evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2409 }
2410
2411 static Eina_Bool
2412 _must_recalc_idler(void *data)
2413 {
2414    Widget_Data *wd = data;
2415    if (wd->calc_job) ecore_job_del(wd->calc_job);
2416    wd->calc_job = ecore_job_add(_calc_job, wd);
2417    wd->must_recalc_idler = NULL;
2418    return ECORE_CALLBACK_CANCEL;
2419 }
2420
2421 static void
2422 _calc_job(void *data)
2423 {
2424    Widget_Data *wd = data;
2425    Item_Block *itb, *chb = NULL;
2426    Evas_Coord minw = -1, minh = 0, y = 0, ow;
2427    int in = 0, minw_change = 0;
2428    Eina_Bool changed = EINA_FALSE;
2429    double t0, t;
2430    Eina_Bool did_must_recalc = EINA_FALSE;
2431    if (!wd) return;
2432
2433    t0 = ecore_time_get();
2434    evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2435    if (wd->w != ow)
2436      wd->w = ow;
2437
2438    evas_event_freeze(evas_object_evas_get(wd->obj));
2439    EINA_INLIST_FOREACH(wd->blocks, itb)
2440      {
2441         Eina_Bool showme = EINA_FALSE;
2442
2443         itb->num = in;
2444         showme = itb->showme;
2445         itb->showme = EINA_FALSE;
2446         if (chb)
2447           {
2448              if (itb->realized) _item_block_unrealize(itb);
2449           }
2450         if ((itb->changed) || (changed) ||
2451             ((itb->must_recalc) && (!did_must_recalc)))
2452           {
2453              if ((changed) || (itb->must_recalc))
2454                {
2455                   Eina_List *l;
2456                   Elm_Genlist_Item *it;
2457                   EINA_LIST_FOREACH(itb->items, l, it)
2458                     if (it->mincalcd) it->mincalcd = EINA_FALSE;
2459                   itb->changed = EINA_TRUE;
2460                   if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2461                   itb->must_recalc = EINA_FALSE;
2462                }
2463              if (itb->realized) _item_block_unrealize(itb);
2464              showme = _item_block_recalc(itb, in, EINA_FALSE);
2465              chb = itb;
2466           }
2467         itb->y = y;
2468         itb->x = 0;
2469         minh += itb->minh;
2470         if (minw == -1) minw = itb->minw;
2471         else if ((!itb->must_recalc) && (minw < itb->minw))
2472           {
2473              minw = itb->minw;
2474              minw_change = EINA_TRUE;
2475           }
2476         itb->w = minw;
2477         itb->h = itb->minh;
2478         y += itb->h;
2479         in += itb->count;
2480         if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2481           {
2482              wd->show_item->showme = EINA_FALSE;
2483              if (wd->bring_in)
2484                elm_smart_scroller_region_bring_in(wd->scr,
2485                                                   wd->show_item->x +
2486                                                   wd->show_item->block->x,
2487                                                   wd->show_item->y +
2488                                                   wd->show_item->block->y,
2489                                                   wd->show_item->block->w,
2490                                                   wd->show_item->h);
2491              else
2492                elm_smart_scroller_child_region_show(wd->scr,
2493                                                     wd->show_item->x +
2494                                                     wd->show_item->block->x,
2495                                                     wd->show_item->y +
2496                                                     wd->show_item->block->y,
2497                                                     wd->show_item->block->w,
2498                                                     wd->show_item->h);
2499              wd->show_item = NULL;
2500           }
2501      }
2502    if (minw_change)
2503      {
2504         EINA_INLIST_FOREACH(wd->blocks, itb)
2505           {
2506              itb->minw = minw;
2507              itb->w = itb->minw;
2508           }
2509      }
2510    if ((chb) && (EINA_INLIST_GET(chb)->next))
2511      {
2512         EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2513           {
2514              if (itb->realized) _item_block_unrealize(itb);
2515           }
2516      }
2517    wd->realminw = minw;
2518    if (minw < wd->w) minw = wd->w;
2519    if ((minw != wd->minw) || (minh != wd->minh))
2520      {
2521         wd->minw = minw;
2522         wd->minh = minh;
2523         if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2524            evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2525         _sizing_eval(wd->obj);
2526 #ifdef ANCHOR_ITEM
2527         if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2528           {
2529              Elm_Genlist_Item *it;
2530              Evas_Coord it_y;
2531
2532              it = wd->anchor_item;
2533              it_y = wd->anchor_y;
2534              elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2535                                               it->block->y + it->y + it_y);
2536              wd->anchor_item = it;
2537              wd->anchor_y = it_y;
2538           }
2539 #endif
2540      }
2541    t = ecore_time_get();
2542    if (did_must_recalc)
2543      {
2544         if (!wd->must_recalc_idler)
2545           wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2546      }
2547    wd->calc_job = NULL;
2548    evas_object_smart_changed(wd->pan_smart);
2549    evas_event_thaw(evas_object_evas_get(wd->obj));
2550    evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2551 }
2552
2553 static void
2554 _update_job(void *data)
2555 {
2556    Widget_Data *wd = data;
2557    Eina_List *l2;
2558    Item_Block *itb;
2559    int num, num0;
2560    Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2561    if (!wd) return;
2562    wd->update_job = NULL;
2563    num = 0;
2564
2565    evas_event_freeze(evas_object_evas_get(wd->obj));
2566    EINA_INLIST_FOREACH(wd->blocks, itb)
2567      {
2568         Evas_Coord itminw, itminh;
2569         Elm_Genlist_Item *it;
2570
2571         if (!itb->updateme)
2572           {
2573              num += itb->count;
2574              if (position)
2575                _item_block_position(itb, num);
2576              continue;
2577           }
2578         num0 = num;
2579         recalc = EINA_FALSE;
2580         EINA_LIST_FOREACH(itb->items, l2, it)
2581           {
2582              if (it->updateme)
2583                {
2584                   itminw = it->minw;
2585                   itminh = it->minh;
2586
2587                   it->updateme = EINA_FALSE;
2588                   if (it->realized)
2589                     {
2590                        _item_unrealize(it, EINA_FALSE);
2591                        _item_realize(it, num, EINA_FALSE);
2592                        position = EINA_TRUE;
2593                     }
2594                   else
2595                     {
2596                        _item_realize(it, num, EINA_TRUE);
2597                        _item_unrealize(it, EINA_TRUE);
2598                     }
2599                   if ((it->minw != itminw) || (it->minh != itminh))
2600                     recalc = EINA_TRUE;
2601                }
2602              num++;
2603           }
2604         itb->updateme = EINA_FALSE;
2605         if (recalc)
2606           {
2607              position = EINA_TRUE;
2608              itb->changed = EINA_TRUE;
2609              _item_block_recalc(itb, num0, EINA_FALSE);
2610              _item_block_position(itb, num0);
2611           }
2612      }
2613    if (position)
2614      {
2615         if (wd->calc_job) ecore_job_del(wd->calc_job);
2616         wd->calc_job = ecore_job_add(_calc_job, wd);
2617      }
2618    evas_event_thaw(evas_object_evas_get(wd->obj));
2619    evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2620 }
2621
2622 static void
2623 _changed_job(void *data)
2624 {
2625    Widget_Data *wd = data; Eina_List *l2;
2626    Item_Block *itb;
2627    int num, num0, position = 0;
2628    Eina_Bool width_changed = EINA_FALSE, height_changed = EINA_FALSE;
2629    if (!wd) return;
2630    wd->changed_job = NULL;
2631    num = 0;
2632    EINA_INLIST_FOREACH(wd->blocks, itb)
2633      {
2634         Evas_Coord itminw, itminh;
2635         Elm_Genlist_Item *it;
2636
2637         if (!itb->changeme)
2638           {
2639              num += itb->count;
2640              if (position)
2641                _item_block_position(itb, num);
2642              continue;
2643           }
2644         num0 = num;
2645         width_changed = height_changed = EINA_FALSE;
2646         EINA_LIST_FOREACH(itb->items, l2, it)
2647           {
2648              if ((!it->mincalcd) && (it->realized))
2649                {
2650                   Evas_Coord mw = -1, mh = -1;
2651                   itminw = it->minw;
2652                   itminh = it->minh;
2653
2654                   if (it->wd->height_for_width) mw = it->wd->w;
2655                   if (!it->display_only)
2656                     elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2657                   if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2658                   edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2659                   if (!it->display_only)
2660                     elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2661                   it->w = it->minw = mw;
2662                   it->h = it->minh = mh;
2663                   it->mincalcd = EINA_TRUE;
2664
2665                   //if ((it->minw != itminw) || (it->minh != itminh))
2666                   //if ((it->minh != itminh))
2667                   //  recalc = 1;
2668                   if ((it->minw != itminw))
2669                     width_changed = EINA_TRUE;
2670                   if ((it->minh != itminh))
2671                     height_changed = EINA_TRUE;
2672
2673                   if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2674                     {
2675                        it->wd->group_item_width = mw;
2676                        it->wd->group_item_height = mh;
2677                     }
2678                   else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2679                     {
2680                        it->wd->item_width = mw;
2681                        it->wd->item_height = mh;
2682                     }
2683                }
2684              num++;
2685           }
2686         itb->changeme = EINA_FALSE;
2687         // TODO: why this is separated.
2688         if (height_changed)
2689           {
2690              position = 1;
2691              itb->changed = EINA_TRUE;
2692              _item_block_recalc(itb, num0, 0);
2693              _item_block_position(itb, num0);
2694           }
2695         else if (width_changed)
2696           {
2697              _item_block_position(itb, num0);
2698           }
2699      }
2700    if (position)
2701      {
2702         if (wd->calc_job) ecore_job_del(wd->calc_job);
2703         wd->calc_job = ecore_job_add(_calc_job, wd);
2704      }
2705 }
2706
2707 static void
2708 _pan_set(Evas_Object *obj,
2709          Evas_Coord   x,
2710          Evas_Coord   y)
2711 {
2712    Pan *sd = evas_object_smart_data_get(obj);
2713 #ifdef ANCHOR_ITEM
2714    Item_Block *itb;
2715 #endif
2716
2717    //   Evas_Coord ow, oh;
2718    //   evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2719    //   ow = sd->wd->minw - ow;
2720    //   if (ow < 0) ow = 0;
2721    //   oh = sd->wd->minh - oh;
2722    //   if (oh < 0) oh = 0;
2723    //   if (x < 0) x = 0;
2724    //   if (y < 0) y = 0;
2725    //   if (x > ow) x = ow;
2726    //   if (y > oh) y = oh;
2727    if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2728    sd->wd->pan_x = x;
2729    sd->wd->pan_y = y;
2730
2731 #ifdef ANCHOR_ITEM
2732    EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2733      {
2734         if ((itb->y + itb->h) > y)
2735           {
2736              Elm_Genlist_Item *it;
2737              Eina_List *l2;
2738
2739              EINA_LIST_FOREACH(itb->items, l2, it)
2740                {
2741                   if ((itb->y + it->y) >= y)
2742                     {
2743                        sd->wd->anchor_item = it;
2744                        sd->wd->anchor_y = -(itb->y + it->y - y);
2745                        goto done;
2746                     }
2747                }
2748           }
2749      }
2750 done:
2751 #endif
2752    if(!sd->wd->item_moving_effect_timer) evas_object_smart_changed(obj);
2753 }
2754
2755 static void
2756 _pan_get(Evas_Object *obj,
2757          Evas_Coord  *x,
2758          Evas_Coord  *y)
2759 {
2760    Pan *sd = evas_object_smart_data_get(obj);
2761
2762    if (x) *x = sd->wd->pan_x;
2763    if (y) *y = sd->wd->pan_y;
2764 }
2765
2766 static void
2767 _pan_max_get(Evas_Object *obj,
2768              Evas_Coord  *x,
2769              Evas_Coord  *y)
2770 {
2771    Pan *sd = evas_object_smart_data_get(obj);
2772    Evas_Coord ow, oh;
2773
2774    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2775    ow = sd->wd->minw - ow;
2776    if (ow < 0) ow = 0;
2777    oh = sd->wd->minh - oh;
2778    if (oh < 0) oh = 0;
2779    if (x) *x = ow;
2780    if (y) *y = oh;
2781 }
2782
2783 static void
2784 _pan_min_get(Evas_Object *obj __UNUSED__,
2785              Evas_Coord  *x,
2786              Evas_Coord  *y)
2787 {
2788    if (x) *x = 0;
2789    if (y) *y = 0;
2790 }
2791
2792 static void
2793 _pan_child_size_get(Evas_Object *obj,
2794                     Evas_Coord  *w,
2795                     Evas_Coord  *h)
2796 {
2797    Pan *sd = evas_object_smart_data_get(obj);
2798
2799    if (w) *w = sd->wd->minw;
2800    if (h) *h = sd->wd->minh;
2801 }
2802
2803 static void
2804 _pan_add(Evas_Object *obj)
2805 {
2806    Pan *sd;
2807    Evas_Object_Smart_Clipped_Data *cd;
2808
2809    _pan_sc.add(obj);
2810    cd = evas_object_smart_data_get(obj);
2811    sd = ELM_NEW(Pan);
2812    if (!sd) return;
2813    sd->__clipped_data = *cd;
2814    free(cd);
2815    evas_object_smart_data_set(obj, sd);
2816 }
2817
2818 static void
2819 _pan_del(Evas_Object *obj)
2820 {
2821    Pan *sd = evas_object_smart_data_get(obj);
2822
2823    if (!sd) return;
2824    if (sd->resize_job)
2825      {
2826         ecore_job_del(sd->resize_job);
2827         sd->resize_job = NULL;
2828      }
2829    _pan_sc.del(obj);
2830 }
2831
2832 static void
2833 _pan_resize_job(void *data)
2834 {
2835    Pan *sd = data;
2836    _sizing_eval(sd->wd->obj);
2837    sd->resize_job = NULL;
2838 }
2839
2840 static void
2841 _pan_resize(Evas_Object *obj,
2842             Evas_Coord   w,
2843             Evas_Coord   h)
2844 {
2845    Pan *sd = evas_object_smart_data_get(obj);
2846    Evas_Coord ow, oh;
2847
2848    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2849    if ((ow == w) && (oh == h)) return;
2850    if ((sd->wd->height_for_width) && (ow != w))
2851      {
2852         if (sd->resize_job) ecore_job_del(sd->resize_job);
2853         sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2854      }
2855    if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2856    sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2857 }
2858
2859 static void
2860 _pan_calculate(Evas_Object *obj)
2861 {
2862    Pan *sd = evas_object_smart_data_get(obj);
2863    Item_Block *itb;
2864    Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2865    static Evas_Coord old_pan_y = 0;
2866    int in = 0;
2867    Elm_Genlist_Item *git;
2868    Eina_List *l;
2869
2870    evas_event_freeze(evas_object_evas_get(obj));
2871    evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2872    evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2873    EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2874      {
2875         git->want_realize = EINA_FALSE;
2876      }
2877    EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2878      {
2879         itb->w = sd->wd->minw;
2880         if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2881                                 itb->y - sd->wd->pan_y + oy,
2882                                 itb->w, itb->h,
2883                                 cvx, cvy, cvw, cvh))
2884           {
2885              if ((!itb->realized) || (itb->changed))
2886                _item_block_realize(itb, in, 0);
2887              _item_block_position(itb, in);
2888           }
2889         else
2890           {
2891              if (itb->realized) _item_block_unrealize(itb);
2892           }
2893         in += itb->count;
2894      }
2895    if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2896       _group_items_recalc(sd->wd);
2897
2898    if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2899      {
2900         if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
2901         else sd->wd->reorder_pan_move = EINA_FALSE;
2902         evas_object_raise(sd->wd->reorder_it->edit_obj);
2903         old_pan_y = sd->wd->pan_y;
2904      }
2905
2906       if (sd->wd->effect_mode &&
2907           ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
2908            (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
2909            (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
2910         {
2911            if (!sd->wd->item_moving_effect_timer)
2912              {
2913                 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2914                    _item_flip_effect_show(sd->wd->expand_item);
2915
2916                 evas_object_raise(sd->wd->alpha_bg);
2917                 evas_object_show(sd->wd->alpha_bg);
2918                 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
2919                 sd->wd->start_time = current_time_get();
2920                 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2921              }
2922         }
2923       else _item_auto_scroll(sd->wd);
2924    evas_event_thaw(evas_object_evas_get(obj));
2925    evas_event_thaw_eval(evas_object_evas_get(obj));
2926 }
2927
2928 static void
2929 _pan_move(Evas_Object *obj,
2930           Evas_Coord   x __UNUSED__,
2931           Evas_Coord   y __UNUSED__)
2932 {
2933    Pan *sd = evas_object_smart_data_get(obj);
2934
2935    if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2936    sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2937 }
2938
2939 static void
2940 _hold_on(void        *data __UNUSED__,
2941          Evas_Object *obj,
2942          void        *event_info __UNUSED__)
2943 {
2944    Widget_Data *wd = elm_widget_data_get(obj);
2945    if (!wd) return;
2946    elm_smart_scroller_hold_set(wd->scr, 1);
2947 }
2948
2949 static void
2950 _hold_off(void        *data __UNUSED__,
2951           Evas_Object *obj,
2952           void        *event_info __UNUSED__)
2953 {
2954    Widget_Data *wd = elm_widget_data_get(obj);
2955    if (!wd) return;
2956    elm_smart_scroller_hold_set(wd->scr, 0);
2957 }
2958
2959 static void
2960 _freeze_on(void        *data __UNUSED__,
2961            Evas_Object *obj,
2962            void        *event_info __UNUSED__)
2963 {
2964    Widget_Data *wd = elm_widget_data_get(obj);
2965    if (!wd) return;
2966    elm_smart_scroller_freeze_set(wd->scr, 1);
2967 }
2968
2969 static void
2970 _freeze_off(void        *data __UNUSED__,
2971             Evas_Object *obj,
2972             void        *event_info __UNUSED__)
2973 {
2974    Widget_Data *wd = elm_widget_data_get(obj);
2975    if (!wd) return;
2976    elm_smart_scroller_freeze_set(wd->scr, 0);
2977 }
2978
2979 static void
2980 _scroll_edge_left(void        *data,
2981                   Evas_Object *scr __UNUSED__,
2982                   void        *event_info __UNUSED__)
2983 {
2984    Evas_Object *obj = data;
2985    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
2986 }
2987
2988 static void
2989 _scroll_edge_right(void        *data,
2990                    Evas_Object *scr __UNUSED__,
2991                    void        *event_info __UNUSED__)
2992 {
2993    Evas_Object *obj = data;
2994    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
2995 }
2996
2997 static void
2998 _scroll_edge_top(void        *data,
2999                  Evas_Object *scr __UNUSED__,
3000                  void        *event_info __UNUSED__)
3001 {
3002    Evas_Object *obj = data;
3003    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
3004 }
3005
3006 static void
3007 _scroll_edge_bottom(void        *data,
3008                     Evas_Object *scr __UNUSED__,
3009                     void        *event_info __UNUSED__)
3010 {
3011    Evas_Object *obj = data;
3012    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
3013 }
3014
3015 static void
3016 _mode_item_realize(Elm_Genlist_Item *it)
3017 {
3018    char buf[1024];
3019
3020    if ((it->mode_view) || (it->delete_me)) return;
3021
3022    evas_event_freeze(evas_object_evas_get(it->wd->obj));
3023    it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
3024    edje_object_scale_set(it->mode_view,
3025                          elm_widget_scale_get(it->base.widget) *
3026                          _elm_config->scale);
3027    evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
3028    elm_widget_sub_object_add(it->base.widget, it->mode_view);
3029
3030    strncpy(buf, "item", sizeof(buf));
3031    if (it->wd->compress)
3032      strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3033
3034    if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3035    strncat(buf, "/", sizeof(buf) - strlen(buf));
3036    strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3037
3038    _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
3039                          elm_widget_style_get(it->base.widget));
3040    edje_object_mirrored_set(it->mode_view,
3041                             elm_widget_mirrored_get(it->base.widget));
3042
3043    /* signal callback add */
3044    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3045                                   _mouse_down, it);
3046    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3047                                   _mouse_up, it);
3048    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3049                                   _mouse_move, it);
3050
3051    /* label_get, icon_get, state_get */
3052    if (it->itc->func.label_get)
3053      {
3054         const Eina_List *l;
3055         const char *key;
3056
3057         it->mode_labels =
3058            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3059                                                           "labels"));
3060         EINA_LIST_FOREACH(it->mode_labels, l, key)
3061           {
3062              char *s = it->itc->func.label_get
3063                 ((void *)it->base.data, it->base.widget, l->data);
3064
3065              if (s)
3066                {
3067                   edje_object_part_text_set(it->mode_view, l->data, s);
3068                   free(s);
3069                }
3070           }
3071      }
3072    if (it->itc->func.icon_get)
3073      {
3074         const Eina_List *l;
3075         const char *key;
3076
3077         it->mode_icons =
3078            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3079                                                           "icons"));
3080         EINA_LIST_FOREACH(it->mode_icons, l, key)
3081          {
3082            Evas_Object *ic = it->itc->func.icon_get
3083                 ((void *)it->base.data, it->base.widget, l->data);
3084
3085              if (ic)
3086                {
3087                   it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
3088                   edje_object_part_swallow(it->mode_view, key, ic);
3089                   evas_object_show(ic);
3090                   elm_widget_sub_object_add(it->base.widget, ic);
3091                   if (it->disabled)
3092                     elm_widget_disabled_set(ic, EINA_TRUE);
3093                }
3094           }
3095      }
3096    if (it->itc->func.state_get)
3097      {
3098         const Eina_List *l;
3099         const char *key;
3100
3101         it->mode_states =
3102            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3103                                                           "states"));
3104         EINA_LIST_FOREACH(it->mode_states, l, key)
3105           {
3106              Eina_Bool on = it->itc->func.state_get
3107                 ((void *)it->base.data, it->base.widget, l->data);
3108
3109              if (on)
3110                {
3111                   snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
3112                   edje_object_signal_emit(it->mode_view, buf, "elm");
3113                }
3114           }
3115      }
3116
3117    edje_object_part_swallow(it->mode_view,
3118                             edje_object_data_get(it->mode_view, "mode_part"),
3119                             it->base.view);
3120
3121    it->want_unrealize = EINA_FALSE;
3122    evas_event_thaw(evas_object_evas_get(it->wd->obj));
3123    evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3124 }
3125
3126 static void
3127 _mode_item_unrealize(Elm_Genlist_Item *it)
3128 {
3129    Widget_Data *wd = it->wd;
3130    Evas_Object *icon;
3131    if (!it->mode_view) return;
3132
3133    evas_event_freeze(evas_object_evas_get(it->wd->obj));
3134    elm_widget_stringlist_free(it->mode_labels);
3135    it->mode_labels = NULL;
3136    elm_widget_stringlist_free(it->mode_icons);
3137    it->mode_icons = NULL;
3138    elm_widget_stringlist_free(it->mode_states);
3139
3140    EINA_LIST_FREE(it->mode_icon_objs, icon)
3141      evas_object_del(icon);
3142
3143    edje_object_part_unswallow(it->mode_view, it->base.view);
3144    evas_object_smart_member_add(it->base.view, wd->pan_smart);
3145    evas_object_del(it->mode_view);
3146    it->mode_view = NULL;
3147
3148    if (wd->mode_item == it)
3149      wd->mode_item = NULL;
3150    evas_event_thaw(evas_object_evas_get(it->wd->obj));
3151    evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3152 }
3153
3154 static void
3155 _item_mode_set(Elm_Genlist_Item *it)
3156 {
3157    if (!it) return;
3158    Widget_Data *wd = it->wd;
3159    if (!wd) return;
3160    char buf[1024];
3161
3162    wd->mode_item = it;
3163    it->nocache = EINA_TRUE;
3164
3165    if (wd->scr_hold_timer)
3166      {
3167         ecore_timer_del(wd->scr_hold_timer);
3168         wd->scr_hold_timer = NULL;
3169      }
3170    elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3171    wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3172
3173    evas_event_freeze(evas_object_evas_get(it->wd->obj));
3174    _mode_item_realize(it);
3175    _item_position(it, it->mode_view);
3176    evas_event_thaw(evas_object_evas_get(it->wd->obj));
3177    evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3178
3179    snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3180    edje_object_signal_emit(it->mode_view, buf, "elm");
3181 }
3182
3183 static void
3184 _item_mode_unset(Widget_Data *wd)
3185 {
3186    if (!wd) return;
3187    if (!wd->mode_item) return;
3188    char buf[1024], buf2[1024];
3189    Elm_Genlist_Item *it;
3190
3191    it = wd->mode_item;
3192    it->nocache = EINA_TRUE;
3193
3194    snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3195    snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3196
3197    edje_object_signal_emit(it->mode_view, buf, "elm");
3198    edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3199
3200    wd->mode_item = NULL;
3201 }
3202
3203 EAPI Evas_Object *
3204 elm_genlist_add(Evas_Object *parent)
3205 {
3206    Evas_Object *obj;
3207    Evas *e;
3208    Widget_Data *wd;
3209    Evas_Coord minw, minh;
3210    static Evas_Smart *smart = NULL;
3211
3212    if (!smart)
3213      {
3214         static Evas_Smart_Class sc;
3215
3216         evas_object_smart_clipped_smart_set(&_pan_sc);
3217         sc = _pan_sc;
3218         sc.name = "elm_genlist_pan";
3219         sc.version = EVAS_SMART_CLASS_VERSION;
3220         sc.add = _pan_add;
3221         sc.del = _pan_del;
3222         sc.resize = _pan_resize;
3223         sc.move = _pan_move;
3224         sc.calculate = _pan_calculate;
3225         if (!(smart = evas_smart_class_new(&sc))) return NULL;
3226      }
3227
3228    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3229
3230    ELM_SET_WIDTYPE(widtype, "genlist");
3231    elm_widget_type_set(obj, "genlist");
3232    elm_widget_sub_object_add(parent, obj);
3233    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3234    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3235    elm_widget_data_set(obj, wd);
3236    elm_widget_del_hook_set(obj, _del_hook);
3237    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3238    elm_widget_theme_hook_set(obj, _theme_hook);
3239    elm_widget_can_focus_set(obj, EINA_TRUE);
3240    elm_widget_event_hook_set(obj, _event_hook);
3241    elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3242
3243    wd->scr = elm_smart_scroller_add(e);
3244    elm_smart_scroller_widget_set(wd->scr, obj);
3245    elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3246                                        elm_widget_style_get(obj));
3247    elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3248                                        _elm_config->thumbscroll_bounce_enable);
3249    elm_widget_resize_object_set(obj, wd->scr);
3250
3251    evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3252    evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3253                                   obj);
3254    evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3255    evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3256                                   obj);
3257
3258    wd->obj = obj;
3259    wd->mode = ELM_LIST_SCROLL;
3260    wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3261    wd->item_cache_max = wd->max_items_per_block * 2;
3262    wd->longpress_timeout = _elm_config->longpress_timeout;
3263    wd->effect_mode = _elm_config->effect_enable;
3264
3265    evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3266    evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3267    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3268    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3269
3270    wd->pan_smart = evas_object_smart_add(e, smart);
3271    wd->pan = evas_object_smart_data_get(wd->pan_smart);
3272    wd->pan->wd = wd;
3273
3274    elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3275                                      _pan_set, _pan_get, _pan_max_get,
3276                                      _pan_min_get, _pan_child_size_get);
3277
3278    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3279                              &minw, &minh);
3280    evas_object_size_hint_min_set(obj, minw, minh);
3281
3282    evas_object_smart_callbacks_descriptions_set(obj, _signals);
3283    _mirrored_set(obj, elm_widget_mirrored_get(obj));
3284    _sizing_eval(obj);
3285    return obj;
3286 }
3287
3288 static Elm_Genlist_Item *
3289 _item_new(Widget_Data                  *wd,
3290           const Elm_Genlist_Item_Class *itc,
3291           const void                   *data,
3292           Elm_Genlist_Item             *parent,
3293           Elm_Genlist_Item_Flags        flags,
3294           Evas_Smart_Cb                 func,
3295           const void                   *func_data)
3296 {
3297    Elm_Genlist_Item *it;
3298
3299    it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3300    if (!it) return NULL;
3301    it->wd = wd;
3302    it->itc = itc;
3303    it->base.data = data;
3304    it->parent = parent;
3305    it->flags = flags;
3306    it->func.func = func;
3307    it->func.data = func_data;
3308    it->mouse_cursor = NULL;
3309    it->expanded_depth = 0;
3310
3311    if (it->parent)
3312      {
3313         if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3314           it->group_item = parent;
3315         else if (it->parent->group_item)
3316           it->group_item = it->parent->group_item;
3317      }
3318    return it;
3319 }
3320
3321 static void
3322 _item_block_add(Widget_Data      *wd,
3323                 Elm_Genlist_Item *it)
3324 {
3325    Item_Block *itb = NULL;
3326
3327    if (!it->rel)
3328      {
3329 newblock:
3330         if (it->rel)
3331           {
3332              itb = calloc(1, sizeof(Item_Block));
3333              if (!itb) return;
3334              itb->wd = wd;
3335              if (!it->rel->block)
3336                {
3337                   wd->blocks =
3338                     eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3339                   itb->items = eina_list_append(itb->items, it);
3340                }
3341              else
3342                {
3343                   if (it->before)
3344                     {
3345                        wd->blocks = eina_inlist_prepend_relative
3346                            (wd->blocks, EINA_INLIST_GET(itb),
3347                            EINA_INLIST_GET(it->rel->block));
3348                        itb->items =
3349                          eina_list_prepend_relative(itb->items, it, it->rel);
3350                     }
3351                   else
3352                     {
3353                        wd->blocks = eina_inlist_append_relative
3354                            (wd->blocks, EINA_INLIST_GET(itb),
3355                            EINA_INLIST_GET(it->rel->block));
3356                        itb->items =
3357                          eina_list_append_relative(itb->items, it, it->rel);
3358                     }
3359                }
3360           }
3361         else
3362           {
3363              if (it->before)
3364                {
3365                   if (wd->blocks)
3366                     {
3367                        itb = (Item_Block *)(wd->blocks);
3368                        if (itb->count >= wd->max_items_per_block)
3369                          {
3370                             itb = calloc(1, sizeof(Item_Block));
3371                             if (!itb) return;
3372                             itb->wd = wd;
3373                             wd->blocks =
3374                               eina_inlist_prepend(wd->blocks,
3375                                                   EINA_INLIST_GET(itb));
3376                          }
3377                     }
3378                   else
3379                     {
3380                        itb = calloc(1, sizeof(Item_Block));
3381                        if (!itb) return;
3382                        itb->wd = wd;
3383                        wd->blocks =
3384                          eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3385                     }
3386                   itb->items = eina_list_prepend(itb->items, it);
3387                }
3388              else
3389                {
3390                   if (wd->blocks)
3391                     {
3392                        itb = (Item_Block *)(wd->blocks->last);
3393                        if (itb->count >= wd->max_items_per_block)
3394                          {
3395                             itb = calloc(1, sizeof(Item_Block));
3396                             if (!itb) return;
3397                             itb->wd = wd;
3398                             wd->blocks =
3399                               eina_inlist_append(wd->blocks,
3400                                                  EINA_INLIST_GET(itb));
3401                          }
3402                     }
3403                   else
3404                     {
3405                        itb = calloc(1, sizeof(Item_Block));
3406                        if (!itb) return;
3407                        itb->wd = wd;
3408                        wd->blocks =
3409                          eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3410                     }
3411                   itb->items = eina_list_append(itb->items, it);
3412                }
3413           }
3414      }
3415    else
3416      {
3417         itb = it->rel->block;
3418         if (!itb) goto newblock;
3419         if (it->before)
3420           itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3421         else
3422           itb->items = eina_list_append_relative(itb->items, it, it->rel);
3423      }
3424    itb->count++;
3425    itb->changed = EINA_TRUE;
3426    it->block = itb;
3427    if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3428    itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3429    if (it->rel)
3430      {
3431         it->rel->relcount--;
3432         if ((it->rel->delete_me) && (!it->rel->relcount))
3433           _item_del(it->rel);
3434         it->rel = NULL;
3435      }
3436    if (itb->count > itb->wd->max_items_per_block)
3437      {
3438         int newc;
3439         Item_Block *itb2;
3440         Elm_Genlist_Item *it2;
3441
3442         newc = itb->count / 2;
3443         itb2 = calloc(1, sizeof(Item_Block));
3444         if (!itb2) return;
3445         itb2->wd = wd;
3446         wd->blocks =
3447           eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3448                                       EINA_INLIST_GET(itb));
3449         itb2->changed = EINA_TRUE;
3450         while ((itb->count > newc) && (itb->items))
3451           {
3452              Eina_List *l;
3453
3454              l = eina_list_last(itb->items);
3455              it2 = l->data;
3456              itb->items = eina_list_remove_list(itb->items, l);
3457              itb->count--;
3458
3459              itb2->items = eina_list_prepend(itb2->items, it2);
3460              it2->block = itb2;
3461              itb2->count++;
3462           }
3463      }
3464 }
3465
3466 static int
3467 _queue_process(Widget_Data *wd)
3468 {
3469    int n;
3470    Eina_Bool showme = EINA_FALSE;
3471    double t0, t;
3472
3473    t0 = ecore_time_get();
3474    //evas_event_freeze(evas_object_evas_get(wd->obj));
3475    for (n = 0; (wd->queue) && (n < 128); n++)
3476      {
3477         Elm_Genlist_Item *it;
3478
3479         it = wd->queue->data;
3480         wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3481         it->queued = EINA_FALSE;
3482         _item_block_add(wd, it);
3483         t = ecore_time_get();
3484         if (it->block->changed)
3485           {
3486              showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3487              it->block->changed = 0;
3488           }
3489         if (showme) it->block->showme = EINA_TRUE;
3490         if (eina_inlist_count(wd->blocks) > 1)
3491           {
3492              if ((t - t0) > (ecore_animator_frametime_get())) break;
3493           }
3494      }
3495    //evas_event_thaw(evas_object_evas_get(wd->obj));
3496    //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3497    return n;
3498 }
3499
3500 static Eina_Bool
3501 _idle_process(void *data, Eina_Bool *wakeup)
3502 {
3503    Widget_Data *wd = data;
3504
3505    //xxx
3506    //static double q_start = 0.0;
3507    //if (q_start == 0.0) q_start = ecore_time_get();
3508    //xxx
3509    if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3510    if (!wd->queue)
3511      {
3512         //xxx
3513         //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3514         //xxx
3515         return ECORE_CALLBACK_CANCEL;
3516      }
3517    return ECORE_CALLBACK_RENEW;
3518 }
3519
3520 static Eina_Bool
3521 _item_idle_enterer(void *data)
3522 {
3523    Widget_Data *wd = data;
3524    Eina_Bool wakeup = EINA_FALSE;
3525    Eina_Bool ok = _idle_process(data, &wakeup);
3526
3527    if (wakeup)
3528      {
3529         // wake up mainloop
3530         if (wd->calc_job) ecore_job_del(wd->calc_job);
3531         wd->calc_job = ecore_job_add(_calc_job, wd);
3532      }
3533    if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3534    return ok;
3535 }
3536
3537 static void
3538 _item_queue(Widget_Data      *wd,
3539             Elm_Genlist_Item *it)
3540 {
3541    if (it->queued) return;
3542    it->queued = EINA_TRUE;
3543    wd->queue = eina_list_append(wd->queue, it);
3544 // FIXME: why does a freeze then thaw here cause some genlist
3545 // elm_genlist_item_append() to be much much slower?
3546 //   evas_event_freeze(evas_object_evas_get(wd->obj));
3547    while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3548      {
3549         if (wd->queue_idle_enterer)
3550           {
3551              ecore_idle_enterer_del(wd->queue_idle_enterer);
3552              wd->queue_idle_enterer = NULL;
3553           }
3554         _queue_process(wd);
3555      }
3556 //   evas_event_thaw(evas_object_evas_get(wd->obj));
3557 //   evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3558    if (!wd->queue_idle_enterer)
3559      wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3560 }
3561
3562 EAPI Elm_Genlist_Item *
3563 elm_genlist_item_append(Evas_Object                  *obj,
3564                         const Elm_Genlist_Item_Class *itc,
3565                         const void                   *data,
3566                         Elm_Genlist_Item             *parent,
3567                         Elm_Genlist_Item_Flags        flags,
3568                         Evas_Smart_Cb                 func,
3569                         const void                   *func_data)
3570 {
3571    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3572    Widget_Data *wd = elm_widget_data_get(obj);
3573    if (!wd) return NULL;
3574    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3575                                     func_data);
3576    if (!it) return NULL;
3577    if (!it->parent)
3578      {
3579         if (flags & ELM_GENLIST_ITEM_GROUP)
3580           wd->group_items = eina_list_append(wd->group_items, it);
3581         wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3582         it->rel = NULL;
3583      }
3584    else
3585      {
3586         Elm_Genlist_Item *it2 = NULL;
3587         Eina_List *ll = eina_list_last(it->parent->items);
3588         if (ll) it2 = ll->data;
3589         it->parent->items = eina_list_append(it->parent->items, it);
3590         if (!it2) it2 = it->parent;
3591         if (it2->delete_me)
3592            it2 = elm_genlist_item_prev_get(it2);
3593         wd->items =
3594           eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3595                                       EINA_INLIST_GET(it2));
3596         it->rel = it2;
3597         it->rel->relcount++;
3598      }
3599    it->before = EINA_FALSE;
3600    _item_queue(wd, it);
3601    return it;
3602 }
3603
3604 EAPI Elm_Genlist_Item *
3605 elm_genlist_item_prepend(Evas_Object                  *obj,
3606                          const Elm_Genlist_Item_Class *itc,
3607                          const void                   *data,
3608                          Elm_Genlist_Item             *parent,
3609                          Elm_Genlist_Item_Flags        flags,
3610                          Evas_Smart_Cb                 func,
3611                          const void                   *func_data)
3612 {
3613    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3614    Widget_Data *wd = elm_widget_data_get(obj);
3615    if (!wd) return NULL;
3616    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3617                                     func_data);
3618    if (!it) return NULL;
3619    if (!it->parent)
3620      {
3621         if (flags & ELM_GENLIST_ITEM_GROUP)
3622           wd->group_items = eina_list_prepend(wd->group_items, it);
3623         wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3624         it->rel = NULL;
3625      }
3626    else
3627      {
3628         Elm_Genlist_Item *it2 = NULL;
3629         Eina_List *ll = it->parent->items;
3630         if (ll) it2 = ll->data;
3631         it->parent->items = eina_list_prepend(it->parent->items, it);
3632         if (!it2) it2 = it->parent;
3633         if (it2->delete_me)
3634            it2 = elm_genlist_item_next_get(it2);
3635         wd->items =
3636           eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3637                                        EINA_INLIST_GET(it2));
3638         it->rel = it2;
3639         it->rel->relcount++;
3640      }
3641    it->before = EINA_TRUE;
3642    _item_queue(wd, it);
3643    return it;
3644 }
3645
3646 EAPI Elm_Genlist_Item *
3647 elm_genlist_item_insert_after(Evas_Object                  *obj,
3648                               const Elm_Genlist_Item_Class *itc,
3649                               const void                   *data,
3650                               Elm_Genlist_Item             *parent,
3651                               Elm_Genlist_Item             *after,
3652                               Elm_Genlist_Item_Flags        flags,
3653                               Evas_Smart_Cb                 func,
3654                               const void                   *func_data)
3655 {
3656    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3657    EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3658    Widget_Data *wd = elm_widget_data_get(obj);
3659    if (!wd) return NULL;
3660    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3661                                     func_data);
3662    if (!it) return NULL;
3663    /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3664    EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3665
3666    if (!it->parent)
3667      {
3668         if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3669             (after->flags & ELM_GENLIST_ITEM_GROUP))
3670           wd->group_items = eina_list_append_relative(wd->group_items, it,
3671                                                       after);
3672      }
3673    else
3674      {
3675         it->parent->items = eina_list_append_relative(it->parent->items, it,
3676                                                       after);
3677      }
3678    wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3679                                            EINA_INLIST_GET(after));
3680    it->rel = after;
3681    it->rel->relcount++;
3682    it->before = EINA_FALSE;
3683    _item_queue(wd, it);
3684    return it;
3685 }
3686
3687 EAPI Elm_Genlist_Item *
3688 elm_genlist_item_insert_before(Evas_Object                  *obj,
3689                                const Elm_Genlist_Item_Class *itc,
3690                                const void                   *data,
3691                                Elm_Genlist_Item             *parent,
3692                                Elm_Genlist_Item             *before,
3693                                Elm_Genlist_Item_Flags        flags,
3694                                Evas_Smart_Cb                 func,
3695                                const void                   *func_data)
3696 {
3697    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3698    EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3699    Widget_Data *wd = elm_widget_data_get(obj);
3700    if (!wd) return NULL;
3701    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3702                                     func_data);
3703    if (!it) return NULL;
3704    /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
3705    EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3706
3707    if (!it->parent)
3708      {
3709         if ((flags & ELM_GENLIST_ITEM_GROUP) &&
3710             (before->flags & ELM_GENLIST_ITEM_GROUP))
3711           wd->group_items = eina_list_prepend_relative(wd->group_items, it,
3712                                                        before);
3713      }
3714    else
3715      {
3716         it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3717                                                        before);
3718      }
3719    wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3720                                             EINA_INLIST_GET(before));
3721    it->rel = before;
3722    it->rel->relcount++;
3723    it->before = EINA_TRUE;
3724    _item_queue(wd, it);
3725    return it;
3726 }
3727
3728 EAPI void
3729 elm_genlist_clear(Evas_Object *obj)
3730 {
3731    ELM_CHECK_WIDTYPE(obj, widtype);
3732    Widget_Data *wd = elm_widget_data_get(obj);
3733    if (!wd) return;
3734    if (wd->walking > 0)
3735      {
3736         Elm_Genlist_Item *it;
3737
3738         wd->clear_me = EINA_TRUE;
3739         EINA_INLIST_FOREACH(wd->items, it)
3740           {
3741              it->delete_me = EINA_TRUE;
3742           }
3743         return;
3744      }
3745    evas_event_freeze(evas_object_evas_get(wd->obj));
3746    while (wd->items)
3747      {
3748         Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3749         it->nocache = EINA_TRUE;
3750         it->highlighted = EINA_FALSE;
3751 #ifdef ANCHOR_ITEM
3752         if (wd->anchor_item == it)
3753           {
3754              wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3755              if (!wd->anchor_item)
3756                wd->anchor_item =
3757                  ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3758           }
3759 #endif
3760         wd->items = eina_inlist_remove(wd->items, wd->items);
3761         if (it->flags & ELM_GENLIST_ITEM_GROUP)
3762           it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3763         elm_widget_item_pre_notify_del(it);
3764         if (it->realized) _item_unrealize(it, EINA_FALSE);
3765         if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3766           it->itc->func.del((void *)it->base.data, it->base.widget);
3767         if (it->long_timer) ecore_timer_del(it->long_timer);
3768         if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3769         elm_widget_item_del(it);
3770      }
3771    wd->clear_me = EINA_FALSE;
3772    wd->anchor_item = NULL;
3773    while (wd->blocks)
3774      {
3775         Item_Block *itb = (Item_Block *)(wd->blocks);
3776
3777         wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3778         if (itb->items) eina_list_free(itb->items);
3779         free(itb);
3780      }
3781    if (wd->calc_job)
3782      {
3783         ecore_job_del(wd->calc_job);
3784         wd->calc_job = NULL;
3785      }
3786    if (wd->queue_idle_enterer)
3787      {
3788         ecore_idle_enterer_del(wd->queue_idle_enterer);
3789         wd->queue_idle_enterer = NULL;
3790      }
3791    if (wd->must_recalc_idler)
3792      {
3793         ecore_idler_del(wd->must_recalc_idler);
3794         wd->must_recalc_idler = NULL;
3795      }
3796    if (wd->queue)
3797      {
3798         eina_list_free(wd->queue);
3799         wd->queue = NULL;
3800      }
3801    if (wd->selected)
3802      {
3803         eina_list_free(wd->selected);
3804         wd->selected = NULL;
3805      }
3806    if (wd->item_moving_effect_timer)
3807      {
3808         ecore_animator_del(wd->item_moving_effect_timer);
3809         wd->item_moving_effect_timer = NULL;
3810      }
3811    wd->show_item = NULL;
3812    wd->pan_x = 0;
3813    wd->pan_y = 0;
3814    wd->minw = 0;
3815    wd->minh = 0;
3816
3817    if (wd->alpha_bg)
3818       evas_object_del(wd->alpha_bg);
3819    wd->alpha_bg = NULL;
3820
3821    if (wd->pan_smart)
3822      {
3823         evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3824         evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3825      }
3826    _sizing_eval(obj);
3827    evas_event_thaw(evas_object_evas_get(wd->obj));
3828    evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3829 }
3830
3831 EAPI void
3832 elm_genlist_multi_select_set(Evas_Object *obj,
3833                              Eina_Bool    multi)
3834 {
3835    ELM_CHECK_WIDTYPE(obj, widtype);
3836    Widget_Data *wd = elm_widget_data_get(obj);
3837    if (!wd) return;
3838    wd->multi = multi;
3839 }
3840
3841 EAPI Eina_Bool
3842 elm_genlist_multi_select_get(const Evas_Object *obj)
3843 {
3844    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3845    Widget_Data *wd = elm_widget_data_get(obj);
3846    if (!wd) return EINA_FALSE;
3847    return wd->multi;
3848 }
3849
3850 EAPI Elm_Genlist_Item *
3851 elm_genlist_selected_item_get(const Evas_Object *obj)
3852 {
3853    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3854    Widget_Data *wd = elm_widget_data_get(obj);
3855    if (!wd) return NULL;
3856    if (wd->selected) return wd->selected->data;
3857    return NULL;
3858 }
3859
3860 EAPI const Eina_List *
3861 elm_genlist_selected_items_get(const Evas_Object *obj)
3862 {
3863    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3864    Widget_Data *wd = elm_widget_data_get(obj);
3865    if (!wd) return NULL;
3866    return wd->selected;
3867 }
3868
3869 EAPI Eina_List *
3870 elm_genlist_realized_items_get(const Evas_Object *obj)
3871 {
3872    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3873    Widget_Data *wd = elm_widget_data_get(obj);
3874    Eina_List *list = NULL;
3875    Item_Block *itb;
3876    Eina_Bool done = EINA_FALSE;
3877    if (!wd) return NULL;
3878    EINA_INLIST_FOREACH(wd->blocks, itb)
3879      {
3880         if (itb->realized)
3881           {
3882              Eina_List *l;
3883              Elm_Genlist_Item *it;
3884
3885              done = 1;
3886              EINA_LIST_FOREACH(itb->items, l, it)
3887                {
3888                   if (it->realized) list = eina_list_append(list, it);
3889                }
3890           }
3891         else
3892           {
3893              if (done) break;
3894           }
3895      }
3896    return list;
3897 }
3898
3899 EAPI Elm_Genlist_Item *
3900 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3901                            Evas_Coord         x,
3902                            Evas_Coord         y,
3903                            int               *posret)
3904 {
3905    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3906    Widget_Data *wd = elm_widget_data_get(obj);
3907    Evas_Coord ox, oy, ow, oh;
3908    Item_Block *itb;
3909    Evas_Coord lasty;
3910    if (!wd) return NULL;
3911    evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3912    lasty = oy;
3913    EINA_INLIST_FOREACH(wd->blocks, itb)
3914      {
3915         Eina_List *l;
3916         Elm_Genlist_Item *it;
3917
3918         if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3919                                  oy + itb->y - itb->wd->pan_y,
3920                                  itb->w, itb->h, x, y, 1, 1))
3921           continue;
3922         EINA_LIST_FOREACH(itb->items, l, it)
3923           {
3924              Evas_Coord itx, ity;
3925
3926              itx = ox + itb->x + it->x - itb->wd->pan_x;
3927              ity = oy + itb->y + it->y - itb->wd->pan_y;
3928              if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3929                {
3930                   if (posret)
3931                     {
3932                        if (y <= (ity + (it->h / 4))) *posret = -1;
3933                        else if (y >= (ity + it->h - (it->h / 4)))
3934                          *posret = 1;
3935                        else *posret = 0;
3936                     }
3937                   return it;
3938                }
3939              lasty = ity + it->h;
3940           }
3941      }
3942    if (posret)
3943      {
3944         if (y > lasty) *posret = 1;
3945         else *posret = -1;
3946      }
3947    return NULL;
3948 }
3949
3950 EAPI Elm_Genlist_Item *
3951 elm_genlist_first_item_get(const Evas_Object *obj)
3952 {
3953    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3954    Widget_Data *wd = elm_widget_data_get(obj);
3955    if (!wd) return NULL;
3956    if (!wd->items) return NULL;
3957    Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3958    while ((it) && (it->delete_me))
3959      it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3960    return it;
3961 }
3962
3963 EAPI Elm_Genlist_Item *
3964 elm_genlist_last_item_get(const Evas_Object *obj)
3965 {
3966    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3967    Widget_Data *wd = elm_widget_data_get(obj);
3968    if (!wd) return NULL;
3969    if (!wd->items) return NULL;
3970    Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3971    while ((it) && (it->delete_me))
3972      it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3973    return it;
3974 }
3975
3976 EAPI Elm_Genlist_Item *
3977 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3978 {
3979    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3980    while (it)
3981      {
3982         it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3983         if ((it) && (!it->delete_me)) break;
3984      }
3985    return (Elm_Genlist_Item *)it;
3986 }
3987
3988 EAPI Elm_Genlist_Item *
3989 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3990 {
3991    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3992    while (it)
3993      {
3994         it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3995         if ((it) && (!it->delete_me)) break;
3996      }
3997    return (Elm_Genlist_Item *)it;
3998 }
3999
4000 EAPI Evas_Object *
4001 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4002 {
4003    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4004    return it->base.widget;
4005 }
4006
4007 EAPI Elm_Genlist_Item *
4008 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4009 {
4010    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4011    return it->parent;
4012 }
4013
4014 EAPI void
4015 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4016 {
4017    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4018    Elm_Genlist_Item *it2;
4019    Evas_Coord y, h;
4020
4021    if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4022       _item_subitems_clear(it);
4023    else
4024      {
4025         if ((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4026              it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE    )
4027           {
4028              it->wd->expand_item = it;
4029              _item_flip_effect_show(it);
4030              evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4031              it->wd->expand_item_end = y + h;
4032
4033               it2= it;
4034              do {
4035                   it2 = elm_genlist_item_next_get(it2);
4036                   if (!it2) break;
4037              } while (it2->expanded_depth > it->expanded_depth);
4038              if (it2)
4039                 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4040              else
4041                 it->wd->expand_item_gap = 0;
4042
4043              evas_object_raise(it->wd->alpha_bg);
4044              evas_object_show(it->wd->alpha_bg);
4045
4046              it->wd->start_time = current_time_get();
4047              it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4048           }
4049         else
4050            _item_subitems_clear(it);
4051      }
4052 }
4053
4054 EAPI void
4055 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4056                               Eina_Bool         selected)
4057 {
4058    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4059    Widget_Data *wd = elm_widget_data_get(it->base.widget);
4060    if (!wd) return;
4061    if ((it->delete_me) || (it->disabled)) return;
4062    selected = !!selected;
4063    if (it->selected == selected) return;
4064
4065    if (selected)
4066      {
4067         if (!wd->multi)
4068           {
4069              while (wd->selected)
4070                _item_unselect(wd->selected->data);
4071           }
4072         _item_highlight(it);
4073         _item_select(it);
4074      }
4075    else
4076      _item_unselect(it);
4077 }
4078
4079 EAPI Eina_Bool
4080 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4081 {
4082    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4083    return it->selected;
4084 }
4085
4086 EAPI void
4087 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4088                               Eina_Bool         expanded)
4089 {
4090    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4091    if (it->flags != ELM_GENLIST_ITEM_SUBITEMS) return;
4092    if (it->expanded == expanded) return;
4093    it->expanded = expanded;
4094    it->wd->expand_item = it;
4095
4096    if (it->wd->effect_mode && !it->wd->alpha_bg)
4097       it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4098
4099    if (it->expanded)
4100      {
4101         it->wd->auto_scrolled = EINA_FALSE;
4102         it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4103         if (it->realized)
4104           edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4105         evas_object_smart_callback_call(it->base.widget, "expanded", it);
4106      }
4107    else
4108      {
4109         it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4110         if (it->realized)
4111           edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4112         evas_object_smart_callback_call(it->base.widget, "contracted", it);
4113      }
4114 }
4115
4116 EAPI Eina_Bool
4117 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4118 {
4119    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4120    return it->expanded;
4121 }
4122
4123 EAPI int
4124 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4125 {
4126    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4127    return it->expanded_depth;
4128 }
4129
4130 EAPI void
4131 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4132                               Eina_Bool         disabled)
4133 {
4134    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4135    Eina_List *l;
4136    Evas_Object *obj;
4137    if (it->disabled == disabled) return;
4138    if (it->delete_me) return;
4139    it->disabled = disabled;
4140    if (it->selected)
4141      elm_genlist_item_selected_set(it, EINA_FALSE);
4142    if (it->realized)
4143      {
4144         if (it->disabled)
4145           {
4146              edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4147              if (it->edit_obj)
4148                edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
4149           }
4150         else
4151           {
4152              edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4153              if (it->edit_obj)
4154                edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
4155           }
4156         EINA_LIST_FOREACH(it->icon_objs, l, obj)
4157            elm_widget_disabled_set(obj, disabled);
4158      }
4159 }
4160
4161 EAPI Eina_Bool
4162 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4163 {
4164    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4165    if (it->delete_me) return EINA_FALSE;
4166    return it->disabled;
4167 }
4168
4169 EAPI void
4170 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4171                                   Eina_Bool         display_only)
4172 {
4173    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4174    if (it->display_only == display_only) return;
4175    if (it->delete_me) return;
4176    it->display_only = display_only;
4177    it->mincalcd = EINA_FALSE;
4178    it->updateme = EINA_TRUE;
4179    if (it->block) it->block->updateme = EINA_TRUE;
4180    if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4181    it->wd->update_job = ecore_job_add(_update_job, it->wd);
4182 }
4183
4184 EAPI Eina_Bool
4185 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4186 {
4187    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4188    if (it->delete_me) return EINA_FALSE;
4189    return it->display_only;
4190 }
4191
4192 EAPI void
4193 elm_genlist_item_show(Elm_Genlist_Item *it)
4194 {
4195    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4196    Evas_Coord gith = 0;
4197    if (it->delete_me) return;
4198    if ((it->queued) || (!it->mincalcd))
4199      {
4200         it->wd->show_item = it;
4201         it->wd->bring_in = EINA_TRUE;
4202         it->showme = EINA_TRUE;
4203         return;
4204      }
4205    if (it->wd->show_item)
4206      {
4207         it->wd->show_item->showme = EINA_FALSE;
4208         it->wd->show_item = NULL;
4209      }
4210    if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4211      gith = it->group_item->h;
4212    elm_smart_scroller_child_region_show(it->wd->scr,
4213                                         it->x + it->block->x,
4214                                         it->y + it->block->y - gith,
4215                                         it->block->w, it->h);
4216 }
4217
4218 EAPI void
4219 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4220 {
4221    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4222    Evas_Coord gith = 0;
4223    if (it->delete_me) return;
4224    if ((it->queued) || (!it->mincalcd))
4225      {
4226         it->wd->show_item = it;
4227         it->wd->bring_in = EINA_TRUE;
4228         it->showme = EINA_TRUE;
4229         return;
4230      }
4231    if (it->wd->show_item)
4232      {
4233         it->wd->show_item->showme = EINA_FALSE;
4234         it->wd->show_item = NULL;
4235      }
4236    if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4237      gith = it->group_item->h;
4238    elm_smart_scroller_region_bring_in(it->wd->scr,
4239                                       it->x + it->block->x,
4240                                       it->y + it->block->y - gith,
4241                                       it->block->w, it->h);
4242 }
4243
4244 EAPI void
4245 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4246 {
4247    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4248    Evas_Coord ow, oh;
4249    Evas_Coord gith = 0;
4250
4251    if (it->delete_me) return;
4252    if ((it->queued) || (!it->mincalcd))
4253      {
4254         it->wd->show_item = it;
4255         it->wd->bring_in = EINA_TRUE;
4256         it->showme = EINA_TRUE;
4257         return;
4258      }
4259    if (it->wd->show_item)
4260      {
4261         it->wd->show_item->showme = EINA_FALSE;
4262         it->wd->show_item = NULL;
4263      }
4264    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4265    if (it->group_item) gith = it->group_item->h;
4266    elm_smart_scroller_child_region_show(it->wd->scr,
4267                                         it->x + it->block->x,
4268                                         it->y + it->block->y - gith,
4269                                         it->block->w, oh);
4270 }
4271
4272 EAPI void
4273 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4274 {
4275    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4276    Evas_Coord ow, oh;
4277    Evas_Coord gith = 0;
4278
4279    if (it->delete_me) return;
4280    if ((it->queued) || (!it->mincalcd))
4281      {
4282         it->wd->show_item = it;
4283         it->wd->bring_in = EINA_TRUE;
4284         it->showme = EINA_TRUE;
4285         return;
4286      }
4287    if (it->wd->show_item)
4288      {
4289         it->wd->show_item->showme = EINA_FALSE;
4290         it->wd->show_item = NULL;
4291      }
4292    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4293    if (it->group_item) gith = it->group_item->h;
4294    elm_smart_scroller_region_bring_in(it->wd->scr,
4295                                       it->x + it->block->x,
4296                                       it->y + it->block->y - gith,
4297                                       it->block->w, oh);
4298 }
4299
4300 EAPI void
4301 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4302 {
4303    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4304    Evas_Coord ow, oh;
4305
4306    if (it->delete_me) return;
4307    if ((it->queued) || (!it->mincalcd))
4308      {
4309         it->wd->show_item = it;
4310         it->wd->bring_in = EINA_TRUE;
4311         it->showme = EINA_TRUE;
4312         return;
4313      }
4314    if (it->wd->show_item)
4315      {
4316         it->wd->show_item->showme = EINA_FALSE;
4317         it->wd->show_item = NULL;
4318      }
4319    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4320    elm_smart_scroller_child_region_show(it->wd->scr,
4321                                         it->x + it->block->x,
4322                                         it->y + it->block->y - oh / 2 +
4323                                         it->h / 2, it->block->w, oh);
4324 }
4325
4326 EAPI void
4327 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4328 {
4329    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4330    Evas_Coord ow, oh;
4331
4332    if (it->delete_me) return;
4333    if ((it->queued) || (!it->mincalcd))
4334      {
4335         it->wd->show_item = it;
4336         it->wd->bring_in = EINA_TRUE;
4337         it->showme = EINA_TRUE;
4338         return;
4339      }
4340    if (it->wd->show_item)
4341      {
4342         it->wd->show_item->showme = EINA_FALSE;
4343         it->wd->show_item = NULL;
4344      }
4345    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4346    elm_smart_scroller_region_bring_in(it->wd->scr,
4347                                       it->x + it->block->x,
4348                                       it->y + it->block->y - oh / 2 + it->h / 2,
4349                                       it->block->w, oh);
4350 }
4351
4352 EAPI void
4353 elm_genlist_item_del(Elm_Genlist_Item *it)
4354 {
4355    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4356    if ((it->relcount > 0) || (it->walking > 0))
4357      {
4358         elm_widget_item_pre_notify_del(it);
4359         elm_genlist_item_subitems_clear(it);
4360         it->delete_me = EINA_TRUE;
4361         if (it->wd->show_item == it) it->wd->show_item = NULL;
4362         if (it->selected)
4363           it->wd->selected = eina_list_remove(it->wd->selected,
4364                                               it);
4365         if (it->block)
4366           {
4367              if (it->realized) _item_unrealize(it, EINA_FALSE);
4368              it->block->changed = EINA_TRUE;
4369              if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4370              it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4371           }
4372         if (it->itc->func.del)
4373           it->itc->func.del((void *)it->base.data, it->base.widget);
4374         return;
4375      }
4376    _item_del(it);
4377 }
4378
4379 EAPI void
4380 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4381                           const void       *data)
4382 {
4383    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4384    elm_widget_item_data_set(it, data);
4385    elm_genlist_item_update(it);
4386 }
4387
4388 EAPI void *
4389 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4390 {
4391    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4392    return elm_widget_item_data_get(it);
4393 }
4394
4395 EAPI void
4396 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4397 {
4398    Evas_Object *icon;
4399    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4400    EINA_LIST_FREE(it->icon_objs, icon)
4401      {
4402         elm_widget_sub_object_del(it->base.widget, icon);
4403         evas_object_smart_member_del(icon);
4404         evas_object_hide(icon);
4405      }
4406 }
4407
4408 EAPI const Evas_Object *
4409 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4410 {
4411    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4412    return it->base.view;
4413 }
4414
4415 EAPI void
4416 elm_genlist_item_update(Elm_Genlist_Item *it)
4417 {
4418    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4419    if (!it->block) return;
4420    if (it->delete_me) return;
4421    it->mincalcd = EINA_FALSE;
4422    it->updateme = EINA_TRUE;
4423    it->block->updateme = EINA_TRUE;
4424    if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4425    it->wd->update_job = ecore_job_add(_update_job, it->wd);
4426 }
4427
4428 EAPI void
4429 elm_genlist_item_item_class_update(Elm_Genlist_Item             *it,
4430                                    const Elm_Genlist_Item_Class *itc)
4431 {
4432    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4433    if (!it->block) return;
4434    EINA_SAFETY_ON_NULL_RETURN(itc);
4435    if (it->delete_me) return;
4436    it->itc = itc;
4437    it->nocache = EINA_TRUE;
4438    elm_genlist_item_update(it);
4439 }
4440
4441 EAPI const Elm_Genlist_Item_Class *
4442 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4443 {
4444    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4445    if (it->delete_me) return NULL;
4446    return it->itc;
4447 }
4448 static Evas_Object *
4449 _elm_genlist_item_label_create(void        *data,
4450                                Evas_Object *obj,
4451                                void        *item __UNUSED__)
4452 {
4453    Evas_Object *label = elm_label_add(obj);
4454    if (!label)
4455      return NULL;
4456    elm_object_style_set(label, "tooltip");
4457    elm_object_text_set(label, data);
4458    return label;
4459 }
4460
4461 static void
4462 _elm_genlist_item_label_del_cb(void        *data,
4463                                Evas_Object *obj __UNUSED__,
4464                                void        *event_info __UNUSED__)
4465 {
4466    eina_stringshare_del(data);
4467 }
4468
4469 EAPI void
4470 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4471                                   const char       *text)
4472 {
4473    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4474    text = eina_stringshare_add(text);
4475    elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4476                                            text,
4477                                            _elm_genlist_item_label_del_cb);
4478 }
4479
4480 EAPI void
4481 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item           *item,
4482                                         Elm_Tooltip_Item_Content_Cb func,
4483                                         const void                 *data,
4484                                         Evas_Smart_Cb               del_cb)
4485 {
4486    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4487
4488    if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4489      return;
4490
4491    if (item->tooltip.del_cb)
4492      item->tooltip.del_cb((void *)item->tooltip.data,
4493                           item->base.widget, item);
4494
4495    item->tooltip.content_cb = func;
4496    item->tooltip.data = data;
4497    item->tooltip.del_cb = del_cb;
4498
4499    if (item->base.view)
4500      {
4501         elm_widget_item_tooltip_content_cb_set(item,
4502                                                item->tooltip.content_cb,
4503                                                item->tooltip.data, NULL);
4504         elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4505      }
4506
4507    return;
4508
4509 error:
4510    if (del_cb) del_cb((void *)data, NULL, NULL);
4511 }
4512
4513 EAPI void
4514 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4515 {
4516    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4517    if ((item->base.view) && (item->tooltip.content_cb))
4518      elm_widget_item_tooltip_unset(item);
4519
4520    if (item->tooltip.del_cb)
4521      item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4522    item->tooltip.del_cb = NULL;
4523    item->tooltip.content_cb = NULL;
4524    item->tooltip.data = NULL;
4525    if (item->tooltip.style)
4526      elm_genlist_item_tooltip_style_set(item, NULL);
4527 }
4528
4529 EAPI void
4530 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4531                                    const char       *style)
4532 {
4533    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4534    eina_stringshare_replace(&item->tooltip.style, style);
4535    if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4536 }
4537
4538 EAPI const char *
4539 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4540 {
4541    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4542    return item->tooltip.style;
4543 }
4544
4545 EAPI void
4546 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4547                             const char       *cursor)
4548 {
4549    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4550    eina_stringshare_replace(&item->mouse_cursor, cursor);
4551    if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4552 }
4553
4554 EAPI const char *
4555 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4556 {
4557    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4558    return elm_widget_item_cursor_get(item);
4559 }
4560
4561 EAPI void
4562 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4563 {
4564    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4565    if (!item->mouse_cursor)
4566      return;
4567
4568    if (item->base.view)
4569      elm_widget_item_cursor_unset(item);
4570
4571    eina_stringshare_del(item->mouse_cursor);
4572    item->mouse_cursor = NULL;
4573 }
4574
4575 EAPI void
4576 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4577                                   const char       *style)
4578 {
4579    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4580    elm_widget_item_cursor_style_set(item, style);
4581 }
4582
4583 EAPI const char *
4584 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4585 {
4586    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4587    return elm_widget_item_cursor_style_get(item);
4588 }
4589
4590 EAPI void
4591 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4592                                         Eina_Bool         engine_only)
4593 {
4594    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4595    elm_widget_item_cursor_engine_only_set(item, engine_only);
4596 }
4597
4598 EAPI Eina_Bool
4599 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4600 {
4601    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4602    return elm_widget_item_cursor_engine_only_get(item);
4603 }
4604
4605 EAPI void
4606 elm_genlist_horizontal_mode_set(Evas_Object  *obj,
4607                                 Elm_List_Mode mode)
4608 {
4609    ELM_CHECK_WIDTYPE(obj, widtype);
4610    Widget_Data *wd = elm_widget_data_get(obj);
4611    if (!wd) return;
4612    if (wd->mode == mode) return;
4613    wd->mode = mode;
4614    _sizing_eval(obj);
4615 }
4616
4617 EAPI Elm_List_Mode
4618 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4619 {
4620    ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4621    Widget_Data *wd = elm_widget_data_get(obj);
4622    if (!wd) return ELM_LIST_LAST;
4623    return wd->mode;
4624 }
4625
4626 EAPI void
4627 elm_genlist_always_select_mode_set(Evas_Object *obj,
4628                                    Eina_Bool    always_select)
4629 {
4630    ELM_CHECK_WIDTYPE(obj, widtype);
4631    Widget_Data *wd = elm_widget_data_get(obj);
4632    if (!wd) return;
4633    wd->always_select = always_select;
4634 }
4635
4636 EAPI Eina_Bool
4637 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4638 {
4639    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4640    Widget_Data *wd = elm_widget_data_get(obj);
4641    if (!wd) return EINA_FALSE;
4642    return wd->always_select;
4643 }
4644
4645 EAPI void
4646 elm_genlist_no_select_mode_set(Evas_Object *obj,
4647                                Eina_Bool    no_select)
4648 {
4649    ELM_CHECK_WIDTYPE(obj, widtype);
4650    Widget_Data *wd = elm_widget_data_get(obj);
4651    if (!wd) return;
4652    wd->no_select = no_select;
4653 }
4654
4655 EAPI Eina_Bool
4656 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4657 {
4658    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4659    Widget_Data *wd = elm_widget_data_get(obj);
4660    if (!wd) return EINA_FALSE;
4661    return wd->no_select;
4662 }
4663
4664 EAPI void
4665 elm_genlist_compress_mode_set(Evas_Object *obj,
4666                               Eina_Bool    compress)
4667 {
4668    ELM_CHECK_WIDTYPE(obj, widtype);
4669    Widget_Data *wd = elm_widget_data_get(obj);
4670    if (!wd) return;
4671    wd->compress = compress;
4672 }
4673
4674 EAPI Eina_Bool
4675 elm_genlist_compress_mode_get(const Evas_Object *obj)
4676 {
4677    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4678    Widget_Data *wd = elm_widget_data_get(obj);
4679    if (!wd) return EINA_FALSE;
4680    return wd->compress;
4681 }
4682
4683 EAPI void
4684 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4685                                       Eina_Bool    height_for_width)
4686 {
4687    ELM_CHECK_WIDTYPE(obj, widtype);
4688    Widget_Data *wd = elm_widget_data_get(obj);
4689    if (!wd) return;
4690    wd->height_for_width = !!height_for_width;
4691    if (wd->height_for_width)
4692      {
4693         elm_genlist_homogeneous_set(obj, EINA_FALSE);
4694         elm_genlist_compress_mode_set(obj, EINA_TRUE);
4695      }
4696 }
4697
4698 EAPI Eina_Bool
4699 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4700 {
4701    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4702    Widget_Data *wd = elm_widget_data_get(obj);
4703    if (!wd) return EINA_FALSE;
4704    return wd->height_for_width;
4705 }
4706
4707 EAPI void
4708 elm_genlist_bounce_set(Evas_Object *obj,
4709                        Eina_Bool    h_bounce,
4710                        Eina_Bool    v_bounce)
4711 {
4712    ELM_CHECK_WIDTYPE(obj, widtype);
4713    Widget_Data *wd = elm_widget_data_get(obj);
4714    if (!wd) return;
4715    elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4716 }
4717
4718 EAPI void
4719 elm_genlist_bounce_get(const Evas_Object *obj,
4720                        Eina_Bool         *h_bounce,
4721                        Eina_Bool         *v_bounce)
4722 {
4723    ELM_CHECK_WIDTYPE(obj, widtype);
4724    Widget_Data *wd = elm_widget_data_get(obj);
4725    if (!wd) return;
4726    elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4727 }
4728
4729 EAPI void
4730 elm_genlist_homogeneous_set(Evas_Object *obj,
4731                             Eina_Bool    homogeneous)
4732 {
4733    ELM_CHECK_WIDTYPE(obj, widtype);
4734    Widget_Data *wd = elm_widget_data_get(obj);
4735    if (!wd) return;
4736    if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4737    wd->homogeneous = homogeneous;
4738 }
4739
4740 EAPI Eina_Bool
4741 elm_genlist_homogeneous_get(const Evas_Object *obj)
4742 {
4743    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4744    Widget_Data *wd = elm_widget_data_get(obj);
4745    if (!wd) return EINA_FALSE;
4746    return wd->homogeneous;
4747 }
4748
4749 EAPI void
4750 elm_genlist_block_count_set(Evas_Object *obj,
4751                             int          n)
4752 {
4753    ELM_CHECK_WIDTYPE(obj, widtype);
4754    Widget_Data *wd = elm_widget_data_get(obj);
4755    if (!wd) return;
4756    wd->max_items_per_block = n;
4757    wd->item_cache_max = wd->max_items_per_block * 2;
4758    _item_cache_clean(wd);
4759 }
4760
4761 EAPI int
4762 elm_genlist_block_count_get(const Evas_Object *obj)
4763 {
4764    ELM_CHECK_WIDTYPE(obj, widtype) 0;
4765    Widget_Data *wd = elm_widget_data_get(obj);
4766    if (!wd) return 0;
4767    return wd->max_items_per_block;
4768 }
4769
4770 EAPI void
4771 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4772                                   double       timeout)
4773 {
4774    ELM_CHECK_WIDTYPE(obj, widtype);
4775    Widget_Data *wd = elm_widget_data_get(obj);
4776    if (!wd) return;
4777    wd->longpress_timeout = timeout;
4778 }
4779
4780 EAPI double
4781 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4782 {
4783    ELM_CHECK_WIDTYPE(obj, widtype) 0;
4784    Widget_Data *wd = elm_widget_data_get(obj);
4785    if (!wd) return 0;
4786    return wd->longpress_timeout;
4787 }
4788
4789 EAPI void
4790 elm_genlist_scroller_policy_set(Evas_Object        *obj,
4791                                 Elm_Scroller_Policy policy_h,
4792                                 Elm_Scroller_Policy policy_v)
4793 {
4794    ELM_CHECK_WIDTYPE(obj, widtype);
4795    Widget_Data *wd = elm_widget_data_get(obj);
4796    if (!wd) return;
4797    if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4798        (policy_v >= ELM_SCROLLER_POLICY_LAST))
4799      return;
4800    if (wd->scr)
4801      elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4802 }
4803
4804 EAPI void
4805 elm_genlist_scroller_policy_get(const Evas_Object   *obj,
4806                                 Elm_Scroller_Policy *policy_h,
4807                                 Elm_Scroller_Policy *policy_v)
4808 {
4809    ELM_CHECK_WIDTYPE(obj, widtype);
4810    Widget_Data *wd = elm_widget_data_get(obj);
4811    Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4812    if ((!wd) || (!wd->scr)) return;
4813    elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4814    if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4815    if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
4816 }
4817
4818 EAPI void
4819 elm_genlist_realized_items_update(Evas_Object *obj)
4820 {
4821    ELM_CHECK_WIDTYPE(obj, widtype);
4822
4823    Eina_List *list, *l;
4824    Elm_Genlist_Item *it;
4825
4826    list = elm_genlist_realized_items_get(obj);
4827    EINA_LIST_FOREACH(list, l, it)
4828      elm_genlist_item_update(it);
4829 }
4830
4831 /**
4832  * Set genlist item mode
4833  *
4834  * @param item The genlist item
4835  * @param mode Mode name
4836  * @param mode_set Boolean to define set or unset mode.
4837  *
4838  * @ingroup Genlist
4839  */
4840 EAPI void
4841 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
4842                           const char       *mode_type,
4843                           Eina_Bool         mode_set)
4844 {
4845    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4846    Widget_Data *wd = it->wd;
4847    Eina_List *l;
4848    Elm_Genlist_Item *it2;
4849
4850    if (!wd) return;
4851    if (!mode_type) return;
4852    if ((it->delete_me) || (it->disabled)) return;
4853    if (wd->edit_mode) return;
4854
4855    if ((wd->mode_item == it) &&
4856        (!strcmp(mode_type, wd->mode_type)) &&
4857        (mode_set))
4858       return;
4859    if (!it->itc->mode_item_style) return;
4860
4861    if (wd->multi)
4862      {
4863         EINA_LIST_FOREACH(wd->selected, l, it2)
4864           if (it2->realized)
4865             elm_genlist_item_selected_set(it2, EINA_FALSE);
4866      }
4867    else
4868      {
4869         it2 = elm_genlist_selected_item_get(wd->obj);
4870         if ((it2) && (it2->realized))
4871           elm_genlist_item_selected_set(it2, EINA_FALSE);
4872      }
4873
4874    if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
4875        (mode_set) ||
4876        ((it == wd->mode_item) && (!mode_set)))
4877      _item_mode_unset(wd);
4878
4879    eina_stringshare_replace(&wd->mode_type, mode_type);
4880    if (mode_set) _item_mode_set(it);
4881 }
4882
4883 /**
4884  * Get active genlist mode type
4885  *
4886  * @param obj The genlist object
4887  *
4888  * @ingroup Genlist
4889  */
4890 EAPI const char *
4891 elm_genlist_mode_get(const Evas_Object *obj)
4892 {
4893    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4894    Widget_Data *wd = elm_widget_data_get(obj);
4895    if (!wd) return NULL;
4896    return wd->mode_type;
4897 }
4898
4899 /**
4900  * Get active genlist mode item
4901  *
4902  * @param obj The genlist object
4903  *
4904  * @ingroup Genlist
4905  */
4906 EAPI const Elm_Genlist_Item *
4907 elm_genlist_mode_item_get(const Evas_Object *obj)
4908 {
4909    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4910    Widget_Data *wd = elm_widget_data_get(obj);
4911    if (!wd) return NULL;
4912    return wd->mode_item;
4913 }
4914
4915 /**
4916  * Set reorder mode
4917  *
4918  * @param obj The genlist object
4919  * @param reorder_mode The reorder mode
4920  * (EINA_TRUE = on, EINA_FALSE = off)
4921  *
4922  * @ingroup Genlist
4923  */
4924 EAPI void
4925 elm_genlist_reorder_mode_set(Evas_Object *obj,
4926                              Eina_Bool    reorder_mode)
4927 {
4928    ELM_CHECK_WIDTYPE(obj, widtype);
4929    Widget_Data *wd = elm_widget_data_get(obj);
4930    if (!wd) return;
4931    wd->reorder_mode = reorder_mode;
4932 }
4933
4934 /**
4935  * Get the reorder mode
4936  *
4937  * @param obj The genlist object
4938  * @return The reorder mode
4939  * (EINA_TRUE = on, EINA_FALSE = off)
4940  *
4941  * @ingroup Genlist
4942  */
4943 EAPI Eina_Bool
4944 elm_genlist_reorder_mode_get(const Evas_Object *obj)
4945 {
4946    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4947    Widget_Data *wd = elm_widget_data_get(obj);
4948    if (!wd) return EINA_FALSE;
4949    return wd->reorder_mode;
4950 }
4951
4952 EAPI void
4953 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
4954 {
4955    return;
4956 }
4957
4958 EAPI void
4959 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
4960 {
4961    return;
4962 }
4963
4964 static void
4965 _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
4966 {
4967    if (!it) return;
4968    if (!after) return;
4969
4970 //   printf("MOVE AFTER : it = %d  after = %d \n", it->num, after->num);
4971    it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4972    it->wd->reorder_deleted = EINA_TRUE;
4973    _item_block_del(it);
4974
4975    it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
4976    it->rel = after;
4977    it->rel->relcount++;
4978    it->before = EINA_FALSE;
4979    _item_queue(it->wd, it);
4980
4981    if (it->itc->func.moved)
4982       it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
4983 }
4984
4985 static void
4986 _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
4987 {
4988    if (!it) return;
4989    if (!before) return;
4990
4991 //   printf("MOVE BEFORE : it = %d  before = %d \n", it->num, before->num);
4992    it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
4993    it->wd->reorder_deleted = EINA_TRUE;
4994    _item_block_del(it);
4995    it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
4996    it->rel = before;
4997    it->rel->relcount++;
4998    it->before = EINA_TRUE;
4999    _item_queue(it->wd, it);
5000
5001    if (it->itc->func.moved)
5002       it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
5003 }
5004
5005 EAPI void
5006 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5007 {
5008    ELM_CHECK_WIDTYPE(obj, widtype);
5009    Widget_Data *wd = elm_widget_data_get(obj);
5010    if (!wd) return;
5011    wd->effect_mode = emode;
5012    //   wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5013    //   evas_object_resize(wd->point_rect, 10, 25);
5014    //   evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5015    //   evas_object_show(wd->point_rect);
5016    //   evas_object_hide(wd->point_rect);
5017 }
5018
5019 static Evas_Object*
5020 _create_tray_alpha_bg(const Evas_Object *obj)
5021 {
5022    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5023    Widget_Data *wd = elm_widget_data_get(obj);
5024    if (!wd) return NULL;
5025
5026    Evas_Object *bg = NULL;
5027    Evas_Coord ox, oy, ow, oh;
5028
5029    evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5030    bg  =  evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5031    evas_object_color_set(bg,0,0,0,0);
5032    evas_object_resize(bg , ow, oh);
5033    evas_object_move(bg , ox, oy);
5034    evas_object_show(bg);
5035    evas_object_hide(bg);
5036    return bg ;
5037 }
5038
5039 static unsigned int
5040 current_time_get()
5041 {
5042    struct timeval timev;
5043
5044    gettimeofday(&timev, NULL);
5045    return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5046 }
5047
5048 // added for item moving animation.
5049 static Eina_Bool
5050 _item_moving_effect_timer_cb(void *data)
5051 {
5052    Widget_Data *wd = data;
5053    if (!wd) return EINA_FALSE;
5054    Item_Block *itb;
5055    Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5056    Elm_Genlist_Item *it = NULL, *it2;
5057    const Eina_List *l;
5058    double time = 0.3, t;
5059    int y, dy;
5060    Eina_Bool check, end = EINA_FALSE;
5061    int in = 0;
5062
5063    t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5064
5065    evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5066    evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5067    if (t > time) end = EINA_TRUE;
5068
5069    it2 = elm_genlist_item_next_get(wd->expand_item);
5070    while (it2)
5071      {
5072         if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5073         it2 = elm_genlist_item_next_get(it2);
5074      }
5075    dy = 0;
5076    if (it2)
5077      {
5078         if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5079           dy = it2->scrl_y - it2->old_scrl_y;
5080         else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5081           dy = wd->expand_item_gap;
5082
5083         if (t <= time)
5084           {
5085              y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5086           }
5087         else
5088           {
5089              end = EINA_TRUE;
5090              y = dy;
5091           }
5092
5093         check = EINA_FALSE;
5094         EINA_INLIST_FOREACH(wd->blocks, itb)
5095           {
5096              itb->w = wd->minw;
5097              if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5098                                      itb->y - wd->pan_y + oy,
5099                                      itb->w, itb->h,
5100                                      cvx, cvy, cvw, cvh))
5101                {
5102                   EINA_LIST_FOREACH(itb->items, l, it)
5103                     {
5104                        if (it == it2) check = EINA_TRUE;
5105                        if (!check) continue;
5106
5107                        if (!it->old_scrl_y)
5108                          it->old_scrl_y  = it->scrl_y;
5109                        if (it->old_scrl_y + y < oy + oh)
5110                          {
5111                             if (!it->realized) _item_realize(it, in, 0);
5112                          }
5113                        if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5114                          it->old_scrl_y = it->scrl_y - y;
5115                        in++;
5116
5117                        if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5118                            (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5119                          {
5120                             if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5121                             else
5122                               {
5123                                  evas_object_resize(it->base.view, it->w, it->h);
5124                                  evas_object_move(it->base.view, it->scrl_x, it->old_scrl_y + y);
5125                                  evas_object_show(it->base.view);
5126                                  evas_object_raise(it->base.view);
5127                               }
5128
5129                             if (it->group_item) evas_object_raise(it->group_item->base.view);
5130                          }
5131                     }
5132                }
5133           }
5134
5135         if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5136           {
5137              it = elm_genlist_item_prev_get(it2);
5138              while (it)
5139                {
5140                   if (it->expanded_depth <= it2->expanded_depth) break;
5141                   if ((it->scrl_y < it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5142                     {
5143                        if (!it->effect_done)
5144                          {
5145                             edje_object_signal_emit(it->base.view, "flip_item", "");
5146                             evas_object_show(it->base.view);
5147                             it->effect_done = EINA_TRUE;
5148                          }
5149                     }
5150                   it = elm_genlist_item_prev_get(it);
5151                }
5152           }
5153         else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5154           {
5155              it = elm_genlist_item_prev_get(it2);
5156              while (it)
5157                {
5158                   if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
5159                     {
5160                        if (!it->effect_done)
5161                          {
5162                             edje_object_signal_emit(it->base.view, "elm,state,hide", "");
5163                             it->effect_done = EINA_TRUE;
5164                          }
5165                     }
5166                   else
5167                     break;
5168                   it = elm_genlist_item_prev_get(it);
5169                }
5170           }
5171      }
5172    else
5173      {
5174         int expand_num = 0;
5175         int expand_order = 0;
5176         if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5177         while (it)
5178           {
5179              expand_num++;
5180              it = elm_genlist_item_next_get(it);
5181           }
5182         if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
5183         while (it)
5184           {
5185              expand_order++;
5186              if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
5187              if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5188                {
5189                   if (!it->effect_done)
5190                     {
5191                        if (t >= (((expand_order - 1) * time) / expand_num))
5192                          {
5193                             edje_object_signal_emit(it->base.view, "flip_item", "");
5194                             evas_object_show(it->base.view);
5195                             it->effect_done = EINA_TRUE;
5196                          }
5197                     }
5198                }
5199              it = elm_genlist_item_next_get(it);
5200           }
5201      }
5202
5203    if (end)
5204      {
5205         if (wd->item_moving_effect_timer)
5206           {
5207              if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5208                 _item_subitems_clear(wd->expand_item);
5209              EINA_INLIST_FOREACH(wd->blocks, itb)
5210                {
5211                   EINA_LIST_FOREACH(itb->items, l, it)
5212                     {
5213                        it->effect_done = EINA_TRUE;
5214                        it->old_scrl_y = it->scrl_y;
5215                     }
5216                }
5217           }
5218         wd->item_moving_effect_timer = NULL;
5219
5220         _item_auto_scroll(wd);
5221         evas_object_lower(wd->alpha_bg);
5222         evas_object_hide(wd->alpha_bg);
5223         if (wd->calc_job) ecore_job_del(wd->calc_job);
5224         wd->calc_job = ecore_job_add(_calc_job, wd);
5225         elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5226         wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5227
5228         evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5229         evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5230         return ECORE_CALLBACK_CANCEL;
5231      }
5232    return ECORE_CALLBACK_RENEW;
5233 }
5234
5235 static void
5236 _emit_contract(Elm_Genlist_Item *it)
5237 {
5238    Elm_Genlist_Item *it2;
5239    Eina_List *l;
5240
5241    //   printf("%p is emited contract\n", it);
5242    edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5243    it->effect_done = EINA_FALSE;
5244
5245    EINA_LIST_FOREACH(it->items, l, it2)
5246       if (it2)
5247          _emit_contract(it2);
5248 }
5249
5250 // added for item moving animation.
5251 static int
5252 _item_flip_effect_show(Elm_Genlist_Item *it)
5253 {
5254    Elm_Genlist_Item *it2;
5255    Eina_List *l;
5256    Widget_Data *wd = it->wd;
5257    Eina_Bool check = EINA_FALSE;
5258
5259    it2 = elm_genlist_item_next_get(it);
5260    while (it2)
5261      {
5262         if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5263         it2 = elm_genlist_item_next_get(it2);
5264      }
5265    EINA_LIST_FOREACH(it->items, l, it2)
5266      {
5267         if (it2->parent && it == it2->parent)
5268           {
5269              if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5270                edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5271              else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5272                _emit_contract(it2);
5273           }
5274      }
5275
5276    return ECORE_CALLBACK_CANCEL;
5277 }
5278
5279 /*
5280 static void
5281 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5282 {
5283    printf("!!! NOW FIXING \n");
5284 }
5285 */
5286
5287 /**
5288  * Set pinch zoom mode
5289  *
5290  * @param obj The genlist object
5291  * @param emode
5292  * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5293  *
5294  * @ingroup Genlist
5295  */
5296 EAPI void
5297 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5298 {
5299    printf("!!! NOW FIXING \n");
5300 }
5301
5302 /**
5303  * Get pinch zoom mode
5304  *
5305  * @param obj The genlist object
5306  * @return The pinch mode
5307  * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5308  *
5309  * @ingroup Genlist
5310  */
5311 EAPI Eina_Bool
5312 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
5313 {
5314    printf("!!! NOW FIXING \n");
5315    return EINA_FALSE;
5316 }
5317
5318 EAPI void
5319 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
5320 {
5321    printf("!!! NOW FIXING \n");
5322 }
5323
5324
5325 ////////////////////////////////////////////////////////////////////////
5326 //  EDIT  MODE
5327 ////////////////////////////////////////////////////////////////////////
5328
5329 static void
5330 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5331 {
5332    if (!it->wd->edit_mode) return;
5333    evas_object_resize(it->edit_obj,it->w, it->h);
5334    evas_object_move(it->edit_obj, itx, ity);
5335 }
5336
5337 static void
5338 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5339 {
5340    if ((it->effect_item_realized) || (it->delete_me)) return;
5341    char buf[1024];
5342
5343    if (it->mode_view)
5344      _mode_finished_signal_cb(it, (Evas_Object *)elm_genlist_item_object_get(it), NULL, NULL);
5345
5346    it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
5347    edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
5348                          _elm_config->scale);
5349    evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5350    elm_widget_sub_object_add(it->base.widget, it->edit_obj);
5351
5352    if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5353    else strncpy(buf, "item", sizeof(buf));
5354    if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5355
5356    strncat(buf, "/", sizeof(buf) - strlen(buf));
5357
5358    if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5359      {
5360         strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
5361         _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
5362      }
5363    else
5364      {
5365         _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget));
5366      }
5367
5368    if (it->wd->reorder_mode)
5369      {
5370         if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
5371         else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
5372      }
5373    if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
5374    else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
5375
5376    if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
5377    else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
5378
5379
5380    if ((it->wd->edit_mode))
5381      {
5382         if (it->itc->func.icon_get)
5383           {
5384              const Eina_List *l;
5385              const char *key;
5386
5387              it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5388              EINA_LIST_FOREACH(it->icons, l, key)
5389                {
5390                   Evas_Object *ic = it->itc->func.icon_get
5391                      ((void *)it->base.data, it->base.widget, l->data);
5392
5393                   if (ic)
5394                     {
5395                        it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5396                        edje_object_part_swallow(it->edit_obj, key, ic);
5397                        evas_object_show(ic);
5398                        elm_widget_sub_object_add(it->base.widget, ic);
5399                        if (it->disabled)
5400                          elm_widget_disabled_set(ic, EINA_TRUE);
5401                     }
5402                }
5403           }
5404      }
5405    edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
5406    _effect_item_controls(it,it->scrl_x, it->scrl_y);
5407    evas_object_show(it->edit_obj);
5408
5409    it->effect_item_realized = EINA_TRUE;
5410    it->want_unrealize = EINA_FALSE;
5411 }
5412
5413 static void
5414 _effect_item_unrealize(Elm_Genlist_Item *it)
5415 {
5416    Evas_Object *icon;
5417
5418    if (!it->effect_item_realized) return;
5419    if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5420
5421    edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
5422    edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
5423    edje_object_message_signal_process(it->edit_obj);
5424    edje_object_part_unswallow(it->edit_obj, it->base.view);
5425    evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
5426    elm_widget_sub_object_add(it->base.widget, it->base.view);
5427    //   evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5428    //   _item_cache_add(it);
5429    evas_object_del(it->edit_obj);
5430    it->edit_obj = NULL;
5431    EINA_LIST_FREE(it->edit_icon_objs, icon)
5432       evas_object_del(icon);
5433
5434 //   edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5435    it->effect_item_realized = EINA_FALSE;
5436 }
5437
5438 /**
5439  * Get Genlist edit mode
5440  *
5441  * @param obj The genlist object
5442  * @return The edit mode status
5443  * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5444  *
5445  * @ingroup Genlist
5446  */
5447 EAPI Eina_Bool
5448 elm_genlist_edit_mode_get(const Evas_Object *obj)
5449 {
5450    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5451    Widget_Data *wd = elm_widget_data_get(obj);
5452    if (!wd) return EINA_FALSE;
5453
5454    if (wd->edit_mode) return EINA_TRUE;
5455    else return EINA_FALSE;
5456 }
5457
5458 /**
5459  * Set Genlist edit mode
5460  *
5461  * This sets Genlist edit mode.
5462  *
5463  * @param obj The Genlist object
5464  * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5465  * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5466  *
5467  * @ingroup Genlist
5468  */
5469 EAPI void
5470 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5471 {
5472    ELM_CHECK_WIDTYPE(obj, widtype);
5473
5474    Item_Block *itb;
5475    Eina_List *l;
5476    Elm_Genlist_Item *it;
5477
5478    Widget_Data *wd = elm_widget_data_get(obj);
5479    if (!wd) return;
5480    if (wd->edit_mode == edit_mode) return;
5481
5482    wd->edit_mode = edit_mode;
5483    if (!wd->edit_mode)
5484      {
5485         EINA_INLIST_FOREACH(wd->blocks, itb)
5486           {
5487              if (itb->realized)
5488                {
5489                   EINA_LIST_FOREACH(itb->items, l, it)
5490                     {
5491                        if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5492                          {
5493                             _effect_item_unrealize(it);
5494                          }
5495                     }
5496                }
5497           }
5498         _item_cache_zero(wd);
5499      }
5500    else
5501      {
5502
5503         EINA_INLIST_FOREACH(wd->blocks, itb)
5504           {
5505              if (itb->realized)
5506                {
5507                   EINA_LIST_FOREACH(itb->items, l, it)
5508                     {
5509                        if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
5510                          {
5511                             if(it->selected) _item_unselect(it);
5512                             if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
5513                          }
5514                     }
5515                 }
5516            }
5517       }
5518
5519    if (wd->calc_job) ecore_job_del(wd->calc_job);
5520    wd->calc_job = ecore_job_add(_calc_job, wd);
5521 }
5522
5523 /**
5524  * Set a given item's rename mode
5525  *
5526  * This renames the item's label from genlist
5527  *
5528  * @param it The item
5529  * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
5530  *
5531  * @ingroup Genlist
5532  */
5533 EAPI void
5534 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
5535 {
5536    if (!it) return;
5537
5538    if (renamed)
5539      {
5540         _item_unrealize(it, EINA_FALSE);
5541         it->renamed = EINA_TRUE;
5542         it->wd->rename_it = it;
5543         it->nocache = EINA_TRUE;
5544         if (it->selected)  _item_unselect(it);
5545
5546         if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5547         it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5548      }
5549    else
5550      {
5551         if (it->renamed)
5552           {
5553              it->renamed = EINA_FALSE;
5554              it->nocache = EINA_TRUE;
5555              it->wd->rename_it = NULL;
5556              _item_cache_zero(it->wd);
5557              elm_genlist_item_update(it);
5558           }
5559      }
5560 }
5561
5562 EAPI Eina_Bool
5563 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
5564 {
5565    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5566    return item->renamed;
5567 }
5568
5569 static void
5570 _item_auto_scroll(void *data)
5571 {
5572    Widget_Data *wd = data;
5573    if (!wd) return;
5574
5575    if ((wd->expand_item) && (!wd->auto_scrolled))
5576      {
5577         Elm_Genlist_Item  *it;
5578         Eina_List *l;
5579         Evas_Coord ox, oy, ow, oh;
5580         evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
5581
5582         wd->auto_scrolled = EINA_TRUE;
5583         if (wd->expand_item->scrl_y > (oh + oy) / 2)
5584           {
5585             EINA_LIST_FOREACH(wd->expand_item->items, l, it)
5586               {
5587                  elm_genlist_item_bring_in(it);
5588               }
5589           }
5590      }
5591 }