--- /dev/null
+#define EFL_BETA_API_SUPPORT 1\r
+#define EFL_EO_API_SUPPORT 1\r
+\r
+#include <Elementary.h>\r
+\r
+#define WIDTH 400\r
+#define HEIGHT 400\r
+\r
+Eo *slider = NULL;\r
+\r
+void\r
+win_del(void *data, Eo *o, void *ev)\r
+{\r
+ elm_exit();\r
+}\r
+\r
+static void\r
+btn_clicked_cb(void *data, Eo *obj, void *event_info)\r
+{\r
+ Eo *anim_view = (Eo *) data;\r
+ const char *text = elm_object_text_get(obj);\r
+\r
+ if (!text) return;\r
+\r
+ if (!strcmp("Play", text))\r
+ elm_animation_view_play(anim_view);\r
+ else if (!strcmp("Pause", text))\r
+ elm_animation_view_pause(anim_view);\r
+ else if (!strcmp("Resume", text))\r
+ elm_animation_view_resume(anim_view);\r
+ else if (!strcmp("Play Back", text))\r
+ elm_animation_view_play_back(anim_view);\r
+ else if (!strcmp("Stop", text))\r
+ elm_animation_view_stop(anim_view);\r
+}\r
+\r
+static void\r
+check_changed_cb(void *data, Eo *obj, void *event_info)\r
+{\r
+ Eo *anim_view = (Eo *) data;\r
+ elm_animation_view_auto_repeat_set(anim_view, elm_check_state_get(obj));\r
+}\r
+\r
+static void\r
+speed_changed_cb(void *data, Eo *obj, void *event_info)\r
+{\r
+ Eo *anim_view = (Eo *) data;\r
+ double speed = 1;\r
+ if (elm_check_state_get(obj)) speed = 0.25;\r
+ elm_animation_view_speed_set(anim_view, speed);\r
+}\r
+\r
+static void\r
+update_anim_view_state(Eo *anim_view, Eo *label)\r
+{\r
+ Elm_Animation_View_State state = elm_animation_view_state_get(anim_view);\r
+\r
+ switch (state)\r
+ {\r
+ case ELM_ANIMATION_VIEW_STATE_NOT_READY:\r
+ elm_object_text_set(label, "State = Not Ready");\r
+ break;\r
+ case ELM_ANIMATION_VIEW_STATE_PLAY:\r
+ elm_object_text_set(label, "State = Playing");\r
+ break;\r
+ case ELM_ANIMATION_VIEW_STATE_PLAY_BACK:\r
+ elm_object_text_set(label, "State = Playing Back");\r
+ break;\r
+ case ELM_ANIMATION_VIEW_STATE_PAUSE:\r
+ elm_object_text_set(label, "State = Paused");\r
+ break;\r
+ case ELM_ANIMATION_VIEW_STATE_STOP:\r
+ elm_object_text_set(label, "State = Stopped");\r
+ break;\r
+ }\r
+}\r
+\r
+static void\r
+_play_done(void *data, Eo *obj, void *ev)\r
+{\r
+ printf("done!\n");\r
+}\r
+\r
+static void\r
+_play_updated(void *data, Eo *obj, void *ev)\r
+{\r
+ Eo *slider = (Eo *) data;\r
+ elm_slider_value_set(slider, elm_animation_view_keyframe_get(obj));\r
+}\r
+\r
+static void\r
+_state_update(void *data, Eo *obj, void *ev)\r
+{\r
+ Eo *label = (Eo *) data;\r
+ update_anim_view_state(obj, label);\r
+}\r
+\r
+static void\r
+_play_repeated(void *data, Eo *obj, void *ev)\r
+{\r
+ printf("repeated!\n");\r
+}\r
+\r
+static void\r
+_slider_drag_cb(void *data, Eo *obj, void *ev)\r
+{\r
+ Eo *anim_view = (Eo *) data;\r
+ elm_animation_view_keyframe_set(anim_view, elm_slider_value_get(obj));\r
+}\r
+\r
+static void\r
+_slider_reset(void *data, Eo *obj, void *ev)\r
+{\r
+ Eo *slider = (Eo *) data;\r
+ elm_slider_value_set(slider, 0);\r
+}\r
+\r
+Eo *\r
+anim_view_test(Eo *parent, const char *path)\r
+{\r
+ Eo *box = elm_box_add(parent);\r
+ evas_object_size_hint_weight_set(box, 1, 1);\r
+ evas_object_show(box);\r
+\r
+ //State Text\r
+ Eo *label = elm_label_add(box);\r
+ evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(label, 0.5, 0);\r
+ evas_object_show(label);\r
+ elm_box_pack_end(box, label);\r
+\r
+ //Animation View\r
+ Eo *anim_view = elm_animation_view_add(box);\r
+ evas_object_size_hint_align_set(anim_view, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ elm_animation_view_file_set(anim_view, path, NULL);\r
+ evas_object_size_hint_weight_set(anim_view, 1, 1);\r
+ evas_object_show(anim_view);\r
+ elm_box_pack_end(box, anim_view);\r
+\r
+ //Controller Set: 0\r
+ Eo *box2 = elm_box_add(box);\r
+ evas_object_size_hint_weight_set(box2, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(box2, EVAS_HINT_FILL, 1);\r
+ elm_box_horizontal_set(box2, EINA_TRUE);\r
+ elm_box_pack_end(box, box2);\r
+ evas_object_show(box2);\r
+\r
+\r
+ //Loop\r
+ Eo *check = elm_check_add(box2);\r
+ evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ elm_object_text_set(check, "Loop");\r
+ evas_object_smart_callback_add(check, "changed", check_changed_cb, anim_view);\r
+ evas_object_show(check);\r
+ elm_box_pack_end(box2, check);\r
+\r
+ //Speed: 0.5x\r
+ Eo *check2 = elm_check_add(box2);\r
+ evas_object_size_hint_weight_set(check2, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(check2, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ elm_object_text_set(check2, "Speed: 0.25x");\r
+ evas_object_smart_callback_add(check2, "changed", speed_changed_cb, anim_view);\r
+ evas_object_show(check2);\r
+ elm_box_pack_end(box2, check2);\r
+\r
+ //Duration Text\r
+ Eo *label2 = elm_label_add(box2);\r
+ evas_object_size_hint_weight_set(label2, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(label2, 0.5, 0);\r
+ evas_object_show(label2);\r
+ elm_box_pack_end(box2, label2);\r
+ char buf[50];\r
+ snprintf(buf, sizeof(buf), "Duration: %1.2fs", elm_animation_view_duration_time_get(anim_view));\r
+ elm_object_text_set(label2, buf);\r
+\r
+ //Slider\r
+ Eo *slider = elm_slider_add(box);\r
+ elm_slider_indicator_show_set(slider, EINA_TRUE);\r
+ elm_slider_indicator_format_set(slider, "%1.2f");\r
+ elm_slider_min_max_set(slider, 0, 1);\r
+ evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ evas_object_smart_callback_add(slider, "changed", _slider_drag_cb, anim_view);\r
+ evas_object_show(slider);\r
+ elm_box_pack_end(box, slider);\r
+\r
+ //Controller Set: 1\r
+ Eo *box3 = elm_box_add(box);\r
+ evas_object_size_hint_weight_set(box3, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(box3, EVAS_HINT_FILL, 1);\r
+ elm_box_horizontal_set(box3, EINA_TRUE);\r
+ elm_box_pack_end(box, box3);\r
+ evas_object_show(box3);\r
+\r
+ Eo *btn;\r
+\r
+ //Play Button\r
+ btn = elm_button_add(box3);\r
+ evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ elm_object_text_set(btn, "Play");\r
+ evas_object_show(btn);\r
+ evas_object_smart_callback_add(btn, "clicked", btn_clicked_cb, anim_view);\r
+ elm_box_pack_end(box3, btn);\r
+\r
+ //Play Back Button\r
+ btn = elm_button_add(box3);\r
+ evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ elm_object_text_set(btn, "Play Back");\r
+ evas_object_smart_callback_add(btn, "clicked", btn_clicked_cb, anim_view);\r
+ evas_object_show(btn);\r
+ elm_box_pack_end(box3, btn);\r
+\r
+ //Stop Button\r
+ btn = elm_button_add(box3);\r
+ evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ elm_object_text_set(btn, "Stop");\r
+ evas_object_smart_callback_add(btn, "clicked", btn_clicked_cb, anim_view);\r
+ evas_object_show(btn);\r
+ elm_box_pack_end(box3, btn);\r
+\r
+ //Controller Set: 2\r
+ Eo *box4 = elm_box_add(box);\r
+ evas_object_size_hint_weight_set(box4, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(box4, EVAS_HINT_FILL, 1);\r
+ elm_box_horizontal_set(box4, EINA_TRUE);\r
+ elm_box_pack_end(box, box4);\r
+ evas_object_show(box4);\r
+\r
+ //Pause Button\r
+ btn = elm_button_add(box4);\r
+ elm_object_text_set(btn, "Pause");\r
+ evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ evas_object_smart_callback_add(btn, "clicked", btn_clicked_cb, anim_view);\r
+ evas_object_show(btn);\r
+ elm_box_pack_end(box4, btn);\r
+\r
+ //Resume Button\r
+ btn = elm_button_add(box4);\r
+ evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0);\r
+ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ elm_object_text_set(btn, "Resume");\r
+ evas_object_smart_callback_add(btn, "clicked", btn_clicked_cb, anim_view);\r
+ evas_object_show(btn);\r
+ elm_box_pack_end(box4, btn);\r
+\r
+ evas_object_smart_callback_add(anim_view, "play,start", _state_update, label);\r
+ evas_object_smart_callback_add(anim_view, "play,stop", _state_update, label);\r
+ evas_object_smart_callback_add(anim_view, "play,pause", _state_update, label);\r
+ evas_object_smart_callback_add(anim_view, "play,resume", _state_update, label);\r
+\r
+ evas_object_smart_callback_add(anim_view, "play,repeat", _play_repeated, label);\r
+ evas_object_smart_callback_add(anim_view, "play,done", _play_done, label);\r
+\r
+ evas_object_smart_callback_add(anim_view, "play,update", _play_updated, slider);\r
+ evas_object_smart_callback_add(anim_view, "play,stop", _slider_reset, slider);\r
+\r
+ update_anim_view_state(anim_view, label);\r
+\r
+ return box;\r
+\r
+}\r
+\r
+int\r
+main(int argc, char **argv)\r
+{\r
+ setenv("ECTOR_BACKEND", "default", 1);\r
+ setenv("ELM_ACCEL", "gl", 1);\r
+\r
+ elm_init(argc, argv);\r
+\r
+ Eo *win = elm_win_util_standard_add(NULL, "test");\r
+ evas_object_smart_callback_add(win, "delete,request", win_del, 0);\r
+ elm_win_autodel_set(win, 1);\r
+\r
+ char path[PATH_MAX];\r
+\r
+ if (argc == 1)\r
+ {\r
+ printf("Usage: efl_animview [input_file]\n");\r
+ return 0;\r
+ }\r
+ else snprintf(path, sizeof(path), "%s/%s", DEMO_DIR, "heart.json");\r
+\r
+ Eo *content = anim_view_test(win, path);\r
+\r
+ elm_win_resize_object_add(win, content);\r
+\r
+ evas_object_resize(win, WIDTH, HEIGHT);\r
+ evas_object_show(win);\r
+\r
+ elm_run();\r
+\r
+ elm_shutdown();\r
+\r
+ return 0;\r
+}\r