summaryrefslogtreecommitdiff
path: root/src/lib/evas/gesture
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
parente65f18ef3ec51e2a3e68ea913b5bdb15d4e5435d (diff)
evas/gesture: Added gesture and tap gesture implementation.
Diffstat (limited to 'src/lib/evas/gesture')
-rw-r--r--src/lib/evas/gesture/efl_gesture.c36
-rw-r--r--src/lib/evas/gesture/efl_gesture_recognizer_tap.c84
-rw-r--r--src/lib/evas/gesture/efl_gesture_tap.c31
3 files changed, 151 insertions, 0 deletions
diff --git a/src/lib/evas/gesture/efl_gesture.c b/src/lib/evas/gesture/efl_gesture.c
new file mode 100644
index 0000000..1ea9993
--- /dev/null
+++ b/src/lib/evas/gesture/efl_gesture.c
@@ -0,0 +1,36 @@
1#include "efl_gesture_private.h"
2
3#define MY_CLASS EFL_GESTURE_CLASS
4
5EOLIAN static const Efl_Event_Description *
6 _efl_gesture_type_get(Eo *obj EINA_UNUSED, Efl_Gesture_Data *pd)
7{
8 return pd->type;
9}
10
11EOLIAN static Efl_Gesture_State
12_efl_gesture_state_get(Eo *obj EINA_UNUSED, Efl_Gesture_Data *pd)
13{
14 return pd->state;
15}
16
17EOLIAN static void
18_efl_gesture_state_set(Eo *obj EINA_UNUSED, Efl_Gesture_Data *pd, Efl_Gesture_State state)
19{
20 pd->state = state;
21}
22
23EOLIAN static void
24_efl_gesture_hotspot_set(Eo *obj EINA_UNUSED, Efl_Gesture_Data *pd, Eina_Vector2 hotspot)
25{
26 pd->hotspot = hotspot;
27}
28
29
30EOLIAN static Eina_Vector2
31_efl_gesture_hotspot_get(Eo *obj EINA_UNUSED, Efl_Gesture_Data *pd)
32{
33 return pd->hotspot;
34}
35
36#include "efl_gesture.eo.c" \ No newline at end of file
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 0000000..e89106c
--- /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
diff --git a/src/lib/evas/gesture/efl_gesture_tap.c b/src/lib/evas/gesture/efl_gesture_tap.c
new file mode 100644
index 0000000..50dbcf3
--- /dev/null
+++ b/src/lib/evas/gesture/efl_gesture_tap.c
@@ -0,0 +1,31 @@
1#include "efl_gesture_private.h"
2
3#define MY_CLASS EFL_GESTURE_TAP_CLASS
4
5
6EOLIAN static void
7_efl_gesture_tap_position_set(Eo *obj EINA_UNUSED, Efl_Gesture_Tap_Data *pd, Eina_Vector2 pos)
8{
9 pd->pos = pos;
10}
11
12EOLIAN static Eina_Vector2
13_efl_gesture_tap_position_get(Eo *obj EINA_UNUSED, Efl_Gesture_Tap_Data *pd)
14{
15 return pd->pos;
16}
17
18EOLIAN static Efl_Object *
19_efl_gesture_tap_efl_object_constructor(Eo *obj, Efl_Gesture_Tap_Data *pd EINA_UNUSED)
20{
21 Efl_Gesture_Data *gd;
22
23 obj = efl_constructor(efl_super(obj, MY_CLASS));
24
25 gd = efl_data_scope_get(obj, EFL_GESTURE_CLASS);
26 gd->type = EFL_EVENT_GESTURE_TAP;
27
28 return obj;
29}
30
31#include "efl_gesture_tap.eo.c" \ No newline at end of file