summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Elementary.am1
-rw-r--r--src/Makefile_Evas.am5
-rw-r--r--src/bin/elementary/Makefile.am1
-rw-r--r--src/bin/elementary/test.c6
-rw-r--r--src/bin/elementary/test_efl_anim_rotate.c252
-rw-r--r--src/lib/evas/Evas_Common.h7
-rw-r--r--src/lib/evas/Evas_Eo.h1
-rw-r--r--src/lib/evas/Evas_Internal.h8
-rw-r--r--src/lib/evas/canvas/efl_animation_object_rotate.c253
-rw-r--r--src/lib/evas/canvas/efl_animation_object_rotate.eo11
-rw-r--r--src/lib/evas/canvas/efl_animation_object_rotate_private.h49
-rw-r--r--src/lib/evas/canvas/efl_animation_rotate.c39
-rw-r--r--src/lib/evas/canvas/efl_animation_rotate.eo1
13 files changed, 633 insertions, 1 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 7e98233..f8c8b7e 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -798,6 +798,7 @@ bin/elementary/test_disable.c \
798bin/elementary/test_diskselector.c \ 798bin/elementary/test_diskselector.c \
799bin/elementary/test_dnd.c \ 799bin/elementary/test_dnd.c \
800bin/elementary/test_efl_anim_alpha.c \ 800bin/elementary/test_efl_anim_alpha.c \
801bin/elementary/test_efl_anim_rotate.c \
801bin/elementary/test_eio.c \ 802bin/elementary/test_eio.c \
802bin/elementary/test_entry.c \ 803bin/elementary/test_entry.c \
803bin/elementary/test_entry_anchor.c \ 804bin/elementary/test_entry_anchor.c \
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 87cc6ea..3fcb08b 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -49,6 +49,7 @@ evas_eolian_pub_files = \
49 lib/evas/canvas/efl_animation_rotate.eo \ 49 lib/evas/canvas/efl_animation_rotate.eo \
50 lib/evas/canvas/efl_animation_object.eo \ 50 lib/evas/canvas/efl_animation_object.eo \
51 lib/evas/canvas/efl_animation_object_alpha.eo \ 51 lib/evas/canvas/efl_animation_object_alpha.eo \
52 lib/evas/canvas/efl_animation_object_rotate.eo \
52 $(NULL) 53 $(NULL)
53 54
54evas_eolian_legacy_files = \ 55evas_eolian_legacy_files = \
@@ -131,7 +132,8 @@ lib/evas/canvas/efl_animation_private.h \
131lib/evas/canvas/efl_animation_alpha_private.h \ 132lib/evas/canvas/efl_animation_alpha_private.h \
132lib/evas/canvas/efl_animation_rotate_private.h \ 133lib/evas/canvas/efl_animation_rotate_private.h \
133lib/evas/canvas/efl_animation_object_private.h \ 134lib/evas/canvas/efl_animation_object_private.h \
134lib/evas/canvas/efl_animation_object_alpha_private.h 135lib/evas/canvas/efl_animation_object_alpha_private.h \
136lib/evas/canvas/efl_animation_object_rotate_private.h
135 137
136# Linebreak 138# Linebreak
137 139
@@ -222,6 +224,7 @@ lib/evas/canvas/efl_animation_alpha.c \
222lib/evas/canvas/efl_animation_rotate.c \ 224lib/evas/canvas/efl_animation_rotate.c \
223lib/evas/canvas/efl_animation_object.c \ 225lib/evas/canvas/efl_animation_object.c \
224lib/evas/canvas/efl_animation_object_alpha.c \ 226lib/evas/canvas/efl_animation_object_alpha.c \
227lib/evas/canvas/efl_animation_object_rotate.c \
225$(NULL) 228$(NULL)
226 229
227EXTRA_DIST2 += \ 230EXTRA_DIST2 += \
diff --git a/src/bin/elementary/Makefile.am b/src/bin/elementary/Makefile.am
index 5dc6479..9eb701a 100644
--- a/src/bin/elementary/Makefile.am
+++ b/src/bin/elementary/Makefile.am
@@ -33,6 +33,7 @@ test_access.c \
33test_actionslider.c \ 33test_actionslider.c \
34test_anim.c \ 34test_anim.c \
35test_efl_anim_alpha.c \ 35test_efl_anim_alpha.c \
36test_efl_anim_rotate.c \
36test_application_server.c \ 37test_application_server.c \
37test_bg.c \ 38test_bg.c \
38test_box.c \ 39test_box.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 215d3ec..265044c 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -323,6 +323,9 @@ void test_efl_gfx_map(void *data, Edje_Object *obj, void *event_info);
323void test_ui_textpath(void *data, Edje_Object *obj, void *event_info); 323void test_ui_textpath(void *data, Edje_Object *obj, void *event_info);
324 324
325void test_efl_anim_alpha(void *data, Evas_Object *obj, void *event_info); 325void test_efl_anim_alpha(void *data, Evas_Object *obj, void *event_info);
326void test_efl_anim_rotate(void *data, Evas_Object *obj, void *event_info);
327void test_efl_anim_rotate_relative(void *data, Evas_Object *obj, void *event_info);
328void test_efl_anim_rotate_absolute(void *data, Evas_Object *obj, void *event_info);
326 329
327Evas_Object *win, *tbx; // TODO: refactoring 330Evas_Object *win, *tbx; // TODO: refactoring
328void *tt; 331void *tt;
@@ -793,6 +796,9 @@ add_tests:
793 ADD_TEST(NULL, "Effects", "Flip Page (EO API)", test_flip_page_eo); 796 ADD_TEST(NULL, "Effects", "Flip Page (EO API)", test_flip_page_eo);
794 ADD_TEST(NULL, "Effects", "Animation", test_anim); 797 ADD_TEST(NULL, "Effects", "Animation", test_anim);
795 ADD_TEST(NULL, "Effects", "Efl Animation Alpha", test_efl_anim_alpha); 798 ADD_TEST(NULL, "Effects", "Efl Animation Alpha", test_efl_anim_alpha);
799 ADD_TEST(NULL, "Effects", "Efl Animation Rotate", test_efl_anim_rotate);
800 ADD_TEST(NULL, "Effects", "Efl Animation Rotate Relative", test_efl_anim_rotate_relative);
801 ADD_TEST(NULL, "Effects", "Efl Animation Rotate Absolute", test_efl_anim_rotate_absolute);
796 802
797 //------------------------------// 803 //------------------------------//
798 ADD_TEST(NULL, "Edje External", "ExtButton", test_external_button); 804 ADD_TEST(NULL, "Edje External", "ExtButton", test_external_button);
diff --git a/src/bin/elementary/test_efl_anim_rotate.c b/src/bin/elementary/test_efl_anim_rotate.c
new file mode 100644
index 0000000..7fda359
--- /dev/null
+++ b/src/bin/elementary/test_efl_anim_rotate.c
@@ -0,0 +1,252 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5
6typedef struct _App_Data
7{
8 Efl_Animation *cw_45_degrees_anim;
9 Efl_Animation *ccw_45_degrees_anim;
10 Efl_Animation_Object *anim_obj;
11
12 Eina_Bool is_btn_rotated;
13} App_Data;
14
15static void
16_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
17{
18 printf("Animation has been started!\n");
19}
20
21static void
22_anim_ended_cb(void *data, const Efl_Event *event EINA_UNUSED)
23{
24 App_Data *ad = data;
25
26 printf("Animation has been ended!\n");
27
28 ad->anim_obj = NULL;
29}
30
31static void
32_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
33{
34 Efl_Animation_Object_Running_Event_Info *event_info = event->info;
35 double progress = event_info->progress;
36 printf("Animation is running! Current progress(%lf)\n", progress);
37}
38
39static void
40_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
41{
42 App_Data *ad = data;
43
44 if (ad->anim_obj)
45 efl_animation_object_cancel(ad->anim_obj);
46
47 ad->is_btn_rotated = !(ad->is_btn_rotated);
48
49 if (ad->is_btn_rotated)
50 {
51 //Create Animation Object from Animation
52 ad->anim_obj = efl_animation_object_create(ad->cw_45_degrees_anim);
53 elm_object_text_set(obj, "Start Rotate Animation from 45 to 0 degrees");
54 }
55 else
56 {
57 //Create Animation Object from Animation
58 ad->anim_obj = efl_animation_object_create(ad->ccw_45_degrees_anim);
59 elm_object_text_set(obj, "Start Rotate Animation from 0 to 45 degrees");
60 }
61
62 //Register callback called when animation starts
63 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_STARTED, _anim_started_cb, NULL);
64
65 //Register callback called when animation ends
66 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_ENDED, _anim_ended_cb, ad);
67
68 //Register callback called while animation is executed
69 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_RUNNING, _anim_running_cb, NULL);
70
71 //Let Animation Object start animation
72 efl_animation_object_start(ad->anim_obj);
73}
74
75static void
76_win_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
77{
78 App_Data *ad = data;
79 free(ad);
80}
81
82void
83test_efl_anim_rotate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
84{
85 App_Data *ad = calloc(1, sizeof(App_Data));
86 if (!ad) return;
87
88 Evas_Object *win = elm_win_add(NULL, "Efl Animation Rotate", ELM_WIN_BASIC);
89 elm_win_title_set(win, "Efl Animation Rotate");
90 elm_win_autodel_set(win, EINA_TRUE);
91 evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ad);
92
93 //Button to be animated
94 Evas_Object *btn = elm_button_add(win);
95 elm_object_text_set(btn, "Target");
96 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
97 evas_object_resize(btn, 150, 150);
98 evas_object_move(btn, 125, 100);
99 evas_object_show(btn);
100
101 //Rotate from 0 to 45 degrees Animation
102 Efl_Animation *cw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
103 efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, NULL, 0.5, 0.5);
104 efl_animation_duration_set(cw_45_degrees_anim, 1.0);
105 efl_animation_target_set(cw_45_degrees_anim, btn);
106 efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE);
107
108 //Rotate from 45 to 0 degrees Animation
109 Efl_Animation *ccw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
110 efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, NULL, 0.5, 0.5);
111 efl_animation_duration_set(ccw_45_degrees_anim, 1.0);
112 efl_animation_target_set(ccw_45_degrees_anim, btn);
113 efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE);
114
115 //Initialize App Data
116 ad->cw_45_degrees_anim = cw_45_degrees_anim;
117 ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
118 ad->anim_obj = NULL;
119 ad->is_btn_rotated = EINA_FALSE;
120
121 //Button to start animation
122 Evas_Object *btn2 = elm_button_add(win);
123 elm_object_text_set(btn2, "Start Rotate Animation from 0 to 45 degrees");
124 evas_object_smart_callback_add(btn2, "clicked", _btn_clicked_cb, ad);
125 evas_object_size_hint_weight_set(btn2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
126 evas_object_resize(btn2, 300, 50);
127 evas_object_move(btn2, 50, 300);
128 evas_object_show(btn2);
129
130 evas_object_resize(win, 400, 400);
131 evas_object_show(win);
132}
133
134void
135test_efl_anim_rotate_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
136{
137 App_Data *ad = calloc(1, sizeof(App_Data));
138 if (!ad) return;
139
140 Evas_Object *win = elm_win_add(NULL, "Efl Animation Relative Rotate", ELM_WIN_BASIC);
141 elm_win_title_set(win, "Efl Animation Relative Rotate");
142 elm_win_autodel_set(win, EINA_TRUE);
143 evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ad);
144
145 //Button to be animated
146 Evas_Object *btn = elm_button_add(win);
147 elm_object_text_set(btn, "Target");
148 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
149 evas_object_resize(btn, 150, 150);
150 evas_object_move(btn, 125, 100);
151 evas_object_show(btn);
152
153 //Pivot to be center of the rotation
154 Evas_Object *pivot = elm_button_add(win);
155 elm_object_text_set(pivot, "Pivot");
156 evas_object_size_hint_weight_set(pivot, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
157 evas_object_resize(pivot, 50, 50);
158 evas_object_move(pivot, 350, 150);
159 evas_object_show(pivot);
160
161 //Rotate from 0 to 45 degrees Animation
162 Efl_Animation *cw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
163 efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, pivot, 0.5, 0.5);
164 efl_animation_duration_set(cw_45_degrees_anim, 1.0);
165 efl_animation_target_set(cw_45_degrees_anim, btn);
166 efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE);
167
168 //Rotate from 45 to 0 degrees Animation
169 Efl_Animation *ccw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
170 efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, pivot, 0.5, 0.5);
171 efl_animation_duration_set(ccw_45_degrees_anim, 1.0);
172 efl_animation_target_set(ccw_45_degrees_anim, btn);
173 efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE);
174
175 //Initialize App Data
176 ad->cw_45_degrees_anim = cw_45_degrees_anim;
177 ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
178 ad->anim_obj = NULL;
179 ad->is_btn_rotated = EINA_FALSE;
180
181 //Button to start animation
182 Evas_Object *btn2 = elm_button_add(win);
183 elm_object_text_set(btn2, "Start Rotate Animation from 0 to 45 degrees");
184 evas_object_smart_callback_add(btn2, "clicked", _btn_clicked_cb, ad);
185 evas_object_size_hint_weight_set(btn2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
186 evas_object_resize(btn2, 300, 50);
187 evas_object_move(btn2, 50, 300);
188 evas_object_show(btn2);
189
190 evas_object_resize(win, 400, 400);
191 evas_object_show(win);
192}
193
194void
195test_efl_anim_rotate_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
196{
197 App_Data *ad = calloc(1, sizeof(App_Data));
198 if (!ad) return;
199
200 Evas_Object *win = elm_win_add(NULL, "Efl Animation Absolute Rotate", ELM_WIN_BASIC);
201 elm_win_title_set(win, "Efl Animation Absolute Rotate");
202 elm_win_autodel_set(win, EINA_TRUE);
203 evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ad);
204
205 //Button to be animated
206 Evas_Object *btn = elm_button_add(win);
207 elm_object_text_set(btn, "Target");
208 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
209 evas_object_resize(btn, 150, 150);
210 evas_object_move(btn, 125, 100);
211 evas_object_show(btn);
212
213 //Absolute coordinate (0, 0) to be center of the rotation
214 Evas_Object *abs_center = elm_button_add(win);
215 elm_object_text_set(abs_center, "(0, 0)");
216 evas_object_size_hint_weight_set(abs_center, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
217 evas_object_resize(abs_center, 50, 50);
218 evas_object_move(abs_center, 0, 0);
219 evas_object_show(abs_center);
220
221 //Rotate from 0 to 45 degrees Animation
222 Efl_Animation *cw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
223 efl_animation_rotate_absolute_set(cw_45_degrees_anim, 0.0, 45.0, 0, 0);
224 efl_animation_duration_set(cw_45_degrees_anim, 1.0);
225 efl_animation_target_set(cw_45_degrees_anim, btn);
226 efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE);
227
228 //Rotate from 45 to 0 degrees Animation
229 Efl_Animation *ccw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
230 efl_animation_rotate_absolute_set(ccw_45_degrees_anim, 45.0, 0.0, 0, 0);
231 efl_animation_duration_set(ccw_45_degrees_anim, 1.0);
232 efl_animation_target_set(ccw_45_degrees_anim, btn);
233 efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE);
234
235 //Initialize App Data
236 ad->cw_45_degrees_anim = cw_45_degrees_anim;
237 ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
238 ad->anim_obj = NULL;
239 ad->is_btn_rotated = EINA_FALSE;
240
241 //Button to start animation
242 Evas_Object *btn2 = elm_button_add(win);
243 elm_object_text_set(btn2, "Start Rotate Animation from 0 to 45 degrees");
244 evas_object_smart_callback_add(btn2, "clicked", _btn_clicked_cb, ad);
245 evas_object_size_hint_weight_set(btn2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
246 evas_object_resize(btn2, 300, 50);
247 evas_object_move(btn2, 50, 300);
248 evas_object_show(btn2);
249
250 evas_object_resize(win, 400, 400);
251 evas_object_show(win);
252}
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index 47fe1d7..fd5c591 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3365,6 +3365,13 @@ typedef Eo Efl_Animation_Object_Alpha;
3365 3365
3366#endif 3366#endif
3367 3367
3368#ifndef _EFL_ANIMATION_OBJECT_ROTATE_EO_CLASS_TYPE
3369#define _EFL_ANIMATION_OBJECT_ROTATE_EO_CLASS_TYPE
3370
3371typedef Eo Efl_Animation_Object_Rotate;
3372
3373#endif
3374
3368struct _Efl_Animation_Object_Running_Event_Info 3375struct _Efl_Animation_Object_Running_Event_Info
3369{ 3376{
3370 double progress; 3377 double progress;
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index 811f252..d0d0cac 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -60,6 +60,7 @@
60#include "canvas/efl_animation_rotate.eo.h" 60#include "canvas/efl_animation_rotate.eo.h"
61#include "canvas/efl_animation_object.eo.h" 61#include "canvas/efl_animation_object.eo.h"
62#include "canvas/efl_animation_object_alpha.eo.h" 62#include "canvas/efl_animation_object_alpha.eo.h"
63#include "canvas/efl_animation_object_rotate.eo.h"
63 64
64#endif /* EFL_EO_API_SUPPORT */ 65#endif /* EFL_EO_API_SUPPORT */
65 66
diff --git a/src/lib/evas/Evas_Internal.h b/src/lib/evas/Evas_Internal.h
index 88cbded..99cb769 100644
--- a/src/lib/evas/Evas_Internal.h
+++ b/src/lib/evas/Evas_Internal.h
@@ -102,6 +102,14 @@ EOAPI void efl_animation_object_alpha_set(Eo *obj, double from_alpha, double to_
102EOAPI void efl_animation_object_alpha_get(const Eo *obj, double *from_alpha, double *to_alpha); 102EOAPI void efl_animation_object_alpha_get(const Eo *obj, double *from_alpha, double *to_alpha);
103/* Efl.Animation.Object.Alpha END */ 103/* Efl.Animation.Object.Alpha END */
104 104
105/* Efl.Animation.Object.Rotate */
106EOAPI void efl_animation_object_rotate_set(Eo *obj, double from_degree, double to_degree, Efl_Canvas_Object *pivot, double cx, double cy);
107EOAPI void efl_animation_object_rotate_get(const Eo *obj, double *from_degree, double *to_degree, Efl_Canvas_Object **pivot, double *cx, double *cy);
108
109EOAPI void efl_animation_object_rotate_absolute_set(Eo *obj, double from_degree, double to_degree, int cx, int cy);
110EOAPI void efl_animation_object_rotate_absolute_get(const Eo *obj, double *from_degree, double *to_degree, int *cx, int *cy);
111/* Efl.Animation.Object.Rotate END */
112
105#ifdef __cplusplus 113#ifdef __cplusplus
106} 114}
107#endif 115#endif
diff --git a/src/lib/evas/canvas/efl_animation_object_rotate.c b/src/lib/evas/canvas/efl_animation_object_rotate.c
new file mode 100644
index 0000000..7fbcc25
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_object_rotate.c
@@ -0,0 +1,253 @@
1#include "efl_animation_object_rotate_private.h"
2
3EOLIAN static void
4_efl_animation_object_rotate_rotate_set(Eo *eo_obj,
5 Efl_Animation_Object_Rotate_Data *pd,
6 double from_degree,
7 double to_degree,
8 Efl_Canvas_Object *pivot,
9 double cx,
10 double cy)
11{
12 EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(eo_obj);
13
14 pd->from.degree = from_degree;
15 pd->to.degree = to_degree;
16
17 pd->rel_pivot.obj = pivot;
18 pd->rel_pivot.cx = cx;
19 pd->rel_pivot.cy = cy;
20
21 //Update absolute pivot based on relative pivot
22 Evas_Coord x = 0;
23 Evas_Coord y = 0;
24 Evas_Coord w = 0;
25 Evas_Coord h = 0;
26
27 if (pivot)
28 evas_object_geometry_get(pivot, &x, &y, &w, &h);
29 else
30 {
31 Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
32 if (target)
33 evas_object_geometry_get(target, &x, &y, &w, &h);
34 }
35
36 pd->abs_pivot.cx = x + (w * cx);
37 pd->abs_pivot.cy = y + (h * cy);
38
39 pd->use_rel_pivot = EINA_TRUE;
40}
41
42EOLIAN static void
43_efl_animation_object_rotate_rotate_get(Eo *eo_obj,
44 Efl_Animation_Object_Rotate_Data *pd,
45 double *from_degree,
46 double *to_degree,
47 Efl_Canvas_Object **pivot,
48 double *cx,
49 double *cy)
50{
51 EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(eo_obj);
52
53 //Update relative pivot based on absolute pivot
54 if (!pd->use_rel_pivot)
55 {
56 Evas_Coord x = 0;
57 Evas_Coord y = 0;
58 Evas_Coord w = 0;
59 Evas_Coord h = 0;
60
61 Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
62 if (target)
63 evas_object_geometry_get(target, &x, &y, &w, &h);
64
65 if (w != 0)
66 pd->rel_pivot.cx = (double)(pd->abs_pivot.cx - x) / w;
67 else
68 pd->rel_pivot.cx = 0.0;
69
70 if (h != 0)
71 pd->rel_pivot.cy = (double)(pd->abs_pivot.cy - y) / h;
72 else
73 pd->rel_pivot.cy = 0.0;
74 }
75
76 if (from_degree)
77 *from_degree = pd->from.degree;
78
79 if (to_degree)
80 *to_degree = pd->to.degree;
81
82 if (pivot)
83 *pivot = pd->rel_pivot.obj;
84
85 if (cx)
86 *cx = pd->rel_pivot.cx;
87
88 if (cy)
89 *cy = pd->rel_pivot.cy;
90}
91
92EOLIAN static void
93_efl_animation_object_rotate_rotate_absolute_set(Eo *eo_obj,
94 Efl_Animation_Object_Rotate_Data *pd,
95 double from_degree,
96 double to_degree,
97 Evas_Coord cx,
98 Evas_Coord cy)
99{
100 EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(eo_obj);
101
102 pd->from.degree = from_degree;
103 pd->to.degree = to_degree;
104
105 pd->abs_pivot.cx = cx;
106 pd->abs_pivot.cy = cy;
107
108 //Update relative pivot based on absolute pivot
109 Evas_Coord x = 0;
110 Evas_Coord y = 0;
111 Evas_Coord w = 0;
112 Evas_Coord h = 0;
113
114 Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
115 if (target)
116 evas_object_geometry_get(target, &x, &y, &w, &h);
117
118 pd->rel_pivot.obj = NULL;
119
120 if (w != 0)
121 pd->rel_pivot.cx = (double)(cx - x) / w;
122 else
123 pd->rel_pivot.cx = 0.0;
124
125 if (h != 0)
126 pd->rel_pivot.cy = (double)(cy - y) / h;
127 else
128 pd->rel_pivot.cy = 0.0;
129
130 pd->use_rel_pivot = EINA_FALSE;
131}
132
133EOLIAN static void
134_efl_animation_object_rotate_rotate_absolute_get(Eo *eo_obj,
135 Efl_Animation_Object_Rotate_Data *pd,
136 double *from_degree,
137 double *to_degree,
138 Evas_Coord *cx,
139 Evas_Coord *cy)
140{
141 EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(eo_obj);
142
143 //Update absolute pivot based on relative pivot
144 if (pd->use_rel_pivot)
145 {
146 Evas_Coord x = 0;
147 Evas_Coord y = 0;
148 Evas_Coord w = 0;
149 Evas_Coord h = 0;
150
151 if (pd->rel_pivot.obj)
152 evas_object_geometry_get(pd->rel_pivot.obj, &x, &y, &w, &h);
153 else
154 {
155 Efl_Canvas_Object *target
156 = efl_animation_object_target_get(eo_obj);
157 if (target)
158 evas_object_geometry_get(target, &x, &y, &w, &h);
159 }
160
161 pd->abs_pivot.cx = x + (w * pd->rel_pivot.cx);
162 pd->abs_pivot.cy = y + (h * pd->rel_pivot.cy);
163 }
164
165 if (from_degree)
166 *from_degree = pd->from.degree;
167
168 if (to_degree)
169 *to_degree = pd->to.degree;
170
171 if (cx)
172 *cx = pd->abs_pivot.cx;
173
174 if (cy)
175 *cy = pd->abs_pivot.cy;
176}
177
178static void
179_progress_set(Eo *eo_obj, double progress)
180{
181 EFL_ANIMATION_OBJECT_ROTATE_DATA_GET(eo_obj, pd);
182
183 Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
184 if (!target) return;
185
186 double degree =
187 (pd->from.degree * (1.0 - progress)) + (pd->to.degree * progress);
188
189 if (pd->use_rel_pivot)
190 {
191 efl_gfx_map_rotate(target,
192 degree,
193 pd->rel_pivot.obj,
194 pd->rel_pivot.cx, pd->rel_pivot.cy);
195 }
196 else
197 {
198 efl_gfx_map_rotate_absolute(target,
199 degree,
200 pd->abs_pivot.cx, pd->abs_pivot.cy);
201 }
202}
203
204EOLIAN static void
205_efl_animation_object_rotate_efl_animation_object_progress_set(Eo *eo_obj,
206 Efl_Animation_Object_Rotate_Data *pd EINA_UNUSED,
207 double progress)
208{
209 EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(eo_obj);
210
211 if ((progress < 0.0) || (progress > 1.0)) return;
212
213 _progress_set(eo_obj, progress);
214
215 efl_animation_object_progress_set(efl_super(eo_obj, MY_CLASS), progress);
216}
217
218EOLIAN static Efl_Object *
219_efl_animation_object_rotate_efl_object_constructor(Eo *eo_obj,
220 Efl_Animation_Object_Rotate_Data *pd)
221{
222 eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
223
224 pd->from.degree = 0.0;
225 pd->to.degree = 0.0;
226
227 pd->rel_pivot.obj = NULL;
228 pd->rel_pivot.cx = 0.5;
229 pd->rel_pivot.cy = 0.5;
230
231 pd->abs_pivot.cx = 0;
232 pd->abs_pivot.cy = 0;
233
234 pd->use_rel_pivot = EINA_TRUE;
235
236 return eo_obj;
237}
238
239/* Internal EO APIs */
240
241EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_rotate_set, EFL_FUNC_CALL(from_degree, to_degree, pivot, cx, cy), double from_degree, double to_degree, Efl_Canvas_Object *pivot, double cx, double cy);
242EOAPI EFL_VOID_FUNC_BODYV_CONST(efl_animation_object_rotate_get, EFL_FUNC_CALL(from_degree, to_degree, pivot, cx, cy), double *from_degree, double *to_degree, Efl_Canvas_Object **pivot, double *cx, double *cy);
243
244EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_rotate_absolute_set, EFL_FUNC_CALL(from_degree, to_degree, cx, cy), double from_degree, double to_degree, int cx, int cy);
245EOAPI EFL_VOID_FUNC_BODYV_CONST(efl_animation_object_rotate_absolute_get, EFL_FUNC_CALL(from_degree, to_degree, cx, cy), double *from_degree, double *to_degree, int *cx, int *cy);
246
247#define EFL_ANIMATION_OBJECT_ROTATE_EXTRA_OPS \
248 EFL_OBJECT_OP_FUNC(efl_animation_object_rotate_set, _efl_animation_object_rotate_rotate_set), \
249 EFL_OBJECT_OP_FUNC(efl_animation_object_rotate_get, _efl_animation_object_rotate_rotate_get), \
250 EFL_OBJECT_OP_FUNC(efl_animation_object_rotate_absolute_set, _efl_animation_object_rotate_rotate_absolute_set), \
251 EFL_OBJECT_OP_FUNC(efl_animation_object_rotate_absolute_get, _efl_animation_object_rotate_rotate_absolute_get)
252
253#include "efl_animation_object_rotate.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_object_rotate.eo b/src/lib/evas/canvas/efl_animation_object_rotate.eo
new file mode 100644
index 0000000..4cf898b
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_object_rotate.eo
@@ -0,0 +1,11 @@
1import efl_animation_types;
2
3class Efl.Animation.Object.Rotate (Efl.Animation.Object)
4{
5 [[Efl rotate animation object class]]
6 data: Efl_Animation_Object_Rotate_Data;
7 implements {
8 Efl.Object.constructor;
9 Efl.Animation.Object.progress_set;
10 }
11}
diff --git a/src/lib/evas/canvas/efl_animation_object_rotate_private.h b/src/lib/evas/canvas/efl_animation_object_rotate_private.h
new file mode 100644
index 0000000..b58860a
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_object_rotate_private.h
@@ -0,0 +1,49 @@
1#define EFL_ANIMATION_OBJECT_PROTECTED
2#define EFL_ANIMATION_OBJECT_ROTATE_PROTECTED
3
4#include "evas_common_private.h"
5
6#define MY_CLASS EFL_ANIMATION_OBJECT_ROTATE_CLASS
7#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
8
9#define EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(anim_obj, ...) \
10 do { \
11 if (!anim_obj) { \
12 CRI("Efl_Animation_Object " # anim_obj " is NULL!"); \
13 return __VA_ARGS__; \
14 } \
15 if (efl_animation_object_is_deleted(anim_obj)) { \
16 ERR("Efl_Animation_Object " # anim_obj " has already been deleted!"); \
17 return __VA_ARGS__; \
18 } \
19 } while (0)
20
21#define EFL_ANIMATION_OBJECT_ROTATE_DATA_GET(o, pd) \
22 Efl_Animation_Object_Rotate_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_OBJECT_ROTATE_CLASS)
23
24typedef struct _Efl_Animation_Object_Rotate_Property
25{
26 double degree;
27} Efl_Animation_Object_Rotate_Property;
28
29typedef struct _Efl_Animation_Object_Rotate_Absolute_Pivot
30{
31 Evas_Coord cx, cy;
32} Efl_Animation_Object_Rotate_Absolute_Pivot;
33
34typedef struct _Efl_Animation_Object_Rotate_Relative_Pivot
35{
36 Efl_Canvas_Object *obj;
37 double cx, cy;
38} Efl_Animation_Object_Rotate_Relative_Pivot;
39
40typedef struct _Efl_Animation_Object_Rotate_Data
41{
42 Efl_Animation_Object_Rotate_Property from;
43 Efl_Animation_Object_Rotate_Property to;
44
45 Efl_Animation_Object_Rotate_Absolute_Pivot abs_pivot;
46 Efl_Animation_Object_Rotate_Relative_Pivot rel_pivot;
47
48 Eina_Bool use_rel_pivot;
49} Efl_Animation_Object_Rotate_Data;
diff --git a/src/lib/evas/canvas/efl_animation_rotate.c b/src/lib/evas/canvas/efl_animation_rotate.c
index 31b590f..d92cf2f 100644
--- a/src/lib/evas/canvas/efl_animation_rotate.c
+++ b/src/lib/evas/canvas/efl_animation_rotate.c
@@ -174,6 +174,45 @@ _efl_animation_rotate_rotate_absolute_get(Eo *eo_obj,
174 *cy = pd->abs_pivot.cy; 174 *cy = pd->abs_pivot.cy;
175} 175}
176 176
177EOLIAN static Efl_Animation_Object *
178_efl_animation_rotate_efl_animation_object_create(Eo *eo_obj,
179 Efl_Animation_Rotate_Data *pd)
180{
181 EFL_ANIMATION_ROTATE_CHECK_OR_RETURN(eo_obj, NULL);
182
183 Efl_Animation_Object_Rotate *anim_obj
184 = efl_add(EFL_ANIMATION_OBJECT_ROTATE_CLASS, NULL);
185
186 Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
187 efl_animation_object_target_set(anim_obj, target);
188
189 Eina_Bool state_keep = efl_animation_final_state_keep_get(eo_obj);
190 efl_animation_object_final_state_keep_set(anim_obj, state_keep);
191
192 double duration = efl_animation_duration_get(eo_obj);
193 efl_animation_object_duration_set(anim_obj, duration);
194
195 if (pd->use_rel_pivot)
196 {
197 efl_animation_object_rotate_set(anim_obj,
198 pd->from.degree,
199 pd->to.degree,
200 pd->rel_pivot.obj,
201 pd->rel_pivot.cx,
202 pd->rel_pivot.cy);
203 }
204 else
205 {
206 efl_animation_object_rotate_absolute_set(anim_obj,
207 pd->from.degree,
208 pd->to.degree,
209 pd->abs_pivot.cx,
210 pd->abs_pivot.cy);
211 }
212
213 return anim_obj;
214}
215
177EOLIAN static Efl_Object * 216EOLIAN static Efl_Object *
178_efl_animation_rotate_efl_object_constructor(Eo *eo_obj, 217_efl_animation_rotate_efl_object_constructor(Eo *eo_obj,
179 Efl_Animation_Rotate_Data *pd) 218 Efl_Animation_Rotate_Data *pd)
diff --git a/src/lib/evas/canvas/efl_animation_rotate.eo b/src/lib/evas/canvas/efl_animation_rotate.eo
index d42415e..aef24fd 100644
--- a/src/lib/evas/canvas/efl_animation_rotate.eo
+++ b/src/lib/evas/canvas/efl_animation_rotate.eo
@@ -33,5 +33,6 @@ class Efl.Animation.Rotate (Efl.Animation)
33 } 33 }
34 implements { 34 implements {
35 Efl.Object.constructor; 35 Efl.Object.constructor;
36 Efl.Animation.object_create;
36 } 37 }
37} 38}