summaryrefslogtreecommitdiff
path: root/src/lib/evas/gesture
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/evas/gesture')
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture.c25
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture.eo19
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_custom.c25
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_custom.eo31
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_double_tap.c13
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_double_tap.eo7
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_events.eo (renamed from src/lib/evas/gesture/efl_gesture_events.eo)29
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_flick.c17
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_flick.eo27
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_long_press.c5
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_long_press.eo11
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_long_tap.c23
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_long_tap.eo13
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_manager.c592
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_manager.eo27
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_momentum.c15
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_momentum.eo17
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_private.h113
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer.c139
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer.eo37
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_custom.c37
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_custom.eo28
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_double_tap.c185
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_double_tap.eo14
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.c325
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.eo2
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_press.c143
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_press.eo13
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_tap.c176
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_tap.eo26
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.c287
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.eo2
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_rotate.c269
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_rotate.eo12
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_tap.c112
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_tap.eo2
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.c184
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.eo14
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.c263
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.eo2
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_rotate.c17
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_rotate.eo28
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_tap.c13
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_tap.eo7
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_touch.c116
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_touch.eo36
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_triple_tap.c13
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_triple_tap.eo7
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_types.eot56
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_zoom.c22
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_zoom.eo28
-rw-r--r--src/lib/evas/gesture/meson.build20
52 files changed, 2118 insertions, 1526 deletions
diff --git a/src/lib/evas/gesture/efl_canvas_gesture.c b/src/lib/evas/gesture/efl_canvas_gesture.c
index 0cc7f8d423..e1fbe7824c 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture.c
@@ -1,15 +1,8 @@
+#define EFL_CANVAS_GESTURE_PROTECTED
#include "efl_canvas_gesture_private.h"
#define MY_CLASS EFL_CANVAS_GESTURE_CLASS
-const Efl_Event_Description *
-_efl_gesture_type_get(const Eo *obj)
-{
- Efl_Canvas_Gesture_Data *pd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_CLASS);
-
- return pd->type;
-}
-
EOLIAN static Efl_Canvas_Gesture_State
_efl_canvas_gesture_state_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Data *pd)
{
@@ -28,7 +21,6 @@ _efl_canvas_gesture_hotspot_set(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Data *pd
pd->hotspot = hotspot;
}
-
EOLIAN static Eina_Position2D
_efl_canvas_gesture_hotspot_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Data *pd)
{
@@ -41,12 +33,23 @@ _efl_canvas_gesture_timestamp_set(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Data *
pd->timestamp = timestamp;
}
-
EOLIAN static unsigned int
_efl_canvas_gesture_timestamp_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Data *pd)
{
return pd->timestamp;
}
+EOLIAN static void
+_efl_canvas_gesture_touch_count_set(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Data *pd, unsigned int touch_count)
+{
+ pd->touch_count = touch_count;
+}
+
+EOLIAN static unsigned int
+_efl_canvas_gesture_touch_count_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Data *pd)
+{
+ return pd->touch_count;
+}
+
#include "efl_canvas_gesture.eo.c"
-#include "efl_gesture_events.eo.c"
+#include "efl_canvas_gesture_events.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture.eo b/src/lib/evas/gesture/efl_canvas_gesture.eo
index eaced25ad8..9166f71ca2 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture.eo
@@ -1,5 +1,5 @@
import efl_canvas_gesture_types;
-parse efl_gesture_events;
+parse efl_canvas_gesture_events;
abstract @beta Efl.Canvas.Gesture extends Efl.Object
{
@@ -11,7 +11,7 @@ abstract @beta Efl.Canvas.Gesture extends Efl.Object
Typically this class is not used directly, instead, some sub-class of it (like
@Efl.Canvas.Gesture_Tap or @Efl.Canvas.Gesture_Zoom) is retrieved from gesture events
- (like @[Efl.Gesture.Events.gesture,tap] or @[Efl.Gesture.Events.gesture,zoom]).
+ (like @[Efl.Canvas.Gesture_Events.gesture,tap] or @[Efl.Canvas.Gesture_Events.gesture,zoom]).
]]
c_prefix: efl_gesture;
methods {
@@ -27,7 +27,8 @@ abstract @beta Efl.Canvas.Gesture extends Efl.Object
}
@property hotspot {
[[Hotspot of the gesture currently being analyzed.
- The exact meaning depends on the gesture type.]]
+ The exact meaning depends on the gesture type, but by default it
+ reflects the current position of the last touch event.]]
get {
}
set {
@@ -43,7 +44,17 @@ abstract @beta Efl.Canvas.Gesture extends Efl.Object
set {
}
values {
- timestamp: uint;[[The time-stamp.]]
+ timestamp: uint;[[The time-stamp, valued in milliseconds.]]
+ }
+ }
+ @property touch_count {
+ [[The current number of touch points recorded in the gesture.]]
+ get {
+ }
+ set @protected {
+ }
+ values {
+ touch_count: uint;[[The count of the touch points.]]
}
}
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_custom.c b/src/lib/evas/gesture/efl_canvas_gesture_custom.c
new file mode 100644
index 0000000000..890bcc5469
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_custom.c
@@ -0,0 +1,25 @@
+#define EFL_CANVAS_GESTURE_CUSTOM_PROTECTED
+#include "efl_canvas_gesture_private.h"
+
+#define MY_CLASS EFL_CANVAS_GESTURE_CUSTOM_CLASS
+
+
+EOLIAN static void
+_efl_canvas_gesture_custom_efl_object_destructor(Eo *obj, Efl_Canvas_Gesture_Custom_Data *pd)
+{
+ eina_stringshare_del(pd->gesture_name);
+ efl_destructor(efl_super(obj, MY_CLASS));
+}
+
+EOLIAN static void
+_efl_canvas_gesture_custom_gesture_name_set(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Custom_Data *pd, const char *name)
+{
+ eina_stringshare_replace(&pd->gesture_name, name);
+}
+
+EOLIAN static Eina_Stringshare *
+_efl_canvas_gesture_custom_gesture_name_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Custom_Data *pd)
+{
+ return pd->gesture_name;
+}
+#include "efl_canvas_gesture_custom.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_custom.eo b/src/lib/evas/gesture/efl_canvas_gesture_custom.eo
new file mode 100644
index 0000000000..c8fe7ad909
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_custom.eo
@@ -0,0 +1,31 @@
+parse efl_canvas_gesture_recognizer;
+
+class @beta Efl.Canvas.Gesture_Custom extends Efl.Canvas.Gesture
+{
+ [[Custom gesture class holding state information.
+ See @Efl.Canvas.Gesture to see what this state is and
+ @[Efl.Canvas.Gesture_Events.gesture,custom] for a description of the Custom gesture.
+
+ Application developers receive these objects inside a gesture event and do not typically need to create their own.
+
+ Custom gesture recognizers which implement their own gesture properties (e.g., gesture momentum or angle) must
+ inherit this class, and their recognizers must implement the @Efl.Canvas.Gesture_Recognizer.type property to return
+ this class.
+ ]]
+ c_prefix: efl_gesture_custom;
+ methods {
+ @property gesture_name {
+ [[This is the name of the custom gesture.]]
+ get {
+ }
+ set @protected {
+ }
+ values {
+ gesture_name: string; [[The name of the custom gesture.]]
+ }
+ }
+ }
+ implements {
+ Efl.Object.destructor;
+ }
+}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_double_tap.c b/src/lib/evas/gesture/efl_canvas_gesture_double_tap.c
index 971d49e3b6..cff4d8fe63 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_double_tap.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_double_tap.c
@@ -2,17 +2,4 @@
#define MY_CLASS EFL_CANVAS_GESTURE_DOUBLE_TAP_CLASS
-EOLIAN static Efl_Object *
-_efl_canvas_gesture_double_tap_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
-{
- Efl_Canvas_Gesture_Data *gd;
-
- obj = efl_constructor(efl_super(obj, MY_CLASS));
-
- gd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_CLASS);
- gd->type = EFL_EVENT_GESTURE_DOUBLE_TAP;
-
- return obj;
-}
-
#include "efl_canvas_gesture_double_tap.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_double_tap.eo b/src/lib/evas/gesture/efl_canvas_gesture_double_tap.eo
index 87b93ccd9c..fe01a2ad66 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_double_tap.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_double_tap.eo
@@ -2,11 +2,10 @@ class @beta Efl.Canvas.Gesture_Double_Tap extends Efl.Canvas.Gesture
{
[[Double-tap gesture class holding state information.
See @Efl.Canvas.Gesture to see what this state is and
- @[Efl.Gesture.Events.gesture,double_tap] for a description of the Double-tap gesture.
+ @[Efl.Canvas.Gesture_Events.gesture,double_tap] for a description of the Double-tap gesture.
+
+ Application developers receive these objects inside a gesture event and do not typically need to create their own.
]]
data: null;
c_prefix: efl_gesture_double_tap;
- implements {
- Efl.Object.constructor;
- }
}
diff --git a/src/lib/evas/gesture/efl_gesture_events.eo b/src/lib/evas/gesture/efl_canvas_gesture_events.eo
index d80c0bbb77..6d95e68d4d 100644
--- a/src/lib/evas/gesture/efl_gesture_events.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_events.eo
@@ -1,43 +1,56 @@
-interface @beta Efl.Gesture.Events
+interface @beta Efl.Canvas.Gesture_Events
{
+ [[Interface for objects capable of emitting gesture events, like @Efl.Canvas.Object.
+ ]]
event_c_prefix: efl;
events {
gesture,tap: Efl.Canvas.Gesture_Tap; [[Emitted when a Tap gesture has been detected.
A Tap gesture consists of a touch of the screen (or click of the mouse) quickly followed by
- a release. If the release happens too late a @[Efl.Gesture.Events.gesture,long_tap] event will be
+ a release. If the release happens too late a @[Efl.Canvas.Gesture_Events.gesture,long_press] event will be
emitted instead.
]]
gesture,double_tap: Efl.Canvas.Gesture_Double_Tap; [[Emitted when a Double-tap gesture has been detected.
A Double-tap gesture consists of two taps on the screen (or clicks of the mouse) in quick
succession. If the second one is delayed for too long they will be detected as two independent
- @[Efl.Gesture.Events.gesture,tap] events.
+ @[Efl.Canvas.Gesture_Events.gesture,tap] events.
]]
gesture,triple_tap: Efl.Canvas.Gesture_Triple_Tap; [[Emitted when a Triple-tap gesture has been detected.
A Triple-tap gesture consists of three taps on the screen (or clicks of the mouse) in quick
succession. If any of them is delayed for too long they will be detected as independent
- @[Efl.Gesture.Events.gesture,tap] or @[Efl.Gesture.Events.gesture,double_tap] events.
+ @[Efl.Canvas.Gesture_Events.gesture,tap] or @[Efl.Canvas.Gesture_Events.gesture,double_tap] events.
]]
- gesture,long_tap: Efl.Canvas.Gesture_Long_Tap; [[Emitted when a Long-tap gesture has been detected.
+ gesture,long_press: Efl.Canvas.Gesture_Long_Press; [[Emitted when a Long-tap gesture has been detected.
A Long-tap gesture consists of a touch of the screen (or click of the mouse) followed by a release
- after some time. If the release happens too quickly a @[Efl.Gesture.Events.gesture,tap] event will be
+ after some time. If the release happens too quickly a @[Efl.Canvas.Gesture_Events.gesture,tap] event will be
emitted instead.
]]
gesture,momentum: Efl.Canvas.Gesture_Momentum; [[Emitted when a Momentum gesture has been detected.
- A Momentum gesture consists of a quick displacement of the finger while touching the screen (or while
- holding down a mouse button).
+ A Momentum gesture is any motion of the finger while touching the screen (or while
+ holding down a mouse button). This gesture is also known as swipe.
]]
gesture,flick: Efl.Canvas.Gesture_Flick; [[Emitted when a Flick gesture has been detected.
+ A Flick gesture consists of a quick motion of the finger while touching the screen (or while
+ holding down a mouse button) with the release occurring before slowing down.
]]
+ gesture,rotate: Efl.Canvas.Gesture_Rotate; [[Emitted when a Rotate gesture has been detected.
+ A Rotate gesture consists of two fingers touching the screen and performing a motion such that
+ one finger rotates around the other.
+ This gesture cannot be performed with a mouse as it requires more than one pointer.
+ ]]
gesture,zoom: Efl.Canvas.Gesture_Zoom; [[Emitted when a Zoom gesture has been detected.
A Zoom gesture consists of two fingers touching the screen and separating ("zoom in") or
getting closer ("zoom out" or "pinch").
This gesture cannot be performed with a mouse as it requires more than one pointer.
]]
+ gesture,custom: Efl.Canvas.Gesture_Custom; [[Emitted when a Custom gesture has been detected.
+ A Custom gesture is one which is custom-written for use in an application or toolkit and
+ is not shipped with EFL.
+ ]]
}
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_flick.c b/src/lib/evas/gesture/efl_canvas_gesture_flick.c
index 1095a84652..57c2ee3309 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_flick.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_flick.c
@@ -2,27 +2,14 @@
#define MY_CLASS EFL_CANVAS_GESTURE_FLICK_CLASS
-EOLIAN static Efl_Object *
-_efl_canvas_gesture_flick_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_Flick_Data *pd EINA_UNUSED)
-{
- Efl_Canvas_Gesture_Data *gd;
-
- obj = efl_constructor(efl_super(obj, MY_CLASS));
-
- gd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_CLASS);
- gd->type = EFL_EVENT_GESTURE_FLICK;
-
- return obj;
-}
-
EOLIAN static Eina_Vector2
-_efl_canvas_gesture_flick_momentum_get(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Flick_Data *pd)
+_efl_canvas_gesture_flick_momentum_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Flick_Data *pd)
{
return pd->momentum;
}
EOLIAN static double
-_efl_canvas_gesture_flick_angle_get(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Flick_Data *pd)
+_efl_canvas_gesture_flick_angle_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Flick_Data *pd)
{
return pd->angle;
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_flick.eo b/src/lib/evas/gesture/efl_canvas_gesture_flick.eo
index afc8391550..a03dffa87d 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_flick.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_flick.eo
@@ -4,22 +4,29 @@ class @beta Efl.Canvas.Gesture_Flick extends Efl.Canvas.Gesture
{
[[Flick gesture class holding state information.
See @Efl.Canvas.Gesture to see what this state is and
- @[Efl.Gesture.Events.gesture,flick] for a description of the Flick gesture.
+ @[Efl.Canvas.Gesture_Events.gesture,flick] for a description of the Flick gesture.
+
+ Application developers receive these objects inside a gesture event and do not typically need to create their own.
]]
c_prefix: efl_gesture_flick;
methods {
- momentum_get {
- [[Gets flick gesture momentum value, this is, the direction in which the
+ @property momentum {
+ [[The flick gesture momentum value, this is, the direction in which the
pointer was flicked.]]
- return: Eina.Vector2; [[The momentum vector.]]
+ get {
+ }
+ values {
+ momentum: Eina.Vector2; [[The momentum vector.]]
+ }
}
- angle_get {
- [[Gets flick gesture direction angle, this is, the angle in which the
+ @property angle {
+ [[The flick gesture direction angle, this is, the angle in which the
pointer was flicked.]]
- return: double; [[The angle value.]]
+ get {
+ }
+ values {
+ angle: double; [[The angle value.]]
+ }
}
}
- implements {
- Efl.Object.constructor;
- }
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_long_press.c b/src/lib/evas/gesture/efl_canvas_gesture_long_press.c
new file mode 100644
index 0000000000..8403a473d1
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_long_press.c
@@ -0,0 +1,5 @@
+#include "efl_canvas_gesture_private.h"
+
+#define MY_CLASS EFL_CANVAS_GESTURE_LONG_PRESS_CLASS
+
+#include "efl_canvas_gesture_long_press.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_long_press.eo b/src/lib/evas/gesture/efl_canvas_gesture_long_press.eo
new file mode 100644
index 0000000000..f039f24ff0
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_long_press.eo
@@ -0,0 +1,11 @@
+class @beta Efl.Canvas.Gesture_Long_Press extends Efl.Canvas.Gesture
+{
+ [[Long-tap gesture class holding state information.
+ See @Efl.Canvas.Gesture to see what this state is and
+ @[Efl.Canvas.Gesture_Events.gesture,long_press] for a description of the Long-tap gesture.
+
+ Application developers receive these objects inside a gesture event and do not typically need to create their own.
+ ]]
+ data: null;
+ c_prefix: efl_gesture_long_press;
+}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_long_tap.c b/src/lib/evas/gesture/efl_canvas_gesture_long_tap.c
deleted file mode 100644
index 21f0055414..0000000000
--- a/src/lib/evas/gesture/efl_canvas_gesture_long_tap.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "efl_canvas_gesture_private.h"
-
-#define MY_CLASS EFL_CANVAS_GESTURE_LONG_TAP_CLASS
-
-EOLIAN static Efl_Object *
-_efl_canvas_gesture_long_tap_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
-{
- Efl_Canvas_Gesture_Data *gd;
-
- obj = efl_constructor(efl_super(obj, MY_CLASS));
- gd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_CLASS);
- gd->type = EFL_EVENT_GESTURE_LONG_TAP;
-
- return obj;
-}
-
-EOLIAN static void
-_efl_canvas_gesture_long_tap_efl_object_destructor(Eo *obj, void *pd EINA_UNUSED)
-{
- efl_destructor(efl_super(obj, MY_CLASS));
-}
-
-#include "efl_canvas_gesture_long_tap.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_long_tap.eo b/src/lib/evas/gesture/efl_canvas_gesture_long_tap.eo
deleted file mode 100644
index 6c0d0c979d..0000000000
--- a/src/lib/evas/gesture/efl_canvas_gesture_long_tap.eo
+++ /dev/null
@@ -1,13 +0,0 @@
-class @beta Efl.Canvas.Gesture_Long_Tap extends Efl.Canvas.Gesture
-{
- [[Long-tap gesture class holding state information.
- See @Efl.Canvas.Gesture to see what this state is and
- @[Efl.Gesture.Events.gesture,long_tap] for a description of the Long-tap gesture.
- ]]
- data: null;
- c_prefix: efl_gesture_long_tap;
- implements {
- Efl.Object.constructor;
- Efl.Object.destructor;
- }
-}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_manager.c b/src/lib/evas/gesture/efl_canvas_gesture_manager.c
index d5103186e1..38071d40e8 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_manager.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_manager.c
@@ -1,49 +1,73 @@
+#define EFL_CANVAS_GESTURE_PROTECTED
+#define EFL_CANVAS_GESTURE_CUSTOM_PROTECTED
#include "efl_canvas_gesture_private.h"
#define MY_CLASS EFL_CANVAS_GESTURE_MANAGER_CLASS
typedef struct _Object_Gesture
{
- Eo *object;
- const Efl_Event_Description *type;
- Efl_Canvas_Gesture *gesture;
- Efl_Canvas_Gesture_Recognizer *recognizer;
+ Eo *object;
+ const Efl_Event_Description *type;
+ Efl_Canvas_Gesture *gesture;
+ Efl_Canvas_Gesture_Recognizer *recognizer;
} Object_Gesture;
typedef struct _Efl_Canvas_Gesture_Manager_Data
{
//Keeps track of all the gesture request for a particular target
- Eina_Hash *m_gesture_contex; // (*target, *event_desc)
+ Eina_Hash *m_gesture_contex; // (*target, Eina_Hash(type, int))
//Keeps all the event directed to this particular object from touch_begin till touch_end
- Eina_Hash *m_object_events; // (*target, *efl_gesture_touch)
+ Eina_Hash *m_object_events; // (*recognizer, *efl_gesture_touch)
//Keeps all the recognizer registered to gesture manager
- Eina_Hash *m_recognizers; // (*gesture_type, *recognizer)
+ Eina_Hash *m_recognizers; // (*gesture_type, *recognizer)
+ Eina_List *custom_recognizers;
//Keeps track of all current object gestures.
- Eina_List *m_object_gestures; //(List of *object_gesture)
+ Eina_List *m_object_gestures; //(List of *object_gesture)
//Lazy deletion of gestures
- Eina_List *m_gestures_to_delete;
+ Eina_Array *m_gestures_to_delete;
//Kepps config values for gesture recognize
- Eina_Hash *m_config;
+ Eina_Bool processing : 1;
} Efl_Canvas_Gesture_Manager_Data;
static void _cleanup_cached_gestures(Efl_Canvas_Gesture_Manager_Data *pd,
- Eo *target, const Efl_Event_Description *type);
-static Efl_Canvas_Gesture*
-_get_state(Efl_Canvas_Gesture_Manager_Data *pd, Eo *target,
- Efl_Canvas_Gesture_Recognizer *recognizer, const Efl_Event_Description *type);
+ const Eo *target, const Efl_Event_Description *type, const Efl_Canvas_Gesture_Recognizer *recognizer);
+static Efl_Canvas_Gesture *
+ _get_state(Efl_Canvas_Gesture_Manager_Data *pd, Eo *target,
+ Efl_Canvas_Gesture_Recognizer *recognizer, const Efl_Event_Description *type);
+
+static const Efl_Event_Description *
+_gesture_recognizer_event_type_get(const Efl_Canvas_Gesture_Recognizer *recognizer)
+{
+ const Efl_Class *type = efl_gesture_recognizer_type_get(recognizer);
+
+ if (type == EFL_CANVAS_GESTURE_TAP_CLASS)
+ return EFL_EVENT_GESTURE_TAP;
+ if (type == EFL_CANVAS_GESTURE_DOUBLE_TAP_CLASS)
+ return EFL_EVENT_GESTURE_DOUBLE_TAP;
+ if (type == EFL_CANVAS_GESTURE_TRIPLE_TAP_CLASS)
+ return EFL_EVENT_GESTURE_TRIPLE_TAP;
+ if (type == EFL_CANVAS_GESTURE_LONG_PRESS_CLASS)
+ return EFL_EVENT_GESTURE_LONG_PRESS;
+ if (type == EFL_CANVAS_GESTURE_MOMENTUM_CLASS)
+ return EFL_EVENT_GESTURE_MOMENTUM;
+ if (type == EFL_CANVAS_GESTURE_FLICK_CLASS)
+ return EFL_EVENT_GESTURE_FLICK;
+ if (type == EFL_CANVAS_GESTURE_ROTATE_CLASS)
+ return EFL_EVENT_GESTURE_ROTATE;
+ if (type == EFL_CANVAS_GESTURE_ZOOM_CLASS)
+ return EFL_EVENT_GESTURE_ZOOM;
+ return EFL_EVENT_GESTURE_CUSTOM;
+}
static void
-_cleanup_object(Eina_List *list)
+_cleanup_object(Eina_Array *arr)
{
- Eina_List *l;
Eo *obj;
- if (!list) return;
+ if (!eina_array_count(arr)) return;
- EINA_LIST_FOREACH(list, l, obj)
+ while ((obj = eina_array_pop(arr)))
efl_del(obj);
-
- eina_list_free(list);
}
static void
@@ -52,90 +76,147 @@ _hash_unref_cb(Eo *obj)
efl_unref(obj);
}
+/* updates the data for in-tree recognizers without needing to watch events */
+static void
+_update_finger_sizes(Efl_Canvas_Gesture_Manager_Data *pd, int finger_size)
+{
+ Efl_Canvas_Gesture_Recognizer *r;
+ Efl_Canvas_Gesture_Recognizer_Tap_Data *td;
+ Efl_Canvas_Gesture_Recognizer_Double_Tap_Data *dtd;
+ Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *ttd;
+ Efl_Canvas_Gesture_Recognizer_Long_Press_Data *ltd;
+ Efl_Canvas_Gesture_Recognizer_Flick_Data *fd;
+ Efl_Canvas_Gesture_Recognizer_Rotate_Data *rd;
+ Efl_Canvas_Gesture_Recognizer_Zoom_Data *zd;
+ const Efl_Event_Description *type;
+
+ type = EFL_EVENT_GESTURE_TAP;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ td = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_TAP_CLASS);
+ td->finger_size = finger_size;
+
+ type = EFL_EVENT_GESTURE_DOUBLE_TAP;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ dtd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_DOUBLE_TAP_CLASS);
+ dtd->finger_size = finger_size;
+
+ type = EFL_EVENT_GESTURE_TRIPLE_TAP;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ ttd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_TRIPLE_TAP_CLASS);
+ ttd->finger_size = finger_size;
+
+ type = EFL_EVENT_GESTURE_LONG_PRESS;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ ltd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_LONG_PRESS_CLASS);
+ ltd->finger_size = finger_size;
+
+ type = EFL_EVENT_GESTURE_FLICK;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ fd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_FLICK_CLASS);
+ fd->finger_size = finger_size;
+
+ type = EFL_EVENT_GESTURE_ROTATE;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ rd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_ROTATE_CLASS);
+ rd->finger_size = finger_size;
+
+ type = EFL_EVENT_GESTURE_ZOOM;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ zd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_ZOOM_CLASS);
+ zd->finger_size = finger_size;
+}
+
+static void
+_gesture_manager_config_changed(void *data, const Efl_Event *ev)
+{
+ Efl_Canvas_Gesture_Manager_Data *pd = data;
+
+ if ((!ev->info) || eina_streq(ev->info, "glayer_tap_finger_size"))
+ _update_finger_sizes(pd, efl_config_int_get(ev->object, "glayer_tap_finger_size"));
+}
+
EOLIAN static Efl_Object *
-_efl_canvas_gesture_manager_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_Manager_Data *pd EINA_UNUSED)
+_efl_canvas_gesture_manager_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_Manager_Data *pd)
{
+ Eo *config;
+ int finger_size = 0;
obj = efl_constructor(efl_super(obj, MY_CLASS));
pd->m_recognizers = eina_hash_pointer_new(EINA_FREE_CB(_hash_unref_cb));
- pd->m_gesture_contex = eina_hash_pointer_new(NULL);
+ pd->m_gesture_contex = eina_hash_pointer_new(EINA_FREE_CB(eina_hash_free));
pd->m_object_events = eina_hash_pointer_new(EINA_FREE_CB(_hash_unref_cb));
pd->m_object_gestures = NULL;
- pd->m_gestures_to_delete = NULL;
+ pd->m_gestures_to_delete = eina_array_new(1);;
- pd->m_config = eina_hash_string_superfast_new(EINA_FREE_CB(eina_value_free));
+ /* this needs to always be present */
+ config = efl_provider_find(efl_main_loop_get(), EFL_CONFIG_INTERFACE);
+ efl_event_callback_add(config, EFL_CONFIG_EVENT_CONFIG_CHANGED, _gesture_manager_config_changed, pd);
//Register all types of recognizers at very first time.
efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_TAP_CLASS, obj));
- efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_LONG_TAP_CLASS, obj));
+ efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_LONG_PRESS_CLASS, obj));
efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_DOUBLE_TAP_CLASS, obj));
efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_TRIPLE_TAP_CLASS, obj));
efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_MOMENTUM_CLASS, obj));
efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_FLICK_CLASS, obj));
+ efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_ROTATE_CLASS, obj));
efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_ZOOM_CLASS, obj));
+ /* realistically this will never fail, but the whole gesture layer breaks if this is 0 */
+ if (!getenv("EFL_RUN_IN_TREE"))
+ finger_size = efl_config_int_get(config, "glayer_tap_finger_size");
+ if (finger_size < 1) finger_size = 10;
+ _update_finger_sizes(pd, finger_size);
return obj;
}
-EOLIAN static Eina_Value *
-_efl_canvas_gesture_manager_config_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Manager_Data *pd, const char *name)
-{
- return eina_hash_find(pd->m_config, name);
-}
-
EOLIAN static void
-_efl_canvas_gesture_manager_config_set(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Manager_Data *pd, const char *name, Eina_Value *value)
+_efl_canvas_gesture_manager_efl_object_destructor(Eo *obj, Efl_Canvas_Gesture_Manager_Data *pd)
{
- Eina_Value *v = eina_value_new(eina_value_type_get(value));
- eina_value_copy(value, v);
- eina_hash_add(pd->m_config, name, v);
-
- //Sets recognizer class property.
- if (!strcmp(name, "glayer_tap_finger_size"))
- {
- int finger_size;
- Efl_Canvas_Gesture_Recognizer *r;
- Efl_Canvas_Gesture_Recognizer_Data *rd;
-
- eina_value_get(value, &finger_size);
-
- const Efl_Event_Description *type = EFL_EVENT_GESTURE_TAP;
-
- r = eina_hash_find(pd->m_recognizers, &type);
- rd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
- rd->finger_size = finger_size;
- }
-}
+ Efl_Canvas_Gesture_Recognizer *recognizer;
+ void *ptr;
+ Eo *config = efl_provider_find(efl_main_loop_get(), EFL_CONFIG_INTERFACE);
+ if (config)
+ efl_event_callback_del(config, EFL_CONFIG_EVENT_CONFIG_CHANGED, _gesture_manager_config_changed, pd);
-EOLIAN static void
-_efl_canvas_gesture_manager_efl_object_destructor(Eo *obj, Efl_Canvas_Gesture_Manager_Data *pd EINA_UNUSED)
-{
- eina_hash_free(pd->m_config);
eina_hash_free(pd->m_recognizers);
+ EINA_LIST_FREE(pd->custom_recognizers, recognizer)
+ efl_unref(recognizer);
eina_hash_free(pd->m_gesture_contex);
eina_hash_free(pd->m_object_events);
_cleanup_object(pd->m_gestures_to_delete);
+ eina_array_free(pd->m_gestures_to_delete);
+ EINA_LIST_FREE(pd->m_object_gestures, ptr)
+ free(ptr);
efl_destructor(efl_super(obj, MY_CLASS));
}
-void *
-_efl_canvas_gesture_manager_private_data_get(Eo *obj)
-{
- Efl_Canvas_Gesture_Manager_Data *pd = efl_data_scope_get(obj, MY_CLASS);
-
- return pd;
-}
-
void
_efl_canvas_gesture_manager_callback_add_hook(void *data, Eo *target, const Efl_Event_Description *type)
{
Efl_Canvas_Gesture_Manager_Data *pd = data;
//If there is a recognizer registered for that event then add it to the gesture context
- Efl_Canvas_Gesture_Recognizer *recognizer = eina_hash_find (pd->m_recognizers, &type);
+ Efl_Canvas_Gesture_Recognizer *recognizer;
+
+ if (type == EFL_EVENT_GESTURE_CUSTOM)
+ recognizer = eina_list_data_get(pd->custom_recognizers);
+ else
+ recognizer = eina_hash_find(pd->m_recognizers, &type);
if (recognizer)
{
//Add it to the gesture context.
- eina_hash_list_append(pd->m_gesture_contex, &target, type);
+ Eina_Hash *thisisreallystupid = eina_hash_find(pd->m_gesture_contex, &target);
+ intptr_t count = 0;
+ /* already present */
+ if (thisisreallystupid)
+ count = (intptr_t)eina_hash_find(thisisreallystupid, &type);
+ else
+ {
+ thisisreallystupid = eina_hash_pointer_new(NULL);
+ eina_hash_set(pd->m_gesture_contex, &target, thisisreallystupid);
+ }
+ count++;
+ eina_hash_set(thisisreallystupid, &type, (intptr_t*)count);
}
}
@@ -144,228 +225,212 @@ _efl_canvas_gesture_manager_callback_del_hook(void *data, Eo *target, const Efl_
{
Efl_Canvas_Gesture_Manager_Data *pd = data;
//If there is a recognizer registered for that event then add it to the gesture context
- Efl_Canvas_Gesture_Recognizer *recognizer = eina_hash_find (pd->m_recognizers, &type);
+ Efl_Canvas_Gesture_Recognizer *recognizer;
+
+ if (type == EFL_EVENT_GESTURE_CUSTOM)
+ recognizer = eina_list_data_get(pd->custom_recognizers);
+ else
+ recognizer = eina_hash_find(pd->m_recognizers, &type);
if (recognizer)
{
- eina_hash_list_remove(pd->m_gesture_contex, &target, type);
- _cleanup_cached_gestures(pd, target, type);
+ Eina_Hash *thisisreallystupid = eina_hash_find(pd->m_gesture_contex, &target);
+ intptr_t count;
+
+ if (!thisisreallystupid) return;
+ count = (intptr_t)eina_hash_find(thisisreallystupid, &type);
+ if (!count) return;
+ count--;
+ eina_hash_set(thisisreallystupid, &type, (intptr_t*)count);
+ if (count) return;
+ eina_hash_del_by_key(thisisreallystupid, &type);
+ if (eina_hash_population(thisisreallystupid)) return;
+ eina_hash_del_by_key(pd->m_gesture_contex, &target);
+ _cleanup_cached_gestures(pd, target, type, NULL);
}
}
-void
-_efl_canvas_gesture_manager_filter_event(void *data, Eo *target, void *event)
+static void
+_recognizer_cleanup_internal(Efl_Canvas_Gesture_Manager_Data *pd, const Efl_Canvas_Gesture_Recognizer *recognizer, const Eo *target, const Efl_Event_Description *type)
+{
+ _cleanup_cached_gestures(pd, target, type, recognizer);
+ eina_hash_del(pd->m_object_events, &recognizer, NULL);
+ //FIXME: delete it by object not list.
+ _cleanup_object(pd->m_gestures_to_delete);
+}
+
+static void
+_gesture_recognizer_process_internal(Efl_Canvas_Gesture_Manager_Data *pd, Efl_Canvas_Gesture_Recognizer *recognizer,
+ Eo *target, const Efl_Event_Description *gesture_type, void *event)
{
- Efl_Canvas_Gesture_Manager_Data *pd = data;
- Eina_List *l, *gesture_context;
- const Efl_Event_Description *gesture_type;
- Efl_Canvas_Gesture_Recognizer *recognizer;
- Efl_Canvas_Gesture *gesture;
Efl_Canvas_Gesture_Recognizer_Result recog_result;
- Efl_Canvas_Gesture_Recognizer_Result recog_state;
+ Efl_Canvas_Gesture_Recognizer_Result recog_state = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
Efl_Canvas_Gesture_Touch *touch_event;
+ Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(recognizer, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
+ //If the gesture canceled or already finished by recognizer.
+ Efl_Canvas_Gesture *gesture = _get_state(pd, target, recognizer, gesture_type);
+ if (!gesture) return;
+
+ //Check there is already created event exist or not.
+ touch_event = eina_hash_find(pd->m_object_events, &recognizer);
+
+ if (!touch_event)
+ {
+ touch_event = efl_add_ref(EFL_CANVAS_GESTURE_TOUCH_CLASS, NULL);
+ eina_hash_add(pd->m_object_events, &recognizer, touch_event);
+ }
+
+ efl_gesture_touch_point_record(touch_event, event);
+
+ //This is for handling the case that mouse event pairs dont match.
+ //Such as the case of canceling gesture recognition after a mouse down.
+ if (efl_gesture_touch_state_get(touch_event) == EFL_GESTURE_TOUCH_STATE_UNKNOWN)
+ return;
+ if ((!rd->continues) && ((efl_gesture_state_get(gesture) == EFL_GESTURE_STATE_CANCELED) ||
+ (efl_gesture_state_get(gesture) == EFL_GESTURE_STATE_FINISHED)))
+ goto post_event;
+
+ /* this is the "default" value for the event, recognizers may modify it if necessary */
+ efl_gesture_touch_count_set(gesture, efl_gesture_touch_points_count_get(touch_event));
+
+ //Gesture detecting.
+ recog_result = efl_gesture_recognizer_recognize(recognizer, gesture, target, touch_event);
+ recog_state = recog_result & EFL_GESTURE_RECOGNIZER_RESULT_RESULT_MASK;
- gesture_context = eina_hash_find(pd->m_gesture_contex, &target);
- if (gesture_context)
+ if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER)
{
- EINA_LIST_FOREACH(gesture_context, l, gesture_type)
+ if (efl_gesture_state_get(gesture) == EFL_GESTURE_STATE_NONE)
+ efl_gesture_state_set(gesture, EFL_GESTURE_STATE_STARTED);
+ else
+ efl_gesture_state_set(gesture, EFL_GESTURE_STATE_UPDATED);
+ }
+ else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_FINISH)
+ {
+ efl_gesture_state_set(gesture, EFL_GESTURE_STATE_FINISHED);
+ }
+ else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_MAYBE)
+ {
+ return;
+ }
+ else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_CANCEL)
+ {
+ if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE)
+ efl_gesture_state_set(gesture, EFL_GESTURE_STATE_CANCELED);
+ else
{
- //Check there is already created event exist or not.
- touch_event = eina_hash_find(pd->m_object_events, &gesture_type);
+ if (rd->continues)
+ return;
+ goto post_event;
+ }
+ }
+ else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_IGNORE)
+ {
+ return;
+ }
- if (!touch_event)
- {
- touch_event = efl_add_ref(EFL_CANVAS_GESTURE_TOUCH_CLASS, NULL);
- eina_hash_add(pd->m_object_events, &gesture_type, touch_event);
- }
+ efl_gesture_timestamp_set(gesture, efl_gesture_touch_current_timestamp_get(touch_event));
+ efl_event_callback_call(target, gesture_type, gesture);
+post_event:
+ /* avoid destroying touch tracking before gesture has ended */
+ if ((!rd->continues) &&
+ ((efl_gesture_touch_state_get(touch_event) != EFL_GESTURE_TOUCH_STATE_END) || efl_gesture_touch_points_count_get(touch_event)))
+ return;
+ //If the current event recognizes the gesture continuously, dont delete gesture.
+ if (((recog_state == EFL_GESTURE_RECOGNIZER_RESULT_FINISH) || (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_CANCEL)) &&
+ !rd->continues)
+ _recognizer_cleanup_internal(pd, recognizer, target, gesture_type);
+}
- efl_gesture_touch_point_record(touch_event, event);
+void
+_efl_canvas_gesture_manager_filter_event(void *data, Eo *target, void *event)
+{
+ Efl_Canvas_Gesture_Manager_Data *pd = data;
+ Eina_Hash *thisisreallystupid;
+ Eina_Iterator *it;
+ Eina_Hash_Tuple *tup;
+ Efl_Canvas_Gesture_Recognizer *recognizer;
- //This is for handling the case that mouse event pairs dont match.
- //Such as the case of canceling gesture recognition after a mouse down.
- if (efl_gesture_touch_state_get(touch_event) == EFL_GESTURE_TOUCH_UNKNOWN)
- continue;
+ thisisreallystupid = eina_hash_find(pd->m_gesture_contex, &target);
+ if (!thisisreallystupid) return;
+ pd->processing = EINA_TRUE;
+ it = eina_hash_iterator_tuple_new(thisisreallystupid);
+ EINA_ITERATOR_FOREACH(it, tup)
+ {
+ const Efl_Event_Description *gesture_type = *(void**)tup->key;
+ if (gesture_type == EFL_EVENT_GESTURE_CUSTOM)
+ {
+ Eina_List *l;
+ EINA_LIST_FOREACH(pd->custom_recognizers, l, recognizer)
+ _gesture_recognizer_process_internal(pd, recognizer, target, gesture_type, event);
+ }
+ else
+ {
recognizer = eina_hash_find(pd->m_recognizers, &gesture_type);
-
- //If the gesture canceled or already finished by recognizer.
- gesture = _get_state(pd, target, recognizer, gesture_type);
- if (!gesture)
- continue;
-
- //Gesture detecting.
- recog_result = efl_gesture_recognizer_recognize(recognizer, gesture, target, touch_event);
- recog_state = recog_result & EFL_GESTURE_RESULT_MASK;
-
- Efl_Canvas_Gesture_Recognizer_Data *rd =
- efl_data_scope_get(recognizer, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
-
- if (recog_state == EFL_GESTURE_TRIGGER)
- {
- if (efl_gesture_state_get(gesture) == EFL_GESTURE_NONE)
- efl_gesture_state_set(gesture, EFL_GESTURE_STARTED);
- else
- efl_gesture_state_set(gesture, EFL_GESTURE_UPDATED);
- }
- else if (recog_state == EFL_GESTURE_FINISH)
- {
- efl_gesture_state_set(gesture, EFL_GESTURE_FINISHED);
- }
- else if (recog_state == EFL_GESTURE_MAYBE)
- {
- continue;
- }
- else if (recog_state == EFL_GESTURE_CANCEL)
- {
- if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE)
- efl_gesture_state_set(gesture, EFL_GESTURE_CANCELED);
- else
- {
- //Need to recognize events that occur consecutively
- //in a mouse-down state.
- if (rd->continues)
- continue;
- }
- }
- else if (recog_state == EFL_GESTURE_IGNORE)
- {
- continue;
- }
-
- efl_gesture_timestamp_set(gesture, efl_gesture_touch_cur_timestamp_get(touch_event));
- efl_event_callback_call(target, gesture_type, gesture);
-
- //If the current event recognizes the gesture continuously, dont delete gesture.
- if (((recog_state == EFL_GESTURE_FINISH) || (recog_state == EFL_GESTURE_CANCEL)) &&
- !rd->continues)
- {
- _cleanup_cached_gestures(pd, target, gesture_type);
- eina_hash_del(pd->m_object_events, &gesture_type, NULL);
- //FIXME: delete it by object not list.
- _cleanup_object(pd->m_gestures_to_delete);
- pd->m_gestures_to_delete = NULL;
-
- }
+ _gesture_recognizer_process_internal(pd, recognizer, target, gesture_type, event);
}
}
+ eina_iterator_free(it);
+ pd->processing = EINA_FALSE;
}
EOLIAN static void
_efl_canvas_gesture_manager_recognizer_register(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Manager_Data *pd,
Efl_Canvas_Gesture_Recognizer *recognizer)
{
- Efl_Canvas_Gesture_Recognizer_Data *rpd;
- Efl_Canvas_Gesture *dummy = efl_gesture_recognizer_add(recognizer, NULL);
-
- if (!dummy)
- return;
-
- const Efl_Event_Description *type = _efl_gesture_type_get(dummy);
-
+ const Efl_Event_Description *type = _gesture_recognizer_event_type_get(recognizer);
//Add the recognizer to the m_recognizers
- eina_hash_add(pd->m_recognizers, &type, efl_ref(recognizer));
- //Update the manager
- rpd = efl_data_scope_get(recognizer, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
- rpd->manager = obj;
+ if (type == EFL_EVENT_GESTURE_CUSTOM)
+ {
+ EINA_SAFETY_ON_TRUE_RETURN(pd->custom_recognizers && eina_list_data_find(pd->custom_recognizers, recognizer));
+ pd->custom_recognizers = eina_list_append(pd->custom_recognizers, efl_ref(recognizer));
+ }
+ else
+ {
+ EINA_SAFETY_ON_TRUE_RETURN(!!eina_hash_find(pd->m_recognizers, &type));
+ eina_hash_add(pd->m_recognizers, &type, efl_ref(recognizer));
+ }
- efl_del(dummy);
}
EOLIAN static void
_efl_canvas_gesture_manager_recognizer_unregister(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Manager_Data *pd,
- Efl_Canvas_Gesture_Recognizer *recognizer)
+ Efl_Canvas_Gesture_Recognizer *recognizer)
{
Eina_List *l, *l_next;
Object_Gesture *object_gesture;
const Efl_Event_Description *type;
- Efl_Canvas_Gesture *dummy;
if (!recognizer) return;
//Find the type of the recognizer
- dummy = efl_gesture_recognizer_add(recognizer, 0);
- if (!dummy)return;
-
- type = _efl_gesture_type_get(dummy);
- efl_del(dummy);
-
+ type = _gesture_recognizer_event_type_get(recognizer);
//Check if its already registered
- recognizer = eina_hash_find(pd->m_recognizers, &type);
-
- if (!recognizer) return;
+ if (type == EFL_EVENT_GESTURE_CUSTOM)
+ {
+ EINA_SAFETY_ON_TRUE_RETURN((!pd->custom_recognizers) || (!eina_list_data_find(pd->custom_recognizers, recognizer)));
+ pd->custom_recognizers = eina_list_remove(pd->custom_recognizers, recognizer);
+ eina_hash_del_by_key(pd->m_object_events, &recognizer);
+ efl_unref(recognizer);
+ }
+ else
+ {
+ EINA_SAFETY_ON_TRUE_RETURN(!eina_hash_find(pd->m_recognizers, &type));
+ eina_hash_del_by_key(pd->m_object_events, &recognizer);
+ eina_hash_del_by_key(pd->m_recognizers, &type);
+ }
//Remove that gesture from the list of object gestures
EINA_LIST_FOREACH_SAFE(pd->m_object_gestures, l, l_next, object_gesture)
{
- if (object_gesture->type == type)
+ if ((object_gesture->type == type) && (object_gesture->recognizer == recognizer))
{
- pd->m_gestures_to_delete = eina_list_append(pd->m_gestures_to_delete, object_gesture->gesture);
+ eina_array_push(pd->m_gestures_to_delete, object_gesture->gesture);
free(object_gesture);
pd->m_object_gestures = eina_list_remove_list(pd->m_object_gestures, l);
}
}
-
- eina_hash_del(pd->m_recognizers, &type, NULL);
-}
-
-static Efl_Canvas_Gesture_Recognizer *
-_find_match_recognizer(Efl_Canvas_Gesture_Manager_Data *pd, Efl_Canvas_Gesture_Recognizer_Type type)
-{
- const Efl_Event_Description *event_type;
-
- switch (type)
- {
- case EFL_GESTURE_TAP:
- {
- event_type = EFL_EVENT_GESTURE_TAP;
- break;
- }
- case EFL_GESTURE_DOUBLETAP:
- {
- event_type = EFL_EVENT_GESTURE_DOUBLE_TAP;
- break;
- }
- case EFL_GESTURE_TRIPLETAP:
- {
- event_type = EFL_EVENT_GESTURE_TRIPLE_TAP;
- break;
- }
- case EFL_GESTURE_LONGTAP:
- {
- event_type = EFL_EVENT_GESTURE_LONG_TAP;
- break;
- }
- case EFL_GESTURE_MOMENTUM:
- {
- event_type = EFL_EVENT_GESTURE_MOMENTUM;
- break;
- }
- case EFL_GESTURE_FLICK:
- {
- event_type = EFL_EVENT_GESTURE_FLICK;
- break;
- }
- case EFL_GESTURE_ZOOM:
- {
- event_type = EFL_EVENT_GESTURE_ZOOM;
- break;
- }
- default:
- return NULL;
- }
-
- return eina_hash_find(pd->m_recognizers, &event_type);
-}
-
-EOLIAN static const Efl_Canvas_Gesture_Recognizer *
-_efl_canvas_gesture_manager_recognizer_get(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Manager_Data *pd,
- Efl_Canvas_Gesture_Recognizer_Type type)
-{
- Efl_Canvas_Gesture_Recognizer *recognizer = _find_match_recognizer(pd, type);
-
- if (recognizer)
- return recognizer;
- else
- return NULL;
+ if (pd->processing) return;
+ _cleanup_object(pd->m_gestures_to_delete);
}
// EOLIAN static void
@@ -387,15 +452,13 @@ _efl_canvas_gesture_manager_recognizer_get(Eo *obj EINA_UNUSED, Efl_Canvas_Gestu
// }
//Get or create a gesture object that will represent the state for a given object, used by the recognizer
-Efl_Canvas_Gesture*
+Efl_Canvas_Gesture *
_get_state(Efl_Canvas_Gesture_Manager_Data *pd,
Eo *target, Efl_Canvas_Gesture_Recognizer *recognizer, const Efl_Event_Description *type)
{
Eina_List *l;
Object_Gesture *object_gesture;
Efl_Canvas_Gesture *gesture;
- Efl_Canvas_Gesture_Recognizer_Data *rd =
- efl_data_scope_get(recognizer, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
//If the widget is being deleted we should be careful not to
//Create a new state.
@@ -408,23 +471,12 @@ _get_state(Efl_Canvas_Gesture_Manager_Data *pd,
if (object_gesture->object == target &&
object_gesture->recognizer == recognizer &&
object_gesture->type == type)
- {
- //The gesture is already processed waiting for cleanup
- if (((efl_gesture_state_get(object_gesture->gesture) == EFL_GESTURE_FINISHED) ||
- (efl_gesture_state_get(object_gesture->gesture) == EFL_GESTURE_CANCELED)) &&
- (!rd->continues))
- {
- _cleanup_cached_gestures(pd, target, type);
- eina_hash_del(pd->m_object_events, &type, NULL);
- _cleanup_object(pd->m_gestures_to_delete);
- pd->m_gestures_to_delete = NULL;
- return NULL;
- }
- return object_gesture->gesture;
- }
+ {
+ return object_gesture->gesture;
+ }
}
- gesture = efl_gesture_recognizer_add(recognizer, target);
+ gesture = efl_add(efl_gesture_recognizer_type_get(recognizer), recognizer);
if (!gesture)
return 0;
@@ -433,6 +485,8 @@ _get_state(Efl_Canvas_Gesture_Manager_Data *pd,
object_gesture->recognizer = recognizer;
object_gesture->type = type;
object_gesture->gesture = gesture;
+ if (type == EFL_EVENT_GESTURE_CUSTOM)
+ efl_gesture_custom_gesture_name_set(gesture, efl_gesture_recognizer_custom_gesture_name_get(recognizer));
pd->m_object_gestures = eina_list_append(pd->m_object_gestures, object_gesture);
@@ -441,31 +495,33 @@ _get_state(Efl_Canvas_Gesture_Manager_Data *pd,
static void
_cleanup_cached_gestures(Efl_Canvas_Gesture_Manager_Data *pd,
- Eo *target, const Efl_Event_Description *type)
+ const Eo *target, const Efl_Event_Description *type, const Efl_Canvas_Gesture_Recognizer *recognizer)
{
Eina_List *l, *l_next;
Object_Gesture *object_gesture;
EINA_LIST_FOREACH_SAFE(pd->m_object_gestures, l, l_next, object_gesture)
{
- if ((object_gesture->type == type) && (target == object_gesture->object))
+ if ((object_gesture->type == type) && (target == object_gesture->object) &&
+ ((!recognizer) || (object_gesture->recognizer == recognizer)))
{
- pd->m_gestures_to_delete = eina_list_append(pd->m_gestures_to_delete, object_gesture->gesture);
+ eina_array_push(pd->m_gestures_to_delete, object_gesture->gesture);
free(object_gesture);
pd->m_object_gestures = eina_list_remove_list(pd->m_object_gestures, l);
}
}
}
-void
-efl_gesture_manager_gesture_clean_up(Eo *obj, Eo *target, const Efl_Event_Description *type)
+EOLIAN static void
+_efl_canvas_gesture_manager_recognizer_cleanup(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Manager_Data *pd, const Efl_Canvas_Gesture_Recognizer *recognizer, const Eo *target)
{
- Efl_Canvas_Gesture_Manager_Data *pd = efl_data_scope_get(obj, MY_CLASS);
+ const Efl_Event_Description *type;
- _cleanup_cached_gestures(pd, target, type);
- eina_hash_del(pd->m_object_events, &type, NULL);
- _cleanup_object(pd->m_gestures_to_delete);
- pd->m_gestures_to_delete = NULL;
+ EINA_SAFETY_ON_NULL_RETURN(recognizer);
+
+ //Find the type of the recognizer
+ type = _gesture_recognizer_event_type_get(recognizer);
+ _recognizer_cleanup_internal(pd, recognizer, target, type);
}
#include "efl_canvas_gesture_manager.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_manager.eo b/src/lib/evas/gesture/efl_canvas_gesture_manager.eo
index 1784f20d1e..7ae66a5af2 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_manager.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_manager.eo
@@ -1,12 +1,10 @@
-import efl_canvas_gesture_types;
-
class @beta Efl.Canvas.Gesture_Manager extends Efl.Object
{
[[This class keeps track of active @Efl.Canvas.Gesture_Recognizer objects.
For internal use only.
- This gesture class defines methods that register and unregister a recognizer and
- get a recognizer according to gesture event type.
+ This class defines methods to manage gesture recognizers and handles passing input events
+ to the recognizers that it manages.
]]
c_prefix: efl_gesture_manager;
methods {
@@ -22,24 +20,11 @@ class @beta Efl.Canvas.Gesture_Manager extends Efl.Object
@in recognizer: Efl.Canvas.Gesture_Recognizer; [[The gesture recognizer object.]]
}
}
- recognizer_get {
- [[Returns the event recognizer object associated with the given $gesture_type.]]
+ recognizer_cleanup {
+ [[Perform cleanup for a gesture which ends after a delay.]]
params {
- @in gesture_type: Efl.Canvas.Gesture_Recognizer_Type; [[The gesture event type.]]
- }
- return: const(Efl.Canvas.Gesture_Recognizer); [[The gesture recognizer.]]
- }
- @property config {
- [[This property holds configuration values for the recognizer.]]
- set {
- }
- get {
- }
- keys {
- name: string; [[Property name.]]
- }
- values {
- value: any_value_ref; [[Value of the property.]]
+ @in recognizer: const(Efl.Canvas.Gesture_Recognizer); [[The gesture recognizer object.]]
+ @in target: const(Efl.Canvas.Object); [[The target object being processed by the recognizer.]]
}
}
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_momentum.c b/src/lib/evas/gesture/efl_canvas_gesture_momentum.c
index e7eb34ad2b..18aaf6595f 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_momentum.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_momentum.c
@@ -2,21 +2,8 @@
#define MY_CLASS EFL_CANVAS_GESTURE_MOMENTUM_CLASS
-EOLIAN static Efl_Object *
-_efl_canvas_gesture_momentum_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_Momentum_Data *pd EINA_UNUSED)
-{
- Efl_Canvas_Gesture_Data *gd;
-
- obj = efl_constructor(efl_super(obj, MY_CLASS));
-
- gd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_CLASS);
- gd->type = EFL_EVENT_GESTURE_MOMENTUM;
-
- return obj;
-}
-
EOLIAN static Eina_Vector2
-_efl_canvas_gesture_momentum_momentum_get(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Momentum_Data *pd)
+_efl_canvas_gesture_momentum_momentum_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Momentum_Data *pd)
{
return pd->momentum;
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_momentum.eo b/src/lib/evas/gesture/efl_canvas_gesture_momentum.eo
index 0f78ad69aa..1220e0ffde 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_momentum.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_momentum.eo
@@ -4,16 +4,19 @@ class @beta Efl.Canvas.Gesture_Momentum extends Efl.Canvas.Gesture
{
[[Momentum gesture class holding state information.
See @Efl.Canvas.Gesture to see what this state is and
- @[Efl.Gesture.Events.gesture,momentum] for a description of the Momentum gesture.
+ @[Efl.Canvas.Gesture_Events.gesture,momentum] for a description of the Momentum gesture.
+
+ Application developers receive these objects inside a gesture event and do not typically need to create their own.
]]
c_prefix: efl_gesture_momentum;
methods {
- momentum_get {
- [[Gets the momentum value, this is, the direction in which the action occurred.]]
- return: Eina.Vector2; [[The momentum vector.]]
+ @property momentum {
+ [[The momentum value, this is, the direction in which the action occurred.]]
+ get {
+ }
+ values {
+ momentum: Eina.Vector2; [[The momentum vector.]]
+ }
}
}
- implements {
- Efl.Object.constructor;
- }
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_private.h b/src/lib/evas/gesture/efl_canvas_gesture_private.h
index a835c3093d..7b9b8550b0 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_private.h
+++ b/src/lib/evas/gesture/efl_canvas_gesture_private.h
@@ -4,52 +4,50 @@
#include "evas_common_private.h"
#include "evas_private.h"
-#include "efl_gesture_events.eo.h"
+#include "efl_canvas_gesture_events.eo.h"
#include <Ecore.h>
-const Efl_Event_Description * _efl_gesture_type_get(const Eo *obj);
-void efl_gesture_manager_gesture_clean_up(Eo *obj, Eo *target, const Efl_Event_Description *type);
+/* milliseconds */
+#define TAP_TOUCH_TIME_THRESHOLD (0.1 * 1000)
+
+int _direction_get(Evas_Coord xx1, Evas_Coord xx2);
+Eina_Value *_recognizer_config_get(const Eo *obj, const char *name);
+Eina_Bool _event_multi_touch_get(const Efl_Canvas_Gesture_Touch *event);
+
+double _angle_get(Evas_Coord xx1, Evas_Coord yy1, Evas_Coord xx2, Evas_Coord yy2);
+Evas_Coord _finger_gap_length_get(Evas_Coord xx1, Evas_Coord yy1, Evas_Coord xx2, Evas_Coord yy2, Evas_Coord *x, Evas_Coord *y);
typedef struct _Efl_Canvas_Gesture_Manager_Data Efl_Canvas_Gesture_Manager_Data;
typedef struct _Efl_Canvas_Gesture_Recognizer_Data Efl_Canvas_Gesture_Recognizer_Data;
typedef struct _Efl_Canvas_Gesture_Recognizer_Tap_Data Efl_Canvas_Gesture_Recognizer_Tap_Data;
-typedef struct _Efl_Canvas_Gesture_Recognizer_Long_Tap_Data Efl_Canvas_Gesture_Recognizer_Long_Tap_Data;
+typedef struct _Efl_Canvas_Gesture_Recognizer_Long_Press_Data Efl_Canvas_Gesture_Recognizer_Long_Press_Data;
typedef struct _Efl_Canvas_Gesture_Recognizer_Double_Tap_Data Efl_Canvas_Gesture_Recognizer_Double_Tap_Data;
typedef struct _Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data;
typedef struct _Efl_Canvas_Gesture_Recognizer_Momentum_Data Efl_Canvas_Gesture_Recognizer_Momentum_Data;
typedef struct _Efl_Canvas_Gesture_Recognizer_Flick_Data Efl_Canvas_Gesture_Recognizer_Flick_Data;
+typedef struct _Efl_Canvas_Gesture_Recognizer_Rotate_Data Efl_Canvas_Gesture_Recognizer_Rotate_Data;
typedef struct _Efl_Canvas_Gesture_Recognizer_Zoom_Data Efl_Canvas_Gesture_Recognizer_Zoom_Data;
+typedef struct _Efl_Canvas_Gesture_Recognizer_Custom_Data Efl_Canvas_Gesture_Recognizer_Custom_Data;
typedef struct _Efl_Canvas_Gesture_Data Efl_Canvas_Gesture_Data;
typedef struct _Efl_Canvas_Gesture_Momentum_Data Efl_Canvas_Gesture_Momentum_Data;
typedef struct _Efl_Canvas_Gesture_Flick_Data Efl_Canvas_Gesture_Flick_Data;
typedef struct _Efl_Canvas_Gesture_Zoom_Data Efl_Canvas_Gesture_Zoom_Data;
-
-typedef struct _Pointer_Data
-{
- struct
- {
- Eina_Position2D pos;
- unsigned int timestamp;
- } start, prev, cur;
- int id;
- Efl_Pointer_Action action;
-} Pointer_Data;
+typedef struct _Efl_Canvas_Gesture_Rotate_Data Efl_Canvas_Gesture_Rotate_Data;
+typedef struct _Efl_Canvas_Gesture_Custom_Data Efl_Canvas_Gesture_Custom_Data;
typedef struct _Efl_Canvas_Gesture_Touch_Data
{
Efl_Canvas_Gesture_Touch_State state;
- Eina_Hash *touch_points;
- int touch_down;
- Eina_Bool multi_touch;
+ Eina_Array *touch_points;
+ Efl_Gesture_Touch_Point_Data *cur_touch;
+ Efl_Gesture_Touch_Point_Data *prev_touch;
Eo *target;
+ int touch_down;
} Efl_Canvas_Gesture_Touch_Data;
struct _Efl_Canvas_Gesture_Recognizer_Data
{
- Eo *manager; // keeps a reference of the manager
- Eo *gesture;
- int finger_size;
Eina_Bool continues;
};
@@ -58,38 +56,42 @@ struct _Efl_Canvas_Gesture_Recognizer_Tap_Data
Eo *target;
Eo *gesture;
Ecore_Timer *timeout;
+ int finger_size;
};
-struct _Efl_Canvas_Gesture_Recognizer_Long_Tap_Data
+struct _Efl_Canvas_Gesture_Recognizer_Long_Press_Data
{
+ double start_timeout;
Eina_List *target_timeout;
Eo *target;
Efl_Canvas_Gesture *gesture;
Ecore_Timer *timeout;
- double start_timeout;
+ int finger_size;
Eina_Bool is_timeout;
};
struct _Efl_Canvas_Gesture_Recognizer_Double_Tap_Data
{
+ double start_timeout;
Eina_List *target_timeout;
Eo *target;
Eo *gesture;
Ecore_Timer *timeout;
- double start_timeout;
- Eina_Bool is_timeout;
int tap_count;
+ int finger_size;
+ Eina_Bool is_timeout;
};
struct _Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data
{
+ double start_timeout;
Eina_List *target_timeout;
Eo *target;
Eo *gesture;
Ecore_Timer *timeout;
- double start_timeout;
- Eina_Bool is_timeout;
int tap_count;
+ int finger_size;
+ Eina_Bool is_timeout;
};
struct _Efl_Canvas_Gesture_Recognizer_Momentum_Data
@@ -105,48 +107,84 @@ struct _Efl_Canvas_Gesture_Recognizer_Momentum_Data
struct _Efl_Canvas_Gesture_Recognizer_Flick_Data
{
+ double line_angle;
Eina_Position2D st_line;
unsigned int t_st;
unsigned int t_end;
int line_length;
- double line_angle;
+ int finger_size;
Eina_Bool touched;
};
+struct _Efl_Canvas_Gesture_Recognizer_Rotate_Data
+{
+ Efl_Gesture_Touch_Point_Data rotate_st;
+ Efl_Gesture_Touch_Point_Data rotate_st1;
+
+ Efl_Gesture_Touch_Point_Data rotate_mv;
+ Efl_Gesture_Touch_Point_Data rotate_mv1;
+ double rotate_step;
+ double base_angle; /**< Holds start-angle */
+ double prev_momentum; /* Snapshot of momentum 0.01
+ * sec ago */
+ double accum_momentum;
+ double rotate_angular_tolerance;
+ double next_step;
+ unsigned int prev_momentum_tm; /* timestamp of prev_momentum */
+ int finger_size;
+};
+
struct _Efl_Canvas_Gesture_Recognizer_Zoom_Data
{
- Pointer_Data zoom_st;
- Pointer_Data zoom_st1;
+ Efl_Gesture_Touch_Point_Data zoom_st;
+ Efl_Gesture_Touch_Point_Data zoom_st1;
- Pointer_Data zoom_mv;
- Pointer_Data zoom_mv1;
+ Efl_Gesture_Touch_Point_Data zoom_mv;
+ Efl_Gesture_Touch_Point_Data zoom_mv1;
- Evas_Coord zoom_base; /* Holds gap between fingers on
- * zoom-start */
double zoom_distance_tolerance;
double zoom_finger_factor;
double zoom_step;
double next_step;
+
+ Evas_Coord zoom_base; /* Holds gap between fingers on
+ * zoom-start */
+ int finger_size;
Eina_Bool calc_temp;
};
+struct _Efl_Canvas_Gesture_Recognizer_Custom_Data
+{
+ Eina_Stringshare *name;
+};
+
struct _Efl_Canvas_Gesture_Data
{
- const Efl_Event_Description *type;
Efl_Canvas_Gesture_State state;
Eina_Position2D hotspot;
unsigned int timestamp;
+ unsigned int touch_count;
};
struct _Efl_Canvas_Gesture_Momentum_Data
{
Eina_Vector2 momentum;
+ int id;
};
struct _Efl_Canvas_Gesture_Flick_Data
{
Eina_Vector2 momentum;
double angle;
+ int id;
+};
+
+struct _Efl_Canvas_Gesture_Rotate_Data
+{
+ //Evas_Coord x, y; /**< Holds rotate center point reported to user */
+ double angle; /**< Rotation value: 0.0 means no rotation */
+ double momentum; /**< Rotation momentum: rotation done per second (NOT YET SUPPORTED) */
+ Evas_Coord radius; /**< Holds radius between fingers reported to user */
};
struct _Efl_Canvas_Gesture_Zoom_Data
@@ -155,4 +193,9 @@ struct _Efl_Canvas_Gesture_Zoom_Data
double zoom;
};
+struct _Efl_Canvas_Gesture_Custom_Data
+{
+ Eina_Stringshare *gesture_name;
+};
+
#endif
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer.c
index 8a83e2f945..c07e11d084 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer.c
@@ -1,28 +1,143 @@
+#define EFL_CANVAS_GESTURE_RECOGNIZER_PROTECTED
#include "efl_canvas_gesture_private.h"
+#define RAD2DEG(x) ((x) * 57.295779513)
-#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_CLASS
+#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_CLASS
+#include "efl_canvas_gesture_recognizer.eo.h"
-#define EFL_GESTURE_TAP_FINGER_SIZE 10
-EOLIAN static Eina_Value *
-_efl_canvas_gesture_recognizer_config_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Data *pd, const char *name)
+Eina_Value *
+_recognizer_config_get(const Eo *obj, const char *name)
{
- return efl_gesture_manager_config_get(pd->manager, name);
+ Eo *config = efl_provider_find(obj, EFL_CONFIG_INTERFACE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(config, NULL);
+ return efl_config_get(config, name);
+}
+
+EOLIAN static Eina_Bool
+_efl_canvas_gesture_recognizer_continues_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Data *pd)
+{
+ return pd->continues;
}
EOLIAN static void
-_efl_canvas_gesture_recognizer_reset(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Data *pd EINA_UNUSED,
- Efl_Canvas_Gesture *gesture EINA_UNUSED)
+_efl_canvas_gesture_recognizer_continues_set(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Data *pd, Eina_Bool value)
+{
+ pd->continues = !!value;
+}
+
+int
+_direction_get(Evas_Coord xx1, Evas_Coord xx2)
+{
+ if (xx2 < xx1) return -1;
+ if (xx2 > xx1) return 1;
+
+ return 0;
+}
+
+Eina_Bool
+_event_multi_touch_get(const Efl_Canvas_Gesture_Touch *event)
{
+ return efl_gesture_touch_points_count_get(event) > 1;
+}
+
+
+double
+_angle_get(Evas_Coord xx1, Evas_Coord yy1, Evas_Coord xx2, Evas_Coord yy2)
+{
+ double a, xx, yy, rt = (-1);
+
+ xx = abs(xx2 - xx1);
+ yy = abs(yy2 - yy1);
+ if (((int)xx) && ((int)yy))
+ {
+ rt = a = RAD2DEG(atan(yy / xx));
+ if (xx1 < xx2)
+ {
+ if (yy1 < yy2) rt = 360 - a;
+ else rt = a;
+ }
+ else
+ {
+ if (yy1 < yy2) rt = 180 + a;
+ else rt = 180 - a;
+ }
+ }
+
+ if (rt < 0) /* Do this only if rt is not set */
+ {
+ if (((int)xx)) /* Horizontal line */
+ {
+ if (xx2 < xx1) rt = 180;
+ else rt = 0.0;
+ }
+ else /* Vertical line */
+ {
+ if (yy2 < yy1) rt = 90;
+ else rt = 270;
+ }
+ }
+
+ /* Now we want to change from:
+ * 90 0
+ * original circle 180 0 We want: 270 90
+ * 270 180
+ */
+ rt = 450 - rt;
+ if (rt >= 360) rt -= 360;
+
+ return rt;
}
-EOLIAN static Efl_Object *
-_efl_canvas_gesture_recognizer_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_Recognizer_Data *pd)
+Evas_Coord
+_finger_gap_length_get(Evas_Coord xx1,
+ Evas_Coord yy1,
+ Evas_Coord xx2,
+ Evas_Coord yy2,
+ Evas_Coord *x,
+ Evas_Coord *y)
{
- obj = efl_constructor(efl_super(obj, MY_CLASS));
+ double a, b, xx, yy, gap;
+ xx = abs(xx2 - xx1);
+ yy = abs(yy2 - yy1);
+ gap = sqrt((xx * xx) + (yy * yy));
- pd->finger_size = EFL_GESTURE_TAP_FINGER_SIZE;
+ /* START - Compute zoom center point */
+ /* The triangle defined as follows:
+ * B
+ * / |
+ * / |
+ * gap / | a
+ * / |
+ * A-----C
+ * b
+ * http://en.wikipedia.org/wiki/Trigonometric_functions
+ *************************************/
+ if (((int)xx) && ((int)yy))
+ {
+ double A = atan((yy / xx));
+ a = (Evas_Coord)((gap / 2) * sin(A));
+ b = (Evas_Coord)((gap / 2) * cos(A));
+ *x = (Evas_Coord)((xx2 > xx1) ? (xx1 + b) : (xx2 + b));
+ *y = (Evas_Coord)((yy2 > yy1) ? (yy1 + a) : (yy2 + a));
+ }
+ else
+ {
+ if ((int)xx) /* horiz line, take half width */
+ {
+ *x = (Evas_Coord)((xx1 + xx2) / 2);
+ *y = (Evas_Coord)(yy1);
+ }
- return obj;
+ if ((int)yy) /* vert line, take half width */
+ {
+ *x = (Evas_Coord)(xx1);
+ *y = (Evas_Coord)((yy1 + yy2) / 2);
+ }
+ }
+ /* END - Compute zoom center point */
+
+ return (Evas_Coord)gap;
}
+
#include "efl_canvas_gesture_recognizer.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer.eo b/src/lib/evas/gesture/efl_canvas_gesture_recognizer.eo
index e24fc7e9df..d03447f934 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer.eo
@@ -7,17 +7,19 @@ abstract @beta Efl.Canvas.Gesture_Recognizer extends Efl.Object
Gesture recognizers listen to events that occur on a target object
to see if a particular gesture has occurred.
- Recognizer-specific configuration values can be modified through @.config.
+ Recognizer-specific configuration values can be modified through @Efl.Config.config,
+ and the global config object can be found using @Efl.Object.provider_find.
Default configuration values are taken from the system's configuration.
]]
c_prefix: efl_gesture_recognizer;
methods {
- add @pure_virtual {
- [[This function is called to create a new @Efl.Canvas.Gesture object for the given target.]]
- params {
- @in target: Efl.Object; [[The target canvas object.]]
+ @property type @pure_virtual {
+ [[This property returns the class type of gesture recognized by this recognizer.
+ It must be implemented for the recognizer to function.]]
+ get {}
+ values {
+ type: const(Efl.Class); [[The gesture type to recognize.]]
}
- return: Efl.Canvas.Gesture; [[Returns the gesture object that will be used to track this gesture.]]
}
recognize @pure_virtual {
[[Analyzes the given $event and the current state of the $gesture object to see if the state
@@ -25,6 +27,8 @@ abstract @beta Efl.Canvas.Gesture_Recognizer extends Efl.Object
Updates the state of the gesture object as required, and returns a
suitable result for the current recognition step.
+
+ This method must be implemented for the recognizer to function.
]]
params {
@in gesture: Efl.Canvas.Gesture; [[The gesture object.]]
@@ -33,26 +37,17 @@ abstract @beta Efl.Canvas.Gesture_Recognizer extends Efl.Object
}
return: Efl.Canvas.Gesture_Recognizer_Result; [[Returns the result of the analysis.]]
}
- /* FIXME: This function is not used? */
- reset {
- [[This function is called by the framework to reset a given gesture.]]
- params {
- @in gesture: Efl.Canvas.Gesture; [[The gesture object.]]
- }
- }
- @property config {
- [[This property holds configuration values for the recognizer.]]
+ @property continues {
+ [[This property determines whether a gesture recognizer should continue
+ to try processing events after returning @Efl.Canvas.Gesture_Recognizer_Result.finish
+ or @Efl.Canvas.Gesture_Recognizer_Result.cancel.]]
get {
}
- keys {
- name: string; [[Property name.]]
+ set {
}
values {
- value: any_value_ref; [[Value of the property.]]
+ value: bool; [[Value of the property.]]
}
}
}
- implements {
- Efl.Object.constructor;
- }
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_custom.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_custom.c
new file mode 100644
index 0000000000..e91b195e3d
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_custom.c
@@ -0,0 +1,37 @@
+#include "efl_canvas_gesture_private.h"
+
+#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_CUSTOM_CLASS
+
+EOLIAN static const Efl_Class *
+_efl_canvas_gesture_recognizer_custom_efl_canvas_gesture_recognizer_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Custom_Data *pd EINA_UNUSED)
+{
+ return EFL_CANVAS_GESTURE_CUSTOM_CLASS;
+}
+
+EOLIAN static Eo *
+_efl_canvas_gesture_recognizer_custom_efl_object_finalize(Eo *obj, Efl_Canvas_Gesture_Recognizer_Custom_Data *pd)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(pd->name, NULL);
+ return efl_finalize(efl_super(obj, MY_CLASS));
+}
+
+EOLIAN static void
+_efl_canvas_gesture_recognizer_custom_efl_object_destructor(Eo *obj, Efl_Canvas_Gesture_Recognizer_Custom_Data *pd)
+{
+ eina_stringshare_del(pd->name);
+ efl_destructor(efl_super(obj, MY_CLASS));
+}
+
+EOLIAN static void
+_efl_canvas_gesture_recognizer_custom_gesture_name_set(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Custom_Data *pd, const char *name)
+{
+ eina_stringshare_replace(&pd->name, name);
+}
+
+EOLIAN static Eina_Stringshare *
+_efl_canvas_gesture_recognizer_custom_gesture_name_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Custom_Data *pd)
+{
+ return pd->name;
+}
+
+#include "efl_canvas_gesture_recognizer_custom.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_custom.eo b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_custom.eo
new file mode 100644
index 0000000000..92f9786e75
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_custom.eo
@@ -0,0 +1,28 @@
+abstract @beta Efl.Canvas.Gesture_Recognizer_Custom extends Efl.Canvas.Gesture_Recognizer
+{
+ [[This is the recognizer for Custom gestures.
+ See @Efl.Canvas.Gesture_Recognizer.
+
+ Custom-written recognizers must inherit this class.
+ They are responsible for managing and updating the state of the recognized @Efl.Canvas.Gesture object inside
+ their implementation of the @Efl.Canvas.Gesture_Recognizer.recognize method, which is required.
+ ]]
+ c_prefix: efl_gesture_recognizer_custom;
+ methods {
+ @property gesture_name {
+ [[This is the name of the gesture recognizer.]]
+ get {
+ }
+ set {
+ }
+ values {
+ gesture_name: string; [[The name of the gesture recognizer.]]
+ }
+ }
+ }
+ implements {
+ Efl.Object.destructor;
+ Efl.Object.finalize;
+ Efl.Canvas.Gesture_Recognizer.type { get; }
+ }
+}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_double_tap.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_double_tap.c
index 1656bb633f..123dbd551e 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_double_tap.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_double_tap.c
@@ -1,13 +1,13 @@
#include "efl_canvas_gesture_private.h"
-#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_DOUBLE_TAP_CLASS
+#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_DOUBLE_TAP_CLASS
#define TAP_TIME_OUT 0.33
-EOLIAN static Efl_Canvas_Gesture *
-_efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_add(Eo *obj, Efl_Canvas_Gesture_Recognizer_Double_Tap_Data *pd EINA_UNUSED, Efl_Object *target EINA_UNUSED)
+EOLIAN static const Efl_Class *
+_efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Double_Tap_Data *pd EINA_UNUSED)
{
- return efl_add(EFL_CANVAS_GESTURE_DOUBLE_TAP_CLASS, obj);
+ return EFL_CANVAS_GESTURE_DOUBLE_TAP_CLASS;
}
EOLIAN static void
@@ -23,16 +23,15 @@ _efl_canvas_gesture_recognizer_double_tap_efl_object_destructor(Eo *obj,
static Eina_Bool
_tap_timeout_cb(void *data)
{
- Efl_Canvas_Gesture_Recognizer_Data *rd;
Efl_Canvas_Gesture_Recognizer_Double_Tap_Data *pd;
- rd = efl_data_scope_get(data, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
pd = efl_data_scope_get(data, EFL_CANVAS_GESTURE_RECOGNIZER_DOUBLE_TAP_CLASS);
- efl_gesture_state_set(pd->gesture, EFL_GESTURE_CANCELED);
+ efl_gesture_state_set(pd->gesture, EFL_GESTURE_STATE_CANCELED);
efl_event_callback_call(pd->target, EFL_EVENT_GESTURE_DOUBLE_TAP, pd->gesture);
- efl_gesture_manager_gesture_clean_up(rd->manager, pd->target, EFL_EVENT_GESTURE_DOUBLE_TAP);
+ efl_gesture_manager_recognizer_cleanup(efl_provider_find(data, EFL_CANVAS_GESTURE_MANAGER_CLASS), data,
+ pd->target);
pd->timeout = NULL;
pd->tap_count = 0;
@@ -46,20 +45,19 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
Efl_Canvas_Gesture *gesture, Efl_Object *watched,
Efl_Canvas_Gesture_Touch *event)
{
- double length;
+ double length, start_timeout = pd->start_timeout;
double timeout = TAP_TIME_OUT;
Eina_Position2D pos;
Eina_Vector2 dist;
- Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;
- Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
+ Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
pd->target = watched;
pd->gesture = gesture;
- if (!pd->start_timeout)
+ if (!EINA_DBL_NONZERO(start_timeout))
{
double time;
- Eina_Value *val = efl_gesture_recognizer_config_get(obj, "glayer_doublee_tap_timeout");
+ Eina_Value *val = _recognizer_config_get(obj, "glayer_double_tap_timeout");
if (val)
{
@@ -68,86 +66,94 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
}
}
else
- timeout = pd->start_timeout;
+ timeout = start_timeout;
switch (efl_gesture_touch_state_get(event))
{
- case EFL_GESTURE_TOUCH_BEGIN:
- {
- pos = efl_gesture_touch_start_point_get(event);
- efl_gesture_hotspot_set(gesture, pos);
+ case EFL_GESTURE_TOUCH_STATE_BEGIN:
+ {
+ pos = efl_gesture_touch_start_point_get(event);
+ efl_gesture_hotspot_set(gesture, pos);
- if (pd->timeout)
- ecore_timer_reset(pd->timeout);
- else
- pd->timeout = ecore_timer_add(timeout, _tap_timeout_cb, obj);
+ if (pd->timeout)
+ ecore_timer_reset(pd->timeout);
+ else
+ pd->timeout = ecore_timer_add(timeout, _tap_timeout_cb, obj);
- result = EFL_GESTURE_TRIGGER;
+ result = EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
- break;
- }
+ break;
+ }
+
+ case EFL_GESTURE_TOUCH_STATE_UPDATE:
+ {
+ /* multi-touch */
+ if (efl_gesture_touch_current_data_get(event)->action == EFL_POINTER_ACTION_DOWN)
+ {
+ /* a second finger was pressed at the same time-ish as the first: combine into same event */
+ if (efl_gesture_touch_current_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
+ {
+ result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ break;
+ }
+ }
+ result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
- case EFL_GESTURE_TOUCH_UPDATE:
+ if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE &&
+ !_event_multi_touch_get(event))
{
- result = EFL_GESTURE_IGNORE;
+ dist = efl_gesture_touch_distance(event, efl_gesture_touch_current_data_get(event)->id);
+ length = fabs(dist.x) + fabs(dist.y);
- if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
- !efl_gesture_touch_multi_touch_get(event))
+ if (length > pd->finger_size)
{
- dist = efl_gesture_touch_distance(event, 0);
- length = fabs(dist.x) + fabs(dist.y);
-
- if (length > rd->finger_size)
+ if (pd->timeout)
{
- if (pd->timeout)
- {
- ecore_timer_del(pd->timeout);
- pd->timeout = NULL;
- }
+ ecore_timer_del(pd->timeout);
+ pd->timeout = NULL;
+ }
- result = EFL_GESTURE_CANCEL;
+ result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
- pd->tap_count = 0;
- }
+ pd->tap_count = 0;
}
-
- break;
}
- case EFL_GESTURE_TOUCH_END:
- {
- if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
- !efl_gesture_touch_multi_touch_get(event))
- {
- dist = efl_gesture_touch_distance(event, 0);
- length = fabs(dist.x) + fabs(dist.y);
+ break;
+ }
- if (length <= rd->finger_size)
+ case EFL_GESTURE_TOUCH_STATE_END:
+ {
+ if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE &&
+ !_event_multi_touch_get(event))
+ {
+ if (efl_gesture_touch_previous_data_get(event))
+ {
+ Efl_Pointer_Action prev_act = efl_gesture_touch_previous_data_get(event)->action;
+ /* multi-touch */
+ if ((prev_act == EFL_POINTER_ACTION_UP) || (prev_act == EFL_POINTER_ACTION_CANCEL))
{
- pd->tap_count++;
- if (pd->tap_count == 1)
- {
- if (pd->timeout)
- ecore_timer_reset(pd->timeout);
-
- result = EFL_GESTURE_TRIGGER;
- }
- else
+ /* a second finger was pressed at the same time-ish as the first: combine into same event */
+ if (efl_gesture_touch_current_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
{
- if (pd->timeout)
- {
- ecore_timer_del(pd->timeout);
- pd->timeout = NULL;
- }
-
- if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_END)
- result = EFL_GESTURE_FINISH;
- else
- result = EFL_GESTURE_TRIGGER;
-
- pd->tap_count = 0;
+ result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ break;
}
}
+ }
+ dist = efl_gesture_touch_distance(event, efl_gesture_touch_current_data_get(event)->id);
+ length = fabs(dist.x) + fabs(dist.y);
+
+ if (length <= pd->finger_size)
+ {
+ pd->tap_count++;
+ if (pd->tap_count == 1)
+ {
+ if (pd->timeout)
+ ecore_timer_reset(pd->timeout);
+
+ result = EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
+ }
else
{
if (pd->timeout)
@@ -156,15 +162,31 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
pd->timeout = NULL;
}
- result = EFL_GESTURE_CANCEL;
+ if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_END)
+ result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
+ else
+ result = EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
pd->tap_count = 0;
}
}
+ else
+ {
+ if (pd->timeout)
+ {
+ ecore_timer_del(pd->timeout);
+ pd->timeout = NULL;
+ }
+
+ result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
- break;
+ pd->tap_count = 0;
+ }
}
+ break;
+ }
+
default:
break;
@@ -173,19 +195,4 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
return result;
}
-EOLIAN static double
-_efl_canvas_gesture_recognizer_double_tap_timeout_get(const Eo *obj EINA_UNUSED,
- Efl_Canvas_Gesture_Recognizer_Double_Tap_Data *pd)
-{
- return pd->start_timeout;
-}
-
-EOLIAN static void
-_efl_canvas_gesture_recognizer_double_tap_timeout_set(Eo *obj EINA_UNUSED,
- Efl_Canvas_Gesture_Recognizer_Double_Tap_Data *pd,
- double time)
-{
- pd->start_timeout = time;
-}
-
#include "efl_canvas_gesture_recognizer_double_tap.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_double_tap.eo b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_double_tap.eo
index de229b7147..e3118fdf99 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_double_tap.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_double_tap.eo
@@ -5,21 +5,9 @@ class @beta Efl.Canvas.Gesture_Recognizer_Double_Tap extends Efl.Canvas.Gesture_
For internal use only.
]]
c_prefix: efl_gesture_recognizer_double_tap;
- methods {
- @property timeout {
- [[Maximum time between taps to be recognized as a double tap.]]
- set {
- }
- get {
- }
- values {
- time: double; [[Time in seconds.]]
- }
- }
- }
implements {
Efl.Object.destructor;
- Efl.Canvas.Gesture_Recognizer.add;
+ Efl.Canvas.Gesture_Recognizer.type { get; }
Efl.Canvas.Gesture_Recognizer.recognize;
}
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.c
index 4968c61b34..962ed3ddda 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.c
@@ -1,19 +1,30 @@
#include "efl_canvas_gesture_private.h"
-#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_FLICK_CLASS
+#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_FLICK_CLASS
-#define MOMENTUM_TIMEOUT 50
-#define THUMBSCROLL_FRICTION 0.95
+#define MOMENTUM_TIMEOUT 50
+#define THUMBSCROLL_FRICTION 0.95
#define THUMBSCROLL_MOMENTUM_THRESHOLD 100.0
-#define EFL_GESTURE_MINIMUM_MOMENTUM 0.001
+#define EFL_GESTURE_MINIMUM_MOMENTUM 0.001
-#define RAD2DEG(x) ((x) * 57.295779513)
#define DEG2RAD(x) ((x) / 57.295779513)
-EOLIAN static Efl_Canvas_Gesture *
-_efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_add(Eo *obj, Efl_Canvas_Gesture_Recognizer_Flick_Data *pd EINA_UNUSED, Efl_Object *target EINA_UNUSED)
+#define memset do not use memset to reset flick data, use _reset_recognizer
+
+static void
+_reset_recognizer(Efl_Canvas_Gesture_Recognizer_Flick_Data *pd)
+{
+ pd->st_line = EINA_POSITION2D(0, 0);
+ pd->t_st = pd->t_end = 0;
+ pd->line_length = 0;
+ pd->line_angle = -1;
+ pd->touched = EINA_FALSE;
+}
+
+EOLIAN static const Efl_Class *
+_efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Flick_Data *pd EINA_UNUSED)
{
- return efl_add(EFL_CANVAS_GESTURE_FLICK_CLASS, obj);
+ return EFL_CANVAS_GESTURE_FLICK_CLASS;
}
static void
@@ -29,7 +40,7 @@ _momentum_set(Eo *obj,
Evas_Coord dy = v2.y - v1.y;
int dt = t2 - t1;
Eina_Value *tf, *tmt;
- double thumbscroll_friction, thumbscroll_momentum_threshold;
+ double thumbscroll_momentum_friction, thumbscroll_momentum_threshold;
if (dt > 0)
{
@@ -39,15 +50,15 @@ _momentum_set(Eo *obj,
vel = sqrt((velx * velx) + (vely * vely));
- tf = efl_gesture_recognizer_config_get(obj, "thumbscroll_friction");
- if (tf) eina_value_get(tf, &thumbscroll_friction);
- else thumbscroll_friction = THUMBSCROLL_FRICTION;
+ tf = _recognizer_config_get(obj, "thumbscroll_momentum_friction");
+ if (tf) eina_value_get(tf, &thumbscroll_momentum_friction);
+ else thumbscroll_momentum_friction = THUMBSCROLL_FRICTION;
- tmt = efl_gesture_recognizer_config_get(obj, "thumbscroll_momentum_threshold");
+ tmt = _recognizer_config_get(obj, "thumbscroll_momentum_threshold");
if (tmt) eina_value_get(tmt, &thumbscroll_momentum_threshold);
else thumbscroll_momentum_threshold = THUMBSCROLL_MOMENTUM_THRESHOLD;
- if ((thumbscroll_friction > 0.0) &&
+ if ((thumbscroll_momentum_friction > 0.0) &&
(vel > thumbscroll_momentum_threshold)) /* report
* momentum */
{
@@ -70,90 +81,38 @@ _single_line_process(Eo *obj,
{
switch (efl_gesture_touch_state_get(event))
{
- case EFL_GESTURE_TOUCH_BEGIN:
- case EFL_GESTURE_TOUCH_UPDATE:
- if (!pd->t_st)
- {
- pd->st_line = efl_gesture_touch_cur_point_get(event);
- pd->t_st = efl_gesture_touch_cur_timestamp_get(event);
-
- efl_gesture_hotspot_set(gesture, pd->st_line);
-
- return;
- }
-
- break;
-
- case EFL_GESTURE_TOUCH_END:
- {
- if (!pd->t_st) return;
-
- pd->t_end = efl_gesture_touch_cur_timestamp_get(event);
+ case EFL_GESTURE_TOUCH_STATE_BEGIN:
+ case EFL_GESTURE_TOUCH_STATE_UPDATE:
+ if (!pd->t_st)
+ {
+ pd->st_line = efl_gesture_touch_current_point_get(event);
+ pd->t_st = efl_gesture_touch_current_timestamp_get(event);
- break;
- }
+ efl_gesture_hotspot_set(gesture, pd->st_line);
- default:
+ return;
+ }
- return;
- }
+ break;
- _momentum_set(obj, fd, pd->st_line, efl_gesture_touch_cur_point_get(event),
- pd->t_st, efl_gesture_touch_cur_timestamp_get(event));
-}
+ case EFL_GESTURE_TOUCH_STATE_END:
+ {
+ if (!pd->t_st) return;
-static double
-_angle_get(Evas_Coord xx1,
- Evas_Coord yy1,
- Evas_Coord xx2,
- Evas_Coord yy2)
-{
- double a, xx, yy, rt = (-1);
+ pd->t_end = efl_gesture_touch_current_timestamp_get(event);
- xx = abs(xx2 - xx1);
- yy = abs(yy2 - yy1);
+ break;
+ }
- if (((int)xx) && ((int)yy))
- {
- rt = a = RAD2DEG(atan(yy / xx));
- if (xx1 < xx2)
- {
- if (yy1 < yy2) rt = 360 - a;
- else rt = a;
- }
- else
- {
- if (yy1 < yy2) rt = 180 + a;
- else rt = 180 - a;
- }
- }
+ default:
- if (rt < 0) /* Do this only if rt is not set */
- {
- if (((int)xx)) /* Horizontal line */
- {
- if (xx2 < xx1) rt = 180;
- else rt = 0.0;
- }
- else
- { /* Vertical line */
- if (yy2 < yy1) rt = 90;
- else rt = 270;
- }
+ return;
}
- /* Now we want to change from:
- * 90 0
- * original circle 180 0 We want: 270 90
- * 270 180
- */
- rt = 450 - rt;
- if (rt >= 360) rt -= 360;
-
- return rt;
+ _momentum_set(obj, fd, pd->st_line, efl_gesture_touch_current_point_get(event),
+ pd->t_st, efl_gesture_touch_current_timestamp_get(event));
}
-
static void
_vector_get(Eina_Position2D v1,
Eina_Position2D v2,
@@ -174,15 +133,17 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
Efl_Canvas_Gesture *gesture, Efl_Object *watched,
Efl_Canvas_Gesture_Touch *event)
{
- double angle;
+ double angle, line_angle;
Eina_Value *val;
unsigned char glayer_continues_enable;
- Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;
+ Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
Eina_Bool touch_up = EINA_FALSE;
+ int points = efl_gesture_touch_points_count_get(event);
Efl_Canvas_Gesture_Flick_Data *fd = efl_data_scope_get(gesture, EFL_CANVAS_GESTURE_FLICK_CLASS);
Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
+ Eina_Bool dead = EINA_FALSE;
- val = efl_gesture_recognizer_config_get(obj, "glayer_continues_enable");
+ val = _recognizer_config_get(obj, "glayer_continues_enable");
if (val) eina_value_get(val, &glayer_continues_enable);
else glayer_continues_enable = 1;
@@ -190,55 +151,88 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
//without mouse up.
//Recognizing the gesture again, even though it was canceled during gesture
//recognition.
- if (efl_gesture_state_get(gesture) == EFL_GESTURE_CANCELED)
- efl_gesture_state_set(gesture, EFL_GESTURE_NONE);
+ if (efl_gesture_state_get(gesture) == EFL_GESTURE_STATE_CANCELED)
+ efl_gesture_state_set(gesture, EFL_GESTURE_STATE_NONE);
- if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_END)
+ if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_END)
touch_up = EINA_TRUE;
//This is to handle a case with a mouse click on the target object.
- if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_END && !pd->touched)
- efl_gesture_manager_gesture_clean_up(rd->manager, watched, EFL_EVENT_GESTURE_FLICK);
+ if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_END && !pd->touched)
+ {
+ efl_gesture_manager_recognizer_cleanup(efl_provider_find(obj, EFL_CANVAS_GESTURE_MANAGER_CLASS), obj, watched);
+ dead = EINA_TRUE;
+ }
if (glayer_continues_enable && !pd->touched)
{
- pd->touched = EINA_TRUE;
- pd->line_angle = -1.0;
- rd->continues = EINA_TRUE;
-
- return EFL_GESTURE_IGNORE;
+ pd->touched = EINA_TRUE;
+ pd->line_angle = -1.0;
+ rd->continues = EINA_TRUE;
+ /* this has been deleted */
+ if (!dead)
+ fd->id = -1;
+
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+ if (pd->touched && (efl_gesture_touch_current_data_get(event)->action == EFL_POINTER_ACTION_DOWN))
+ {
+ /* a second finger was pressed at the same time-ish as the first: combine into same event */
+ if (efl_gesture_touch_current_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+ if (pd->t_st && (points > 1) && (fd->id != efl_gesture_touch_current_data_get(event)->id))
+ {
+ int xdir[2], ydir[2];
+ const Efl_Gesture_Touch_Point_Data *data = efl_gesture_touch_current_data_get(event);
+ const Efl_Gesture_Touch_Point_Data *data2;
+
+ if (fd->id == -1) return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ data2 = efl_gesture_touch_data_get(event, fd->id);
+ xdir[0] = _direction_get(data->prev.pos.x, data->cur.pos.x);
+ ydir[0] = _direction_get(data->prev.pos.y, data->cur.pos.y);
+ xdir[1] = _direction_get(data2->prev.pos.x, data2->cur.pos.x);
+ ydir[1] = _direction_get(data2->prev.pos.y, data2->cur.pos.y);
+ if ((xdir[0] != xdir[1]) || (ydir[0] != ydir[1]))
+ {
+ rd->continues = EINA_FALSE;
+ _reset_recognizer(pd);
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
}
_single_line_process(obj, pd, gesture, fd, event);
- _vector_get(pd->st_line, efl_gesture_touch_cur_point_get(event),
+ _vector_get(pd->st_line, efl_gesture_touch_current_point_get(event),
&pd->line_length, &angle);
+ line_angle = pd->line_angle;
if (pd->t_st)
{
- if (pd->line_angle >= 0.0)
+ if ((line_angle > 0.0) || EINA_DBL_EQ(line_angle, 0.0))
{
double line_distance_tolerance, line_angular_tolerance;
- double a = fabs(angle - pd->line_angle);
+ double a = fabs(angle - line_angle);
double d = (tan(DEG2RAD(a))) * pd->line_length;
- val = efl_gesture_recognizer_config_get(obj, "glayer_line_distance_tolerance");
+ val = _recognizer_config_get(obj, "glayer_line_distance_tolerance");
if (val) eina_value_get(val, &line_distance_tolerance);
else line_distance_tolerance = 3.0;
- line_distance_tolerance *= rd->finger_size;
+ line_distance_tolerance *= pd->finger_size;
- val = efl_gesture_recognizer_config_get(obj, "glayer_line_angular_tolerance");
+ val = _recognizer_config_get(obj, "glayer_line_angular_tolerance");
if (val) eina_value_get(val, &line_angular_tolerance);
else line_angular_tolerance = 20.0;
if ((d > line_distance_tolerance) ||
(a > line_angular_tolerance))
{
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Flick_Data));
+ _reset_recognizer(pd);
if (touch_up) rd->continues = EINA_FALSE;
- return EFL_GESTURE_CANCEL;
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
}
/* We may finish line if momentum is zero */
@@ -246,39 +240,38 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
{
/* This is for continues-gesture */
/* Finish line on zero momentum for continues gesture */
- if ((!fd->momentum.x) && (!fd->momentum.y))
- pd->t_end = efl_gesture_touch_cur_timestamp_get(event);
+ if (EINA_DBL_EQ(fd->momentum.x, 0) && EINA_DBL_EQ(fd->momentum.y, 0))
+ pd->t_end = efl_gesture_touch_current_timestamp_get(event);
}
}
else
{
double line_min_length;
- val = efl_gesture_recognizer_config_get(obj, "glayer_line_min_length");
+ val = _recognizer_config_get(obj, "glayer_line_min_length");
if (val) eina_value_get(val, &line_min_length);
else line_min_length = 1.0;
- line_min_length *= rd->finger_size;
+ line_min_length *= pd->finger_size;
if (pd->line_length >= line_min_length)
- fd->angle = pd->line_angle = angle;
-
+ line_angle = fd->angle = pd->line_angle = angle;
}
if (pd->t_end)
{
- if (pd->line_angle < 0.0)
+ if (line_angle < 0.0)
{
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Flick_Data));
+ _reset_recognizer(pd);
if (touch_up) rd->continues = EINA_FALSE;
- return EFL_GESTURE_CANCEL;
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
}
}
}
- unsigned int tm_end = efl_gesture_touch_cur_timestamp_get(event);
+ unsigned int tm_end = efl_gesture_touch_current_timestamp_get(event);
if (pd->t_end)
{
if (pd->t_end < tm_end)
@@ -286,62 +279,66 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
}
unsigned int time_limit_ms;
- val = efl_gesture_recognizer_config_get(obj, "glayer_flick_time_limit_ms");
+ val = _recognizer_config_get(obj, "glayer_flick_time_limit_ms");
if (val) eina_value_get(val, &time_limit_ms);
else time_limit_ms = 120;
if ((tm_end - pd->t_st) > time_limit_ms)
- {
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Flick_Data));
+ {
+ _reset_recognizer(pd);
- if (touch_up) rd->continues = EINA_FALSE;
+ if (touch_up) rd->continues = EINA_FALSE;
- return EFL_GESTURE_CANCEL;
- }
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
switch (efl_gesture_touch_state_get(event))
{
- case EFL_GESTURE_TOUCH_BEGIN:
- case EFL_GESTURE_TOUCH_UPDATE:
- {
- if (pd->t_st)
- {
- if (glayer_continues_enable && pd->t_end)
- {
- result = EFL_GESTURE_FINISH;
- }
- else
- {
- result = EFL_GESTURE_TRIGGER;
- }
- }
- break;
- }
-
- case EFL_GESTURE_TOUCH_END:
- {
- if (!pd->t_st)
- {
- pd->touched = EINA_FALSE;
- rd->continues = EINA_FALSE;
-
- return EFL_GESTURE_CANCEL;
- }
- if (pd->t_st && pd->t_end)
- {
- rd->continues = EINA_FALSE;
-
- result = EFL_GESTURE_FINISH;
- }
-
- efl_gesture_hotspot_set(gesture, efl_gesture_touch_cur_point_get(event));
-
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Flick_Data));
-
- rd->continues = EINA_FALSE;
-
- break;
- }
+ case EFL_GESTURE_TOUCH_STATE_BEGIN:
+ fd->id = efl_gesture_touch_current_data_get(event)->id;
+ EINA_FALLTHROUGH;
+ case EFL_GESTURE_TOUCH_STATE_UPDATE:
+ {
+ if (fd->id == -1)
+ fd->id = efl_gesture_touch_current_data_get(event)->id;
+ if (pd->t_st)
+ {
+ if (glayer_continues_enable && pd->t_end)
+ {
+ result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
+ }
+ else
+ {
+ result = EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
+ }
+ }
+ break;
+ }
+
+ case EFL_GESTURE_TOUCH_STATE_END:
+ {
+ if (!pd->t_st)
+ {
+ pd->touched = EINA_FALSE;
+ rd->continues = EINA_FALSE;
+
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
+ if (pd->t_st && pd->t_end)
+ {
+ rd->continues = EINA_FALSE;
+
+ result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
+ }
+
+ efl_gesture_hotspot_set(gesture, efl_gesture_touch_current_point_get(event));
+
+ _reset_recognizer(pd);
+
+ rd->continues = EINA_FALSE;
+
+ break;
+ }
default:
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.eo b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.eo
index 5f038f1a17..afb9cceb3e 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.eo
@@ -6,7 +6,7 @@ class @beta Efl.Canvas.Gesture_Recognizer_Flick extends Efl.Canvas.Gesture_Recog
]]
c_prefix: efl_gesture_recognizer_flick;
implements {
- Efl.Canvas.Gesture_Recognizer.add;
+ Efl.Canvas.Gesture_Recognizer.type { get; }
Efl.Canvas.Gesture_Recognizer.recognize;
}
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_press.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_press.c
new file mode 100644
index 0000000000..e146c5acaf
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_press.c
@@ -0,0 +1,143 @@
+#include "efl_canvas_gesture_private.h"
+
+#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_LONG_PRESS_CLASS
+
+#define EFL_GESTURE_LONG_PRESS_TIME_OUT 1.2
+
+EOLIAN static const Efl_Class *
+_efl_canvas_gesture_recognizer_long_press_efl_canvas_gesture_recognizer_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Long_Press_Data *pd EINA_UNUSED)
+{
+ return EFL_CANVAS_GESTURE_LONG_PRESS_CLASS;
+}
+
+EOLIAN static void
+_efl_canvas_gesture_recognizer_long_press_efl_object_destructor(Eo *obj,
+ Efl_Canvas_Gesture_Recognizer_Long_Press_Data *pd)
+{
+ if (pd->timeout)
+ ecore_timer_del(pd->timeout);
+
+ efl_destructor(efl_super(obj, MY_CLASS));
+}
+
+static Eina_Bool
+_long_press_timeout_cb(void *data)
+{
+ Efl_Canvas_Gesture_Recognizer_Long_Press_Data *pd = data;
+
+ /* FIXME: Needs to propagate this event back to evas! */
+ pd->is_timeout = EINA_TRUE;
+
+ efl_gesture_state_set(pd->gesture, EFL_GESTURE_STATE_UPDATED);
+ efl_event_callback_call(pd->target, EFL_EVENT_GESTURE_LONG_PRESS, pd->gesture);
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+EOLIAN static Efl_Canvas_Gesture_Recognizer_Result
+_efl_canvas_gesture_recognizer_long_press_efl_canvas_gesture_recognizer_recognize(Eo *obj,
+ Efl_Canvas_Gesture_Recognizer_Long_Press_Data *pd,
+ Efl_Canvas_Gesture *gesture,
+ Efl_Object *watched,
+ Efl_Canvas_Gesture_Touch *event)
+{
+ double length, start_timeout = pd->start_timeout; // Manhattan distance
+ double timeout = EFL_GESTURE_LONG_PRESS_TIME_OUT;
+ Eina_Position2D pos;
+ Eina_Vector2 dist;
+ Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+
+ pd->target = watched;
+ pd->gesture = gesture;
+
+ if (!EINA_DBL_NONZERO(start_timeout))
+ {
+ double time;
+ Eina_Value *val = _recognizer_config_get(obj, "glayer_long_tap_start_timeout");
+
+ if (val)
+ {
+ eina_value_get(val, &time);
+ pd->start_timeout = timeout = time;
+ }
+ }
+ else
+ timeout = start_timeout;
+
+ switch (efl_gesture_touch_state_get(event))
+ {
+ case EFL_GESTURE_TOUCH_STATE_BEGIN:
+ {
+ pos = efl_gesture_touch_start_point_get(event);
+ efl_gesture_hotspot_set(gesture, pos);
+
+ if (pd->timeout)
+ {
+ ecore_timer_del(pd->timeout);
+ }
+ pd->timeout = ecore_timer_add(timeout,
+ _long_press_timeout_cb, pd);
+
+ result = EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
+
+ break;
+ }
+
+ case EFL_GESTURE_TOUCH_STATE_UPDATE:
+ {
+ dist = efl_gesture_touch_distance(event, efl_gesture_touch_current_data_get(event)->id);
+ length = fabs(dist.x) + fabs(dist.y);
+
+ if ((_event_multi_touch_get(event)) || (length > pd->finger_size))
+ {
+ if (pd->timeout)
+ {
+ ecore_timer_del(pd->timeout);
+ pd->timeout = NULL;
+ }
+
+ result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
+ else
+ {
+ result = EFL_GESTURE_RECOGNIZER_RESULT_MAYBE;
+ }
+
+ break;
+ }
+
+ case EFL_GESTURE_TOUCH_STATE_END:
+ {
+ if (pd->timeout)
+ {
+ ecore_timer_del(pd->timeout);
+ pd->timeout = NULL;
+ }
+
+ if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE &&
+ !_event_multi_touch_get(event))
+ {
+ dist = efl_gesture_touch_distance(event, efl_gesture_touch_current_data_get(event)->id);
+ length = fabs(dist.x) + fabs(dist.y);
+ if (length <= pd->finger_size && pd->is_timeout)
+ {
+ result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
+ }
+ else
+ {
+ result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
+ }
+
+ break;
+ }
+
+ default:
+
+ break;
+ }
+
+ return result;
+}
+
+#include "efl_canvas_gesture_recognizer_long_press.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_press.eo b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_press.eo
new file mode 100644
index 0000000000..316b74d683
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_press.eo
@@ -0,0 +1,13 @@
+class @beta Efl.Canvas.Gesture_Recognizer_Long_Press extends Efl.Canvas.Gesture_Recognizer
+{
+ [[This is the recognizer for Long-tap gestures.
+ See @Efl.Canvas.Gesture_Long_Press and @Efl.Canvas.Gesture_Recognizer.
+ For internal use only.
+ ]]
+ c_prefix: efl_gesture_recognizer_long_press;
+ implements {
+ Efl.Object.destructor;
+ Efl.Canvas.Gesture_Recognizer.type { get; }
+ Efl.Canvas.Gesture_Recognizer.recognize;
+ }
+}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_tap.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_tap.c
deleted file mode 100644
index 8f6773588b..0000000000
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_tap.c
+++ /dev/null
@@ -1,176 +0,0 @@
-#include "efl_canvas_gesture_private.h"
-
-#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_LONG_TAP_CLASS
-
-#define EFL_GESTURE_LONG_TAP_TIME_OUT 1.2
-
-EOLIAN static Efl_Canvas_Gesture *
-_efl_canvas_gesture_recognizer_long_tap_efl_canvas_gesture_recognizer_add(Eo *obj,
- Efl_Canvas_Gesture_Recognizer_Long_Tap_Data *pd EINA_UNUSED,
- Efl_Object *target EINA_UNUSED)
-{
- return efl_add(EFL_CANVAS_GESTURE_LONG_TAP_CLASS, obj);
-}
-
-EOLIAN static void
-_efl_canvas_gesture_recognizer_long_tap_efl_object_destructor(Eo *obj,
- Efl_Canvas_Gesture_Recognizer_Long_Tap_Data *pd)
-{
- if (pd->timeout)
- ecore_timer_del(pd->timeout);
-
- efl_destructor(efl_super(obj, MY_CLASS));
-}
-
-static Eina_Bool
-_long_tap_timeout_cb(void *data)
-{
- Efl_Canvas_Gesture_Recognizer_Long_Tap_Data *pd = data;
-
- /* FIXME: Needs to propagate this event back to evas! */
- pd->is_timeout = EINA_TRUE;
-
- efl_gesture_state_set(pd->gesture, EFL_GESTURE_UPDATED);
- efl_event_callback_call(pd->target, EFL_EVENT_GESTURE_LONG_TAP, pd->gesture);
-
- return ECORE_CALLBACK_RENEW;
-}
-
-EOLIAN static Efl_Canvas_Gesture_Recognizer_Result
-_efl_canvas_gesture_recognizer_long_tap_efl_canvas_gesture_recognizer_recognize(Eo *obj,
- Efl_Canvas_Gesture_Recognizer_Long_Tap_Data *pd,
- Efl_Canvas_Gesture *gesture,
- Efl_Object *watched,
- Efl_Canvas_Gesture_Touch *event)
-{
- double length; // Manhattan distance
- double timeout = EFL_GESTURE_LONG_TAP_TIME_OUT;
- Eina_Position2D pos;
- Eina_Vector2 dist;
- Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;
- Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
-
- pd->target = watched;
- pd->gesture = gesture;
-
- if (!pd->start_timeout)
- {
- double time;
- Eina_Value *val = efl_gesture_recognizer_config_get(obj, "glayer_long_tap_start_timeout");
-
- if (val)
- {
- eina_value_get(val, &time);
- pd->start_timeout = timeout = time;
- }
- }
- else
- timeout = pd->start_timeout;
-
-
- switch (efl_gesture_touch_state_get(event))
- {
- case EFL_GESTURE_TOUCH_BEGIN:
- {
- pos = efl_gesture_touch_start_point_get(event);
- efl_gesture_hotspot_set(gesture, pos);
-
- if (pd->timeout)
- {
- ecore_timer_del(pd->timeout);
- }
- pd->timeout = ecore_timer_add(timeout,
- _long_tap_timeout_cb, pd);
-
- result = EFL_GESTURE_TRIGGER;
-
- break;
- }
-
- case EFL_GESTURE_TOUCH_UPDATE:
- {
- dist = efl_gesture_touch_distance(event, 0);
- length = fabs(dist.x) + fabs(dist.y);
-
- if ((efl_gesture_touch_multi_touch_get(event)) || (length > rd->finger_size))
- {
- if (pd->timeout)
- {
- ecore_timer_del(pd->timeout);
- pd->timeout = NULL;
- }
-
- result = EFL_GESTURE_CANCEL;
- }
- else
- {
- result = EFL_GESTURE_MAYBE;
- }
-
- break;
- }
-
- case EFL_GESTURE_TOUCH_END:
- {
- if (pd->timeout)
- {
- ecore_timer_del(pd->timeout);
- pd->timeout = NULL;
- }
-
- if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
- !efl_gesture_touch_multi_touch_get(event))
- {
- dist = efl_gesture_touch_distance(event, 0);
- length = fabs(dist.x) + fabs(dist.y);
- if (length <= rd->finger_size && pd->is_timeout)
- {
- result = EFL_GESTURE_FINISH;
- }
- else
- {
- result = EFL_GESTURE_CANCEL;
- }
- }
-
- break;
- }
-
- default:
-
- break;
- }
-
- return result;
-}
-
-EOLIAN static void
-_efl_canvas_gesture_recognizer_long_tap_efl_canvas_gesture_recognizer_reset(Eo *obj,
- Efl_Canvas_Gesture_Recognizer_Long_Tap_Data *pd,
- Efl_Canvas_Gesture *gesture)
-{
- if (pd->timeout)
- {
- ecore_timer_del(pd->timeout);
- pd->timeout = NULL;
- }
- pd->is_timeout = EINA_FALSE;
- efl_gesture_recognizer_reset(efl_super(obj, MY_CLASS), gesture);
-}
-
-EOLIAN static double
-_efl_canvas_gesture_recognizer_long_tap_timeout_get(const Eo *obj EINA_UNUSED,
- Efl_Canvas_Gesture_Recognizer_Long_Tap_Data *pd)
-{
- return pd->start_timeout;
-}
-
-EOLIAN static void
-_efl_canvas_gesture_recognizer_long_tap_timeout_set(Eo *obj EINA_UNUSED,
- Efl_Canvas_Gesture_Recognizer_Long_Tap_Data *pd,
- double time)
-{
- pd->start_timeout = time;
-}
-
-#include "efl_canvas_gesture_recognizer_long_tap.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_tap.eo b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_tap.eo
deleted file mode 100644
index d18d2c236f..0000000000
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_long_tap.eo
+++ /dev/null
@@ -1,26 +0,0 @@
-class @beta Efl.Canvas.Gesture_Recognizer_Long_Tap extends Efl.Canvas.Gesture_Recognizer
-{
- [[This is the recognizer for Long-tap gestures.
- See @Efl.Canvas.Gesture_Long_Tap and @Efl.Canvas.Gesture_Recognizer.
- For internal use only.
- ]]
- c_prefix: efl_gesture_recognizer_long_tap;
- methods {
- @property timeout {
- [[Minimum holding time to be recognized as a long tap.]]
- set {
- }
- get {
- }
- values {
- time: double; [[Time in seconds.]]
- }
- }
- }
- implements {
- Efl.Object.destructor;
- Efl.Canvas.Gesture_Recognizer.add;
- Efl.Canvas.Gesture_Recognizer.recognize;
- Efl.Canvas.Gesture_Recognizer.reset;
- }
-}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.c
index 2e007cc0f9..64afe22a2d 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.c
@@ -1,16 +1,16 @@
#include "efl_canvas_gesture_private.h"
-#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_MOMENTUM_CLASS
+#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_MOMENTUM_CLASS
-#define MOMENTUM_TIMEOUT 50
-#define THUMBSCROLL_FRICTION 0.95
+#define MOMENTUM_TIMEOUT 50
+#define THUMBSCROLL_FRICTION 0.95
#define THUMBSCROLL_MOMENTUM_THRESHOLD 100.0
-#define EFL_GESTURE_MINIMUM_MOMENTUM 0.001
+#define EFL_GESTURE_MINIMUM_MOMENTUM 0.001
-EOLIAN static Efl_Canvas_Gesture *
-_efl_canvas_gesture_recognizer_momentum_efl_canvas_gesture_recognizer_add(Eo *obj, Efl_Canvas_Gesture_Recognizer_Momentum_Data *pd EINA_UNUSED, Efl_Object *target EINA_UNUSED)
+EOLIAN static const Efl_Class *
+_efl_canvas_gesture_recognizer_momentum_efl_canvas_gesture_recognizer_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Momentum_Data *pd EINA_UNUSED)
{
- return efl_add(EFL_CANVAS_GESTURE_MOMENTUM_CLASS, obj);
+ return EFL_CANVAS_GESTURE_MOMENTUM_CLASS;
}
static void
@@ -26,25 +26,25 @@ _momentum_set(Eo *obj,
Evas_Coord dy = v2.y - v1.y;
int dt = t2 - t1;
Eina_Value *tf, *tmt;
- double thumbscroll_friction, thumbscroll_momentum_threshold;
+ double thumbscroll_momentum_friction, thumbscroll_momentum_threshold;
if (dt > 0)
{
velx = (dx * 1000) / dt;
vely = (dy * 1000) / dt;
- }
+ }
vel = sqrt((velx * velx) + (vely * vely));
- tf = efl_gesture_recognizer_config_get(obj, "thumbscroll_friction");
- if (tf) eina_value_get(tf, &thumbscroll_friction);
- else thumbscroll_friction = THUMBSCROLL_FRICTION;
+ tf = _recognizer_config_get(obj, "thumbscroll_momentum_friction");
+ if (tf) eina_value_get(tf, &thumbscroll_momentum_friction);
+ else thumbscroll_momentum_friction = THUMBSCROLL_FRICTION;
- tmt = efl_gesture_recognizer_config_get(obj, "thumbscroll_momentum_threshold");
+ tmt = _recognizer_config_get(obj, "thumbscroll_momentum_threshold");
if (tmt) eina_value_get(tmt, &thumbscroll_momentum_threshold);
else thumbscroll_momentum_threshold = THUMBSCROLL_MOMENTUM_THRESHOLD;
- if ((thumbscroll_friction > 0.0) &&
+ if ((thumbscroll_momentum_friction > 0.0) &&
(vel > thumbscroll_momentum_threshold)) /* report
* momentum */
{
@@ -58,28 +58,19 @@ _momentum_set(Eo *obj,
}
}
-static int
-_direction_get(Evas_Coord xx1,
- Evas_Coord xx2)
-{
- if (xx2 < xx1) return -1;
- if (xx2 > xx1) return 1;
-
- return 0;
-}
-
EOLIAN static Efl_Canvas_Gesture_Recognizer_Result
_efl_canvas_gesture_recognizer_momentum_efl_canvas_gesture_recognizer_recognize(Eo *obj,
- Efl_Canvas_Gesture_Recognizer_Momentum_Data *pd,
- Efl_Canvas_Gesture *gesture, Efl_Object *watched EINA_UNUSED,
- Efl_Canvas_Gesture_Touch *event)
+ Efl_Canvas_Gesture_Recognizer_Momentum_Data *pd,
+ Efl_Canvas_Gesture *gesture, Efl_Object *watched EINA_UNUSED,
+ Efl_Canvas_Gesture_Touch *event)
{
Eina_Value *val;
unsigned char glayer_continues_enable;
- Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;
+ Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
Efl_Canvas_Gesture_Momentum_Data *md = efl_data_scope_get(gesture, EFL_CANVAS_GESTURE_MOMENTUM_CLASS);
- val = efl_gesture_recognizer_config_get(obj, "glayer_continues_enable");
+ val = _recognizer_config_get(obj, "glayer_continues_enable");
if (val) eina_value_get(val, &glayer_continues_enable);
else glayer_continues_enable = 1;
@@ -87,104 +78,152 @@ _efl_canvas_gesture_recognizer_momentum_efl_canvas_gesture_recognizer_recognize(
//It does not have any meanging of this gesture.
if (glayer_continues_enable && !pd->touched)
{
- pd->touched = EINA_TRUE;
-
- return EFL_GESTURE_IGNORE;
- }
+ if (efl_gesture_touch_state_get(event) != EFL_GESTURE_TOUCH_STATE_END)
+ {
+ /* guard against successive multi-touch cancels */
+ if (efl_gesture_touch_points_count_get(event) == 1)
+ {
+ pd->touched = EINA_TRUE;
+ rd->continues = EINA_TRUE;
+ md->id = -1;
+ }
+ }
+
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+ if (pd->touched && (efl_gesture_touch_current_data_get(event)->action == EFL_POINTER_ACTION_DOWN))
+ {
+ /* a second finger was pressed at the same time-ish as the first: combine into same event */
+ if (efl_gesture_touch_points_count_get(event) > 1)
+ {
+ if (efl_gesture_touch_current_timestamp_get(event) - efl_gesture_touch_previous_data_get(event)->cur.timestamp < TAP_TOUCH_TIME_THRESHOLD)
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+ else if (efl_gesture_touch_current_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+ if (pd->t_st && (md->id != -1) && (md->id != efl_gesture_touch_current_data_get(event)->id))
+ {
+ int xdir, ydir;
+ const Efl_Gesture_Touch_Point_Data *data = efl_gesture_touch_current_data_get(event);
+ xdir = _direction_get(data->prev.pos.x, data->cur.pos.x);
+ ydir = _direction_get(data->prev.pos.y, data->cur.pos.y);
+ if ((xdir != pd->xdir) || (ydir != pd->ydir))
+ {
+ memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Momentum_Data));
+ rd->continues = EINA_FALSE;
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
switch (efl_gesture_touch_state_get(event))
{
- case EFL_GESTURE_TOUCH_BEGIN:
- case EFL_GESTURE_TOUCH_UPDATE:
- {
- if (!pd->t_st)
- {
- if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_BEGIN ||
- glayer_continues_enable)
- {
- pd->t_st = pd->t_end = efl_gesture_touch_cur_timestamp_get(event);
-
- pd->st_line = pd->end_line =
- efl_gesture_touch_start_point_get(event);
-
- efl_gesture_hotspot_set(gesture, pd->st_line);
-
- return EFL_GESTURE_TRIGGER;
- }
- }
-
- if ((efl_gesture_touch_cur_timestamp_get(event) - MOMENTUM_TIMEOUT) >
- pd->t_end)
- {
- pd->st_line = efl_gesture_touch_cur_point_get(event);
- pd->t_st = efl_gesture_touch_cur_timestamp_get(event);
- pd->xdir = pd->ydir = 0;
- }
- else
- {
- int xdir, ydir;
- Eina_Position2D cur_p = efl_gesture_touch_cur_point_get(event);
-
- xdir = _direction_get(pd->end_line.x, cur_p.x);
- ydir = _direction_get(pd->end_line.y, cur_p.y);
-
- if (xdir && (xdir != pd->xdir))
- {
- pd->st_line.x = pd->end_line.x;
- pd->t_st = pd->t_end;
- pd->xdir = xdir;
- }
-
- if (ydir && (ydir != pd->ydir))
- {
- pd->st_line.y = pd->end_line.y;
- pd->t_st = pd->t_end;
- pd->ydir = ydir;
- }
- }
-
- pd->end_line = efl_gesture_touch_cur_point_get(event);
- pd->t_end = efl_gesture_touch_cur_timestamp_get(event);
- efl_gesture_hotspot_set(gesture, pd->end_line);
-
- _momentum_set(obj, md, pd->st_line, efl_gesture_touch_cur_point_get(event),
- pd->t_st, efl_gesture_touch_cur_timestamp_get(event));
-
- result = EFL_GESTURE_TRIGGER;
-
- break;
- }
-
- case EFL_GESTURE_TOUCH_END:
- {
- if (!pd->t_st)
- {
- pd->touched = EINA_FALSE;
-
- return EFL_GESTURE_CANCEL;
- }
-
- if ((efl_gesture_touch_cur_timestamp_get(event) - MOMENTUM_TIMEOUT) > pd->t_end)
- {
- pd->st_line = efl_gesture_touch_cur_point_get(event);
- pd->t_st = efl_gesture_touch_cur_timestamp_get(event);
- pd->xdir = pd->ydir = 0;
- }
-
- pd->end_line = efl_gesture_touch_cur_point_get(event);
- pd->t_end = efl_gesture_touch_cur_timestamp_get(event);
- efl_gesture_hotspot_set(gesture, pd->end_line);
-
- if ((fabs(md->momentum.x) > EFL_GESTURE_MINIMUM_MOMENTUM) ||
- (fabs(md->momentum.y) > EFL_GESTURE_MINIMUM_MOMENTUM))
- result = EFL_GESTURE_FINISH;
- else
- result = EFL_GESTURE_CANCEL;
-
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Momentum_Data));
-
- break;
- }
+ case EFL_GESTURE_TOUCH_STATE_BEGIN:
+ case EFL_GESTURE_TOUCH_STATE_UPDATE:
+ {
+ if (!pd->t_st)
+ {
+ if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_BEGIN ||
+ glayer_continues_enable)
+ {
+
+ pd->t_st = pd->t_end = efl_gesture_touch_current_timestamp_get(event);
+
+ pd->st_line = pd->end_line =
+ efl_gesture_touch_start_point_get(event);
+
+ efl_gesture_hotspot_set(gesture, pd->st_line);
+ md->id = efl_gesture_touch_current_data_get(event)->id;
+ if (efl_gesture_touch_previous_data_get(event))
+ {
+ /* if multiple fingers are pressed simultaneously, start tracking the latest finger for gesture */
+ if (efl_gesture_touch_previous_data_get(event)->action == efl_gesture_touch_current_data_get(event)->action)
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+ return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
+ }
+ }
+
+ if ((efl_gesture_touch_current_timestamp_get(event) - MOMENTUM_TIMEOUT) >
+ pd->t_end)
+ {
+ pd->st_line = efl_gesture_touch_current_point_get(event);
+ pd->t_st = efl_gesture_touch_current_timestamp_get(event);
+ pd->xdir = pd->ydir = 0;
+ }
+ else
+ {
+ int xdir, ydir;
+ Eina_Position2D cur_p = efl_gesture_touch_current_point_get(event);
+
+ xdir = _direction_get(pd->end_line.x, cur_p.x);
+ ydir = _direction_get(pd->end_line.y, cur_p.y);
+
+ if (xdir && (xdir != pd->xdir))
+ {
+ pd->st_line.x = pd->end_line.x;
+ pd->t_st = pd->t_end;
+ pd->xdir = xdir;
+ }
+
+ if (ydir && (ydir != pd->ydir))
+ {
+ pd->st_line.y = pd->end_line.y;
+ pd->t_st = pd->t_end;
+ pd->ydir = ydir;
+ }
+ }
+
+ pd->end_line = efl_gesture_touch_current_point_get(event);
+ pd->t_end = efl_gesture_touch_current_timestamp_get(event);
+ efl_gesture_hotspot_set(gesture, pd->end_line);
+
+ _momentum_set(obj, md, pd->st_line, efl_gesture_touch_current_point_get(event),
+ pd->t_st, efl_gesture_touch_current_timestamp_get(event));
+
+ result = EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
+
+ break;
+ }
+
+ case EFL_GESTURE_TOUCH_STATE_END:
+ {
+ Eina_Bool touched = !!efl_gesture_touch_points_count_get(event);
+ if (!pd->t_st)
+ {
+ Eina_Bool prev_touched = pd->touched;
+
+ rd->continues = pd->touched = touched;
+
+ if (prev_touched)
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+
+ if ((efl_gesture_touch_current_timestamp_get(event) - MOMENTUM_TIMEOUT) > pd->t_end)
+ {
+ pd->st_line = efl_gesture_touch_current_point_get(event);
+ pd->t_st = efl_gesture_touch_current_timestamp_get(event);
+ pd->xdir = pd->ydir = 0;
+ }
+
+ pd->end_line = efl_gesture_touch_current_point_get(event);
+ pd->t_end = efl_gesture_touch_current_timestamp_get(event);
+ rd->continues = touched;
+ efl_gesture_hotspot_set(gesture, pd->end_line);
+
+ if ((fabs(md->momentum.x) > EFL_GESTURE_MINIMUM_MOMENTUM) ||
+ (fabs(md->momentum.y) > EFL_GESTURE_MINIMUM_MOMENTUM))
+ result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
+ else
+ result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+
+ memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Momentum_Data));
+ pd->touched = touched;
+
+ break;
+ }
default:
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.eo b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.eo
index 1713fb4f68..6093fbdcbd 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.eo
@@ -6,7 +6,7 @@ class @beta Efl.Canvas.Gesture_Recognizer_Momentum extends Efl.Canvas.Gesture_Re
]]
c_prefix: efl_gesture_recognizer_momentum;
implements {
- Efl.Canvas.Gesture_Recognizer.add;
+ Efl.Canvas.Gesture_Recognizer.type { get; }
Efl.Canvas.Gesture_Recognizer.recognize;
}
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_rotate.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_rotate.c
new file mode 100644
index 0000000000..97fa907767
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_rotate.c
@@ -0,0 +1,269 @@
+#include "efl_canvas_gesture_private.h"
+
+#define NEGATIVE_ANGLE (-1.0) /* Magic number */
+
+#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_ROTATE_CLASS
+
+static void
+_reset_recognizer(Efl_Canvas_Gesture_Recognizer_Rotate_Data *pd)
+{
+ memset(&pd->rotate_st, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ memset(&pd->rotate_st1, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ memset(&pd->rotate_mv, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ memset(&pd->rotate_mv1, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ pd->prev_momentum = 0;
+ pd->base_angle = 0;
+ pd->next_step = pd->accum_momentum = 0;
+}
+
+#define memset do not use memset to reset rotate data, use _reset_recognizer
+
+
+static void
+_rotate_properties_get(Efl_Canvas_Gesture_Recognizer_Rotate_Data *pd,
+ Efl_Canvas_Gesture_Rotate_Data *gd,
+ Evas_Coord xx1,
+ Evas_Coord yy1,
+ Evas_Coord xx2,
+ Evas_Coord yy2,
+ double *angle, Eina_Bool started)
+{
+ /* FIXME: Fix momentum computation, it's wrong */
+ double prev_angle = *angle;
+ int x, y;
+ gd->radius = _finger_gap_length_get(xx1, yy1, xx2, yy2, &x, &y) / 2;
+
+ *angle = _angle_get(xx1, yy1, xx2, yy2);
+
+ if (!started) /* Fingers are moving, compute momentum */
+ {
+ unsigned int tm_start =
+ (pd->rotate_st.cur.timestamp > pd->rotate_st1.cur.timestamp)
+ ? pd->rotate_st.cur.timestamp : pd->rotate_st1.cur.timestamp;
+ unsigned int tm_end =
+ (pd->rotate_mv.cur.timestamp > pd->rotate_mv1.cur.timestamp)
+ ? pd->rotate_mv.cur.timestamp : pd->rotate_mv1.cur.timestamp;
+
+ unsigned int tm_total = tm_end - tm_start;
+ if (tm_total) /* Momentum computed as:
+ accumulated rotation angle (deg) divided by time */
+ {
+ double m = 0;
+ if (((prev_angle < 90) && ((*angle) > 270)) ||
+ /* We circle passing ZERO point */
+ ((prev_angle > 270) && ((*angle) < 90)))
+ {
+ prev_angle = (*angle);
+ }
+ else m = prev_angle - (*angle);
+
+ pd->accum_momentum += m;
+
+ if ((tm_end - pd->prev_momentum_tm) < 100)
+ pd->prev_momentum += m;
+ else
+ {
+ if (fabs(pd->prev_momentum) < 0.002)
+ pd->accum_momentum = 0.0; /* reset momentum */
+
+ pd->prev_momentum = 0.0; /* Start again */
+ }
+
+ pd->prev_momentum_tm = tm_end;
+ gd->momentum = (pd->accum_momentum * 1000) / tm_total;
+ }
+ }
+ else
+ gd->momentum = 0;
+}
+
+static Eina_Bool
+_on_rotation_broke_tolerance(Efl_Canvas_Gesture_Recognizer_Rotate_Data *pd, Efl_Canvas_Gesture_Rotate_Data *gd)
+{
+ if (pd->base_angle < 0)
+ return EINA_FALSE; /* Angle has to be computed first */
+
+ if (pd->rotate_angular_tolerance < 0)
+ return EINA_TRUE;
+
+ double low = pd->base_angle - pd->rotate_angular_tolerance;
+ double high = pd->base_angle + pd->rotate_angular_tolerance;
+ double t = gd->angle;
+
+ if (low < 0)
+ {
+ low += 180;
+ high += 180;
+
+ if (t < 180)
+ t += 180;
+ else
+ t -= 180;
+ }
+
+ if (high > 360)
+ {
+ low -= 180;
+ high -= 180;
+
+ if (t < 180)
+ t += 180;
+ else
+ t -= 180;
+ }
+
+ if ((t < low) || (t > high)) /* This marks that rotation action has
+ * started */
+ {
+ pd->rotate_angular_tolerance = NEGATIVE_ANGLE;
+ pd->base_angle = gd->angle; /* Avoid jump in angle value */
+ return EINA_TRUE;
+ }
+
+ return EINA_FALSE;
+}
+
+EOLIAN static const Efl_Class *
+_efl_canvas_gesture_recognizer_rotate_efl_canvas_gesture_recognizer_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Rotate_Data *pd EINA_UNUSED)
+{
+ return EFL_CANVAS_GESTURE_ROTATE_CLASS;
+}
+
+EOLIAN static Efl_Canvas_Gesture_Recognizer_Result
+_efl_canvas_gesture_recognizer_rotate_efl_canvas_gesture_recognizer_recognize(Eo *obj,
+ Efl_Canvas_Gesture_Recognizer_Rotate_Data *pd,
+ Efl_Canvas_Gesture *gesture,
+ Efl_Object *watched,
+ Efl_Canvas_Gesture_Touch *event)
+{
+ Eina_Value *val;
+ unsigned char glayer_continues_enable;
+ Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ Efl_Canvas_Gesture_Rotate_Data *gd = efl_data_scope_get(gesture, EFL_CANVAS_GESTURE_ROTATE_CLASS);
+ Efl_Canvas_Gesture_Touch_Data *td = efl_data_scope_get(event, EFL_CANVAS_GESTURE_TOUCH_CLASS);
+ Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
+ const Efl_Gesture_Touch_Point_Data *p1 = efl_gesture_touch_data_get(event, 0);
+ const Efl_Gesture_Touch_Point_Data *p2 = efl_gesture_touch_data_get(event, 1);
+
+ //FIXME: Wheel rotate test first here.
+
+ val = _recognizer_config_get(obj, "glayer_continues_enable");
+ if (val) eina_value_get(val, &glayer_continues_enable);
+ else glayer_continues_enable = 1;
+
+ rd->continues = EINA_TRUE;
+
+ switch (efl_gesture_touch_state_get(event))
+ {
+ case EFL_GESTURE_TOUCH_STATE_UPDATE:
+ {
+ if ((!glayer_continues_enable) && (!pd->rotate_st.cur.timestamp))
+ {
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+ EINA_FALLTHROUGH;
+ }
+
+ case EFL_GESTURE_TOUCH_STATE_BEGIN:
+ {
+ if (td->touch_down > 2)
+ {
+ _reset_recognizer(pd);
+ if (efl_gesture_state_get(gesture) == EFL_GESTURE_STATE_CANCELED)
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
+ if (td->touch_down == 1)
+ {
+ return EFL_GESTURE_RECOGNIZER_RESULT_MAYBE;
+ }
+
+ if (!pd->rotate_st.cur.timestamp) /* Now scan touched-devices list
+ * and find other finger */
+ {
+ if (!_event_multi_touch_get(event))
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ pd->base_angle = NEGATIVE_ANGLE;
+ val = _recognizer_config_get(obj, "glayer_rotate_angular_tolerance");
+ if (val) eina_value_get(val, &pd->rotate_angular_tolerance);
+ else pd->rotate_angular_tolerance = 2.0;
+
+ memcpy(&pd->rotate_st, p2, sizeof(Efl_Gesture_Touch_Point_Data));
+ memcpy(&pd->rotate_st1, p1, sizeof(Efl_Gesture_Touch_Point_Data));
+
+ memcpy(&pd->rotate_mv, p2, sizeof(Efl_Gesture_Touch_Point_Data));
+ memcpy(&pd->rotate_mv1, p1, sizeof(Efl_Gesture_Touch_Point_Data));
+
+ _rotate_properties_get(pd, gd,
+ pd->rotate_st.cur.pos.x, pd->rotate_st.cur.pos.y,
+ pd->rotate_st1.cur.pos.x, pd->rotate_st1.cur.pos.y,
+ &pd->base_angle, EINA_TRUE);
+ if ((efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_STARTED) &&
+ (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_UPDATED))
+ return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
+
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
+
+ if (p2->id == pd->rotate_mv.id)
+ memcpy(&pd->rotate_mv, p2, sizeof(Efl_Gesture_Touch_Point_Data));
+ else if (p2->id == pd->rotate_mv1.id)
+ memcpy(&pd->rotate_mv1, p2, sizeof(Efl_Gesture_Touch_Point_Data));
+
+ _rotate_properties_get(pd, gd,
+ pd->rotate_mv.cur.pos.x, pd->rotate_mv.cur.pos.y,
+ pd->rotate_mv1.cur.pos.x, pd->rotate_mv1.cur.pos.y,
+ &gd->angle, EINA_FALSE);
+
+ if (_on_rotation_broke_tolerance(pd, gd)) /* Rotation broke
+ * tolerance, report
+ * move */
+ {
+ double d = gd->angle - pd->next_step;
+
+ if (d < 0.0) d = (-d);
+
+ if (d >= pd->rotate_step)
+ {
+ pd->next_step = gd->angle;
+
+ return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
+ }
+ }
+
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+
+ case EFL_GESTURE_TOUCH_STATE_END:
+ {
+ /* no gesture was started, so no gesture should be detected */
+ if ((td->touch_down == 0) || (!pd->rotate_st.cur.timestamp))
+ {
+ rd->continues = EINA_FALSE;
+
+ _reset_recognizer(pd);
+ efl_gesture_manager_recognizer_cleanup(efl_provider_find(obj, EFL_CANVAS_GESTURE_MANAGER_CLASS), obj, watched);
+
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+ _reset_recognizer(pd);
+ if (pd->rotate_angular_tolerance < 0)
+ {
+ return EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
+ }
+
+ if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE)
+ {
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
+ }
+
+ default:
+
+ break;
+ }
+
+ return result;
+}
+
+#include "efl_canvas_gesture_recognizer_rotate.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_rotate.eo b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_rotate.eo
new file mode 100644
index 0000000000..28291b3083
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_rotate.eo
@@ -0,0 +1,12 @@
+class @beta Efl.Canvas.Gesture_Recognizer_Rotate extends Efl.Canvas.Gesture_Recognizer
+{
+ [[This is the recognizer for Rotate gestures.
+ See @Efl.Canvas.Gesture_Rotate and @Efl.Canvas.Gesture_Recognizer.
+ For internal use only.
+ ]]
+ c_prefix: efl_gesture_recognizer_rotate;
+ implements {
+ Efl.Canvas.Gesture_Recognizer.type { get; }
+ Efl.Canvas.Gesture_Recognizer.recognize;
+ }
+}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_tap.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_tap.c
index 8f53a0585a..f4c28879cb 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_tap.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_tap.c
@@ -1,33 +1,31 @@
#include "efl_canvas_gesture_private.h"
-#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_TAP_CLASS
+#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_TAP_CLASS
//FIXME: It doesnt have matched config value.
// may using dobule tap timeout value?
-#define EFL_GESTURE_TAP_TIME_OUT 0.33
+#define EFL_GESTURE_RECOGNIZER_TYPE_TAP_TIME_OUT 0.33
-EOLIAN static Efl_Canvas_Gesture *
-_efl_canvas_gesture_recognizer_tap_efl_canvas_gesture_recognizer_add(Eo *obj,
- Efl_Canvas_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED,
- Efl_Object *target EINA_UNUSED)
+EOLIAN static const Efl_Class *
+_efl_canvas_gesture_recognizer_tap_efl_canvas_gesture_recognizer_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED)
{
- return efl_add(EFL_CANVAS_GESTURE_TAP_CLASS, obj);
+ return EFL_CANVAS_GESTURE_TAP_CLASS;
}
static Eina_Bool
_tap_timeout_cb(void *data)
{
Efl_Canvas_Gesture_Recognizer_Tap_Data *pd = data;
+ pd->timeout = NULL;
- efl_gesture_state_set(pd->gesture, EFL_GESTURE_CANCELED);
+ efl_gesture_state_set(pd->gesture, EFL_GESTURE_STATE_CANCELED);
efl_event_callback_call(pd->target, EFL_EVENT_GESTURE_TAP, pd->gesture);
return ECORE_CALLBACK_CANCEL;
}
-
EOLIAN static Efl_Canvas_Gesture_Recognizer_Result
-_efl_canvas_gesture_recognizer_tap_efl_canvas_gesture_recognizer_recognize(Eo *obj,
+_efl_canvas_gesture_recognizer_tap_efl_canvas_gesture_recognizer_recognize(Eo *obj EINA_UNUSED,
Efl_Canvas_Gesture_Recognizer_Tap_Data *pd,
Efl_Canvas_Gesture *gesture,
Efl_Object *watched,
@@ -36,53 +34,65 @@ _efl_canvas_gesture_recognizer_tap_efl_canvas_gesture_recognizer_recognize(Eo *o
double length;
Eina_Position2D pos;
Eina_Vector2 dist;
- Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;
- Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
+ Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
pd->target = watched;
pd->gesture = gesture;
switch (efl_gesture_touch_state_get(event))
{
- case EFL_GESTURE_TOUCH_BEGIN:
- {
- pos = efl_gesture_touch_start_point_get(event);
- efl_gesture_hotspot_set(gesture, pos);
-
- if (pd->timeout)
- ecore_timer_del(pd->timeout);
- pd->timeout = ecore_timer_add(EFL_GESTURE_TAP_TIME_OUT, _tap_timeout_cb, pd);
-
- result = EFL_GESTURE_TRIGGER;
-
- break;
- }
-
- case EFL_GESTURE_TOUCH_UPDATE:
- case EFL_GESTURE_TOUCH_END:
- {
- if (pd->timeout)
- {
- ecore_timer_del(pd->timeout);
- pd->timeout = NULL;
- }
-
- if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
- !efl_gesture_touch_multi_touch_get(event))
- {
- dist = efl_gesture_touch_distance(event, 0);
- length = fabs(dist.x) + fabs(dist.y);
- if (length <= rd->finger_size)
- {
- if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_END)
- result = EFL_GESTURE_FINISH;
- else
- result = EFL_GESTURE_TRIGGER;
- }
- }
-
- break;
- }
+ case EFL_GESTURE_TOUCH_STATE_BEGIN:
+ {
+new_tap:
+ pos = efl_gesture_touch_start_point_get(event);
+ efl_gesture_hotspot_set(gesture, pos);
+
+ if (pd->timeout)
+ ecore_timer_del(pd->timeout);
+ pd->timeout = ecore_timer_add(EFL_GESTURE_RECOGNIZER_TYPE_TAP_TIME_OUT, _tap_timeout_cb, pd);
+
+ result = EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
+
+ break;
+ }
+
+ case EFL_GESTURE_TOUCH_STATE_UPDATE:
+ /* multi-touch */
+ if (efl_gesture_touch_current_data_get(event)->action == EFL_POINTER_ACTION_DOWN)
+ {
+ /* a second finger was pressed at the same time-ish as the first: combine into same event */
+ if (efl_gesture_touch_current_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
+ {
+ result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ break;
+ }
+ /* another distinct touch occurred, treat this as a new touch */
+ goto new_tap;
+ }
+ EINA_FALLTHROUGH;
+ case EFL_GESTURE_TOUCH_STATE_END:
+ {
+ if (pd->timeout)
+ {
+ ecore_timer_del(pd->timeout);
+ pd->timeout = NULL;
+ }
+ if (_event_multi_touch_get(event)) return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE)
+ {
+ dist = efl_gesture_touch_distance(event, efl_gesture_touch_current_data_get(event)->id);
+ length = fabs(dist.x) + fabs(dist.y);
+ if (length <= pd->finger_size)
+ {
+ if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_END)
+ result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
+ else
+ result = EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
+ }
+ }
+
+ break;
+ }
default:
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_tap.eo b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_tap.eo
index 26aeb83a4d..b951013c2a 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_tap.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_tap.eo
@@ -6,7 +6,7 @@ class @beta Efl.Canvas.Gesture_Recognizer_Tap extends Efl.Canvas.Gesture_Recogni
]]
c_prefix: efl_gesture_recognizer_tap;
implements {
- Efl.Canvas.Gesture_Recognizer.add;
+ Efl.Canvas.Gesture_Recognizer.type { get; }
Efl.Canvas.Gesture_Recognizer.recognize;
}
}
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
index cd54d45886..75cb3686b4 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.c
@@ -1,13 +1,13 @@
#include "efl_canvas_gesture_private.h"
-#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_TRIPLE_TAP_CLASS
+#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_TRIPLE_TAP_CLASS
#define TAP_TIME_OUT 0.33
-EOLIAN static Efl_Canvas_Gesture *
-_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)
+EOLIAN static const Efl_Class *
+_efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *pd EINA_UNUSED)
{
- return efl_add(EFL_CANVAS_GESTURE_TRIPLE_TAP_CLASS, obj);
+ return EFL_CANVAS_GESTURE_TRIPLE_TAP_CLASS;
}
EOLIAN static void
@@ -23,16 +23,14 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_object_destructor(Eo *obj,
static Eina_Bool
_tap_timeout_cb(void *data)
{
- Efl_Canvas_Gesture_Recognizer_Data *rd;
Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *pd;
- rd = efl_data_scope_get(data, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
pd = efl_data_scope_get(data, EFL_CANVAS_GESTURE_RECOGNIZER_TRIPLE_TAP_CLASS);
- efl_gesture_state_set(pd->gesture, EFL_GESTURE_CANCELED);
+ efl_gesture_state_set(pd->gesture, EFL_GESTURE_STATE_CANCELED);
efl_event_callback_call(pd->target, EFL_EVENT_GESTURE_TRIPLE_TAP, pd->gesture);
- efl_gesture_manager_gesture_clean_up(rd->manager, pd->target, EFL_EVENT_GESTURE_TRIPLE_TAP);
+ efl_gesture_manager_recognizer_cleanup(efl_provider_find(data, EFL_CANVAS_GESTURE_MANAGER_CLASS), data, pd->target);
pd->timeout = NULL;
pd->tap_count = 0;
@@ -46,20 +44,19 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
Efl_Canvas_Gesture *gesture, Efl_Object *watched,
Efl_Canvas_Gesture_Touch *event)
{
- double length;
+ double length, start_timeout = pd->start_timeout;
double timeout = TAP_TIME_OUT;
Eina_Position2D pos;
Eina_Vector2 dist;
- Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;
- Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
+ Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
pd->target = watched;
pd->gesture = gesture;
- if (!pd->start_timeout)
+ if (!EINA_DBL_NONZERO(start_timeout))
{
double time;
- Eina_Value *val = efl_gesture_recognizer_config_get(obj, "glayer_doublee_tap_timeout");
+ Eina_Value *val = _recognizer_config_get(obj, "glayer_double_tap_timeout");
if (val)
{
@@ -68,86 +65,94 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
}
}
else
- timeout = pd->start_timeout;
+ timeout = start_timeout;
switch (efl_gesture_touch_state_get(event))
{
- case EFL_GESTURE_TOUCH_BEGIN:
- {
- pos = efl_gesture_touch_start_point_get(event);
- efl_gesture_hotspot_set(gesture, pos);
+ case EFL_GESTURE_TOUCH_STATE_BEGIN:
+ {
+ pos = efl_gesture_touch_start_point_get(event);
+ efl_gesture_hotspot_set(gesture, pos);
- if (pd->timeout)
- ecore_timer_reset(pd->timeout);
- else
- pd->timeout = ecore_timer_add(timeout, _tap_timeout_cb, obj);
+ if (pd->timeout)
+ ecore_timer_reset(pd->timeout);
+ else
+ pd->timeout = ecore_timer_add(timeout, _tap_timeout_cb, obj);
- result = EFL_GESTURE_TRIGGER;
+ result = EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
- break;
- }
+ break;
+ }
+
+ case EFL_GESTURE_TOUCH_STATE_UPDATE:
+ {
+ /* multi-touch */
+ if (efl_gesture_touch_current_data_get(event)->action == EFL_POINTER_ACTION_DOWN)
+ {
+ /* a second finger was pressed at the same time-ish as the first: combine into same event */
+ if (efl_gesture_touch_current_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
+ {
+ result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ break;
+ }
+ }
+ result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
- case EFL_GESTURE_TOUCH_UPDATE:
+ if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE &&
+ !_event_multi_touch_get(event))
{
- result = EFL_GESTURE_IGNORE;
+ dist = efl_gesture_touch_distance(event, efl_gesture_touch_current_data_get(event)->id);
+ length = fabs(dist.x) + fabs(dist.y);
- if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
- !efl_gesture_touch_multi_touch_get(event))
+ if (length > pd->finger_size)
{
- dist = efl_gesture_touch_distance(event, 0);
- length = fabs(dist.x) + fabs(dist.y);
-
- if (length > rd->finger_size)
+ if (pd->timeout)
{
- if (pd->timeout)
- {
- ecore_timer_del(pd->timeout);
- pd->timeout = NULL;
- }
+ ecore_timer_del(pd->timeout);
+ pd->timeout = NULL;
+ }
- result = EFL_GESTURE_CANCEL;
+ result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
- pd->tap_count = 0;
- }
+ pd->tap_count = 0;
}
-
- break;
}
- case EFL_GESTURE_TOUCH_END:
- {
- if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
- !efl_gesture_touch_multi_touch_get(event))
- {
- dist = efl_gesture_touch_distance(event, 0);
- length = fabs(dist.x) + fabs(dist.y);
+ break;
+ }
- if (length <= rd->finger_size)
+ case EFL_GESTURE_TOUCH_STATE_END:
+ {
+ if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE &&
+ !_event_multi_touch_get(event))
+ {
+ if (efl_gesture_touch_previous_data_get(event))
+ {
+ Efl_Pointer_Action prev_act = efl_gesture_touch_previous_data_get(event)->action;
+ /* multi-touch */
+ if ((prev_act == EFL_POINTER_ACTION_UP) || (prev_act == EFL_POINTER_ACTION_CANCEL))
{
- pd->tap_count++;
- if (pd->tap_count < 3)
- {
- if (pd->timeout)
- ecore_timer_reset(pd->timeout);
-
- result = EFL_GESTURE_TRIGGER;
- }
- else
+ /* a second finger was pressed at the same time-ish as the first: combine into same event */
+ if (efl_gesture_touch_current_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
{
- if (pd->timeout)
- {
- ecore_timer_del(pd->timeout);
- pd->timeout = NULL;
- }
-
- if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_END)
- result = EFL_GESTURE_FINISH;
- else
- result = EFL_GESTURE_TRIGGER;
-
- pd->tap_count = 0;
+ result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ break;
}
}
+ }
+ dist = efl_gesture_touch_distance(event, efl_gesture_touch_current_data_get(event)->id);
+ length = fabs(dist.x) + fabs(dist.y);
+
+ if (length <= pd->finger_size)
+ {
+ pd->tap_count++;
+ if (pd->tap_count < 3)
+ {
+ if (pd->timeout)
+ ecore_timer_reset(pd->timeout);
+
+ result = EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
+ }
else
{
if (pd->timeout)
@@ -156,15 +161,31 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
pd->timeout = NULL;
}
- result = EFL_GESTURE_CANCEL;
+ if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_END)
+ result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
+ else
+ result = EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
pd->tap_count = 0;
}
}
+ else
+ {
+ if (pd->timeout)
+ {
+ ecore_timer_del(pd->timeout);
+ pd->timeout = NULL;
+ }
+
+ result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
- break;
+ pd->tap_count = 0;
+ }
}
+ break;
+ }
+
default:
break;
@@ -173,19 +194,4 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
return result;
}
-EOLIAN static double
-_efl_canvas_gesture_recognizer_triple_tap_timeout_get(const Eo *obj EINA_UNUSED,
- Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *pd)
-{
- return pd->start_timeout;
-}
-
-EOLIAN static void
-_efl_canvas_gesture_recognizer_triple_tap_timeout_set(Eo *obj EINA_UNUSED,
- Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *pd,
- double time)
-{
- pd->start_timeout = time;
-}
-
#include "efl_canvas_gesture_recognizer_triple_tap.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.eo b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.eo
index 99458938fa..baf2d71457 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_triple_tap.eo
@@ -5,21 +5,9 @@ class @beta Efl.Canvas.Gesture_Recognizer_Triple_Tap extends Efl.Canvas.Gesture_
For internal use only.
]]
c_prefix: efl_gesture_recognizer_triple_tap;
- methods {
- @property timeout {
- [[Minimum time between each consecutive tap to be recognized as a triple tap.]]
- set {
- }
- get {
- }
- values {
- time: double; [[Time in seconds.]]
- }
- }
- }
implements {
Efl.Object.destructor;
- Efl.Canvas.Gesture_Recognizer.add;
+ Efl.Canvas.Gesture_Recognizer.type { get; }
Efl.Canvas.Gesture_Recognizer.recognize;
}
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.c
index 0bd41f55b6..0a1d2e9a20 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.c
@@ -2,57 +2,20 @@
#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_ZOOM_CLASS
-static Evas_Coord
-_finger_gap_length_get(Evas_Coord xx1,
- Evas_Coord yy1,
- Evas_Coord xx2,
- Evas_Coord yy2,
- Evas_Coord *x,
- Evas_Coord *y)
+static void
+_reset_recognizer(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd)
{
- double a, b, xx, yy, gap;
- xx = abs(xx2 - xx1);
- yy = abs(yy2 - yy1);
- gap = sqrt((xx * xx) + (yy * yy));
-
- /* START - Compute zoom center point */
- /* The triangle defined as follows:
- * B
- * / |
- * / |
- * gap / | a
- * / |
- * A-----C
- * b
- * http://en.wikipedia.org/wiki/Trigonometric_functions
- *************************************/
- if (((int)xx) && ((int)yy))
- {
- double A = atan((yy / xx));
- a = (Evas_Coord)((gap / 2) * sin(A));
- b = (Evas_Coord)((gap / 2) * cos(A));
- *x = (Evas_Coord)((xx2 > xx1) ? (xx1 + b) : (xx2 + b));
- *y = (Evas_Coord)((yy2 > yy1) ? (yy1 + a) : (yy2 + a));
- }
- else
- {
- if ((int)xx) /* horiz line, take half width */
- {
- *x = (Evas_Coord)((xx1 + xx2) / 2);
- *y = (Evas_Coord)(yy1);
- }
-
- if ((int)yy) /* vert line, take half width */
- {
- *x = (Evas_Coord)(xx1);
- *y = (Evas_Coord)((yy1 + yy2) / 2);
- }
- }
- /* END - Compute zoom center point */
-
- return (Evas_Coord)gap;
+ memset(&pd->zoom_st, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ memset(&pd->zoom_st1, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ memset(&pd->zoom_mv, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ memset(&pd->zoom_mv1, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ pd->zoom_base = 0;
+ pd->zoom_step = pd->next_step = pd->zoom_finger_factor = pd->zoom_distance_tolerance = 0;
+ pd->calc_temp = EINA_FALSE;
}
+#define memset do not use memset to reset zoom data, use _reset_recognizer
+
static double
_zoom_compute(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd,
Efl_Canvas_Gesture_Zoom_Data *zd,
@@ -62,12 +25,12 @@ _zoom_compute(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd,
Evas_Coord yy2,
double zoom_finger_factor)
{
- double rt = 1.0;
+ double rt = 1.0, zoom_distance_tolerance = pd->zoom_distance_tolerance;
//TODO: Enable below code if the zoom momentum is need
//unsigned int tm_end = (pd->zoom_mv.cur.timestamp > pd->zoom_mv1.cur.timestamp) ?
// pd->zoom_mv.cur.timestamp : pd->zoom_mv1.cur.timestamp;
- int x,y; //Hot spot
+ int x, y; //Hot spot
Evas_Coord diam = _finger_gap_length_get(xx1, yy1, xx2, yy2,
&x, &y);
@@ -79,8 +42,8 @@ _zoom_compute(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd,
return zd->zoom;
}
- if (pd->zoom_distance_tolerance) /* zoom tolerance <> ZERO, means
- * zoom action NOT started yet */
+ if (EINA_DBL_NONZERO(zoom_distance_tolerance)) /* zoom tolerance <> ZERO, means
+ * zoom action NOT started yet */
{
/* avoid jump with zoom value when break tolerance */
if (diam < (pd->zoom_base - pd->zoom_distance_tolerance))
@@ -111,12 +74,10 @@ _zoom_compute(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd,
return rt;
}
-EOLIAN static Efl_Canvas_Gesture *
-_efl_canvas_gesture_recognizer_zoom_efl_canvas_gesture_recognizer_add(Eo *obj,
- Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd EINA_UNUSED,
- Efl_Object *target EINA_UNUSED)
+EOLIAN static const Efl_Class *
+_efl_canvas_gesture_recognizer_zoom_efl_canvas_gesture_recognizer_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd EINA_UNUSED)
{
- return efl_add(EFL_CANVAS_GESTURE_ZOOM_CLASS, obj);
+ return EFL_CANVAS_GESTURE_ZOOM_CLASS;
}
EOLIAN static Efl_Canvas_Gesture_Recognizer_Result
@@ -126,147 +87,155 @@ _efl_canvas_gesture_recognizer_zoom_efl_canvas_gesture_recognizer_recognize(Eo *
Efl_Object *watched,
Efl_Canvas_Gesture_Touch *event)
{
- int id1 = 0;
- int id2 = 1;
Eina_Value *val;
unsigned char zoom_finger_enable;
unsigned char glayer_continues_enable;
- Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;
+ Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
Efl_Canvas_Gesture_Zoom_Data *zd = efl_data_scope_get(gesture, EFL_CANVAS_GESTURE_ZOOM_CLASS);
Efl_Canvas_Gesture_Touch_Data *td = efl_data_scope_get(event, EFL_CANVAS_GESTURE_TOUCH_CLASS);
Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
+ double zoom_distance_tolerance = pd->zoom_distance_tolerance;
//FIXME: Wheel zoom test first here.
- val = efl_gesture_recognizer_config_get(obj, "glayer_continues_enable");
+ val = _recognizer_config_get(obj, "glayer_continues_enable");
if (val) eina_value_get(val, &glayer_continues_enable);
else glayer_continues_enable = 1;
- val = efl_gesture_recognizer_config_get(obj, "glayer_zoom_finger_enable");
+ val = _recognizer_config_get(obj, "glayer_zoom_finger_enable");
if (val) eina_value_get(val, &zoom_finger_enable);
else zoom_finger_enable = 1;
- val = efl_gesture_recognizer_config_get(obj, "glayer_zoom_finger_factor");
- if (val) eina_value_get(val, &pd->zoom_finger_factor);
+ val = _recognizer_config_get(obj, "glayer_zoom_finger_factor");
+ if (val) eina_value_get(val, &pd->zoom_finger_factor);
else pd->zoom_finger_factor = 1.0;
rd->continues = EINA_TRUE;
- if (!pd->zoom_distance_tolerance && !pd->calc_temp)
+ if (!EINA_DBL_NONZERO(zoom_distance_tolerance) && !pd->calc_temp)
{
pd->calc_temp = EINA_TRUE;
- val = efl_gesture_recognizer_config_get(obj, "glayer_zoom_distance_tolerance");
- if (val) eina_value_get(val, &pd->zoom_distance_tolerance);
+ val = _recognizer_config_get(obj, "glayer_zoom_distance_tolerance");
+ if (val) eina_value_get(val, &pd->zoom_distance_tolerance);
else pd->zoom_distance_tolerance = 1.0;
- pd->zoom_distance_tolerance *= rd->finger_size;
+ pd->zoom_distance_tolerance *= pd->finger_size;
}
switch (efl_gesture_touch_state_get(event))
{
- case EFL_GESTURE_TOUCH_UPDATE:
- {
- if ((!glayer_continues_enable) && (!pd->zoom_st.cur.timestamp))
- {
- return EFL_GESTURE_IGNORE;
- }
- EINA_FALLTHROUGH;
- }
- case EFL_GESTURE_TOUCH_BEGIN:
- {
- if (td->touch_down > 2)
- {
- return EFL_GESTURE_CANCEL;
- }
-
- if (!pd->zoom_st.cur.timestamp) /* Now scan touched-devices list
+ case EFL_GESTURE_TOUCH_STATE_UPDATE:
+ {
+ if ((!glayer_continues_enable) && (!pd->zoom_st.cur.timestamp))
+ {
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+ EINA_FALLTHROUGH;
+ }
+
+ case EFL_GESTURE_TOUCH_STATE_BEGIN:
+ {
+ if (td->touch_down > 2)
+ {
+ _reset_recognizer(pd);
+ if (efl_gesture_state_get(gesture) == EFL_GESTURE_STATE_CANCELED)
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
+ if (td->touch_down == 1)
+ {
+ return EFL_GESTURE_RECOGNIZER_RESULT_MAYBE;
+ }
+
+ if (!pd->zoom_st.cur.timestamp) /* Now scan touched-devices list
* and find other finger */
- {
- if (!efl_gesture_touch_multi_touch_get(event))
- return EFL_GESTURE_IGNORE;
+ {
+ if (!_event_multi_touch_get(event))
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
- Pointer_Data *p1 = eina_hash_find(td->touch_points, &id1);
- Pointer_Data *p2 = eina_hash_find(td->touch_points, &id2);
+ const Efl_Gesture_Touch_Point_Data *p1 = efl_gesture_touch_data_get(event, 0);
+ const Efl_Gesture_Touch_Point_Data *p2 = efl_gesture_touch_data_get(event, 1);
- memcpy(&pd->zoom_st, p2, sizeof(Pointer_Data));
- memcpy(&pd->zoom_st1, p1, sizeof(Pointer_Data));
+ memcpy(&pd->zoom_st, p2, sizeof(Efl_Gesture_Touch_Point_Data));
+ memcpy(&pd->zoom_st1, p1, sizeof(Efl_Gesture_Touch_Point_Data));
- memcpy(&pd->zoom_mv, p2, sizeof(Pointer_Data));
- memcpy(&pd->zoom_mv1, p1, sizeof(Pointer_Data));
+ memcpy(&pd->zoom_mv, p2, sizeof(Efl_Gesture_Touch_Point_Data));
+ memcpy(&pd->zoom_mv1, p1, sizeof(Efl_Gesture_Touch_Point_Data));
- int x,y; //Hot spot
- zd->zoom = 1.0;
- pd->zoom_base = _finger_gap_length_get(pd->zoom_st1.cur.pos.x,
- pd->zoom_st1.cur.pos.y,
- pd->zoom_st.cur.pos.x,
- pd->zoom_st.cur.pos.y,
- &x, &y);
+ int x, y; //Hot spot
+ zd->zoom = 1.0;
+ pd->zoom_base = _finger_gap_length_get(pd->zoom_st1.cur.pos.x,
+ pd->zoom_st1.cur.pos.y,
+ pd->zoom_st.cur.pos.x,
+ pd->zoom_st.cur.pos.y,
+ &x, &y);
- zd->radius = pd->zoom_base / 2.0;
+ zd->radius = pd->zoom_base / 2.0;
- if ((efl_gesture_state_get(gesture) != EFL_GESTURE_STARTED) &&
- (efl_gesture_state_get(gesture) != EFL_GESTURE_UPDATED))
- return EFL_GESTURE_TRIGGER;
+ if ((efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_STARTED) &&
+ (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_UPDATED))
+ return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
- return EFL_GESTURE_CANCEL;
- }
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
- Pointer_Data *p2 = eina_hash_find(td->touch_points, &id2);
- if (p2->id == pd->zoom_mv.id)
- memcpy(&pd->zoom_mv, p2, sizeof(Pointer_Data));
- else if (p2->id == pd->zoom_mv1.id)
- memcpy(&pd->zoom_mv1, p2, sizeof(Pointer_Data));
+ const Efl_Gesture_Touch_Point_Data *p2 = efl_gesture_touch_data_get(event, 1);
+ if (p2->id == pd->zoom_mv.id)
+ memcpy(&pd->zoom_mv, p2, sizeof(Efl_Gesture_Touch_Point_Data));
+ else if (p2->id == pd->zoom_mv1.id)
+ memcpy(&pd->zoom_mv1, p2, sizeof(Efl_Gesture_Touch_Point_Data));
- zd->zoom = _zoom_compute(pd, zd, pd->zoom_mv.cur.pos.x,
- pd->zoom_mv.cur.pos.y, pd->zoom_mv1.cur.pos.x,
- pd->zoom_mv1.cur.pos.y, pd->zoom_finger_factor);
+ zd->zoom = _zoom_compute(pd, zd, pd->zoom_mv.cur.pos.x,
+ pd->zoom_mv.cur.pos.y, pd->zoom_mv1.cur.pos.x,
+ pd->zoom_mv1.cur.pos.y, pd->zoom_finger_factor);
+ if (!EINA_DBL_NONZERO(zoom_distance_tolerance))
+ {
+ double d = zd->zoom - pd->next_step;
- if (!pd->zoom_distance_tolerance)
- {
- double d = zd->zoom - pd->next_step;
+ if (d < 0.0) d = (-d);
- if (d < 0.0) d = (-d);
+ if (d >= pd->zoom_step)
+ {
+ pd->next_step = zd->zoom;
- if (d >= pd->zoom_step)
- {
- pd->next_step = zd->zoom;
+ return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
+ }
+ }
- return EFL_GESTURE_TRIGGER;
- }
- }
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
- return EFL_GESTURE_IGNORE;
- }
- case EFL_GESTURE_TOUCH_END:
- {
- if (td->touch_down == 0)
- {
- rd->continues = EINA_FALSE;
+ case EFL_GESTURE_TOUCH_STATE_END:
+ {
+ /* no gesture was started, so no gesture should be detected */
+ if ((td->touch_down == 0) || (!pd->zoom_st.cur.timestamp))
+ {
+ rd->continues = EINA_FALSE;
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Zoom_Data));
- efl_gesture_manager_gesture_clean_up(rd->manager, watched, EFL_EVENT_GESTURE_ZOOM);
+ _reset_recognizer(pd);
+ efl_gesture_manager_recognizer_cleanup(efl_provider_find(obj, EFL_CANVAS_GESTURE_MANAGER_CLASS), obj, watched);
- return EFL_GESTURE_IGNORE;
- }
- if ((pd->zoom_base) && (pd->zoom_distance_tolerance == 0))
- {
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Zoom_Data));
+ return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
+ }
+ if ((pd->zoom_base) && EINA_DBL_EQ(pd->zoom_distance_tolerance, 0))
+ {
+ _reset_recognizer(pd);
- return EFL_GESTURE_FINISH;
- }
+ return EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
+ }
- if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE)
- {
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Zoom_Data));
+ if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE)
+ {
+ _reset_recognizer(pd);
- return EFL_GESTURE_CANCEL;
- }
- }
+ return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
+ }
+ }
default:
- break;
+ break;
}
return result;
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.eo b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.eo
index a07e112d87..8ada83abb3 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.eo
@@ -6,7 +6,7 @@ class @beta Efl.Canvas.Gesture_Recognizer_Zoom extends Efl.Canvas.Gesture_Recogn
]]
c_prefix: efl_gesture_recognizer_zoom;
implements {
- Efl.Canvas.Gesture_Recognizer.add;
+ Efl.Canvas.Gesture_Recognizer.type { get; }
Efl.Canvas.Gesture_Recognizer.recognize;
}
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_rotate.c b/src/lib/evas/gesture/efl_canvas_gesture_rotate.c
new file mode 100644
index 0000000000..77351236f8
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_rotate.c
@@ -0,0 +1,17 @@
+#include "efl_canvas_gesture_private.h"
+
+#define MY_CLASS EFL_CANVAS_GESTURE_ROTATE_CLASS
+
+EOLIAN static unsigned int
+_efl_canvas_gesture_rotate_radius_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Rotate_Data *pd)
+{
+ return pd->radius;
+}
+
+EOLIAN static double
+_efl_canvas_gesture_rotate_angle_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Rotate_Data *pd)
+{
+ return pd->angle;
+}
+
+#include "efl_canvas_gesture_rotate.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_rotate.eo b/src/lib/evas/gesture/efl_canvas_gesture_rotate.eo
new file mode 100644
index 0000000000..8cd35f8661
--- /dev/null
+++ b/src/lib/evas/gesture/efl_canvas_gesture_rotate.eo
@@ -0,0 +1,28 @@
+class @beta Efl.Canvas.Gesture_Rotate extends Efl.Canvas.Gesture
+{
+ [[Rotate gesture class holding state information.
+ See @Efl.Canvas.Gesture to see what this state is and
+ @[Efl.Canvas.Gesture_Events.gesture,rotate] for a description of the Rotate gesture.
+
+ Application developers receive these objects inside a gesture event and do not typically need to create their own.
+ ]]
+ c_prefix: efl_gesture_rotate;
+ methods {
+ @property radius {
+ [[The current radius (i.e. the distance between the two fingers) of the gesture.]]
+ get {
+ }
+ values {
+ radius: uint; [[The radius value in pixels.]]
+ }
+ }
+ @property angle {
+ [[The current angle of rotation for this gesture.]]
+ get {
+ }
+ values {
+ rotate: double; [[The angle of the rotation. $[0.0] means no rotation has occurred.]]
+ }
+ }
+ }
+}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_tap.c b/src/lib/evas/gesture/efl_canvas_gesture_tap.c
index d777bebba1..99ee591089 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_tap.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_tap.c
@@ -2,17 +2,4 @@
#define MY_CLASS EFL_CANVAS_GESTURE_TAP_CLASS
-EOLIAN static Efl_Object *
-_efl_canvas_gesture_tap_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
-{
- Efl_Canvas_Gesture_Data *gd;
-
- obj = efl_constructor(efl_super(obj, MY_CLASS));
-
- gd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_CLASS);
- gd->type = EFL_EVENT_GESTURE_TAP;
-
- return obj;
-}
-
#include "efl_canvas_gesture_tap.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_tap.eo b/src/lib/evas/gesture/efl_canvas_gesture_tap.eo
index 0e940608d3..bd33011e05 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_tap.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_tap.eo
@@ -2,11 +2,10 @@ class @beta Efl.Canvas.Gesture_Tap extends Efl.Canvas.Gesture
{
[[Tap gesture class holding state information.
See @Efl.Canvas.Gesture to see what this state is and
- @[Efl.Gesture.Events.gesture,tap] for a description of the Tap gesture.
+ @[Efl.Canvas.Gesture_Events.gesture,tap] for a description of the Tap gesture.
+
+ Application developers receive these objects inside a gesture event and do not typically need to create their own.
]]
data: null;
c_prefix: efl_gesture_tap;
- implements {
- Efl.Object.constructor;
- }
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_touch.c b/src/lib/evas/gesture/efl_canvas_gesture_touch.c
index bec99b7539..25325d952e 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_touch.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_touch.c
@@ -6,32 +6,30 @@
//that are directed to a particular object from the
//first finger down to the last finger up
-static void _hash_free_cb(Pointer_Data *point)
-{
- free(point);
-}
-
static inline void
_touch_points_reset(Efl_Canvas_Gesture_Touch_Data *pd)
{
- eina_hash_free(pd->touch_points);
- pd->touch_points = eina_hash_int32_new(EINA_FREE_CB(_hash_free_cb));
+ while (eina_array_count(pd->touch_points))
+ free(eina_array_pop(pd->touch_points));
pd->touch_down = 0;
- pd->state = EFL_GESTURE_TOUCH_UNKNOWN;
+ pd->prev_touch = pd->cur_touch = NULL;
+ pd->state = EFL_GESTURE_TOUCH_STATE_UNKNOWN;
}
EOLIAN static Efl_Object *
_efl_canvas_gesture_touch_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_Touch_Data *pd)
{
- obj = efl_constructor(efl_super(obj, MY_CLASS));
- _touch_points_reset(pd);
- return obj;
+ pd->touch_points = eina_array_new(2);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(pd->touch_points, NULL);
+ return efl_constructor(efl_super(obj, MY_CLASS));
}
EOLIAN static void
_efl_canvas_gesture_touch_efl_object_destructor(Eo *obj, Efl_Canvas_Gesture_Touch_Data *pd)
{
- eina_hash_free(pd->touch_points);
+ while (eina_array_count(pd->touch_points))
+ free(eina_array_pop(pd->touch_points));
+ eina_array_free(pd->touch_points);
efl_destructor(efl_super(obj, MY_CLASS));
}
@@ -50,22 +48,22 @@ _efl_canvas_gesture_touch_point_record(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_T
Efl_Pointer_Action action = pointer_data->action;
Eina_Vector2 pos = pointer_data->cur;
- Pointer_Data *point = eina_hash_find(pd->touch_points, &id);
Eina_Position2D _pos = { pos.x, pos.y };
+ Efl_Gesture_Touch_Point_Data *point = NULL;
+
+ if (eina_array_count(pd->touch_points) >= (unsigned int)id + 1)
+ point = eina_array_data_get(pd->touch_points, id);
if (action == EFL_POINTER_ACTION_DOWN)
{
- pd->touch_down++;
- //TODO: Need to handle 2 or more case.
- if (pd->touch_down == 2)
- pd->multi_touch = EINA_TRUE;
+ if ((!point) || (!point->cur.pressed))
+ pd->touch_down++;
}
else if ((action == EFL_POINTER_ACTION_UP) ||
(action == EFL_POINTER_ACTION_CANCEL))
{
- pd->touch_down--;
- if (pd->multi_touch && pd->touch_down == 1)
- pd->multi_touch = EINA_FALSE;
+ if (point && point->cur.pressed)
+ pd->touch_down--;
}
if (pd->touch_down < 0) goto finished_touch;
@@ -80,36 +78,41 @@ _efl_canvas_gesture_touch_point_record(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_T
else
{
//New finger
- if (!id && (action != EFL_POINTER_ACTION_DOWN))
+ if (action != EFL_POINTER_ACTION_DOWN)
{
//Discard any other event
return;
}
- point = calloc(1, sizeof(Pointer_Data));
+
+ point = calloc(1, sizeof(Efl_Gesture_Touch_Point_Data));
if (!point) return;
point->start.pos = point->prev.pos = point->cur.pos = _pos;
point->start.timestamp = point->prev.timestamp = point->cur.timestamp = timestamp;
point->id = id;
- //Add to the hash
- eina_hash_add(pd->touch_points, &id, point);
- //FIXME: finger_list was broken
- if (id)
- pd->multi_touch = EINA_TRUE;
+ eina_array_push(pd->touch_points, point);
}
+ if (pd->cur_touch != point)
+ pd->prev_touch = pd->cur_touch;
+ pd->cur_touch = point;
point->action = action;
- if (!id && (action == EFL_POINTER_ACTION_DOWN))
+ if (action == EFL_POINTER_ACTION_DOWN)
{
- pd->state = EFL_GESTURE_TOUCH_BEGIN;
+ point->cur.pressed = EINA_TRUE;
+ if (!id)
+ pd->state = EFL_GESTURE_TOUCH_STATE_BEGIN;
+ else
+ pd->state = EFL_GESTURE_TOUCH_STATE_UPDATE;
}
- else if (action == EFL_POINTER_ACTION_UP)
+ else if (action == EFL_POINTER_ACTION_UP)
{
- pd->state = EFL_GESTURE_TOUCH_END;
+ point->cur.pressed = EINA_FALSE;
+ pd->state = EFL_GESTURE_TOUCH_STATE_END;
}
else
{
- pd->state = EFL_GESTURE_TOUCH_UPDATE;
+ pd->state = EFL_GESTURE_TOUCH_STATE_UPDATE;
}
return;
@@ -117,17 +120,34 @@ finished_touch:
_touch_points_reset(pd);
}
-EOLIAN static Eina_Bool
-_efl_canvas_gesture_touch_multi_touch_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd)
+EOLIAN static unsigned int
+_efl_canvas_gesture_touch_touch_points_count_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd)
+{
+ return pd->touch_down;
+}
+
+EOLIAN static const Efl_Gesture_Touch_Point_Data *
+_efl_canvas_gesture_touch_current_data_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd)
{
- return pd->multi_touch;
+ return pd->cur_touch;
+}
+
+EOLIAN static const Efl_Gesture_Touch_Point_Data *
+_efl_canvas_gesture_touch_previous_data_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd)
+{
+ return pd->prev_touch;
+}
+
+EOLIAN static const Efl_Gesture_Touch_Point_Data *
+_efl_canvas_gesture_touch_data_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd, unsigned int id)
+{
+ return eina_array_count(pd->touch_points) >= id + 1 ? eina_array_data_get(pd->touch_points, id) : NULL;
}
EOLIAN static Eina_Position2D
-_efl_canvas_gesture_touch_start_point_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd)
+_efl_canvas_gesture_touch_start_point_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd EINA_UNUSED)
{
- int tool = 0;
- Pointer_Data *point = eina_hash_find(pd->touch_points, &tool);
+ const Efl_Gesture_Touch_Point_Data *point = efl_gesture_touch_data_get(obj, 0);
Eina_Position2D vec = { 0, 0 };
if (!point)
@@ -137,10 +157,9 @@ _efl_canvas_gesture_touch_start_point_get(const Eo *obj EINA_UNUSED, Efl_Canvas_
}
EOLIAN static Eina_Position2D
-_efl_canvas_gesture_touch_cur_point_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd)
+_efl_canvas_gesture_touch_current_point_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd)
{
- int tool = 0;
- Pointer_Data *point = eina_hash_find(pd->touch_points, &tool);
+ const Efl_Gesture_Touch_Point_Data *point = pd->cur_touch;
Eina_Position2D vec = { 0, 0 };
if (!point)
@@ -150,10 +169,9 @@ _efl_canvas_gesture_touch_cur_point_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Ge
}
EOLIAN static unsigned int
-_efl_canvas_gesture_touch_cur_timestamp_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd)
+_efl_canvas_gesture_touch_current_timestamp_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd)
{
- int tool = 0;
- Pointer_Data *point = eina_hash_find(pd->touch_points, &tool);
+ const Efl_Gesture_Touch_Point_Data *point = pd->cur_touch;
if (!point)
return 0;
@@ -164,11 +182,10 @@ _efl_canvas_gesture_touch_cur_timestamp_get(const Eo *obj EINA_UNUSED, Efl_Canva
EOLIAN static Eina_Vector2
_efl_canvas_gesture_touch_delta(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd, int tool)
{
- Pointer_Data *point = eina_hash_find(pd->touch_points, &tool);
+ Efl_Gesture_Touch_Point_Data *point = eina_array_count(pd->touch_points) >= (unsigned)tool + 1 ? eina_array_data_get(pd->touch_points, tool) : NULL;
Eina_Vector2 vec = { 0, 0 };
- if (!point)
- return vec;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(point, vec);
Eina_Vector2 v1 = { point->cur.pos.x, point->cur.pos.y };
Eina_Vector2 v2 = { point->prev.pos.x, point->prev.pos.y };
@@ -180,11 +197,10 @@ _efl_canvas_gesture_touch_delta(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_To
EOLIAN static Eina_Vector2
_efl_canvas_gesture_touch_distance(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Touch_Data *pd, int tool)
{
- Pointer_Data *point = eina_hash_find(pd->touch_points, &tool);
+ Efl_Gesture_Touch_Point_Data *point = eina_array_count(pd->touch_points) >= (unsigned)tool + 1 ? eina_array_data_get(pd->touch_points, tool) : NULL;
Eina_Vector2 vec = { 0, 0 };
- if (!point)
- return vec;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(point, vec);
Eina_Vector2 v1 = { point->cur.pos.x, point->cur.pos.y };
Eina_Vector2 v2 = { point->start.pos.x, point->start.pos.y };
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_touch.eo b/src/lib/evas/gesture/efl_canvas_gesture_touch.eo
index 0425aa7fdc..94f633afc7 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_touch.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_touch.eo
@@ -1,5 +1,4 @@
import efl_canvas_gesture_types;
-import efl_input_types;
/* FIXME: This class lacks a lot of useful helpers. */
@@ -40,24 +39,26 @@ class @beta Efl.Canvas.Gesture_Touch extends Efl.Object
pos: Eina.Position2D; [[The start position.]]
}
}
- @property cur_point {
+ @property current_point {
[[Returns the current touch point.]]
get {}
values {
pos: Eina.Position2D; [[The current position.]]
}
}
- @property cur_timestamp {
+ @property current_timestamp {
[[Returns the timestamp.]]
get {}
values {
time: uint; [[The timestamp.]]
}
}
- @property multi_touch {
- [[This property tells if the event is multi touch.]]
+ @property touch_points_count {
+ [[This provides the number of touch points active.]]
get {
- return: bool; [[returns $true if its a multi touch]]
+ }
+ values {
+ touch_count: uint; [[The number of active touch points.]]
}
}
@property state {
@@ -66,6 +67,29 @@ class @beta Efl.Canvas.Gesture_Touch extends Efl.Object
return : Efl.Canvas.Gesture_Touch_State; [[touch event state]]
}
}
+ @property current_data {
+ [[This property holds the data struct of the most recent touch point.]]
+ get {}
+ values {
+ data: const(Efl.Canvas.Gesture_Touch_Point_Data) @by_ref; [[The current data.]]
+ }
+ }
+ @property previous_data {
+ [[This property holds the data struct of the second-most recent touch point.
+ If there is only one touch point active, it will return NULL.
+ ]]
+ get {}
+ values {
+ data: const(Efl.Canvas.Gesture_Touch_Point_Data) @by_ref; [[The previous touch point's data.]]
+ }
+ }
+ data_get @const {
+ [[This fetches the data for a specified touch point.]]
+ params {
+ @in id: uint; [[The id of the touch point to return.]]
+ }
+ return: const(Efl.Canvas.Gesture_Touch_Point_Data) @by_ref; [[The specified data if it exists.]]
+ }
/* FIXME: finger_list was broken by design - TODO */
}
implements {
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_triple_tap.c b/src/lib/evas/gesture/efl_canvas_gesture_triple_tap.c
index 5a6bb2f126..f698013318 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_triple_tap.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_triple_tap.c
@@ -2,17 +2,4 @@
#define MY_CLASS EFL_CANVAS_GESTURE_TRIPLE_TAP_CLASS
-EOLIAN static Efl_Object *
-_efl_canvas_gesture_triple_tap_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
-{
- Efl_Canvas_Gesture_Data *gd;
-
- obj = efl_constructor(efl_super(obj, MY_CLASS));
-
- gd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_CLASS);
- gd->type = EFL_EVENT_GESTURE_TRIPLE_TAP;
-
- return obj;
-}
-
#include "efl_canvas_gesture_triple_tap.eo.c"
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_triple_tap.eo b/src/lib/evas/gesture/efl_canvas_gesture_triple_tap.eo
index abedc442d4..590148d530 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_triple_tap.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_triple_tap.eo
@@ -2,11 +2,10 @@ class @beta Efl.Canvas.Gesture_Triple_Tap extends Efl.Canvas.Gesture
{
[[Triple-tap gesture class holding state information.
See @Efl.Canvas.Gesture to see what this state is and
- @[Efl.Gesture.Events.gesture,triple_tap] for a description of the Triple-tap gesture.
+ @[Efl.Canvas.Gesture_Events.gesture,triple_tap] for a description of the Triple-tap gesture.
+
+ Application developers receive these objects inside a gesture event and do not typically need to create their own.
]]
data: null;
c_prefix: efl_gesture_triple_tap;
- implements {
- Efl.Object.constructor;
- }
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_types.eot b/src/lib/evas/gesture/efl_canvas_gesture_types.eot
index 96a2ff6293..dde4924154 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_types.eot
+++ b/src/lib/evas/gesture/efl_canvas_gesture_types.eot
@@ -1,46 +1,52 @@
+import eina_types;
+import efl_input_types;
+
enum @beta Efl.Canvas.Gesture_Touch_State
{
[[ This enum type describes the state of a touch event. ]]
- legacy: efl_gesture_touch;
- unknown = 0, [[Gesture Touch State unknown]]
- begin , [[First fingure touch down]]
- update, [[fingure touch update]]
- end, [[Last fingure touch up]]
+ legacy: efl_gesture_touch_state;
+ unknown = 0, [[Touch state is unset.]]
+ begin, [[First touch point has just been added.]]
+ update, [[A touch point position has updated or other touch points were added.]]
+ end, [[A touch point has been released.]]
}
enum @beta Efl.Canvas.Gesture_State
{
[[ This enum type describes the state of a gesture. ]]
- legacy: efl_gesture;
- none = 0, [[No gesture state]]
- started = 1, [[A continuous gesture has started.]]
- updated, [[A gesture continues.]]
- finished, [[A gesture has finished.]]
- canceled, [[A gesture was canceled.]]
+ legacy: efl_gesture_state;
+ none = 0, [[No gesture state.]]
+ started = 1, [[A gesture has started.]]
+ updated, [[A gesture has triggered.]]
+ finished, [[A gesture has ended and has triggered.]]
+ canceled, [[A gesture has ended without triggering.]]
}
enum @beta Efl.Canvas.Gesture_Recognizer_Result
{
[[ This enum type describes the state of a gesture recognizer. ]]
- legacy: efl_gesture;
+ legacy: efl_gesture_recognizer_result;
ignore = 0x0001, [[The event does not change the state of the recognizer.]]
- maybe = 0x0002, [[The event changed the internal state of the recognizer, but it isn't clear yet if it is a gesture or not. The recognizer needs to filter more events to decide.]]
+ maybe = 0x0002, [[The event changed the internal state of the recognizer, but it isn't clear yet if it is a gesture or not. The recognizer needs to filter more events to decide.]]
trigger = 0x0004, [[The gesture has been triggered]]
- finish = 0x0008, [[The gesture has been finished successfully.]]
+ finish = 0x0008, [[The gesture has been finished successfully and the gesture triggered.]]
cancel = 0x0010, [[The event made it clear that it is not a gesture. If the gesture recognizer was in Triggered state before, then the gesture is canceled.]]
result_mask = 0x00ff, [[The gesture result mask]]
}
-enum @beta Efl.Canvas.Gesture_Recognizer_Type
-{
- [[ This enum type describes the state of a touch event. ]]
- legacy: efl_gesture;
- tap = 0,
- doubleTap,
- tripleTap,
- longTap,
- momentum,
- flick,
- zoom,
+struct @beta @c_name(Efl_Gesture_Touch_Point_Info) Efl.Canvas.Gesture_Touch_Point_Info {
+ [[This struct represents the underlying data of a touch point.]]
+ pos: Eina.Position2D; [[The canvas position of the touch point data.]]
+ pressed: bool; [[Whether this touch point is currently being pressed down.]]
+ timestamp: uint; [[The timestamp of the touch point data in milliseconds.]]
+}
+
+struct @beta @c_name(Efl_Gesture_Touch_Point_Data) Efl.Canvas.Gesture_Touch_Point_Data {
+ [[This struct represents the state of a touch point.]]
+ id: int; [[Touch id of the point, where the first point is $0.]]
+ action: Efl.Pointer.Action; [[The last event with this point.]]
+ start: Efl.Canvas.Gesture_Touch_Point_Info; [[The start data for the touch point.]]
+ prev: Efl.Canvas.Gesture_Touch_Point_Info; [[The previous data for the touch point.]]
+ cur: Efl.Canvas.Gesture_Touch_Point_Info; [[The current data for the touch point.]]
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_zoom.c b/src/lib/evas/gesture/efl_canvas_gesture_zoom.c
index 3ac4ffcbf4..8e7a635231 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_zoom.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_zoom.c
@@ -2,32 +2,14 @@
#define MY_CLASS EFL_CANVAS_GESTURE_ZOOM_CLASS
-EOLIAN static Efl_Object *
-_efl_canvas_gesture_zoom_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_Zoom_Data *pd EINA_UNUSED)
-{
- Efl_Canvas_Gesture_Data *gd;
-
- obj = efl_constructor(efl_super(obj, MY_CLASS));
- gd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_CLASS);
- gd->type = EFL_EVENT_GESTURE_ZOOM;
-
- return obj;
-}
-
-EOLIAN static void
-_efl_canvas_gesture_zoom_efl_object_destructor(Eo *obj, Efl_Canvas_Gesture_Zoom_Data *pd EINA_UNUSED)
-{
- efl_destructor(efl_super(obj, MY_CLASS));
-}
-
EOLIAN static double
-_efl_canvas_gesture_zoom_radius_get(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Zoom_Data *pd)
+_efl_canvas_gesture_zoom_radius_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Zoom_Data *pd)
{
return pd->radius;
}
EOLIAN static double
-_efl_canvas_gesture_zoom_zoom_get(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Zoom_Data *pd)
+_efl_canvas_gesture_zoom_zoom_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Zoom_Data *pd)
{
return pd->zoom;
}
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_zoom.eo b/src/lib/evas/gesture/efl_canvas_gesture_zoom.eo
index c41610bf77..5642da7b17 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_zoom.eo
+++ b/src/lib/evas/gesture/efl_canvas_gesture_zoom.eo
@@ -2,24 +2,30 @@ class @beta Efl.Canvas.Gesture_Zoom extends Efl.Canvas.Gesture
{
[[Zoom gesture class holding state information.
See @Efl.Canvas.Gesture to see what this state is and
- @[Efl.Gesture.Events.gesture,zoom] for a description of the Zoom gesture.
+ @[Efl.Canvas.Gesture_Events.gesture,zoom] for a description of the Zoom gesture.
+
+ Application developers receive these objects inside a gesture event and do not typically need to create their own.
]]
c_prefix: efl_gesture_zoom;
methods {
- radius_get {
- [[Gets the current radius (i.e. the distance between the two fingers) of the gesture.]]
- return: double; [[The radius value in pixels.]]
+ @property radius {
+ [[The current radius (i.e. the distance between the two fingers) of the gesture.]]
+ get {
+ }
+ values {
+ radius: double; [[The radius value in pixels.]]
+ }
}
- zoom_get {
- [[Gets the current zoom value of the gesture. When the gesture begins, the finger
+ @property zoom {
+ [[The current zoom value of the gesture. When the gesture begins, the finger
distance is recorded. When the distance becomes greater than the initial one, a
zoom value greater than $[1.0] is reported. When it becomes smaller, a zoom value
lesser than $[1.0] is reported.]]
- return: double; [[The zoom value. $[1.0] means no zoom.]]
+ get {
+ }
+ values {
+ zoom: double; [[The zoom value. $[1.0] means no zoom.]]
+ }
}
}
- implements {
- Efl.Object.constructor;
- Efl.Object.destructor;
- }
}
diff --git a/src/lib/evas/gesture/meson.build b/src/lib/evas/gesture/meson.build
index 9854e6f94d..bc761d4674 100644
--- a/src/lib/evas/gesture/meson.build
+++ b/src/lib/evas/gesture/meson.build
@@ -4,20 +4,24 @@ pub_eo_files = [
'efl_canvas_gesture_tap.eo',
'efl_canvas_gesture_double_tap.eo',
'efl_canvas_gesture_triple_tap.eo',
- 'efl_canvas_gesture_long_tap.eo',
+ 'efl_canvas_gesture_long_press.eo',
'efl_canvas_gesture_momentum.eo',
'efl_canvas_gesture_flick.eo',
+ 'efl_canvas_gesture_rotate.eo',
'efl_canvas_gesture_zoom.eo',
+ 'efl_canvas_gesture_custom.eo',
'efl_canvas_gesture_recognizer.eo',
'efl_canvas_gesture_recognizer_tap.eo',
'efl_canvas_gesture_recognizer_double_tap.eo',
'efl_canvas_gesture_recognizer_triple_tap.eo',
- 'efl_canvas_gesture_recognizer_long_tap.eo',
+ 'efl_canvas_gesture_recognizer_long_press.eo',
'efl_canvas_gesture_recognizer_momentum.eo',
'efl_canvas_gesture_recognizer_flick.eo',
+ 'efl_canvas_gesture_recognizer_rotate.eo',
'efl_canvas_gesture_recognizer_zoom.eo',
+ 'efl_canvas_gesture_recognizer_custom.eo',
'efl_canvas_gesture_manager.eo',
- 'efl_gesture_events.eo'
+ 'efl_canvas_gesture_events.eo'
]
evas_gesture_eo_files = pub_eo_files
@@ -34,6 +38,7 @@ foreach eo_file : pub_eo_files
'-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'),
'-o', 'c:' + join_paths(meson.current_build_dir(), eo_file + '.c'),
'-o', 'd:' + join_paths(meson.current_build_dir(), eo_file + '.d'),
+ '-e', 'EVAS_API',
'-gchd', '@INPUT@'])
endforeach
@@ -57,6 +62,7 @@ foreach eo_file : pub_eo_types_files
command : eolian_gen + ['-I', meson.current_source_dir(), eolian_include_directories,
'-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'),
'-o', 'd:' + join_paths(meson.current_build_dir(), eo_file + '.d'),
+ '-e', 'EVAS_API',
'-ghd', '@INPUT@'])
endforeach
@@ -66,18 +72,22 @@ evas_src += files([
'efl_canvas_gesture_tap.c',
'efl_canvas_gesture_double_tap.c',
'efl_canvas_gesture_triple_tap.c',
- 'efl_canvas_gesture_long_tap.c',
+ 'efl_canvas_gesture_long_press.c',
'efl_canvas_gesture_momentum.c',
'efl_canvas_gesture_flick.c',
+ 'efl_canvas_gesture_rotate.c',
'efl_canvas_gesture_zoom.c',
+ 'efl_canvas_gesture_custom.c',
'efl_canvas_gesture_recognizer.c',
'efl_canvas_gesture_recognizer_tap.c',
'efl_canvas_gesture_recognizer_double_tap.c',
'efl_canvas_gesture_recognizer_triple_tap.c',
- 'efl_canvas_gesture_recognizer_long_tap.c',
+ 'efl_canvas_gesture_recognizer_long_press.c',
'efl_canvas_gesture_recognizer_momentum.c',
'efl_canvas_gesture_recognizer_flick.c',
+ 'efl_canvas_gesture_recognizer_rotate.c',
'efl_canvas_gesture_recognizer_zoom.c',
+ 'efl_canvas_gesture_recognizer_custom.c',
'efl_canvas_gesture_manager.c',
])