1 #pragma once
2 
3 #ifndef SCRIPTBINDING_LEVEL_H
4 #define SCRIPTBINDING_LEVEL_H
5 
6 #include "toonz/scriptbinding.h"
7 #include "toonz/scriptbinding_image.h"
8 
9 class ToonzScene;
10 class TXshSimpleLevel;
11 
12 namespace TScriptBinding {
13 
14 class DVAPI Level final : public Wrapper {
15   Q_OBJECT
16   TXshSimpleLevel *m_sl;
17   ToonzScene *m_scene;
18   bool m_sceneOwner;
19   int m_type;
20 
21 public:
22   Level();
23   Level(TXshSimpleLevel *);
24   ~Level();
25 
26   WRAPPER_STD_METHODS(Image)
27   Q_INVOKABLE QScriptValue toString();
28 
29   // QScriptValue toScriptValue(QScriptEngine *engine) { return create(engine,
30   // this); }
31   // static QScriptValue toScriptValue(QScriptEngine *engine, TXshSimpleLevel
32   // *sl) { return (new Level(sl))->toScriptValue(engine); }
33 
34   Q_PROPERTY(QString type READ getType)
35   QString getType() const;
36 
37   Q_PROPERTY(int frameCount READ getFrameCount)
38   int getFrameCount() const;
39 
40   Q_PROPERTY(QString name READ getName WRITE setName)
41   QString getName() const;
42   void setName(const QString &name);
43 
44   Q_PROPERTY(QScriptValue path READ getPath WRITE setPath)
45   QScriptValue getPath() const;
46   void setPath(const QScriptValue &name);
47 
48   Q_INVOKABLE QScriptValue getFrame(const QScriptValue &fid);
49   Q_INVOKABLE QScriptValue getFrameByIndex(const QScriptValue &index);
50   Q_INVOKABLE QScriptValue setFrame(const QScriptValue &fid,
51                                     const QScriptValue &image);
52 
53   Q_INVOKABLE QScriptValue getFrameIds();
54 
55   Q_INVOKABLE QScriptValue load(const QScriptValue &fp);
56   Q_INVOKABLE QScriptValue save(const QScriptValue &fp);
57 
58   void getFrameIds(QList<TFrameId> &fids);
59   TImageP getImg(const TFrameId &fid);
60 
61   int setFrame(const TFrameId &fid, const TImageP &img);
62 
getSimpleLevel()63   TXshSimpleLevel *getSimpleLevel() const { return m_sl; }
64 
65   static TFrameId getFid(const QScriptValue &arg, QString &err);
66 };
67 
68 }  // namespace TScriptBinding
69 
70 Q_DECLARE_METATYPE(TScriptBinding::Level *)
71 
72 #endif
73