2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the LGPL License, Version 2.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * https://www.gnu.org/licenses/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "lottieview.h"
26 UxSampleTest(EvasApp *app, bool renderMode) {
28 mRenderMode = renderMode;
29 mResourceList = EvasApp::jsonFiles(std::string(DEMO_DIR) + "UXSample_1920x1080/");
30 mRepeatMode = LottieView::RepeatMode::Restart;
34 if (mResourceList.empty()) return;
37 mCurIndex = mResourceList.size() - 1;
42 if (mResourceList.empty()) return;
45 if (mCurIndex >= int(mResourceList.size()))
52 mView->setSize(mApp->width(), mApp->height());
58 mView = std::make_unique<LottieView>(mApp->evas(), mRenderMode);
59 mView->setFilePath(mResourceList[mCurIndex].c_str());
61 mView->setSize(mApp->width(), mApp->height());
65 mView->setRepeatMode(mRepeatMode);
70 bool mRenderMode = false;
72 std::vector<std::string> mResourceList;
73 std::unique_ptr<LottieView> mView;
74 LottieView::RepeatMode mRepeatMode;
78 onExitCb(void *data, void *extra)
80 UxSampleTest *view = (UxSampleTest *)data;
85 onKeyCb(void *data, void *extra)
87 UxSampleTest *view = (UxSampleTest *)data;
88 char *keyname = (char *)extra;
90 if (!strcmp(keyname, "Right") || !strcmp(keyname, "n")) {
92 } else if (!strcmp(keyname, "Left") || !strcmp(keyname, "p")) {
94 } else if (!strcmp(keyname,"r")) {
95 if (view->mRepeatMode == LottieView::RepeatMode::Restart) {
96 view->mRepeatMode = LottieView::RepeatMode::Reverse;
98 view->mRepeatMode = LottieView::RepeatMode::Restart;
100 view->mView->setRepeatMode(view->mRepeatMode);
105 onRenderPreCb(void *data, void *extra)
107 UxSampleTest *view = (UxSampleTest *)data;
109 view->mView->render();
113 onResizeCb(void *data, void *extra)
115 UxSampleTest *view = (UxSampleTest *)data;
120 main(int argc, char **argv)
122 EvasApp *app = new EvasApp(800, 800);
125 bool renderMode = true;
127 if (!strcmp(argv[1],"--disable-render"))
130 UxSampleTest *view = new UxSampleTest(app, renderMode);
133 app->addExitCb(onExitCb, view);
134 app->addKeyCb(onKeyCb, view);
135 app->addRenderPreCb(onRenderPreCb, view);
136 app->addResizeCb(onResizeCb, view);