1 | // Copyright (C) 2017 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qabstractanimation.h" |
5 | #include "Qt3DAnimation/private/qabstractanimation_p.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | namespace Qt3DAnimation { |
10 | |
11 | /*! |
12 | \class Qt3DAnimation::QAbstractAnimation |
13 | \brief An abstract base class for Qt3D animations. |
14 | \inmodule Qt3DAnimation |
15 | \since 5.9 |
16 | \inherits QObject |
17 | |
18 | Qt3DAnimation::QAbstractAnimation is an abstract base class for all animations. |
19 | Qt3DAnimation::QAbstractAnimation can not be directly instantiated, but rather |
20 | through its subclasses. QAbstractAnimation specifies common properties |
21 | for all Qt3D animations, such as animation name and type, current position and animation |
22 | duration, while leaving the actual animating for the subclasses. |
23 | */ |
24 | |
25 | /*! |
26 | \qmltype AbstractAnimation |
27 | \brief An abstract base type for Qt3D animations. |
28 | \inqmlmodule Qt3D.Animation |
29 | \since 5.9 |
30 | \instantiates Qt3DAnimation::QAbstractAnimation |
31 | |
32 | AbstractAnimation is an abstract base type for all animations. |
33 | AbstractAnimation can not be directly instantiated, but rather |
34 | through its subtypes. AbstractAnimation specifies common properties |
35 | for all Qt3D animations, such as animation type, current position and animation |
36 | duration, while leaving the actual animating for the subtypes. |
37 | */ |
38 | /*! |
39 | \enum QAbstractAnimation::AnimationType |
40 | |
41 | This enumeration specifies the type of the animation |
42 | \value KeyframeAnimation Simple keyframe animation implementation for QTransform |
43 | \value MorphingAnimation Blend-shape morphing animation |
44 | \value VertexBlendAnimation Vertex-blend animation |
45 | */ |
46 | /*! |
47 | \property Qt3DAnimation::QAbstractAnimation::animationName |
48 | Holds the name of the animation. |
49 | */ |
50 | /*! |
51 | \property Qt3DAnimation::QAbstractAnimation::animationType |
52 | Holds the type of the animation. |
53 | */ |
54 | /*! |
55 | \property Qt3DAnimation::QAbstractAnimation::position |
56 | Holds the current position of the animation. |
57 | */ |
58 | /*! |
59 | \property Qt3DAnimation::QAbstractAnimation::duration |
60 | Holds the duration of the animation. |
61 | */ |
62 | |
63 | /*! |
64 | \qmlproperty string AbstractAnimation::animationName |
65 | Holds the name of the animation. |
66 | */ |
67 | /*! |
68 | \qmlproperty enumeration AbstractAnimation::animationType |
69 | Holds the type of the animation. |
70 | \list |
71 | \li KeyframeAnimation |
72 | \li MorphingAnimation |
73 | \li VertexBlendAnimation |
74 | \endlist |
75 | */ |
76 | /*! |
77 | \qmlproperty real AbstractAnimation::position |
78 | Holds the current position of the animation. |
79 | */ |
80 | /*! |
81 | \qmlproperty real AbstractAnimation::duration |
82 | Holds the duration of the animation. |
83 | */ |
84 | |
85 | QAbstractAnimationPrivate::QAbstractAnimationPrivate(QAbstractAnimation::AnimationType type) |
86 | : QObjectPrivate() |
87 | , m_animationType(type) |
88 | , m_position(0.0f) |
89 | , m_duration(0.0f) |
90 | { |
91 | |
92 | } |
93 | |
94 | QAbstractAnimation::QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent) |
95 | : QObject(dd, parent) |
96 | { |
97 | |
98 | } |
99 | |
100 | QString QAbstractAnimation::animationName() const |
101 | { |
102 | Q_D(const QAbstractAnimation); |
103 | return d->m_animationName; |
104 | } |
105 | |
106 | QAbstractAnimation::AnimationType QAbstractAnimation::animationType() const |
107 | { |
108 | Q_D(const QAbstractAnimation); |
109 | return d->m_animationType; |
110 | } |
111 | |
112 | float QAbstractAnimation::position() const |
113 | { |
114 | Q_D(const QAbstractAnimation); |
115 | return d->m_position; |
116 | } |
117 | |
118 | float QAbstractAnimation::duration() const |
119 | { |
120 | Q_D(const QAbstractAnimation); |
121 | return d->m_duration; |
122 | } |
123 | |
124 | void QAbstractAnimation::setAnimationName(const QString &name) |
125 | { |
126 | Q_D(QAbstractAnimation); |
127 | if (name != d->m_animationName) { |
128 | d->m_animationName = name; |
129 | emit animationNameChanged(name); |
130 | } |
131 | } |
132 | |
133 | void QAbstractAnimation::setPosition(float position) |
134 | { |
135 | Q_D(QAbstractAnimation); |
136 | if (!qFuzzyCompare(p1: position, p2: d->m_position)) { |
137 | d->m_position = position; |
138 | emit positionChanged(position); |
139 | } |
140 | } |
141 | |
142 | /*! |
143 | Sets the \a duration of the animation. |
144 | */ |
145 | void QAbstractAnimation::setDuration(float duration) |
146 | { |
147 | Q_D(QAbstractAnimation); |
148 | if (!qFuzzyCompare(p1: duration, p2: d->m_duration)) { |
149 | d->m_duration = duration; |
150 | emit durationChanged(duration); |
151 | } |
152 | } |
153 | |
154 | } // Qt3DAnimation |
155 | |
156 | QT_END_NAMESPACE |
157 | |
158 | #include "moc_qabstractanimation.cpp" |
159 | |