| 1 | // Copyright (C) 2019 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICKKEYFRAME_P_H |
| 5 | #define QQUICKKEYFRAME_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 "qtquicktimelineglobal_p.h" |
| 19 | |
| 20 | #include <QtCore/QObject> |
| 21 | #include <QtCore/qeasingcurve.h> |
| 22 | |
| 23 | #include <QtQml/qqml.h> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | class QQuickKeyframeGroupPrivate; |
| 28 | class QQuickKeyframePrivate; |
| 29 | class QQuickNumberKeyframePrivate; |
| 30 | |
| 31 | class Q_QUICKTIMELINE_EXPORT QQuickKeyframe : public QObject |
| 32 | { |
| 33 | Q_OBJECT |
| 34 | Q_DECLARE_PRIVATE(QQuickKeyframe) |
| 35 | |
| 36 | Q_PROPERTY(qreal frame READ frame WRITE setFrame NOTIFY frameChanged) |
| 37 | Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingCurveChanged) |
| 38 | Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) |
| 39 | |
| 40 | QML_NAMED_ELEMENT(Keyframe) |
| 41 | QML_ADDED_IN_VERSION(1, 0) |
| 42 | |
| 43 | public: |
| 44 | explicit QQuickKeyframe(QObject *parent = nullptr); |
| 45 | |
| 46 | qreal frame() const; |
| 47 | void setFrame(qreal); |
| 48 | void reset(); |
| 49 | |
| 50 | QEasingCurve easing() const; |
| 51 | void setEasing(const QEasingCurve &); |
| 52 | |
| 53 | QVariant value() const; |
| 54 | void setValue(const QVariant &v); |
| 55 | |
| 56 | virtual QVariant evaluate(QQuickKeyframe *pre, qreal frame, int userType) const; |
| 57 | |
| 58 | protected: |
| 59 | QQuickKeyframe(QQuickKeyframePrivate &dd, QObject *parent); |
| 60 | |
| 61 | Q_SIGNALS: |
| 62 | void frameChanged(); |
| 63 | void easingCurveChanged(); |
| 64 | void valueChanged(); |
| 65 | }; |
| 66 | |
| 67 | class Q_QUICKTIMELINE_EXPORT QQuickKeyframeGroup : public QObject, public QQmlParserStatus |
| 68 | { |
| 69 | Q_OBJECT |
| 70 | Q_DECLARE_PRIVATE(QQuickKeyframeGroup) |
| 71 | |
| 72 | Q_INTERFACES(QQmlParserStatus) |
| 73 | |
| 74 | Q_PROPERTY(QObject *target READ target WRITE setTargetObject NOTIFY targetChanged) |
| 75 | Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) |
| 76 | Q_PROPERTY(QQmlListProperty<QQuickKeyframe> keyframes READ keyframes) |
| 77 | Q_PROPERTY(QUrl keyframeSource READ keyframeSource WRITE setKeyframeSource NOTIFY keyframeSourceChanged REVISION(1, 1)) |
| 78 | |
| 79 | QML_NAMED_ELEMENT(KeyframeGroup) |
| 80 | QML_ADDED_IN_VERSION(1, 0) |
| 81 | |
| 82 | Q_CLASSINFO("DefaultProperty" , "keyframes" ) |
| 83 | |
| 84 | public: |
| 85 | explicit QQuickKeyframeGroup(QObject *parent = nullptr); |
| 86 | |
| 87 | QQmlListProperty<QQuickKeyframe> keyframes(); |
| 88 | |
| 89 | QObject *target() const; |
| 90 | void setTargetObject(QObject *); |
| 91 | |
| 92 | QString property() const; |
| 93 | void setProperty(const QString &); |
| 94 | |
| 95 | Q_REVISION(1, 1) QUrl keyframeSource() const; |
| 96 | Q_REVISION(1, 1) void setKeyframeSource(const QUrl &source); |
| 97 | |
| 98 | const QByteArray keyframeData() const; |
| 99 | void setKeyframeData(const QByteArray &data); |
| 100 | |
| 101 | QVariant evaluate(qreal frame) const; |
| 102 | |
| 103 | void setProperty(qreal frame); |
| 104 | |
| 105 | void init(); |
| 106 | |
| 107 | void resetDefaultValue(); |
| 108 | |
| 109 | void reset(); |
| 110 | |
| 111 | protected: |
| 112 | void setupKeyframes(); |
| 113 | |
| 114 | void classBegin() override; |
| 115 | void componentComplete() override; |
| 116 | |
| 117 | Q_SIGNALS: |
| 118 | void targetChanged(); |
| 119 | void propertyChanged(); |
| 120 | Q_REVISION(1, 1) void keyframeSourceChanged(); |
| 121 | }; |
| 122 | |
| 123 | QT_END_NAMESPACE |
| 124 | |
| 125 | #endif // QQUICKKEYFRAME_P_H |
| 126 | |