Merge remote-tracking branch 'remotes/origin/upstream'
[framework/uifw/elementary.git] / src / lib / elm_gengrid.c
1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
3 #include "elm_priv.h"
4 #include "els_scroller.h"
5 #include "elm_gen_common.h"
6
7 <<<<<<< HEAD
8 =======
9 // internally allocated
10 #define CLASS_ALLOCATED 0x3a70f00f
11
12 >>>>>>> remotes/origin/upstream
13 /* --
14  * TODO:
15  * Handle non-homogeneous objects too.
16  */
17
18 #define PRELOAD 1
19 #define REORDER_EFFECT_TIME 0.5
20
21 #define ELM_GEN_SETUP(wd) \
22    (wd)->calc_cb = (Ecore_Cb)_calc_job
23
24 #define ELM_GEN_ITEM_SETUP(it) \
25    (it)->del_cb = (Ecore_Cb)_item_del; \
26    (it)->highlight_cb = (Ecore_Cb)_item_highlight; \
27    (it)->unsel_cb = (Ecore_Cb)_item_unselect; \
28    (it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
29
30 struct Elm_Gen_Item_Type
31 {
32    Elm_Gen_Item   *it;
33    Ecore_Animator *item_moving_effect_timer;
34    Evas_Coord   gx, gy, ox, oy, tx, ty, rx, ry;
35    unsigned int moving_effect_start_time;
36    int          prev_group;
37
38    Eina_Bool   group_realized : 1;
39    Eina_Bool   moving : 1;
40 };
41
42 #if 0
43 struct _Widget_Data
44 {
45    Eina_Inlist_Sorted_State *state;
46    Evas_Object      *obj; /* the gengrid object */
47    Evas_Object      *scr; /* a smart scroller object which is used internally in genlist */
48    Evas_Object      *pan_smart; /* "elm_genlist_pan" evas smart object. this is an extern pan of smart scroller(scr). */
49    Eina_List        *selected;
50    Eina_List        *group_items; /* list of groups index items */
51    Eina_Inlist      *items; /* inlist of all items */
52    Elm_Gen_Item     *reorder_it; /* item currently being repositioned */
53    Elm_Gen_Item     *last_selected_item;
54    Pan              *pan; /* pan_smart object's smart data */
55    Ecore_Job        *calc_job;
56    int               walking;
57    int               item_width, item_height;
58    int               group_item_width, group_item_height;
59    int               minw, minh;
60    long              count;
61    Evas_Coord        pan_x, pan_y;
62    Eina_Bool         reorder_mode : 1;
63    Eina_Bool         on_hold : 1;
64    Eina_Bool         multi : 1;
65 <<<<<<< HEAD
66    Eina_Bool         no_select : 1;
67    Eina_Bool         wasselected : 1;
68    Eina_Bool         always_select : 1;
69 =======
70    Eina_Bool         wasselected : 1;
71 >>>>>>> remotes/origin/upstream
72    Eina_Bool         clear_me : 1;
73    Eina_Bool         h_bounce : 1;
74    Eina_Bool         v_bounce : 1;
75    Ecore_Cb          del_cb, calc_cb, sizing_cb;
76    Ecore_Cb          clear_cb;
77    ////////////////////////////////////
78    double            align_x, align_y;
79
80    Evas_Coord        old_pan_x, old_pan_y;
81    Evas_Coord        reorder_item_x, reorder_item_y;
82    unsigned int      nmax;
83    long              items_lost;
84
85    int               generation;
86
87    Eina_Bool         horizontal : 1;
88    Eina_Bool         longpressed : 1;
89    Eina_Bool         reorder_item_changed : 1;
90    Eina_Bool         move_effect_enabled : 1;
91 };
92 #endif
93
94 static const char *widtype = NULL;
95 static void      _item_highlight(Elm_Gen_Item *it);
96 static void      _item_unrealize_cb(Elm_Gen_Item *it);
97 static void      _item_unselect(Elm_Gen_Item *it);
98 static void      _calc_job(void *data);
99 static void      _on_focus_hook(void        *data,
100                                 Evas_Object *obj);
101 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
102 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
103 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
104 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
105 static Eina_Bool _item_single_select_up(Widget_Data *wd);
106 static Eina_Bool _item_single_select_down(Widget_Data *wd);
107 static Eina_Bool _item_single_select_left(Widget_Data *wd);
108 static Eina_Bool _item_single_select_right(Widget_Data *wd);
109 static Eina_Bool _event_hook(Evas_Object       *obj,
110                              Evas_Object       *src,
111                              Evas_Callback_Type type,
112                              void              *event_info);
113 static Eina_Bool _deselect_all_items(Widget_Data *wd);
114 <<<<<<< HEAD
115 #if 1
116 static void      _elm_gengrid_clear(Evas_Object *obj,
117                                     Eina_Bool    standby);
118 #endif
119 =======
120 >>>>>>> remotes/origin/upstream
121
122 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
123 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
124
125 static const char SIG_ACTIVATED[] = "activated";
126 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
127 static const char SIG_LONGPRESSED[] = "longpressed";
128 static const char SIG_SELECTED[] = "selected";
129 static const char SIG_UNSELECTED[] = "unselected";
130 static const char SIG_REALIZED[] = "realized";
131 static const char SIG_UNREALIZED[] = "unrealized";
132 static const char SIG_CHANGED[] = "changed";
133 static const char SIG_DRAG_START_UP[] = "drag,start,up";
134 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
135 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
136 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
137 static const char SIG_DRAG_STOP[] = "drag,stop";
138 static const char SIG_DRAG[] = "drag";
139 static const char SIG_SCROLL[] = "scroll";
140 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
141 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
142 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
143 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
144 static const char SIG_EDGE_TOP[] = "edge,top";
145 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
146 static const char SIG_EDGE_LEFT[] = "edge,left";
147 static const char SIG_EDGE_RIGHT[] = "edge,right";
148 static const char SIG_MOVED[] = "moved";
149 <<<<<<< HEAD
150 =======
151 static const char SIG_INDEX_UPDATE[] = "index,update";
152 >>>>>>> remotes/origin/upstream
153
154 static const Evas_Smart_Cb_Description _signals[] = {
155    {SIG_ACTIVATED, ""},
156    {SIG_CLICKED_DOUBLE, ""},
157    {SIG_LONGPRESSED, ""},
158    {SIG_SELECTED, ""},
159    {SIG_UNSELECTED, ""},
160    {SIG_REALIZED, ""},
161    {SIG_UNREALIZED, ""},
162    {SIG_CHANGED, ""},
163    {SIG_DRAG_START_UP, ""},
164    {SIG_DRAG_START_DOWN, ""},
165    {SIG_DRAG_START_LEFT, ""},
166    {SIG_DRAG_START_RIGHT, ""},
167    {SIG_DRAG_STOP, ""},
168    {SIG_DRAG, ""},
169    {SIG_SCROLL, ""},
170    {SIG_SCROLL_ANIM_START, ""},
171    {SIG_SCROLL_ANIM_STOP, ""},
172    {SIG_SCROLL_DRAG_START, ""},
173    {SIG_SCROLL_DRAG_STOP, ""},
174    {SIG_EDGE_TOP, ""},
175    {SIG_EDGE_BOTTOM, ""},
176    {SIG_EDGE_LEFT, ""},
177    {SIG_EDGE_RIGHT, ""},
178    {SIG_MOVED, ""},
179    {NULL, NULL}
180 };
181
182 static Eina_Bool
183 _event_hook(Evas_Object        *obj,
184             Evas_Object        *src __UNUSED__,
185             Evas_Callback_Type  type,
186             void               *event_info)
187 {
188    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
189    Evas_Event_Key_Down *ev = event_info;
190    Widget_Data *wd = elm_widget_data_get(obj);
191    if (!wd) return EINA_FALSE;
192    if (!wd->items) return EINA_FALSE;
193    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
194    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
195
196    Elm_Object_Item *it = NULL;
197    Evas_Coord x = 0;
198    Evas_Coord y = 0;
199    Evas_Coord step_x = 0;
200    Evas_Coord step_y = 0;
201    Evas_Coord v_w = 0;
202    Evas_Coord v_h = 0;
203    Evas_Coord page_x = 0;
204    Evas_Coord page_y = 0;
205
206    elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
207    elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
208    elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
209    elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
210
211    if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
212      {
213         if ((wd->horizontal) &&
214             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
215               (_item_multi_select_up(wd)))
216              || (_item_single_select_up(wd))))
217           {
218              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
219              return EINA_TRUE;
220           }
221         else if ((!wd->horizontal) &&
222                  (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
223                    (_item_multi_select_left(wd)))
224                   || (_item_single_select_left(wd))))
225           {
226              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
227              return EINA_TRUE;
228           }
229         else
230           x -= step_x;
231      }
232    else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
233      {
234         if ((wd->horizontal) &&
235             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
236               (_item_multi_select_down(wd)))
237              || (_item_single_select_down(wd))))
238           {
239              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
240              return EINA_TRUE;
241           }
242         else if ((!wd->horizontal) &&
243                  (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
244                    (_item_multi_select_right(wd)))
245                   || (_item_single_select_right(wd))))
246           {
247              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
248              return EINA_TRUE;
249           }
250         else
251           x += step_x;
252      }
253    else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
254      {
255         if ((wd->horizontal) &&
256             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
257               (_item_multi_select_left(wd)))
258              || (_item_single_select_left(wd))))
259           {
260              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
261              return EINA_TRUE;
262           }
263         else if ((!wd->horizontal) &&
264                  (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
265                    (_item_multi_select_up(wd)))
266                   || (_item_single_select_up(wd))))
267           {
268              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
269              return EINA_TRUE;
270           }
271         else
272           y -= step_y;
273      }
274    else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
275      {
276         if ((wd->horizontal) &&
277             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
278               (_item_multi_select_right(wd)))
279              || (_item_single_select_right(wd))))
280           {
281              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
282              return EINA_TRUE;
283           }
284         else if ((!wd->horizontal) &&
285                  (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
286                    (_item_multi_select_down(wd)))
287                   || (_item_single_select_down(wd))))
288           {
289              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
290              return EINA_TRUE;
291           }
292         else
293           y += step_y;
294      }
295    else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
296      {
297         it = elm_gengrid_first_item_get(obj);
298 <<<<<<< HEAD
299         elm_gengrid_item_bring_in(it);
300 =======
301         elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN);
302         elm_gengrid_item_selected_set(it, EINA_TRUE);
303 >>>>>>> remotes/origin/upstream
304         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
305         return EINA_TRUE;
306      }
307    else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
308      {
309         it = elm_gengrid_last_item_get(obj);
310 <<<<<<< HEAD
311         elm_gengrid_item_bring_in(it);
312 =======
313         elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN);
314         elm_gengrid_item_selected_set(it, EINA_TRUE);
315 >>>>>>> remotes/origin/upstream
316         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
317         return EINA_TRUE;
318      }
319    else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
320      {
321         if (wd->horizontal)
322           {
323              if (page_x < 0)
324                x -= -(page_x * v_w) / 100;
325              else
326                x -= page_x;
327           }
328         else
329           {
330              if (page_y < 0)
331                y -= -(page_y * v_h) / 100;
332              else
333                y -= page_y;
334           }
335      }
336    else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
337      {
338         if (wd->horizontal)
339           {
340              if (page_x < 0)
341                x += -(page_x * v_w) / 100;
342              else
343                x += page_x;
344           }
345         else
346           {
347              if (page_y < 0)
348                y += -(page_y * v_h) / 100;
349              else
350                y += page_y;
351           }
352      }
353    else if (!strcmp(ev->keyname, "Escape"))
354      {
355         if (!_deselect_all_items(wd)) return EINA_FALSE;
356         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
357         return EINA_TRUE;
358      }
359    else if (((!strcmp(ev->keyname, "Return")) ||
360              (!strcmp(ev->keyname, "KP_Enter")) ||
361              (!strcmp(ev->keyname, "space")))
362             && (!wd->multi) && (wd->selected))
363      {
364         it = elm_gengrid_selected_item_get(obj);
365         evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
366      }
367    else return EINA_FALSE;
368
369    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
370    elm_smart_scroller_child_pos_set(wd->scr, x, y);
371    return EINA_TRUE;
372 }
373
374 static Eina_Bool
375 _deselect_all_items(Widget_Data *wd)
376 {
377    if (!wd->selected) return EINA_FALSE;
378    while (wd->selected)
379      elm_gengrid_item_selected_set((Elm_Object_Item *) wd->selected->data,
380                                    EINA_FALSE);
381
382    return EINA_TRUE;
383 }
384
385 static Eina_Bool
386 _item_multi_select_left(Widget_Data *wd)
387 {
388    if (!wd->selected) return EINA_FALSE;
389
390    Elm_Object_Item *prev =
391       elm_gengrid_item_prev_get(wd->last_selected_item);
392    if (!prev) return EINA_TRUE;
393    if (elm_gengrid_item_selected_get(prev))
394      {
395         elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
396         wd->last_selected_item = prev;
397 <<<<<<< HEAD
398         elm_gengrid_item_show(wd->last_selected_item);
399 =======
400         elm_gengrid_item_show(wd->last_selected_item, ELM_GENGRID_ITEM_SCROLLTO_IN);
401 >>>>>>> remotes/origin/upstream
402      }
403    else
404      {
405         elm_gengrid_item_selected_set(prev, EINA_TRUE);
406 <<<<<<< HEAD
407         elm_gengrid_item_show(prev);
408 =======
409         elm_gengrid_item_show(prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
410 >>>>>>> remotes/origin/upstream
411      }
412
413    return EINA_TRUE;
414 }
415
416 static Eina_Bool
417 _item_multi_select_right(Widget_Data *wd)
418 {
419    if (!wd->selected) return EINA_FALSE;
420
421    Elm_Object_Item *next =
422       elm_gengrid_item_next_get(wd->last_selected_item);
423    if (!next) return EINA_TRUE;
424    if (elm_gengrid_item_selected_get(next))
425      {
426         elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
427         wd->last_selected_item = next;
428 <<<<<<< HEAD
429         elm_gengrid_item_show(wd->last_selected_item);
430 =======
431         elm_gengrid_item_show(wd->last_selected_item, ELM_GENGRID_ITEM_SCROLLTO_IN);
432 >>>>>>> remotes/origin/upstream
433      }
434    else
435      {
436         elm_gengrid_item_selected_set(next, EINA_TRUE);
437 <<<<<<< HEAD
438         elm_gengrid_item_show(next);
439 =======
440         elm_gengrid_item_show(next, ELM_GENGRID_ITEM_SCROLLTO_IN);
441 >>>>>>> remotes/origin/upstream
442      }
443
444    return EINA_TRUE;
445 }
446
447 static Eina_Bool
448 _item_multi_select_up(Widget_Data *wd)
449 {
450    unsigned int i;
451    Eina_Bool r = EINA_TRUE;
452
453    if (!wd->selected) return EINA_FALSE;
454
455    for (i = 0; (r) && (i < wd->nmax); i++)
456      r &= _item_multi_select_left(wd);
457
458    return r;
459 }
460
461 static Eina_Bool
462 _item_multi_select_down(Widget_Data *wd)
463 {
464    unsigned int i;
465    Eina_Bool r = EINA_TRUE;
466
467    if (!wd->selected) return EINA_FALSE;
468
469    for (i = 0; (r) && (i < wd->nmax); i++)
470      r &= _item_multi_select_right(wd);
471
472    return r;
473 }
474
475 static Eina_Bool
476 _item_single_select_up(Widget_Data *wd)
477 {
478    unsigned int i;
479
480    Elm_Gen_Item *prev;
481
482    if (!wd->selected)
483      {
484         prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
485         while ((prev) && (prev->generation < wd->generation))
486           prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
487         elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
488 <<<<<<< HEAD
489         elm_gengrid_item_show((Elm_Object_Item *) prev);
490 =======
491         elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
492 >>>>>>> remotes/origin/upstream
493         return EINA_TRUE;
494      }
495    else
496      prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
497
498    if (!prev) return EINA_FALSE;
499
500    for (i = 1; i < wd->nmax; i++)
501      {
502         Elm_Object_Item *tmp =
503            elm_gengrid_item_prev_get((Elm_Object_Item *) prev);
504         if (!tmp) return EINA_FALSE;
505         prev = (Elm_Gen_Item *) tmp;
506      }
507
508    _deselect_all_items(wd);
509
510    elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
511 <<<<<<< HEAD
512    elm_gengrid_item_show((Elm_Object_Item *) prev);
513 =======
514    elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
515 >>>>>>> remotes/origin/upstream
516    return EINA_TRUE;
517 }
518
519 static Eina_Bool
520 _item_single_select_down(Widget_Data *wd)
521 {
522    unsigned int i;
523
524    Elm_Gen_Item *next;
525
526    if (!wd->selected)
527      {
528         next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
529         while ((next) && (next->generation < wd->generation))
530           next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
531         elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
532 <<<<<<< HEAD
533         elm_gengrid_item_show((Elm_Object_Item *) next);
534 =======
535         elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN);
536 >>>>>>> remotes/origin/upstream
537         return EINA_TRUE;
538      }
539    else
540      next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
541
542    if (!next) return EINA_FALSE;
543
544    for (i = 1; i < wd->nmax; i++)
545      {
546         Elm_Object_Item *tmp =
547            elm_gengrid_item_next_get((Elm_Object_Item *) next);
548         if (!tmp) return EINA_FALSE;
549         next = (Elm_Gen_Item *) tmp;
550      }
551
552    _deselect_all_items(wd);
553
554    elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
555 <<<<<<< HEAD
556    elm_gengrid_item_show((Elm_Object_Item *) next);
557 =======
558    elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN);
559 >>>>>>> remotes/origin/upstream
560    return EINA_TRUE;
561 }
562
563 static Eina_Bool
564 _item_single_select_left(Widget_Data *wd)
565 {
566    Elm_Gen_Item *prev;
567    if (!wd->selected)
568      {
569         prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
570         while ((prev) && (prev->generation < wd->generation))
571           prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
572      }
573    else
574      prev = (Elm_Gen_Item *) elm_gengrid_item_prev_get(wd->last_selected_item);
575
576    if (!prev) return EINA_FALSE;
577
578    _deselect_all_items(wd);
579
580    elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE);
581 <<<<<<< HEAD
582    elm_gengrid_item_show((Elm_Object_Item *) prev);
583 =======
584    elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
585 >>>>>>> remotes/origin/upstream
586    return EINA_TRUE;
587 }
588
589 static Eina_Bool
590 _item_single_select_right(Widget_Data *wd)
591 {
592    Elm_Gen_Item *next;
593    if (!wd->selected)
594      {
595         next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
596         while ((next) && (next->generation < wd->generation))
597           next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
598      }
599    else
600      next = (Elm_Gen_Item *) elm_gengrid_item_next_get(wd->last_selected_item);
601
602    if (!next) return EINA_FALSE;
603
604    _deselect_all_items(wd);
605
606    elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE);
607 <<<<<<< HEAD
608    elm_gengrid_item_show((Elm_Object_Item *) next);
609 =======
610    elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN);
611 >>>>>>> remotes/origin/upstream
612    return EINA_TRUE;
613 }
614
615 static void
616 _on_focus_hook(void *data   __UNUSED__,
617                Evas_Object *obj)
618 {
619    Widget_Data *wd = elm_widget_data_get(obj);
620    if (!wd) return;
621    if (elm_widget_focus_get(obj))
622      {
623         edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
624         evas_object_focus_set(wd->obj, EINA_TRUE);
625         if ((wd->selected) && (!wd->last_selected_item))
626           wd->last_selected_item = eina_list_data_get(wd->selected);
627      }
628    else
629      {
630         edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
631         evas_object_focus_set(wd->obj, EINA_FALSE);
632      }
633 }
634
635 static void
636 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
637 {
638    Widget_Data *wd = elm_widget_data_get(obj);
639    Elm_Gen_Item *it;
640    if (!wd) return;
641    elm_smart_scroller_mirrored_set(wd->scr, rtl);
642    if (!wd->items) return;
643    it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
644
645    while (it)
646      {
647         edje_object_mirrored_set(VIEW(it), rtl);
648 <<<<<<< HEAD
649         elm_gengrid_item_update((Elm_Object_Item *) it);
650 =======
651         elm_gengrid_item_update((Elm_Object_Item *)it);
652 >>>>>>> remotes/origin/upstream
653         it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
654      }
655 }
656
657 static void
658 _theme_hook(Evas_Object *obj)
659 {
660    Widget_Data *wd = elm_widget_data_get(obj);
661    if (!wd) return;
662    _elm_widget_mirrored_reload(obj);
663    _mirrored_set(obj, elm_widget_mirrored_get(obj));
664    elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
665                                        elm_widget_style_get(obj));
666 }
667
668 static void
669 _del_pre_hook(Evas_Object *obj)
670 {
671    Widget_Data *wd = elm_widget_data_get(obj);
672    if (!wd) return;
673    elm_gengrid_clear(obj);
674    evas_object_del(wd->pan_smart);
675    wd->pan_smart = NULL;
676 }
677
678 static void
679 _del_hook(Evas_Object *obj)
680 {
681    Widget_Data *wd = elm_widget_data_get(obj);
682    if (wd->calc_job) ecore_job_del(wd->calc_job);
683    free(wd);
684 }
685
686 static void
687 _signal_emit_hook(Evas_Object *obj,
688                   const char  *emission,
689                   const char  *source)
690 {
691    Widget_Data *wd = elm_widget_data_get(obj);
692    if (!wd) return;
693    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
694                            emission, source);
695 }
696
697 static void
698 _signal_callback_add_hook(Evas_Object *obj,
699                           const char  *emission,
700                           const char  *source,
701                           Edje_Signal_Cb func_cb,
702                           void *data)
703 {
704    Widget_Data *wd = elm_widget_data_get(obj);
705    if (!wd) return;
706    edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
707                                    emission, source, func_cb, data);
708 }
709
710 static void
711 _signal_callback_del_hook(Evas_Object *obj,
712                           const char  *emission,
713                           const char  *source,
714                           Edje_Signal_Cb func_cb,
715                           void *data)
716 {
717    Widget_Data *wd = elm_widget_data_get(obj);
718    if (!wd) return;
719    edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scr),
720                                         emission, source, func_cb, data);
721 }
722
723 static void
724 _mouse_move(void        *data,
725             Evas *evas   __UNUSED__,
726             Evas_Object *obj,
727             void        *event_info)
728 {
729    Elm_Gen_Item *it = data;
730    Evas_Event_Mouse_Move *ev = event_info;
731    Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
732    Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
733
734    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
735      {
736         if (!it->wd->on_hold)
737           {
738              it->wd->on_hold = EINA_TRUE;
739              if (!it->wd->wasselected)
740                _item_unselect(it);
741           }
742      }
743    if ((it->dragging) && (it->down))
744      {
745         if (it->long_timer)
746           {
747              ecore_timer_del(it->long_timer);
748              it->long_timer = NULL;
749           }
750         evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
751         return;
752      }
753    if ((!it->down) || (it->wd->longpressed))
754      {
755         if (it->long_timer)
756           {
757              ecore_timer_del(it->long_timer);
758              it->long_timer = NULL;
759           }
760         if ((it->wd->reorder_mode) && (it->wd->reorder_it))
761           {
762              evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
763
764              it_scrl_x = ev->cur.canvas.x - it->wd->reorder_it->dx;
765              it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
766
767              if (it_scrl_x < ox) it->wd->reorder_item_x = ox;
768              else if (it_scrl_x + it->wd->item_width > ox + ow)
769                it->wd->reorder_item_x = ox + ow - it->wd->item_width;
770              else it->wd->reorder_item_x = it_scrl_x;
771
772              if (it_scrl_y < oy) it->wd->reorder_item_y = oy;
773              else if (it_scrl_y + it->wd->item_height > oy + oh)
774                it->wd->reorder_item_y = oy + oh - it->wd->item_height;
775              else it->wd->reorder_item_y = it_scrl_y;
776
777              if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
778              it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
779           }
780         return;
781      }
782 <<<<<<< HEAD
783    if (!it->display_only)
784 =======
785    if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
786 >>>>>>> remotes/origin/upstream
787      elm_coords_finger_size_adjust(1, &minw, 1, &minh);
788    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
789    x = ev->cur.canvas.x - x;
790    y = ev->cur.canvas.y - y;
791    dx = x - it->dx;
792    adx = dx;
793    if (adx < 0) adx = -dx;
794    dy = y - it->dy;
795    ady = dy;
796    if (ady < 0) ady = -dy;
797    minw /= 2;
798    minh /= 2;
799    if ((adx > minw) || (ady > minh))
800      {
801         const char *left_drag, *right_drag;
802         if (!elm_widget_mirrored_get(WIDGET(it)))
803           {
804              left_drag = SIG_DRAG_START_LEFT;
805              right_drag = SIG_DRAG_START_RIGHT;
806           }
807         else
808           {
809              left_drag = SIG_DRAG_START_RIGHT;
810              right_drag = SIG_DRAG_START_LEFT;
811           }
812
813         it->dragging = 1;
814         if (it->long_timer)
815           {
816              ecore_timer_del(it->long_timer);
817              it->long_timer = NULL;
818           }
819         if (!it->wd->wasselected)
820           _item_unselect(it);
821         if (dy < 0)
822           {
823              if (ady > adx)
824                evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_START_UP,
825                                                it);
826              else
827                {
828                   if (dx < 0)
829                     evas_object_smart_callback_call(WIDGET(it),
830                                                     left_drag, it);
831                }
832           }
833         else
834           {
835              if (ady > adx)
836                evas_object_smart_callback_call(WIDGET(it),
837                                                SIG_DRAG_START_DOWN, it);
838              else
839                {
840                   if (dx < 0)
841                     evas_object_smart_callback_call(WIDGET(it),
842                                                     left_drag, it);
843                   else
844                     evas_object_smart_callback_call(WIDGET(it),
845                                                     right_drag, it);
846                }
847           }
848      }
849 }
850
851 static Eina_Bool
852 _long_press(void *data)
853 {
854    Elm_Gen_Item *it = data;
855
856    it->long_timer = NULL;
857    if (elm_widget_item_disabled_get(it)|| (it->dragging))
858      return ECORE_CALLBACK_CANCEL;
859    it->wd->longpressed = EINA_TRUE;
860    evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
861    if (it->wd->reorder_mode)
862      {
863         it->wd->reorder_it = it;
864         evas_object_raise(VIEW(it));
865         elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
866         elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
867         edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
868      }
869    return ECORE_CALLBACK_CANCEL;
870 }
871
872 static void
873 _mouse_down(void        *data,
874             Evas *evas   __UNUSED__,
875             Evas_Object *obj,
876             void        *event_info)
877 {
878    Elm_Gen_Item *it = data;
879    Evas_Event_Mouse_Down *ev = event_info;
880    Evas_Coord x, y;
881
882    if (ev->button != 1) return;
883    it->down = 1;
884    it->dragging = 0;
885    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
886    it->dx = ev->canvas.x - x;
887    it->dy = ev->canvas.y - y;
888    it->wd->longpressed = EINA_FALSE;
889    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
890    else it->wd->on_hold = EINA_FALSE;
891    if (it->wd->on_hold) return;
892    it->wd->wasselected = it->selected;
893    _item_highlight(it);
894    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
895      {
896         evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
897         evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
898      }
899    if (it->long_timer) ecore_timer_del(it->long_timer);
900    if (it->realized)
901      it->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
902                                         _long_press, it);
903    else
904      it->long_timer = NULL;
905 }
906
907 static void
908 _mouse_up(void            *data,
909           Evas *evas       __UNUSED__,
910           Evas_Object *obj __UNUSED__,
911           void            *event_info)
912 {
913    Elm_Gen_Item *it = data;
914    Evas_Event_Mouse_Up *ev = event_info;
915    Eina_Bool dragged = EINA_FALSE;
916
917    if (ev->button != 1) return;
918    it->down = EINA_FALSE;
919    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
920    else it->wd->on_hold = EINA_FALSE;
921    if (it->long_timer)
922      {
923         ecore_timer_del(it->long_timer);
924         it->long_timer = NULL;
925      }
926    if (it->dragging)
927      {
928         it->dragging = EINA_FALSE;
929         evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
930         dragged = EINA_TRUE;
931      }
932    if (it->wd->on_hold)
933      {
934         it->wd->longpressed = EINA_FALSE;
935         it->wd->on_hold = EINA_FALSE;
936         return;
937      }
938    if ((it->wd->reorder_mode) && (it->wd->reorder_it))
939      {
940         evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it->wd->reorder_it);
941         it->wd->reorder_it = NULL;
942         it->wd->move_effect_enabled = EINA_FALSE;
943         if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
944           it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
945
946         elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
947         elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
948         edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
949      }
950    if (it->wd->longpressed)
951      {
952         it->wd->longpressed = EINA_FALSE;
953         if (!it->wd->wasselected) _item_unselect(it);
954         it->wd->wasselected = EINA_FALSE;
955         return;
956      }
957    if (dragged)
958      {
959         if (it->want_unrealize)
960 <<<<<<< HEAD
961           _elm_gengrid_item_unrealize(it, EINA_FALSE);
962 =======
963           _elm_genlist_item_unrealize(it, EINA_FALSE);
964 >>>>>>> remotes/origin/upstream
965      }
966    if (elm_widget_item_disabled_get(it) || (dragged)) return;
967    if (it->wd->multi)
968      {
969         if (!it->selected)
970           {
971              _item_highlight(it);
972              it->sel_cb(it);
973           }
974         else _item_unselect(it);
975      }
976    else
977      {
978         if (!it->selected)
979           {
980              while (it->wd->selected)
981                _item_unselect(it->wd->selected->data);
982           }
983         else
984           {
985              const Eina_List *l, *l_next;
986              Elm_Gen_Item *item2;
987
988              EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, item2)
989                 if (item2 != it) _item_unselect(item2);
990           }
991         _item_highlight(it);
992         it->sel_cb(it);
993      }
994 }
995
996 static void
997 _item_highlight(Elm_Gen_Item *it)
998 {
999 <<<<<<< HEAD
1000    if ((it->wd->no_select) || (it->generation < it->wd->generation) || (it->highlighted)) return;
1001 =======
1002    if ((it->wd->select_mode == ELM_OBJECT_SELECT_MODE_NONE) ||
1003        (it->wd->no_highlight) || (it->highlighted) ||
1004        (it->generation < it->wd->generation)) return;
1005 >>>>>>> remotes/origin/upstream
1006    edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1007    it->highlighted = EINA_TRUE;
1008 }
1009
1010 static void
1011 <<<<<<< HEAD
1012 =======
1013 _elm_gengrid_item_index_update(Elm_Gen_Item *it)
1014 {
1015    if (it->position_update)
1016      {
1017         evas_object_smart_callback_call(WIDGET(it), SIG_INDEX_UPDATE, it);
1018         it->position_update = EINA_FALSE;
1019      }
1020 }
1021
1022 static void
1023 >>>>>>> remotes/origin/upstream
1024 _item_realize(Elm_Gen_Item *it)
1025 {
1026    char buf[1024];
1027    char style[1024];
1028
1029    if ((it->realized) || (it->generation < it->wd->generation)) return;
1030    VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
1031    edje_object_scale_set(VIEW(it), elm_widget_scale_get(WIDGET(it)) *
1032                          _elm_config->scale);
1033    edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
1034    evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
1035    elm_widget_sub_object_add(WIDGET(it), VIEW(it));
1036    snprintf(style, sizeof(style), "item/%s",
1037             it->itc->item_style ? it->itc->item_style : "default");
1038    _elm_theme_object_set(WIDGET(it), VIEW(it), "gengrid", style,
1039                          elm_widget_style_get(WIDGET(it)));
1040    it->spacer =
1041       evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1042    evas_object_color_set(it->spacer, 0, 0, 0, 0);
1043    elm_widget_sub_object_add(WIDGET(it), it->spacer);
1044    evas_object_size_hint_min_set(it->spacer, 2 * _elm_config->scale, 1);
1045    edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
1046
1047    if (it->itc->func.text_get)
1048      {
1049         const Eina_List *l;
1050         const char *key;
1051
1052         it->texts =
1053            elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
1054                                                           "texts"));
1055         EINA_LIST_FOREACH(it->texts, l, key)
1056           {
1057              char *s = it->itc->func.text_get
1058                 ((void *)it->base.data, WIDGET(it), key);
1059              if (s)
1060                {
1061                   edje_object_part_text_set(VIEW(it), key, s);
1062                   free(s);
1063                }
1064           }
1065      }
1066
1067    if (it->itc->func.content_get)
1068      {
1069         const Eina_List *l;
1070         const char *key;
1071         Evas_Object *ic = NULL;
1072
1073         it->contents =
1074            elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
1075                                                           "contents"));
1076         EINA_LIST_FOREACH(it->contents, l, key)
1077           {
1078              if (it->itc->func.content_get)
1079                ic = it->itc->func.content_get
1080                   ((void *)it->base.data, WIDGET(it), key);
1081              if (ic)
1082                {
1083                   it->content_objs = eina_list_append(it->content_objs, ic);
1084                   edje_object_part_swallow(VIEW(it), key, ic);
1085                   evas_object_show(ic);
1086                   elm_widget_sub_object_add(WIDGET(it), ic);
1087                }
1088           }
1089      }
1090
1091    if (it->itc->func.state_get)
1092      {
1093         const Eina_List *l;
1094         const char *key;
1095
1096         it->states =
1097            elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
1098                                                           "states"));
1099         EINA_LIST_FOREACH(it->states, l, key)
1100           {
1101              Eina_Bool on = it->itc->func.state_get
1102                 ((void *)it->base.data, WIDGET(it), l->data);
1103              if (on)
1104                {
1105                   snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1106                   edje_object_signal_emit(VIEW(it), buf, "elm");
1107                }
1108           }
1109      }
1110
1111    if (it->group)
1112      {
1113         if ((!it->wd->group_item_width) && (!it->wd->group_item_height))
1114           {
1115              edje_object_size_min_restricted_calc(VIEW(it),
1116                                                   &it->wd->group_item_width,
1117                                                   &it->wd->group_item_height,
1118                                                   it->wd->group_item_width,
1119                                                   it->wd->group_item_height);
1120           }
1121      }
1122    else
1123      {
1124         if ((!it->wd->item_width) && (!it->wd->item_height))
1125           {
1126              edje_object_size_min_restricted_calc(VIEW(it),
1127                                                   &it->wd->item_width,
1128                                                   &it->wd->item_height,
1129                                                   it->wd->item_width,
1130                                                   it->wd->item_height);
1131              elm_coords_finger_size_adjust(1, &it->wd->item_width,
1132                                            1, &it->wd->item_height);
1133           }
1134
1135         evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1136                                        _mouse_down, it);
1137         evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1138                                        _mouse_up, it);
1139         evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1140                                        _mouse_move, it);
1141
1142 <<<<<<< HEAD
1143 =======
1144         _elm_gengrid_item_index_update(it);
1145
1146 >>>>>>> remotes/origin/upstream
1147         if (it->selected)
1148           edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1149         if (elm_widget_item_disabled_get(it))
1150           edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1151      }
1152    evas_object_show(VIEW(it));
1153
1154    if (it->tooltip.content_cb)
1155      {
1156         elm_widget_item_tooltip_content_cb_set(it,
1157                                                it->tooltip.content_cb,
1158                                                it->tooltip.data, NULL);
1159         elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1160         elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
1161      }
1162
1163    if (it->mouse_cursor)
1164      elm_widget_item_cursor_set(it, it->mouse_cursor);
1165
1166    it->realized = EINA_TRUE;
1167    it->want_unrealize = EINA_FALSE;
1168 }
1169
1170 static void
1171 _item_unrealize_cb(Elm_Gen_Item *it)
1172 {
1173    evas_object_del(VIEW(it));
1174    VIEW(it) = NULL;
1175    evas_object_del(it->spacer);
1176    it->spacer = NULL;
1177 }
1178
1179 static Eina_Bool
1180 _reorder_item_moving_effect_timer_cb(void *data)
1181 {
1182    Elm_Gen_Item *it = data;
1183 <<<<<<< HEAD
1184    double time, t;
1185    Evas_Coord dx, dy;
1186
1187    time = REORDER_EFFECT_TIME;
1188 =======
1189    double tt, t;
1190    Evas_Coord dx, dy;
1191
1192    tt = REORDER_EFFECT_TIME;
1193 >>>>>>> remotes/origin/upstream
1194    t = ((0.0 > (t = ecore_loop_time_get()-it->item->moving_effect_start_time)) ? 0.0 : t);
1195    dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
1196    dy = ((it->item->ty - it->item->oy) / 10) * _elm_config->scale;
1197
1198 <<<<<<< HEAD
1199    if (t <= time)
1200      {
1201         it->item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
1202         it->item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
1203 =======
1204    if (t <= tt)
1205      {
1206         it->item->rx += (1 * sin((t / tt) * (M_PI / 2)) * dx);
1207         it->item->ry += (1 * sin((t / tt) * (M_PI / 2)) * dy);
1208 >>>>>>> remotes/origin/upstream
1209      }
1210    else
1211      {
1212         it->item->rx += dx;
1213         it->item->ry += dy;
1214      }
1215
1216    if ((((dx > 0) && (it->item->rx >= it->item->tx)) || ((dx <= 0) && (it->item->rx <= it->item->tx))) &&
1217        (((dy > 0) && (it->item->ry >= it->item->ty)) || ((dy <= 0) && (it->item->ry <= it->item->ty))))
1218      {
1219         evas_object_move(VIEW(it), it->item->tx, it->item->ty);
1220         if (it->group)
1221           {
1222              Evas_Coord vw, vh;
1223              evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1224              if (it->wd->horizontal)
1225                evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1226              else
1227                evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1228           }
1229         else
1230           evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1231         it->item->moving = EINA_FALSE;
1232         it->item->item_moving_effect_timer = NULL;
1233         return ECORE_CALLBACK_CANCEL;
1234      }
1235
1236    evas_object_move(VIEW(it), it->item->rx, it->item->ry);
1237    if (it->group)
1238      {
1239         Evas_Coord vw, vh;
1240         evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1241         if (it->wd->horizontal)
1242           evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1243         else
1244           evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1245      }
1246    else
1247      evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1248
1249    return ECORE_CALLBACK_RENEW;
1250 }
1251
1252 static void
1253 _group_item_place(Pan *sd)
1254 {
1255    Evas_Coord iw, ih, vw, vh;
1256    Eina_List *l;
1257    Eina_Bool was_realized;
1258    Elm_Gen_Item *it;
1259    evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1260    if (sd->wd->horizontal)
1261      {
1262         iw = sd->wd->group_item_width;
1263         ih = vh;
1264      }
1265    else
1266      {
1267         iw = vw;
1268         ih = sd->wd->group_item_height;
1269      }
1270    EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1271      {
1272         was_realized = it->realized;
1273         if (it->item->group_realized)
1274           {
1275              _item_realize(it);
1276              if (!was_realized)
1277                evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1278              evas_object_move(VIEW(it), it->item->gx, it->item->gy);
1279              evas_object_resize(VIEW(it), iw, ih);
1280              evas_object_raise(VIEW(it));
1281           }
1282         else
1283 <<<<<<< HEAD
1284           _elm_gengrid_item_unrealize(it, EINA_FALSE);
1285 =======
1286           _elm_genlist_item_unrealize(it, EINA_FALSE);
1287 >>>>>>> remotes/origin/upstream
1288      }
1289 }
1290
1291
1292 static void
1293 _item_place(Elm_Gen_Item *it,
1294             Evas_Coord        cx,
1295             Evas_Coord        cy)
1296 {
1297    Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1298    Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1299    Eina_Bool reorder_item_move_forward = EINA_FALSE;
1300    long items_count;
1301    it->x = cx;
1302    it->y = cy;
1303    evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &vw, &vh);
1304
1305    /* Preload rows/columns at each side of the Gengrid */
1306    cvx = ox - PRELOAD * it->wd->item_width;
1307    cvy = oy - PRELOAD * it->wd->item_height;
1308    cvw = vw + 2 * PRELOAD * it->wd->item_width;
1309    cvh = vh + 2 * PRELOAD * it->wd->item_height;
1310
1311    alignh = 0;
1312    alignw = 0;
1313
1314 <<<<<<< HEAD
1315    items_count = it->wd->count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
1316 =======
1317    items_count = it->wd->item_count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
1318 >>>>>>> remotes/origin/upstream
1319    if (it->wd->horizontal)
1320      {
1321         int columns, items_visible = 0, items_row;
1322
1323         if (it->wd->item_height > 0)
1324           items_visible = vh / it->wd->item_height;
1325         if (items_visible < 1)
1326           items_visible = 1;
1327
1328         columns = items_count / items_visible;
1329         if (items_count % items_visible)
1330           columns++;
1331
1332         tcw = (it->wd->item_width * columns) + (it->wd->group_item_width * eina_list_count(it->wd->group_items));
1333         alignw = (vw - tcw) * it->wd->align_x;
1334
1335         items_row = items_visible;
1336 <<<<<<< HEAD
1337         if (items_row > it->wd->count)
1338           items_row = it->wd->count;
1339          if (it->wd->filled
1340              && (unsigned int)it->wd->nmax > (unsigned int)it->wd->count)
1341 =======
1342         if ((unsigned int)items_row > it->wd->item_count)
1343           items_row = it->wd->item_count;
1344          if (it->wd->filled
1345              && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1346 >>>>>>> remotes/origin/upstream
1347            tch = it->wd->nmax * it->wd->item_height;
1348          else
1349            tch = items_row * it->wd->item_height;
1350         alignh = (vh - tch) * it->wd->align_y;
1351      }
1352    else
1353      {
1354 <<<<<<< HEAD
1355         int rows, items_visible = 0, items_col;
1356 =======
1357         unsigned int rows, items_visible = 0, items_col;
1358 >>>>>>> remotes/origin/upstream
1359
1360         if (it->wd->item_width > 0)
1361           items_visible = vw / it->wd->item_width;
1362         if (items_visible < 1)
1363           items_visible = 1;
1364
1365         rows = items_count / items_visible;
1366         if (items_count % items_visible)
1367           rows++;
1368
1369         tch = (it->wd->item_height * rows) + (it->wd->group_item_height * eina_list_count(it->wd->group_items));
1370         alignh = (vh - tch) * it->wd->align_y;
1371
1372         items_col = items_visible;
1373 <<<<<<< HEAD
1374         if (items_col > it->wd->count)
1375           items_col = it->wd->count;
1376          if (it->wd->filled
1377              && (unsigned int)it->wd->nmax > (unsigned int)it->wd->count)
1378 =======
1379         if (items_col > it->wd->item_count)
1380           items_col = it->wd->item_count;
1381          if (it->wd->filled
1382              && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
1383 >>>>>>> remotes/origin/upstream
1384            tcw = it->wd->nmax * it->wd->item_width;
1385          else
1386            tcw = items_col * it->wd->item_width;
1387         alignw = (vw - tcw) * it->wd->align_x;
1388      }
1389
1390    if (it->group)
1391      {
1392         if (it->wd->horizontal)
1393           {
1394              x = (((cx - it->item->prev_group) * it->wd->item_width) + (it->item->prev_group * it->wd->group_item_width)) - it->wd->pan_x + ox + alignw;
1395              y = oy;
1396              iw = it->wd->group_item_width;
1397              ih = vh;
1398           }
1399         else
1400           {
1401              x = ox;
1402              y = (((cy - it->item->prev_group) * it->wd->item_height) + (it->item->prev_group * it->wd->group_item_height)) - it->wd->pan_y + oy + alignh;
1403              iw = vw;
1404              ih = it->wd->group_item_height;
1405           }
1406         it->item->gx = x;
1407         it->item->gy = y;
1408      }
1409    else
1410      {
1411         if (it->wd->horizontal)
1412           {
1413              x = (((cx - it->item->prev_group) * it->wd->item_width) + (it->item->prev_group * it->wd->group_item_width)) - it->wd->pan_x + ox + alignw;
1414              y = (cy * it->wd->item_height) - it->wd->pan_y + oy + alignh;
1415           }
1416         else
1417           {
1418              x = (cx * it->wd->item_width) - it->wd->pan_x + ox + alignw;
1419              y = (((cy - it->item->prev_group) * it->wd->item_height) + (it->item->prev_group * it->wd->group_item_height)) - it->wd->pan_y + oy + alignh;
1420           }
1421         if (elm_widget_mirrored_get(WIDGET(it)))
1422           {  /* Switch items side and componsate for pan_x when in RTL mode */
1423              evas_object_geometry_get(WIDGET(it), NULL, NULL, &ww, NULL);
1424              x = ww - x - it->wd->item_width - it->wd->pan_x - it->wd->pan_x;
1425           }
1426         iw = it->wd->item_width;
1427         ih = it->wd->item_height;
1428      }
1429
1430    Eina_Bool was_realized = it->realized;
1431    if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1432      {
1433         _item_realize(it);
1434         if (!was_realized)
1435           evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1436         if (it->parent)
1437           {
1438              if (it->wd->horizontal)
1439                {
1440                   if (it->parent->item->gx < ox)
1441                     {
1442                        it->parent->item->gx = x + it->wd->item_width - it->wd->group_item_width;
1443                        if (it->parent->item->gx > ox)
1444                          it->parent->item->gx = ox;
1445                     }
1446                   it->parent->item->group_realized = EINA_TRUE;
1447                }
1448              else
1449                {
1450                   if (it->parent->item->gy < oy)
1451                     {
1452                        it->parent->item->gy = y + it->wd->item_height - it->wd->group_item_height;
1453                        if (it->parent->item->gy > oy)
1454                          it->parent->item->gy = oy;
1455                     }
1456                   it->parent->item->group_realized = EINA_TRUE;
1457                }
1458           }
1459         if (it->wd->reorder_mode)
1460           {
1461              if (it->wd->reorder_it)
1462                {
1463                   if (it->item->moving) return;
1464
1465                   if (!it->wd->move_effect_enabled)
1466                     {
1467                        it->item->ox = x;
1468                        it->item->oy = y;
1469                     }
1470                   if (it->wd->reorder_it == it)
1471                     {
1472                        evas_object_move(VIEW(it),
1473                                         it->wd->reorder_item_x, it->wd->reorder_item_y);
1474                        evas_object_resize(VIEW(it), iw, ih);
1475                        return;
1476                     }
1477                   else
1478                     {
1479                        if (it->wd->move_effect_enabled)
1480                          {
1481                             if ((it->item->ox != x) || (it->item->oy != y))
1482                               {
1483                                  if (((it->wd->old_pan_x == it->wd->pan_x) && (it->wd->old_pan_y == it->wd->pan_y)) ||
1484                                      ((it->wd->old_pan_x != it->wd->pan_x) && !(it->item->ox - it->wd->pan_x + it->wd->old_pan_x == x)) ||
1485                                      ((it->wd->old_pan_y != it->wd->pan_y) && !(it->item->oy - it->wd->pan_y + it->wd->old_pan_y == y)))
1486                                    {
1487                                       it->item->tx = x;
1488                                       it->item->ty = y;
1489                                       it->item->rx = it->item->ox;
1490                                       it->item->ry = it->item->oy;
1491                                       it->item->moving = EINA_TRUE;
1492                                       it->item->moving_effect_start_time = ecore_loop_time_get();
1493                                       it->item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
1494                                       return;
1495                                    }
1496                               }
1497                          }
1498
1499                        /* need fix here */
1500                        Evas_Coord nx, ny, nw, nh;
1501                        if (it->group)
1502                          {
1503                             if (it->wd->horizontal)
1504                               {
1505                                  nx = x + (it->wd->group_item_width / 2);
1506                                  ny = y;
1507                                  nw = 1;
1508                                  nh = vh;
1509                               }
1510                             else
1511                               {
1512                                  nx = x;
1513                                  ny = y + (it->wd->group_item_height / 2);
1514                                  nw = vw;
1515                                  nh = 1;
1516                               }
1517                          }
1518                        else
1519                          {
1520                             nx = x + (it->wd->item_width / 2);
1521                             ny = y + (it->wd->item_height / 2);
1522                             nw = 1;
1523                             nh = 1;
1524                          }
1525
1526                        if ( ELM_RECTS_INTERSECT(it->wd->reorder_item_x, it->wd->reorder_item_y,
1527                                                 it->wd->item_width, it->wd->item_height,
1528                                                 nx, ny, nw, nh))
1529                          {
1530                             if (it->wd->horizontal)
1531                               {
1532                                  if ((it->wd->nmax * it->wd->reorder_it->x + it->wd->reorder_it->y) >
1533                                      (it->wd->nmax * it->x + it->y))
1534                                    reorder_item_move_forward = EINA_TRUE;
1535                               }
1536                             else
1537                               {
1538                                  if ((it->wd->nmax * it->wd->reorder_it->y + it->wd->reorder_it->x) >
1539                                      (it->wd->nmax * it->y + it->x))
1540                                    reorder_item_move_forward = EINA_TRUE;
1541                               }
1542
1543                             it->wd->items = eina_inlist_remove(it->wd->items,
1544                                                                  EINA_INLIST_GET(it->wd->reorder_it));
1545                             if (reorder_item_move_forward)
1546                               it->wd->items = eina_inlist_prepend_relative(it->wd->items,
1547                                                                              EINA_INLIST_GET(it->wd->reorder_it),
1548                                                                              EINA_INLIST_GET(it));
1549                             else
1550                               it->wd->items = eina_inlist_append_relative(it->wd->items,
1551                                                                             EINA_INLIST_GET(it->wd->reorder_it),
1552                                                                             EINA_INLIST_GET(it));
1553
1554                             it->wd->reorder_item_changed = EINA_TRUE;
1555                             it->wd->move_effect_enabled = EINA_TRUE;
1556                             if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1557                               it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1558
1559                             return;
1560                          }
1561                     }
1562                }
1563              else if (it->item->item_moving_effect_timer)
1564                {
1565                   ecore_animator_del(it->item->item_moving_effect_timer);
1566                   it->item->item_moving_effect_timer = NULL;
1567                   it->item->moving = EINA_FALSE;
1568                }
1569           }
1570         if (!it->group)
1571           {
1572              evas_object_move(VIEW(it), x, y);
1573              evas_object_resize(VIEW(it), iw, ih);
1574           }
1575         else
1576           it->item->group_realized = EINA_TRUE;
1577      }
1578    else
1579      {
1580         if (!it->group)
1581 <<<<<<< HEAD
1582           _elm_gengrid_item_unrealize(it, EINA_FALSE);
1583 =======
1584           _elm_genlist_item_unrealize(it, EINA_FALSE);
1585 >>>>>>> remotes/origin/upstream
1586         else
1587           it->item->group_realized = EINA_FALSE;
1588      }
1589 }
1590
1591 static void
1592 <<<<<<< HEAD
1593 =======
1594 _item_position_update(Eina_Inlist *list, int idx)
1595 {
1596    Elm_Gen_Item *it;
1597
1598    EINA_INLIST_FOREACH(list, it)
1599      {
1600         it->position = idx++;
1601         it->position_update = EINA_TRUE;
1602      }
1603 }
1604
1605 static void
1606 >>>>>>> remotes/origin/upstream
1607 _item_del(Elm_Gen_Item *it)
1608 {
1609    Evas_Object *obj = WIDGET(it);
1610
1611    evas_event_freeze(evas_object_evas_get(obj));
1612    it->wd->selected = eina_list_remove(it->wd->selected, it);
1613 <<<<<<< HEAD
1614    if (it->realized) _elm_gengrid_item_unrealize(it, EINA_FALSE);
1615    it->wd->count--;
1616    _elm_gengrid_item_del_serious(it);
1617 =======
1618    if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
1619    it->wd->item_count--;
1620    _elm_genlist_item_del_serious(it);
1621    elm_gengrid_item_class_unref((Elm_Gengrid_Item_Class *)it->itc);
1622 >>>>>>> remotes/origin/upstream
1623    evas_event_thaw(evas_object_evas_get(obj));
1624    evas_event_thaw_eval(evas_object_evas_get(obj));
1625 }
1626
1627 static void
1628 _item_unselect(Elm_Gen_Item *it)
1629 {
1630    if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
1631    edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
1632    it->highlighted = EINA_FALSE;
1633    if (it->selected)
1634      {
1635         it->selected = EINA_FALSE;
1636         it->wd->selected = eina_list_remove(it->wd->selected, it);
1637         evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
1638      }
1639 }
1640
1641 static void
1642 _calc_job(void *data)
1643 {
1644    Widget_Data *wd = data;
1645    Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1646    Elm_Gen_Item *it, *group_item = NULL;
1647    int count_group = 0;
1648    long count = 0;
1649    wd->items_lost = 0;
1650
1651    evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1652    if ((cvw != 0) || (cvh != 0))
1653      {
1654         if ((wd->horizontal) && (wd->item_height > 0))
1655           nmax = cvh / wd->item_height;
1656         else if (wd->item_width > 0)
1657           nmax = cvw / wd->item_width;
1658
1659         if (nmax < 1)
1660           nmax = 1;
1661
1662         EINA_INLIST_FOREACH(wd->items, it)
1663           {
1664              if (it->item->prev_group != count_group)
1665                it->item->prev_group = count_group;
1666              if (it->group)
1667                {
1668                   count = count % nmax;
1669                   if (count)
1670                     wd->items_lost += nmax - count;
1671                   //printf("%d items and I lost %d\n", count, wd->items_lost);
1672                   count_group++;
1673                   if (count) count = 0;
1674                   group_item = it;
1675                }
1676              else
1677                {
1678                   if (it->parent != group_item)
1679                     it->parent = group_item;
1680                   count++;
1681                }
1682           }
1683 <<<<<<< HEAD
1684         count = wd->count + wd->items_lost - count_group;
1685 =======
1686         count = wd->item_count + wd->items_lost - count_group;
1687 >>>>>>> remotes/origin/upstream
1688         if (wd->horizontal)
1689           {
1690              minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width);
1691              minh = nmax * wd->item_height;
1692           }
1693         else
1694           {
1695              minw = nmax * wd->item_width;
1696              minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1697           }
1698
1699         if ((minw != wd->minw) || (minh != wd->minh))
1700           {
1701              wd->minh = minh;
1702              wd->minw = minw;
1703              evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1704           }
1705
1706         wd->nmax = nmax;
1707         evas_object_smart_changed(wd->pan_smart);
1708      }
1709    wd->calc_job = NULL;
1710 }
1711
1712 static void
1713 _pan_add(Evas_Object *obj)
1714 {
1715    Pan *sd;
1716    Evas_Object_Smart_Clipped_Data *cd;
1717
1718    _pan_sc.add(obj);
1719    cd = evas_object_smart_data_get(obj);
1720    sd = ELM_NEW(Pan);
1721    if (!sd) return;
1722    sd->__clipped_data = *cd;
1723    free(cd);
1724    evas_object_smart_data_set(obj, sd);
1725 }
1726
1727 static void
1728 _pan_del(Evas_Object *obj)
1729 {
1730    Pan *sd = evas_object_smart_data_get(obj);
1731
1732    if (!sd) return;
1733    _pan_sc.del(obj);
1734 }
1735
1736 static void
1737 _pan_set(Evas_Object *obj,
1738          Evas_Coord   x,
1739          Evas_Coord   y)
1740 {
1741    Pan *sd = evas_object_smart_data_get(obj);
1742    if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1743    sd->wd->pan_x = x;
1744    sd->wd->pan_y = y;
1745    evas_object_smart_changed(obj);
1746 }
1747
1748 static void
1749 _pan_get(Evas_Object *obj,
1750          Evas_Coord  *x,
1751          Evas_Coord  *y)
1752 {
1753    Pan *sd = evas_object_smart_data_get(obj);
1754    if (x) *x = sd->wd->pan_x;
1755    if (y) *y = sd->wd->pan_y;
1756 }
1757
1758 static void
1759 _pan_child_size_get(Evas_Object *obj,
1760                     Evas_Coord  *w,
1761                     Evas_Coord  *h)
1762 {
1763    Pan *sd = evas_object_smart_data_get(obj);
1764    if (w) *w = sd->wd->minw;
1765    if (h) *h = sd->wd->minh;
1766 }
1767
1768 static void
1769 _pan_max_get(Evas_Object *obj,
1770              Evas_Coord  *x,
1771              Evas_Coord  *y)
1772 {
1773    Pan *sd = evas_object_smart_data_get(obj);
1774    Evas_Coord ow, oh;
1775
1776    if (!sd) return;
1777    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1778    if (x)
1779      *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1780    if (y)
1781      *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1782 }
1783
1784 static void
1785 _pan_min_get(Evas_Object *obj,
1786              Evas_Coord  *x,
1787              Evas_Coord  *y)
1788 {
1789    Pan *sd = evas_object_smart_data_get(obj);
1790    Evas_Coord mx = 0, my = 0;
1791
1792    if (!sd) return;
1793    _pan_max_get(obj, &mx, &my);
1794    if (x)
1795      *x = -mx * sd->wd->align_x;
1796    if (y)
1797      *y = -my * sd->wd->align_y;
1798 }
1799
1800 static void
1801 _pan_resize(Evas_Object *obj,
1802             Evas_Coord   w,
1803             Evas_Coord   h)
1804 {
1805    Pan *sd = evas_object_smart_data_get(obj);
1806    Evas_Coord ow, oh;
1807
1808    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1809    if ((ow == w) && (oh == h)) return;
1810    if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1811    sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1812 }
1813
1814 static void
1815 _pan_calculate(Evas_Object *obj)
1816 {
1817    Pan *sd = evas_object_smart_data_get(obj);
1818    Evas_Coord cx = 0, cy = 0;
1819    Elm_Gen_Item *it;
1820
1821    if (!sd) return;
1822    if (!sd->wd->nmax) return;
1823
1824    sd->wd->reorder_item_changed = EINA_FALSE;
1825
1826    EINA_INLIST_FOREACH(sd->wd->items, it)
1827      {
1828         if (it->group)
1829           {
1830              if (sd->wd->horizontal)
1831                {
1832                   if (cy)
1833                     {
1834                        cx++;
1835                        cy = 0;
1836                     }
1837                }
1838              else
1839                {
1840                   if (cx)
1841                     {
1842                        cx = 0;
1843                        cy++;
1844                     }
1845                }
1846           }
1847         _item_place(it, cx, cy);
1848         if (sd->wd->reorder_item_changed) return;
1849         if (it->group)
1850           {
1851              if (sd->wd->horizontal)
1852                {
1853                   cx++;
1854                   cy = 0;
1855                }
1856              else
1857                {
1858                   cx = 0;
1859                   cy++;
1860                }
1861           }
1862         else
1863           {
1864              if (sd->wd->horizontal)
1865                {
1866                   cy = (cy + 1) % sd->wd->nmax;
1867                   if (!cy) cx++;
1868                }
1869              else
1870                {
1871                   cx = (cx + 1) % sd->wd->nmax;
1872                   if (!cx) cy++;
1873                }
1874           }
1875      }
1876    _group_item_place(sd);
1877
1878
1879    if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
1880      {
1881         if (!sd->wd->reorder_item_changed)
1882           {
1883              sd->wd->old_pan_x = sd->wd->pan_x;
1884              sd->wd->old_pan_y = sd->wd->pan_y;
1885           }
1886         sd->wd->move_effect_enabled = EINA_FALSE;
1887      }
1888    evas_object_smart_callback_call(sd->wd->obj, SIG_CHANGED, NULL);
1889 }
1890
1891 static void
1892 _pan_move(Evas_Object *obj,
1893           Evas_Coord x __UNUSED__,
1894           Evas_Coord y __UNUSED__)
1895 {
1896    Pan *sd = evas_object_smart_data_get(obj);
1897    if (!sd) return;
1898    if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1899    sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1900 }
1901
1902 static void
1903 _hold_on(void *data       __UNUSED__,
1904          Evas_Object     *obj,
1905          void *event_info __UNUSED__)
1906 {
1907    Widget_Data *wd = elm_widget_data_get(obj);
1908    if (!wd) return;
1909    elm_smart_scroller_hold_set(wd->scr, 1);
1910 }
1911
1912 static void
1913 _hold_off(void *data       __UNUSED__,
1914           Evas_Object     *obj,
1915           void *event_info __UNUSED__)
1916 {
1917    Widget_Data *wd = elm_widget_data_get(obj);
1918    if (!wd) return;
1919    elm_smart_scroller_hold_set(wd->scr, 0);
1920 }
1921
1922 static void
1923 _freeze_on(void *data       __UNUSED__,
1924            Evas_Object     *obj,
1925            void *event_info __UNUSED__)
1926 {
1927    Widget_Data *wd = elm_widget_data_get(obj);
1928    if (!wd) return;
1929    elm_smart_scroller_freeze_set(wd->scr, 1);
1930 }
1931
1932 static void
1933 _freeze_off(void *data       __UNUSED__,
1934             Evas_Object     *obj,
1935             void *event_info __UNUSED__)
1936 {
1937    Widget_Data *wd = elm_widget_data_get(obj);
1938    if (!wd) return;
1939    elm_smart_scroller_freeze_set(wd->scr, 0);
1940 }
1941
1942 static void
1943 _scr_anim_start(void        *data,
1944                 Evas_Object *obj __UNUSED__,
1945                 void        *event_info __UNUSED__)
1946 {
1947    evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1948 }
1949
1950 static void
1951 _scr_anim_stop(void        *data,
1952                 Evas_Object *obj __UNUSED__,
1953                 void        *event_info __UNUSED__)
1954 {
1955    evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1956 }
1957
1958 static void
1959 _scr_drag_start(void            *data,
1960                 Evas_Object *obj __UNUSED__,
1961                 void *event_info __UNUSED__)
1962 {
1963    evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1964 }
1965
1966 static void
1967 _scr_drag_stop(void            *data,
1968                Evas_Object *obj __UNUSED__,
1969                void *event_info __UNUSED__)
1970 {
1971    evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1972 }
1973
1974 static void
1975 _edge_left(void        *data,
1976            Evas_Object *scr __UNUSED__,
1977            void        *event_info __UNUSED__)
1978 {
1979    evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
1980 }
1981
1982 static void
1983 _edge_right(void        *data,
1984             Evas_Object *scr __UNUSED__,
1985             void        *event_info __UNUSED__)
1986 {
1987    evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
1988 }
1989
1990 static void
1991 _edge_top(void        *data,
1992           Evas_Object *scr __UNUSED__,
1993           void        *event_info __UNUSED__)
1994 {
1995    evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
1996 }
1997
1998 static void
1999 _edge_bottom(void        *data,
2000              Evas_Object *scr __UNUSED__,
2001              void        *event_info __UNUSED__)
2002 {
2003    evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
2004 }
2005
2006 static void
2007 _scr_scroll(void            *data,
2008             Evas_Object *obj __UNUSED__,
2009             void *event_info __UNUSED__)
2010 {
2011    evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
2012 }
2013
2014 static int
2015 <<<<<<< HEAD
2016 _elm_gengrid_item_compare_data(const void *data, const void *data1)
2017 {
2018    const Elm_Gen_Item *it = data;
2019    const Elm_Gen_Item *item1 = data1;
2020
2021    return it->wd->item_compare_data_cb(it->base.data, item1->base.data);
2022 }
2023
2024 static int
2025 =======
2026 >>>>>>> remotes/origin/upstream
2027 _elm_gengrid_item_compare(const void *data, const void *data1)
2028 {
2029    Elm_Gen_Item *it, *item1;
2030    it = ELM_GEN_ITEM_FROM_INLIST(data);
2031    item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
2032    return it->wd->item_compare_cb(it, item1);
2033 }
2034
2035 static void
2036 _item_disable_hook(Elm_Object_Item *it)
2037 {
2038 <<<<<<< HEAD
2039    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2040    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2041 =======
2042    Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2043 >>>>>>> remotes/origin/upstream
2044
2045    if (_it->generation < _it->wd->generation) return;
2046
2047    if (_it->realized)
2048      {
2049         if (elm_widget_item_disabled_get(_it))
2050           edje_object_signal_emit(VIEW(_it), "elm,state,disabled", "elm");
2051         else
2052           edje_object_signal_emit(VIEW(_it), "elm,state,enabled", "elm");
2053      }
2054 }
2055
2056 static void
2057 _item_del_pre_hook(Elm_Object_Item *it)
2058 {
2059 <<<<<<< HEAD
2060    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2061    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2062    if ((_it->relcount > 0) || (_it->walking > 0))
2063      {
2064         _elm_gengrid_item_del_notserious(_it);
2065 =======
2066    Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2067    if ((_it->relcount > 0) || (_it->walking > 0))
2068      {
2069         _elm_genlist_item_del_notserious(_it);
2070 >>>>>>> remotes/origin/upstream
2071         return;
2072      }
2073
2074    _item_del(_it);
2075 }
2076
2077 <<<<<<< HEAD
2078 #if 1
2079 void
2080 _item_select(Elm_Gen_Item *it)
2081 {
2082    if ((it->wd->no_select) || (it->generation < it->wd->generation) || (it->mode_set)) return;
2083    if (!it->selected)
2084      {
2085         it->selected = EINA_TRUE;
2086         it->wd->selected = eina_list_append(it->wd->selected, it);
2087      }
2088    else if (!it->wd->always_select) return;
2089
2090    evas_object_ref(WIDGET(it));
2091    it->walking++;
2092    it->wd->walking++;
2093    if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), it);
2094    if (it->generation == it->wd->generation)
2095      evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
2096    it->walking--;
2097    it->wd->walking--;
2098    evas_object_unref(WIDGET(it));
2099    if ((it->wd->clear_me) && (!it->wd->walking))
2100      _elm_gengrid_clear(WIDGET(it), EINA_TRUE);
2101    else
2102      {
2103         if ((!it->walking) && (it->generation < it->wd->generation))
2104           {
2105              if (!it->relcount)
2106                {
2107                   it->del_cb(it);
2108                   elm_widget_item_free(it);
2109                }
2110           }
2111         else
2112           it->wd->last_selected_item = (Elm_Object_Item *) it;
2113      }
2114 }
2115
2116 static Evas_Object *
2117 _item_content_get_hook(Elm_Gen_Item *it, const char *part)
2118 {
2119    return edje_object_part_swallow_get(VIEW(it), part);
2120 }
2121
2122 static void
2123 _item_content_set_hook(Elm_Gen_Item *it, const char *part, Evas_Object *content)
2124 {
2125    edje_object_part_swallow(VIEW(it), part, content);
2126 }
2127
2128 static Evas_Object *
2129 _item_content_unset_hook(Elm_Gen_Item *it, const char *part)
2130 {
2131    Evas_Object *obj;
2132
2133    obj = edje_object_part_swallow_get(VIEW(it), part);
2134    if (!obj) return NULL;
2135    edje_object_part_unswallow(VIEW(it), obj);
2136    return obj;
2137 }
2138
2139 static const char *
2140 _item_text_hook(Elm_Gen_Item *it, const char *part)
2141 {
2142    if (!it->itc->func.text_get) return NULL;
2143    return edje_object_part_text_get(VIEW(it), part);
2144 }
2145
2146 Elm_Gen_Item *
2147 _elm_gengrid_item_new(Widget_Data              *wd,
2148                       const Elm_Gen_Item_Class *itc,
2149                       const void               *data,
2150                       Elm_Gen_Item             *parent,
2151                       Evas_Smart_Cb             func,
2152                       const void               *func_data)
2153 {
2154    Elm_Gen_Item *it;
2155
2156    it = elm_widget_item_new(wd->obj, Elm_Gen_Item);
2157    if (!it) return NULL;
2158    it->wd = wd;
2159    it->generation = wd->generation;
2160    it->itc = itc;
2161    it->base.data = data;
2162    it->parent = parent;
2163    it->func.func = func;
2164    it->func.data = func_data;
2165    elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
2166    elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
2167    elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
2168    //elm_widget_item_disable_hook_set(it, _item_disable_hook);
2169    //elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
2170    /* TEMPORARY */
2171    it->sel_cb = (Ecore_Cb)_item_select;
2172
2173    elm_widget_item_text_get_hook_set(it, _item_text_hook);
2174    return it;
2175 }
2176 #endif
2177
2178 =======
2179 >>>>>>> remotes/origin/upstream
2180 static Elm_Gen_Item *
2181 _item_new(Widget_Data                  *wd,
2182           const Elm_Gengrid_Item_Class *itc,
2183           const void                   *data,
2184           Evas_Smart_Cb                 func,
2185           const void                   *func_data)
2186 {
2187    Elm_Gen_Item *it;
2188
2189 <<<<<<< HEAD
2190 #if 0
2191    it = _elm_genlist_item_new(wd, itc, data, NULL, func, func_data);
2192 #else
2193    it = _elm_gengrid_item_new(wd, itc, data, NULL, func, func_data);
2194 #endif
2195    if (!it) return NULL;
2196    elm_widget_item_disable_hook_set(it, _item_disable_hook);
2197    elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
2198    it->item = ELM_NEW(Elm_Gen_Item_Type);
2199    wd->count++;
2200 =======
2201    it = _elm_genlist_item_new(wd, itc, data, NULL, func, func_data);
2202    if (!it) return NULL;
2203    elm_widget_item_disable_hook_set(it, _item_disable_hook);
2204    elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
2205    elm_gengrid_item_class_ref((Elm_Gengrid_Item_Class *)itc);
2206    it->item = ELM_NEW(Elm_Gen_Item_Type);
2207    wd->item_count++;
2208 >>>>>>> remotes/origin/upstream
2209    it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
2210    ELM_GEN_ITEM_SETUP(it);
2211
2212    return it;
2213 }
2214
2215 EAPI Evas_Object *
2216 elm_gengrid_add(Evas_Object *parent)
2217 {
2218    Evas_Object *obj;
2219    Evas *e;
2220    Widget_Data *wd;
2221    static Evas_Smart *smart = NULL;
2222    Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
2223
2224    if (!smart)
2225      {
2226         static Evas_Smart_Class sc;
2227
2228         evas_object_smart_clipped_smart_set(&_pan_sc);
2229         sc = _pan_sc;
2230         sc.name = "elm_gengrid_pan";
2231         sc.version = EVAS_SMART_CLASS_VERSION;
2232         sc.add = _pan_add;
2233         sc.del = _pan_del;
2234         sc.resize = _pan_resize;
2235         sc.move = _pan_move;
2236         sc.calculate = _pan_calculate;
2237         if (!(smart = evas_smart_class_new(&sc))) return NULL;
2238      }
2239
2240    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2241
2242    ELM_SET_WIDTYPE(widtype, "gengrid");
2243    ELM_GEN_SETUP(wd);
2244    elm_widget_type_set(obj, "gengrid");
2245    elm_widget_sub_object_add(parent, obj);
2246    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2247    elm_widget_data_set(obj, wd);
2248    elm_widget_del_hook_set(obj, _del_hook);
2249    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2250    elm_widget_theme_hook_set(obj, _theme_hook);
2251    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2252    elm_widget_can_focus_set(obj, EINA_TRUE);
2253    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2254    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2255    elm_widget_event_hook_set(obj, _event_hook);
2256
2257    wd->generation = 1;
2258    wd->scr = elm_smart_scroller_add(e);
2259    elm_smart_scroller_widget_set(wd->scr, obj);
2260    elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
2261                                        "default");
2262    elm_smart_scroller_bounce_allow_set(wd->scr, bounce,
2263 <<<<<<< HEAD
2264                                        _elm_config->thumbscroll_bounce_enable);
2265 =======
2266                                        _elm_config->thumbscroll_bounce_enable);
2267 >>>>>>> remotes/origin/upstream
2268    elm_widget_resize_object_set(obj, wd->scr);
2269
2270    evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
2271    evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
2272    evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
2273    evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
2274    evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
2275    evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
2276    evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
2277    evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom,
2278                                   obj);
2279    evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
2280
2281    wd->obj = obj;
2282    wd->align_x = 0.5;
2283    wd->align_y = 0.5;
2284    wd->h_bounce = bounce;
2285    wd->v_bounce = bounce;
2286
2287    evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2288    evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2289    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2290    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2291
2292    wd->pan_smart = evas_object_smart_add(e, smart);
2293    wd->pan = evas_object_smart_data_get(wd->pan_smart);
2294    wd->pan->wd = wd;
2295
2296    elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2297                                      _pan_set, _pan_get, _pan_max_get,
2298                                      _pan_min_get, _pan_child_size_get);
2299
2300    evas_object_smart_callbacks_descriptions_set(obj, _signals);
2301
2302    _mirrored_set(obj, elm_widget_mirrored_get(obj));
2303    return obj;
2304 }
2305
2306 EAPI void
2307 elm_gengrid_item_size_set(Evas_Object *obj,
2308                           Evas_Coord   w,
2309                           Evas_Coord   h)
2310 {
2311    ELM_CHECK_WIDTYPE(obj, widtype);
2312    Widget_Data *wd = elm_widget_data_get(obj);
2313    if (!wd) return;
2314    if ((wd->item_width == w) && (wd->item_height == h)) return;
2315    wd->item_width = w;
2316    wd->item_height = h;
2317    if (wd->calc_job) ecore_job_del(wd->calc_job);
2318    wd->calc_job = ecore_job_add(_calc_job, wd);
2319 }
2320
2321 EAPI void
2322 elm_gengrid_item_size_get(const Evas_Object *obj,
2323                           Evas_Coord        *w,
2324                           Evas_Coord        *h)
2325 {
2326    ELM_CHECK_WIDTYPE(obj, widtype);
2327    Widget_Data *wd = elm_widget_data_get(obj);
2328    if (!wd) return;
2329    if (w) *w = wd->item_width;
2330    if (h) *h = wd->item_height;
2331 }
2332
2333 EAPI void
2334 elm_gengrid_group_item_size_set(Evas_Object *obj,
2335                           Evas_Coord   w,
2336                           Evas_Coord   h)
2337 {
2338    ELM_CHECK_WIDTYPE(obj, widtype);
2339    Widget_Data *wd = elm_widget_data_get(obj);
2340    if (!wd) return;
2341    if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
2342    wd->group_item_width = w;
2343    wd->group_item_height = h;
2344    if (wd->calc_job) ecore_job_del(wd->calc_job);
2345    wd->calc_job = ecore_job_add(_calc_job, wd);
2346 }
2347
2348 EAPI void
2349 elm_gengrid_group_item_size_get(const Evas_Object *obj,
2350                           Evas_Coord        *w,
2351                           Evas_Coord        *h)
2352 {
2353    ELM_CHECK_WIDTYPE(obj, widtype);
2354    Widget_Data *wd = elm_widget_data_get(obj);
2355    if (!wd) return;
2356    if (w) *w = wd->group_item_width;
2357    if (h) *h = wd->group_item_height;
2358 }
2359
2360 EAPI void
2361 elm_gengrid_align_set(Evas_Object *obj,
2362                       double       align_x,
2363                       double       align_y)
2364 {
2365    ELM_CHECK_WIDTYPE(obj, widtype);
2366
2367    Widget_Data *wd = elm_widget_data_get(obj);
2368    double old_h = wd->align_x, old_y = wd->align_y;
2369
2370    if (align_x > 1.0)
2371      align_x = 1.0;
2372    else if (align_x < 0.0)
2373      align_x = 0.0;
2374    wd->align_x = align_x;
2375
2376    if (align_y > 1.0)
2377      align_y = 1.0;
2378    else if (align_y < 0.0)
2379      align_y = 0.0;
2380    wd->align_y = align_y;
2381
2382    if ((old_h != wd->align_x) || (old_y != wd->align_y))
2383      evas_object_smart_calculate(wd->pan_smart);
2384 }
2385
2386 EAPI void
2387 elm_gengrid_align_get(const Evas_Object *obj,
2388                       double            *align_x,
2389                       double            *align_y)
2390 {
2391    ELM_CHECK_WIDTYPE(obj, widtype);
2392    Widget_Data *wd = elm_widget_data_get(obj);
2393    if (align_x) *align_x = wd->align_x;
2394    if (align_y) *align_y = wd->align_y;
2395 }
2396
2397 EAPI Elm_Object_Item *
2398 elm_gengrid_item_append(Evas_Object                  *obj,
2399                         const Elm_Gengrid_Item_Class *itc,
2400                         const void                   *data,
2401                         Evas_Smart_Cb                 func,
2402                         const void                   *func_data)
2403 {
2404    Elm_Gen_Item *it;
2405    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2406    Widget_Data *wd = elm_widget_data_get(obj);
2407    if (!wd) return NULL;
2408
2409    it = _item_new(wd, itc, data, func, func_data);
2410    if (!it) return NULL;
2411    wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2412 <<<<<<< HEAD
2413 =======
2414    it->position = eina_inlist_count(wd->items);
2415    it->position_update = EINA_TRUE;
2416 >>>>>>> remotes/origin/upstream
2417
2418    if (it->group)
2419      wd->group_items = eina_list_prepend(wd->group_items, it);
2420
2421    if (wd->calc_job) ecore_job_del(wd->calc_job);
2422    wd->calc_job = ecore_job_add(_calc_job, wd);
2423
2424 <<<<<<< HEAD
2425    return (Elm_Object_Item *) it;
2426 =======
2427    return (Elm_Object_Item *)it;
2428 >>>>>>> remotes/origin/upstream
2429 }
2430
2431 EAPI Elm_Object_Item *
2432 elm_gengrid_item_prepend(Evas_Object                  *obj,
2433                          const Elm_Gengrid_Item_Class *itc,
2434                          const void                   *data,
2435                          Evas_Smart_Cb                 func,
2436                          const void                   *func_data)
2437 {
2438    Elm_Gen_Item *it;
2439    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2440    Widget_Data *wd = elm_widget_data_get(obj);
2441    if (!wd) return NULL;
2442
2443    it = _item_new(wd, itc, data, func, func_data);
2444    if (!it) return NULL;
2445    wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2446 <<<<<<< HEAD
2447 =======
2448    _item_position_update(wd->items, 0);
2449
2450 >>>>>>> remotes/origin/upstream
2451    if (it->group)
2452      wd->group_items = eina_list_append(wd->group_items, it);
2453
2454    if (wd->calc_job) ecore_job_del(wd->calc_job);
2455    wd->calc_job = ecore_job_add(_calc_job, wd);
2456
2457 <<<<<<< HEAD
2458    return (Elm_Object_Item *) it;
2459 =======
2460    return (Elm_Object_Item *)it;
2461 >>>>>>> remotes/origin/upstream
2462 }
2463
2464 EAPI Elm_Object_Item *
2465 elm_gengrid_item_insert_before(Evas_Object                  *obj,
2466                                const Elm_Gengrid_Item_Class *itc,
2467                                const void                   *data,
2468                                Elm_Object_Item              *relative,
2469                                Evas_Smart_Cb                 func,
2470                                const void                   *func_data)
2471 {
2472    Elm_Gen_Item *it;
2473    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2474    ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2475    Widget_Data *wd = elm_widget_data_get(obj);
2476    if (!wd) return NULL;
2477
2478    it = _item_new(wd, itc, data, func, func_data);
2479    if (!it) return NULL;
2480    wd->items = eina_inlist_prepend_relative
2481       (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2482 <<<<<<< HEAD
2483 =======
2484    Eina_Inlist *tmp = eina_inlist_find(wd->items, EINA_INLIST_GET(it));
2485    _item_position_update(tmp, ((Elm_Gen_Item *)relative)->position);
2486
2487 >>>>>>> remotes/origin/upstream
2488    if (it->group)
2489      wd->group_items = eina_list_append_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2490
2491    if (wd->calc_job) ecore_job_del(wd->calc_job);
2492    wd->calc_job = ecore_job_add(_calc_job, wd);
2493
2494 <<<<<<< HEAD
2495    return (Elm_Object_Item *) it;
2496 =======
2497    return (Elm_Object_Item *)it;
2498 >>>>>>> remotes/origin/upstream
2499 }
2500
2501 EAPI Elm_Object_Item *
2502 elm_gengrid_item_insert_after(Evas_Object                  *obj,
2503                               const Elm_Gengrid_Item_Class *itc,
2504                               const void                   *data,
2505                               Elm_Object_Item              *relative,
2506                               Evas_Smart_Cb                 func,
2507                               const void                   *func_data)
2508 {
2509    Elm_Gen_Item *it;
2510    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2511    ELM_OBJ_ITEM_CHECK_OR_RETURN(relative, NULL);
2512    Widget_Data *wd = elm_widget_data_get(obj);
2513    if (!wd) return NULL;
2514
2515    it = _item_new(wd, itc, data, func, func_data);
2516    if (!it) return NULL;
2517    wd->items = eina_inlist_append_relative
2518       (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET((Elm_Gen_Item *) relative));
2519 <<<<<<< HEAD
2520 =======
2521    Eina_Inlist *tmp = eina_inlist_find(wd->items, EINA_INLIST_GET(it));
2522    _item_position_update(tmp, ((Elm_Gen_Item *)relative)->position+1);
2523
2524 >>>>>>> remotes/origin/upstream
2525    if (it->group)
2526      wd->group_items = eina_list_prepend_relative(wd->group_items, it, ((Elm_Gen_Item *) relative)->parent);
2527
2528    if (wd->calc_job) ecore_job_del(wd->calc_job);
2529    wd->calc_job = ecore_job_add(_calc_job, wd);
2530
2531 <<<<<<< HEAD
2532    return (Elm_Object_Item *) it;
2533 }
2534
2535 EAPI Elm_Object_Item *
2536 elm_gengrid_item_direct_sorted_insert(Evas_Object                  *obj,
2537                                       const Elm_Gengrid_Item_Class *itc,
2538                                       const void                   *data,
2539                                       Eina_Compare_Cb               comp,
2540                                       Evas_Smart_Cb                 func,
2541                                       const void                   *func_data)
2542 =======
2543    return (Elm_Object_Item *)it;
2544 }
2545
2546 EAPI Elm_Object_Item *
2547 elm_gengrid_item_sorted_insert(Evas_Object                  *obj,
2548                                const Elm_Gengrid_Item_Class *itc,
2549                                const void                   *data,
2550                                Eina_Compare_Cb               comp,
2551                                Evas_Smart_Cb                 func,
2552                                const void                   *func_data)
2553 >>>>>>> remotes/origin/upstream
2554 {
2555    Elm_Gen_Item *it;
2556    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2557    Widget_Data *wd = elm_widget_data_get(obj);
2558    if (!wd) return NULL;
2559
2560    it = _item_new(wd, itc, data, func, func_data);
2561    if (!it) return NULL;
2562
2563    if (!wd->state)
2564      wd->state = eina_inlist_sorted_state_new();
2565
2566    wd->item_compare_cb = comp;
2567    wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
2568                                          _elm_gengrid_item_compare, wd->state);
2569 <<<<<<< HEAD
2570    if (wd->calc_job) ecore_job_del(wd->calc_job);
2571    wd->calc_job = ecore_job_add(_calc_job, wd);
2572
2573    return (Elm_Object_Item *) it;
2574 }
2575
2576 EAPI Elm_Object_Item *
2577 elm_gengrid_item_sorted_insert(Evas_Object                  *obj,
2578                                const Elm_Gengrid_Item_Class *itc,
2579                                const void                   *data,
2580                                Eina_Compare_Cb               comp,
2581                                Evas_Smart_Cb                 func,
2582                                const void                   *func_data)
2583 {
2584    Widget_Data *wd = elm_widget_data_get(obj);
2585    wd->item_compare_data_cb = comp;
2586
2587    return elm_gengrid_item_direct_sorted_insert(obj, itc, data, _elm_gengrid_item_compare_data, func, func_data);
2588 =======
2589    _item_position_update(wd->items, 0);
2590
2591    if (wd->calc_job) ecore_job_del(wd->calc_job);
2592    wd->calc_job = ecore_job_add(_calc_job, wd);
2593
2594    return (Elm_Object_Item *)it;
2595 }
2596
2597 EINA_DEPRECATED Elm_Object_Item *
2598 elm_gengrid_item_direct_sorted_insert(Evas_Object                  *obj,
2599                                       const Elm_Gengrid_Item_Class *itc,
2600                                       const void                   *data,
2601                                       Eina_Compare_Cb               comp,
2602                                       Evas_Smart_Cb                 func,
2603                                       const void                   *func_data)
2604 {
2605    return elm_gengrid_item_sorted_insert(obj, itc, data, comp, func, func_data);
2606 >>>>>>> remotes/origin/upstream
2607 }
2608
2609 EAPI void
2610 elm_gengrid_item_del(Elm_Object_Item *it)
2611 {
2612    elm_object_item_del(it);
2613 }
2614
2615 EAPI void
2616 elm_gengrid_horizontal_set(Evas_Object *obj,
2617 <<<<<<< HEAD
2618                            Eina_Bool    setting)
2619 =======
2620                            Eina_Bool    horizontal)
2621 >>>>>>> remotes/origin/upstream
2622 {
2623    ELM_CHECK_WIDTYPE(obj, widtype);
2624    Widget_Data *wd = elm_widget_data_get(obj);
2625    if (!wd) return;
2626 <<<<<<< HEAD
2627    if (setting == wd->horizontal) return;
2628    wd->horizontal = setting;
2629 =======
2630    horizontal = !!horizontal;
2631    if (horizontal == wd->horizontal) return;
2632    wd->horizontal = horizontal;
2633 >>>>>>> remotes/origin/upstream
2634
2635    /* Update the items to conform to the new layout */
2636    if (wd->calc_job) ecore_job_del(wd->calc_job);
2637    wd->calc_job = ecore_job_add(_calc_job, wd);
2638 }
2639
2640 EAPI Eina_Bool
2641 elm_gengrid_horizontal_get(const Evas_Object *obj)
2642 {
2643    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2644    Widget_Data *wd = elm_widget_data_get(obj);
2645    if (!wd) return EINA_FALSE;
2646    return wd->horizontal;
2647 }
2648
2649 <<<<<<< HEAD
2650 #if 1
2651 static void
2652 _elm_gengrid_clear(Evas_Object *obj, Eina_Bool standby)
2653 {
2654    Eina_Inlist *next, *l;
2655
2656    ELM_CHECK_WIDTYPE(obj, widtype);
2657    Widget_Data *wd = elm_widget_data_get(obj);
2658    if (!wd) return;
2659
2660    if (!standby) wd->generation++;
2661
2662    if (wd->state)
2663      {
2664         eina_inlist_sorted_state_free(wd->state);
2665         wd->state = NULL;
2666      }
2667
2668    if (wd->walking > 0)
2669      {
2670         wd->clear_me = 1;
2671         return;
2672      }
2673    evas_event_freeze(evas_object_evas_get(wd->obj));
2674    for (l = wd->items, next = l ? l->next : NULL;
2675         l;
2676         l = next, next = next ? next->next : NULL)
2677      {
2678         Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(l);
2679
2680         if (it->generation < wd->generation)
2681           {
2682              Elm_Gen_Item *itn = NULL;
2683
2684              if (next) itn = ELM_GEN_ITEM_FROM_INLIST(next);
2685              if (itn) itn->walking++; /* prevent early death of subitem */
2686              it->del_cb(it);
2687              elm_widget_item_free(it);
2688              if (itn) itn->walking--;
2689           }
2690      }
2691    wd->clear_me = 0;
2692    wd->pan_changed = EINA_TRUE;
2693    if (wd->calc_job)
2694      {
2695         ecore_job_del(wd->calc_job);
2696         wd->calc_job = NULL;
2697      }
2698    if (wd->selected) wd->selected = eina_list_free(wd->selected);
2699    if (wd->clear_cb) wd->clear_cb(wd);
2700    wd->pan_x = 0;
2701    wd->pan_y = 0;
2702    wd->minw = 0;
2703    wd->minh = 0;
2704    wd->count = 0;
2705    if (wd->pan_smart)
2706      {
2707         evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2708         evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2709      }
2710    if (wd->sizing_cb) wd->sizing_cb(wd->obj);
2711    elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
2712    evas_event_thaw(evas_object_evas_get(wd->obj));
2713    evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2714 }
2715 #endif
2716
2717 EAPI void
2718 elm_gengrid_clear(Evas_Object *obj)
2719 {
2720 #if 0
2721    elm_genlist_clear(obj);
2722 #else
2723    _elm_gengrid_clear(obj, EINA_FALSE);
2724 #endif
2725 }
2726
2727 EAPI const Evas_Object *
2728 =======
2729 EAPI void
2730 elm_gengrid_clear(Evas_Object *obj)
2731 {
2732    elm_genlist_clear(obj);
2733 }
2734
2735 EINA_DEPRECATED EAPI const Evas_Object *
2736 >>>>>>> remotes/origin/upstream
2737 elm_gengrid_item_object_get(const Elm_Object_Item *it)
2738 {
2739    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2740    return VIEW(it);
2741 }
2742
2743 EAPI void
2744 elm_gengrid_item_update(Elm_Object_Item *it)
2745 {
2746    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2747 <<<<<<< HEAD
2748    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2749    if (!_it->realized) return;
2750    if (_it->want_unrealize) return;
2751    _elm_gengrid_item_unrealize(_it, EINA_FALSE);
2752 =======
2753    Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2754    if (!_it->realized) return;
2755    if (_it->want_unrealize) return;
2756    _elm_genlist_item_unrealize(_it, EINA_FALSE);
2757 >>>>>>> remotes/origin/upstream
2758    _item_realize(_it);
2759    _item_place(_it, _it->x, _it->y);
2760 }
2761
2762 EAPI void *
2763 elm_gengrid_item_data_get(const Elm_Object_Item *it)
2764 {
2765    return elm_object_item_data_get(it);
2766 }
2767
2768 EAPI void
2769 elm_gengrid_item_data_set(Elm_Object_Item  *it,
2770                           const void       *data)
2771 {
2772    elm_object_item_data_set(it, (void *) data);
2773 }
2774
2775 EAPI const Elm_Gengrid_Item_Class *
2776 elm_gengrid_item_item_class_get(const Elm_Object_Item *it)
2777 {
2778 <<<<<<< HEAD
2779    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2780    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2781    if (_it->generation < _it->wd->generation) return NULL;
2782    return _it->itc;
2783 }
2784
2785 EAPI void
2786 elm_gengrid_item_item_class_set(Elm_Object_Item *it,
2787                                 const Elm_Gengrid_Item_Class *itc)
2788 {
2789    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2790    EINA_SAFETY_ON_NULL_RETURN(itc);
2791    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2792 =======
2793    return (Elm_Gengrid_Item_Class *) elm_genlist_item_item_class_get(it);
2794 }
2795
2796 EINA_DEPRECATED EAPI void
2797 elm_gengrid_item_item_class_set(Elm_Object_Item *it,
2798                                 const Elm_Gengrid_Item_Class *itc)
2799 {
2800    elm_gengrid_item_item_class_update(it, itc);
2801 }
2802
2803 EAPI void
2804 elm_gengrid_item_item_class_update(Elm_Object_Item *it,
2805                                    const Elm_Gengrid_Item_Class *itc)
2806 {
2807    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2808    EINA_SAFETY_ON_NULL_RETURN(itc);
2809    Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
2810 >>>>>>> remotes/origin/upstream
2811    if (_it->generation < _it->wd->generation) return;
2812    _it->itc = itc;
2813    elm_gengrid_item_update(it);
2814 }
2815
2816 EAPI void
2817 elm_gengrid_item_pos_get(const Elm_Object_Item *it,
2818                          unsigned int           *x,
2819                          unsigned int           *y)
2820 {
2821    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2822 <<<<<<< HEAD
2823    if (x) *x = ((Elm_Gen_Item *) it)->x;
2824    if (y) *y = ((Elm_Gen_Item *) it)->y;
2825 =======
2826    if (x) *x = ((Elm_Gen_Item *)it)->x;
2827    if (y) *y = ((Elm_Gen_Item *)it)->y;
2828 >>>>>>> remotes/origin/upstream
2829 }
2830
2831 EAPI void
2832 elm_gengrid_multi_select_set(Evas_Object *obj,
2833                              Eina_Bool    multi)
2834 {
2835    ELM_CHECK_WIDTYPE(obj, widtype);
2836    Widget_Data *wd = elm_widget_data_get(obj);
2837    if (!wd) return;
2838 <<<<<<< HEAD
2839    wd->multi = multi;
2840 =======
2841    wd->multi = !!multi;
2842 >>>>>>> remotes/origin/upstream
2843 }
2844
2845 EAPI Eina_Bool
2846 elm_gengrid_multi_select_get(const Evas_Object *obj)
2847 {
2848    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2849    Widget_Data *wd = elm_widget_data_get(obj);
2850    if (!wd) return EINA_FALSE;
2851    return wd->multi;
2852 }
2853
2854 EAPI Elm_Object_Item *
2855 elm_gengrid_selected_item_get(const Evas_Object *obj)
2856 {
2857    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2858    Widget_Data *wd = elm_widget_data_get(obj);
2859    if (!wd) return NULL;
2860    if (wd->selected) return wd->selected->data;
2861    return NULL;
2862 }
2863
2864 EAPI const Eina_List *
2865 elm_gengrid_selected_items_get(const Evas_Object *obj)
2866 {
2867 <<<<<<< HEAD
2868    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2869    Widget_Data *wd = elm_widget_data_get(obj);
2870    if (!wd) return NULL;
2871    return wd->selected;
2872 =======
2873    return elm_genlist_selected_items_get(obj);
2874 >>>>>>> remotes/origin/upstream
2875 }
2876
2877 EAPI void
2878 elm_gengrid_item_selected_set(Elm_Object_Item  *it,
2879                               Eina_Bool         selected)
2880 {
2881 <<<<<<< HEAD
2882 #if 0
2883    elm_genlist_item_selected_set(it, selected);
2884 #else
2885    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2886    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
2887    Widget_Data *wd = _it->wd;
2888    if (!wd) return;
2889    if ((_it->generation < wd->generation) || elm_widget_item_disabled_get(_it))
2890      return;
2891    selected = !!selected;
2892    if (_it->selected == selected) return;
2893
2894    if (selected)
2895      {
2896         if (!wd->multi)
2897           {
2898              while (wd->selected)
2899                {
2900                   if (_it->unhighlight_cb) _it->unhighlight_cb(wd->selected->data);
2901                   _it->unsel_cb(wd->selected->data);
2902                }
2903           }
2904         _it->highlight_cb(_it);
2905         _item_select(_it);
2906         return;
2907      }
2908    if (_it->unhighlight_cb) _it->unhighlight_cb(_it);
2909    _it->unsel_cb(_it);
2910 #endif
2911 =======
2912    elm_genlist_item_selected_set(it, selected);
2913 >>>>>>> remotes/origin/upstream
2914 }
2915
2916 EAPI Eina_Bool
2917 elm_gengrid_item_selected_get(const Elm_Object_Item *it)
2918 {
2919 <<<<<<< HEAD
2920 #if 0
2921    return elm_genlist_item_selected_get(it);
2922 #else
2923    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2924    return ((Elm_Gen_Item *) it)->selected;
2925 #endif
2926 =======
2927    return elm_genlist_item_selected_get(it);
2928 }
2929
2930 EAPI Eina_List *
2931 elm_gengrid_realized_items_get(const Evas_Object *obj)
2932 {
2933    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2934    Widget_Data *wd = elm_widget_data_get(obj);
2935    Eina_List *list = NULL;
2936    Elm_Gen_Item *it;
2937
2938    EINA_INLIST_FOREACH(wd->items, it)
2939      {
2940         if (it->realized) list = eina_list_append(list, (Elm_Object_Item *)it);
2941      }
2942    return list;
2943 }
2944
2945 EAPI void
2946 elm_gengrid_realized_items_update(Evas_Object *obj)
2947 {
2948    ELM_CHECK_WIDTYPE(obj, widtype);
2949
2950    Eina_List *list, *l;
2951    Elm_Object_Item *it;
2952
2953    list = elm_gengrid_realized_items_get(obj);
2954    EINA_LIST_FOREACH(list, l, it)
2955      elm_gengrid_item_update(it);
2956 >>>>>>> remotes/origin/upstream
2957 }
2958
2959 EAPI void
2960 elm_gengrid_item_disabled_set(Elm_Object_Item  *it,
2961                               Eina_Bool         disabled)
2962 {
2963    elm_object_item_disabled_set(it, disabled);
2964 }
2965
2966 EAPI Eina_Bool
2967 elm_gengrid_item_disabled_get(const Elm_Object_Item *it)
2968 {
2969    return elm_object_item_disabled_get(it);
2970 }
2971
2972 static Evas_Object *
2973 _elm_gengrid_item_label_create(void        *data,
2974                                Evas_Object *obj __UNUSED__,
2975                                Evas_Object *tooltip,
2976                                void *it   __UNUSED__)
2977 {
2978    Evas_Object *label = elm_label_add(tooltip);
2979    if (!label)
2980      return NULL;
2981    elm_object_style_set(label, "tooltip");
2982    elm_object_text_set(label, data);
2983    return label;
2984 }
2985
2986 static void
2987 _elm_gengrid_item_label_del_cb(void            *data,
2988                                Evas_Object *obj __UNUSED__,
2989                                void *event_info __UNUSED__)
2990 {
2991    eina_stringshare_del(data);
2992 }
2993
2994 EAPI void
2995 elm_gengrid_item_tooltip_text_set(Elm_Object_Item  *it,
2996                                   const char       *text)
2997 {
2998    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2999    text = eina_stringshare_add(text);
3000    elm_gengrid_item_tooltip_content_cb_set(it, _elm_gengrid_item_label_create,
3001                                            text,
3002                                            _elm_gengrid_item_label_del_cb);
3003 }
3004
3005 EAPI void
3006 elm_gengrid_item_tooltip_content_cb_set(Elm_Object_Item            *it,
3007                                         Elm_Tooltip_Item_Content_Cb func,
3008                                         const void                 *data,
3009                                         Evas_Smart_Cb               del_cb)
3010 {
3011    ELM_OBJ_ITEM_CHECK_OR_GOTO(it, error);
3012 <<<<<<< HEAD
3013    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
3014 =======
3015    Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3016 >>>>>>> remotes/origin/upstream
3017
3018    if ((_it->tooltip.content_cb == func) && (_it->tooltip.data == data))
3019      return;
3020
3021    if (_it->tooltip.del_cb)
3022      _it->tooltip.del_cb((void *)_it->tooltip.data, WIDGET(_it), _it);
3023    _it->tooltip.content_cb = func;
3024    _it->tooltip.data = data;
3025    _it->tooltip.del_cb = del_cb;
3026    if (VIEW(_it))
3027      {
3028         elm_widget_item_tooltip_content_cb_set(_it,
3029                                                _it->tooltip.content_cb,
3030                                                _it->tooltip.data, NULL);
3031         elm_widget_item_tooltip_style_set(_it, _it->tooltip.style);
3032         elm_widget_item_tooltip_window_mode_set(_it, _it->tooltip.free_size);
3033      }
3034
3035    return;
3036
3037 error:
3038    if (del_cb) del_cb((void *)data, NULL, NULL);
3039 }
3040
3041 EAPI void
3042 elm_gengrid_item_tooltip_unset(Elm_Object_Item *it)
3043 {
3044    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
3045 <<<<<<< HEAD
3046    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
3047 =======
3048    Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3049 >>>>>>> remotes/origin/upstream
3050
3051    if ((VIEW(_it)) && (_it->tooltip.content_cb))
3052      elm_widget_item_tooltip_unset(_it);
3053
3054    if (_it->tooltip.del_cb)
3055      _it->tooltip.del_cb((void *) _it->tooltip.data, WIDGET(_it), _it);
3056    _it->tooltip.del_cb = NULL;
3057    _it->tooltip.content_cb = NULL;
3058    _it->tooltip.data = NULL;
3059    _it->tooltip.free_size = EINA_FALSE;
3060    if (_it->tooltip.style)
3061      elm_gengrid_item_tooltip_style_set(it, NULL);
3062 }
3063
3064 EAPI void
3065 elm_gengrid_item_tooltip_style_set(Elm_Object_Item  *it,
3066                                    const char       *style)
3067 {
3068    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
3069 <<<<<<< HEAD
3070    eina_stringshare_replace(&((Elm_Gen_Item *) it)->tooltip.style, style);
3071 =======
3072    eina_stringshare_replace(&((Elm_Gen_Item *)it)->tooltip.style, style);
3073 >>>>>>> remotes/origin/upstream
3074    if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
3075 }
3076
3077 EAPI const char *
3078 elm_gengrid_item_tooltip_style_get(const Elm_Object_Item *it)
3079 {
3080    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
3081 <<<<<<< HEAD
3082    return ((Elm_Gen_Item *) it)->tooltip.style;
3083 =======
3084    return ((Elm_Gen_Item *)it)->tooltip.style;
3085 >>>>>>> remotes/origin/upstream
3086 }
3087
3088 EAPI Eina_Bool
3089 elm_gengrid_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
3090 {
3091    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
3092 <<<<<<< HEAD
3093    ((Elm_Gen_Item *) it)->tooltip.free_size = disable;
3094 =======
3095    ((Elm_Gen_Item *)it)->tooltip.free_size = disable;
3096 >>>>>>> remotes/origin/upstream
3097    if (VIEW(it)) return elm_widget_item_tooltip_window_mode_set(it, disable);
3098    return EINA_TRUE;
3099 }
3100
3101 EAPI Eina_Bool
3102 elm_gengrid_item_tooltip_window_mode_get(const Elm_Object_Item *it)
3103 {
3104    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
3105 <<<<<<< HEAD
3106    return ((Elm_Gen_Item *) it)->tooltip.free_size;
3107 =======
3108    return ((Elm_Gen_Item *)it)->tooltip.free_size;
3109 >>>>>>> remotes/origin/upstream
3110 }
3111
3112 EAPI void
3113 elm_gengrid_item_cursor_set(Elm_Object_Item  *it,
3114                             const char       *cursor)
3115 {
3116    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
3117 <<<<<<< HEAD
3118    eina_stringshare_replace(&((Elm_Gen_Item *) it)->mouse_cursor, cursor);
3119 =======
3120    eina_stringshare_replace(&((Elm_Gen_Item *)it)->mouse_cursor, cursor);
3121 >>>>>>> remotes/origin/upstream
3122    if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
3123 }
3124
3125 EAPI const char *
3126 elm_gengrid_item_cursor_get(const Elm_Object_Item *it)
3127 {
3128 <<<<<<< HEAD
3129    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
3130 =======
3131 >>>>>>> remotes/origin/upstream
3132    return elm_widget_item_cursor_get(it);
3133 }
3134
3135 EAPI void
3136 elm_gengrid_item_cursor_unset(Elm_Object_Item *it)
3137 {
3138    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
3139 <<<<<<< HEAD
3140    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
3141 =======
3142    Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3143 >>>>>>> remotes/origin/upstream
3144    if (!_it->mouse_cursor)
3145      return;
3146
3147    if (VIEW(_it))
3148      elm_widget_item_cursor_unset(_it);
3149
3150    eina_stringshare_del(_it->mouse_cursor);
3151    _it->mouse_cursor = NULL;
3152 }
3153
3154 EAPI void
3155 elm_gengrid_item_cursor_style_set(Elm_Object_Item  *it,
3156                                   const char       *style)
3157 {
3158 <<<<<<< HEAD
3159    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
3160 =======
3161 >>>>>>> remotes/origin/upstream
3162    elm_widget_item_cursor_style_set(it, style);
3163 }
3164
3165 EAPI const char *
3166 elm_gengrid_item_cursor_style_get(const Elm_Object_Item *it)
3167 {
3168 <<<<<<< HEAD
3169    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
3170 =======
3171 >>>>>>> remotes/origin/upstream
3172    return elm_widget_item_cursor_style_get(it);
3173 }
3174
3175 EAPI void
3176 elm_gengrid_item_cursor_engine_only_set(Elm_Object_Item  *it,
3177                                         Eina_Bool         engine_only)
3178 {
3179 <<<<<<< HEAD
3180    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
3181 =======
3182 >>>>>>> remotes/origin/upstream
3183    elm_widget_item_cursor_engine_only_set(it, engine_only);
3184 }
3185
3186 EAPI Eina_Bool
3187 elm_gengrid_item_cursor_engine_only_get(const Elm_Object_Item *it)
3188 {
3189 <<<<<<< HEAD
3190    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
3191 =======
3192 >>>>>>> remotes/origin/upstream
3193    return elm_widget_item_cursor_engine_only_get(it);
3194 }
3195
3196 EAPI void
3197 elm_gengrid_reorder_mode_set(Evas_Object *obj,
3198                              Eina_Bool    reorder_mode)
3199 {
3200    ELM_CHECK_WIDTYPE(obj, widtype);
3201    Widget_Data *wd = elm_widget_data_get(obj);
3202    if (!wd) return;
3203 <<<<<<< HEAD
3204    wd->reorder_mode = reorder_mode;
3205 =======
3206    wd->reorder_mode = !!reorder_mode;
3207 >>>>>>> remotes/origin/upstream
3208 }
3209
3210 EAPI Eina_Bool
3211 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
3212 {
3213    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3214    Widget_Data *wd = elm_widget_data_get(obj);
3215    if (!wd) return EINA_FALSE;
3216    return wd->reorder_mode;
3217 }
3218
3219 <<<<<<< HEAD
3220 EAPI void
3221 elm_gengrid_always_select_mode_set(Evas_Object *obj,
3222                                    Eina_Bool    always_select)
3223 {
3224 #if 0
3225    elm_genlist_always_select_mode_set(obj, always_select);
3226 #else
3227    ELM_CHECK_WIDTYPE(obj, widtype);
3228    Widget_Data *wd = elm_widget_data_get(obj);
3229    if (!wd) return;
3230    wd->always_select = always_select;
3231 #endif
3232 }
3233
3234 EAPI Eina_Bool
3235 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
3236 {
3237 #if 0
3238    return elm_genlist_always_select_mode_get(obj);
3239 #else
3240    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3241    Widget_Data *wd = elm_widget_data_get(obj);
3242    if (!wd) return EINA_FALSE;
3243    return wd->always_select;
3244 #endif
3245 }
3246
3247 EAPI void
3248 elm_gengrid_no_select_mode_set(Evas_Object *obj,
3249                                Eina_Bool    no_select)
3250 {
3251 #if 0
3252    elm_genlist_no_select_mode_set(obj, no_select);
3253 #else
3254    ELM_CHECK_WIDTYPE(obj, widtype);
3255    Widget_Data *wd = elm_widget_data_get(obj);
3256    if (!wd) return;
3257    wd->no_select = no_select;
3258 #endif
3259 }
3260
3261 EAPI Eina_Bool
3262 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
3263 {
3264 #if 0
3265    return elm_genlist_no_select_mode_get(obj);
3266 #else
3267    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3268    Widget_Data *wd = elm_widget_data_get(obj);
3269    if (!wd) return EINA_FALSE;
3270    return wd->no_select;
3271 #endif
3272 =======
3273 EINA_DEPRECATED EAPI void
3274 elm_gengrid_always_select_mode_set(Evas_Object *obj,
3275                                    Eina_Bool    always_select)
3276 {
3277    if (always_select)
3278      elm_genlist_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_ALWAYS);
3279    else
3280      {
3281         Elm_Object_Select_Mode oldmode = elm_genlist_select_mode_get(obj);
3282         if (oldmode == ELM_OBJECT_SELECT_MODE_ALWAYS)
3283           elm_genlist_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_DEFAULT);
3284      }
3285 }
3286
3287 EINA_DEPRECATED EAPI Eina_Bool
3288 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
3289 {
3290    Elm_Object_Select_Mode oldmode = elm_genlist_select_mode_get(obj);
3291    if (oldmode == ELM_OBJECT_SELECT_MODE_ALWAYS)
3292      return EINA_TRUE;
3293    else
3294      return EINA_FALSE;
3295 }
3296
3297 EINA_DEPRECATED EAPI void
3298 elm_gengrid_no_select_mode_set(Evas_Object *obj,
3299                                Eina_Bool    no_select)
3300 {
3301    if (no_select)
3302      elm_genlist_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_NONE);
3303    else
3304      {
3305         Elm_Object_Select_Mode oldmode = elm_genlist_select_mode_get(obj);
3306         if (oldmode == ELM_OBJECT_SELECT_MODE_NONE)
3307           elm_genlist_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_DEFAULT);
3308      }
3309 }
3310
3311 EINA_DEPRECATED EAPI Eina_Bool
3312 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
3313 {
3314    Elm_Object_Select_Mode oldmode = elm_genlist_select_mode_get(obj);
3315    if (oldmode == ELM_OBJECT_SELECT_MODE_NONE)
3316      return EINA_TRUE;
3317    else
3318      return EINA_FALSE;
3319 >>>>>>> remotes/origin/upstream
3320 }
3321
3322 EAPI void
3323 elm_gengrid_bounce_set(Evas_Object *obj,
3324                        Eina_Bool    h_bounce,
3325                        Eina_Bool    v_bounce)
3326 {
3327 <<<<<<< HEAD
3328 #if 0
3329    elm_genlist_bounce_set(obj, h_bounce, v_bounce);
3330 #else
3331    ELM_CHECK_WIDTYPE(obj, widtype);
3332    Widget_Data *wd = elm_widget_data_get(obj);
3333    if (!wd) return;
3334    elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
3335    wd->h_bounce = h_bounce;
3336    wd->v_bounce = v_bounce;
3337 #endif
3338 =======
3339    elm_genlist_bounce_set(obj, h_bounce, v_bounce);
3340 >>>>>>> remotes/origin/upstream
3341 }
3342
3343 EAPI void
3344 elm_gengrid_bounce_get(const Evas_Object *obj,
3345                        Eina_Bool         *h_bounce,
3346                        Eina_Bool         *v_bounce)
3347 {
3348 <<<<<<< HEAD
3349 #if 0
3350    elm_genlist_bounce_get(obj, h_bounce, v_bounce);
3351 #else
3352    ELM_CHECK_WIDTYPE(obj, widtype);
3353    Widget_Data *wd = elm_widget_data_get(obj);
3354    if (!wd) return;
3355    if (h_bounce) *h_bounce = wd->h_bounce;
3356    if (v_bounce) *v_bounce = wd->v_bounce;
3357 #endif
3358 =======
3359    elm_genlist_bounce_get(obj, h_bounce, v_bounce);
3360 >>>>>>> remotes/origin/upstream
3361 }
3362
3363 EAPI void
3364 elm_gengrid_page_relative_set(Evas_Object *obj,
3365                               double       h_pagerel,
3366                               double       v_pagerel)
3367 {
3368 <<<<<<< HEAD
3369 #if 0
3370    _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
3371 #else
3372    Evas_Coord pagesize_h;
3373    Evas_Coord pagesize_v;
3374
3375    ELM_CHECK_WIDTYPE(obj, widtype);
3376    Widget_Data *wd = elm_widget_data_get(obj);
3377    if (!wd) return;
3378
3379    elm_smart_scroller_paging_get(wd->scr, NULL, NULL, &pagesize_h, &pagesize_v);
3380    elm_smart_scroller_paging_set(wd->scr, h_pagerel, v_pagerel, pagesize_h,
3381                                  pagesize_v);
3382 #endif
3383 =======
3384    _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
3385 >>>>>>> remotes/origin/upstream
3386 }
3387
3388 EAPI void
3389 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
3390 {
3391 <<<<<<< HEAD
3392 #if 0
3393    _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
3394 #else
3395    ELM_CHECK_WIDTYPE(obj, widtype);
3396    Widget_Data *wd = elm_widget_data_get(obj);
3397    if (!wd) return;
3398
3399    elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
3400 #endif
3401 =======
3402    _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
3403 >>>>>>> remotes/origin/upstream
3404 }
3405
3406 EAPI void
3407 elm_gengrid_page_size_set(Evas_Object *obj,
3408                           Evas_Coord   h_pagesize,
3409                           Evas_Coord   v_pagesize)
3410 {
3411 <<<<<<< HEAD
3412 #if 0
3413    _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
3414 #else
3415    double pagerel_h;
3416    double pagerel_v;
3417
3418    ELM_CHECK_WIDTYPE(obj, widtype);
3419    Widget_Data *wd = elm_widget_data_get(obj);
3420    if (!wd) return;
3421    elm_smart_scroller_paging_get(wd->scr, &pagerel_h, &pagerel_v, NULL, NULL);
3422    elm_smart_scroller_paging_set(wd->scr, pagerel_h, pagerel_v, h_pagesize,
3423                                  v_pagesize);
3424 #endif
3425 =======
3426    _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
3427 >>>>>>> remotes/origin/upstream
3428 }
3429
3430 EAPI void
3431 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
3432 {
3433 <<<<<<< HEAD
3434 #if 0
3435    _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
3436 #else
3437    ELM_CHECK_WIDTYPE(obj, widtype);
3438    Widget_Data *wd = elm_widget_data_get(obj);
3439    if (!wd) return;
3440    if (wd->scr)
3441      elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber);
3442 #endif
3443 =======
3444    _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
3445 >>>>>>> remotes/origin/upstream
3446 }
3447
3448 EAPI void
3449 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
3450 {
3451 <<<<<<< HEAD
3452 #if 0
3453    _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
3454 #else
3455    ELM_CHECK_WIDTYPE(obj, widtype);
3456    Widget_Data *wd = elm_widget_data_get(obj);
3457    if (!wd) return;
3458    if (wd->scr)
3459      elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber);
3460 #endif
3461 =======
3462    _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
3463 >>>>>>> remotes/origin/upstream
3464 }
3465
3466 EAPI void
3467 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
3468 {
3469 <<<<<<< HEAD
3470 #if 0
3471    _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
3472 #else
3473    ELM_CHECK_WIDTYPE(obj, widtype);
3474    Widget_Data *wd = elm_widget_data_get(obj);
3475    if (!wd) return;
3476    if (wd->scr)
3477      elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber);
3478 #endif
3479 =======
3480    _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
3481 >>>>>>> remotes/origin/upstream
3482 }
3483
3484 EAPI void
3485 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
3486 {
3487 <<<<<<< HEAD
3488 #if 0
3489    _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
3490 #else
3491    ELM_CHECK_WIDTYPE(obj, widtype);
3492    Widget_Data *wd = elm_widget_data_get(obj);
3493    if (!wd) return;
3494    if (wd->scr)
3495      elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber);
3496 #endif
3497 =======
3498    _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
3499 }
3500
3501 EAPI void
3502 elm_gengrid_scroller_policy_set(Evas_Object        *obj,
3503                                 Elm_Scroller_Policy policy_h,
3504                                 Elm_Scroller_Policy policy_v)
3505 {
3506    ELM_CHECK_WIDTYPE(obj, widtype);
3507    Widget_Data *wd = elm_widget_data_get(obj);
3508    if ((!wd) || (!wd->scr)) return;
3509    if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
3510        (policy_v >= ELM_SCROLLER_POLICY_LAST))
3511      return;
3512    elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
3513 }
3514
3515 EAPI void
3516 elm_gengrid_scroller_policy_get(const Evas_Object   *obj,
3517                                 Elm_Scroller_Policy *policy_h,
3518                                 Elm_Scroller_Policy *policy_v)
3519 {
3520    ELM_CHECK_WIDTYPE(obj, widtype);
3521    Widget_Data *wd = elm_widget_data_get(obj);
3522    Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
3523    if ((!wd) || (!wd->scr)) return;
3524    elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
3525    if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
3526    if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
3527 >>>>>>> remotes/origin/upstream
3528 }
3529
3530 EAPI Elm_Object_Item *
3531 elm_gengrid_first_item_get(const Evas_Object *obj)
3532 {
3533 <<<<<<< HEAD
3534 #if 0
3535    return elm_genlist_first_item_get(obj);
3536 #else
3537    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3538    Widget_Data *wd = elm_widget_data_get(obj);
3539    if (!wd) return NULL;
3540    if (!wd->items) return NULL;
3541    Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
3542    while ((it) && (it->generation < wd->generation))
3543      it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3544    return (Elm_Object_Item *) it;
3545 #endif
3546 =======
3547    return elm_genlist_first_item_get(obj);
3548 >>>>>>> remotes/origin/upstream
3549 }
3550
3551 EAPI Elm_Object_Item *
3552 elm_gengrid_last_item_get(const Evas_Object *obj)
3553 {
3554 <<<<<<< HEAD
3555 #if 0
3556    return elm_genlist_last_item_get(obj);
3557 #else
3558    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3559    Widget_Data *wd = elm_widget_data_get(obj);
3560    if (!wd) return NULL;
3561    if (!wd->items) return NULL;
3562    Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
3563    while ((it) && (it->generation < wd->generation))
3564      it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3565    return (Elm_Object_Item *) it;
3566 #endif
3567 =======
3568    return elm_genlist_last_item_get(obj);
3569 >>>>>>> remotes/origin/upstream
3570 }
3571
3572 EAPI Elm_Object_Item *
3573 elm_gengrid_item_next_get(const Elm_Object_Item *it)
3574 {
3575 <<<<<<< HEAD
3576 #if 0
3577    return elm_genlist_item_next_get(it);
3578 #else
3579    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
3580    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
3581    while (_it)
3582      {
3583         _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->next);
3584         if ((_it) && (_it->generation == _it->wd->generation)) break;
3585      }
3586    return (Elm_Object_Item *) _it;
3587 #endif
3588 =======
3589    return elm_genlist_item_next_get(it);
3590 >>>>>>> remotes/origin/upstream
3591 }
3592
3593 EAPI Elm_Object_Item *
3594 elm_gengrid_item_prev_get(const Elm_Object_Item *it)
3595 {
3596 <<<<<<< HEAD
3597 #if 0
3598    return elm_genlist_item_prev_get(it);
3599 #else
3600    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
3601    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
3602    while (_it)
3603      {
3604         _it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(_it)->prev);
3605         if ((_it) && (_it->generation == _it->wd->generation)) break;
3606      }
3607    return (Elm_Object_Item *) _it;
3608 #endif
3609 =======
3610    return elm_genlist_item_prev_get(it);
3611 >>>>>>> remotes/origin/upstream
3612 }
3613
3614 EAPI Evas_Object *
3615 elm_gengrid_item_gengrid_get(const Elm_Object_Item *it)
3616 {
3617    return elm_object_item_widget_get(it);
3618 }
3619
3620 EAPI void
3621 <<<<<<< HEAD
3622 elm_gengrid_item_show(Elm_Object_Item *it)
3623 {
3624    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
3625    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
3626 =======
3627 elm_gengrid_item_show(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
3628 {
3629    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
3630    Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3631 >>>>>>> remotes/origin/upstream
3632    Widget_Data *wd = _it->wd;
3633    Evas_Coord minx = 0, miny = 0;
3634
3635    if ((_it->generation < _it->wd->generation)) return;
3636    _pan_min_get(wd->pan_smart, &minx, &miny);
3637
3638 <<<<<<< HEAD
3639 =======
3640    if (type==ELM_GENGRID_ITEM_SCROLLTO_IN)
3641      {
3642         //TODO : type based handling like genlist
3643      }
3644
3645 >>>>>>> remotes/origin/upstream
3646    if (wd->horizontal)
3647      elm_smart_scroller_region_bring_in(_it->wd->scr,
3648                                         ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
3649                                         _it->y * wd->item_height + miny,
3650                                         _it->wd->item_width,
3651                                         _it->wd->item_height);
3652    else
3653      elm_smart_scroller_region_bring_in(_it->wd->scr,
3654                                         _it->x * wd->item_width + minx,
3655                                         ((_it->y - _it->item->prev_group) * wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
3656                                         _it->wd->item_width,
3657                                         _it->wd->item_height);
3658 }
3659
3660 EAPI void
3661 <<<<<<< HEAD
3662 elm_gengrid_item_bring_in(Elm_Object_Item *it)
3663 {
3664    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
3665    Elm_Gen_Item *_it = (Elm_Gen_Item *) it;
3666 =======
3667 elm_gengrid_item_bring_in(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type)
3668 {
3669    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
3670    Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3671 >>>>>>> remotes/origin/upstream
3672
3673    if (_it->generation < _it->wd->generation) return;
3674
3675    Evas_Coord minx = 0, miny = 0;
3676    Widget_Data *wd = _it->wd;
3677    _pan_min_get(wd->pan_smart, &minx, &miny);
3678
3679 <<<<<<< HEAD
3680 =======
3681    if (type==ELM_GENGRID_ITEM_SCROLLTO_IN)
3682      {
3683         //TODO : type based handling like genlist
3684      }
3685
3686 >>>>>>> remotes/origin/upstream
3687    if (wd->horizontal)
3688      elm_smart_scroller_region_bring_in(_it->wd->scr,
3689                                         ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx,
3690                                         _it->y * wd->item_height + miny,
3691                                         _it->wd->item_width,
3692                                         _it->wd->item_height);
3693    else
3694      elm_smart_scroller_region_bring_in(_it->wd->scr,
3695                                         _it->x * wd->item_width + minx,
3696                                         ((_it->y - _it->item->prev_group)* wd->item_height) + (_it->item->prev_group * _it->wd->group_item_height) + miny,
3697                                         _it->wd->item_width,
3698                                         _it->wd->item_height);
3699 }
3700
3701 EAPI void
3702 elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill)
3703 {
3704    ELM_CHECK_WIDTYPE(obj, widtype);
3705    Widget_Data *wd = elm_widget_data_get(obj);
3706    if (!wd) return;
3707    fill = !!fill;
3708    if (wd->filled != fill)
3709      wd->filled = fill;
3710 }
3711
3712 EAPI Eina_Bool
3713 elm_gengrid_filled_get(const Evas_Object *obj)
3714 {
3715    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3716    Widget_Data *wd = elm_widget_data_get(obj);
3717    if (!wd) return EINA_FALSE;
3718    return wd->filled;
3719 }
3720
3721 <<<<<<< HEAD
3722 #if 1
3723 void
3724 _elm_gengrid_item_unrealize(Elm_Gen_Item *it,
3725                             Eina_Bool     calc)
3726 {
3727    Evas_Object *content;
3728
3729    if (!it->realized) return;
3730    if (it->wd->reorder_it == it) return;
3731    evas_event_freeze(evas_object_evas_get(WIDGET(it)));
3732    if (!calc)
3733      evas_object_smart_callback_call(WIDGET(it), SIG_UNREALIZED, it);
3734    if (it->long_timer)
3735      {
3736         ecore_timer_del(it->long_timer);
3737         it->long_timer = NULL;
3738      }
3739
3740    elm_widget_stringlist_free(it->texts);
3741    it->texts = NULL;
3742    elm_widget_stringlist_free(it->contents);
3743    it->contents = NULL;
3744    elm_widget_stringlist_free(it->states);
3745    it->states = NULL;
3746
3747    EINA_LIST_FREE(it->content_objs, content)
3748      evas_object_del(content);
3749
3750    it->unrealize_cb(it);
3751
3752    it->realized = EINA_FALSE;
3753    it->want_unrealize = EINA_FALSE;
3754    evas_event_thaw(evas_object_evas_get(WIDGET(it)));
3755    evas_event_thaw_eval(evas_object_evas_get(WIDGET(it)));
3756 }
3757
3758 void
3759 _elm_gengrid_item_del_notserious(Elm_Gen_Item *it)
3760 {
3761    elm_widget_item_pre_notify_del(it);
3762    it->generation = it->wd->generation - 1; /* This means that the item is deleted */
3763    if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
3764
3765    if (it->itc->func.del)
3766      it->itc->func.del((void *)it->base.data, WIDGET(it));
3767 }
3768
3769 void
3770 _elm_gengrid_item_del_serious(Elm_Gen_Item *it)
3771 {
3772    _elm_gengrid_item_del_notserious(it);
3773    it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3774    if (it->tooltip.del_cb)
3775      it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
3776    it->wd->walking -= it->walking;
3777    if (it->long_timer) ecore_timer_del(it->long_timer);
3778    if (it->group)
3779      it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3780
3781    if (it->wd->state)
3782      {
3783         eina_inlist_sorted_state_free(it->wd->state);
3784         it->wd->state = NULL;
3785      }
3786    if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
3787    it->wd->calc_job = ecore_job_add(it->wd->calc_cb, it->wd);
3788    free(it->item);
3789
3790    it->item = NULL;
3791    if (it->wd->last_selected_item == (Elm_Object_Item *) it)
3792      it->wd->last_selected_item = NULL;
3793 }
3794 #endif
3795 =======
3796 EAPI unsigned int
3797 elm_gengrid_items_count(const Evas_Object *obj)
3798 {
3799    ELM_CHECK_WIDTYPE(obj, widtype) 0;
3800    Widget_Data *wd = elm_widget_data_get(obj);
3801    if (!wd) return 0;
3802    return wd->item_count;
3803 }
3804
3805 EAPI Elm_Gengrid_Item_Class *
3806 elm_gengrid_item_class_new(void)
3807 {
3808    Elm_Gengrid_Item_Class *itc;
3809
3810    itc = calloc(1, sizeof(Elm_Gengrid_Item_Class));
3811    if (!itc)
3812      return NULL;
3813    itc->version = CLASS_ALLOCATED;
3814    itc->refcount = 1;
3815    itc->delete_me = EINA_FALSE;
3816
3817    return itc;
3818 }
3819
3820 EAPI void
3821 elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
3822 {
3823    if (itc && (itc->version == CLASS_ALLOCATED))
3824      {
3825         if (!itc->delete_me) itc->delete_me = EINA_TRUE;
3826         if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
3827         else
3828           {
3829              itc->version = 0;
3830              free(itc);
3831           }
3832      }
3833 }
3834
3835 EAPI void
3836 elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
3837 {
3838    if (itc && (itc->version == CLASS_ALLOCATED))
3839      {
3840         itc->refcount++;
3841         if (itc->refcount == 0) itc->refcount--;
3842      }
3843 }
3844
3845 EAPI void
3846 elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
3847 {
3848    if (itc && (itc->version == CLASS_ALLOCATED))
3849      {
3850         if (itc->refcount > 0) itc->refcount--;
3851         if (itc->delete_me && (!itc->refcount))
3852           elm_gengrid_item_class_free(itc);
3853      }
3854 }
3855
3856 EAPI void
3857 elm_gengrid_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode mode)
3858 {
3859    elm_genlist_select_mode_set(obj, mode);
3860 }
3861
3862 EAPI Elm_Object_Select_Mode
3863 elm_gengrid_select_mode_get(const Evas_Object *obj)
3864 {
3865    return elm_genlist_select_mode_get(obj);
3866 }
3867
3868 EAPI void
3869 elm_gengrid_highlight_mode_set(Evas_Object *obj,
3870                              Eina_Bool    highlight)
3871 {
3872    elm_genlist_highlight_mode_set(obj, highlight);
3873 }
3874
3875 EAPI Eina_Bool
3876 elm_gengrid_highlight_mode_get(const Evas_Object *obj)
3877 {
3878    return elm_genlist_highlight_mode_get(obj);
3879 }
3880
3881 EAPI int
3882 elm_gengrid_item_index_get(const Elm_Object_Item *it)
3883 {
3884    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, -1);
3885    Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
3886
3887    return _it->position;
3888 }
3889 >>>>>>> remotes/origin/upstream