lottie/example: enhanced lottieviewer example
[platform/core/uifw/lottie-player.git] / example / lottieview.h
1 #ifndef LOTTIEVIEW_H
2 #define LOTTIEVIEW_H
3
4 #ifndef EFL_BETA_API_SUPPORT
5 #define EFL_BETA_API_SUPPORT
6 #endif
7
8 #ifndef EFL_EO_API_SUPPORT
9 #define EFL_EO_API_SUPPORT
10 #endif
11
12 #include <Eo.h>
13 #include <Efl.h>
14 #include <Evas.h>
15 #include <Ecore.h>
16 #include <Ecore_Evas.h>
17 #include"lotplayer.h"
18 #include<future>
19 class LottieView
20 {
21 public:
22     enum class RepeatMode {
23         Restart,
24         Reverse
25     };
26     LottieView(Evas *evas, bool renderMode = true, bool asyncRender = true);
27     ~LottieView();
28     Evas_Object *getImage();
29     void setSize(int w, int h);
30     void setPos(int x, int y);
31     void setFilePath(const char *filePath);
32     void show();
33     void hide();
34     void loop(bool loop);
35     void setSpeed(float speed) { mSpeed = speed;}
36     void setRepeatCount(int count);
37     void setRepeatMode(LottieView::RepeatMode mode);
38     float getFrameRate() const { return mFrameRate; }
39     long getTotalFrame() const { return mTotalFrame; }
40 public:
41     void seek(float pos);
42     float getPos();
43     void finished();
44     void play();
45     void pause();
46     void stop();
47     void render();
48     void initializeBufferObject(Evas *evas);
49 private:
50     void createVgNode(LOTNode *node, Efl_VG *parent);
51     void update(const std::vector<LOTNode *> &);
52     void restart();
53 public:
54     int                      mw;
55     int                      mh;
56     Evas                    *mEvas;
57     Efl_VG                  *mRoot;
58     Evas_Object             *mVg;
59     int                      mRepeatCount;
60     LottieView::RepeatMode   mRepeatMode;
61     lottieplayer::LOTPlayer    *mPlayer;
62     Ecore_Animator          *mAnimator{nullptr};
63     bool                     mLoop;
64     int                      mCurCount;
65     bool                     mReverse;
66     bool                     mPalying;
67     Evas_Object             *mImage;
68     float                    mSpeed;
69     bool                     mRenderMode;
70     bool                     mAsyncRender;
71     bool                     mDirty;
72     float                    mStartPos;
73     float                    mPos;
74     float                    mFrameRate;
75     long                     mTotalFrame;
76     std::future<bool>        mRenderTask;
77     LOTBuffer                mBuffer;
78 };
79 #endif //LOTTIEVIEW_H