Merge branch 'intefl/svn_merge' of ssh://165.213.149.219:29418/slp/pkgs/e/elementary...
[framework/uifw/elementary.git] / src / lib / elm_gen_common.h
1 #ifndef ELM_GEN_H_
2 #define ELM_GEN_H_
3
4 #include <Elementary.h>
5 #include <Elementary_Cursor.h>
6 #include "elm_priv.h"
7
8 #define ELM_GEN_ITEM_FROM_INLIST(it) \
9   ((it) ? EINA_INLIST_CONTAINER_GET(it, Elm_Gen_Item) : NULL)
10
11 #define SWIPE_MOVES 12
12
13 typedef struct Elm_Gen_Item_Type    Elm_Gen_Item_Type;
14 typedef struct Elm_Gen_Item_Tooltip Elm_Gen_Item_Tooltip;
15 typedef struct _Widget_Data         Widget_Data;
16
17 struct Elm_Gen_Item_Tooltip
18 {
19    const void                 *data;
20    Elm_Tooltip_Item_Content_Cb content_cb;
21    Evas_Smart_Cb               del_cb;
22    const char                 *style;
23    Eina_Bool                   free_size : 1;
24 };
25
26 struct Elm_Gen_Item
27 {
28    ELM_WIDGET_ITEM;
29    EINA_INLIST;
30    Widget_Data              *wd;
31    Elm_Gen_Item_Type        *item;
32    const Elm_Gen_Item_Class *itc;
33    Evas_Coord                x, y, dx, dy;
34    Evas_Object              *spacer, *edit_obj;
35    Elm_Gen_Item             *parent;
36    Eina_List                *texts, *contents, *states, *content_objs;
37    Ecore_Timer              *long_timer;
38    int                       relcount;
39    int                       walking;
40    int                       generation; /**< a generation of an item. when the item is created, this value is set to the value of genlist generation. this value will be decreased when the item is going to be deleted */
41    const char               *mouse_cursor;
42
43    struct
44      {
45         Evas_Smart_Cb func;
46         const void   *data;
47      } func;
48
49    Elm_Gen_Item_Tooltip      tooltip;
50    Ecore_Cb                  del_cb, sel_cb, highlight_cb;
51    Ecore_Cb                  unsel_cb, unhighlight_cb, unrealize_cb;
52
53    int                       position;
54    Elm_Object_Select_Mode    select_mode;
55
56    Eina_Bool                 position_update : 1;
57    Eina_Bool                 want_unrealize : 1;
58    Eina_Bool                 realized : 1;
59    Eina_Bool                 selected : 1;
60    Eina_Bool                 highlighted : 1;
61    Eina_Bool                 dragging : 1; /**< this is set true when an item is being dragged. this is set false on multidown/mouseup/mousedown. when this is true, the item should not be unrealized. or evas mouse down/up event will be corrupted. */
62    Eina_Bool                 down : 1;
63    Eina_Bool                 group : 1;
64    Eina_Bool                 reorder : 1;
65    Eina_Bool                 mode_set : 1; /**< item uses style mode for highlight/select */
66    Eina_Bool                 flipped : 1; /**< a flag that shows the flip status of the item. */
67    Eina_Bool                 defer_unrealize : 1;
68    Eina_Bool                 can_focus : 1;
69 };
70
71 typedef struct _Pan Pan;
72 struct _Pan
73 {
74    Evas_Object_Smart_Clipped_Data __clipped_data;
75    Widget_Data                   *wd;
76    Ecore_Job                     *resize_job;
77 };
78
79 struct _Widget_Data
80 {
81    Eina_Inlist_Sorted_State      *state;
82    Evas_Object                   *obj; /**< the genlist object */
83    Evas_Object                   *scr; /**< a smart scroller object which is used internally in genlist */
84    Evas_Object                   *pan_smart; /**< "elm_genlist_pan" evas smart object. this is an extern pan of smart scroller(scr). */
85    Eina_List                     *selected; /**< a list of selected items */
86    Eina_List                     *group_items; /**< a list of groups index items */
87    Eina_Inlist                   *items; /**< an inlist of all items */
88    Elm_Gen_Item                  *reorder_it; /**< item currently being repositioned */
89    Elm_Object_Item               *last_selected_item;
90    Pan                           *pan; /**< pan_smart object's smart data */
91    Ecore_Job                     *calc_job;
92    int                            walking;
93    int                            item_width, item_height;
94    int                            group_item_width, group_item_height;
95    int                            minw, minh;
96    unsigned int                   item_count;
97    Evas_Coord                     pan_x, pan_y;
98    Elm_Object_Select_Mode         select_mode;
99    Eina_Bool                      reorder_mode : 1; /**< a flag for reorder mode enable/disable */
100    Eina_Bool                      on_hold : 1;
101    Eina_Bool                      multi : 1; /**< a flag for item multi selection */
102    Eina_Bool                      wasselected : 1;
103    Eina_Bool                      no_highlight : 1;
104    Eina_Bool                      clear_me : 1; /**< a flag whether genlist is marked as to be cleared or not. if this flag is true, genlist clear was already deferred.  */
105    Eina_Bool                      h_bounce : 1;
106    Eina_Bool                      v_bounce : 1;
107    Ecore_Cb                       del_cb, calc_cb, sizing_cb;
108    Ecore_Cb                       clear_cb;
109    ////////////////////////////////////
110    Eina_Inlist                   *blocks; /**< an inlist of all blocks. a block consists of a certain number of items. maximum number of items in a block is 'max_items_per_block'. */
111    Evas_Coord                     reorder_old_pan_y, w, h, realminw, prev_viewport_w;
112    Ecore_Job                     *update_job;
113    Ecore_Idle_Enterer            *queue_idle_enterer;
114    Ecore_Idler                   *must_recalc_idler;
115    Eina_List                     *queue;
116    Elm_Gen_Item                  *show_item, *anchor_item, *mode_item, *reorder_rel, *expanded_item;
117    Eina_Inlist                   *item_cache; /**< an inlist of edje object it cache. */
118    Evas_Coord                     anchor_y;
119    Evas_Coord                     reorder_start_y; /**< reorder it's initial y coordinate in the pan. */
120    Elm_List_Mode                  mode;
121    Ecore_Timer                   *multi_timer, *scr_hold_timer;
122    Ecore_Animator                *reorder_move_animator;
123    const char                    *mode_type;
124    double                         start_time;
125    Evas_Coord                     prev_x, prev_y, prev_mx, prev_my;
126    Evas_Coord                     cur_x, cur_y, cur_mx, cur_my;
127    Eina_Bool                      mouse_down : 1;
128    Eina_Bool                      multi_down : 1;
129    Eina_Bool                      multi_timeout : 1;
130    Eina_Bool                      multitouched : 1;
131    Eina_Bool                      longpressed : 1;
132    Eina_Bool                      bring_in : 1; /**< a flag to describe the scroll animation. (show, bring in) */
133    Eina_Bool                      height_for_width : 1;
134    Eina_Bool                      homogeneous : 1;
135    Eina_Bool                      swipe : 1;
136    Eina_Bool                      decorate_mode : 1;
137    Eina_Bool                      reorder_pan_move : 1;
138    Eina_Bool                      auto_scroll_enabled : 1;
139    Eina_Bool                      pan_changed : 1;
140    Eina_Bool                      requeued : 1; /**< this is set to EINA_TRUE when the item is re-queued. this happens when the item is un-queued but the rel item is still in the queue. this item will be processed later. */
141    Eina_Bool                      check_scroll : 1; /**< this flag means genlist is supposed to be scrolled. if this flag is set to EINA_TRUE, genlist checks whether it's ok to scroll genlist now or not. */
142    Eina_Bool                      tree_effect_enabled : 1; /**< tree effect */
143    Eina_Bool                      reorder_deleted : 1;
144    Eina_Bool                      drag_started : 1;
145    struct
146      {
147         Evas_Coord x, y;
148      } history[SWIPE_MOVES];
149    int                            multi_device;
150    int                            item_cache_count;
151    int                            item_cache_max; /**< maximum number of cached items */
152    int                            movements;
153    int                            max_items_per_block; /**< maximum number of items per block */
154    double                         longpress_timeout; /**< longpress timeout. this value comes from _elm_config by default. this can be changed by elm_genlist_longpress_timeout_set() */
155    int                            generation; /**< a generation of genlist. when genlist is cleared, this value will be increased and a new generation will start */
156    Eina_Compare_Cb                item_compare_cb;
157    Eina_Compare_Cb                item_compare_data_cb;
158    Elm_Genlist_Item_Scrollto_Type scrollto_type; /**< a scrollto type which remembers where to scroll ex) in, top, middle */
159    Evas_Object                   *alpha_bg; /**< not to receive event when tree effect is not finished */
160    Eina_List                     *move_items; /**< items move for tree effect */
161    Elm_Gen_Item                  *expanded_next_item;
162    Ecore_Animator                *item_moving_effect_timer; /**< tree effect */
163    Elm_Genlist_Item_Move_Effect_Mode move_effect_mode;
164    Ecore_Job                     *changed_job;
165
166    /* The stuff below directly come from gengrid without any thinking */
167    unsigned int                   nmax;
168    Evas_Coord                     reorder_item_x, reorder_item_y;
169    Evas_Coord                     old_pan_x, old_pan_y;
170    long                           items_lost;
171    double                         align_x, align_y;
172
173    Eina_Bool                      horizontal : 1;
174    Eina_Bool                      move_effect_enabled : 1;
175    Eina_Bool                      reorder_item_changed : 1;
176    Eina_Bool                      filled : 1;
177 };
178
179 Elm_Gen_Item *_elm_genlist_item_new(Widget_Data *wd, const Elm_Gen_Item_Class *itc, const void *data, Elm_Gen_Item *parent, Evas_Smart_Cb func, const void *func_data);
180
181 Evas_Object  *_elm_genlist_item_widget_get(const Elm_Gen_Item *it);
182
183 void          _elm_genlist_page_relative_set(Evas_Object *obj, double h_pagerel, double v_pagerel);
184
185 void          _elm_genlist_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel);
186
187 void          _elm_genlist_page_size_set(Evas_Object *obj, Evas_Coord h_pagesize, Evas_Coord v_pagesize);
188
189 void          _elm_genlist_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber);
190
191 void          _elm_genlist_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber);
192
193 void          _elm_genlist_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber);
194
195 void          _elm_genlist_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber);
196
197 void          _elm_genlist_item_unrealize(Elm_Gen_Item *it, Eina_Bool calc);
198 void          _elm_genlist_item_del_serious(Elm_Gen_Item *it);
199
200 void          _elm_genlist_item_del_notserious(Elm_Gen_Item *it);
201
202 #endif