1 #ifndef ELM_WIDGET_GENGRID_H
2 #define ELM_WIDGET_GENGRID_H
4 #include "elm_gen_common.h"
5 #include "elm_interface_scrollable.h"
6 #include "elm_widget_layout.h"
8 #define GENGRID_FX_SUPPORT 1
14 * @section elm-gengrid-class The Elementary Gengrid Class
16 * Elementary, besides having the @ref Gengrid widget, exposes its
17 * foundation -- the Elementary Gengrid Class -- in order to create
18 * other widgets which are a gengrid with some more logic on top.
22 * @def ELM_GENGRID_CLASS
24 * Use this macro to cast whichever subclass of
25 * #Elm_Gengrid_Smart_Class into it, so to access its fields.
29 #define ELM_GENGRID_CLASS(x) ((Elm_Gengrid_Smart_Class *)x)
32 * @def ELM_GENGRID_DATA
34 * Use this macro to cast whichever subdata of
35 * #Elm_Gengrid_Smart_Data into it, so to access its fields.
39 #define ELM_GENGRID_DATA(x) ((Elm_Gengrid_Smart_Data *)x)
42 * @def ELM_GENGRID_SMART_CLASS_VERSION
44 * Current version for Elementary gengrid @b base smart class, a value
45 * which goes to _Elm_Gengrid_Smart_Class::version.
49 #define ELM_GENGRID_SMART_CLASS_VERSION 1
52 * @def ELM_GENGRID_SMART_CLASS_INIT
54 * Initializer for a whole #Elm_Gengrid_Smart_Class structure, with
55 * @c NULL values on its specific fields.
57 * @param smart_class_init initializer to use for the "base" field
58 * (#Evas_Smart_Class).
60 * @see EVAS_SMART_CLASS_INIT_NULL
61 * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
62 * @see ELM_GENGRID_SMART_CLASS_INIT_NULL
63 * @see ELM_GENGRID_SMART_CLASS_INIT_NAME_VERSION
67 #define ELM_GENGRID_SMART_CLASS_INIT(smart_class_init) \
68 {smart_class_init, ELM_GENGRID_SMART_CLASS_VERSION}
71 * @def ELM_GENGRID_SMART_CLASS_INIT_NULL
73 * Initializer to zero out a whole #Elm_Gengrid_Smart_Class structure.
75 * @see ELM_GENGRID_SMART_CLASS_INIT_NAME_VERSION
76 * @see ELM_GENGRID_SMART_CLASS_INIT
80 #define ELM_GENGRID_SMART_CLASS_INIT_NULL \
81 ELM_GENGRID_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
84 * @def ELM_GENGRID_SMART_CLASS_INIT_NAME_VERSION
86 * Initializer to zero out a whole #Elm_Gengrid_Smart_Class structure and
87 * set its name and version.
89 * This is similar to #ELM_GENGRID_SMART_CLASS_INIT_NULL, but it will
90 * also set the version field of #Elm_Gengrid_Smart_Class (base field)
91 * to the latest #ELM_GENGRID_SMART_CLASS_VERSION and name it to the
94 * It will keep a reference to the name field as a <c>"const char *"</c>,
95 * i.e., the name must be available while the structure is
96 * used (hint: static or global variable!) and must not be modified.
98 * @see ELM_GENGRID_SMART_CLASS_INIT_NULL
99 * @see ELM_GENGRID_SMART_CLASS_INIT
103 #define ELM_GENGRID_SMART_CLASS_INIT_NAME_VERSION(name) \
104 ELM_GENGRID_SMART_CLASS_INIT \
105 (ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
108 * Elementary gengrid base smart class. This inherits directly from
109 * #Elm_Layout_Smart_Class and is meant to build widgets extending the
110 * behavior of a gengrid.
112 * All of the functions listed on @ref Gengrid namespace will work for
113 * objects deriving from #Elm_Gengrid_Smart_Class.
115 typedef struct _Elm_Gengrid_Smart_Class
117 Elm_Layout_Smart_Class base;
119 int version; /**< Version of this smart class definition */
120 } Elm_Gengrid_Smart_Class;
123 * Base widget smart data extended with gengrid instance data.
125 typedef struct _Elm_Gengrid_Smart_Data Elm_Gengrid_Smart_Data;
126 struct _Elm_Gengrid_Smart_Data
128 Elm_Layout_Smart_Data base; /* base widget smart data as
129 * first member obligatory, as
130 * we're inheriting from it */
132 const Elm_Scrollable_Smart_Interface *s_iface;
134 Eina_Inlist_Sorted_State *state;
135 Evas_Object *hit_rect;
136 Evas_Object *pan_obj;
138 Eina_List *selected; /* a list of
141 Eina_List *group_items; /* a list of
144 Eina_Inlist *items; /* an inlist of all items */
145 Elm_Gen_Item *reorder_it; /* item currently
148 Elm_Object_Item *last_selected_item;
149 Elm_Gen_Item *show_it;
150 Elm_Gen_Item *bring_in_it;
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;
164 /* longpress timeout. this value comes from _elm_config by
165 * default. this can be changed by
166 * elm_gengrid_longpress_timeout_set() */
167 double longpress_timeout;
169 /* a generation of gengrid. when gengrid is cleared, this value
170 * will be increased and a new generation will start */
172 Eina_Compare_Cb item_compare_cb;
174 /* The stuff below directly come from gengrid without any thinking */
176 Evas_Coord reorder_item_x, reorder_item_y;
177 Evas_Coord old_pan_x, old_pan_y;
179 double align_x, align_y;
181 #if GENGRID_FX_SUPPORT
182 Evas_Object *alpha_bg;
184 Eina_List *capture_before_items, *capture_after_items;
185 Eina_List *pending_del_items, *pending_unrealized_items;
186 Elm_Gen_Item *realized_top_item;
189 Eina_Bool reorder_item_changed : 1;
190 Eina_Bool move_effect_enabled : 1;
192 Eina_Bool old_h_bounce;
193 Eina_Bool old_v_bounce;
195 /* a flag for reorder mode enable/disable */
196 Eina_Bool reorder_mode : 1;
197 Eina_Bool was_selected : 1;
199 Eina_Bool longpressed : 1;
200 Eina_Bool pan_changed : 1;
201 Eina_Bool horizontal : 1;
203 /* a flag for items can be highlighted or not. by default this flag
205 Eina_Bool highlight : 1;
207 Eina_Bool clear_me : 1; /**< a flag whether
209 * as to be cleared or
215 Eina_Bool on_hold : 1;
217 Eina_Bool filled : 1;
218 Eina_Bool multi : 1; /* a flag for item
221 Eina_Bool show_region : 1;
222 Eina_Bool bring_in : 1;
224 #if GENGRID_FX_SUPPORT
225 Eina_Bool fx_mode : 1;
226 Eina_Bool fx_first_captured : 1;
227 Eina_Bool fx_playing : 1;
228 Eina_Bool rendered : 1;
229 Eina_Bool fx_items_deleted : 1;
230 Eina_Bool gengrid_clearing : 1;
234 struct Elm_Gen_Item_Type
238 Elm_Gengrid_Smart_Data *wsd;
240 Ecore_Animator *item_reorder_move_animator;
241 Evas_Coord gx, gy, ox, oy, tx, ty, rx, ry;
242 unsigned int moving_effect_start_time;
244 #if GENGRID_FX_SUPPORT
245 Evas_Coord scrl_x, scrl_y, w, h;
248 Eina_Bool has_proxy_it : 1;
250 Eina_Bool group_realized : 1;
251 Eina_Bool moving : 1;
254 typedef struct _Elm_Gengrid_Pan_Smart_Class
256 Elm_Pan_Smart_Class base;
257 } Elm_Gengrid_Pan_Smart_Class;
259 typedef struct _Elm_Gengrid_Pan_Smart_Data Elm_Gengrid_Pan_Smart_Data;
260 struct _Elm_Gengrid_Pan_Smart_Data
262 Elm_Pan_Smart_Data base;
263 Elm_Gengrid_Smart_Data *wsd;
264 Ecore_Job *resize_job;
271 EAPI extern const char ELM_GENGRID_SMART_NAME[];
272 EAPI const Elm_Gengrid_Smart_Class *elm_gengrid_smart_class_get(void);
274 #define ELM_GENGRID_DATA_GET(o, sd) \
275 Elm_Gengrid_Smart_Data * sd = evas_object_smart_data_get(o)
277 #define ELM_GENGRID_PAN_DATA_GET(o, sd) \
278 Elm_Gengrid_Pan_Smart_Data * sd = evas_object_smart_data_get(o)
280 #define ELM_GENGRID_DATA_GET_OR_RETURN(o, ptr) \
281 ELM_GENGRID_DATA_GET(o, ptr); \
284 CRITICAL("No widget data for object %p (%s)", \
285 o, evas_object_type_get(o)); \
289 #define ELM_GENGRID_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
290 ELM_GENGRID_DATA_GET(o, ptr); \
293 CRITICAL("No widget data for object %p (%s)", \
294 o, evas_object_type_get(o)); \
298 #define ELM_GENGRID_CHECK(obj) \
299 if (!obj || !elm_widget_type_check((obj), ELM_GENGRID_SMART_NAME, __func__)) \
302 #define ELM_GENGRID_ITEM_CHECK(it) \
303 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
304 ELM_GENGRID_CHECK(it->base.widget);
306 #define ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, ...) \
307 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
308 ELM_GENGRID_CHECK(it->base.widget) __VA_ARGS__;
310 #define ELM_GENGRID_ITEM_CHECK_OR_GOTO(it, label) \
311 ELM_WIDGET_ITEM_CHECK_OR_GOTO((Elm_Widget_Item *)it, label); \
312 if (!it->base.widget || !elm_widget_type_check \
313 ((it->base.widget), ELM_GENGRID_SMART_NAME, __func__)) goto label;