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"
12 * @section elm-gengrid-class The Elementary Gengrid Class
14 * Elementary, besides having the @ref Gengrid widget, exposes its
15 * foundation -- the Elementary Gengrid Class -- in order to create
16 * other widgets which are a gengrid with some more logic on top.
20 * @def ELM_GENGRID_CLASS
22 * Use this macro to cast whichever subclass of
23 * #Elm_Gengrid_Smart_Class into it, so to access its fields.
27 #define ELM_GENGRID_CLASS(x) ((Elm_Gengrid_Smart_Class *)x)
30 * @def ELM_GENGRID_DATA
32 * Use this macro to cast whichever subdata of
33 * #Elm_Gengrid_Smart_Data into it, so to access its fields.
37 #define ELM_GENGRID_DATA(x) ((Elm_Gengrid_Smart_Data *)x)
40 * @def ELM_GENGRID_SMART_CLASS_VERSION
42 * Current version for Elementary gengrid @b base smart class, a value
43 * which goes to _Elm_Gengrid_Smart_Class::version.
47 #define ELM_GENGRID_SMART_CLASS_VERSION 1
50 * @def ELM_GENGRID_SMART_CLASS_INIT
52 * Initializer for a whole #Elm_Gengrid_Smart_Class structure, with
53 * @c NULL values on its specific fields.
55 * @param smart_class_init initializer to use for the "base" field
56 * (#Evas_Smart_Class).
58 * @see EVAS_SMART_CLASS_INIT_NULL
59 * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
60 * @see ELM_GENGRID_SMART_CLASS_INIT_NULL
61 * @see ELM_GENGRID_SMART_CLASS_INIT_NAME_VERSION
65 #define ELM_GENGRID_SMART_CLASS_INIT(smart_class_init) \
66 {smart_class_init, ELM_GENGRID_SMART_CLASS_VERSION}
69 * @def ELM_GENGRID_SMART_CLASS_INIT_NULL
71 * Initializer to zero out a whole #Elm_Gengrid_Smart_Class structure.
73 * @see ELM_GENGRID_SMART_CLASS_INIT_NAME_VERSION
74 * @see ELM_GENGRID_SMART_CLASS_INIT
78 #define ELM_GENGRID_SMART_CLASS_INIT_NULL \
79 ELM_GENGRID_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
82 * @def ELM_GENGRID_SMART_CLASS_INIT_NAME_VERSION
84 * Initializer to zero out a whole #Elm_Gengrid_Smart_Class structure and
85 * set its name and version.
87 * This is similar to #ELM_GENGRID_SMART_CLASS_INIT_NULL, but it will
88 * also set the version field of #Elm_Gengrid_Smart_Class (base field)
89 * to the latest #ELM_GENGRID_SMART_CLASS_VERSION and name it to the
92 * It will keep a reference to the name field as a <c>"const char *"</c>,
93 * i.e., the name must be available while the structure is
94 * used (hint: static or global variable!) and must not be modified.
96 * @see ELM_GENGRID_SMART_CLASS_INIT_NULL
97 * @see ELM_GENGRID_SMART_CLASS_INIT
101 #define ELM_GENGRID_SMART_CLASS_INIT_NAME_VERSION(name) \
102 ELM_GENGRID_SMART_CLASS_INIT \
103 (ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
106 * Elementary gengrid base smart class. This inherits directly from
107 * #Elm_Layout_Smart_Class and is meant to build widgets extending the
108 * behavior of a gengrid.
110 * All of the functions listed on @ref Gengrid namespace will work for
111 * objects deriving from #Elm_Gengrid_Smart_Class.
113 typedef struct _Elm_Gengrid_Smart_Class
115 Elm_Layout_Smart_Class base;
117 int version; /**< Version of this smart class definition */
118 } Elm_Gengrid_Smart_Class;
121 * Base widget smart data extended with gengrid instance data.
123 typedef struct _Elm_Gengrid_Smart_Data Elm_Gengrid_Smart_Data;
124 struct _Elm_Gengrid_Smart_Data
126 Elm_Layout_Smart_Data base; /* base widget smart data as
127 * first member obligatory, as
128 * we're inheriting from it */
130 const Elm_Scrollable_Smart_Interface *s_iface;
132 Eina_Inlist_Sorted_State *state;
133 Evas_Object *hit_rect;
134 Evas_Object *pan_obj;
136 Eina_List *selected; /* a list of
139 Eina_List *group_items; /* a list of
142 Eina_Inlist *items; /* an inlist of all items */
143 Elm_Gen_Item *reorder_it; /* item currently
146 Elm_Object_Item *last_selected_item;
147 Elm_Gen_Item *show_it;
148 Elm_Gen_Item *bring_in_it;
152 int item_width, item_height;
153 int group_item_width, group_item_height;
155 unsigned int item_count;
156 Evas_Coord pan_x, pan_y;
157 Elm_Object_Select_Mode select_mode;
162 /* longpress timeout. this value comes from _elm_config by
163 * default. this can be changed by
164 * elm_gengrid_longpress_timeout_set() */
165 double longpress_timeout;
167 /* a generation of gengrid. when gengrid is cleared, this value
168 * will be increased and a new generation will start */
170 Eina_Compare_Cb item_compare_cb;
172 /* The stuff below directly come from gengrid without any thinking */
174 Evas_Coord reorder_item_x, reorder_item_y;
175 Evas_Coord old_pan_x, old_pan_y;
177 double align_x, align_y;
179 Eina_Bool reorder_item_changed : 1;
180 Eina_Bool move_effect_enabled : 1;
182 Eina_Bool old_h_bounce;
183 Eina_Bool old_v_bounce;
185 /* a flag for reorder mode enable/disable */
186 Eina_Bool reorder_mode : 1;
187 Eina_Bool was_selected : 1;
189 Eina_Bool longpressed : 1;
190 Eina_Bool pan_changed : 1;
191 Eina_Bool horizontal : 1;
193 /* a flag for items can be highlighted or not. by default this flag
195 Eina_Bool highlight : 1;
197 Eina_Bool clear_me : 1; /**< a flag whether
199 * as to be cleared or
205 Eina_Bool on_hold : 1;
207 Eina_Bool filled : 1;
208 Eina_Bool multi : 1; /* a flag for item
211 Eina_Bool show_region : 1;
212 Eina_Bool bring_in : 1;
215 struct Elm_Gen_Item_Type
219 Elm_Gengrid_Smart_Data *wsd;
221 Ecore_Animator *item_reorder_move_animator;
222 Evas_Coord gx, gy, ox, oy, tx, ty, rx, ry;
223 unsigned int moving_effect_start_time;
226 Eina_Bool group_realized : 1;
227 Eina_Bool moving : 1;
230 typedef struct _Elm_Gengrid_Pan_Smart_Class
232 Elm_Pan_Smart_Class base;
233 } Elm_Gengrid_Pan_Smart_Class;
235 typedef struct _Elm_Gengrid_Pan_Smart_Data Elm_Gengrid_Pan_Smart_Data;
236 struct _Elm_Gengrid_Pan_Smart_Data
238 Elm_Pan_Smart_Data base;
239 Elm_Gengrid_Smart_Data *wsd;
240 Ecore_Job *resize_job;
247 EAPI extern const char ELM_GENGRID_SMART_NAME[];
248 EAPI const Elm_Gengrid_Smart_Class *elm_gengrid_smart_class_get(void);
250 #define ELM_GENGRID_DATA_GET(o, sd) \
251 Elm_Gengrid_Smart_Data * sd = evas_object_smart_data_get(o)
253 #define ELM_GENGRID_PAN_DATA_GET(o, sd) \
254 Elm_Gengrid_Pan_Smart_Data * sd = evas_object_smart_data_get(o)
256 #define ELM_GENGRID_DATA_GET_OR_RETURN(o, ptr) \
257 ELM_GENGRID_DATA_GET(o, ptr); \
260 CRITICAL("No widget data for object %p (%s)", \
261 o, evas_object_type_get(o)); \
265 #define ELM_GENGRID_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
266 ELM_GENGRID_DATA_GET(o, ptr); \
269 CRITICAL("No widget data for object %p (%s)", \
270 o, evas_object_type_get(o)); \
274 #define ELM_GENGRID_CHECK(obj) \
275 if (!obj || !elm_widget_type_check((obj), ELM_GENGRID_SMART_NAME, __func__)) \
278 #define ELM_GENGRID_ITEM_CHECK(it) \
279 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
280 ELM_GENGRID_CHECK(it->base.widget);
282 #define ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, ...) \
283 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
284 ELM_GENGRID_CHECK(it->base.widget) __VA_ARGS__;
286 #define ELM_GENGRID_ITEM_CHECK_OR_GOTO(it, label) \
287 ELM_WIDGET_ITEM_CHECK_OR_GOTO((Elm_Widget_Item *)it, label); \
288 if (!it->base.widget || !elm_widget_type_check \
289 ((it->base.widget), ELM_GENGRID_SMART_NAME, __func__)) goto label;