summaryrefslogtreecommitdiff
path: root/src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.c
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/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.c
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/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.c')
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.c191
1 files changed, 191 insertions, 0 deletions
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.c
new file mode 100644
index 0000000..cd54d45
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.c
@@ -0,0 +1,191 @@
1#include "efl_canvas_gesture_private.h"
2
3#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_TRIPLE_TAP_CLASS
4
5#define TAP_TIME_OUT 0.33
6
7EOLIAN static Efl_Canvas_Gesture *
8_efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_add(Eo *obj, Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *pd EINA_UNUSED, Efl_Object *target EINA_UNUSED)
9{
10 return efl_add(EFL_CANVAS_GESTURE_TRIPLE_TAP_CLASS, obj);
11}
12
13EOLIAN static void
14_efl_canvas_gesture_recognizer_triple_tap_efl_object_destructor(Eo *obj,
15 Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *pd)
16{
17 if (pd->timeout)
18 ecore_timer_del(pd->timeout);
19
20 efl_destructor(efl_super(obj, MY_CLASS));
21}
22
23static Eina_Bool
24_tap_timeout_cb(void *data)
25{
26 Efl_Canvas_Gesture_Recognizer_Data *rd;
27 Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *pd;
28
29 rd = efl_data_scope_get(data, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
30 pd = efl_data_scope_get(data, EFL_CANVAS_GESTURE_RECOGNIZER_TRIPLE_TAP_CLASS);
31
32 efl_gesture_state_set(pd->gesture, EFL_GESTURE_CANCELED);
33 efl_event_callback_call(pd->target, EFL_EVENT_GESTURE_TRIPLE_TAP, pd->gesture);
34
35 efl_gesture_manager_gesture_clean_up(rd->manager, pd->target, EFL_EVENT_GESTURE_TRIPLE_TAP);
36
37 pd->timeout = NULL;
38 pd->tap_count = 0;
39
40 return ECORE_CALLBACK_CANCEL;
41}
42
43EOLIAN static Efl_Canvas_Gesture_Recognizer_Result
44_efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recognize(Eo *obj,
45 Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *pd,
46 Efl_Canvas_Gesture *gesture, Efl_Object *watched,
47 Efl_Canvas_Gesture_Touch *event)
48{
49 double length;
50 double timeout = TAP_TIME_OUT;
51 Eina_Position2D pos;
52 Eina_Vector2 dist;
53 Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;
54 Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
55
56 pd->target = watched;
57 pd->gesture = gesture;
58
59 if (!pd->start_timeout)
60 {
61 double time;
62 Eina_Value *val = efl_gesture_recognizer_config_get(obj, "glayer_doublee_tap_timeout");
63
64 if (val)
65 {
66 eina_value_get(val, &time);
67 pd->start_timeout = timeout = time;
68 }
69 }
70 else
71 timeout = pd->start_timeout;
72
73 switch (efl_gesture_touch_state_get(event))
74 {
75 case EFL_GESTURE_TOUCH_BEGIN:
76 {
77 pos = efl_gesture_touch_start_point_get(event);
78 efl_gesture_hotspot_set(gesture, pos);
79
80 if (pd->timeout)
81 ecore_timer_reset(pd->timeout);
82 else
83 pd->timeout = ecore_timer_add(timeout, _tap_timeout_cb, obj);
84
85 result = EFL_GESTURE_TRIGGER;
86
87 break;
88 }
89
90 case EFL_GESTURE_TOUCH_UPDATE:
91 {
92 result = EFL_GESTURE_IGNORE;
93
94 if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
95 !efl_gesture_touch_multi_touch_get(event))
96 {
97 dist = efl_gesture_touch_distance(event, 0);
98 length = fabs(dist.x) + fabs(dist.y);
99
100 if (length > rd->finger_size)
101 {
102 if (pd->timeout)
103 {
104 ecore_timer_del(pd->timeout);
105 pd->timeout = NULL;
106 }
107
108 result = EFL_GESTURE_CANCEL;
109
110 pd->tap_count = 0;
111 }
112 }
113
114 break;
115 }
116 case EFL_GESTURE_TOUCH_END:
117 {
118
119 if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
120 !efl_gesture_touch_multi_touch_get(event))
121 {
122 dist = efl_gesture_touch_distance(event, 0);
123 length = fabs(dist.x) + fabs(dist.y);
124
125 if (length <= rd->finger_size)
126 {
127 pd->tap_count++;
128 if (pd->tap_count < 3)
129 {
130 if (pd->timeout)
131 ecore_timer_reset(pd->timeout);
132
133 result = EFL_GESTURE_TRIGGER;
134 }
135 else
136 {
137 if (pd->timeout)
138 {
139 ecore_timer_del(pd->timeout);
140 pd->timeout = NULL;
141 }
142
143 if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_END)
144 result = EFL_GESTURE_FINISH;
145 else
146 result = EFL_GESTURE_TRIGGER;
147
148 pd->tap_count = 0;
149 }
150 }
151 else
152 {
153 if (pd->timeout)
154 {
155 ecore_timer_del(pd->timeout);
156 pd->timeout = NULL;
157 }
158
159 result = EFL_GESTURE_CANCEL;
160
161 pd->tap_count = 0;
162 }
163 }
164
165 break;
166 }
167
168 default:
169
170 break;
171 }
172
173 return result;
174}
175
176EOLIAN static double
177_efl_canvas_gesture_recognizer_triple_tap_timeout_get(const Eo *obj EINA_UNUSED,
178 Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *pd)
179{
180 return pd->start_timeout;
181}
182
183EOLIAN static void
184_efl_canvas_gesture_recognizer_triple_tap_timeout_set(Eo *obj EINA_UNUSED,
185 Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *pd,
186 double time)
187{
188 pd->start_timeout = time;
189}
190
191#include "efl_canvas_gesture_recognizer_triple_tap.eo.c"