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
56QT_BEGIN_NAMESPACE
57
58class QQuickItem;
59
60class QQuickAnimatorJob;
61class QQuickAnimatorPrivate;
62class 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
72public:
73 QQuickItem *targetItem() const;
74 void setTargetItem(QQuickItem *target);
75
76 int duration() const;
77 void setDuration(int duration);
78
79 QEasingCurve easing() const;
80 void setEasing(const QEasingCurve & easing);
81
82 qreal to() const;
83 void setTo(qreal to);
84
85 qreal from() const;
86 void setFrom(qreal from);
87
88protected:
89 ThreadingModel threadingModel() const override { return RenderThread; }
90 virtual QQuickAnimatorJob *createJob() const = 0;
91 virtual QString propertyName() const = 0;
92 QAbstractAnimationJob *transition(QQuickStateActions &actions,
93 QQmlProperties &modified,
94 TransitionDirection,
95 QObject *) override;
96
97 QQuickAnimator(QQuickAnimatorPrivate &dd, QObject *parent = nullptr);
98 QQuickAnimator(QObject *parent = nullptr);
99
100Q_SIGNALS:
101 void targetItemChanged(QQuickItem *);
102 void durationChanged(int duration);
103 void easingChanged(const QEasingCurve &curve);
104 void toChanged(qreal to);
105 void fromChanged(qreal from);
106};
107
108class QQuickScaleAnimatorPrivate;
109class Q_QUICK_PRIVATE_EXPORT QQuickScaleAnimator : public QQuickAnimator
110{
111 Q_OBJECT
112public:
113 QQuickScaleAnimator(QObject *parent = nullptr);
114protected:
115 QQuickAnimatorJob *createJob() const override;
116 QString propertyName() const override { return QStringLiteral("scale"); }
117};
118
119class Q_QUICK_PRIVATE_EXPORT QQuickXAnimator : public QQuickAnimator
120{
121 Q_OBJECT
122public:
123 QQuickXAnimator(QObject *parent = nullptr);
124protected:
125 QQuickAnimatorJob *createJob() const override;
126 QString propertyName() const override { return QStringLiteral("x"); }
127};
128
129class Q_QUICK_PRIVATE_EXPORT QQuickYAnimator : public QQuickAnimator
130{
131 Q_OBJECT
132public:
133 QQuickYAnimator(QObject *parent = nullptr);
134protected:
135 QQuickAnimatorJob *createJob() const override;
136 QString propertyName() const override { return QStringLiteral("y"); }
137};
138
139class Q_QUICK_PRIVATE_EXPORT QQuickOpacityAnimator : public QQuickAnimator
140{
141 Q_OBJECT
142public:
143 QQuickOpacityAnimator(QObject *parent = nullptr);
144protected:
145 QQuickAnimatorJob *createJob() const override;
146 QString propertyName() const override { return QStringLiteral("opacity"); }
147};
148
149class QQuickRotationAnimatorPrivate;
150class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimator : public QQuickAnimator
151{
152 Q_OBJECT
153 Q_DECLARE_PRIVATE(QQuickRotationAnimator)
154 Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
155
156public:
157 enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
158 Q_ENUM(RotationDirection)
159
160 QQuickRotationAnimator(QObject *parent = nullptr);
161
162 void setDirection(RotationDirection dir);
163 RotationDirection direction() const;
164
165Q_SIGNALS:
166 void directionChanged(RotationDirection dir);
167
168protected:
169 QQuickAnimatorJob *createJob() const override;
170 QString propertyName() const override { return QStringLiteral("rotation"); }
171};
172
173#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
174class QQuickUniformAnimatorPrivate;
175class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimator : public QQuickAnimator
176{
177 Q_OBJECT
178 Q_DECLARE_PRIVATE(QQuickUniformAnimator)
179 Q_PROPERTY(QString uniform READ uniform WRITE setUniform NOTIFY uniformChanged)
180
181public:
182 QQuickUniformAnimator(QObject *parent = nullptr);
183
184 QString uniform() const;
185 void setUniform(const QString &);
186
187Q_SIGNALS:
188 void uniformChanged(const QString &);
189
190protected:
191 QQuickAnimatorJob *createJob() const override;
192 QString propertyName() const override;
193};
194#endif
195
196QT_END_NAMESPACE
197
198QML_DECLARE_TYPE(QQuickAnimator)
199QML_DECLARE_TYPE(QQuickXAnimator)
200QML_DECLARE_TYPE(QQuickYAnimator)
201QML_DECLARE_TYPE(QQuickScaleAnimator)
202QML_DECLARE_TYPE(QQuickRotationAnimator)
203QML_DECLARE_TYPE(QQuickOpacityAnimator)
204#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
205QML_DECLARE_TYPE(QQuickUniformAnimator)
206#endif
207#endif // QQUICKANIMATOR_P_H
208