e3e02d5d14eba5bbeb5f2ff454850695a1c5b186
[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() { return mRenderMode ? mImage : mVg; }
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     void finished();
43     void play();
44     void pause();
45     void stop();
46     void render();
47 private:
48     void createVgNode(LOTNode *node, Efl_VG *parent);
49     void update(const std::vector<LOTNode *> &);
50     void restart();
51 public:
52     int                      mw;
53     int                      mh;
54     Evas                    *mEvas;
55     Efl_VG                  *mRoot;
56     Evas_Object             *mVg;
57     int                      mRepeatCount;
58     LottieView::RepeatMode   mRepeatMode;
59     lottieplayer::LOTPlayer    *mPlayer;
60     Ecore_Animator          *mAnimator{nullptr};
61     bool                     mLoop;
62     int                      mCurCount;
63     bool                     mReverse;
64     bool                     mPalying;
65     Evas_Object             *mImage;
66     float                    mSpeed;
67     bool                     mRenderMode;
68     bool                     mAsyncRender;
69     bool                     mDirty;
70     float                    mPendingPos;
71     float                    mFrameRate;
72     long                     mTotalFrame;
73     std::future<bool>        mRenderTask;
74     LOTBuffer                mBuffer;
75 };
76 #endif //LOTTIEVIEW_H