From: Jaeun Choi Date: Fri, 17 Aug 2018 12:15:22 +0000 (+0900) Subject: lottie: add "lottieviewer" example X-Git-Tag: submit/tizen/20180917.042405~86 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=617b257ec4c45f38a1e214e431ce5246a2788434;p=platform%2Fcore%2Fuifw%2Flottie-player.git lottie: add "lottieviewer" example lottieviewer shows each frame image according to slider value. since edc compilation is not supported yet, do the following steps to run this example: $ cd example $ edje_cc layout.edc $ mv layout.edj ../build/example Change-Id: I00f7d8b743e9028d1e8006104e63bef5d96084b6 --- diff --git a/example/layout.edc b/example/layout.edc new file mode 100644 index 0000000..cbc0694 --- /dev/null +++ b/example/layout.edc @@ -0,0 +1,31 @@ +collections { + group { name: "layout"; + parts { + rect { "bg"; + desc { state: "default" 0.0; + color: 255 255 255 255; + } + } + spacer { "lottie_base"; + desc { state: "default" 0.0; + rel2.relative: 1.0 0.7; + } + } + swallow { "lottie"; + desc { state: "default" 0.0; + rel1.to: "lottie_base"; + rel1.relative: 0.5 0.5; + rel2.to: "lottie_base"; + rel2.relative: 0.5 0.5; + } + } + swallow { "slider"; + desc { state: "default" 0.0; + rel1.relative: 0.0 0.7; + rel1.offset: 20 20; + rel2.offset: -20 -20; + } + } + } + } +} diff --git a/example/lottieviewer.cpp b/example/lottieviewer.cpp new file mode 100644 index 0000000..2f46b47 --- /dev/null +++ b/example/lottieviewer.cpp @@ -0,0 +1,72 @@ +#include +#include "lottieview.h" +#include +#include + +using namespace std; + +static void +_win_del_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + LottieView *view = (LottieView *)data; + delete view; +} + +static void +_slider_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + double val = elm_slider_value_get(obj); + LottieView *view = (LottieView *)data; + + view->seek(val); + view->render(); +} + +EAPI_MAIN int +elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) +{ + Evas_Object *win, *layout, *slider, *image; + bool renderMode = true; + + if (argc > 1) { + if (!strcmp(argv[1], "--disable-render")) + renderMode = false; + } + + win = elm_win_util_standard_add("lottie", "LottieViewer"); + evas_object_resize(win, 500, 700); + evas_object_show(win); + + layout = elm_layout_add(win); + evas_object_show(layout); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_layout_file_set(layout, "layout.edj", "layout"); + elm_win_resize_object_add(win, layout); + + std::string filePath = DEMO_DIR; + filePath +="data.json"; + + LottieView *view = new LottieView(evas_object_evas_get(win), renderMode); + view->setFilePath(filePath.c_str()); + view->setSize(500, 500); + + evas_object_smart_callback_add(win, "delete,request", _win_del_cb, (void *)view); + + image = view->getImage(); + evas_object_show(image); + evas_object_size_hint_min_set(image, 500, 500); + elm_object_part_content_set(layout, "lottie", image); + + slider = elm_slider_add(layout); + evas_object_show(slider); + elm_object_part_content_set(layout, "slider", slider); + evas_object_smart_callback_add(slider, "changed", _slider_cb, (void *)view); + + view->seek(0.0); + view->render(); + + elm_run(); + + return 0; +} +ELM_MAIN() diff --git a/example/meson.build b/example/meson.build index 79db2c1..72fb942 100644 --- a/example/meson.build +++ b/example/meson.build @@ -32,3 +32,12 @@ executable('uxsampleTest', include_directories : inc, link_with : lottie_player_lib, dependencies : demo_dep) + +lottieviewer_sources = files('lottieviewer.cpp') +lottieviewer_sources += common_source + +executable('lottieviewer', + lottieviewer_sources, + include_directories : inc, + link_with : lottie_player_lib, + dependencies : demo_dep)