efl/gesture: move some internal recognizer functions to be reusable
authorMike Blumenkrantz <zmike@samsung.com>
Wed, 19 Feb 2020 14:49:08 +0000 (09:49 -0500)
committerJongmin Lee <jm105.lee@samsung.com>
Tue, 3 Mar 2020 21:16:58 +0000 (06:16 +0900)
no functional changes

Differential Revision: https://phab.enlightenment.org/D11382

src/lib/evas/gesture/efl_canvas_gesture_private.h
src/lib/evas/gesture/efl_canvas_gesture_recognizer.c
src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.c
src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.c

index 1b9e7d2..fe8de41 100644 (file)
@@ -15,6 +15,9 @@ 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;
index 588a233..c07e11d 100644 (file)
@@ -1,5 +1,6 @@
 #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
 #include "efl_canvas_gesture_recognizer.eo.h"
@@ -39,4 +40,104 @@ _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;
+}
+
+Evas_Coord
+_finger_gap_length_get(Evas_Coord xx1,
+                       Evas_Coord yy1,
+                       Evas_Coord xx2,
+                       Evas_Coord yy2,
+                       Evas_Coord *x,
+                       Evas_Coord *y)
+{
+   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;
+}
+
 #include "efl_canvas_gesture_recognizer.eo.c"
index 6736e39..071d45f 100644 (file)
@@ -7,7 +7,6 @@
 #define THUMBSCROLL_MOMENTUM_THRESHOLD 100.0
 #define EFL_GESTURE_MINIMUM_MOMENTUM   0.001
 
-#define RAD2DEG(x) ((x) * 57.295779513)
 #define DEG2RAD(x) ((x) / 57.295779513)
 
 #define memset do not use memset to reset flick data, use _reset_recognizer
@@ -114,57 +113,6 @@ _single_line_process(Eo *obj,
                  pd->t_st, efl_gesture_touch_current_timestamp_get(event));
 }
 
-static 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;
-}
-
 static void
 _vector_get(Eina_Position2D v1,
             Eina_Position2D v2,
index 3dd6070..372fd1e 100644 (file)
@@ -16,57 +16,6 @@ _reset_recognizer(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd)
 
 #define memset do not use memset to reset zoom data, use _reset_recognizer
 
-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)
-{
-   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;
-}
-
 static double
 _zoom_compute(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd,
               Efl_Canvas_Gesture_Zoom_Data *zd,