summaryrefslogtreecommitdiff
path: root/src/bin/elementary/test_efl_anim_interpolator.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/elementary/test_efl_anim_interpolator.c')
-rw-r--r--src/bin/elementary/test_efl_anim_interpolator.c99
1 files changed, 44 insertions, 55 deletions
diff --git a/src/bin/elementary/test_efl_anim_interpolator.c b/src/bin/elementary/test_efl_anim_interpolator.c
index be177d7..c5a828f 100644
--- a/src/bin/elementary/test_efl_anim_interpolator.c
+++ b/src/bin/elementary/test_efl_anim_interpolator.c
@@ -13,7 +13,7 @@
13typedef struct _App_Data 13typedef struct _App_Data
14{ 14{
15 Efl_Canvas_Animation *anim[INTERP_NUM]; 15 Efl_Canvas_Animation *anim[INTERP_NUM];
16 Efl_Canvas_Animation_Player *anim_obj[INTERP_NUM]; 16 Efl_Ui_Button *btns[INTERP_NUM];
17 17
18 Evas_Object *btn[INTERP_NUM]; 18 Evas_Object *btn[INTERP_NUM];
19 Evas_Object *start_all_btn; 19 Evas_Object *start_all_btn;
@@ -33,78 +33,84 @@ _interpolator_create(int index, Evas_Object *win)
33 else if (index == 1) 33 else if (index == 1)
34 { 34 {
35 interp = efl_add(EFL_SINUSOIDAL_INTERPOLATOR_CLASS, win); 35 interp = efl_add(EFL_SINUSOIDAL_INTERPOLATOR_CLASS, win);
36 efl_sinusoidal_interpolator_factor_set(interp, 1.0); 36 efl_sinusoidal_interpolator_slope_set(interp, 1.0);
37 } 37 }
38 else if (index == 2) 38 else if (index == 2)
39 { 39 {
40 interp = efl_add(EFL_DECELERATE_INTERPOLATOR_CLASS, win); 40 interp = efl_add(EFL_DECELERATE_INTERPOLATOR_CLASS, win);
41 efl_decelerate_interpolator_factor_set(interp, 1.0); 41 efl_decelerate_interpolator_slope_set(interp, 1.0);
42 } 42 }
43 else if (index == 3) 43 else if (index == 3)
44 { 44 {
45 interp = efl_add(EFL_ACCELERATE_INTERPOLATOR_CLASS, win); 45 interp = efl_add(EFL_ACCELERATE_INTERPOLATOR_CLASS, win);
46 efl_accelerate_interpolator_factor_set(interp, 1.0); 46 efl_accelerate_interpolator_slope_set(interp, 1.0);
47 } 47 }
48 else if (index == 4) 48 else if (index == 4)
49 { 49 {
50 interp = efl_add(EFL_DIVISOR_INTERPOLATOR_CLASS, win); 50 interp = efl_add(EFL_DIVISOR_INTERPOLATOR_CLASS, win);
51 efl_divisor_interpolator_factors_set(interp, 1.0, 1.0); 51 efl_divisor_interpolator_divisor_set(interp, 1.0);
52 efl_divisor_interpolator_power_set(interp, 1);
52 } 53 }
53 else if (index == 5) 54 else if (index == 5)
54 { 55 {
55 interp = efl_add(EFL_BOUNCE_INTERPOLATOR_CLASS, win); 56 interp = efl_add(EFL_BOUNCE_INTERPOLATOR_CLASS, win);
56 efl_bounce_interpolator_factors_set(interp, 1.0, 1.0); 57 efl_bounce_interpolator_rigidness_set(interp, 1.0);
58 efl_bounce_interpolator_bounces_set(interp, 1);
57 } 59 }
58 else if (index == 6) 60 else if (index == 6)
59 { 61 {
60 interp = efl_add(EFL_SPRING_INTERPOLATOR_CLASS, win); 62 interp = efl_add(EFL_SPRING_INTERPOLATOR_CLASS, win);
61 efl_spring_interpolator_factors_set(interp, 1.0, 1.0); 63 efl_spring_interpolator_decay_set(interp, 1.0);
64 efl_spring_interpolator_oscillations_set(interp, 1);
62 } 65 }
63 66
64 return interp; 67 return interp;
65} 68}
66 69
67static void 70static void
68_anim_started_cb(void *data, const Efl_Event *event EINA_UNUSED) 71_anim_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
69{ 72{
73 Eo *anim = event->info;
70 App_Data *ad = data; 74 App_Data *ad = data;
71 75
72 printf("Animation has been started!\n"); 76 if (anim)
73 77 {
74 ad->running_anim_cnt++; 78 printf("Animation has been started!\n");
75} 79 ad->running_anim_cnt++;
76 80 }
77static void 81 else
78_anim_ended_cb(void *data, const Efl_Event *event) 82 {
79{ 83 int i;
80 App_Data *ad = data;
81 int i;
82
83 printf("Animation has been ended!\n");
84 84
85 ad->running_anim_cnt--; 85 printf("Animation has been ended!\n");
86 ad->running_anim_cnt--;
86 87
87 for (i = 0; i < INTERP_NUM; i++) 88 for (i = 0; i < INTERP_NUM; i++)
88 {
89 if (ad->anim_obj[i] == event->object)
90 { 89 {
91 elm_object_disabled_set(ad->btn[i], EINA_FALSE); 90 if (ad->btns[i] == event->object)
92 break; 91 {
92 elm_object_disabled_set(ad->btn[i], EINA_FALSE);
93 break;
94 }
93 } 95 }
94 }
95 96
96 if (ad->running_anim_cnt == 0) 97 if (ad->running_anim_cnt == 0)
97 elm_object_disabled_set(ad->start_all_btn, EINA_FALSE); 98 elm_object_disabled_set(ad->start_all_btn, EINA_FALSE);
99 }
98} 100}
99 101
100static void 102static void
101_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event) 103_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
102{ 104{
103 Efl_Canvas_Animation_Player_Event_Running *event_running = event->info; 105 double *progress = event->info;
104 double progress = event_running->progress; 106 printf("Animation is running! Current progress(%lf)\n", *progress);
105 printf("Animation is running! Current progress(%lf)\n", progress);
106} 107}
107 108
109EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
110 {EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
111 {EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
112)
113
108static void 114static void
109_anim_start(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) 115_anim_start(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
110{ 116{
@@ -113,7 +119,7 @@ _anim_start(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
113 int index = (uintptr_t)evas_object_data_get(obj, "index"); 119 int index = (uintptr_t)evas_object_data_get(obj, "index");
114 120
115 //Let Animation Object start animation 121 //Let Animation Object start animation
116 efl_player_playing_set(ad->anim_obj[index], EINA_TRUE); 122 efl_canvas_object_animation_start(ad->btns[index], ad->anim[index], 1.0, 0.0);
117 123
118 elm_object_disabled_set(obj, EINA_TRUE); 124 elm_object_disabled_set(obj, EINA_TRUE);
119 elm_object_disabled_set(ad->start_all_btn, EINA_TRUE); 125 elm_object_disabled_set(ad->start_all_btn, EINA_TRUE);
@@ -128,7 +134,7 @@ _anim_start_all(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
128 for (i = 0; i < INTERP_NUM; i++) 134 for (i = 0; i < INTERP_NUM; i++)
129 { 135 {
130 //Let Animation Object start animation 136 //Let Animation Object start animation
131 efl_player_playing_set(ad->anim_obj[i], EINA_TRUE); 137 efl_canvas_object_animation_start(ad->btns[i], ad->anim[i], 1.0, 0.0);
132 elm_object_disabled_set(ad->btn[i], EINA_TRUE); 138 elm_object_disabled_set(ad->btn[i], EINA_TRUE);
133 } 139 }
134 140
@@ -144,9 +150,7 @@ _win_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
144 for (i = 0; i < INTERP_NUM; i++) 150 for (i = 0; i < INTERP_NUM; i++)
145 { 151 {
146 //Unregister callback called when window deletes 152 //Unregister callback called when window deletes
147 efl_event_callback_del(ad->anim_obj[i], 153 efl_event_callback_array_del(ad->btns[i], animation_stats_cb(), ad);
148 EFL_ANIMATION_PLAYER_EVENT_ENDED,
149 _anim_ended_cb, ad);
150 } 154 }
151 155
152 free(ad); 156 free(ad);
@@ -199,7 +203,7 @@ test_efl_anim_interpolator(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
199 203
200 Efl_Canvas_Animation *anim = 204 Efl_Canvas_Animation *anim =
201 efl_add(EFL_CANVAS_ANIMATION_TRANSLATE_CLASS, win); 205 efl_add(EFL_CANVAS_ANIMATION_TRANSLATE_CLASS, win);
202 efl_animation_translate_set(anim, 0, 0, (WIN_W - BTN_W), 0); 206 efl_animation_translate_set(anim, EINA_POSITION2D(0, 0), EINA_POSITION2D((WIN_W - BTN_W), 0));
203 efl_animation_duration_set(anim, 2.0); 207 efl_animation_duration_set(anim, 2.0);
204 efl_animation_final_state_keep_set(anim, EINA_FALSE); 208 efl_animation_final_state_keep_set(anim, EINA_FALSE);
205 209
@@ -208,23 +212,8 @@ test_efl_anim_interpolator(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
208 ad->anim[i] = anim; 212 ad->anim[i] = anim;
209 213
210 //Create Animation Object from Animation 214 //Create Animation Object from Animation
211 Efl_Canvas_Animation_Player *anim_obj = 215 ad->btns[i] = btn;
212 efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win, 216 efl_event_callback_array_add(btn, animation_stats_cb(), ad);
213 efl_animation_player_animation_set(efl_added, anim),
214 efl_animation_player_target_set(efl_added, btn));
215 ad->anim_obj[i] = anim_obj;
216
217 //Register callback called when animation starts
218 efl_event_callback_add(anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED,
219 _anim_started_cb, ad);
220
221 //Register callback called when animation ends
222 efl_event_callback_add(anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED,
223 _anim_ended_cb, ad);
224
225 //Register callback called while animation is executed
226 efl_event_callback_add(anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING,
227 _anim_running_cb, NULL);
228 } 217 }
229 218
230 ad->running_anim_cnt = 0; 219 ad->running_anim_cnt = 0;