summaryrefslogtreecommitdiff
path: root/src/bin/elementary/test_efl_anim_scale.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/elementary/test_efl_anim_scale.c')
-rw-r--r--src/bin/elementary/test_efl_anim_scale.c84
1 files changed, 32 insertions, 52 deletions
diff --git a/src/bin/elementary/test_efl_anim_scale.c b/src/bin/elementary/test_efl_anim_scale.c
index 5e5f9ab..93ac1f7 100644
--- a/src/bin/elementary/test_efl_anim_scale.c
+++ b/src/bin/elementary/test_efl_anim_scale.c
@@ -7,31 +7,38 @@ typedef struct _App_Data
7{ 7{
8 Efl_Canvas_Animation *scale_double_anim; 8 Efl_Canvas_Animation *scale_double_anim;
9 Efl_Canvas_Animation *scale_half_anim; 9 Efl_Canvas_Animation *scale_half_anim;
10 Efl_Canvas_Animation_Player *anim_obj; 10 Elm_Button *button;
11 11
12 Eina_Bool is_btn_scaled; 12 Eina_Bool is_btn_scaled;
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_scaled) 49 if (ad->is_btn_scaled)
43 { 50 {
44 //Create Animation Object from Animation 51 //Create Animation Object from Animation
45 efl_animation_player_animation_set(ad->anim_obj, ad->scale_double_anim); 52 efl_canvas_object_animation_start(ad->button, ad->scale_double_anim, 1.0, 0.0);
46 efl_text_set(obj, "Start Scale Animation to zoom out"); 53 efl_text_set(obj, "Start Scale Animation to zoom out");
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->scale_half_anim); 58 efl_canvas_object_animation_start(ad->button, ad->scale_half_anim, 1.0, 0.0);
52 efl_text_set(obj, "Start Scale Animation to zoom in"); 59 efl_text_set(obj, "Start Scale Animation to zoom in");
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,35 +85,25 @@ test_efl_anim_scale(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 //Scale Animation to zoom in 90 //Scale Animation to zoom in
86 Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win); 91 Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
87 efl_animation_scale_set(scale_double_anim, 1.0, 1.0, 2.0, 2.0, NULL, 0.5, 0.5); 92 efl_animation_scale_set(scale_double_anim, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(2.0, 2.0), NULL, EINA_VECTOR2(0.5, 0.5));
88 efl_animation_duration_set(scale_double_anim, 1.0); 93 efl_animation_duration_set(scale_double_anim, 1.0);
89 efl_animation_final_state_keep_set(scale_double_anim, EINA_TRUE); 94 efl_animation_final_state_keep_set(scale_double_anim, EINA_TRUE);
90 95
91 //Scale Animation to zoom out 96 //Scale Animation to zoom out
92 Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win); 97 Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
93 efl_animation_scale_set(scale_half_anim, 2.0, 2.0, 1.0, 1.0, NULL, 0.5, 0.5); 98 efl_animation_scale_set(scale_half_anim, EINA_VECTOR2(2.0, 2.0), EINA_VECTOR2(1.0, 1.0), NULL, EINA_VECTOR2(0.5, 0.5));
94 efl_animation_duration_set(scale_half_anim, 1.0); 99 efl_animation_duration_set(scale_half_anim, 1.0);
95 efl_animation_final_state_keep_set(scale_half_anim, EINA_TRUE); 100 efl_animation_final_state_keep_set(scale_half_anim, EINA_TRUE);
96 101
97 //Initialize App Data 102 //Initialize App Data
98 ad->scale_double_anim = scale_double_anim; 103 ad->scale_double_anim = scale_double_anim;
99 ad->scale_half_anim = scale_half_anim; 104 ad->scale_half_anim = scale_half_anim;
100 ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
101 efl_animation_player_target_set(efl_added, btn));
102
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
106 //Register callback called when animation ends
107 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, ad);
108
109 //Register callback called while animation is executed
110 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
111
112 ad->is_btn_scaled = EINA_FALSE; 105 ad->is_btn_scaled = EINA_FALSE;
106 ad->button = btn;
113 107
114 //Button to start animation 108 //Button to start animation
115 Evas_Object *btn2 = elm_button_add(win); 109 Evas_Object *btn2 = elm_button_add(win);
@@ -142,6 +136,7 @@ test_efl_anim_scale_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
142 evas_object_resize(btn, 150, 150); 136 evas_object_resize(btn, 150, 150);
143 evas_object_move(btn, 125, 100); 137 evas_object_move(btn, 125, 100);
144 evas_object_show(btn); 138 evas_object_show(btn);
139 efl_event_callback_array_add(btn, animation_stats_cb(), ad);
145 140
146 //Pivot to be center of the scaling 141 //Pivot to be center of the scaling
147 Evas_Object *pivot = elm_button_add(win); 142 Evas_Object *pivot = elm_button_add(win);
@@ -153,28 +148,20 @@ test_efl_anim_scale_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
153 148
154 //Scale Animation to zoom in 149 //Scale Animation to zoom in
155 Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win); 150 Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
156 efl_animation_scale_set(scale_double_anim, 1.0, 1.0, 2.0, 2.0, pivot, 0.5, 0.5); 151 efl_animation_scale_set(scale_double_anim, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(2.0, 2.0), pivot, EINA_VECTOR2(0.5, 0.5));
157 efl_animation_duration_set(scale_double_anim, 1.0); 152 efl_animation_duration_set(scale_double_anim, 1.0);
158 efl_animation_final_state_keep_set(scale_double_anim, EINA_TRUE); 153 efl_animation_final_state_keep_set(scale_double_anim, EINA_TRUE);
159 154
160 //Scale Animation to zoom out 155 //Scale Animation to zoom out
161 Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win); 156 Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
162 efl_animation_scale_set(scale_half_anim, 2.0, 2.0, 1.0, 1.0, pivot, 0.5, 0.5); 157 efl_animation_scale_set(scale_half_anim, EINA_VECTOR2(2.0, 2.0), EINA_VECTOR2(1.0, 1.0), pivot, EINA_VECTOR2(0.5, 0.5));
163 efl_animation_duration_set(scale_half_anim, 1.0); 158 efl_animation_duration_set(scale_half_anim, 1.0);
164 efl_animation_final_state_keep_set(scale_half_anim, EINA_TRUE); 159 efl_animation_final_state_keep_set(scale_half_anim, EINA_TRUE);
165 160
166 //Initialize App Data 161 //Initialize App Data
167 ad->scale_double_anim = scale_double_anim; 162 ad->scale_double_anim = scale_double_anim;
168 ad->scale_half_anim = scale_half_anim; 163 ad->scale_half_anim = scale_half_anim;
169 ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win, 164 ad->button = btn;
170 efl_animation_player_target_set(efl_added, btn));
171 //Register callback called when animation starts
172 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
173 //Register callback called when animation ends
174 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, ad);
175 //Register callback called while animation is executed
176 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
177
178 ad->is_btn_scaled = EINA_FALSE; 165 ad->is_btn_scaled = EINA_FALSE;
179 166
180 //Button to start animation 167 //Button to start animation
@@ -208,6 +195,7 @@ test_efl_anim_scale_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
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 scaling 200 //Absolute coordinate (0, 0) to be center of the scaling
213 Evas_Object *abs_center = elm_button_add(win); 201 Evas_Object *abs_center = elm_button_add(win);
@@ -219,28 +207,20 @@ test_efl_anim_scale_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
219 207
220 //Scale Animation to zoom in 208 //Scale Animation to zoom in
221 Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win); 209 Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
222 efl_animation_scale_absolute_set(scale_double_anim, 1.0, 1.0, 2.0, 2.0, 0, 0); 210 efl_animation_scale_absolute_set(scale_double_anim, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(2.0, 2.0), EINA_POSITION2D(0, 0));
223 efl_animation_duration_set(scale_double_anim, 1.0); 211 efl_animation_duration_set(scale_double_anim, 1.0);
224 efl_animation_final_state_keep_set(scale_double_anim, EINA_TRUE); 212 efl_animation_final_state_keep_set(scale_double_anim, EINA_TRUE);
225 213
226 //Scale Animation to zoom out 214 //Scale Animation to zoom out
227 Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win); 215 Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
228 efl_animation_scale_absolute_set(scale_half_anim, 2.0, 2.0, 1.0, 1.0, 0, 0); 216 efl_animation_scale_absolute_set(scale_half_anim, EINA_VECTOR2(2.0, 2.0), EINA_VECTOR2(1.0, 1.0), EINA_POSITION2D(0, 0));
229 efl_animation_duration_set(scale_half_anim, 1.0); 217 efl_animation_duration_set(scale_half_anim, 1.0);
230 efl_animation_final_state_keep_set(scale_half_anim, EINA_TRUE); 218 efl_animation_final_state_keep_set(scale_half_anim, EINA_TRUE);
231 219
232 //Initialize App Data 220 //Initialize App Data
233 ad->scale_double_anim = scale_double_anim; 221 ad->scale_double_anim = scale_double_anim;
234 ad->scale_half_anim = scale_half_anim; 222 ad->scale_half_anim = scale_half_anim;
235 ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win, 223 ad->button = btn;
236 efl_animation_player_target_set(efl_added, btn));
237 //Register callback called when animation starts
238 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
239 //Register callback called when animation ends
240 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, ad);
241 //Register callback called while animation is executed
242 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
243
244 ad->is_btn_scaled = EINA_FALSE; 224 ad->is_btn_scaled = EINA_FALSE;
245 225
246 //Button to start animation 226 //Button to start animation