1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
3 
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10 
11  * The above copyright notice and this permission notice shall be included in all
12  * copies or substantial portions of the Software.
13 
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 
23 #include "evasapp.h"
24 #include "lottieview.h"
25 #include<iostream>
26 #include <stdio.h>
27 #include <fstream>
28 #include <sstream>
29 using namespace std;
30 
31 class DemoMarker
32 {
33 public:
DemoMarker(EvasApp * app,std::string filePath)34    DemoMarker(EvasApp *app, std::string filePath) {
35       view1.reset(new LottieView(app->evas()));
36       view1->setFilePath(filePath.c_str());
37       view1->setPos(0, 0);
38       view1->setSize(400, 400);
39       view1->show();
40       view1->play();
41       view1->loop(true);
42 
43       /* Play with marker */
44       view2.reset(new LottieView(app->evas()));
45       view2->setFilePath(filePath.c_str());
46       view2->setPos(400, 0);
47       view2->setSize(400, 400);
48       view2->show();
49       view2->play("second");
50       view2->loop(true);
51 
52       /* Play marker to marker */
53       view3.reset(new LottieView(app->evas()));
54       view3->setFilePath(filePath.c_str());
55       view3->setPos(800, 0);
56       view3->setSize(400, 400);
57       view3->show();
58       view3->play("second", "third");
59       view3->loop(true);
60    }
61 
62 private:
63     std::unique_ptr<LottieView>  view1;
64     std::unique_ptr<LottieView>  view2;
65     std::unique_ptr<LottieView>  view3;
66 };
67 
68 static void
onExitCb(void * data,void *)69 onExitCb(void *data, void */*extra*/)
70 {
71     DemoMarker *demo = (DemoMarker *)data;
72     delete demo;
73 }
74 
75 int
main(void)76 main(void)
77 {
78    EvasApp *app = new EvasApp(1200, 400);
79    app->setup();
80 
81    std::string filePath = DEMO_DIR;
82    filePath +="marker.json";
83 
84    auto demo = new DemoMarker(app, filePath);
85 
86    app->addExitCb(onExitCb, demo);
87    app->run();
88 
89    delete app;
90    return 0;
91 }
92 
93 
94 
95 
96 
97