summaryrefslogtreecommitdiff
path: root/src/bin/elementary/test_efl_anim_rotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/elementary/test_efl_anim_rotate.c')
-rw-r--r--src/bin/elementary/test_efl_anim_rotate.c85
1 files changed, 32 insertions, 53 deletions
diff --git a/src/bin/elementary/test_efl_anim_rotate.c b/src/bin/elementary/test_efl_anim_rotate.c
index 10df8ca..437d015 100644
--- a/src/bin/elementary/test_efl_anim_rotate.c
+++ b/src/bin/elementary/test_efl_anim_rotate.c
@@ -7,31 +7,38 @@ typedef struct _App_Data
7{ 7{
8 Efl_Canvas_Animation *cw_45_degrees_anim; 8 Efl_Canvas_Animation *cw_45_degrees_anim;
9 Efl_Canvas_Animation *ccw_45_degrees_anim; 9 Efl_Canvas_Animation *ccw_45_degrees_anim;
10 Efl_Canvas_Animation_Player *anim_obj; 10 Elm_Button *button;
11 11
12 Eina_Bool is_btn_rotated; 12 Eina_Bool is_btn_rotated;
13} App_Data; 13} App_Data;
14 14
15static void 15static void
16_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) 16_anim_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
17{ 17{
18 printf("Animation has been started!\n"); 18 Eo *anim = event->info;
19}
20 19
21static void 20 if (anim)
22_anim_ended_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) 21 {
23{ 22 printf("Animation has been started!\n");
24 printf("Animation has been ended!\n"); 23 }
24 else
25 {
26 printf("Animation has been ended!\n");
27 }
25} 28}
26 29
27static void 30static void
28_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event) 31_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
29{ 32{
30 Efl_Canvas_Animation_Player_Event_Running *event_running = event->info; 33 double *progress = event->info;
31 double progress = event_running->progress; 34 printf("Animation is running! Current progress(%lf)\n", *progress);
32 printf("Animation is running! Current progress(%lf)\n", progress);
33} 35}
34 36
37EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
38 {EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
39 {EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
40)
41
35static void 42static void
36_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) 43_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
37{ 44{
@@ -42,18 +49,15 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
42 if (ad->is_btn_rotated) 49 if (ad->is_btn_rotated)
43 { 50 {
44 //Create Animation Object from Animation 51 //Create Animation Object from Animation
45 efl_animation_player_animation_set(ad->anim_obj, ad->cw_45_degrees_anim); 52 efl_canvas_object_animation_start(ad->button, ad->cw_45_degrees_anim, 1.0, 0.0);
46 efl_text_set(obj, "Start Rotate Animation from 45 to 0 degrees"); 53 efl_text_set(obj, "Start Rotate Animation from 45 to 0 degrees");
47 } 54 }
48 else 55 else
49 { 56 {
50 //Create Animation Object from Animation 57 //Create Animation Object from Animation
51 efl_animation_player_animation_set(ad->anim_obj, ad->ccw_45_degrees_anim); 58 efl_canvas_object_animation_start(ad->button, ad->ccw_45_degrees_anim, 1.0, 0.0);
52 efl_text_set(obj, "Start Rotate Animation from 0 to 45 degrees"); 59 efl_text_set(obj, "Start Rotate Animation from 0 to 45 degrees");
53 } 60 }
54
55 //Let Animation Object start animation
56 efl_player_playing_set(ad->anim_obj, EINA_TRUE);
57} 61}
58 62
59static void 63static void
@@ -81,32 +85,24 @@ test_efl_anim_rotate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
81 evas_object_resize(btn, 150, 150); 85 evas_object_resize(btn, 150, 150);
82 evas_object_move(btn, 125, 100); 86 evas_object_move(btn, 125, 100);
83 evas_object_show(btn); 87 evas_object_show(btn);
88 efl_event_callback_array_add(btn, animation_stats_cb(), ad);
84 89
85 //Rotate from 0 to 45 degrees Animation 90 //Rotate from 0 to 45 degrees Animation
86 Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); 91 Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win);
87 efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0,NULL, 0.5, 0.5); 92 efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, NULL, EINA_VECTOR2(0.5, 0.5));
88 efl_animation_duration_set(cw_45_degrees_anim, 1.0); 93 efl_animation_duration_set(cw_45_degrees_anim, 1.0);
89 efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE); 94 efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE);
90 95
91 //Rotate from 45 to 0 degrees Animation 96 //Rotate from 45 to 0 degrees Animation
92 Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); 97 Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win);
93 efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, NULL, 0.5, 0.5); 98 efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, NULL, EINA_VECTOR2(0.5, 0.5));
94 efl_animation_duration_set(ccw_45_degrees_anim, 1.0); 99 efl_animation_duration_set(ccw_45_degrees_anim, 1.0);
95 efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE); 100 efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE);
96 101
97 //Initialize App Data 102 //Initialize App Data
98 ad->cw_45_degrees_anim = cw_45_degrees_anim; 103 ad->cw_45_degrees_anim = cw_45_degrees_anim;
99 ad->ccw_45_degrees_anim = ccw_45_degrees_anim; 104 ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
100 105 ad->button = btn;
101 ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
102 efl_animation_player_target_set(efl_added, btn));
103 //Register callback called when animation starts
104 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
105 //Register callback called when animation ends
106 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, NULL);
107 //Register callback called while animation is executed
108 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
109
110 ad->is_btn_rotated = EINA_FALSE; 106 ad->is_btn_rotated = EINA_FALSE;
111 107
112 //Button to start animation 108 //Button to start animation
@@ -140,6 +136,7 @@ test_efl_anim_rotate_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS
140 evas_object_resize(btn, 150, 150); 136 evas_object_resize(btn, 150, 150);
141 evas_object_move(btn, 125, 100); 137 evas_object_move(btn, 125, 100);
142 evas_object_show(btn); 138 evas_object_show(btn);
139 efl_event_callback_array_add(btn, animation_stats_cb(), ad);
143 140
144 //Pivot to be center of the rotation 141 //Pivot to be center of the rotation
145 Evas_Object *pivot = elm_button_add(win); 142 Evas_Object *pivot = elm_button_add(win);
@@ -151,31 +148,21 @@ test_efl_anim_rotate_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS
151 148
152 //Rotate from 0 to 45 degrees Animation 149 //Rotate from 0 to 45 degrees Animation
153 Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); 150 Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win);
154 efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, pivot, 0.5, 0.5); 151 efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, pivot, EINA_VECTOR2(0.5, 0.5));
155 efl_animation_duration_set(cw_45_degrees_anim, 1.0); 152 efl_animation_duration_set(cw_45_degrees_anim, 1.0);
156 efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE); 153 efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE);
157 154
158 //Rotate from 45 to 0 degrees Animation 155 //Rotate from 45 to 0 degrees Animation
159 Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); 156 Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win);
160 efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, pivot, 0.5, 0.5); 157 efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, pivot, EINA_VECTOR2(0.5, 0.5));
161 efl_animation_duration_set(ccw_45_degrees_anim, 1.0); 158 efl_animation_duration_set(ccw_45_degrees_anim, 1.0);
162 efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE); 159 efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE);
163 160
164 //Initialize App Data 161 //Initialize App Data
165 ad->cw_45_degrees_anim = cw_45_degrees_anim; 162 ad->cw_45_degrees_anim = cw_45_degrees_anim;
166 ad->ccw_45_degrees_anim = ccw_45_degrees_anim; 163 ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
167 ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
168 efl_animation_player_target_set(efl_added, btn));
169
170 //Register callback called when animation starts
171 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
172
173 //Register callback called when animation ends
174 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, NULL);
175
176 //Register callback called while animation is executed
177 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
178 ad->is_btn_rotated = EINA_FALSE; 164 ad->is_btn_rotated = EINA_FALSE;
165 ad->button = btn;
179 166
180 //Button to start animation 167 //Button to start animation
181 Evas_Object *btn2 = elm_button_add(win); 168 Evas_Object *btn2 = elm_button_add(win);
@@ -208,6 +195,7 @@ test_efl_anim_rotate_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS
208 evas_object_resize(btn, 150, 150); 195 evas_object_resize(btn, 150, 150);
209 evas_object_move(btn, 125, 100); 196 evas_object_move(btn, 125, 100);
210 evas_object_show(btn); 197 evas_object_show(btn);
198 efl_event_callback_array_add(btn, animation_stats_cb(), ad);
211 199
212 //Absolute coordinate (0, 0) to be center of the rotation 200 //Absolute coordinate (0, 0) to be center of the rotation
213 Evas_Object *abs_center = elm_button_add(win); 201 Evas_Object *abs_center = elm_button_add(win);
@@ -219,30 +207,21 @@ test_efl_anim_rotate_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS
219 207
220 //Rotate from 0 to 45 degrees Animation 208 //Rotate from 0 to 45 degrees Animation
221 Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); 209 Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win);
222 efl_animation_rotate_absolute_set(cw_45_degrees_anim, 0.0, 45.0, 0, 0); 210 efl_animation_rotate_absolute_set(cw_45_degrees_anim, 0.0, 45.0, EINA_POSITION2D(0, 0));
223 efl_animation_duration_set(cw_45_degrees_anim, 1.0); 211 efl_animation_duration_set(cw_45_degrees_anim, 1.0);
224 efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE); 212 efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE);
225 213
226 //Rotate from 45 to 0 degrees Animation 214 //Rotate from 45 to 0 degrees Animation
227 Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); 215 Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win);
228 efl_animation_rotate_absolute_set(ccw_45_degrees_anim, 45.0, 0.0, 0, 0); 216 efl_animation_rotate_absolute_set(ccw_45_degrees_anim, 45.0, 0.0, EINA_POSITION2D(0, 0));
229 efl_animation_duration_set(ccw_45_degrees_anim, 1.0); 217 efl_animation_duration_set(ccw_45_degrees_anim, 1.0);
230 efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE); 218 efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE);
231 219
232 //Initialize App Data 220 //Initialize App Data
233 ad->cw_45_degrees_anim = cw_45_degrees_anim; 221 ad->cw_45_degrees_anim = cw_45_degrees_anim;
234 ad->ccw_45_degrees_anim = ccw_45_degrees_anim; 222 ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
235 ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
236 efl_animation_player_target_set(efl_added, btn));
237
238 //Register callback called when animation starts
239 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
240 //Register callback called when animation ends
241 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, NULL);
242 //Register callback called while animation is executed
243 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
244
245 ad->is_btn_rotated = EINA_FALSE; 223 ad->is_btn_rotated = EINA_FALSE;
224 ad->button = btn;
246 225
247 //Button to start animation 226 //Button to start animation
248 Evas_Object *btn2 = elm_button_add(win); 227 Evas_Object *btn2 = elm_button_add(win);