1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#ifndef QT3DANIMATION_QKEYFRAMEANIMATION_H
38#define QT3DANIMATION_QKEYFRAMEANIMATION_H
39
40#include <Qt3DCore/qtransform.h>
41
42#include <Qt3DAnimation/qabstractanimation.h>
43#include <Qt3DAnimation/qt3danimation_global.h>
44
45#include <QtCore/qeasingcurve.h>
46
47QT_BEGIN_NAMESPACE
48
49namespace Qt3DAnimation {
50
51class QKeyframeAnimationPrivate;
52
53class Q_3DANIMATIONSHARED_EXPORT QKeyframeAnimation : public QAbstractAnimation
54{
55 Q_OBJECT
56 Q_PROPERTY(QVector<float> framePositions READ framePositions WRITE setFramePositions NOTIFY framePositionsChanged)
57 Q_PROPERTY(Qt3DCore::QTransform *target READ target WRITE setTarget NOTIFY targetChanged)
58 Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
59 Q_PROPERTY(QString targetName READ targetName WRITE setTargetName NOTIFY targetNameChanged)
60 Q_PROPERTY(RepeatMode startMode READ startMode WRITE setStartMode NOTIFY startModeChanged)
61 Q_PROPERTY(RepeatMode endMode READ endMode WRITE setEndMode NOTIFY endModeChanged)
62
63public:
64 explicit QKeyframeAnimation(QObject *parent = nullptr);
65
66 enum RepeatMode
67 {
68 None,
69 Constant,
70 Repeat,
71 };
72 Q_ENUM(RepeatMode)
73
74 QVector<float> framePositions() const;
75 QVector<Qt3DCore::QTransform *> keyframeList() const;
76 Qt3DCore::QTransform *target() const;
77 QEasingCurve easing() const;
78 QString targetName() const;
79 RepeatMode startMode() const;
80 RepeatMode endMode() const;
81
82 void setKeyframes(const QVector<Qt3DCore::QTransform *> &keyframes);
83 void addKeyframe(Qt3DCore::QTransform *keyframe);
84 void removeKeyframe(Qt3DCore::QTransform *keyframe);
85
86public Q_SLOTS:
87 void setFramePositions(const QVector<float> &positions);
88 void setTarget(Qt3DCore::QTransform *target);
89 void setEasing(const QEasingCurve &easing);
90 void setTargetName(const QString &name);
91 void setStartMode(RepeatMode mode);
92 void setEndMode(RepeatMode mode);
93
94Q_SIGNALS:
95 void framePositionsChanged(const QVector<float> &positions);
96 void targetChanged(Qt3DCore::QTransform *target);
97 void easingChanged(const QEasingCurve &easing);
98 void targetNameChanged(const QString &name);
99 void startModeChanged(QKeyframeAnimation::RepeatMode startMode);
100 void endModeChanged(QKeyframeAnimation::RepeatMode endMode);
101
102private:
103 void updateAnimation(float position);
104
105 Q_DECLARE_PRIVATE(QKeyframeAnimation)
106};
107
108} // Qt3DAnimation
109
110QT_END_NAMESPACE
111
112#endif // QT3DANIMATION_QKEYFRAMEANIMATION_H
113

source code of qt3d/src/animation/frontend/qkeyframeanimation.h