1 | // Copyright (C) 2016 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 | #ifndef QT3DANIMATION_QKEYFRAMEANIMATION_H |
5 | #define QT3DANIMATION_QKEYFRAMEANIMATION_H |
6 | |
7 | #include <Qt3DCore/qtransform.h> |
8 | |
9 | #include <Qt3DAnimation/qabstractanimation.h> |
10 | #include <Qt3DAnimation/qt3danimation_global.h> |
11 | |
12 | #include <QtCore/qeasingcurve.h> |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | namespace Qt3DAnimation { |
17 | |
18 | class QKeyframeAnimationPrivate; |
19 | |
20 | class Q_3DANIMATIONSHARED_EXPORT QKeyframeAnimation : public QAbstractAnimation |
21 | { |
22 | Q_OBJECT |
23 | Q_PROPERTY(QList<float> framePositions READ framePositions WRITE setFramePositions NOTIFY framePositionsChanged) |
24 | Q_PROPERTY(Qt3DCore::QTransform *target READ target WRITE setTarget NOTIFY targetChanged) |
25 | Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged) |
26 | Q_PROPERTY(QString targetName READ targetName WRITE setTargetName NOTIFY targetNameChanged) |
27 | Q_PROPERTY(RepeatMode startMode READ startMode WRITE setStartMode NOTIFY startModeChanged) |
28 | Q_PROPERTY(RepeatMode endMode READ endMode WRITE setEndMode NOTIFY endModeChanged) |
29 | |
30 | public: |
31 | explicit QKeyframeAnimation(QObject *parent = nullptr); |
32 | |
33 | enum RepeatMode |
34 | { |
35 | None, |
36 | Constant, |
37 | Repeat, |
38 | }; |
39 | Q_ENUM(RepeatMode) |
40 | |
41 | QList<float> framePositions() const; |
42 | QList<Qt3DCore::QTransform *> keyframeList() const; |
43 | Qt3DCore::QTransform *target() const; |
44 | QEasingCurve easing() const; |
45 | QString targetName() const; |
46 | RepeatMode startMode() const; |
47 | RepeatMode endMode() const; |
48 | |
49 | void setKeyframes(const QList<Qt3DCore::QTransform *> &keyframes); |
50 | void addKeyframe(Qt3DCore::QTransform *keyframe); |
51 | void removeKeyframe(Qt3DCore::QTransform *keyframe); |
52 | |
53 | public Q_SLOTS: |
54 | void setFramePositions(const QList<float> &positions); |
55 | void setTarget(Qt3DCore::QTransform *target); |
56 | void setEasing(const QEasingCurve &easing); |
57 | void setTargetName(const QString &name); |
58 | void setStartMode(RepeatMode mode); |
59 | void setEndMode(RepeatMode mode); |
60 | |
61 | Q_SIGNALS: |
62 | void framePositionsChanged(const QList<float> &positions); |
63 | void targetChanged(Qt3DCore::QTransform *target); |
64 | void easingChanged(const QEasingCurve &easing); |
65 | void targetNameChanged(const QString &name); |
66 | void startModeChanged(QKeyframeAnimation::RepeatMode startMode); |
67 | void endModeChanged(QKeyframeAnimation::RepeatMode endMode); |
68 | |
69 | private: |
70 | void updateAnimation(float position); |
71 | |
72 | Q_DECLARE_PRIVATE(QKeyframeAnimation) |
73 | }; |
74 | |
75 | } // Qt3DAnimation |
76 | |
77 | QT_END_NAMESPACE |
78 | |
79 | #endif // QT3DANIMATION_QKEYFRAMEANIMATION_H |
80 | |