| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtQuick module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 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 https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QQUICKANIMATOR_P_H |
| 41 | #define QQUICKANIMATOR_P_H |
| 42 | |
| 43 | // |
| 44 | // W A R N I N G |
| 45 | // ------------- |
| 46 | // |
| 47 | // This file is not part of the Qt API. It exists purely as an |
| 48 | // implementation detail. This header file may change from version to |
| 49 | // version without notice, or even be removed. |
| 50 | // |
| 51 | // We mean it. |
| 52 | // |
| 53 | |
| 54 | #include "qquickanimation_p.h" |
| 55 | |
| 56 | QT_BEGIN_NAMESPACE |
| 57 | |
| 58 | class QQuickItem; |
| 59 | |
| 60 | class QQuickAnimatorJob; |
| 61 | class QQuickAnimatorPrivate; |
| 62 | class Q_QUICK_PRIVATE_EXPORT QQuickAnimator : public QQuickAbstractAnimation |
| 63 | { |
| 64 | Q_OBJECT |
| 65 | Q_DECLARE_PRIVATE(QQuickAnimator) |
| 66 | Q_PROPERTY(QQuickItem *target READ targetItem WRITE setTargetItem NOTIFY targetItemChanged) |
| 67 | Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged) |
| 68 | Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) |
| 69 | Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) |
| 70 | Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) |
| 71 | |
| 72 | QML_NAMED_ELEMENT(Animator) |
| 73 | QML_ADDED_IN_MINOR_VERSION(2) |
| 74 | QML_UNCREATABLE("Animator is an abstract class" ) |
| 75 | |
| 76 | public: |
| 77 | QQuickItem *targetItem() const; |
| 78 | void setTargetItem(QQuickItem *target); |
| 79 | |
| 80 | int duration() const; |
| 81 | void setDuration(int duration); |
| 82 | |
| 83 | QEasingCurve easing() const; |
| 84 | void setEasing(const QEasingCurve & easing); |
| 85 | |
| 86 | qreal to() const; |
| 87 | void setTo(qreal to); |
| 88 | |
| 89 | qreal from() const; |
| 90 | void setFrom(qreal from); |
| 91 | |
| 92 | protected: |
| 93 | ThreadingModel threadingModel() const override { return RenderThread; } |
| 94 | virtual QQuickAnimatorJob *createJob() const = 0; |
| 95 | virtual QString propertyName() const = 0; |
| 96 | QAbstractAnimationJob *transition(QQuickStateActions &actions, |
| 97 | QQmlProperties &modified, |
| 98 | TransitionDirection, |
| 99 | QObject *) override; |
| 100 | |
| 101 | QQuickAnimator(QQuickAnimatorPrivate &dd, QObject *parent = nullptr); |
| 102 | QQuickAnimator(QObject *parent = nullptr); |
| 103 | |
| 104 | Q_SIGNALS: |
| 105 | void targetItemChanged(QQuickItem *); |
| 106 | void durationChanged(int duration); |
| 107 | void easingChanged(const QEasingCurve &curve); |
| 108 | void toChanged(qreal to); |
| 109 | void fromChanged(qreal from); |
| 110 | }; |
| 111 | |
| 112 | class QQuickScaleAnimatorPrivate; |
| 113 | class Q_QUICK_PRIVATE_EXPORT QQuickScaleAnimator : public QQuickAnimator |
| 114 | { |
| 115 | Q_OBJECT |
| 116 | QML_NAMED_ELEMENT(ScaleAnimator) |
| 117 | QML_ADDED_IN_MINOR_VERSION(2) |
| 118 | public: |
| 119 | QQuickScaleAnimator(QObject *parent = nullptr); |
| 120 | protected: |
| 121 | QQuickAnimatorJob *createJob() const override; |
| 122 | QString propertyName() const override { return QStringLiteral("scale" ); } |
| 123 | }; |
| 124 | |
| 125 | class Q_QUICK_PRIVATE_EXPORT QQuickXAnimator : public QQuickAnimator |
| 126 | { |
| 127 | Q_OBJECT |
| 128 | QML_NAMED_ELEMENT(XAnimator) |
| 129 | QML_ADDED_IN_MINOR_VERSION(2) |
| 130 | public: |
| 131 | QQuickXAnimator(QObject *parent = nullptr); |
| 132 | protected: |
| 133 | QQuickAnimatorJob *createJob() const override; |
| 134 | QString propertyName() const override { return QStringLiteral("x" ); } |
| 135 | }; |
| 136 | |
| 137 | class Q_QUICK_PRIVATE_EXPORT QQuickYAnimator : public QQuickAnimator |
| 138 | { |
| 139 | Q_OBJECT |
| 140 | QML_NAMED_ELEMENT(YAnimator) |
| 141 | QML_ADDED_IN_MINOR_VERSION(2) |
| 142 | public: |
| 143 | QQuickYAnimator(QObject *parent = nullptr); |
| 144 | protected: |
| 145 | QQuickAnimatorJob *createJob() const override; |
| 146 | QString propertyName() const override { return QStringLiteral("y" ); } |
| 147 | }; |
| 148 | |
| 149 | class Q_QUICK_PRIVATE_EXPORT QQuickOpacityAnimator : public QQuickAnimator |
| 150 | { |
| 151 | Q_OBJECT |
| 152 | QML_NAMED_ELEMENT(OpacityAnimator) |
| 153 | QML_ADDED_IN_MINOR_VERSION(2) |
| 154 | public: |
| 155 | QQuickOpacityAnimator(QObject *parent = nullptr); |
| 156 | protected: |
| 157 | QQuickAnimatorJob *createJob() const override; |
| 158 | QString propertyName() const override { return QStringLiteral("opacity" ); } |
| 159 | }; |
| 160 | |
| 161 | class QQuickRotationAnimatorPrivate; |
| 162 | class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimator : public QQuickAnimator |
| 163 | { |
| 164 | Q_OBJECT |
| 165 | Q_DECLARE_PRIVATE(QQuickRotationAnimator) |
| 166 | Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged) |
| 167 | QML_NAMED_ELEMENT(RotationAnimator) |
| 168 | QML_ADDED_IN_MINOR_VERSION(2) |
| 169 | |
| 170 | public: |
| 171 | enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise }; |
| 172 | Q_ENUM(RotationDirection) |
| 173 | |
| 174 | QQuickRotationAnimator(QObject *parent = nullptr); |
| 175 | |
| 176 | void setDirection(RotationDirection dir); |
| 177 | RotationDirection direction() const; |
| 178 | |
| 179 | Q_SIGNALS: |
| 180 | void directionChanged(RotationDirection dir); |
| 181 | |
| 182 | protected: |
| 183 | QQuickAnimatorJob *createJob() const override; |
| 184 | QString propertyName() const override { return QStringLiteral("rotation" ); } |
| 185 | }; |
| 186 | |
| 187 | #if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl) |
| 188 | class QQuickUniformAnimatorPrivate; |
| 189 | class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimator : public QQuickAnimator |
| 190 | { |
| 191 | Q_OBJECT |
| 192 | Q_DECLARE_PRIVATE(QQuickUniformAnimator) |
| 193 | Q_PROPERTY(QString uniform READ uniform WRITE setUniform NOTIFY uniformChanged) |
| 194 | QML_NAMED_ELEMENT(UniformAnimator) |
| 195 | QML_ADDED_IN_MINOR_VERSION(2) |
| 196 | |
| 197 | public: |
| 198 | QQuickUniformAnimator(QObject *parent = nullptr); |
| 199 | |
| 200 | QString uniform() const; |
| 201 | void setUniform(const QString &); |
| 202 | |
| 203 | Q_SIGNALS: |
| 204 | void uniformChanged(const QString &); |
| 205 | |
| 206 | protected: |
| 207 | QQuickAnimatorJob *createJob() const override; |
| 208 | QString propertyName() const override; |
| 209 | }; |
| 210 | #endif |
| 211 | |
| 212 | QT_END_NAMESPACE |
| 213 | |
| 214 | QML_DECLARE_TYPE(QQuickAnimator) |
| 215 | QML_DECLARE_TYPE(QQuickXAnimator) |
| 216 | QML_DECLARE_TYPE(QQuickYAnimator) |
| 217 | QML_DECLARE_TYPE(QQuickScaleAnimator) |
| 218 | QML_DECLARE_TYPE(QQuickRotationAnimator) |
| 219 | QML_DECLARE_TYPE(QQuickOpacityAnimator) |
| 220 | #if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl) |
| 221 | QML_DECLARE_TYPE(QQuickUniformAnimator) |
| 222 | #endif |
| 223 | #endif // QQUICKANIMATOR_P_H |
| 224 | |