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
27QT_BEGIN_NAMESPACE
28class BODYMOVIN_EXPORT BMBase
29{
30public:
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 appendChild(BMBase *child);
57
58 virtual BMBase *findChild(const QString &childName);
59
60 virtual void updateProperties(int frame);
61 virtual void render(LottieRenderer &renderer) const;
62
63protected:
64 void resolveTopRoot();
65 BMBase *topRoot() const;
66 const QJsonObject resolveExpression(const QJsonObject& definition);
67
68protected:
69 QJsonObject m_definition;
70 int m_type;
71 bool m_hidden = false;
72 QVersionNumber m_version;
73 QString m_name;
74 QString m_matchName;
75 bool m_autoOrient = false;
76
77 friend class BMRasterRenderer;
78 friend class BMRenderer;
79
80private:
81 BMBase *m_parent = nullptr;
82 QList<BMBase *> m_children;
83
84 // Handle to the topmost element on which this element resides
85 // Will be resolved when traversing effects
86 BMBase *m_topRoot = nullptr;
87};
88
89QT_END_NAMESPACE
90
91#endif // BMBASE_P_H
92

source code of qtlottie/src/bodymovin/bmbase_p.h