1 #ifndef ELM_WIDGET_GENLIST_H
2 #define ELM_WIDGET_GENLIST_H
4 #include "elm_gen_common.h"
5 #include "elm_interface_scrollable.h"
6 #include "elm_widget_layout.h"
8 // FIXME: Difference from upstream
9 #define GENLIST_ENTRY_SUPPORT 1
10 #define GENLIST_FX_SUPPORT 1
11 #define GENLIST_PINCH_ZOOM_SUPPORT 1
17 * @section elm-genlist-class The Elementary Genlist Class
19 * Elementary, besides having the @ref Genlist widget, exposes its
20 * foundation -- the Elementary Genlist Class -- in order to create
21 * other widgets which are a genlist with some more logic on top.
25 * @def ELM_GENLIST_CLASS
27 * Use this macro to cast whichever subclass of
28 * #Elm_Genlist_Smart_Class into it, so to access its fields.
32 #define ELM_GENLIST_CLASS(x) ((Elm_Genlist_Smart_Class *)x)
35 * @def ELM_GENLIST_DATA
37 * Use this macro to cast whichever subdata of
38 * #Elm_Genlist_Smart_Data into it, so to access its fields.
42 #define ELM_GENLIST_DATA(x) ((Elm_Genlist_Smart_Data *)x)
45 * @def ELM_GENLIST_SMART_CLASS_VERSION
47 * Current version for Elementary genlist @b base smart class, a value
48 * which goes to _Elm_Genlist_Smart_Class::version.
52 #define ELM_GENLIST_SMART_CLASS_VERSION 1
55 * @def ELM_GENLIST_SMART_CLASS_INIT
57 * Initializer for a whole #Elm_Genlist_Smart_Class structure, with
58 * @c NULL values on its specific fields.
60 * @param smart_class_init initializer to use for the "base" field
61 * (#Evas_Smart_Class).
63 * @see EVAS_SMART_CLASS_INIT_NULL
64 * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
65 * @see ELM_GENLIST_SMART_CLASS_INIT_NULL
66 * @see ELM_GENLIST_SMART_CLASS_INIT_NAME_VERSION
70 #define ELM_GENLIST_SMART_CLASS_INIT(smart_class_init) \
71 {smart_class_init, ELM_GENLIST_SMART_CLASS_VERSION}
74 * @def ELM_GENLIST_SMART_CLASS_INIT_NULL
76 * Initializer to zero out a whole #Elm_Genlist_Smart_Class structure.
78 * @see ELM_GENLIST_SMART_CLASS_INIT_NAME_VERSION
79 * @see ELM_GENLIST_SMART_CLASS_INIT
83 #define ELM_GENLIST_SMART_CLASS_INIT_NULL \
84 ELM_GENLIST_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
87 * @def ELM_GENLIST_SMART_CLASS_INIT_NAME_VERSION
89 * Initializer to zero out a whole #Elm_Genlist_Smart_Class structure and
90 * set its name and version.
92 * This is similar to #ELM_GENLIST_SMART_CLASS_INIT_NULL, but it will
93 * also set the version field of #Elm_Genlist_Smart_Class (base field)
94 * to the latest #ELM_GENLIST_SMART_CLASS_VERSION and name it to the
97 * It will keep a reference to the name field as a <c>"const char *"</c>,
98 * i.e., the name must be available while the structure is
99 * used (hint: static or global variable!) and must not be modified.
101 * @see ELM_GENLIST_SMART_CLASS_INIT_NULL
102 * @see ELM_GENLIST_SMART_CLASS_INIT
106 #define ELM_GENLIST_SMART_CLASS_INIT_NAME_VERSION(name) \
107 ELM_GENLIST_SMART_CLASS_INIT \
108 (ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
111 * Elementary genlist base smart class. This inherits directly from
112 * #Elm_Layout_Smart_Class and is meant to build widgets extending the
113 * behavior of a genlist.
115 * All of the functions listed on @ref Genlist namespace will work for
116 * objects deriving from #Elm_Genlist_Smart_Class.
118 typedef struct _Elm_Genlist_Smart_Class
120 Elm_Layout_Smart_Class base;
122 int version; /**< Version of this smart class definition */
123 } Elm_Genlist_Smart_Class;
126 * Base widget smart data extended with genlist instance data.
128 typedef struct _Elm_Genlist_Smart_Data Elm_Genlist_Smart_Data;
130 struct _Elm_Genlist_Smart_Data
132 Elm_Layout_Smart_Data base; /* base widget smart data as
133 * first member obligatory, as
134 * we're inheriting from it */
136 const Elm_Scrollable_Smart_Interface *s_iface;
138 Eina_Inlist_Sorted_State *state;
139 Evas_Object *hit_rect;
140 Evas_Object *pan_obj;
142 Eina_List *selected; /* a list of
145 Eina_List *group_items; /* a list of
148 Eina_Inlist *items; /* an inlist of all items */
149 Elm_Gen_Item *reorder_it; /* item currently
152 Elm_Object_Item *last_selected_item;
154 int item_width, item_height;
155 int group_item_width, group_item_height;
157 unsigned int item_count;
158 Evas_Coord pan_x, pan_y;
159 Elm_Object_Select_Mode select_mode;
161 Eina_Inlist *blocks; /* an inlist of all
168 * 'max_items_per_block'. */
169 Evas_Coord reorder_old_pan_y, w, h, realminw,
171 Ecore_Job *update_job;
172 Ecore_Idle_Enterer *queue_idle_enterer;
173 Ecore_Idler *must_recalc_idler;
175 Elm_Gen_Item *show_item, *anchor_item, *mode_item,
176 *reorder_rel, *expanded_item;
177 Eina_Inlist *item_cache; /* an inlist of
181 Evas_Coord reorder_start_y; /* reorder
188 Ecore_Timer *multi_timer, *scr_hold_timer;
189 Ecore_Animator *reorder_move_animator;
190 const char *decorate_it_type;
192 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
193 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
198 } history[SWIPE_MOVES];
201 int item_cache_count;
202 int item_cache_max; /* maximum
208 /* maximum number of items per block */
209 int max_items_per_block;
211 /* longpress timeout. this value comes from _elm_config by
212 * default. this can be changed by
213 * elm_genlist_longpress_timeout_set() */
214 double longpress_timeout;
215 Eina_Compare_Cb item_compare_cb;
216 Eina_Compare_Cb item_compare_data_cb;
218 /* a scrollto type which remembers where to scroll ex) in, top,
220 Elm_Genlist_Item_Scrollto_Type scroll_to_type;
221 Evas_Object *alpha_bg; /* not to receive
225 Elm_Gen_Item *expanded_next_item;
228 #if GENLIST_FX_SUPPORT
230 Eina_List *capture_before_items, *capture_after_items;
231 Eina_List *pending_del_items, *pending_unrealized_items;
232 Eina_List *pending_unrealized_decorate_all_items;
233 Elm_Gen_Item *realized_top_item;
234 Ecore_Timer *fx_timer;
237 Eina_Bool auto_scroll_enabled : 1;
238 Eina_Bool decorate_all_mode : 1;
239 Eina_Bool height_for_width : 1;
240 Eina_Bool reorder_pan_move : 1;
241 Eina_Bool multi_timeout : 1;
242 Eina_Bool multi_touched : 1;
243 Eina_Bool reorder_mode : 1; /* a flag
248 /* this flag means genlist is supposed to be scrolled. if this flag
249 * is set to EINA_TRUE, genlist checks whether it's ok to scroll
250 * genlist now or not. */
251 Eina_Bool check_scroll : 1;
252 Eina_Bool pan_changed : 1;
253 Eina_Bool wasselected : 1;
254 Eina_Bool homogeneous : 1;
255 Eina_Bool longpressed : 1;
257 Eina_Bool mouse_down : 1;
258 Eina_Bool multi_down : 1;
259 Eina_Bool on_sub_del : 1;
261 /* a flag for items can be highlighted or not. by default this flag
263 Eina_Bool highlight : 1;
264 Eina_Bool h_bounce : 1;
265 Eina_Bool v_bounce : 1;
266 Eina_Bool bring_in : 1; /* a flag to
272 /* this is set to EINA_TRUE when the item is re-queued. this
273 * happens when the item is un-queued but the rel item is still in
274 * the queue. this item will be processed later. */
275 Eina_Bool requeued : 1;
276 Eina_Bool on_hold : 1;
277 Eina_Bool multi : 1; /* a flag for item
282 #if GENLIST_ENTRY_SUPPORT
283 Eina_Bool size_changed : 1;
286 #if GENLIST_FX_SUPPORT
287 Eina_Bool fx_mode : 1;
288 Eina_Bool fx_first_captured : 1;
289 Eina_Bool fx_playing : 1;
290 Eina_Bool rendered : 1;
291 Eina_Bool fx_items_deleted : 1;
292 Eina_Bool genlist_clearing : 1;
294 #if GENLIST_PINCH_ZOOM_SUPPORT
295 Elm_Gen_Pinch_Zoom_Mode pinch_zoom_mode;
296 Evas_Coord pinch_pan_y, pinch_zoom_h;
298 Eina_Bool sorting : 1;
301 typedef struct _Item_Block Item_Block;
302 typedef struct _Item_Cache Item_Cache;
304 struct Elm_Gen_Item_Type
308 Elm_Genlist_Smart_Data *wsd;
312 Evas_Coord w, h, minw, minh;
313 Elm_Gen_Item *group_item;
314 Elm_Genlist_Item_Type type;
315 Eina_List *deco_it_texts, *deco_it_contents,
316 *deco_it_states, *deco_it_content_objs;
317 Eina_List *deco_all_texts, *deco_all_contents,
318 *deco_all_states, *deco_all_content_objs;
319 Eina_List *flip_contents, *flip_content_objs;
320 Ecore_Timer *swipe_timer;
321 Evas_Coord scrl_x, scrl_y, old_scrl_y;
324 Eina_List *rel_revs; // FIXME: find better way not to use this
325 Evas_Object *deco_it_view;
326 #if GENLIST_FX_SUPPORT
330 #if GENLIST_PINCH_ZOOM_SUPPORT
331 Evas_Coord pan_scrl_y;
336 Eina_Bool decorate_all_item_realized : 1;
337 Eina_Bool move_effect_enabled : 1;
339 Eina_Bool stacking_even : 1;
340 Eina_Bool want_realize : 1;
341 Eina_Bool nocache_once : 1; /* do not use cache for
342 * this item only once */
343 Eina_Bool nostacking : 1;
344 Eina_Bool expanded : 1;
345 Eina_Bool mincalcd : 1;
346 Eina_Bool updateme : 1;
347 Eina_Bool nocache : 1; /* do not use cache for this item */
348 Eina_Bool queued : 1;
349 Eina_Bool before : 1;
350 Eina_Bool show_me : 1;
351 /* if item is realized once, it is not unrealized & realized again. */
352 Eina_Bool unrealize_disabled: 1;
353 #if GENLIST_FX_SUPPORT
354 Eina_Bool has_proxy_it : 1;
365 Elm_Genlist_Smart_Data *sd;
367 Evas_Coord x, y, w, h, minw, minh;
369 int item_position_stamp;
371 Eina_Bool position_update : 1;
372 Eina_Bool want_unrealize : 1;
373 Eina_Bool must_recalc : 1;
374 Eina_Bool realized : 1;
375 Eina_Bool updateme : 1;
376 Eina_Bool changed : 1;
377 Eina_Bool show_me : 1;
384 Evas_Object *base_view, *spacer;
386 const char *item_style; // it->itc->item_style
388 Eina_Bool selected : 1; // it->selected
389 Eina_Bool disabled : 1; // it->disabled
390 Eina_Bool expanded : 1; // it->item->expanded
391 Eina_Bool tree : 1; // it->group
394 typedef struct _Elm_Genlist_Pan_Smart_Class
396 Elm_Pan_Smart_Class base;
397 } Elm_Genlist_Pan_Smart_Class;
399 typedef struct _Elm_Genlist_Pan_Smart_Data Elm_Genlist_Pan_Smart_Data;
400 struct _Elm_Genlist_Pan_Smart_Data
402 Elm_Pan_Smart_Data base;
403 Elm_Genlist_Smart_Data *wsd;
404 Ecore_Job *resize_job;
411 EAPI extern const char ELM_GENLIST_SMART_NAME[];
412 EAPI const Elm_Genlist_Smart_Class *elm_genlist_smart_class_get(void);
414 #define ELM_GENLIST_DATA_GET(o, sd) \
415 Elm_Genlist_Smart_Data * sd = evas_object_smart_data_get(o)
417 #define ELM_GENLIST_PAN_DATA_GET(o, sd) \
418 Elm_Genlist_Pan_Smart_Data * sd = evas_object_smart_data_get(o)
420 #define ELM_GENLIST_DATA_GET_OR_RETURN(o, ptr) \
421 ELM_GENLIST_DATA_GET(o, ptr); \
424 CRITICAL("No widget data for object %p (%s)", \
425 o, evas_object_type_get(o)); \
429 #define ELM_GENLIST_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
430 ELM_GENLIST_DATA_GET(o, ptr); \
433 CRITICAL("No widget data for object %p (%s)", \
434 o, evas_object_type_get(o)); \
438 #define ELM_GENLIST_CHECK(obj) \
439 if (!obj || !elm_widget_type_check((obj), ELM_GENLIST_SMART_NAME, __func__)) \
442 #define ELM_GENLIST_ITEM_CHECK(it) \
443 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
444 ELM_GENLIST_CHECK(it->base.widget);
446 #define ELM_GENLIST_ITEM_CHECK_OR_RETURN(it, ...) \
447 ELM_WIDGET_ITEM_CHECK_OR_RETURN(((Elm_Widget_Item *)it), __VA_ARGS__); \
448 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(((Elm_Widget_Item *)it), __VA_ARGS__); \
449 ELM_GENLIST_CHECK(it->base.widget) __VA_ARGS__;
451 #define ELM_GENLIST_ITEM_CHECK_OR_GOTO(it, label) \
452 ELM_WIDGET_ITEM_CHECK_OR_GOTO(((Elm_Widget_Item *)it), label); \
453 ELM_WIDGET_ITEM_GOTO_IF_ONDEL(((Elm_Widget_Item *)it), label); \
454 if (!it->base.widget || !elm_widget_type_check \
455 ((it->base.widget), ELM_GENLIST_SMART_NAME, __func__)) goto label;