Atspi: enhance finding next and prev item on screen's edge
[platform/upstream/elementary.git] / src / mobile_lib / elm_widget_genlist.h
1 #ifndef ELM_WIDGET_GENLIST_H
2 #define ELM_WIDGET_GENLIST_H
3
4 #include "elm_gen_common.h"
5 #include "Elementary.h"
6 #define BANDED_MAX_ITEMS 20
7
8 /* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
9  * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
10  * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
11  * IT AT RUNTIME.
12  */
13
14 /**
15  * @internal
16  * @addtogroup Widget
17  * @{
18  *
19  * @section elm-genlist-class The Elementary Genlist Class
20  *
21  * Elementary, besides having the @ref Elm_Genlist widget, exposes its
22  * foundation -- the Elementary Genlist Class -- in order to create
23  * other widgets which are a genlist with some more logic on top.
24  */
25
26 /**
27  * Base widget smart data extended with genlist instance data.
28  */
29 typedef struct _Elm_Genlist_Data Elm_Genlist_Data;
30
31 typedef enum
32 {
33    ELM_GENLIST_TREE_EFFECT_NONE = 0,
34    ELM_GENLIST_TREE_EFFECT_EXPAND = 1,
35    ELM_GENLIST_TREE_EFFECT_CONTRACT = 2
36 } Elm_Genlist_Item_Move_Effect_Mode;
37
38 struct _Elm_Genlist_Data
39 {
40    Eina_Inlist_Sorted_State             *state;
41    Evas_Object                          *hit_rect;
42    Evas_Object                          *pan_obj;
43
44    Evas_Object                          *focused_content;
45    Elm_Gen_Item                         *focused_item;
46
47    //Evas_Object                          *stack[2]; // stacking markers in pan
48    Evas_Object                          *obj; // the object itself
49
50    Eina_List                            *selected; /* a list of
51                                                     * selected
52                                                     * items */
53    //Eina_List                            *deselecting; /* a list of items currently being deselected */
54    Eina_List                            *group_items; /* a list of
55                                                        * groups index
56                                                        * items */
57    Eina_Inlist                          *items; /* an inlist of all items */
58    //Elm_Gen_Item                         *reorder_it; /* item currently
59    //                                                  * being
60    //                                                  * repositioned */
61
62    struct
63      {
64         Elm_Gen_Item *it;
65         int dir;
66         Eina_List *move_items;
67         Ecore_Animator *anim;
68      } reorder;
69
70    Elm_Object_Item                      *last_selected_item;
71    int                                   minw, minh;
72
73    Eina_Bool                             scr_minw : 1;
74    Eina_Bool                             scr_minh : 1;
75    unsigned int                          item_count;
76    Evas_Coord                            pan_x, pan_y;
77    Elm_Object_Select_Mode                select_mode;
78
79    Evas_Coord                            comp_y;
80    int                                   dir;
81    Eina_List                            *blocks_realized;
82    Eina_Inlist                          *blocks; /* an inlist of all
83                                                   * blocks. a block
84                                                   * consists of a
85                                                   * certain number of
86                                                   * items. maximum
87                                                   * number of items in
88                                                   * a block is
89                                                   * 'max_items_per_block'. */
90    Evas_Coord                            prev_viewport_w;
91    Ecore_Idle_Enterer                   *queue_idle_enterer;
92    Eina_List                            *queue;
93    Elm_Gen_Item                         *show_item, *mode_item, *expanded_item;
94    Eina_Inlist                          *item_cache; /* an inlist of
95                                                       * edje object it
96                                                       * cache. */
97
98    Elm_List_Mode                         mode;
99    Ecore_Timer                          *scr_hold_timer;
100    const char                           *decorate_it_type;
101    double                                start_time;
102    Evas_Coord                            prev_x, prev_y, prev_mx, prev_my;
103    Evas_Coord                            cur_x, cur_y, cur_mx, cur_my;
104
105    int                                   item_cache_count;
106    int                                   item_cache_max; /* maximum
107                                                           * number of
108                                                           * cached
109                                                           * items */
110    /* maximum number of items per block */
111    int                                   max_items_per_block;
112
113    /* longpress timeout. this value comes from _elm_config by
114     * default. this can be changed by
115     * elm_genlist_longpress_timeout_set() */
116    double                                longpress_timeout;
117    Eina_Compare_Cb                       item_compare_cb;
118    Eina_Compare_Cb                       item_compare_data_cb;
119
120    /* a scrollto type which remembers where to scroll ex) in, top,
121     * middle */
122    Elm_Genlist_Item_Scrollto_Type        scroll_to_type;
123
124    Evas_Object                          *g_layer;
125    Elm_Gen_Item                         *g_item;
126    const char                           *g_type;
127    Eina_Bool                             select_on_focus_enabled : 1;
128    Eina_Bool                             decorate_all_mode : 1;
129    Eina_Bool                             reorder_mode : 1; /* a flag
130                                                             * for
131                                                             * reorder
132                                                             * mode
133                                                             * enable/disable */
134    Eina_Bool                             reorder_force : 1; /* a flag
135                                                              * for
136                                                              * reorder
137                                                              * by force */
138    /* this flag means genlist is supposed to be scrolled. if this flag
139     * is set to EINA_TRUE, genlist checks whether it's ok to scroll
140     * genlist now or not. */
141
142    Eina_Bool                             homogeneous : 1;
143    Eina_Bool                             realization_mode : 1;
144    Eina_Hash                             *size_caches;
145
146    Eina_Bool                             on_sub_del : 1;
147
148    /* a flag for items can be highlighted or not. by default this flag
149        * is true. */
150    Eina_Bool                             highlight : 1;
151    Eina_Bool                             h_bounce : 1;
152    Eina_Bool                             v_bounce : 1;
153    Eina_Bool                             bring_in : 1; /* a flag to
154                                                         * describe the
155                                                         * scroll
156                                                         * animation. (show,
157                                                         * bring in) */
158
159    /* this is set to EINA_TRUE when the item is re-queued. this
160     * happens when the item is un-queued but the rel item is still in
161     * the queue. this item will be processed later. */
162    Eina_Bool                             requeued : 1;
163    Eina_Bool                             multi : 1; /* a flag for item
164                                                      * multi
165                                                      * selection */
166    Eina_Bool                             sorting : 1;
167    Evas_Coord                            finger_minw, finger_minh;
168    int                                   processed_sizes;
169    Eina_Bool                             calc_done : 1;
170    Eina_Bool                             was_selected : 1;
171    Ecore_Job                             *dummy_job;
172    Ecore_Timer                           *scr_timer;
173    Eina_Bool                             no_cache : 1;
174    Elm_Gen_Item                          *key_down_item;
175    Eina_Bool                             on_hold : 1; /* a flag for check
176                                                        * item selected or
177                                                        * not */
178
179    /* this is genlist item Fx effect on Add/Remove */
180    Eina_Bool                             fx_mode : 1;
181    struct
182      {
183         Eina_List                        *items;
184         Eina_List                        *pending_items;
185         Ecore_Animator                   *anim;
186         int                              cnt;
187      } del_fx;
188    struct
189      {
190         Eina_List                        *items;
191         Ecore_Animator                   *anim;
192         int                              cnt;
193      } add_fx;
194
195 // TIZEN ONLY(20150701) : Banded Color UX Feature
196    /*for banded ux*/
197    Elm_Gen_Item                          *top_drawn_item;
198    Evas_Object                           *banded_bg_rect; /* banded color
199                                                              background feature.
200                                                              enabled only
201                                                              un-scrollable. */
202    Eina_Bool                             banded_bg_on : 1;
203 // TIZEN_ONLY
204
205    Eina_Bool                             is_access : 1;
206    Elm_Gen_Item                         *highlighted_item;
207    Evas_Coord                            viewport_w, viewport_h;
208    Elm_Gen_Item                         *atspi_item_to_highlight;
209    // TIZEN_ONLY(20180326) : Atspi: enhance finding next and prev item on screen's edge
210    int                                   scroll_delta_y_backup;
211    //
212    Elm_Gen_Item                         *aligned_item;
213    //TIZEN_ONLY(20161104) : Accessibility : synchronized highlight of atspi and item align feature for wearable profile
214    Elm_Gen_Item                         *currently_highlighted_item;
215    //
216
217    Eina_List                            *filter_queue;
218    Eina_List                            *filtered_list;
219    void                                 *filter_data;
220    unsigned int                          processed_count;
221    unsigned int                          filtered_count;
222    Ecore_Idle_Enterer                   *queue_filter_enterer;
223    Eina_Bool                             filter;
224    Elm_Genlist_Item_Scrollto_Type        focus_scrollto_type;
225
226    Eina_Bool                             unhighlight_skip: 1;
227    Elm_Gen_Item                          *adjusted_item;
228    Eina_Bool                             bottom_margin_enabled : 1;
229    Eina_Bool                             unhighlighted : 1;
230    Evas_Object                           *focus_bg;
231
232    Eina_Bool                             focus_on_selection_enabled : 1;
233 };
234
235 typedef struct _Item_Block Item_Block;
236 typedef struct _Item_Cache Item_Cache;
237 typedef struct _Elm_Genlist_Filter Elm_Genlist_Filter;
238
239 struct Elm_Gen_Item_Type
240 {
241    Elm_Gen_Item           *it;
242
243    Elm_Genlist_Data       *wsd;
244
245    Item_Block             *block;
246    Eina_List              *items;
247    Evas_Coord              w, h, minw, minh;
248    Elm_Gen_Item           *group_item;
249    Elm_Genlist_Item_Type   type;
250    Eina_List              *deco_it_texts, *deco_it_contents;
251    Eina_List              *deco_all_texts, *deco_all_contents;
252    Eina_List              *flip_contents, *flip_content_objs;
253    Ecore_Timer            *swipe_timer;
254    Evas_Coord              scrl_x, scrl_y, old_scrl_y;
255
256    Elm_Gen_Item           *rel;
257    Eina_List              *rel_revs; // FIXME: find better way not to use this
258    Evas_Object            *deco_it_view;
259    int                     expanded_depth;
260    int                     order_num_in;
261
262 // TIZEN ONLY(20150701) : Banded Color UX Feature
263    int                     banded_color_index;
264    Evas_Object            *banded_bg;
265    Ecore_Animator         *banded_anim;
266 // TIZEN ONLY
267
268    Eina_Bool               decorate_all_item_realized : 1;
269    Eina_Bool               tree_effect_finished : 1; /* tree effect */
270    Eina_Bool               move_effect_enabled : 1;
271    Eina_Bool               tree_effect_hide_me : 1; /* item hide for
272                                                     * tree effect */
273
274    Eina_Bool               stacking_even : 1;
275    Eina_Bool               want_realize : 1;
276    Eina_Bool               nocache_once : 1; /* do not use cache for
277                                               * this item only once */
278    Eina_Bool               nostacking : 1;
279    Eina_Bool               expanded : 1;
280    Eina_Bool               mincalcd : 1;
281    Eina_Bool               updateme : 1;
282    Eina_Bool               nocache : 1; /* do not use cache for this item */
283    Eina_Bool               queued : 1;
284    Eina_Bool               before : 1;
285    Eina_Bool               show_me : 1;
286
287    Eina_Bool               is_prepend : 1;
288    Eina_Bool               calc_done : 1;
289
290    Evas_Coord              reorder_offset;
291
292    Ecore_Timer             *highlight_timer;
293    Eina_Bool               multiline : 1;
294    Eina_Bool               resized : 1;
295    Evas_Object             *proxy;
296 };
297
298
299 struct _Item_Block
300 {
301    EINA_INLIST;
302
303    int                     count;
304    int                     num;
305    int                     reorder_offset;
306    Elm_Genlist_Data       *sd;
307    Eina_List              *items;
308    Evas_Coord              x, y, w, h, minw, minh;
309    int                     position;
310    int                     item_position_stamp;
311
312    Eina_Bool               position_update : 1;
313    Eina_Bool               want_unrealize : 1;
314    Eina_Bool               must_recalc : 1;
315    Eina_Bool               realized : 1;
316    Eina_Bool               updateme : 1;
317    Eina_Bool               changed : 1;
318    Eina_Bool               show_me : 1;
319
320    Eina_Bool               calc_done : 1;
321 };
322
323 struct _Item_Cache
324 {
325    EINA_INLIST;
326
327    Evas_Object *base_view, *spacer;
328
329    const Elm_Genlist_Item_Class  *item_class; // it->itc
330    Eina_Bool    multiline;
331    Eina_Bool    selected : 1; // it->selected
332    Eina_Bool    disabled : 1; // it->disabled
333    Eina_Bool    expanded : 1; // it->item->expanded
334    Eina_Bool    tree : 1; // it->group
335    Eina_List   *contents; // content objects for reusing
336 };
337
338 typedef struct _Elm_Genlist_Pan_Data Elm_Genlist_Pan_Data;
339 struct _Elm_Genlist_Pan_Data
340 {
341    Evas_Object            *wobj;
342    Elm_Genlist_Data       *wsd;
343    Ecore_Job              *resize_job;
344 };
345
346 /**
347  * Structure added to genlist for internal filter iterator implementation
348  * Can be extended to genlist as a whole in future if needed.
349  */
350 struct _Elm_Genlist_Filter
351 {
352    Eina_Iterator iterator;
353    const Eina_Inlist *head;
354    const Eina_Inlist *current;
355 };
356
357
358 /**
359  * @}
360  */
361
362 #define GL_IT(_it) (_it->item)
363
364 #define ELM_GENLIST_DATA_GET(o, sd) \
365   Elm_Genlist_Data * sd = eo_data_scope_get(o, ELM_GENLIST_CLASS)
366
367 #define ELM_GENLIST_DATA_GET_FROM_ITEM(it, sd) \
368   Elm_Genlist_Data * sd = GL_IT(it)->wsd
369
370 #define ELM_GENLIST_PAN_DATA_GET(o, sd) \
371   Elm_Genlist_Pan_Data * sd = eo_data_scope_get(o, ELM_GENLIST_PAN_CLASS)
372
373 #define ELM_GENLIST_DATA_GET_OR_RETURN(o, ptr)       \
374   ELM_GENLIST_DATA_GET(o, ptr);                      \
375   if (EINA_UNLIKELY(!ptr))                           \
376     {                                                \
377        CRI("No widget data for object %p (%s)",      \
378            o, evas_object_type_get(o));              \
379        return;                                       \
380     }
381
382 #define ELM_GENLIST_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
383   ELM_GENLIST_DATA_GET(o, ptr);                         \
384   if (EINA_UNLIKELY(!ptr))                              \
385     {                                                   \
386        CRI("No widget data for object %p (%s)",         \
387            o, evas_object_type_get(o));                 \
388        return val;                                      \
389     }
390
391 #define ELM_GENLIST_CHECK(obj)                              \
392   if (EINA_UNLIKELY(!eo_isa((obj), ELM_GENLIST_CLASS))) \
393     return
394
395 #define ELM_GENLIST_ITEM_CHECK(it)                          \
396   ELM_WIDGET_ITEM_CHECK_OR_RETURN(it->base, ); \
397   ELM_GENLIST_CHECK(it->base->widget);
398
399 #define ELM_GENLIST_ITEM_CHECK_OR_RETURN(it, ...)                      \
400   ELM_WIDGET_ITEM_CHECK_OR_RETURN(it->base, __VA_ARGS__); \
401   ELM_GENLIST_CHECK(it->base->widget) __VA_ARGS__;
402
403 #define ELM_GENLIST_ITEM_CHECK_OR_GOTO(it, label)              \
404   ELM_WIDGET_ITEM_CHECK_OR_GOTO(it->base, label); \
405   if (!it->base->widget || !eo_isa                              \
406         ((it->base->widget), ELM_GENLIST_CLASS)) goto label;
407
408 #define ELM_GENLIST_ITEM_DATA_GET(o, sd) \
409   Elm_Gen_Item* sd = eo_data_scope_get(o, ELM_GENLIST_ITEM_CLASS)
410
411 #define ELM_GENLIST_FILTER_ITERATOR_ITEM_GET(ptr,                 \
412                                   type) ((type *)((char *)ptr - \
413                                                   offsetof(type, __in_list)))
414
415 #endif