summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorJunsuChoi <jsuya.choi@samsung.com>2020-01-15 09:24:12 -0500
committerMike Blumenkrantz <zmike@samsung.com>2020-01-15 09:24:12 -0500
commite71cfba201d977d4d81ccf5c39aad92a9200e05b (patch)
treed39a96e27475ceda7ef2796c09c7d9185631ea43 /src/bin
parenta63306a9087893bb894329306fe4149394db832f (diff)
elementary_test: Apply changed event related to Efl.Ui.Vg_Animation
Summary: Events has changed from Efl.Ui.Vg_Animation to Efl.Player. Apply the changes. ref T8476 Depends on D11080 Test Plan: elementary_test -to "Vector Graphics Animation" Reviewers: zmike, Hermet, kimcinoo Reviewed By: zmike Subscribers: cedric, #reviewers, #committers, segfaultxavi, bu5hm4n Tags: #efl Maniphest Tasks: T8476 Differential Revision: https://phab.enlightenment.org/D11100
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/elementary/test_efl_gfx_vg_value_provider.c163
-rw-r--r--src/bin/elementary/test_efl_ui_vg_animation.c80
2 files changed, 146 insertions, 97 deletions
diff --git a/src/bin/elementary/test_efl_gfx_vg_value_provider.c b/src/bin/elementary/test_efl_gfx_vg_value_provider.c
index c8f55c8..5b9424c 100644
--- a/src/bin/elementary/test_efl_gfx_vg_value_provider.c
+++ b/src/bin/elementary/test_efl_gfx_vg_value_provider.c
@@ -15,6 +15,12 @@
15 15
16#ifdef BUILD_VG_LOADER_JSON 16#ifdef BUILD_VG_LOADER_JSON
17 17
18typedef struct _App_Data
19{
20 Eo *label;
21 Eo *slider;
22} App_Data;
23
18Evas_Object *values[4], *anim_view; 24Evas_Object *values[4], *anim_view;
19Evas_Object *path_entry, *type_hoversel; 25Evas_Object *path_entry, *type_hoversel;
20 26
@@ -186,71 +192,12 @@ limit_frame_cb(void *data, const Efl_Event *event)
186} 192}
187 193
188static void 194static void
189update_anim_view_state(Evas_Object *anim_view, Evas_Object *label)
190{
191 Efl_Ui_Vg_Animation_State state = efl_ui_vg_animation_state_get(anim_view);
192
193 switch (state)
194 {
195 case EFL_UI_VG_ANIMATION_STATE_NOT_READY:
196 efl_text_set(label, "State = Not Ready");
197 break;
198 case EFL_UI_VG_ANIMATION_STATE_PLAYING:
199 efl_text_set(label, "State = Playing");
200 break;
201 case EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS:
202 efl_text_set(label, "State = Playing Backwards");
203
204 break;
205 case EFL_UI_VG_ANIMATION_STATE_PAUSED:
206 efl_text_set(label, "State = Paused");
207 break;
208 case EFL_UI_VG_ANIMATION_STATE_STOPPED:
209 efl_text_set(label, "State = Stopped");
210 break;
211 }
212}
213
214static void
215_play_updated(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
216{
217 Evas_Object *slider = data;
218 efl_ui_range_value_set(slider, efl_player_playback_progress_get(obj));
219}
220
221static void
222_state_update(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
223{
224 Evas_Object *label = data;
225 update_anim_view_state(obj, label);
226}
227
228static void
229_play_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
230{
231 printf("done!\n");
232}
233
234static void
235_play_repeated(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
236{
237 printf("repeated!\n");
238}
239
240static void
241_slider_changed_cb(void *data, const Efl_Event *ev) 195_slider_changed_cb(void *data, const Efl_Event *ev)
242{ 196{
243 Evas_Object *anim_view = data; 197 Evas_Object *anim_view = data;
244 efl_player_playback_progress_set(anim_view, efl_ui_range_value_get(ev->object)); 198 efl_player_playback_progress_set(anim_view, efl_ui_range_value_get(ev->object));
245} 199}
246 200
247static void
248_slider_reset(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
249{
250 Evas_Object *slider = data;
251 efl_ui_range_value_set(slider, 0);
252}
253
254void values_input(Eo* box, const char* type) 201void values_input(Eo* box, const char* type)
255{ 202{
256 for (int i = 0; i < 4; i++) 203 for (int i = 0; i < 4; i++)
@@ -300,18 +247,102 @@ _hover_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
300 values_input(box, selected); 247 values_input(box, selected);
301} 248}
302 249
250static void
251update_anim_view_state(Evas_Object *anim_view, Evas_Object *label)
252{
253 Efl_Ui_Vg_Animation_State state = efl_ui_vg_animation_state_get(anim_view);
254
255 switch (state)
256 {
257 case EFL_UI_VG_ANIMATION_STATE_NOT_READY:
258 efl_text_set(label, "State = Not Ready");
259 break;
260 case EFL_UI_VG_ANIMATION_STATE_PLAYING:
261 efl_text_set(label, "State = Playing");
262 break;
263 case EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS:
264 efl_text_set(label, "State = Playing Backwards");
265
266 break;
267 case EFL_UI_VG_ANIMATION_STATE_PAUSED:
268 efl_text_set(label, "State = Paused");
269 break;
270 case EFL_UI_VG_ANIMATION_STATE_STOPPED:
271 efl_text_set(label, "State = Stopped");
272 break;
273 }
274}
275
276static void
277_animation_playing_changed_cb(void *data, const Efl_Event *event)
278{
279 Eina_Bool playing = *(Eina_Bool*)event->info;
280 App_Data *ad = data;
281 update_anim_view_state(event->object, ad->label);
282 //Stopped
283 if (!playing)
284 efl_ui_range_value_set(ad->slider, 0);
285}
286
287static void
288_animation_paused_changed_cb(void *data, const Efl_Event *event)
289{
290 App_Data *ad = data;
291 update_anim_view_state(event->object, ad->label);
292}
293
294static void
295_animation_playback_progress_changed_cb(void *data, const Efl_Event *event)
296{
297 double progress = *(double*)event->info;
298 App_Data *ad = data;
299 efl_ui_range_value_set(ad->slider, progress);
300}
301
302static void
303_animation_playback_repeated_changed_cb(void *data EINA_UNUSED, const Efl_Event *event)
304{
305 int repeated_times = *(int*)event->info;
306 printf("repeated! (times: %d)\n", repeated_times);
307}
308
309static void
310_animation_playback_finished_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
311{
312 printf("done!\n");
313}
314
315EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
316 {EFL_PLAYER_EVENT_PLAYING_CHANGED, _animation_playing_changed_cb },
317 {EFL_PLAYER_EVENT_PAUSED_CHANGED, _animation_paused_changed_cb },
318 {EFL_PLAYER_EVENT_PLAYBACK_PROGRESS_CHANGED, _animation_playback_progress_changed_cb },
319 {EFL_PLAYER_EVENT_PLAYBACK_REPEATED, _animation_playback_repeated_changed_cb },
320 {EFL_PLAYER_EVENT_PLAYBACK_FINISHED, _animation_playback_finished_changed_cb },
321)
322
323static void
324_win_del_cb(void *data, const Efl_Event *ev EINA_UNUSED)
325{
326 App_Data *ad = data;
327 free(ad);
328}
329
303void 330void
304test_efl_gfx_vg_value_provider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 331test_efl_gfx_vg_value_provider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
305{ 332{
306 Eo *win, *box, *box_sub, *label, *check, *slider, *list; 333 Eo *win, *box, *box_sub, *label, *check, *slider, *list;
307 char buf[255]; 334 char buf[255];
335 App_Data *ad = calloc(1, sizeof(App_Data));
336 if (!ad) return;
337
308 // This line must to need. 338 // This line must to need.
309 setenv("ELM_ACCEL", "gl", 1); 339 setenv("ELM_ACCEL", "gl", 1);
310 340
311 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), 341 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
312 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC), 342 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
313 efl_text_set(efl_added, "Efl_Ui_Vg_Animation demo"), 343 efl_text_set(efl_added, "Efl_Ui_Vg_Animation demo"),
314 efl_ui_win_autodel_set(efl_added, EINA_TRUE)); 344 efl_ui_win_autodel_set(efl_added, EINA_TRUE),
345 efl_event_callback_add(efl_added, EFL_EVENT_DEL, _win_del_cb, ad));
315 346
316 // Create a box in Canvas 347 // Create a box in Canvas
317 box = efl_add(EFL_UI_BOX_CLASS, win, 348 box = efl_add(EFL_UI_BOX_CLASS, win,
@@ -558,16 +589,10 @@ test_efl_gfx_vg_value_provider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU
558 efl_pack(box_sub, efl_added), 589 efl_pack(box_sub, efl_added),
559 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view)); 590 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
560 591
561 evas_object_smart_callback_add(anim_view, "play,start", _state_update, label); 592 efl_event_callback_array_add(anim_view, animation_stats_cb(), ad);
562 evas_object_smart_callback_add(anim_view, "play,stop", _state_update, label);
563 evas_object_smart_callback_add(anim_view, "play,pause", _state_update, label);
564 evas_object_smart_callback_add(anim_view, "play,resume", _state_update, label);
565
566 evas_object_smart_callback_add(anim_view, "play,repeat", _play_repeated, label);
567 evas_object_smart_callback_add(anim_view, "play,done", _play_done, label);
568 593
569 evas_object_smart_callback_add(anim_view, "play,update", _play_updated, slider); 594 ad->label = label;
570 evas_object_smart_callback_add(anim_view, "play,stop", _slider_reset, slider); 595 ad->slider = slider;
571 596
572 update_anim_view_state(anim_view, label); 597 update_anim_view_state(anim_view, label);
573 598
diff --git a/src/bin/elementary/test_efl_ui_vg_animation.c b/src/bin/elementary/test_efl_ui_vg_animation.c
index 8c6f38d..b514919 100644
--- a/src/bin/elementary/test_efl_ui_vg_animation.c
+++ b/src/bin/elementary/test_efl_ui_vg_animation.c
@@ -14,6 +14,12 @@
14 14
15#ifdef BUILD_VG_LOADER_JSON 15#ifdef BUILD_VG_LOADER_JSON
16 16
17typedef struct _App_Data
18{
19 Eo *label;
20 Eo *slider;
21} App_Data;
22
17static void 23static void
18btn_clicked_cb(void *data , const Efl_Event *ev ) 24btn_clicked_cb(void *data , const Efl_Event *ev )
19{ 25{
@@ -79,6 +85,13 @@ limit_frame_cb(void *data, const Efl_Event *event)
79} 85}
80 86
81static void 87static void
88_slider_changed_cb(void *data, const Efl_Event *ev)
89{
90 Evas_Object *anim_view = data;
91 efl_player_playback_progress_set(anim_view, efl_ui_range_value_get(ev->object));
92}
93
94static void
82update_anim_view_state(Evas_Object *anim_view, Evas_Object *label) 95update_anim_view_state(Evas_Object *anim_view, Evas_Object *label)
83{ 96{
84 Efl_Ui_Vg_Animation_State state = efl_ui_vg_animation_state_get(anim_view); 97 Efl_Ui_Vg_Animation_State state = efl_ui_vg_animation_state_get(anim_view);
@@ -104,43 +117,57 @@ update_anim_view_state(Evas_Object *anim_view, Evas_Object *label)
104} 117}
105 118
106static void 119static void
107_play_updated(void *data, Evas_Object *obj, void *ev EINA_UNUSED) 120_animation_playing_changed_cb(void *data, const Efl_Event *event)
108{ 121{
109 Evas_Object *slider = data; 122 Eina_Bool playing = *(Eina_Bool*)event->info;
110 efl_ui_range_value_set(slider, efl_player_playback_progress_get(obj)); 123 App_Data *ad = data;
124 update_anim_view_state(event->object, ad->label);
125 //Stopped
126 if (!playing)
127 efl_ui_range_value_set(ad->slider, 0);
111} 128}
112 129
113static void 130static void
114_state_update(void *data, Evas_Object *obj, void *ev EINA_UNUSED) 131_animation_paused_changed_cb(void *data, const Efl_Event *event)
115{ 132{
116 Evas_Object *label = data; 133 App_Data *ad = data;
117 update_anim_view_state(obj, label); 134 update_anim_view_state(event->object, ad->label);
118} 135}
119 136
120static void 137static void
121_play_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED) 138_animation_playback_progress_changed_cb(void *data, const Efl_Event *event)
122{ 139{
123 printf("done!\n"); 140 double progress = *(double*)event->info;
141 App_Data *ad = data;
142 efl_ui_range_value_set(ad->slider, progress);
124} 143}
125 144
126static void 145static void
127_play_repeated(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED) 146_animation_playback_repeated_changed_cb(void *data EINA_UNUSED, const Efl_Event *event)
128{ 147{
129 printf("repeated!\n"); 148 int repeated_times = *(int*)event->info;
149 printf("repeated! (times: %d)\n", repeated_times);
130} 150}
131 151
132static void 152static void
133_slider_changed_cb(void *data, const Efl_Event *ev) 153_animation_playback_finished_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
134{ 154{
135 Evas_Object *anim_view = data; 155 printf("done!\n");
136 efl_player_playback_progress_set(anim_view, efl_ui_range_value_get(ev->object));
137} 156}
138 157
158EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
159 {EFL_PLAYER_EVENT_PLAYING_CHANGED, _animation_playing_changed_cb },
160 {EFL_PLAYER_EVENT_PAUSED_CHANGED, _animation_paused_changed_cb },
161 {EFL_PLAYER_EVENT_PLAYBACK_PROGRESS_CHANGED, _animation_playback_progress_changed_cb },
162 {EFL_PLAYER_EVENT_PLAYBACK_REPEATED, _animation_playback_repeated_changed_cb },
163 {EFL_PLAYER_EVENT_PLAYBACK_FINISHED, _animation_playback_finished_changed_cb },
164)
165
139static void 166static void
140_slider_reset(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED) 167_win_del_cb(void *data, const Efl_Event *ev EINA_UNUSED)
141{ 168{
142 Evas_Object *slider = data; 169 App_Data *ad = data;
143 efl_ui_range_value_set(slider, 0); 170 free(ad);
144} 171}
145 172
146void 173void
@@ -148,10 +175,13 @@ test_efl_ui_vg_animation(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, v
148{ 175{
149 Eo *win, *box, *box2, *box3, *box4, *label, *anim_view, *check, *slider; 176 Eo *win, *box, *box2, *box3, *box4, *label, *anim_view, *check, *slider;
150 char buf[255]; 177 char buf[255];
178 App_Data *ad = calloc(1, sizeof(App_Data));
179 if (!ad) return;
151 180
152 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), 181 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
153 efl_text_set(efl_added, "Efl_Ui_Vg_Animation demo"), 182 efl_text_set(efl_added, "Efl_Ui_Vg_Animation demo"),
154 efl_ui_win_autodel_set(efl_added, EINA_TRUE)); 183 efl_ui_win_autodel_set(efl_added, EINA_TRUE),
184 efl_event_callback_add(efl_added, EFL_EVENT_DEL, _win_del_cb, ad));
155 185
156 // Create a box in Canvas 186 // Create a box in Canvas
157 box = efl_add(EFL_UI_BOX_CLASS, win, 187 box = efl_add(EFL_UI_BOX_CLASS, win,
@@ -279,19 +309,13 @@ test_efl_ui_vg_animation(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, v
279 efl_pack(box4, efl_added), 309 efl_pack(box4, efl_added),
280 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view)); 310 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
281 311
282 evas_object_smart_callback_add(anim_view, "play,start", _state_update, label); 312 efl_event_callback_array_add(anim_view, animation_stats_cb(), ad);
283 evas_object_smart_callback_add(anim_view, "play,stop", _state_update, label);
284 evas_object_smart_callback_add(anim_view, "play,pause", _state_update, label);
285 evas_object_smart_callback_add(anim_view, "play,resume", _state_update, label);
286
287 evas_object_smart_callback_add(anim_view, "play,repeat", _play_repeated, label);
288 evas_object_smart_callback_add(anim_view, "play,done", _play_done, label);
289
290 evas_object_smart_callback_add(anim_view, "play,update", _play_updated, slider);
291 evas_object_smart_callback_add(anim_view, "play,stop", _slider_reset, slider);
292 313
293 update_anim_view_state(anim_view, label); 314 update_anim_view_state(anim_view, label);
294 315
316 ad->label = label;
317 ad->slider = slider;
318
295 efl_gfx_entity_size_set(win, EINA_SIZE2D(600, 730)); 319 efl_gfx_entity_size_set(win, EINA_SIZE2D(600, 730));
296} 320}
297 321