File: demo_marker.cpp

package info (click to toggle)
rlottie 0.1%2Bdfsg-4.2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 9,872 kB
  • sloc: cpp: 20,373; asm: 221; ansic: 194; makefile: 16
file content (92 lines) | stat: -rw-r--r-- 2,332 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* 
 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "evasapp.h"
#include "lottieview.h"
#include<iostream>
#include <stdio.h>
#include <fstream>
#include <sstream>
using namespace std;

class DemoMarker
{
public:
   DemoMarker(EvasApp *app, std::string filePath) {
      view1.reset(new LottieView(app->evas()));
      view1->setFilePath(filePath.c_str());
      view1->setPos(0, 0);
      view1->setSize(400, 400);
      view1->show();
      view1->play();
      view1->loop(true);

      /* Play with marker */
      view2.reset(new LottieView(app->evas()));
      view2->setFilePath(filePath.c_str());
      view2->setPos(400, 0);
      view2->setSize(400, 400);
      view2->show();
      view2->play("second");
      view2->loop(true);

      /* Play marker to marker */
      view3.reset(new LottieView(app->evas()));
      view3->setFilePath(filePath.c_str());
      view3->setPos(800, 0);
      view3->setSize(400, 400);
      view3->show();
      view3->play("second", "third");
      view3->loop(true);
   }

private:
    std::unique_ptr<LottieView>  view1;
    std::unique_ptr<LottieView>  view2;
    std::unique_ptr<LottieView>  view3;   
};

static void
onExitCb(void *data, void */*extra*/)
{
    DemoMarker *demo = (DemoMarker *)data;
    delete demo;
}

int
main(void)
{
   EvasApp *app = new EvasApp(1200, 400);
   app->setup();

   std::string filePath = DEMO_DIR;
   filePath +="marker.json";

   auto demo = new DemoMarker(app, filePath);

   app->addExitCb(onExitCb, demo);
   app->run();

   delete app;
   return 0;
}