elm genlist: More documentation.
[framework/uifw/elementary.git] / src / lib / elm_genlist.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;
35    Elm_Gen_Item                 *parent;
36    Eina_List                    *labels, *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    Eina_Bool   want_unrealize : 1;
54    Eina_Bool   display_only : 1;
55    Eina_Bool   realized : 1;
56    Eina_Bool   selected : 1;
57    Eina_Bool   highlighted : 1;
58    Eina_Bool   disabled : 1;
59    Eina_Bool   dragging : 1;
60    Eina_Bool   down : 1;
61    Eina_Bool   group : 1;
62    Eina_Bool   reorder : 1;
63    Eina_Bool   mode_set : 1; /* item uses style mode for highlight/select */
64 };
65
66 typedef struct _Pan Pan;
67 struct _Pan
68 {
69    Evas_Object_Smart_Clipped_Data __clipped_data;
70    Widget_Data                   *wd;
71    Ecore_Job                     *resize_job;
72 };
73
74 struct _Widget_Data
75 {
76    Eina_Inlist_Sorted_State *state;
77    Evas_Object      *obj; /* the genlist object */
78    Evas_Object      *scr; /* a smart scroller object which is used internally in genlist */
79    Evas_Object      *pan_smart; /* "elm_genlist_pan" evas smart object. this is an extern pan of smart scroller(scr). */
80    Eina_List        *selected;
81    Eina_List        *group_items; /* list of groups index items */
82    Eina_Inlist      *items; /* inlist of all items */
83    Elm_Gen_Item     *reorder_it; /* item currently being repositioned */
84    Elm_Gen_Item     *last_selected_item;
85    Pan              *pan; /* pan_smart object's smart data */
86    Ecore_Job        *calc_job;
87    int               walking;
88    int               item_width, item_height;
89    int               group_item_width, group_item_height;
90    int               minw, minh;
91    long              count;
92    Evas_Coord        pan_x, pan_y;
93    Eina_Bool         reorder_mode : 1; /* a flag for reorder mode enable/disable */
94    Eina_Bool         on_hold : 1;
95    Eina_Bool         multi : 1; /* a flag for item multi selection */
96    Eina_Bool         no_select : 1;
97    Eina_Bool         wasselected : 1;
98    Eina_Bool         always_select : 1;
99    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.  */
100    Eina_Bool         h_bounce : 1;
101    Eina_Bool         v_bounce : 1;
102    Ecore_Cb          del_cb, calc_cb, sizing_cb;
103    Ecore_Cb          clear_cb;
104    ////////////////////////////////////
105    Eina_Inlist      *blocks; /* 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'. */
106    Evas_Coord        reorder_old_pan_y, w, h, realminw, prev_viewport_w;
107    Ecore_Job        *update_job;
108    Ecore_Idle_Enterer *queue_idle_enterer;
109    Ecore_Idler        *must_recalc_idler;
110    Eina_List        *queue;
111    Elm_Gen_Item *show_item, *anchor_item, *mode_item, *reorder_rel, *expanded_item;
112    Eina_Inlist      *item_cache; /* an inlist of edje object it cache. */
113    Evas_Coord        anchor_y;
114    Evas_Coord        reorder_start_y; /* reorder it's initial y coordinate in the pan. */
115    Elm_List_Mode     mode;
116    Ecore_Timer      *multi_timer, *scr_hold_timer;
117    Ecore_Animator   *reorder_move_animator;
118    const char       *mode_type;
119    const char       *mode_item_style;
120    unsigned int      start_time;
121    Evas_Coord        prev_x, prev_y, prev_mx, prev_my;
122    Evas_Coord        cur_x, cur_y, cur_mx, cur_my;
123    Eina_Bool         mouse_down : 1;
124    Eina_Bool         multi_down : 1;
125    Eina_Bool         multi_timeout : 1;
126    Eina_Bool         multitouched : 1;
127    Eina_Bool         longpressed : 1;
128    Eina_Bool         bring_in : 1;
129    Eina_Bool         compress : 1;
130    Eina_Bool         height_for_width : 1;
131    Eina_Bool         homogeneous : 1;
132    Eina_Bool         swipe : 1;
133    Eina_Bool         reorder_pan_move : 1;
134    Eina_Bool         auto_scroll_enabled : 1;
135    Eina_Bool         pan_resized : 1;
136    struct
137    {
138       Evas_Coord x, y;
139    } history[SWIPE_MOVES];
140    int               multi_device;
141    int               item_cache_count;
142    int               item_cache_max; /* maximum number of cached items */
143    int               movements;
144    int               max_items_per_block; /* maximum number of items per block */
145    double            longpress_timeout; /* longpress timeout. this value comes from _elm_config by default. this can be changed by elm_genlist_longpress_timeout_set() */
146    int               generation; /* a generation of genlist. when genlist is cleared, this value will be increased and a new generation will start */
147
148    /* The stuff below directly come from gengrid without any thinking */
149    unsigned int      nmax;
150    Evas_Coord        reorder_item_x, reorder_item_y;
151    Evas_Coord        old_pan_x, old_pan_y;
152    long              items_lost;
153    double            align_x, align_y;
154
155    Eina_Bool         horizontal : 1;
156    Eina_Bool         move_effect_enabled : 1;
157    Eina_Bool         reorder_item_changed : 1;
158 };
159
160 Elm_Gen_Item *
161 _elm_genlist_item_new(Widget_Data              *wd,
162                       const Elm_Gen_Item_Class *itc,
163                       const void               *data,
164                       Elm_Gen_Item             *parent,
165                       Evas_Smart_Cb             func,
166                       const void               *func_data);
167
168 Evas_Object *
169 _elm_genlist_item_widget_get(const Elm_Gen_Item *it);
170
171 void
172 _elm_genlist_page_relative_set(Evas_Object *obj,
173                                double       h_pagerel,
174                                double       v_pagerel);
175
176 void
177 _elm_genlist_page_relative_get(const Evas_Object *obj,
178                                double            *h_pagerel,
179                                double            *v_pagerel);
180
181 void
182 _elm_genlist_page_size_set(Evas_Object *obj,
183                            Evas_Coord   h_pagesize,
184                            Evas_Coord   v_pagesize);
185
186 void
187 _elm_genlist_current_page_get(const Evas_Object *obj,
188                               int               *h_pagenumber,
189                               int               *v_pagenumber);
190
191 void
192 _elm_genlist_last_page_get(const Evas_Object *obj,
193                            int               *h_pagenumber,
194                            int               *v_pagenumber);
195
196 void
197 _elm_genlist_page_show(const Evas_Object *obj,
198                        int                h_pagenumber,
199                        int                v_pagenumber);
200
201 void
202 _elm_genlist_page_bring_in(const Evas_Object *obj,
203                            int                h_pagenumber,
204                            int                v_pagenumber);
205
206 void
207 _elm_genlist_item_unrealize(Elm_Gen_Item *it,
208                             Eina_Bool     calc);
209 void
210 _elm_genlist_item_del_serious(Elm_Gen_Item *it);
211
212 void
213 _elm_genlist_item_del_notserious(Elm_Gen_Item *it);
214
215 #endif