summaryrefslogtreecommitdiff
path: root/src/bin/elementary/test_efl_gfx_vg_value_provider.c
diff options
context:
space:
mode:
authorJunsuChoi <jsuya.choi@samsung.com>2019-10-02 14:32:33 +0900
committerJunsuChoi <jsuya.choi@samsung.com>2019-10-02 14:38:45 +0900
commit3f51e30976ebe68cf5480598a0d8302d82e1961e (patch)
tree1f6fab863f636215a8bfcad7d104a133a3b486af /src/bin/elementary/test_efl_gfx_vg_value_provider.c
parent779bd0539eb6ab8050289da83d0792670a15422c (diff)
elementary_test: Add the value provider test for animation_view
Summary: Add an Value Provider item to test vector animation on elementary_test. This test is to apply Efl.Gfx.Vg.Value_Provider to the loaded efl_ui_animation object. If Evas Vg Json(Lottie) Loader is not supported, use the vector class to output the svg file. Depends on D9874 Depends on D9897 Test Plan: elementary_test -> Value Provider Reviewers: Hermet, kimcinoo, smohanty Reviewed By: Hermet Subscribers: cedric, #committers, #reviewers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10015
Diffstat (limited to '')
-rw-r--r--src/bin/elementary/test_efl_gfx_vg_value_provider.c605
1 files changed, 605 insertions, 0 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
new file mode 100644
index 0000000..7f5add0
--- /dev/null
+++ b/src/bin/elementary/test_efl_gfx_vg_value_provider.c
@@ -0,0 +1,605 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5#include <Efl_Ui.h>
6#include "elm_priv.h"
7
8#ifndef EFL_BETA_API_SUPPORT
9#define EFL_BETA_API_SUPPORT
10#endif
11
12#ifndef EFL_EO_API_SUPPORT
13#define EFL_EO_API_SUPPORT
14#endif
15
16#ifdef BUILD_VG_LOADER_JSON
17
18Evas_Object *values[4], *anim_view;
19Evas_Object *path_entry, *type_hoversel;
20
21Eina_Bool
22add_value_provider(char* new_path, char* new_type, char* new_values)
23{
24 const char* type = elm_object_text_get(type_hoversel);
25 if (!type) return EINA_FALSE;
26 const char* path = efl_text_get(path_entry);
27 if (!path) return EINA_FALSE;
28
29 if (strstr(type, "Color") != NULL)
30 {
31 int color[4];
32 Eo *vp = efl_add(EFL_GFX_VG_VALUE_PROVIDER_CLASS, anim_view);
33 efl_gfx_vg_value_provider_keypath_set(vp, (char*)path);
34 for (int i = 0; i < 4; i++)
35 {
36 char* v = (char*)efl_text_get(values[i]);
37 if (v) color[i] = atoi(v);
38 }
39
40 sprintf(new_path, "%s", path);
41 sprintf(new_values, "%d %d %d %d",color[0], color[1], color[2], color[3]);
42 if (!strcmp(type, "FillColor"))
43 {
44 efl_gfx_vg_value_provider_fill_color_set(vp, color[0], color[1], color[2], color[3]);
45 sprintf(new_type, "FillColor");
46 }
47 if (!strcmp(type, "StrokeColor"))
48 {
49 efl_gfx_vg_value_provider_stroke_color_set(vp, color[0], color[1], color[2], color[3]);
50 sprintf(new_type, "StrokeColor");
51 }
52
53
54 efl_ui_animation_view_value_provider_override(anim_view, vp);
55 }
56 if (!strcmp(type, "StrokeWidth"))
57 {
58 double width;
59 Eo *vp = efl_add(EFL_GFX_VG_VALUE_PROVIDER_CLASS, anim_view);
60 efl_gfx_vg_value_provider_keypath_set(vp, (char*)path);
61 char* v = (char*)efl_text_get(values[0]);
62 if (v) width = strtod(v, NULL);
63 efl_gfx_vg_value_provider_stroke_width_set(vp, width);
64 efl_ui_animation_view_value_provider_override(anim_view, vp);
65 evas_object_show(anim_view);
66 sprintf(new_path, "%s", path);
67 sprintf(new_type, "StrokeWidth");
68 sprintf(new_values, "%f", width);
69 }
70 return EINA_TRUE;
71}
72
73static void
74btn_clicked_cb(void *data , const Efl_Event *ev )
75{
76 const char *text = efl_text_get(ev->object);
77
78 if (!text) return;
79
80 if (!strcmp("Play", text))
81 efl_ui_animation_view_play((Evas_Object*)data);
82 else if (!strcmp("Pause", text))
83 efl_ui_animation_view_pause((Evas_Object*)data);
84 else if (!strcmp("Resume", text))
85 efl_ui_animation_view_resume((Evas_Object*)data);
86 else if (!strcmp("Play Back", text))
87 efl_ui_animation_view_play_back((Evas_Object*)data);
88 else if (!strcmp("Stop", text))
89 efl_ui_animation_view_stop((Evas_Object*)data);
90 else if (!strcmp("ADD", text))
91 {
92 Evas_Object *list = (Evas_Object*)data;
93 Elm_Object_Item *list_it;
94 char new_path[255], new_type[255], new_values[255];
95 if (add_value_provider(new_path, new_type, new_values))
96 {
97 char buf[255];
98 //TODO: Even if there is the same path as the existing item, it is added without updating.
99 // In efl_ui_animation_view, duplicate paths are managed.
100 // However, animator (lottie) does not have an implementation that manages overridden values.
101 /*Eina_List *items = (Eina_List*)elm_list_items_get(list);
102 Eina_List *l;
103 EINA_LIST_FOREACH(items, l, list_it)
104 {
105 char item_text[255];
106 strcpy(item_text, elm_object_item_text_get(list_it));
107 if (item_text[0] != '/')
108 {
109 char* path = strtok(item_text, "/");
110 char* type = strtok(NULL, "/");
111 if (!strcmp(new_path, path) && !strcmp(new_type, type))
112 {
113 elm_object_item_del(list_it);
114 break;
115 }
116 }
117 }*/
118 sprintf(buf, "%s/%s/%s", new_path, new_type, new_values);
119 list_it = elm_list_item_append(list, buf, NULL, NULL, NULL, NULL);
120 elm_list_item_bring_in(list_it);
121 elm_list_go(list);
122 }
123 }
124 else if (!strcmp("DEL", text))
125 {
126 Evas_Object *list = (Evas_Object*)data;
127 Elm_Object_Item *list_it = elm_list_selected_item_get(list);
128 if (list_it)
129 {
130 char item_text[255];
131 strcpy(item_text, elm_object_item_text_get(list_it));
132 if (item_text[0] != '/')
133 {
134 /* Need to work */
135 }
136 //TODO
137 printf("Value provider remove is not implemented yet\n");
138 /*elm_object_item_del(list_it);
139 elm_list_go(list);*/
140 }
141 }
142}
143
144static void
145check_changed_cb(void *data, const Efl_Event *event)
146{
147 Evas_Object *anim_view = data;
148 efl_ui_animation_view_auto_repeat_set(anim_view, efl_ui_selectable_selected_get(event->object));
149}
150
151static void
152speed_changed_cb(void *data, const Efl_Event *event)
153{
154 Evas_Object *anim_view = data;
155 double speed = 1;
156 if (efl_ui_selectable_selected_get(event->object)) speed = 0.25;
157 efl_ui_animation_view_speed_set(anim_view, speed);
158}
159
160static void
161limit_frame_cb(void *data, const Efl_Event *event)
162{
163 Evas_Object *anim_view = data;
164 int frame_count = efl_ui_animation_view_frame_count_get(anim_view);
165 printf("Total Frame Count : %d\n", frame_count);
166 if (efl_ui_selectable_selected_get(event->object))
167 {
168 efl_ui_animation_view_min_frame_set(anim_view, 5);
169 efl_ui_animation_view_max_frame_set(anim_view, 10);
170 printf("Frames to show 5-10 only\n");
171 }
172 else
173 {
174 efl_ui_animation_view_min_frame_set(anim_view, 0);
175 efl_ui_animation_view_max_frame_set(anim_view, frame_count);
176 printf("Showing all frames now\n");
177 }
178}
179
180static void
181update_anim_view_state(Evas_Object *anim_view, Evas_Object *label)
182{
183 Efl_Ui_Animation_View_State state = efl_ui_animation_view_state_get(anim_view);
184
185 switch (state)
186 {
187 case EFL_UI_ANIMATION_VIEW_STATE_NOT_READY:
188 efl_text_set(label, "State = Not Ready");
189 break;
190 case EFL_UI_ANIMATION_VIEW_STATE_PLAY:
191 efl_text_set(label, "State = Playing");
192 break;
193 case EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK:
194 efl_text_set(label, "State = Playing Back");
195 break;
196 case EFL_UI_ANIMATION_VIEW_STATE_PAUSE:
197 efl_text_set(label, "State = Paused");
198 break;
199 case EFL_UI_ANIMATION_VIEW_STATE_STOP:
200 efl_text_set(label, "State = Stopped");
201 break;
202 }
203}
204
205static void
206_play_updated(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
207{
208 Evas_Object *slider = data;
209 efl_ui_range_value_set(slider, efl_ui_animation_view_progress_get(obj));
210}
211
212static void
213_state_update(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
214{
215 Evas_Object *label = data;
216 update_anim_view_state(obj, label);
217}
218
219static void
220_play_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
221{
222 printf("done!\n");
223}
224
225static void
226_play_repeated(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
227{
228 printf("repeated!\n");
229}
230
231static void
232_slider_changed_cb(void *data, const Efl_Event *ev)
233{
234 Evas_Object *anim_view = data;
235 efl_ui_animation_view_progress_set(anim_view, efl_ui_range_value_get(ev->object));
236}
237
238static void
239_slider_reset(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
240{
241 Evas_Object *slider = data;
242 efl_ui_range_value_set(slider, 0);
243}
244
245void values_input(Eo* box, const char* type)
246{
247 for (int i = 0; i < 4; i++)
248 {
249 if (values[i])
250 {
251 //efl_pack_unpack(box, values[i]);
252 efl_del(values[i]);
253 values[i] = NULL;
254 }
255 }
256 if (strstr(type, "Color") != NULL)
257 {
258 char color_text[4][2] = { "R", "G", "B", "A" };
259 for (int i = 0; i < 4; i++)
260 {
261 values[i] = efl_add(EFL_UI_TEXT_CLASS, box,
262 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
263 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
264 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
265 efl_text_interactive_editable_set(efl_added, EINA_TRUE),
266 efl_pack(box, efl_added));
267 efl_gfx_hint_size_min_set(values[i], EINA_SIZE2D(50, 10));
268 efl_text_set(efl_part(values[i], "efl.text_guide"), color_text[i]);
269 }
270 }
271 else if (!strcmp(type, "StrokeWidth"))
272 {
273 values[0] = efl_add(EFL_UI_TEXT_CLASS, box,
274 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
275 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
276 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
277 efl_text_interactive_editable_set(efl_added, EINA_TRUE),
278 efl_pack(box, efl_added));
279 efl_gfx_hint_size_min_set(values[0], EINA_SIZE2D(50, 10));
280 efl_text_set(efl_part(values[0], "efl.text_guide"), "Width(double type)");
281 }
282}
283
284static void
285_hover_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
286{
287 Evas_Object* box = (Evas_Object*)data;
288 const char *selected = elm_object_item_text_get(event_info);
289
290 elm_object_text_set(obj, selected);
291 values_input(box, selected);
292}
293
294void
295test_efl_gfx_vg_value_provider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
296{
297 Eo *win, *box, *box_sub, *label, *check, *slider, *list;
298 char buf[255];
299 // This line must to need.
300 setenv("ELM_ACCEL", "gl", 1);
301
302 win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
303 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
304 efl_text_set(efl_added, "Efl_Ui_Animation_View demo"),
305 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
306
307 // Create a box in Canvas
308 box = efl_add(EFL_UI_BOX_CLASS, win,
309 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND),
310 efl_content_set(win, efl_added));
311
312 //Create a label to show state of animation
313 label = efl_add(EFL_UI_TEXT_CLASS, win,
314 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0.1),
315 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
316 efl_pack(box, efl_added));
317
318 //Create Animation View to play animation directly from JSON file
319 snprintf(buf, sizeof(buf), "%s/images/three_box.json", elm_app_data_dir_get());
320 anim_view = efl_add(EFL_UI_ANIMATION_VIEW_CLASS, win,
321 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND),
322 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
323 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(600, 600)),
324 efl_file_set(efl_added, buf),
325 efl_pack(box, efl_added));
326
327//-----------------------------------------------------------------------------------
328 box_sub = efl_add(EFL_UI_BOX_CLASS, box,
329 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0.1),
330 efl_pack(box, efl_added));
331 //Path
332 efl_add(EFL_UI_TEXT_CLASS, box_sub,
333 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
334 efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
335 efl_text_set(efl_added, "Path examples : three_box.json\n"
336 "**\n"
337 "layer.*.Fill 1\n"
338 "layer.box1.*\n"
339 "layer.box1.Fill 1\n"
340 "layer.box1.Stroke 1\n"
341 "layer.box_sub.Fill 1\n"
342 "layer.box_sub.Stroke 1\n"
343 "layer.box_sub.Fill 1\n"
344 "layer.box_sub.Stroke 1\n"),
345 efl_text_interactive_editable_set(efl_added, EINA_FALSE),
346 efl_text_multiline_set(efl_added, EINA_TRUE),
347 efl_pack(box_sub, efl_added));
348
349 efl_add(EFL_UI_TEXT_CLASS, box_sub,
350 efl_gfx_hint_weight_set(efl_added, 0, 0),
351 efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
352 efl_text_set(efl_added, "[Value Provider]"),
353 efl_text_interactive_editable_set(efl_added, EINA_FALSE),
354 efl_text_multiline_set(efl_added, EINA_TRUE),
355 efl_pack(box_sub, efl_added));
356//-----------------------------------------------------------------------------------
357 // Controller Set : 0
358 box_sub = efl_add(EFL_UI_BOX_CLASS, box,
359 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0.1),
360 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
361 efl_pack(box, efl_added));
362
363 //Path
364 efl_add(EFL_UI_TEXT_CLASS, box_sub,
365 efl_gfx_hint_weight_set(efl_added, 0, 0),
366 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
367 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
368 efl_text_set(efl_added, "PATH : "),
369 efl_text_interactive_editable_set(efl_added, EINA_FALSE),
370 efl_pack(box_sub, efl_added));
371
372 path_entry = efl_add(EFL_UI_TEXT_CLASS, box_sub,
373 efl_gfx_hint_weight_set(efl_added, 0.1, 0),
374 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
375 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
376 efl_text_interactive_editable_set(efl_added, EINA_TRUE),
377 efl_pack(box_sub, efl_added));
378 efl_gfx_hint_size_min_set(path_entry, EINA_SIZE2D(200, 10));
379 efl_text_set(efl_part(path_entry, "efl.text_guide"), "Enter path(ex: ** or Layer.Shape.Fill) ");
380
381 efl_add(EFL_UI_TEXT_CLASS, box_sub,
382 efl_gfx_hint_weight_set(efl_added, 0, 0),
383 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
384 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
385 efl_text_set(efl_added, "TYPE : "),
386 efl_text_interactive_editable_set(efl_added, EINA_FALSE),
387 efl_pack(box_sub, efl_added));
388 type_hoversel = elm_hoversel_add(box_sub);
389 elm_hoversel_hover_parent_set(type_hoversel, win);
390 evas_object_size_hint_weight_set(type_hoversel, 0, 0);
391 evas_object_size_hint_align_set(type_hoversel, EVAS_HINT_FILL, EVAS_HINT_FILL);
392 efl_gfx_hint_size_min_set(type_hoversel, EINA_SIZE2D(100, 10)),
393 elm_object_text_set(type_hoversel, "FillColor");
394 elm_hoversel_item_add(type_hoversel, "FillColor", NULL, ELM_ICON_NONE, _hover_item_selected_cb, box_sub);
395 elm_hoversel_item_add(type_hoversel, "StrokeColor", NULL, ELM_ICON_NONE, _hover_item_selected_cb, box_sub);
396 elm_hoversel_item_add(type_hoversel, "StrokeWidth", NULL, ELM_ICON_NONE, _hover_item_selected_cb, box_sub);
397 evas_object_show(type_hoversel);
398 elm_object_focus_set(type_hoversel, EINA_TRUE);
399 efl_pack(box_sub, type_hoversel);
400
401 efl_add(EFL_UI_TEXT_CLASS, box_sub,
402 efl_gfx_hint_weight_set(efl_added, 0, 0),
403 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
404 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
405 efl_text_set(efl_added, "VALUES : "),
406 efl_text_interactive_editable_set(efl_added, EINA_FALSE),
407 efl_pack(box_sub, efl_added));
408 values_input(box_sub, elm_object_text_get(type_hoversel));
409
410//-----------------------------------------------------------------------------------
411
412 // Controller Set : 0
413 box_sub = efl_add(EFL_UI_BOX_CLASS, box,
414 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0.1),
415 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
416 efl_pack(box, efl_added));
417
418 list = elm_list_add(win);
419 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
420 evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
421 evas_object_show(list);
422 efl_pack(box_sub, list);
423
424 elm_object_item_disabled_set(elm_list_item_append(list, "Example : ** / FillColor / 255, 255, 255, 255", NULL, NULL, NULL, NULL), EINA_TRUE);
425 efl_gfx_hint_size_min_set(list, EINA_SIZE2D(400, 100)),
426 elm_list_go(list);
427
428
429
430 efl_add(EFL_UI_BUTTON_CLASS, box_sub,
431 efl_gfx_hint_weight_set(efl_added, 0, 0),
432 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
433 efl_text_set(efl_added, "ADD"),
434 efl_pack(box_sub, efl_added),
435 efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(50, 20)),
436 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, list));
437
438 efl_add(EFL_UI_BUTTON_CLASS, box_sub,
439 efl_gfx_hint_weight_set(efl_added, 0, 0),
440 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
441 efl_text_set(efl_added, "DEL"),
442 efl_pack(box_sub, efl_added),
443 efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(50, 20)),
444 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, list));
445//-----------------------------------------------------------------------------------
446 // Controller Set : 0
447 box_sub = efl_add(EFL_UI_BOX_CLASS, box,
448 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0.1),
449 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
450 efl_pack(box, efl_added));
451
452 //Loop
453 check = efl_add(EFL_UI_CHECK_CLASS, box_sub,
454 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
455 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
456 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
457 efl_pack(box_sub, efl_added));
458 efl_text_set(check, "Loop");
459 efl_event_callback_add(check, EFL_UI_EVENT_SELECTED_CHANGED, check_changed_cb, anim_view);
460
461 //Speed: 0.5x
462 check = efl_add(EFL_UI_CHECK_CLASS, box_sub,
463 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
464 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
465 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
466 efl_pack(box_sub, efl_added));
467 efl_text_set(check, "Speed: 0.25x");
468 efl_event_callback_add(check, EFL_UI_EVENT_SELECTED_CHANGED, speed_changed_cb, anim_view);
469
470 //Limit Frames
471 check = efl_add(EFL_UI_CHECK_CLASS, box_sub,
472 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
473 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
474 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
475 efl_pack(box_sub, efl_added));
476 efl_text_set(check, "Limit Frames");
477 efl_event_callback_add(check, EFL_UI_EVENT_SELECTED_CHANGED, limit_frame_cb, anim_view);
478
479
480 //Duration Text
481 snprintf(buf, sizeof(buf), "Duration: %1.2fs", efl_ui_animation_view_duration_time_get(anim_view));
482 efl_add(EFL_UI_TEXT_CLASS, box_sub,
483 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
484 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
485 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
486 efl_text_set(efl_added, buf),
487 efl_pack(box_sub, efl_added));
488
489 //Slider
490 slider = efl_add(EFL_UI_SLIDER_CLASS, box,
491 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0.1),
492 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
493 efl_ui_range_limits_set(efl_added, 0, 1),
494 efl_event_callback_add(efl_added, EFL_UI_RANGE_EVENT_CHANGED, _slider_changed_cb, anim_view),
495 efl_pack(box, efl_added));
496
497 //Controller Set: 1
498 box_sub = efl_add(EFL_UI_BOX_CLASS, box,
499 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
500 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, 1),
501 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
502 efl_pack(box, efl_added));
503
504 //Play Button
505 efl_add(EFL_UI_BUTTON_CLASS, box_sub,
506 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
507 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
508 efl_text_set(efl_added, "Play"),
509 efl_pack(box_sub, efl_added),
510 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
511
512
513 //Play Back Button
514 efl_add(EFL_UI_BUTTON_CLASS, box_sub,
515 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
516 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
517 efl_text_set(efl_added, "Play Back"),
518 efl_pack(box_sub, efl_added),
519 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
520
521 //Stop Button
522 efl_add(EFL_UI_BUTTON_CLASS, box_sub,
523 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
524 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
525 efl_text_set(efl_added, "Stop"),
526 efl_pack(box_sub, efl_added),
527 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
528
529 //Controller Set: 2
530 box_sub = efl_add(EFL_UI_BOX_CLASS, box,
531 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
532 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, 1),
533 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
534 efl_pack(box, efl_added));
535
536 //Pause Button
537 efl_add(EFL_UI_BUTTON_CLASS, box_sub,
538 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
539 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
540 efl_text_set(efl_added, "Pause"),
541 efl_pack(box_sub, efl_added),
542 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
543
544 //Resume Button
545 efl_add(EFL_UI_BUTTON_CLASS, box_sub,
546 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0),
547 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
548 efl_text_set(efl_added, "Resume"),
549 efl_pack(box_sub, efl_added),
550 efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, btn_clicked_cb, anim_view));
551
552 evas_object_smart_callback_add(anim_view, "play,start", _state_update, label);
553 evas_object_smart_callback_add(anim_view, "play,stop", _state_update, label);
554 evas_object_smart_callback_add(anim_view, "play,pause", _state_update, label);
555 evas_object_smart_callback_add(anim_view, "play,resume", _state_update, label);
556
557 evas_object_smart_callback_add(anim_view, "play,repeat", _play_repeated, label);
558 evas_object_smart_callback_add(anim_view, "play,done", _play_done, label);
559
560 evas_object_smart_callback_add(anim_view, "play,update", _play_updated, slider);
561 evas_object_smart_callback_add(anim_view, "play,stop", _slider_reset, slider);
562
563 update_anim_view_state(anim_view, label);
564
565 efl_gfx_entity_size_set(win, EINA_SIZE2D(600, 850));
566}
567
568#else
569
570void
571test_efl_gfx_vg_value_provider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
572{
573 Eo *win, *box;
574 char buf[255];
575
576 win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
577 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
578 efl_text_set(efl_added, "Efl_Ui_Animation_View demo"),
579 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
580
581 // Create a box
582 box = efl_add(EFL_UI_BOX_CLASS, win,
583 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND),
584 efl_content_set(win, efl_added));
585
586 efl_add(EFL_UI_TEXT_CLASS, win,
587 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0.1),
588 efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
589 efl_text_set(efl_added, "Evas Vg Json (Lottie) Loader is not supported, Only Static Vector Image is available!"),
590 efl_pack(box, efl_added));
591
592 //Create Vector object.
593 snprintf(buf, sizeof(buf), "%s/images/tiger.svg", elm_app_data_dir_get());
594 efl_add(EFL_CANVAS_VG_OBJECT_CLASS, win,
595 efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND),
596 efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
597 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(600, 600)),
598 efl_file_simple_load(efl_added, buf, NULL),
599 efl_gfx_entity_visible_set(efl_added, EINA_TRUE),
600 efl_pack(box, efl_added));
601
602 efl_gfx_entity_size_set(win, EINA_SIZE2D(600, 730));
603}
604
605#endif