| 1 | // Copyright (C) 2018 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QLOTTIEBASE_P_H |
| 5 | #define QLOTTIEBASE_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 | |
| 21 | #include <QtLottie/qtlottieexports.h> |
| 22 | #include <QtLottie/private/qlottieconstants_p.h> |
| 23 | |
| 24 | #include <QtLottie/private/qlottierenderer_p.h> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | class Q_LOTTIE_EXPORT QLottieBase |
| 28 | { |
| 29 | public: |
| 30 | QLottieBase() = default; |
| 31 | explicit QLottieBase(const QLottieBase &other); |
| 32 | virtual ~QLottieBase(); |
| 33 | |
| 34 | virtual QLottieBase *clone() const; |
| 35 | |
| 36 | virtual bool setProperty(QLottieLiteral::PropertyType propertyType, QVariant value); |
| 37 | |
| 38 | QString name() const; |
| 39 | void setName(const QString &name); |
| 40 | |
| 41 | int type() const; |
| 42 | void setType(int type); |
| 43 | virtual void parse(const QJsonObject &definition); |
| 44 | |
| 45 | const QJsonObject& definition() const; |
| 46 | |
| 47 | virtual bool active(int frame) const; |
| 48 | bool hidden() const; |
| 49 | |
| 50 | inline QLottieBase *parent() const { return m_parent; } |
| 51 | void setParent(QLottieBase *parent); |
| 52 | |
| 53 | const QList<QLottieBase *> &children() const { return m_children; } |
| 54 | void prependChild(QLottieBase *child); |
| 55 | void insertChildBeforeLast(QLottieBase *child); |
| 56 | void appendChild(QLottieBase *child); |
| 57 | |
| 58 | virtual QLottieBase *findChild(const QString &childName); |
| 59 | |
| 60 | virtual void updateProperties(int frame); |
| 61 | virtual void render(QLottieRenderer &renderer) const; |
| 62 | |
| 63 | bool isStructureDumping() const; |
| 64 | |
| 65 | protected: |
| 66 | void resolveTopRoot(); |
| 67 | QLottieBase *topRoot() const; |
| 68 | const QJsonObject resolveExpression(const QJsonObject& definition); |
| 69 | |
| 70 | protected: |
| 71 | QJsonObject m_definition; |
| 72 | int m_type = -1; |
| 73 | bool m_hidden = false; |
| 74 | mutable qint8 m_structureDumping = -1; |
| 75 | QString m_name; |
| 76 | QString m_matchName; |
| 77 | bool m_autoOrient = false; |
| 78 | |
| 79 | friend class QLottieRasterRenderer; |
| 80 | friend class QLottieRenderer; |
| 81 | |
| 82 | private: |
| 83 | QLottieBase *m_parent = nullptr; |
| 84 | QList<QLottieBase *> m_children; |
| 85 | |
| 86 | // Handle to the topmost element on which this element resides |
| 87 | // Will be resolved when traversing effects |
| 88 | QLottieBase *m_topRoot = nullptr; |
| 89 | }; |
| 90 | |
| 91 | QT_END_NAMESPACE |
| 92 | |
| 93 | #endif // QLOTTIEBASE_P_H |
| 94 | |