summaryrefslogtreecommitdiffstats
path: root/src/animation/frontend/qabstractanimation.cpp
blob: 4744e221864415f4dc2302e3e36b1f80c400a196 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
****************************************************************************/

#include "qabstractanimation.h"
#include "Qt3DAnimation/private/qabstractanimation_p.h"

QT_BEGIN_NAMESPACE

namespace Qt3DAnimation {

/*!
    \class Qt3DAnimation::QAbstractAnimation
    \brief An abstract base class for Qt3D animations.
    \inmodule Qt3DAnimation
    \since 5.9
    \inherits QObject

    Qt3DAnimation::QAbstractAnimation is an abstract base class for all animations.
    Qt3DAnimation::QAbstractAnimation can not be directly instantiated, but rather
    through its subclasses. QAbstractAnimation specifies common properties
    for all Qt3D animations, such as animation name and type, current position and animation
    duration, while leaving the actual animating for the subclasses.
*/

/*!
    \qmltype AbstractAnimation
    \brief An abstract base type for Qt3D animations.
    \inqmlmodule Qt3D.Animation
    \since 5.9
    \instantiates Qt3DAnimation::QAbstractAnimation

    AbstractAnimation is an abstract base type for all animations.
    AbstractAnimation can not be directly instantiated, but rather
    through its subtypes. AbstractAnimation specifies common properties
    for all Qt3D animations, such as animation type, current position and animation
    duration, while leaving the actual animating for the subtypes.
*/
/*!
    \enum QAbstractAnimation::AnimationType

    This enumeration specifies the type of the animation
    \value KeyframeAnimation Simple keyframe animation implementation for QTransform
    \value MorphingAnimation Blend-shape morphing animation
    \value VertexBlendAnimation Vertex-blend animation
*/
/*!
    \property Qt3DAnimation::QAbstractAnimation::animationName
    Holds the name of the animation.
*/
/*!
    \property Qt3DAnimation::QAbstractAnimation::animationType
    Holds the type of the animation.
*/
/*!
    \property Qt3DAnimation::QAbstractAnimation::position
    Holds the current position of the animation.
*/
/*!
    \property Qt3DAnimation::QAbstractAnimation::duration
    Holds the duration of the animation.
*/

/*!
    \qmlproperty string AbstractAnimation::animationName
    Holds the name of the animation.
*/
/*!
    \qmlproperty enumeration AbstractAnimation::animationType
    Holds the type of the animation.
    \list
    \li KeyframeAnimation
    \li MorphingAnimation
    \li VertexBlendAnimation
    \endlist
*/
/*!
    \qmlproperty real AbstractAnimation::position
    Holds the current position of the animation.
*/
/*!
    \qmlproperty real AbstractAnimation::duration
    Holds the duration of the animation.
*/

QAbstractAnimationPrivate::QAbstractAnimationPrivate(QAbstractAnimation::AnimationType type)
    : QObjectPrivate()
    , m_animationType(type)
    , m_position(0.0f)
    , m_duration(0.0f)
{

}

QAbstractAnimation::QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent)
    : QObject(dd, parent)
{

}

QString QAbstractAnimation::animationName() const
{
    Q_D(const QAbstractAnimation);
    return d->m_animationName;
}

QAbstractAnimation::AnimationType QAbstractAnimation::animationType() const
{
    Q_D(const QAbstractAnimation);
    return d->m_animationType;
}

float QAbstractAnimation::position() const
{
    Q_D(const QAbstractAnimation);
    return d->m_position;
}

float QAbstractAnimation::duration() const
{
    Q_D(const QAbstractAnimation);
    return d->m_duration;
}

void QAbstractAnimation::setAnimationName(const QString &name)
{
    Q_D(QAbstractAnimation);
    if (name != d->m_animationName) {
        d->m_animationName = name;
        emit animationNameChanged(name);
    }
}

void QAbstractAnimation::setPosition(float position)
{
    Q_D(QAbstractAnimation);
    if (!qFuzzyCompare(position, d->m_position)) {
        d->m_position = position;
        emit positionChanged(position);
    }
}

/*!
    Sets the \a duration of the animation.
*/
void QAbstractAnimation::setDuration(float duration)
{
    Q_D(QAbstractAnimation);
    if (!qFuzzyCompare(duration, d->m_duration)) {
        d->m_duration = duration;
        emit durationChanged(duration);
    }
}

} // Qt3DAnimation

QT_END_NAMESPACE