summaryrefslogtreecommitdiff
path: root/src/lib/evas/gesture
diff options
context:
space:
mode:
authorsmohanty <smohantty@gmail.com>2017-09-21 10:23:18 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-10-19 10:33:12 +0900
commitd5f72053fd92a1df5fc85186d12fec83b7693f1a (patch)
tree7dc56790e7963387ddcb5bfb2be79082a5cd9483 /src/lib/evas/gesture
parentba3afc74a8b03b96c3ea43855b09362d32b47cd2 (diff)
evas/gesture: Added long_tap gesture to gesture framework
Diffstat (limited to 'src/lib/evas/gesture')
-rw-r--r--src/lib/evas/gesture/efl_gesture_long_tap.c40
-rw-r--r--src/lib/evas/gesture/efl_gesture_long_tap.eo26
-rw-r--r--src/lib/evas/gesture/efl_gesture_manager.c2
-rw-r--r--src/lib/evas/gesture/efl_gesture_private.h1
-rw-r--r--src/lib/evas/gesture/efl_gesture_recognizer_long_tap.c134
-rw-r--r--src/lib/evas/gesture/efl_gesture_recognizer_long_tap.eo10
6 files changed, 213 insertions, 0 deletions
diff --git a/src/lib/evas/gesture/efl_gesture_long_tap.c b/src/lib/evas/gesture/efl_gesture_long_tap.c
new file mode 100644
index 0000000..64f39a4
--- /dev/null
+++ b/src/lib/evas/gesture/efl_gesture_long_tap.c
@@ -0,0 +1,40 @@
1#include "efl_gesture_private.h"
2
3#define MY_CLASS EFL_GESTURE_LONG_TAP_CLASS
4
5
6EOLIAN static void
7_efl_gesture_long_tap_position_set(Eo *obj EINA_UNUSED, Efl_Gesture_Long_Tap_Data *pd,
8 Eina_Vector2 pos)
9{
10 pd->pos = pos;
11}
12
13EOLIAN static Eina_Vector2
14_efl_gesture_long_tap_position_get(Eo *obj EINA_UNUSED, Efl_Gesture_Long_Tap_Data *pd)
15{
16 return pd->pos;
17}
18
19EOLIAN static Efl_Object *
20_efl_gesture_long_tap_efl_object_constructor(Eo *obj, Efl_Gesture_Long_Tap_Data *pd EINA_UNUSED)
21{
22 Efl_Gesture_Data *gd;
23
24 obj = efl_constructor(efl_super(obj, MY_CLASS));
25 gd = efl_data_scope_get(obj, EFL_GESTURE_CLASS);
26 gd->type = EFL_EVENT_GESTURE_LONG_TAP;
27
28 return obj;
29}
30
31EOLIAN static void
32_efl_gesture_long_tap_efl_object_destructor(Eo *obj, Efl_Gesture_Long_Tap_Data *pd)
33{
34 if (pd->timeout)
35 ecore_timer_del(pd->timeout);
36
37 efl_destructor(efl_super(obj, MY_CLASS));
38}
39
40#include "efl_gesture_long_tap.eo.c" \ No newline at end of file
diff --git a/src/lib/evas/gesture/efl_gesture_long_tap.eo b/src/lib/evas/gesture/efl_gesture_long_tap.eo
new file mode 100644
index 0000000..e575199
--- /dev/null
+++ b/src/lib/evas/gesture/efl_gesture_long_tap.eo
@@ -0,0 +1,26 @@
1import efl_gesture_types;
2
3class Efl.Gesture.Long.Tap(Efl.Gesture)
4{
5 methods {
6 @property position {
7 [[This property holds the type of the gesture.]]
8 set {
9 }
10 get {
11 }
12 values {
13 pos: Eina.Vector2;[[position of the mouse event]]
14 }
15 }
16 }
17 event_prefix: efl;
18 events {
19 gesture_long_tap; [[Event for tap gesture]]
20 }
21
22 implements {
23 Efl.Object.constructor;
24 Efl.Object.destructor;
25 }
26} \ No newline at end of file
diff --git a/src/lib/evas/gesture/efl_gesture_manager.c b/src/lib/evas/gesture/efl_gesture_manager.c
index 5936ded..2b90db9 100644
--- a/src/lib/evas/gesture/efl_gesture_manager.c
+++ b/src/lib/evas/gesture/efl_gesture_manager.c
@@ -66,6 +66,8 @@ _efl_gesture_manager_efl_object_constructor(Eo *obj, Efl_Gesture_Manager_Data *p
66 pd->m_config = eina_hash_string_superfast_new(EINA_FREE_CB(eina_value_free)); 66 pd->m_config = eina_hash_string_superfast_new(EINA_FREE_CB(eina_value_free));
67 67
68 efl_gesture_manager_recognizer_register(obj, efl_add(EFL_GESTURE_RECOGNIZER_TAP_CLASS, obj)); 68 efl_gesture_manager_recognizer_register(obj, efl_add(EFL_GESTURE_RECOGNIZER_TAP_CLASS, obj));
69 efl_gesture_manager_recognizer_register(obj, efl_add(EFL_GESTURE_RECOGNIZER_LONG_TAP_CLASS, obj));
70
69 return obj; 71 return obj;
70} 72}
71 73
diff --git a/src/lib/evas/gesture/efl_gesture_private.h b/src/lib/evas/gesture/efl_gesture_private.h
index 4a4468a..e00faf6 100644
--- a/src/lib/evas/gesture/efl_gesture_private.h
+++ b/src/lib/evas/gesture/efl_gesture_private.h
@@ -10,6 +10,7 @@
10 10
11//private gesture classes 11//private gesture classes
12#include "efl_gesture_recognizer_tap.eo.h" 12#include "efl_gesture_recognizer_tap.eo.h"
13#include "efl_gesture_recognizer_long_tap.eo.h"
13 14
14typedef struct _Efl_Gesture_Recognizer_Data Efl_Gesture_Recognizer_Data; 15typedef struct _Efl_Gesture_Recognizer_Data Efl_Gesture_Recognizer_Data;
15typedef struct _Efl_Gesture_Data Efl_Gesture_Data; 16typedef struct _Efl_Gesture_Data Efl_Gesture_Data;
diff --git a/src/lib/evas/gesture/efl_gesture_recognizer_long_tap.c b/src/lib/evas/gesture/efl_gesture_recognizer_long_tap.c
new file mode 100644
index 0000000..2ba7cd8
--- /dev/null
+++ b/src/lib/evas/gesture/efl_gesture_recognizer_long_tap.c
@@ -0,0 +1,134 @@
1#include "efl_gesture_private.h"
2
3#define MY_CLASS EFL_GESTURE_RECOGNIZER_LONG_TAP_CLASS
4
5#define LONG_TAP_TIME_OUT 0.2
6
7typedef struct _Efl_Gesture_Recognizer_Long_Tap_Data
8{
9
10} Efl_Gesture_Recognizer_Long_Tap_Data;
11
12EOLIAN static Efl_Object *
13_efl_gesture_recognizer_long_tap_efl_object_constructor(Eo *obj, Efl_Gesture_Recognizer_Long_Tap_Data *pd EINA_UNUSED)
14{
15 obj = efl_constructor(efl_super(obj, MY_CLASS));
16 return obj;
17}
18
19EOLIAN static void
20_efl_gesture_recognizer_long_tap_efl_object_destructor(Eo *obj EINA_UNUSED, Efl_Gesture_Recognizer_Long_Tap_Data *pd EINA_UNUSED)
21{
22 efl_destructor(efl_super(obj, MY_CLASS));
23}
24
25EOLIAN static Efl_Gesture *
26_efl_gesture_recognizer_long_tap_efl_gesture_recognizer_create(Eo *obj, Efl_Gesture_Recognizer_Long_Tap_Data *pd EINA_UNUSED,
27 Efl_Object *target EINA_UNUSED)
28{
29 return efl_add(EFL_GESTURE_LONG_TAP_CLASS, obj);
30}
31
32static Eina_Bool
33_long_tap_timeout_cb(void *data)
34{
35 Efl_Gesture_Long_Tap_Data *ltp = data;
36
37 ltp->is_timeout = EINA_TRUE;
38 return ECORE_CALLBACK_RENEW;
39}
40
41EOLIAN static Efl_Gesture_Recognizer_Result
42_efl_gesture_recognizer_long_tap_efl_gesture_recognizer_recognize(Eo *obj EINA_UNUSED,
43 Efl_Gesture_Recognizer_Long_Tap_Data *pd EINA_UNUSED,
44 Efl_Gesture *gesture, Efl_Object *watched EINA_UNUSED,
45 Efl_Gesture_Touch *event)
46{
47 double dist_x, dist_y, length, x, y;
48 Eina_Vector2 pos;
49 Efl_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;
50 Efl_Gesture_Long_Tap_Data *ltp = efl_data_scope_get(gesture, EFL_GESTURE_LONG_TAP_CLASS);
51
52 switch (efl_gesture_touch_state_get(event))
53 {
54 case EFL_GESTURE_TOUCH_BEGIN:
55 {
56 efl_gesture_touch_start_point(event, &x, &y);
57 eina_vector2_set(&pos, x, y);
58 efl_gesture_long_tap_position_set(gesture, pos);
59 efl_gesture_hotspot_set(gesture, pos);
60 if (ltp->timeout)
61 ecore_timer_del(ltp->timeout);
62 ltp->timeout = ecore_timer_add(LONG_TAP_TIME_OUT,
63 _long_tap_timeout_cb, ltp);
64 result = EFL_GESTURE_MAYBE;
65 break;
66 }
67 case EFL_GESTURE_TOUCH_UPDATE:
68 {
69 if (!efl_gesture_touch_multi_touch_get(event))
70 {
71 efl_gesture_touch_distance(event, 0, &dist_x, &dist_y);
72 length = abs(dist_x) + abs(dist_y);
73 if (length <= 50)
74 {
75 if (ltp->is_timeout)
76 {
77 ltp->is_timeout = EINA_FALSE;
78 result = EFL_GESTURE_TRIGGER;
79 }
80 else
81 {
82 result = EFL_GESTURE_MAYBE;
83 }
84 }
85 else
86 {
87 result = EFL_GESTURE_CANCEL;
88 }
89 }
90 break;
91 }
92 case EFL_GESTURE_TOUCH_END:
93 {
94 if (ltp->timeout)
95 ecore_timer_del(ltp->timeout);
96 ltp->timeout = NULL;
97 if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
98 !efl_gesture_touch_multi_touch_get(event))
99 {
100 efl_gesture_touch_distance(event, 0, &dist_x, &dist_y);
101 length = abs(dist_x) + abs(dist_y);
102 if (length <= 50 && ltp->is_timeout)
103 {
104 result = EFL_GESTURE_FINISH;
105 }
106 else
107 {
108 result = EFL_GESTURE_CANCEL;
109 }
110 }
111 break;
112 }
113 default:
114 break;
115 }
116 return result;
117}
118
119EOLIAN static void
120_efl_gesture_recognizer_long_tap_efl_gesture_recognizer_reset(Eo *obj,
121 Efl_Gesture_Recognizer_Long_Tap_Data *pd EINA_UNUSED,
122 Efl_Gesture *gesture)
123{
124 Efl_Gesture_Long_Tap_Data *ltp;
125 ltp = efl_data_scope_get(gesture, EFL_GESTURE_LONG_TAP_CLASS);
126 eina_vector2_set(&ltp->pos, 0, 0);
127 if (ltp->timeout)
128 ecore_timer_del(ltp->timeout);
129 ltp->timeout = NULL;
130 ltp->is_timeout = EINA_FALSE;
131 efl_gesture_recognizer_reset(efl_super(obj, MY_CLASS), gesture);
132}
133
134#include "efl_gesture_recognizer_long_tap.eo.c" \ No newline at end of file
diff --git a/src/lib/evas/gesture/efl_gesture_recognizer_long_tap.eo b/src/lib/evas/gesture/efl_gesture_recognizer_long_tap.eo
new file mode 100644
index 0000000..b54a47b
--- /dev/null
+++ b/src/lib/evas/gesture/efl_gesture_recognizer_long_tap.eo
@@ -0,0 +1,10 @@
1class Efl.Gesture.Recognizer.Long.Tap(Efl.Gesture.Recognizer)
2{
3 implements {
4 Efl.Object.constructor;
5 Efl.Object.destructor;
6 Efl.Gesture.Recognizer.create;
7 Efl.Gesture.Recognizer.recognize;
8 Efl.Gesture.Recognizer.reset;
9 }
10} \ No newline at end of file