summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorWoochanlee <wc0917.lee@samsung.com>2019-05-14 16:37:20 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2019-05-14 16:37:20 +0900
commit54175998d538e0b2173fc023bb822f1e6536e58f (patch)
tree5c240f08eff5dddd9a2c6d7b4d1cdfaf948a86a1 /src/bin
parentf93eb3fc043fcc945fb2e65a27a05447ac8ce603 (diff)
Gesture Manager: Add gestures and fix gesture managing, recognizer logic.
Summary: https://phab.enlightenment.org/T7544 Provides a way for a user to get a gesture manager, recognizer instance. Supports different recognizer properties for each target(Eo). Gesture, Touch Class Life-cycle re-implementation. for supporting multiple touches. Add below gestures. efl_canvas_gesture_tap efl_canvas_gesture_double_tap efl_canvas_gesture_triple_tap efl_canvas_gesture_long_tap efl_canvas_gesture_momentum efl_canvas_gesture_zoom efl_canvas_gesture_flick Test Plan: Simple test -> test_gesture_framework.c More test cases will upload. Reviewers: woohyun, smohanty, segfaultxavi, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: Jaehyun_Cho, segfaultxavi, cedric Tags: #efl, #do_not_merge Differential Revision: https://phab.enlightenment.org/D7579
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/elementary/test_gesture_framework.c281
1 files changed, 254 insertions, 27 deletions
diff --git a/src/bin/elementary/test_gesture_framework.c b/src/bin/elementary/test_gesture_framework.c
index ada28bc50f..5e2e935e49 100644
--- a/src/bin/elementary/test_gesture_framework.c
+++ b/src/bin/elementary/test_gesture_framework.c
@@ -175,25 +175,19 @@ _color_and_icon_set(infra_data *infra, char *name, int n, int max,
175static void 175static void
176finger_tap_start(void *data , Efl_Canvas_Gesture *tap) 176finger_tap_start(void *data , Efl_Canvas_Gesture *tap)
177{ 177{
178 Eina_Vector2 pos = efl_gesture_hotspot_get(tap); 178 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
179 179
180 _color_and_icon_set(data, TAP_NAME, 1, MAX_TAP, START_COLOR); 180 _color_and_icon_set(data, TAP_NAME, 1, MAX_TAP, START_COLOR);
181 printf("Tap Gesture started x,y=<%f,%f> \n", pos.x, pos.y); 181 printf("Tap Gesture started x,y=<%d,%d> \n", pos.x, pos.y);
182}
183
184static void
185finger_tap_update(void *data , Efl_Canvas_Gesture *tap EINA_UNUSED)
186{
187 _color_and_icon_set(data, TAP_NAME, 1, MAX_TAP, UPDATE_COLOR);
188} 182}
189 183
190static void 184static void
191finger_tap_end(void *data , Efl_Canvas_Gesture *tap) 185finger_tap_end(void *data , Efl_Canvas_Gesture *tap)
192{ 186{
193 Eina_Vector2 pos = efl_gesture_hotspot_get(tap); 187 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
194 188
195 _color_and_icon_set(data, TAP_NAME, 1, MAX_TAP, END_COLOR); 189 _color_and_icon_set(data, TAP_NAME, 1, MAX_TAP, END_COLOR);
196 printf("Tap Gesture ended x,y=<%f,%f> \n", pos.x, pos.y); 190 printf("Tap Gesture ended x,y=<%d,%d> \n", pos.x, pos.y);
197} 191}
198 192
199static void 193static void
@@ -204,12 +198,147 @@ finger_tap_abort(void *data , Efl_Canvas_Gesture *tap EINA_UNUSED)
204} 198}
205 199
206static void 200static void
201finger_flick_start(void *data , Efl_Canvas_Gesture *tap)
202{
203 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
204
205 _color_and_icon_set(data, FLICK_NAME, 1, MAX_TAP, START_COLOR);
206 printf("Flick Gesture started x,y=<%d,%d> \n", pos.x, pos.y);
207}
208
209static void
210finger_flick_end(void *data , Efl_Canvas_Gesture *tap)
211{
212 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
213 double angle = efl_gesture_flick_angle_get(tap);
214
215 _color_and_icon_set(data, FLICK_NAME, 1, MAX_TAP, END_COLOR);
216 printf("Flick Gesture ended x,y=<%d,%d> angle=<%f>\n", pos.x, pos.y, angle);
217}
218
219static void
220finger_flick_abort(void *data , Efl_Canvas_Gesture *tap EINA_UNUSED)
221{
222 _color_and_icon_set(data, FLICK_NAME, 1, MAX_TAP, ABORT_COLOR);
223 printf("Flick Aborted\n");
224}
225
226static void
227finger_momentum_start(void *data , Efl_Canvas_Gesture *tap)
228{
229 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
230 unsigned int t = efl_gesture_timestamp_get(tap);
231
232 _color_and_icon_set(data, MOMENTUM_NAME, 1, MAX_TAP, START_COLOR);
233 printf("Momentum Gesture started x,y=<%d,%d> time=<%d>\n", pos.x, pos.y, t);
234}
235
236static void
237finger_momentum_update(void *data , Efl_Canvas_Gesture *tap EINA_UNUSED)
238{
239 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
240 Eina_Vector2 m = efl_gesture_momentum_get(tap);
241 unsigned int t = efl_gesture_timestamp_get(tap);
242
243 _color_and_icon_set(data, MOMENTUM_NAME, 1, MAX_TAP, UPDATE_COLOR);
244 printf("Momentum Gesture updated x,y=<%d,%d> momentum=<%f %f> time=<%d>\n",
245 pos.x, pos.y, m.x, m.y, t);
246}
247
248static void
249finger_momentum_end(void *data , Efl_Canvas_Gesture *tap)
250{
251 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
252 Eina_Vector2 m = efl_gesture_momentum_get(tap);
253 unsigned int t = efl_gesture_timestamp_get(tap);
254
255 _color_and_icon_set(data, MOMENTUM_NAME, 1, MAX_TAP, END_COLOR);
256 printf("Momentum Gesture ended x,y=<%d,%d> momentum=<%f %f> time=<%d>\n",
257 pos.x, pos.y, m.x, m.y, t);
258}
259
260static void
261finger_momentum_abort(void *data , Efl_Canvas_Gesture *tap EINA_UNUSED)
262{
263 _color_and_icon_set(data, MOMENTUM_NAME, 1, MAX_TAP, ABORT_COLOR);
264 printf("Momentum Aborted\n");
265}
266
267static void
268finger_triple_tap_start(void *data , Efl_Canvas_Gesture *tap)
269{
270 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
271
272 _color_and_icon_set(data, TRIPLE_TAP_NAME, 1, MAX_TAP, START_COLOR);
273 printf("Triple Tap Gesture started x,y=<%d,%d> \n", pos.x, pos.y);
274}
275
276static void
277finger_triple_tap_update(void *data , Efl_Canvas_Gesture *tap EINA_UNUSED)
278{
279 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
280
281 _color_and_icon_set(data, TRIPLE_TAP_NAME, 1, MAX_TAP, UPDATE_COLOR);
282 printf("Triple Tap Gesture updated x,y=<%d,%d> \n", pos.x, pos.y);
283}
284
285static void
286finger_triple_tap_end(void *data , Efl_Canvas_Gesture *tap)
287{
288 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
289
290 _color_and_icon_set(data, TRIPLE_TAP_NAME, 1, MAX_TAP, END_COLOR);
291 printf("Triple Tap Gesture ended x,y=<%d,%d> \n", pos.x, pos.y);
292}
293
294static void
295finger_triple_tap_abort(void *data , Efl_Canvas_Gesture *tap EINA_UNUSED)
296{
297 _color_and_icon_set(data, TRIPLE_TAP_NAME, 1, MAX_TAP, ABORT_COLOR);
298 printf("Triple Tap Aborted\n");
299}
300
301static void
302finger_double_tap_start(void *data , Efl_Canvas_Gesture *tap)
303{
304 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
305
306 _color_and_icon_set(data, DOUBLE_TAP_NAME, 1, MAX_TAP, START_COLOR);
307 printf("Double Tap Gesture started x,y=<%d,%d> \n", pos.x, pos.y);
308}
309
310static void
311finger_double_tap_update(void *data , Efl_Canvas_Gesture *tap EINA_UNUSED)
312{
313 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
314
315 _color_and_icon_set(data, DOUBLE_TAP_NAME, 1, MAX_TAP, UPDATE_COLOR);
316 printf("Double Tap Gesture updated x,y=<%d,%d> \n", pos.x, pos.y);
317}
318
319static void
320finger_double_tap_end(void *data , Efl_Canvas_Gesture *tap)
321{
322 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
323
324 _color_and_icon_set(data, DOUBLE_TAP_NAME, 1, MAX_TAP, END_COLOR);
325 printf("Double Tap Gesture ended x,y=<%d,%d> \n", pos.x, pos.y);
326}
327
328static void
329finger_double_tap_abort(void *data , Efl_Canvas_Gesture *tap EINA_UNUSED)
330{
331 _color_and_icon_set(data, DOUBLE_TAP_NAME, 1, MAX_TAP, ABORT_COLOR);
332 printf("Double Tap Aborted\n");
333}
334
335static void
207finger_long_tap_start(void *data , Efl_Canvas_Gesture *tap) 336finger_long_tap_start(void *data , Efl_Canvas_Gesture *tap)
208{ 337{
209 Eina_Vector2 pos = efl_gesture_hotspot_get(tap); 338 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
210 339
211 _color_and_icon_set(data, LONG_TAP_NAME, 1, MAX_TAP, START_COLOR); 340 _color_and_icon_set(data, LONG_TAP_NAME, 1, MAX_TAP, START_COLOR);
212 printf("Long Tap Gesture started x,y=<%f,%f> \n", pos.x, pos.y); 341 printf("Long Tap Gesture started x,y=<%d,%d> \n", pos.x, pos.y);
213} 342}
214 343
215static void 344static void
@@ -222,10 +351,10 @@ finger_long_tap_update(void *data , Efl_Canvas_Gesture *tap EINA_UNUSED)
222static void 351static void
223finger_long_tap_end(void *data , Efl_Canvas_Gesture *tap) 352finger_long_tap_end(void *data , Efl_Canvas_Gesture *tap)
224{ 353{
225 Eina_Vector2 pos = efl_gesture_hotspot_get(tap); 354 Eina_Position2D pos = efl_gesture_hotspot_get(tap);
226 355
227 _color_and_icon_set(data, LONG_TAP_NAME, 1, MAX_TAP, END_COLOR); 356 _color_and_icon_set(data, LONG_TAP_NAME, 1, MAX_TAP, END_COLOR);
228 printf("Long Tap Gesture ended x,y=<%f,%f> \n",pos.x, pos.y); 357 printf("Long Tap Gesture ended x,y=<%d,%d> \n",pos.x, pos.y);
229} 358}
230 359
231static void 360static void
@@ -244,9 +373,6 @@ tap_gesture_cb(void *data , const Efl_Event *ev)
244 case EFL_GESTURE_STARTED: 373 case EFL_GESTURE_STARTED:
245 finger_tap_start(data, g); 374 finger_tap_start(data, g);
246 break; 375 break;
247 case EFL_GESTURE_UPDATED:
248 finger_tap_update(data, g);
249 break;
250 case EFL_GESTURE_CANCELED: 376 case EFL_GESTURE_CANCELED:
251 finger_tap_abort(data, g); 377 finger_tap_abort(data, g);
252 break; 378 break;
@@ -259,6 +385,95 @@ tap_gesture_cb(void *data , const Efl_Event *ev)
259} 385}
260 386
261static void 387static void
388flick_gesture_cb(void *data , const Efl_Event *ev)
389{
390 Efl_Canvas_Gesture *g = ev->info;
391 switch(efl_gesture_state_get(g))
392 {
393 case EFL_GESTURE_STARTED:
394 finger_flick_start(data, g);
395 break;
396 case EFL_GESTURE_CANCELED:
397 finger_flick_abort(data, g);
398 break;
399 case EFL_GESTURE_FINISHED:
400 finger_flick_end(data, g);
401 break;
402 default:
403 break;
404 }
405}
406
407static void
408momentum_gesture_cb(void *data , const Efl_Event *ev)
409{
410 Efl_Canvas_Gesture *g = ev->info;
411 switch(efl_gesture_state_get(g))
412 {
413 case EFL_GESTURE_STARTED:
414 finger_momentum_start(data, g);
415 break;
416 case EFL_GESTURE_UPDATED:
417 finger_momentum_update(data, g);
418 break;
419 case EFL_GESTURE_CANCELED:
420 finger_momentum_abort(data, g);
421 break;
422 case EFL_GESTURE_FINISHED:
423 finger_momentum_end(data, g);
424 break;
425 default:
426 break;
427 }
428}
429
430static void
431triple_tap_gesture_cb(void *data , const Efl_Event *ev)
432{
433 Efl_Canvas_Gesture *g = ev->info;
434 switch(efl_gesture_state_get(g))
435 {
436 case EFL_GESTURE_STARTED:
437 finger_triple_tap_start(data, g);
438 break;
439 case EFL_GESTURE_UPDATED:
440 finger_triple_tap_update(data, g);
441 break;
442 case EFL_GESTURE_CANCELED:
443 finger_triple_tap_abort(data, g);
444 break;
445 case EFL_GESTURE_FINISHED:
446 finger_triple_tap_end(data, g);
447 break;
448 default:
449 break;
450 }
451}
452
453static void
454double_tap_gesture_cb(void *data , const Efl_Event *ev)
455{
456 Efl_Canvas_Gesture *g = ev->info;
457 switch(efl_gesture_state_get(g))
458 {
459 case EFL_GESTURE_STARTED:
460 finger_double_tap_start(data, g);
461 break;
462 case EFL_GESTURE_UPDATED:
463 finger_double_tap_update(data, g);
464 break;
465 case EFL_GESTURE_CANCELED:
466 finger_double_tap_abort(data, g);
467 break;
468 case EFL_GESTURE_FINISHED:
469 finger_double_tap_end(data, g);
470 break;
471 default:
472 break;
473 }
474}
475
476static void
262long_tap_gesture_cb(void *data , const Efl_Event *ev) 477long_tap_gesture_cb(void *data , const Efl_Event *ev)
263{ 478{
264 Efl_Canvas_Gesture *g = ev->info; 479 Efl_Canvas_Gesture *g = ev->info;
@@ -314,11 +529,22 @@ create_gesture_box(Evas_Object *win, icon_properties *icons,
314} 529}
315 530
316void 531void
532_tb_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
533{
534 int w,h;
535
536 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
537 evas_object_resize(data, w, h);
538 evas_object_color_set(data, 0, 0, 0, 0);
539 evas_object_show(data);
540}
541
542void
317test_gesture_framework(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, 543test_gesture_framework(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
318 void *event_info EINA_UNUSED) 544 void *event_info EINA_UNUSED)
319{ 545{
320 Evas_Object *win, *tb, *lb, *bx; 546 Evas_Object *win, *tb, *lb, *bx;
321 Evas_Object *r; /* Gesture layer transparent object */ 547 Evas_Object *r, *target; /* Gesture layer transparent object */
322 548
323 infra_data *infra = _infra_data_alloc(); 549 infra_data *infra = _infra_data_alloc();
324 550
@@ -336,6 +562,9 @@ test_gesture_framework(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
336 evas_object_show(tb); 562 evas_object_show(tb);
337 evas_object_show(bx); 563 evas_object_show(bx);
338 564
565 target = evas_object_rectangle_add(evas_object_evas_get(win));
566 evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _tb_resize, target);
567
339 /* Box of Tap icon and label */ 568 /* Box of Tap icon and label */
340 bx = create_gesture_box(win, infra->icons, 0, TAP_NAME, "Tap"); 569 bx = create_gesture_box(win, infra->icons, 0, TAP_NAME, "Tap");
341 elm_table_pack(tb, bx, 0, 0, 1, 1); 570 elm_table_pack(tb, bx, 0, 0, 1, 1);
@@ -458,15 +687,13 @@ test_gesture_framework(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
458 evas_object_show(lb); 687 evas_object_show(lb);
459 /* END - Building icons table */ 688 /* END - Building icons table */
460 689
461 r = evas_object_rectangle_add(evas_object_evas_get(win)); 690 // LISTEN FOR GESTURES
462 evas_object_move(r, 250, 300); 691 efl_event_callback_add(target, EFL_EVENT_GESTURE_TAP, tap_gesture_cb, infra);
463 evas_object_color_set(r, 0, 0, 255, 255); 692 efl_event_callback_add(target, EFL_EVENT_GESTURE_LONG_TAP, long_tap_gesture_cb, infra);
464 evas_object_resize(r, 70, 70); 693 efl_event_callback_add(target, EFL_EVENT_GESTURE_DOUBLE_TAP, double_tap_gesture_cb, infra);
465 evas_object_show(r); 694 efl_event_callback_add(target, EFL_EVENT_GESTURE_TRIPLE_TAP, triple_tap_gesture_cb, infra);
466 695 efl_event_callback_add(target, EFL_EVENT_GESTURE_MOMENTUM, momentum_gesture_cb, infra);
467 // LISTEN FOR TAP GESTURE 696 efl_event_callback_add(target, EFL_EVENT_GESTURE_FLICK, flick_gesture_cb, infra);
468 efl_event_callback_add(r, EFL_EVENT_GESTURE_TAP, tap_gesture_cb, infra);
469 efl_event_callback_add(r, EFL_EVENT_GESTURE_LONG_TAP, long_tap_gesture_cb, infra);
470 697
471 /* Update color state 20 times a second */ 698 /* Update color state 20 times a second */
472 infra->colortimer = ecore_timer_add(0.05, _icon_color_set_cb, infra->icons); 699 infra->colortimer = ecore_timer_add(0.05, _icon_color_set_cb, infra->icons);