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 QtQml 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 QQUICKANIMATION_H
43 #define QQUICKANIMATION_H
45 #include "qquickstate_p.h"
46 #include <QtGui/qvector3d.h>
48 #include <qqmlpropertyvaluesource.h>
50 #include <qqmlscriptstring.h>
52 #include <QtCore/qvariant.h>
53 #include <QtCore/qeasingcurve.h>
54 #include "private/qabstractanimationjob_p.h"
55 #include <QtGui/qcolor.h>
61 class QQuickAbstractAnimationPrivate;
62 class QQuickAnimationGroup;
63 class Q_QUICK_PRIVATE_EXPORT QQuickAbstractAnimation : public QObject, public QQmlPropertyValueSource, public QQmlParserStatus
66 Q_DECLARE_PRIVATE(QQuickAbstractAnimation)
68 Q_INTERFACES(QQmlParserStatus)
69 Q_INTERFACES(QQmlPropertyValueSource)
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 QQuickAbstractAnimation(QObject *parent=0);
79 virtual ~QQuickAbstractAnimation();
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);
95 void setCurrentTime(int);
97 QQuickAnimationGroup *group() const;
98 void setGroup(QQuickAnimationGroup *);
100 void setDefaultTarget(const QQmlProperty &);
101 void setDisableUserControl();
102 void setEnableUserControl();
103 bool userControlDisabled() const;
105 void componentComplete();
110 void runningChanged(bool);
111 void pausedChanged(bool);
112 void alwaysRunToEndChanged(bool);
113 void loopCountChanged(int);
124 QQuickAbstractAnimation(QQuickAbstractAnimationPrivate &dd, QObject *parent);
125 QAbstractAnimationJob* initInstance(QAbstractAnimationJob *animation);
128 enum TransitionDirection { Forward, Backward };
129 virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
130 QQmlProperties &modified,
131 TransitionDirection direction,
132 QObject *defaultTarget = 0);
133 QAbstractAnimationJob* qtAnimation();
136 void componentFinalized();
138 virtual void setTarget(const QQmlProperty &);
139 void notifyRunningChanged(bool running);
140 friend class QQuickBehavior;
141 friend class QQuickBehaviorPrivate;
144 class QQuickPauseAnimationPrivate;
145 class Q_QUICK_PRIVATE_EXPORT QQuickPauseAnimation : public QQuickAbstractAnimation
148 Q_DECLARE_PRIVATE(QQuickPauseAnimation)
150 Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
153 QQuickPauseAnimation(QObject *parent=0);
154 virtual ~QQuickPauseAnimation();
156 int duration() const;
157 void setDuration(int);
160 void durationChanged(int);
163 QAbstractAnimationJob* transition(QQuickStateActions &actions,
164 QQmlProperties &modified,
165 TransitionDirection direction,
166 QObject *defaultTarget = 0);
169 class QQuickScriptActionPrivate;
170 class QQuickScriptAction : public QQuickAbstractAnimation
173 Q_DECLARE_PRIVATE(QQuickScriptAction)
175 Q_PROPERTY(QQmlScriptString script READ script WRITE setScript)
176 Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
179 QQuickScriptAction(QObject *parent=0);
180 virtual ~QQuickScriptAction();
182 QQmlScriptString script() const;
183 void setScript(const QQmlScriptString &);
185 QString stateChangeScriptName() const;
186 void setStateChangeScriptName(const QString &);
189 virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
190 QQmlProperties &modified,
191 TransitionDirection direction,
192 QObject *defaultTarget = 0);
195 class QQuickPropertyActionPrivate;
196 class QQuickPropertyAction : public QQuickAbstractAnimation
199 Q_DECLARE_PRIVATE(QQuickPropertyAction)
201 Q_PROPERTY(QObject *target READ target WRITE setTargetObject NOTIFY targetChanged)
202 Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
203 Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
204 Q_PROPERTY(QQmlListProperty<QObject> targets READ targets)
205 Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude)
206 Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
209 QQuickPropertyAction(QObject *parent=0);
210 virtual ~QQuickPropertyAction();
212 QObject *target() const;
213 void setTargetObject(QObject *);
215 QString property() const;
216 void setProperty(const QString &);
218 QString properties() const;
219 void setProperties(const QString &);
221 QQmlListProperty<QObject> targets();
222 QQmlListProperty<QObject> exclude();
224 QVariant value() const;
225 void setValue(const QVariant &);
228 void valueChanged(const QVariant &);
229 void propertiesChanged(const QString &);
230 void targetChanged();
231 void propertyChanged();
234 virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
235 QQmlProperties &modified,
236 TransitionDirection direction,
237 QObject *defaultTarget = 0);
240 class QQuickPropertyAnimationPrivate;
241 class Q_QUICK_PRIVATE_EXPORT QQuickPropertyAnimation : public QQuickAbstractAnimation
244 Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
246 Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
247 Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
248 Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
249 Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
250 Q_PROPERTY(QObject *target READ target WRITE setTargetObject NOTIFY targetChanged)
251 Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
252 Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
253 Q_PROPERTY(QQmlListProperty<QObject> targets READ targets)
254 Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude)
257 QQuickPropertyAnimation(QObject *parent=0);
258 virtual ~QQuickPropertyAnimation();
260 virtual int duration() const;
261 virtual void setDuration(int);
263 QVariant from() const;
264 void setFrom(const QVariant &);
267 void setTo(const QVariant &);
269 QEasingCurve easing() const;
270 void setEasing(const QEasingCurve &);
272 QObject *target() const;
273 void setTargetObject(QObject *);
275 QString property() const;
276 void setProperty(const QString &);
278 QString properties() const;
279 void setProperties(const QString &);
281 QQmlListProperty<QObject> targets();
282 QQmlListProperty<QObject> exclude();
285 QQuickStateActions createTransitionActions(QQuickStateActions &actions,
286 QQmlProperties &modified,
287 QObject *defaultTarget = 0);
289 QQuickPropertyAnimation(QQuickPropertyAnimationPrivate &dd, QObject *parent);
290 virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
291 QQmlProperties &modified,
292 TransitionDirection direction,
293 QObject *defaultTarget = 0);
295 void durationChanged(int);
296 void fromChanged(QVariant);
297 void toChanged(QVariant);
298 void easingChanged(const QEasingCurve &);
299 void propertiesChanged(const QString &);
300 void targetChanged();
301 void propertyChanged();
304 class Q_QUICK_PRIVATE_EXPORT QQuickColorAnimation : public QQuickPropertyAnimation
307 Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
308 Q_PROPERTY(QColor from READ from WRITE setFrom)
309 Q_PROPERTY(QColor to READ to WRITE setTo)
312 QQuickColorAnimation(QObject *parent=0);
313 virtual ~QQuickColorAnimation();
316 void setFrom(const QColor &);
319 void setTo(const QColor &);
322 class Q_QUICK_PRIVATE_EXPORT QQuickNumberAnimation : public QQuickPropertyAnimation
325 Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
327 Q_PROPERTY(qreal from READ from WRITE setFrom)
328 Q_PROPERTY(qreal to READ to WRITE setTo)
331 QQuickNumberAnimation(QObject *parent=0);
332 virtual ~QQuickNumberAnimation();
341 QQuickNumberAnimation(QQuickPropertyAnimationPrivate &dd, QObject *parent);
347 class Q_QUICK_PRIVATE_EXPORT QQuickVector3dAnimation : public QQuickPropertyAnimation
350 Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
352 Q_PROPERTY(QVector3D from READ from WRITE setFrom)
353 Q_PROPERTY(QVector3D to READ to WRITE setTo)
356 QQuickVector3dAnimation(QObject *parent=0);
357 virtual ~QQuickVector3dAnimation();
359 QVector3D from() const;
360 void setFrom(QVector3D);
362 QVector3D to() const;
363 void setTo(QVector3D);
366 class QQuickRotationAnimationPrivate;
367 class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimation : public QQuickPropertyAnimation
370 Q_DECLARE_PRIVATE(QQuickRotationAnimation)
371 Q_ENUMS(RotationDirection)
373 Q_PROPERTY(qreal from READ from WRITE setFrom)
374 Q_PROPERTY(qreal to READ to WRITE setTo)
375 Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
378 QQuickRotationAnimation(QObject *parent=0);
379 virtual ~QQuickRotationAnimation();
387 enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
388 RotationDirection direction() const;
389 void setDirection(RotationDirection direction);
392 void directionChanged();
395 class QQuickAnimationGroupPrivate;
396 class Q_QUICK_PRIVATE_EXPORT QQuickAnimationGroup : public QQuickAbstractAnimation
399 Q_DECLARE_PRIVATE(QQuickAnimationGroup)
401 Q_CLASSINFO("DefaultProperty", "animations")
402 Q_PROPERTY(QQmlListProperty<QQuickAbstractAnimation> animations READ animations)
405 QQuickAnimationGroup(QObject *parent);
406 virtual ~QQuickAnimationGroup();
408 QQmlListProperty<QQuickAbstractAnimation> animations();
409 friend class QQuickAbstractAnimation;
412 QQuickAnimationGroup(QQuickAnimationGroupPrivate &dd, QObject *parent);
415 class QQuickSequentialAnimation : public QQuickAnimationGroup
418 Q_DECLARE_PRIVATE(QQuickAnimationGroup)
421 QQuickSequentialAnimation(QObject *parent=0);
422 virtual ~QQuickSequentialAnimation();
425 virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
426 QQmlProperties &modified,
427 TransitionDirection direction,
428 QObject *defaultTarget = 0);
431 class Q_QUICK_PRIVATE_EXPORT QQuickParallelAnimation : public QQuickAnimationGroup
434 Q_DECLARE_PRIVATE(QQuickAnimationGroup)
437 QQuickParallelAnimation(QObject *parent=0);
438 virtual ~QQuickParallelAnimation();
441 virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
442 QQmlProperties &modified,
443 TransitionDirection direction,
444 QObject *defaultTarget = 0);
450 QML_DECLARE_TYPE(QQuickAbstractAnimation)
451 QML_DECLARE_TYPE(QQuickPauseAnimation)
452 QML_DECLARE_TYPE(QQuickScriptAction)
453 QML_DECLARE_TYPE(QQuickPropertyAction)
454 QML_DECLARE_TYPE(QQuickPropertyAnimation)
455 QML_DECLARE_TYPE(QQuickColorAnimation)
456 QML_DECLARE_TYPE(QQuickNumberAnimation)
457 QML_DECLARE_TYPE(QQuickSequentialAnimation)
458 QML_DECLARE_TYPE(QQuickParallelAnimation)
459 QML_DECLARE_TYPE(QQuickVector3dAnimation)
460 QML_DECLARE_TYPE(QQuickRotationAnimation)
464 #endif // QQUICKANIMATION_H