evas/gesture: Added gesture and tap gesture implementation.
authorsmohanty <smohantty@gmail.com>
Mon, 25 Sep 2017 06:25:42 +0000 (15:25 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Thu, 19 Oct 2017 01:33:12 +0000 (10:33 +0900)
src/Makefile_Evas.am
src/lib/evas/gesture/efl_gesture.c [new file with mode: 0644]
src/lib/evas/gesture/efl_gesture_recognizer_tap.c [new file with mode: 0644]
src/lib/evas/gesture/efl_gesture_tap.c [new file with mode: 0644]

index f88d177..7ef134e 100644 (file)
@@ -266,6 +266,8 @@ lib/evas/canvas/efl_animation_object_group.c \
 lib/evas/canvas/efl_animation_object_group_parallel.c \
 lib/evas/canvas/efl_animation_object_group_sequential.c \
 lib/evas/gesture/efl_gesture_touch.c \
+lib/evas/gesture/efl_gesture.c \
+lib/evas/gesture/efl_gesture_tap.c \
 $(NULL)
 
 EXTRA_DIST2 += \
diff --git a/src/lib/evas/gesture/efl_gesture.c b/src/lib/evas/gesture/efl_gesture.c
new file mode 100644 (file)
index 0000000..1ea9993
--- /dev/null
@@ -0,0 +1,36 @@
+#include "efl_gesture_private.h"
+
+#define MY_CLASS EFL_GESTURE_CLASS
+
+EOLIAN static const Efl_Event_Description *
+ _efl_gesture_type_get(Eo *obj EINA_UNUSED, Efl_Gesture_Data *pd)
+{
+   return pd->type;
+}
+
+EOLIAN static Efl_Gesture_State
+_efl_gesture_state_get(Eo *obj EINA_UNUSED, Efl_Gesture_Data *pd)
+{
+   return pd->state;
+}
+
+EOLIAN static void
+_efl_gesture_state_set(Eo *obj EINA_UNUSED, Efl_Gesture_Data *pd, Efl_Gesture_State state)
+{
+   pd->state = state;
+}
+
+EOLIAN static void
+_efl_gesture_hotspot_set(Eo *obj EINA_UNUSED, Efl_Gesture_Data *pd, Eina_Vector2 hotspot)
+{
+   pd->hotspot = hotspot;
+}
+
+
+EOLIAN static Eina_Vector2
+_efl_gesture_hotspot_get(Eo *obj EINA_UNUSED, Efl_Gesture_Data *pd)
+{
+   return pd->hotspot;
+}
+
+#include "efl_gesture.eo.c"
\ No newline at end of file
diff --git a/src/lib/evas/gesture/efl_gesture_recognizer_tap.c b/src/lib/evas/gesture/efl_gesture_recognizer_tap.c
new file mode 100644 (file)
index 0000000..e89106c
--- /dev/null
@@ -0,0 +1,84 @@
+#include "efl_gesture_private.h"
+
+#define MY_CLASS EFL_GESTURE_RECOGNIZER_TAP_CLASS
+
+typedef struct _Efl_Gesture_Recognizer_Tap_Data
+{
+
+} Efl_Gesture_Recognizer_Tap_Data;
+
+EOLIAN static Efl_Object *
+_efl_gesture_recognizer_tap_efl_object_constructor(Eo *obj, Efl_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED)
+{
+   obj = efl_constructor(efl_super(obj, MY_CLASS));
+   return obj;
+}
+
+EOLIAN static void
+_efl_gesture_recognizer_tap_efl_object_destructor(Eo *obj EINA_UNUSED, Efl_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED)
+{
+   efl_destructor(efl_super(obj, MY_CLASS));
+}
+
+EOLIAN static Efl_Gesture *
+_efl_gesture_recognizer_tap_efl_gesture_recognizer_create(Eo *obj EINA_UNUSED, Efl_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED,
+                                                                Efl_Object *target EINA_UNUSED)
+{
+   return efl_add(EFL_GESTURE_TAP_CLASS, NULL);
+}
+
+EOLIAN static Efl_Gesture_Recognizer_Result
+_efl_gesture_recognizer_tap_efl_gesture_recognizer_recognize(Eo *obj EINA_UNUSED,
+                                                                   Efl_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED,
+                                                                   Efl_Gesture *gesture, Efl_Object *watched EINA_UNUSED,
+                                                                   Efl_Gesture_Touch *event EINA_UNUSED)
+{
+    double dist_x, dist_y, length, x, y;
+    Efl_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;
+
+    switch (efl_gesture_touch_state_get(event))
+      {
+         case EFL_GESTURE_TOUCH_BEGIN:
+           {
+              efl_gesture_touch_start_point(event, &x, &y);
+              efl_gesture_tap_position_set(gesture, EINA_POSITION2D(x, y));
+              efl_gesture_hotspot_set(gesture, EINA_POSITION2D(x, y));
+              result = EFL_GESTURE_TRIGGER;
+              break;
+           }
+         case EFL_GESTURE_TOUCH_UPDATE:
+         case EFL_GESTURE_TOUCH_END:
+           {
+              if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
+                  !efl_gesture_touch_multi_touch_get(event))
+                {
+                   efl_gesture_touch_distance(event, 0, &dist_x, &dist_y);
+                   length = abs(dist_x) + abs(dist_y);
+                   if (length <= 50)
+                     {
+                        if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_END)
+                          result = EFL_GESTURE_FINISH;
+                        else
+                          result = EFL_GESTURE_TRIGGER;
+                     }
+                }
+              break;
+           }
+          default:
+             break;
+      }
+   return result;
+}
+
+EOLIAN static void
+_efl_gesture_recognizer_tap_efl_gesture_recognizer_reset(Eo *obj,
+                                                              Efl_Gesture_Recognizer_Tap_Data *pd EINA_UNUSED,
+                                                              Efl_Gesture *gesture)
+{
+   Efl_Gesture_Tap_Data *tap;
+   tap = efl_data_scope_get(gesture, EFL_GESTURE_TAP_CLASS);
+   tap->pos = EINA_POSITION2D(0, 0);
+   efl_gesture_recognizer_reset(efl_super(obj, MY_CLASS), gesture);
+}
+
+#include "efl_gesture_recognizer_tap.eo.c"
\ No newline at end of file
diff --git a/src/lib/evas/gesture/efl_gesture_tap.c b/src/lib/evas/gesture/efl_gesture_tap.c
new file mode 100644 (file)
index 0000000..50dbcf3
--- /dev/null
@@ -0,0 +1,31 @@
+#include "efl_gesture_private.h"
+
+#define MY_CLASS EFL_GESTURE_TAP_CLASS
+
+
+EOLIAN static void
+_efl_gesture_tap_position_set(Eo *obj EINA_UNUSED, Efl_Gesture_Tap_Data *pd, Eina_Vector2 pos)
+{
+   pd->pos = pos;
+}
+
+EOLIAN static Eina_Vector2
+_efl_gesture_tap_position_get(Eo *obj EINA_UNUSED, Efl_Gesture_Tap_Data *pd)
+{
+   return pd->pos;
+}
+
+EOLIAN static Efl_Object *
+_efl_gesture_tap_efl_object_constructor(Eo *obj, Efl_Gesture_Tap_Data *pd EINA_UNUSED)
+{
+   Efl_Gesture_Data *gd;
+
+   obj = efl_constructor(efl_super(obj, MY_CLASS));
+
+   gd = efl_data_scope_get(obj, EFL_GESTURE_CLASS);
+   gd->type = EFL_EVENT_GESTURE_TAP;
+
+   return obj;
+}
+
+#include "efl_gesture_tap.eo.c"
\ No newline at end of file