1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEANIMATION_H
43 #define QDECLARATIVEANIMATION_H
45 #include "qdeclarativestate_p.h"
46 #include <QtGui/qvector3d.h>
48 #include <qdeclarativepropertyvaluesource.h>
49 #include <qdeclarative.h>
50 #include <qdeclarativescriptstring.h>
52 #include <QtCore/qvariant.h>
53 #include <QtCore/qeasingcurve.h>
54 #include <QtCore/QAbstractAnimation>
55 #include <QtGui/qcolor.h>
61 class QDeclarativeAbstractAnimationPrivate;
62 class QDeclarativeAnimationGroup;
63 class Q_QUICK_PRIVATE_EXPORT QDeclarativeAbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus
66 Q_DECLARE_PRIVATE(QDeclarativeAbstractAnimation)
68 Q_INTERFACES(QDeclarativeParserStatus)
69 Q_INTERFACES(QDeclarativePropertyValueSource)
71 Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
72 Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
73 Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged)
74 Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopCountChanged)
75 Q_CLASSINFO("DefaultMethod", "start()")
78 QDeclarativeAbstractAnimation(QObject *parent=0);
79 virtual ~QDeclarativeAbstractAnimation();
81 enum Loops { Infinite = -2 };
83 bool isRunning() const;
84 void setRunning(bool);
85 bool isPaused() const;
87 bool alwaysRunToEnd() const;
88 void setAlwaysRunToEnd(bool);
94 void setCurrentTime(int);
96 QDeclarativeAnimationGroup *group() const;
97 void setGroup(QDeclarativeAnimationGroup *);
99 void setDefaultTarget(const QDeclarativeProperty &);
100 void setDisableUserControl();
103 void componentComplete();
108 void runningChanged(bool);
109 void pausedChanged(bool);
110 void alwaysRunToEndChanged(bool);
111 void loopCountChanged(int);
122 QDeclarativeAbstractAnimation(QDeclarativeAbstractAnimationPrivate &dd, QObject *parent);
125 enum TransitionDirection { Forward, Backward };
126 virtual void transition(QDeclarativeStateActions &actions,
127 QDeclarativeProperties &modified,
128 TransitionDirection direction);
129 virtual QAbstractAnimation *qtAnimation() = 0;
132 void timelineComplete();
133 void componentFinalized();
135 virtual void setTarget(const QDeclarativeProperty &);
136 void notifyRunningChanged(bool running);
137 friend class QDeclarativeBehavior;
142 class QDeclarativePauseAnimationPrivate;
143 class Q_AUTOTEST_EXPORT QDeclarativePauseAnimation : public QDeclarativeAbstractAnimation
146 Q_DECLARE_PRIVATE(QDeclarativePauseAnimation)
148 Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
151 QDeclarativePauseAnimation(QObject *parent=0);
152 virtual ~QDeclarativePauseAnimation();
154 int duration() const;
155 void setDuration(int);
158 void durationChanged(int);
161 virtual QAbstractAnimation *qtAnimation();
164 class QDeclarativeScriptActionPrivate;
165 class Q_QUICK_PRIVATE_EXPORT QDeclarativeScriptAction : public QDeclarativeAbstractAnimation
168 Q_DECLARE_PRIVATE(QDeclarativeScriptAction)
170 Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
171 Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
174 QDeclarativeScriptAction(QObject *parent=0);
175 virtual ~QDeclarativeScriptAction();
177 QDeclarativeScriptString script() const;
178 void setScript(const QDeclarativeScriptString &);
180 QString stateChangeScriptName() const;
181 void setStateChangeScriptName(const QString &);
184 virtual void transition(QDeclarativeStateActions &actions,
185 QDeclarativeProperties &modified,
186 TransitionDirection direction);
187 virtual QAbstractAnimation *qtAnimation();
190 class QDeclarativePropertyActionPrivate;
191 class QDeclarativePropertyAction : public QDeclarativeAbstractAnimation
194 Q_DECLARE_PRIVATE(QDeclarativePropertyAction)
196 Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
197 Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
198 Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
199 Q_PROPERTY(QDeclarativeListProperty<QObject> targets READ targets)
200 Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude)
201 Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
204 QDeclarativePropertyAction(QObject *parent=0);
205 virtual ~QDeclarativePropertyAction();
207 QObject *target() const;
208 void setTarget(QObject *);
210 QString property() const;
211 void setProperty(const QString &);
213 QString properties() const;
214 void setProperties(const QString &);
216 QDeclarativeListProperty<QObject> targets();
217 QDeclarativeListProperty<QObject> exclude();
219 QVariant value() const;
220 void setValue(const QVariant &);
223 void valueChanged(const QVariant &);
224 void propertiesChanged(const QString &);
225 void targetChanged();
226 void propertyChanged();
229 virtual void transition(QDeclarativeStateActions &actions,
230 QDeclarativeProperties &modified,
231 TransitionDirection direction);
232 virtual QAbstractAnimation *qtAnimation();
235 class QDeclarativePropertyAnimationPrivate;
236 class Q_AUTOTEST_EXPORT QDeclarativePropertyAnimation : public QDeclarativeAbstractAnimation
239 Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
241 Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
242 Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
243 Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
244 Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
245 Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
246 Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
247 Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
248 Q_PROPERTY(QDeclarativeListProperty<QObject> targets READ targets)
249 Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude)
252 QDeclarativePropertyAnimation(QObject *parent=0);
253 virtual ~QDeclarativePropertyAnimation();
255 virtual int duration() const;
256 virtual void setDuration(int);
258 QVariant from() const;
259 void setFrom(const QVariant &);
262 void setTo(const QVariant &);
264 QEasingCurve easing() const;
265 void setEasing(const QEasingCurve &);
267 QObject *target() const;
268 void setTarget(QObject *);
270 QString property() const;
271 void setProperty(const QString &);
273 QString properties() const;
274 void setProperties(const QString &);
276 QDeclarativeListProperty<QObject> targets();
277 QDeclarativeListProperty<QObject> exclude();
280 QDeclarativePropertyAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent);
281 virtual void transition(QDeclarativeStateActions &actions,
282 QDeclarativeProperties &modified,
283 TransitionDirection direction);
284 virtual QAbstractAnimation *qtAnimation();
287 void durationChanged(int);
288 void fromChanged(QVariant);
289 void toChanged(QVariant);
290 void easingChanged(const QEasingCurve &);
291 void propertiesChanged(const QString &);
292 void targetChanged();
293 void propertyChanged();
296 class Q_AUTOTEST_EXPORT QDeclarativeColorAnimation : public QDeclarativePropertyAnimation
299 Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
300 Q_PROPERTY(QColor from READ from WRITE setFrom)
301 Q_PROPERTY(QColor to READ to WRITE setTo)
304 QDeclarativeColorAnimation(QObject *parent=0);
305 virtual ~QDeclarativeColorAnimation();
308 void setFrom(const QColor &);
311 void setTo(const QColor &);
314 class Q_AUTOTEST_EXPORT QDeclarativeNumberAnimation : public QDeclarativePropertyAnimation
317 Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
319 Q_PROPERTY(qreal from READ from WRITE setFrom)
320 Q_PROPERTY(qreal to READ to WRITE setTo)
323 QDeclarativeNumberAnimation(QObject *parent=0);
324 virtual ~QDeclarativeNumberAnimation();
333 QDeclarativeNumberAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent);
339 class Q_AUTOTEST_EXPORT QDeclarativeVector3dAnimation : public QDeclarativePropertyAnimation
342 Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
344 Q_PROPERTY(QVector3D from READ from WRITE setFrom)
345 Q_PROPERTY(QVector3D to READ to WRITE setTo)
348 QDeclarativeVector3dAnimation(QObject *parent=0);
349 virtual ~QDeclarativeVector3dAnimation();
351 QVector3D from() const;
352 void setFrom(QVector3D);
354 QVector3D to() const;
355 void setTo(QVector3D);
358 class QDeclarativeRotationAnimationPrivate;
359 class Q_AUTOTEST_EXPORT QDeclarativeRotationAnimation : public QDeclarativePropertyAnimation
362 Q_DECLARE_PRIVATE(QDeclarativeRotationAnimation)
363 Q_ENUMS(RotationDirection)
365 Q_PROPERTY(qreal from READ from WRITE setFrom)
366 Q_PROPERTY(qreal to READ to WRITE setTo)
367 Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
370 QDeclarativeRotationAnimation(QObject *parent=0);
371 virtual ~QDeclarativeRotationAnimation();
379 enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
380 RotationDirection direction() const;
381 void setDirection(RotationDirection direction);
384 void directionChanged();
387 class QDeclarativeAnimationGroupPrivate;
388 class Q_AUTOTEST_EXPORT QDeclarativeAnimationGroup : public QDeclarativeAbstractAnimation
391 Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup)
393 Q_CLASSINFO("DefaultProperty", "animations")
394 Q_PROPERTY(QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations READ animations)
397 QDeclarativeAnimationGroup(QObject *parent);
398 virtual ~QDeclarativeAnimationGroup();
400 QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations();
401 friend class QDeclarativeAbstractAnimation;
404 QDeclarativeAnimationGroup(QDeclarativeAnimationGroupPrivate &dd, QObject *parent);
407 class QDeclarativeSequentialAnimation : public QDeclarativeAnimationGroup
410 Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup)
413 QDeclarativeSequentialAnimation(QObject *parent=0);
414 virtual ~QDeclarativeSequentialAnimation();
417 virtual void transition(QDeclarativeStateActions &actions,
418 QDeclarativeProperties &modified,
419 TransitionDirection direction);
420 virtual QAbstractAnimation *qtAnimation();
423 class QDeclarativeParallelAnimation : public QDeclarativeAnimationGroup
426 Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup)
429 QDeclarativeParallelAnimation(QObject *parent=0);
430 virtual ~QDeclarativeParallelAnimation();
433 virtual void transition(QDeclarativeStateActions &actions,
434 QDeclarativeProperties &modified,
435 TransitionDirection direction);
436 virtual QAbstractAnimation *qtAnimation();
442 QML_DECLARE_TYPE(QDeclarativeAbstractAnimation)
443 QML_DECLARE_TYPE(QDeclarativePauseAnimation)
444 QML_DECLARE_TYPE(QDeclarativeScriptAction)
445 QML_DECLARE_TYPE(QDeclarativePropertyAction)
446 QML_DECLARE_TYPE(QDeclarativePropertyAnimation)
447 QML_DECLARE_TYPE(QDeclarativeColorAnimation)
448 QML_DECLARE_TYPE(QDeclarativeNumberAnimation)
449 QML_DECLARE_TYPE(QDeclarativeSequentialAnimation)
450 QML_DECLARE_TYPE(QDeclarativeParallelAnimation)
451 QML_DECLARE_TYPE(QDeclarativeVector3dAnimation)
452 QML_DECLARE_TYPE(QDeclarativeRotationAnimation)
456 #endif // QDECLARATIVEANIMATION_H