| 1 | // Copyright (C) 2018 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef BMBASE_P_H |
| 5 | #define BMBASE_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QJsonObject> |
| 19 | #include <QList> |
| 20 | #include <QVersionNumber> |
| 21 | |
| 22 | #include <QtBodymovin/bmglobal.h> |
| 23 | #include <QtBodymovin/private/bmconstants_p.h> |
| 24 | |
| 25 | #include <QtBodymovin/private/lottierenderer_p.h> |
| 26 | |
| 27 | QT_BEGIN_NAMESPACE |
| 28 | class BODYMOVIN_EXPORT BMBase |
| 29 | { |
| 30 | public: |
| 31 | BMBase() = default; |
| 32 | explicit BMBase(const BMBase &other); |
| 33 | virtual ~BMBase(); |
| 34 | |
| 35 | virtual BMBase *clone() const; |
| 36 | |
| 37 | virtual bool setProperty(BMLiteral::PropertyType propertyType, QVariant value); |
| 38 | |
| 39 | QString name() const; |
| 40 | void setName(const QString &name); |
| 41 | |
| 42 | int type() const; |
| 43 | void setType(int type); |
| 44 | virtual void parse(const QJsonObject &definition); |
| 45 | |
| 46 | const QJsonObject& definition() const; |
| 47 | |
| 48 | virtual bool active(int frame) const; |
| 49 | bool hidden() const; |
| 50 | |
| 51 | inline BMBase *parent() const { return m_parent; } |
| 52 | void setParent(BMBase *parent); |
| 53 | |
| 54 | const QList<BMBase *> &children() const { return m_children; } |
| 55 | void prependChild(BMBase *child); |
| 56 | void insertChildBeforeLast(BMBase *child); |
| 57 | void appendChild(BMBase *child); |
| 58 | |
| 59 | virtual BMBase *findChild(const QString &childName); |
| 60 | |
| 61 | virtual void updateProperties(int frame); |
| 62 | virtual void render(LottieRenderer &renderer) const; |
| 63 | |
| 64 | protected: |
| 65 | void resolveTopRoot(); |
| 66 | BMBase *topRoot() const; |
| 67 | const QJsonObject resolveExpression(const QJsonObject& definition); |
| 68 | |
| 69 | protected: |
| 70 | QJsonObject m_definition; |
| 71 | int m_type; |
| 72 | bool m_hidden = false; |
| 73 | QVersionNumber m_version; |
| 74 | QString m_name; |
| 75 | QString m_matchName; |
| 76 | bool m_autoOrient = false; |
| 77 | |
| 78 | friend class BMRasterRenderer; |
| 79 | friend class BMRenderer; |
| 80 | |
| 81 | private: |
| 82 | BMBase *m_parent = nullptr; |
| 83 | QList<BMBase *> m_children; |
| 84 | |
| 85 | // Handle to the topmost element on which this element resides |
| 86 | // Will be resolved when traversing effects |
| 87 | BMBase *m_topRoot = nullptr; |
| 88 | }; |
| 89 | |
| 90 | QT_END_NAMESPACE |
| 91 | |
| 92 | #endif // BMBASE_P_H |
| 93 | |