summaryrefslogtreecommitdiff
path: root/src/lib/evas
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-08-25 11:34:28 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-10-12 21:03:49 +0900
commitc3865609c9a89a705976a79a8a8e189a00027d18 (patch)
treee65388f98e261e772edfdd8784d82021364cc11c /src/lib/evas
parent29917e4e91c61cff88753bddbeb571e58faea9a6 (diff)
efl_animation: Add scale animation
Diffstat (limited to 'src/lib/evas')
-rw-r--r--src/lib/evas/Evas_Common.h7
-rw-r--r--src/lib/evas/Evas_Eo.h1
-rw-r--r--src/lib/evas/canvas/efl_animation_scale.c224
-rw-r--r--src/lib/evas/canvas/efl_animation_scale.eo41
-rw-r--r--src/lib/evas/canvas/efl_animation_scale_private.h48
5 files changed, 321 insertions, 0 deletions
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index fd5c5910b5..d12e028145 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3351,6 +3351,13 @@ typedef Eo Efl_Animation_Rotate;
3351 3351
3352#endif 3352#endif
3353 3353
3354#ifndef _EFL_ANIMATION_SCALE_EO_CLASS_TYPE
3355#define _EFL_ANIMATION_SCALE_EO_CLASS_TYPE
3356
3357typedef Eo Efl_Animation_Scale;
3358
3359#endif
3360
3354#ifndef _EFL_ANIMATION_OBJECT_EO_CLASS_TYPE 3361#ifndef _EFL_ANIMATION_OBJECT_EO_CLASS_TYPE
3355#define _EFL_ANIMATION_OBJECT_EO_CLASS_TYPE 3362#define _EFL_ANIMATION_OBJECT_EO_CLASS_TYPE
3356 3363
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index d0d0cacc6d..4a7e5e5399 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -58,6 +58,7 @@
58#include "canvas/efl_animation.eo.h" 58#include "canvas/efl_animation.eo.h"
59#include "canvas/efl_animation_alpha.eo.h" 59#include "canvas/efl_animation_alpha.eo.h"
60#include "canvas/efl_animation_rotate.eo.h" 60#include "canvas/efl_animation_rotate.eo.h"
61#include "canvas/efl_animation_scale.eo.h"
61#include "canvas/efl_animation_object.eo.h" 62#include "canvas/efl_animation_object.eo.h"
62#include "canvas/efl_animation_object_alpha.eo.h" 63#include "canvas/efl_animation_object_alpha.eo.h"
63#include "canvas/efl_animation_object_rotate.eo.h" 64#include "canvas/efl_animation_object_rotate.eo.h"
diff --git a/src/lib/evas/canvas/efl_animation_scale.c b/src/lib/evas/canvas/efl_animation_scale.c
new file mode 100644
index 0000000000..2b2d41198a
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_scale.c
@@ -0,0 +1,224 @@
1#include "efl_animation_scale_private.h"
2
3EOLIAN static void
4_efl_animation_scale_scale_set(Eo *eo_obj,
5 Efl_Animation_Scale_Data *pd,
6 double from_scale_x,
7 double from_scale_y,
8 double to_scale_x,
9 double to_scale_y,
10 Efl_Canvas_Object *pivot,
11 double cx,
12 double cy)
13{
14 EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);
15
16 pd->from.scale_x = from_scale_x;
17 pd->from.scale_y = from_scale_y;
18
19 pd->to.scale_x = to_scale_x;
20 pd->to.scale_y = to_scale_y;
21
22 pd->rel_pivot.obj = pivot;
23 pd->rel_pivot.cx = cx;
24 pd->rel_pivot.cy = cy;
25
26 //Update absolute pivot based on relative pivot
27 Evas_Coord x = 0;
28 Evas_Coord y = 0;
29 Evas_Coord w = 0;
30 Evas_Coord h = 0;
31
32 if (pivot)
33 evas_object_geometry_get(pivot, &x, &y, &w, &h);
34 else
35 {
36 Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
37 if (target)
38 evas_object_geometry_get(target, &x, &y, &w, &h);
39 }
40
41 pd->abs_pivot.cx = x + (w * cx);
42 pd->abs_pivot.cy = y + (h * cy);
43
44 pd->use_rel_pivot = EINA_TRUE;
45}
46
47EOLIAN static void
48_efl_animation_scale_scale_get(Eo *eo_obj,
49 Efl_Animation_Scale_Data *pd,
50 double *from_scale_x,
51 double *from_scale_y,
52 double *to_scale_x,
53 double *to_scale_y,
54 Efl_Canvas_Object **pivot,
55 double *cx,
56 double *cy)
57{
58 EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);
59
60 //Update relative pivot based on absolute pivot
61 if (!pd->use_rel_pivot)
62 {
63 Evas_Coord x = 0;
64 Evas_Coord y = 0;
65 Evas_Coord w = 0;
66 Evas_Coord h = 0;
67
68 Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
69 if (target)
70 evas_object_geometry_get(target, &x, &y, &w, &h);
71
72 if (w != 0)
73 pd->rel_pivot.cx = (double)(pd->abs_pivot.cx - x) / w;
74 else
75 pd->rel_pivot.cx = 0.0;
76
77 if (h != 0)
78 pd->rel_pivot.cy = (double)(pd->abs_pivot.cy - y) / h;
79 else
80 pd->rel_pivot.cy = 0.0;
81 }
82
83 if (from_scale_x)
84 *from_scale_x = pd->from.scale_x;
85
86 if (from_scale_y)
87 *from_scale_y = pd->from.scale_y;
88
89 if (to_scale_x)
90 *to_scale_x = pd->to.scale_x;
91
92 if (to_scale_y)
93 *to_scale_y = pd->to.scale_y;
94
95 if (pivot)
96 *pivot = pd->rel_pivot.obj;
97
98 if (cx)
99 *cx = pd->rel_pivot.cx;
100
101 if (cy)
102 *cy = pd->rel_pivot.cy;
103}
104
105EOLIAN static void
106_efl_animation_scale_scale_absolute_set(Eo *eo_obj,
107 Efl_Animation_Scale_Data *pd,
108 double from_scale_x,
109 double from_scale_y,
110 double to_scale_x,
111 double to_scale_y,
112 Evas_Coord cx,
113 Evas_Coord cy)
114{
115 EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);
116
117 pd->from.scale_x = from_scale_x;
118 pd->from.scale_y = from_scale_y;
119
120 pd->to.scale_x = to_scale_x;
121 pd->to.scale_y = to_scale_y;
122
123 pd->abs_pivot.cx = cx;
124 pd->abs_pivot.cy = cy;
125
126 //Update relative pivot based on absolute pivot
127 Evas_Coord x = 0;
128 Evas_Coord y = 0;
129 Evas_Coord w = 0;
130 Evas_Coord h = 0;
131
132 Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
133 if (target)
134 evas_object_geometry_get(target, &x, &y, &w, &h);
135
136 pd->rel_pivot.obj = NULL;
137
138 if (w != 0)
139 pd->rel_pivot.cx = (double)(cx - x) / w;
140 else
141 pd->rel_pivot.cx = 0.0;
142
143 if (h != 0)
144 pd->rel_pivot.cy = (double)(cy - y) / h;
145 else
146 pd->rel_pivot.cy = 0.0;
147
148 pd->use_rel_pivot = EINA_FALSE;
149}
150
151EOLIAN static void
152_efl_animation_scale_scale_absolute_get(Eo *eo_obj,
153 Efl_Animation_Scale_Data *pd,
154 double *from_scale_x,
155 double *from_scale_y,
156 double *to_scale_x,
157 double *to_scale_y,
158 Evas_Coord *cx,
159 Evas_Coord *cy)
160{
161 EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);
162
163 //Update absolute pivot based on relative pivot
164 if (pd->use_rel_pivot)
165 {
166 Evas_Coord x = 0;
167 Evas_Coord y = 0;
168 Evas_Coord w = 0;
169 Evas_Coord h = 0;
170
171 if (pd->rel_pivot.obj)
172 evas_object_geometry_get(pd->rel_pivot.obj, &x, &y, &w, &h);
173 else
174 {
175 Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
176 if (target)
177 evas_object_geometry_get(target, &x, &y, &w, &h);
178 }
179
180 pd->abs_pivot.cx = x + (w * pd->rel_pivot.cx);
181 pd->abs_pivot.cy = y + (h * pd->rel_pivot.cy);
182 }
183
184 if (from_scale_x)
185 *from_scale_x = pd->from.scale_x;
186
187 if (from_scale_y)
188 *from_scale_y = pd->from.scale_y;
189
190 if (to_scale_x)
191 *to_scale_x = pd->to.scale_x;
192
193 if (to_scale_y)
194 *to_scale_y = pd->to.scale_y;
195
196 if (cx)
197 *cx = pd->abs_pivot.cx;
198
199 if (cy)
200 *cy = pd->abs_pivot.cy;
201}
202
203EOLIAN static Efl_Object *
204_efl_animation_scale_efl_object_constructor(Eo *eo_obj,
205 Efl_Animation_Scale_Data *pd)
206{
207 eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
208
209 pd->from.scale_x = 1.0;
210 pd->from.scale_y = 1.0;
211
212 pd->rel_pivot.obj = NULL;
213 pd->rel_pivot.cx = 0.5;
214 pd->rel_pivot.cy = 0.5;
215
216 pd->abs_pivot.cx = 0;
217 pd->abs_pivot.cy = 0;
218
219 pd->use_rel_pivot = EINA_TRUE;
220
221 return eo_obj;
222}
223
224#include "efl_animation_scale.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_scale.eo b/src/lib/evas/canvas/efl_animation_scale.eo
new file mode 100644
index 0000000000..28eb0e25e9
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_scale.eo
@@ -0,0 +1,41 @@
1import efl_animation_types;
2
3class Efl.Animation.Scale (Efl.Animation)
4{
5 [[Efl scale animation class]]
6 data: Efl_Animation_Scale_Data;
7 methods {
8 @property scale {
9 set {
10 }
11 get {
12 }
13 values {
14 from_scale_x: double; [[Scale factor along x axis when animation starts]]
15 from_scale_y: double; [[Scale factor along y axis when animation starts]]
16 to_scale_x: double; [[Scale factor along x axis when animation ends]]
17 to_scale_y: double; [[Scale factor along y axis when animation ends]]
18 pivot: Efl.Canvas.Object; [[Pivot object for the center point. If the pivot object is NULL, then the object is scaled on itself.]]
19 cx: double; [[X relative coordinate of the center point. The left end is 0.0 and the right end is 1.0 (the center is 0.5).]]
20 cy: double; [[Y relative coordinate of the center point. The top end is 0.0 and the bottom end is 1.0 (the center is 0.5).]]
21 }
22 }
23 @property scale_absolute {
24 set {
25 }
26 get {
27 }
28 values {
29 from_scale_x: double; [[Scale factor along x axis when animation starts]]
30 from_scale_y: double; [[Scale factor along y axis when animation starts]]
31 to_scale_x: double; [[Scale factor along x axis when animation ends]]
32 to_scale_y: double; [[Scale factor along y axis when animation ends]]
33 cx: int; [[X absolute coordinate of the center point.]]
34 cy: int; [[Y absolute coordinate of the center point.]]
35 }
36 }
37 }
38 implements {
39 Efl.Object.constructor;
40 }
41}
diff --git a/src/lib/evas/canvas/efl_animation_scale_private.h b/src/lib/evas/canvas/efl_animation_scale_private.h
new file mode 100644
index 0000000000..298097a64c
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_scale_private.h
@@ -0,0 +1,48 @@
1#define EFL_ANIMATION_PROTECTED
2
3#include "evas_common_private.h"
4
5#define MY_CLASS EFL_ANIMATION_SCALE_CLASS
6#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
7
8#define EFL_ANIMATION_SCALE_CHECK_OR_RETURN(anim, ...) \
9 do { \
10 if (!anim) { \
11 CRI("Efl_Animation " # anim " is NULL!"); \
12 return __VA_ARGS__; \
13 } \
14 if (efl_animation_is_deleted(anim)) { \
15 ERR("Efl_Animation " # anim " has already been deleted!"); \
16 return __VA_ARGS__; \
17 } \
18 } while (0)
19
20#define EFL_ANIMATION_SCALE_DATA_GET(o, pd) \
21 Efl_Animation_Scale_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_SCALE_CLASS)
22
23typedef struct _Efl_Animation_Scale_Property
24{
25 double scale_x, scale_y;
26} Efl_Animation_Scale_Property;
27
28typedef struct _Efl_Animation_Scale_Absolute_Pivot
29{
30 Evas_Coord cx, cy;
31} Efl_Animation_Scale_Absolute_Pivot;
32
33typedef struct _Efl_Animation_Scale_Relative_Pivot
34{
35 Efl_Canvas_Object *obj;
36 double cx, cy;
37} Efl_Animation_Scale_Relative_Pivot;
38
39typedef struct _Efl_Animation_Scale_Data
40{
41 Efl_Animation_Scale_Property from;
42 Efl_Animation_Scale_Property to;
43
44 Efl_Animation_Scale_Absolute_Pivot abs_pivot;
45 Efl_Animation_Scale_Relative_Pivot rel_pivot;
46
47 Eina_Bool use_rel_pivot;
48} Efl_Animation_Scale_Data;