summaryrefslogtreecommitdiff
path: root/src/lib/evas/gesture/efl_gesture_recognizer_tap.c
diff options
context:
space:
mode:
authorsmohanty <smohantty@gmail.com>2017-09-25 15:25:42 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-10-19 10:33:12 +0900
commit5af499b01b6448cd669d35330e6981e8a87ed43c (patch)
tree8f53a080a9959a4811cb06eb5551804eac55b1e3 /src/lib/evas/gesture/efl_gesture_recognizer_tap.c
parente65f18ef3ec51e2a3e68ea913b5bdb15d4e5435d (diff)
evas/gesture: Added gesture and tap gesture implementation.
Diffstat (limited to '')
-rw-r--r--src/lib/evas/gesture/efl_gesture_recognizer_tap.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/lib/evas/gesture/efl_gesture_recognizer_tap.c b/src/lib/evas/gesture/efl_gesture_recognizer_tap.c
new file mode 100644
index 0000000000..e89106c5e5
--- /dev/null
+++ b/src/lib/evas/gesture/efl_gesture_recognizer_tap.c
@@ -0,0 +1,84 @@
1#include "efl_gesture_private.h"
2
3#define MY_CLASS EFL_GESTURE_RECOGNIZER_TAP_CLASS
4
5typedef struct _Efl_Gesture_Recognizer_Tap_Data
6{
7
8} Efl_Gesture_Recognizer_Tap_Data;
9
10EOLIAN static Efl_Object *
11_efl_gesture_recognizer_tap_efl_object_constructor(Eo *obj, Efl_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED)
12{
13 obj = efl_constructor(efl_super(obj, MY_CLASS));
14 return obj;
15}
16
17EOLIAN static void
18_efl_gesture_recognizer_tap_efl_object_destructor(Eo *obj EINA_UNUSED, Efl_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED)
19{
20 efl_destructor(efl_super(obj, MY_CLASS));
21}
22
23EOLIAN static Efl_Gesture *
24_efl_gesture_recognizer_tap_efl_gesture_recognizer_create(Eo *obj EINA_UNUSED, Efl_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED,
25 Efl_Object *target EINA_UNUSED)
26{
27 return efl_add(EFL_GESTURE_TAP_CLASS, NULL);
28}
29
30EOLIAN static Efl_Gesture_Recognizer_Result
31_efl_gesture_recognizer_tap_efl_gesture_recognizer_recognize(Eo *obj EINA_UNUSED,
32 Efl_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED,
33 Efl_Gesture *gesture, Efl_Object *watched EINA_UNUSED,
34 Efl_Gesture_Touch *event EINA_UNUSED)
35{
36 double dist_x, dist_y, length, x, y;
37 Efl_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;
38
39 switch (efl_gesture_touch_state_get(event))
40 {
41 case EFL_GESTURE_TOUCH_BEGIN:
42 {
43 efl_gesture_touch_start_point(event, &x, &y);
44 efl_gesture_tap_position_set(gesture, EINA_POSITION2D(x, y));
45 efl_gesture_hotspot_set(gesture, EINA_POSITION2D(x, y));
46 result = EFL_GESTURE_TRIGGER;
47 break;
48 }
49 case EFL_GESTURE_TOUCH_UPDATE:
50 case EFL_GESTURE_TOUCH_END:
51 {
52 if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
53 !efl_gesture_touch_multi_touch_get(event))
54 {
55 efl_gesture_touch_distance(event, 0, &dist_x, &dist_y);
56 length = abs(dist_x) + abs(dist_y);
57 if (length <= 50)
58 {
59 if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_END)
60 result = EFL_GESTURE_FINISH;
61 else
62 result = EFL_GESTURE_TRIGGER;
63 }
64 }
65 break;
66 }
67 default:
68 break;
69 }
70 return result;
71}
72
73EOLIAN static void
74_efl_gesture_recognizer_tap_efl_gesture_recognizer_reset(Eo *obj,
75 Efl_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED,
76 Efl_Gesture *gesture)
77{
78 Efl_Gesture_Tap_Data *tap;
79 tap = efl_data_scope_get(gesture, EFL_GESTURE_TAP_CLASS);
80 tap->pos = EINA_POSITION2D(0, 0);
81 efl_gesture_recognizer_reset(efl_super(obj, MY_CLASS), gesture);
82}
83
84#include "efl_gesture_recognizer_tap.eo.c" \ No newline at end of file