summaryrefslogtreecommitdiff
path: root/src/bin/elementary/test_efl_ui_animation_view.c
diff options
context:
space:
mode:
authorJunsuChoi <jsuya.choi@samsung.com>2019-08-21 17:53:14 +0900
committerHermet Park <hermetpark@gmail.com>2019-08-21 18:03:00 +0900
commit7a7d6a858d0dccba3d7d73779e39a999eaf543e9 (patch)
tree2599018914108c4e91803db2d3f2dbf47e70996c /src/bin/elementary/test_efl_ui_animation_view.c
parent8900cf0715e97640eb6226023a6005b4c6021e42 (diff)
elementary_test: Add the animation view test
Summary: Add an animation view item to test vector animation on elementary_test. If Evas Vg Json(Lottie) Loader is not supported, use the vector class to output the svg file. Depends {D9451} Test Plan: elementart_test Animation View Reviewers: Hermet, smohanty, kimcinoo, zmike Subscribers: zmike, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9472
Diffstat (limited to '')
-rw-r--r--src/bin/elementary/test_efl_ui_animation_view.c328
1 files changed, 328 insertions, 0 deletions
diff --git a/src/bin/elementary/test_efl_ui_animation_view.c b/src/bin/elementary/test_efl_ui_animation_view.c
new file mode 100644
index 0000000..8d06d6a
--- /dev/null
+++ b/src/bin/elementary/test_efl_ui_animation_view.c
@@ -0,0 +1,328 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5#include <Efl_Ui.h>
6
7#ifndef EFL_BETA_API_SUPPORT
8#define EFL_BETA_API_SUPPORT
9#endif
10
11#ifndef EFL_EO_API_SUPPORT
12#define EFL_EO_API_SUPPORT
13#endif
14
15#ifdef BUILD_VG_LOADER_JSON
16
17static void
18btn_clicked_cb(void *data , const Efl_Event *ev )
19{
20 Evas_Object *anim_view = data;
21 const char *text = efl_text_get(ev->object);
22
23 if (!text) return;
24
25 if (!strcmp("Play", text))
26 efl_ui_animation_view_play(anim_view);
27 else if (!strcmp("Pause", text))
28 efl_ui_animation_view_pause(anim_view);
29 else if (!strcmp("Resume", text))
30 efl_ui_animation_view_resume(anim_view);
31 else if (!strcmp("Play Back", text))
32 efl_ui_animation_view_play_back(anim_view);
33 else if (!strcmp("Stop", text))
34 efl_ui_animation_view_stop(anim_view);
35}
36
37static void
38check_changed_cb(void *data, const Efl_Event *event)
39{
40 Evas_Object *anim_view = data;
41 efl_ui_animation_view_auto_repeat_set(anim_view, efl_ui_selectable_selected_get(event->object));
42}
43
44static void
45speed_changed_cb(void *data, const Efl_Event *event)
46{
47 Evas_Object *anim_view = data;
48 double speed = 1;
49 if (efl_ui_selectable_selected_get(event->object)) speed = 0.25;
50 efl_ui_animation_view_speed_set(anim_view, speed);
51}
52
53static void
54limit_frame_cb(void *data, const Efl_Event *event)
55{
56 Evas_Object *anim_view = data;
57 int frame_count = efl_ui_animation_view_frame_count_get(anim_view);
58 printf("Total Frame Count : %d\n", frame_count);
59 if (efl_ui_selectable_selected_get(event->object))
60 {
61 efl_ui_animation_view_min_frame_set(anim_view, 5);
62 efl_ui_animation_view_max_frame_set(anim_view, 10);
63 printf("Frames to show 5-10 only\n");
64 }
65 else
66 {
67 efl_ui_animation_view_min_frame_set(anim_view, 0);
68 efl_ui_animation_view_max_frame_set(anim_view, frame_count);
69 printf("Showing all frames now\n");
70 }
71}
72
73static void
74update_anim_view_state(Evas_Object *anim_view, Evas_Object *label)
75{
76 Efl_Ui_Animation_View_State state = efl_ui_animation_view_state_get(anim_view);
77
78 switch (state)
79 {
80 case EFL_UI_ANIMATION_VIEW_STATE_NOT_READY:
81 efl_text_set(label, "State = Not Ready");
82 break;
83 case EFL_UI_ANIMATION_VIEW_STATE_PLAY:
84 efl_text_set(label, "State = Playing");
85 break;
86 case EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK:
87 efl_text_set(label, "State = Playing Back");
88 break;
89 case EFL_UI_ANIMATION_VIEW_STATE_PAUSE:
90 efl_text_set(label, "State = Paused");
91 break;
92 case EFL_UI_ANIMATION_VIEW_STATE_STOP:
93 efl_text_set(label, "State = Stopped");
94 break;
95 }
96}
97
98static void
99_play_updated(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
100{
101 Evas_Object *slider = data;
102 efl_ui_range_value_set(slider, efl_ui_animation_view_progress_get(obj));
103}
104
105static void
106_state_update(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
107{
108 Evas_Object *label = data;
109 update_anim_view_state(obj, label);
110}
111
112static void
113_play_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
114{
115 printf("done!\n");
116}
117
118static void
119_play_repeated(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
120{
121 printf("repeated!\n");
122}
123
124static void
125_slider_changed_cb(void *data, const Efl_Event *ev)
126{
127 Evas_Object *anim_view = data;
128 efl_ui_animation_view_progress_set(anim_view, efl_ui_range_value_get(ev->object));
129}
130
131static void
132_slider_reset(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
133{
134 Evas_Object *slider = data;
135 efl_ui_range_value_set(slider, 0);
136}
137
138void
139test_efl_ui_animation_view(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
140{
141 Eo *win, *box, *box2, *box3, *box4, *label, *anim_view, *check, *slider;
142 char buf[255];
143
144 win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
145 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
146 efl_text_set(efl_added, "Efl_Ui_Animation_View demo"),
147 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
148
149 // Create a box in Canvas
150 box = efl_add(EFL_UI_BOX_CLASS, win,
151 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND),
152 efl_content_set(win, efl_added));
153
154 //Create a label to show state of animation
155 label = efl_add(EFL_UI_TEXT_CLASS, win,
156 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0.1),
157 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
158 efl_pack(box, efl_added));
159
160 //Create Animation View to play animation directly from JSON file
161 snprintf(buf, sizeof(buf), "%s/images/emoji_wink.json", elm_app_data_dir_get());
162 anim_view = efl_add(EFL_UI_ANIMATION_VIEW_CLASS, win,
163 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND),
164 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
165 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(600, 600)),
166 efl_file_set(efl_added, buf),
167 efl_pack(box, efl_added));
168
169 // Controller Set : 0
170 box2 = efl_add(EFL_UI_BOX_CLASS, box,
171 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0.1),
172 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
173 efl_pack(box, efl_added));
174
175 //Loop
176 check = efl_add(EFL_UI_CHECK_CLASS, box2,
177 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
178 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
179 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
180 efl_pack(box2, efl_added));
181 efl_text_set(check, "Loop");
182 efl_event_callback_add(check, EFL_UI_EVENT_SELECTED_CHANGED, check_changed_cb, anim_view);
183
184 //Speed: 0.5x
185 check = efl_add(EFL_UI_CHECK_CLASS, box2,
186 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
187 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
188 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
189 efl_pack(box2, efl_added));
190 efl_text_set(check, "Speed: 0.25x");
191 efl_event_callback_add(check, EFL_UI_EVENT_SELECTED_CHANGED, speed_changed_cb, anim_view);
192
193 //Limit Frames
194 check = efl_add(EFL_UI_CHECK_CLASS, box2,
195 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
196 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
197 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
198 efl_pack(box2, efl_added));
199 efl_text_set(check, "Limit Frames");
200 efl_event_callback_add(check, EFL_UI_EVENT_SELECTED_CHANGED, limit_frame_cb, anim_view);
201
202
203 //Duration Text
204 snprintf(buf, sizeof(buf), "Duration: %1.2fs", efl_ui_animation_view_duration_time_get(anim_view));
205 efl_add(EFL_UI_TEXT_CLASS, box2,
206 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
207 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
208 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
209 efl_text_set(efl_added, buf),
210 efl_pack(box2, efl_added));
211
212 //Slider
213 slider = efl_add(EFL_UI_SLIDER_CLASS, box,
214 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0.1),
215 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
216 efl_ui_range_limits_set(efl_added, 0, 1),
217 efl_event_callback_add(efl_added, EFL_UI_RANGE_EVENT_CHANGED, _slider_changed_cb, anim_view),
218 efl_pack(box, efl_added));
219
220 //Controller Set: 1
221 box3 = efl_add(EFL_UI_BOX_CLASS, box,
222 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
223 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, 1),
224 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
225 efl_pack(box, efl_added));
226
227 //Play Button
228 efl_add(EFL_UI_BUTTON_CLASS, box3,
229 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
230 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
231 efl_text_set(efl_added, "Play"),
232 efl_pack(box3, efl_added),
233 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
234
235
236 //Play Back Button
237 efl_add(EFL_UI_BUTTON_CLASS, box3,
238 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
239 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
240 efl_text_set(efl_added, "Play Back"),
241 efl_pack(box3, efl_added),
242 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
243
244 //Stop Button
245 efl_add(EFL_UI_BUTTON_CLASS, box3,
246 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
247 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
248 efl_text_set(efl_added, "Stop"),
249 efl_pack(box3, efl_added),
250 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
251
252 //Controller Set: 2
253 box4 = efl_add(EFL_UI_BOX_CLASS, box,
254 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
255 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, 1),
256 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
257 efl_pack(box, efl_added));
258
259 //Pause Button
260 efl_add(EFL_UI_BUTTON_CLASS, box3,
261 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
262 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
263 efl_text_set(efl_added, "Pause"),
264 efl_pack(box4, efl_added),
265 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
266
267 //Resume Button
268 efl_add(EFL_UI_BUTTON_CLASS, box3,
269 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
270 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
271 efl_text_set(efl_added, "Resume"),
272 efl_pack(box4, efl_added),
273 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
274
275 evas_object_smart_callback_add(anim_view, "play,start", _state_update, label);
276 evas_object_smart_callback_add(anim_view, "play,stop", _state_update, label);
277 evas_object_smart_callback_add(anim_view, "play,pause", _state_update, label);
278 evas_object_smart_callback_add(anim_view, "play,resume", _state_update, label);
279
280 evas_object_smart_callback_add(anim_view, "play,repeat", _play_repeated, label);
281 evas_object_smart_callback_add(anim_view, "play,done", _play_done, label);
282
283 evas_object_smart_callback_add(anim_view, "play,update", _play_updated, slider);
284 evas_object_smart_callback_add(anim_view, "play,stop", _slider_reset, slider);
285
286 update_anim_view_state(anim_view, label);
287
288 efl_gfx_entity_size_set(win, EINA_SIZE2D(600, 730));
289}
290
291#else
292
293void
294test_efl_ui_animation_view(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
295{
296 Eo *win, *box;
297 char buf[255];
298
299 win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
300 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
301 efl_text_set(efl_added, "Efl_Ui_Animation_View demo"),
302 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
303
304 // Create a box
305 box = efl_add(EFL_UI_BOX_CLASS, win,
306 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND),
307 efl_content_set(win, efl_added));
308
309 efl_add(EFL_UI_TEXT_CLASS, win,
310 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0.1),
311 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
312 efl_text_set(efl_added, "Evas Vg Json (Lottie) Loader is not supported, Only Static Vector Image is available!"),
313 efl_pack(box, efl_added));
314
315 //Create Vector object.
316 snprintf(buf, sizeof(buf), "%s/images/ubuntu.svg", elm_app_data_dir_get());
317 efl_add(EFL_CANVAS_VG_OBJECT_CLASS, win,
318 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND),
319 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
320 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(600, 600)),
321 efl_file_set(efl_added, buf),
322 efl_gfx_entity_visible_set(efl_added, EINA_TRUE),
323 efl_pack(box, efl_added));
324
325 efl_gfx_entity_size_set(win, EINA_SIZE2D(600, 730));
326}
327
328#endif