| 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 QQUICKANIMATOR_P_H |
| 5 | #define QQUICKANIMATOR_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 "qquickanimation_p.h" |
| 19 | |
| 20 | QT_BEGIN_NAMESPACE |
| 21 | |
| 22 | class QQuickItem; |
| 23 | |
| 24 | class QQuickAnimatorJob; |
| 25 | class QQuickAnimatorPrivate; |
| 26 | class Q_QUICK_EXPORT QQuickAnimator : public QQuickAbstractAnimation |
| 27 | { |
| 28 | Q_OBJECT |
| 29 | Q_DECLARE_PRIVATE(QQuickAnimator) |
| 30 | Q_PROPERTY(QQuickItem *target READ targetItem WRITE setTargetItem NOTIFY targetItemChanged) |
| 31 | Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged) |
| 32 | Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) |
| 33 | Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) |
| 34 | Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) |
| 35 | |
| 36 | QML_NAMED_ELEMENT(Animator) |
| 37 | QML_ADDED_IN_VERSION(2, 2) |
| 38 | QML_UNCREATABLE("Animator is an abstract class" ) |
| 39 | |
| 40 | public: |
| 41 | QQuickItem *targetItem() const; |
| 42 | void setTargetItem(QQuickItem *target); |
| 43 | |
| 44 | int duration() const; |
| 45 | void setDuration(int duration); |
| 46 | |
| 47 | QEasingCurve easing() const; |
| 48 | void setEasing(const QEasingCurve & easing); |
| 49 | |
| 50 | qreal to() const; |
| 51 | void setTo(qreal to); |
| 52 | |
| 53 | qreal from() const; |
| 54 | void setFrom(qreal from); |
| 55 | |
| 56 | protected: |
| 57 | ThreadingModel threadingModel() const override { return RenderThread; } |
| 58 | virtual QQuickAnimatorJob *createJob() const = 0; |
| 59 | virtual QString propertyName() const = 0; |
| 60 | QAbstractAnimationJob *transition(QQuickStateActions &actions, |
| 61 | QQmlProperties &modified, |
| 62 | TransitionDirection, |
| 63 | QObject *) override; |
| 64 | |
| 65 | QQuickAnimator(QQuickAnimatorPrivate &dd, QObject *parent = nullptr); |
| 66 | QQuickAnimator(QObject *parent = nullptr); |
| 67 | |
| 68 | Q_SIGNALS: |
| 69 | void targetItemChanged(QQuickItem *); |
| 70 | void durationChanged(int duration); |
| 71 | void easingChanged(const QEasingCurve &curve); |
| 72 | void toChanged(qreal to); |
| 73 | void fromChanged(qreal from); |
| 74 | }; |
| 75 | |
| 76 | class Q_QUICK_EXPORT QQuickScaleAnimator : public QQuickAnimator |
| 77 | { |
| 78 | Q_OBJECT |
| 79 | QML_NAMED_ELEMENT(ScaleAnimator) |
| 80 | QML_ADDED_IN_VERSION(2, 2) |
| 81 | public: |
| 82 | QQuickScaleAnimator(QObject *parent = nullptr); |
| 83 | protected: |
| 84 | QQuickAnimatorJob *createJob() const override; |
| 85 | QString propertyName() const override { return QStringLiteral("scale" ); } |
| 86 | }; |
| 87 | |
| 88 | class Q_QUICK_EXPORT QQuickXAnimator : public QQuickAnimator |
| 89 | { |
| 90 | Q_OBJECT |
| 91 | QML_NAMED_ELEMENT(XAnimator) |
| 92 | QML_ADDED_IN_VERSION(2, 2) |
| 93 | public: |
| 94 | QQuickXAnimator(QObject *parent = nullptr); |
| 95 | protected: |
| 96 | QQuickAnimatorJob *createJob() const override; |
| 97 | QString propertyName() const override { return QStringLiteral("x" ); } |
| 98 | }; |
| 99 | |
| 100 | class Q_QUICK_EXPORT QQuickYAnimator : public QQuickAnimator |
| 101 | { |
| 102 | Q_OBJECT |
| 103 | QML_NAMED_ELEMENT(YAnimator) |
| 104 | QML_ADDED_IN_VERSION(2, 2) |
| 105 | public: |
| 106 | QQuickYAnimator(QObject *parent = nullptr); |
| 107 | protected: |
| 108 | QQuickAnimatorJob *createJob() const override; |
| 109 | QString propertyName() const override { return QStringLiteral("y" ); } |
| 110 | }; |
| 111 | |
| 112 | class Q_QUICK_EXPORT QQuickOpacityAnimator : public QQuickAnimator |
| 113 | { |
| 114 | Q_OBJECT |
| 115 | QML_NAMED_ELEMENT(OpacityAnimator) |
| 116 | QML_ADDED_IN_VERSION(2, 2) |
| 117 | public: |
| 118 | QQuickOpacityAnimator(QObject *parent = nullptr); |
| 119 | protected: |
| 120 | QQuickAnimatorJob *createJob() const override; |
| 121 | QString propertyName() const override { return QStringLiteral("opacity" ); } |
| 122 | }; |
| 123 | |
| 124 | class QQuickRotationAnimatorPrivate; |
| 125 | class Q_QUICK_EXPORT QQuickRotationAnimator : public QQuickAnimator |
| 126 | { |
| 127 | Q_OBJECT |
| 128 | Q_DECLARE_PRIVATE(QQuickRotationAnimator) |
| 129 | Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged) |
| 130 | QML_NAMED_ELEMENT(RotationAnimator) |
| 131 | QML_ADDED_IN_VERSION(2, 2) |
| 132 | |
| 133 | public: |
| 134 | enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise }; |
| 135 | Q_ENUM(RotationDirection) |
| 136 | |
| 137 | QQuickRotationAnimator(QObject *parent = nullptr); |
| 138 | |
| 139 | void setDirection(RotationDirection dir); |
| 140 | RotationDirection direction() const; |
| 141 | |
| 142 | Q_SIGNALS: |
| 143 | void directionChanged(RotationDirection dir); |
| 144 | |
| 145 | protected: |
| 146 | QQuickAnimatorJob *createJob() const override; |
| 147 | QString propertyName() const override { return QStringLiteral("rotation" ); } |
| 148 | }; |
| 149 | |
| 150 | #if QT_CONFIG(quick_shadereffect) |
| 151 | class QQuickUniformAnimatorPrivate; |
| 152 | class Q_QUICK_EXPORT QQuickUniformAnimator : public QQuickAnimator |
| 153 | { |
| 154 | Q_OBJECT |
| 155 | Q_DECLARE_PRIVATE(QQuickUniformAnimator) |
| 156 | Q_PROPERTY(QString uniform READ uniform WRITE setUniform NOTIFY uniformChanged) |
| 157 | QML_NAMED_ELEMENT(UniformAnimator) |
| 158 | QML_ADDED_IN_VERSION(2, 2) |
| 159 | |
| 160 | public: |
| 161 | QQuickUniformAnimator(QObject *parent = nullptr); |
| 162 | |
| 163 | QString uniform() const; |
| 164 | void setUniform(const QString &); |
| 165 | |
| 166 | Q_SIGNALS: |
| 167 | void uniformChanged(const QString &); |
| 168 | |
| 169 | protected: |
| 170 | QQuickAnimatorJob *createJob() const override; |
| 171 | QString propertyName() const override; |
| 172 | }; |
| 173 | #endif |
| 174 | |
| 175 | QT_END_NAMESPACE |
| 176 | |
| 177 | #endif // QQUICKANIMATOR_P_H |
| 178 | |