summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2020-02-19 09:49:08 -0500
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-03 10:54:27 +0100
commit830cdcf7ea7d45a78f2b08403f9eb5f50f35eeac (patch)
tree6f3ff32739906b657872c028be90f5b9d87f4501
parent641c9427ef5f462655750ad3c802f925d09430b4 (diff)
efl/gesture: move some internal recognizer functions to be reusable
no functional changes Differential Revision: https://phab.enlightenment.org/D11382
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_private.h3
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer.c101
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.c52
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.c51
4 files changed, 104 insertions, 103 deletions
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_private.h b/src/lib/evas/gesture/efl_canvas_gesture_private.h
index 1b9e7d2ddc..fe8de41d04 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_private.h
+++ b/src/lib/evas/gesture/efl_canvas_gesture_private.h
@@ -15,6 +15,9 @@ int _direction_get(Evas_Coord xx1, Evas_Coord xx2);
15Eina_Value *_recognizer_config_get(const Eo *obj, const char *name); 15Eina_Value *_recognizer_config_get(const Eo *obj, const char *name);
16Eina_Bool _event_multi_touch_get(const Efl_Canvas_Gesture_Touch *event); 16Eina_Bool _event_multi_touch_get(const Efl_Canvas_Gesture_Touch *event);
17 17
18double _angle_get(Evas_Coord xx1, Evas_Coord yy1, Evas_Coord xx2, Evas_Coord yy2);
19Evas_Coord _finger_gap_length_get(Evas_Coord xx1, Evas_Coord yy1, Evas_Coord xx2, Evas_Coord yy2, Evas_Coord *x, Evas_Coord *y);
20
18typedef struct _Efl_Canvas_Gesture_Manager_Data Efl_Canvas_Gesture_Manager_Data; 21typedef struct _Efl_Canvas_Gesture_Manager_Data Efl_Canvas_Gesture_Manager_Data;
19typedef struct _Efl_Canvas_Gesture_Recognizer_Data Efl_Canvas_Gesture_Recognizer_Data; 22typedef struct _Efl_Canvas_Gesture_Recognizer_Data Efl_Canvas_Gesture_Recognizer_Data;
20typedef struct _Efl_Canvas_Gesture_Recognizer_Tap_Data Efl_Canvas_Gesture_Recognizer_Tap_Data; 23typedef struct _Efl_Canvas_Gesture_Recognizer_Tap_Data Efl_Canvas_Gesture_Recognizer_Tap_Data;
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer.c
index 588a233660..c07e11d084 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer.c
@@ -1,5 +1,6 @@
1#define EFL_CANVAS_GESTURE_RECOGNIZER_PROTECTED 1#define EFL_CANVAS_GESTURE_RECOGNIZER_PROTECTED
2#include "efl_canvas_gesture_private.h" 2#include "efl_canvas_gesture_private.h"
3#define RAD2DEG(x) ((x) * 57.295779513)
3 4
4#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_CLASS 5#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_CLASS
5#include "efl_canvas_gesture_recognizer.eo.h" 6#include "efl_canvas_gesture_recognizer.eo.h"
@@ -39,4 +40,104 @@ _event_multi_touch_get(const Efl_Canvas_Gesture_Touch *event)
39 return efl_gesture_touch_points_count_get(event) > 1; 40 return efl_gesture_touch_points_count_get(event) > 1;
40} 41}
41 42
43
44double
45_angle_get(Evas_Coord xx1, Evas_Coord yy1, Evas_Coord xx2, Evas_Coord yy2)
46{
47 double a, xx, yy, rt = (-1);
48
49 xx = abs(xx2 - xx1);
50 yy = abs(yy2 - yy1);
51
52 if (((int)xx) && ((int)yy))
53 {
54 rt = a = RAD2DEG(atan(yy / xx));
55 if (xx1 < xx2)
56 {
57 if (yy1 < yy2) rt = 360 - a;
58 else rt = a;
59 }
60 else
61 {
62 if (yy1 < yy2) rt = 180 + a;
63 else rt = 180 - a;
64 }
65 }
66
67 if (rt < 0) /* Do this only if rt is not set */
68 {
69 if (((int)xx)) /* Horizontal line */
70 {
71 if (xx2 < xx1) rt = 180;
72 else rt = 0.0;
73 }
74 else /* Vertical line */
75 {
76 if (yy2 < yy1) rt = 90;
77 else rt = 270;
78 }
79 }
80
81 /* Now we want to change from:
82 * 90 0
83 * original circle 180 0 We want: 270 90
84 * 270 180
85 */
86 rt = 450 - rt;
87 if (rt >= 360) rt -= 360;
88
89 return rt;
90}
91
92Evas_Coord
93_finger_gap_length_get(Evas_Coord xx1,
94 Evas_Coord yy1,
95 Evas_Coord xx2,
96 Evas_Coord yy2,
97 Evas_Coord *x,
98 Evas_Coord *y)
99{
100 double a, b, xx, yy, gap;
101 xx = abs(xx2 - xx1);
102 yy = abs(yy2 - yy1);
103 gap = sqrt((xx * xx) + (yy * yy));
104
105 /* START - Compute zoom center point */
106 /* The triangle defined as follows:
107 * B
108 * / |
109 * / |
110 * gap / | a
111 * / |
112 * A-----C
113 * b
114 * http://en.wikipedia.org/wiki/Trigonometric_functions
115 *************************************/
116 if (((int)xx) && ((int)yy))
117 {
118 double A = atan((yy / xx));
119 a = (Evas_Coord)((gap / 2) * sin(A));
120 b = (Evas_Coord)((gap / 2) * cos(A));
121 *x = (Evas_Coord)((xx2 > xx1) ? (xx1 + b) : (xx2 + b));
122 *y = (Evas_Coord)((yy2 > yy1) ? (yy1 + a) : (yy2 + a));
123 }
124 else
125 {
126 if ((int)xx) /* horiz line, take half width */
127 {
128 *x = (Evas_Coord)((xx1 + xx2) / 2);
129 *y = (Evas_Coord)(yy1);
130 }
131
132 if ((int)yy) /* vert line, take half width */
133 {
134 *x = (Evas_Coord)(xx1);
135 *y = (Evas_Coord)((yy1 + yy2) / 2);
136 }
137 }
138 /* END - Compute zoom center point */
139
140 return (Evas_Coord)gap;
141}
142
42#include "efl_canvas_gesture_recognizer.eo.c" 143#include "efl_canvas_gesture_recognizer.eo.c"
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 6736e39a45..071d45f142 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.c
@@ -7,7 +7,6 @@
7#define THUMBSCROLL_MOMENTUM_THRESHOLD 100.0 7#define THUMBSCROLL_MOMENTUM_THRESHOLD 100.0
8#define EFL_GESTURE_MINIMUM_MOMENTUM 0.001 8#define EFL_GESTURE_MINIMUM_MOMENTUM 0.001
9 9
10#define RAD2DEG(x) ((x) * 57.295779513)
11#define DEG2RAD(x) ((x) / 57.295779513) 10#define DEG2RAD(x) ((x) / 57.295779513)
12 11
13#define memset do not use memset to reset flick data, use _reset_recognizer 12#define memset do not use memset to reset flick data, use _reset_recognizer
@@ -114,57 +113,6 @@ _single_line_process(Eo *obj,
114 pd->t_st, efl_gesture_touch_current_timestamp_get(event)); 113 pd->t_st, efl_gesture_touch_current_timestamp_get(event));
115} 114}
116 115
117static double
118_angle_get(Evas_Coord xx1,
119 Evas_Coord yy1,
120 Evas_Coord xx2,
121 Evas_Coord yy2)
122{
123 double a, xx, yy, rt = (-1);
124
125 xx = abs(xx2 - xx1);
126 yy = abs(yy2 - yy1);
127
128 if (((int)xx) && ((int)yy))
129 {
130 rt = a = RAD2DEG(atan(yy / xx));
131 if (xx1 < xx2)
132 {
133 if (yy1 < yy2) rt = 360 - a;
134 else rt = a;
135 }
136 else
137 {
138 if (yy1 < yy2) rt = 180 + a;
139 else rt = 180 - a;
140 }
141 }
142
143 if (rt < 0) /* Do this only if rt is not set */
144 {
145 if (((int)xx)) /* Horizontal line */
146 {
147 if (xx2 < xx1) rt = 180;
148 else rt = 0.0;
149 }
150 else /* Vertical line */
151 {
152 if (yy2 < yy1) rt = 90;
153 else rt = 270;
154 }
155 }
156
157 /* Now we want to change from:
158 * 90 0
159 * original circle 180 0 We want: 270 90
160 * 270 180
161 */
162 rt = 450 - rt;
163 if (rt >= 360) rt -= 360;
164
165 return rt;
166}
167
168static void 116static void
169_vector_get(Eina_Position2D v1, 117_vector_get(Eina_Position2D v1,
170 Eina_Position2D v2, 118 Eina_Position2D v2,
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 3dd6070ae4..372fd1ecfe 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.c
@@ -16,57 +16,6 @@ _reset_recognizer(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd)
16 16
17#define memset do not use memset to reset zoom data, use _reset_recognizer 17#define memset do not use memset to reset zoom data, use _reset_recognizer
18 18
19static Evas_Coord
20_finger_gap_length_get(Evas_Coord xx1,
21 Evas_Coord yy1,
22 Evas_Coord xx2,
23 Evas_Coord yy2,
24 Evas_Coord *x,
25 Evas_Coord *y)
26{
27 double a, b, xx, yy, gap;
28 xx = abs(xx2 - xx1);
29 yy = abs(yy2 - yy1);
30 gap = sqrt((xx * xx) + (yy * yy));
31
32 /* START - Compute zoom center point */
33 /* The triangle defined as follows:
34 * B
35 * / |
36 * / |
37 * gap / | a
38 * / |
39 * A-----C
40 * b
41 * http://en.wikipedia.org/wiki/Trigonometric_functions
42 *************************************/
43 if (((int)xx) && ((int)yy))
44 {
45 double A = atan((yy / xx));
46 a = (Evas_Coord)((gap / 2) * sin(A));
47 b = (Evas_Coord)((gap / 2) * cos(A));
48 *x = (Evas_Coord)((xx2 > xx1) ? (xx1 + b) : (xx2 + b));
49 *y = (Evas_Coord)((yy2 > yy1) ? (yy1 + a) : (yy2 + a));
50 }
51 else
52 {
53 if ((int)xx) /* horiz line, take half width */
54 {
55 *x = (Evas_Coord)((xx1 + xx2) / 2);
56 *y = (Evas_Coord)(yy1);
57 }
58
59 if ((int)yy) /* vert line, take half width */
60 {
61 *x = (Evas_Coord)(xx1);
62 *y = (Evas_Coord)((yy1 + yy2) / 2);
63 }
64 }
65 /* END - Compute zoom center point */
66
67 return (Evas_Coord)gap;
68}
69
70static double 19static double
71_zoom_compute(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd, 20_zoom_compute(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd,
72 Efl_Canvas_Gesture_Zoom_Data *zd, 21 Efl_Canvas_Gesture_Zoom_Data *zd,