summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-28 17:11:40 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-29 16:32:05 +0200
commit44a45e3acadb61235e5230d2ff38b967b99e7a39 (patch)
tree77fdbe4e9c19d92912f816daee7f2b701fe94d6f /src/lib
parenta61cef3fb208655bb98e2bc511c2abe2b9169587 (diff)
efl_ui_item: migrate to Efl.Ui.Clickable
this adds the mixin to the item. With this commit every class inheriting from Efl.Ui.Item will automatically emit all the clickable events. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es> Differential Revision: https://phab.enlightenment.org/D8830
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/elementary/efl_ui_item.c135
-rw-r--r--src/lib/elementary/efl_ui_item_private.h2
2 files changed, 20 insertions, 117 deletions
diff --git a/src/lib/elementary/efl_ui_item.c b/src/lib/elementary/efl_ui_item.c
index 7b9beab362..26911a3a73 100644
--- a/src/lib/elementary/efl_ui_item.c
+++ b/src/lib/elementary/efl_ui_item.c
@@ -167,134 +167,39 @@ _item_unselect(Eo *obj, Efl_Ui_Item_Data *pd)
167} 167}
168 168
169/* Mouse Controls */ 169/* Mouse Controls */
170static Eina_Bool
171_item_longpressed(void *data)
172{
173 Efl_Ui_Item *item = data;
174 EFL_UI_ITEM_DATA_GET_OR_RETURN(item, pd, ECORE_CALLBACK_CANCEL);
175
176 pd->longpress_timer = NULL;
177
178 efl_event_callback_call(item, EFL_INPUT_EVENT_LONGPRESSED, NULL);
179 return ECORE_CALLBACK_CANCEL;
180}
181
182static void 170static void
183_item_mouse_down(void *data, 171_item_pressed(void *data, const Efl_Event *ev EINA_UNUSED)
184 Evas *evas EINA_UNUSED,
185 Evas_Object *obj EINA_UNUSED,
186 void *event_info)
187{ 172{
188 Evas_Event_Mouse_Down *ev = event_info; 173 Efl_Ui_Item *obj = data;
189 Eo *item = data; 174 if (efl_ui_widget_disabled_get(obj)) return;
190 EFL_UI_ITEM_DATA_GET_OR_RETURN(item, pd);
191 ELM_WIDGET_DATA_GET_OR_RETURN(item, wd);
192 if (wd->disabled) return;
193 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
194
195 edje_object_signal_emit(wd->resize_obj, "efl,state,pressed", "efl");
196 175
197 pd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _item_longpressed, item); 176 efl_layout_signal_emit(obj, "efl,state,pressed", "efl");
198 efl_event_callback_call(item, EFL_INPUT_EVENT_PRESSED, NULL);
199} 177}
200 178
201static void 179static void
202_item_mouse_up(void *data, 180_item_unpressed(void *data, const Efl_Event *ev EINA_UNUSED)
203 Evas *evas EINA_UNUSED,
204 Evas_Object *obj EINA_UNUSED,
205 void *event_info)
206{ 181{
207 Evas_Event_Mouse_Up *ev = event_info; 182 Efl_Ui_Item *obj = data;
208 Eo *item = data;
209 Efl_Ui_Select_Mode m; 183 Efl_Ui_Select_Mode m;
184 EFL_UI_ITEM_DATA_GET_OR_RETURN(obj, pd);
210 185
211 if (!efl_ui_item_container_get(item)) 186 if (efl_ui_widget_disabled_get(obj)) return;
212 return; 187 if (!efl_ui_item_container_get(obj)) return;
213 EFL_UI_ITEM_DATA_GET_OR_RETURN(item, pd);
214 ELM_WIDGET_DATA_GET_OR_RETURN(item, wd);
215 if (wd->disabled) return;
216 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
217 {
218 //FIXME: should we send this message to fallback?
219 edje_object_signal_emit(wd->resize_obj, "efl,state,unpressed", "efl");
220 //efl_event_callback_call(item, EFL_INPUT_EVENT_UNPRESSED, NULL);
221 return;
222 }
223
224 if (pd->longpress_timer)
225 {
226 ecore_timer_del(pd->longpress_timer);
227 pd->longpress_timer = NULL;
228 }
229 188
230 edje_object_signal_emit(wd->resize_obj, "efl,state,unpressed", "efl"); 189 efl_layout_signal_emit(obj, "efl,state,unpressed", "efl");
231 efl_event_callback_call(item, EFL_INPUT_EVENT_UNPRESSED, NULL); 190 m = efl_ui_select_mode_get(efl_ui_item_container_get(obj));
232 191
233 m = efl_ui_select_mode_get(efl_ui_item_container_get(item));
234 if ((m != EFL_UI_SELECT_MODE_SINGLE_ALWAYS) && (pd->selected)) 192 if ((m != EFL_UI_SELECT_MODE_SINGLE_ALWAYS) && (pd->selected))
235 _item_unselect(item, pd); 193 _item_unselect(obj, pd);
236 else if (m != EFL_UI_SELECT_MODE_NONE) 194 else if (m != EFL_UI_SELECT_MODE_NONE)
237 _item_select(item, pd); 195 _item_select(obj, pd);
238} 196}
239 197
240static void 198EFL_CALLBACKS_ARRAY_DEFINE(self_listening,
241_item_mouse_move(void *data EINA_UNUSED, 199 {EFL_INPUT_EVENT_PRESSED, _item_pressed},
242 Evas *evas EINA_UNUSED, 200 {EFL_INPUT_EVENT_UNPRESSED, _item_unpressed},
243 Evas_Object *obj EINA_UNUSED, 201)
244 void *event_info)
245{
246 Evas_Event_Mouse_Move *ev = event_info;
247 Eo *item = data;
248 EFL_UI_ITEM_DATA_GET_OR_RETURN(item, pd);
249 ELM_WIDGET_DATA_GET_OR_RETURN(item, wd);
250 if (wd->disabled) return;
251 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
252 {
253 edje_object_signal_emit(wd->resize_obj, "efl,state,unpressed", "efl");
254 return;
255 }
256}
257 202
258static void
259_item_mouse_in(void *data EINA_UNUSED,
260 Evas *evas EINA_UNUSED,
261 Evas_Object *obj EINA_UNUSED,
262 void *event_info)
263{
264 Evas_Event_Mouse_In *ev = event_info;
265 Eo *item = data;
266 EFL_UI_ITEM_DATA_GET_OR_RETURN(item, pd);
267 ELM_WIDGET_DATA_GET_OR_RETURN(item, wd);
268 if (wd->disabled) return;
269
270 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
271}
272
273static void
274_item_mouse_callback_add(Eo *obj, void *data)
275{
276 evas_object_event_callback_add
277 (obj, EVAS_CALLBACK_MOUSE_DOWN, _item_mouse_down, data);
278 evas_object_event_callback_add
279 (obj, EVAS_CALLBACK_MOUSE_UP, _item_mouse_up, data);
280 evas_object_event_callback_add
281 (obj, EVAS_CALLBACK_MOUSE_MOVE, _item_mouse_move, data);
282 evas_object_event_callback_add
283 (obj, EVAS_CALLBACK_MOUSE_IN, _item_mouse_in, data);
284}
285
286static void
287_item_mouse_callback_del(Eo *obj, void *data)
288{
289 evas_object_event_callback_del_full
290 (obj, EVAS_CALLBACK_MOUSE_DOWN, _item_mouse_down, data);
291 evas_object_event_callback_del_full
292 (obj, EVAS_CALLBACK_MOUSE_UP, _item_mouse_up, data);
293 evas_object_event_callback_del_full
294 (obj, EVAS_CALLBACK_MOUSE_MOVE, _item_mouse_move, data);
295 evas_object_event_callback_del_full
296 (obj, EVAS_CALLBACK_MOUSE_IN, _item_mouse_in, data);
297}
298/* Mouse Controls ends */ 203/* Mouse Controls ends */
299 204
300static void 205static void
@@ -335,6 +240,8 @@ _efl_ui_item_efl_object_constructor(Eo *obj, Efl_Ui_Item_Data *pd EINA_UNUSED)
335{ 240{
336 obj = efl_constructor(efl_super(obj, MY_CLASS)); 241 obj = efl_constructor(efl_super(obj, MY_CLASS));
337 242
243 efl_event_callback_array_add(obj, self_listening(), obj);
244
338 return obj; 245 return obj;
339} 246}
340 247
@@ -348,7 +255,7 @@ _efl_ui_item_efl_object_finalize(Eo *obj, Efl_Ui_Item_Data *pd EINA_UNUSED)
348 /* Support Item Focus Feature */ 255 /* Support Item Focus Feature */
349 elm_widget_can_focus_set(obj, EINA_TRUE); 256 elm_widget_can_focus_set(obj, EINA_TRUE);
350 257
351 _item_mouse_callback_add(wd->resize_obj, eo); 258 efl_ui_clickable_util_bind_to_object(wd->resize_obj, obj);
352 return eo; 259 return eo;
353} 260}
354 261
@@ -357,7 +264,6 @@ _efl_ui_item_efl_object_destructor(Eo *obj, Efl_Ui_Item_Data *pd EINA_UNUSED)
357{ 264{
358 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 265 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
359 266
360 _item_mouse_callback_del(wd->resize_obj, obj);
361 efl_destructor(efl_super(obj, MY_CLASS)); 267 efl_destructor(efl_super(obj, MY_CLASS));
362} 268}
363 269
@@ -396,7 +302,6 @@ _efl_ui_item_container_get(const Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd)
396 return pd->parent; 302 return pd->parent;
397} 303}
398 304
399
400/* Internal EO APIs and hidden overrides */ 305/* Internal EO APIs and hidden overrides */
401 306
402#define EFL_UI_ITEM_EXTRA_OPS \ 307#define EFL_UI_ITEM_EXTRA_OPS \
diff --git a/src/lib/elementary/efl_ui_item_private.h b/src/lib/elementary/efl_ui_item_private.h
index bb09c2e509..e6babde8a3 100644
--- a/src/lib/elementary/efl_ui_item_private.h
+++ b/src/lib/elementary/efl_ui_item_private.h
@@ -8,8 +8,6 @@ typedef struct _Efl_Ui_Item_Data
8 // Eo Objects 8 // Eo Objects
9 Eo *parent; /* Parent Widget */ 9 Eo *parent; /* Parent Widget */
10 10
11 Ecore_Timer *longpress_timer; /* Timer for longpress handle */
12
13 // Boolean Data 11 // Boolean Data
14 Eina_Bool selected : 1; /* State for item selected */ 12 Eina_Bool selected : 1; /* State for item selected */
15 Eina_Bool needs_size_calc : 1; /* Flag for Size calculation */ 13 Eina_Bool needs_size_calc : 1; /* Flag for Size calculation */