Qt 4.8
qdeclarativeanimation_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative 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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QDECLARATIVEANIMATION_H
43 #define QDECLARATIVEANIMATION_H
44 
45 #include "private/qdeclarativetransition_p.h"
46 #include "private/qdeclarativestate_p.h"
47 #include <QtGui/qvector3d.h>
48 
50 #include <qdeclarative.h>
52 
53 #include <QtCore/qvariant.h>
54 #include <QtCore/qeasingcurve.h>
55 #include <QtCore/QAbstractAnimation>
56 #include <QtGui/qcolor.h>
57 
59 
61 
62 QT_MODULE(Declarative)
63 
67 {
68  Q_OBJECT
70 
73  Q_ENUMS(Loops)
74  bool running;
75  bool paused;
76  bool alwaysRunToEnd;
77  int loops;
78  Q_CLASSINFO("DefaultMethod", "start()")
79 
80 public:
83 
84  enum Loops { Infinite = -2 };
85 
86  bool isRunning() const;
87  void setRunning(bool);
88  bool isPaused() const;
89  void setPaused(bool);
90  bool alwaysRunToEnd() const;
91  void setAlwaysRunToEnd(bool);
92 
93  int loops() const;
94  void setLoops(int);
95 
96  int currentTime();
97  void setCurrentTime(int);
98 
99  QDeclarativeAnimationGroup *group() const;
100  void setGroup(QDeclarativeAnimationGroup *);
101 
102  void setDefaultTarget(const QDeclarativeProperty &);
103  void setDisableUserControl();
104 
105  void classBegin();
106  void componentComplete();
107 
108 Q_SIGNALS:
109  void started();
110  void completed();
111  void runningChanged(bool);
112  void pausedChanged(bool);
113  void alwaysRunToEndChanged(bool);
114  void loopCountChanged(int);
115 
116 public Q_SLOTS:
117  void restart();
118  void start();
119  void pause();
120  void resume();
121  void stop();
122  void complete();
123 
124 protected:
126 
127 public:
128  enum TransitionDirection { Forward, Backward };
129  virtual void transition(QDeclarativeStateActions &actions,
130  QDeclarativeProperties &modified,
132  virtual QAbstractAnimation *qtAnimation() = 0;
133 
134 private Q_SLOTS:
135  void timelineComplete();
136  void componentFinalized();
137 private:
138  virtual void setTarget(const QDeclarativeProperty &);
139  void notifyRunningChanged(bool running);
140  friend class QDeclarativeBehavior;
141 
142 
143 };
144 
147 {
148  Q_OBJECT
150 
151  int duration;
152 
153 public:
155  virtual ~QDeclarativePauseAnimation();
156 
157  int duration() const;
158  void setDuration(int);
159 
160 Q_SIGNALS:
161  void durationChanged(int);
162 
163 protected:
164  virtual QAbstractAnimation *qtAnimation();
165 };
166 
169 {
170  Q_OBJECT
172 
174  QString scriptName;
175 
176 public:
178  virtual ~QDeclarativeScriptAction();
179 
180  QDeclarativeScriptString script() const;
181  void setScript(const QDeclarativeScriptString &);
182 
183  QString stateChangeScriptName() const;
184  void setStateChangeScriptName(const QString &);
185 
186 protected:
187  virtual void transition(QDeclarativeStateActions &actions,
188  QDeclarativeProperties &modified,
190  virtual QAbstractAnimation *qtAnimation();
191 };
192 
194 class QDeclarativePropertyAction : public QDeclarativeAbstractAnimation
195 {
196  Q_OBJECT
198 
199  QObject *target;
200  QString property;
201  QString properties;
204  QVariant value;
205 
206 public:
208  virtual ~QDeclarativePropertyAction();
209 
210  QObject *target() const;
211  void setTarget(QObject *);
212 
213  QString property() const;
214  void setProperty(const QString &);
215 
216  QString properties() const;
217  void setProperties(const QString &);
218 
219  QDeclarativeListProperty<QObject> targets();
220  QDeclarativeListProperty<QObject> exclude();
221 
222  QVariant value() const;
223  void setValue(const QVariant &);
224 
225 Q_SIGNALS:
226  void valueChanged(const QVariant &);
227  void propertiesChanged(const QString &);
228  void targetChanged();
229  void propertyChanged();
230 
231 protected:
232  virtual void transition(QDeclarativeStateActions &actions,
233  QDeclarativeProperties &modified,
234  TransitionDirection direction);
235  virtual QAbstractAnimation *qtAnimation();
236 };
237 
240 class Q_AUTOTEST_EXPORT QDeclarativePropertyAnimation : public QDeclarativeAbstractAnimation
241 {
242  Q_OBJECT
244 
245  int duration;
246  QVariant from;
247  QVariant to;
248  QEasingCurve easing;
249  QObject *target;
250  QString property;
251  QString properties;
252  QDeclarativeListProperty<QObject> targets;
253  QDeclarativeListProperty<QObject> exclude;
254 
255 public:
256  QDeclarativePropertyAnimation(QObject *parent=0);
258 
259  virtual int duration() const;
260  virtual void setDuration(int);
261 
262  QVariant from() const;
263  void setFrom(const QVariant &);
264 
265  QVariant to() const;
266  void setTo(const QVariant &);
267 
268  QEasingCurve easing() const;
269  void setEasing(const QEasingCurve &);
270 
271  QObject *target() const;
272  void setTarget(QObject *);
273 
274  QString property() const;
275  void setProperty(const QString &);
276 
277  QString properties() const;
278  void setProperties(const QString &);
279 
280  QDeclarativeListProperty<QObject> targets();
281  QDeclarativeListProperty<QObject> exclude();
282 
283 protected:
284  QDeclarativePropertyAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent);
285  virtual void transition(QDeclarativeStateActions &actions,
286  QDeclarativeProperties &modified,
287  TransitionDirection direction);
288  virtual QAbstractAnimation *qtAnimation();
289 
290 Q_SIGNALS:
291  void durationChanged(int);
292  void fromChanged(QVariant);
293  void toChanged(QVariant);
294  void easingChanged(const QEasingCurve &);
295  void propertiesChanged(const QString &);
296  void targetChanged();
297  void propertyChanged();
298 };
299 
300 class Q_AUTOTEST_EXPORT QDeclarativeColorAnimation : public QDeclarativePropertyAnimation
301 {
302  Q_OBJECT
303  Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
304  QColor from;
305  QColor to;
306 
307 public:
308  QDeclarativeColorAnimation(QObject *parent=0);
309  virtual ~QDeclarativeColorAnimation();
310 
311  QColor from() const;
312  void setFrom(const QColor &);
313 
314  QColor to() const;
315  void setTo(const QColor &);
316 };
317 
318 class Q_AUTOTEST_EXPORT QDeclarativeNumberAnimation : public QDeclarativePropertyAnimation
319 {
320  Q_OBJECT
321  Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
322 
323  qreal from;
324  qreal to;
325 
326 public:
327  QDeclarativeNumberAnimation(QObject *parent=0);
328  virtual ~QDeclarativeNumberAnimation();
329 
330  qreal from() const;
331  void setFrom(qreal);
332 
333  qreal to() const;
334  void setTo(qreal);
335 
336 protected:
337  QDeclarativeNumberAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent);
338 
339 private:
340  void init();
341 };
342 
343 class Q_AUTOTEST_EXPORT QDeclarativeVector3dAnimation : public QDeclarativePropertyAnimation
344 {
345  Q_OBJECT
346  Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
347 
348  QVector3D from;
350 
351 public:
352  QDeclarativeVector3dAnimation(QObject *parent=0);
354 
355  QVector3D from() const;
356  void setFrom(QVector3D);
357 
358  QVector3D to() const;
359  void setTo(QVector3D);
360 };
361 
363 class Q_AUTOTEST_EXPORT QDeclarativeRotationAnimation : public QDeclarativePropertyAnimation
364 {
365  Q_OBJECT
368 
369  qreal from;
370  qreal to;
371  RotationDirection direction;
372 
373 public:
374  QDeclarativeRotationAnimation(QObject *parent=0);
376 
377  qreal from() const;
378  void setFrom(qreal);
379 
380  qreal to() const;
381  void setTo(qreal);
382 
383  enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
385  void setDirection(RotationDirection direction);
386 
387 Q_SIGNALS:
388  void directionChanged();
389 };
390 
393 {
394  Q_OBJECT
396 
397  Q_CLASSINFO("DefaultProperty", "animations")
399 
400 public:
402  virtual ~QDeclarativeAnimationGroup();
403 
406 
407 protected:
408  QDeclarativeAnimationGroup(QDeclarativeAnimationGroupPrivate &dd, QObject *parent);
409 };
410 
411 class QDeclarativeSequentialAnimation : public QDeclarativeAnimationGroup
412 {
413  Q_OBJECT
414  Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup)
415 
416 public:
419 
420 protected:
421  virtual void transition(QDeclarativeStateActions &actions,
422  QDeclarativeProperties &modified,
424  virtual QAbstractAnimation *qtAnimation();
425 };
426 
428 {
429  Q_OBJECT
431 
432 public:
435 
436 protected:
437  virtual void transition(QDeclarativeStateActions &actions,
438  QDeclarativeProperties &modified,
440  virtual QAbstractAnimation *qtAnimation();
441 };
442 
445 {
446  Q_OBJECT
448 
450  QDeclarativeItem *newParent;
452 
453 public:
455  virtual ~QDeclarativeParentAnimation();
456 
457  QDeclarativeItem *target() const;
458  void setTarget(QDeclarativeItem *);
459 
460  QDeclarativeItem *newParent() const;
461  void setNewParent(QDeclarativeItem *);
462 
463  QDeclarativeItem *via() const;
464  void setVia(QDeclarativeItem *);
465 
466 Q_SIGNALS:
467  void targetChanged();
468  void newParentChanged();
469  void viaChanged();
470 
471 protected:
472  virtual void transition(QDeclarativeStateActions &actions,
473  QDeclarativeProperties &modified,
475  virtual QAbstractAnimation *qtAnimation();
476 };
477 
480 {
481  Q_OBJECT
483  QDeclarativeListProperty<QDeclarativeItem> targets;
484  int duration;
485  QEasingCurve easing;
486 
487 public:
489  virtual ~QDeclarativeAnchorAnimation();
490 
491  QDeclarativeListProperty<QDeclarativeItem> targets();
492 
493  int duration() const;
494  void setDuration(int);
495 
496  QEasingCurve easing() const;
497  void setEasing(const QEasingCurve &);
498 
499 Q_SIGNALS:
500  void durationChanged(int);
501  void easingChanged(const QEasingCurve&);
502 
503 protected:
504  virtual void transition(QDeclarativeStateActions &actions,
505  QDeclarativeProperties &modified,
506  TransitionDirection direction);
507  virtual QAbstractAnimation *qtAnimation();
508 };
509 
511 
512 QML_DECLARE_TYPE(QDeclarativeAbstractAnimation)
523 QML_DECLARE_TYPE(QDeclarativeParentAnimation)
524 QML_DECLARE_TYPE(QDeclarativeAnchorAnimation)
525 
527 
528 #endif // QDECLARATIVEANIMATION_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QVector3D class represents a vector or vertex in 3D space.
Definition: qvector3d.h:60
#define Q_CLASSINFO(name, value)
This macro associates extra information to the class, which is available using QObject::metaObject()...
Definition: qobjectdefs.h:78
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
The QEasingCurve class provides easing curves for controlling animation.
Definition: qeasingcurve.h:55
#define QML_DECLARE_TYPE(TYPE)
Definition: qdeclarative.h:56
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Infinite(x)
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
virtual void componentComplete()=0
Invoked after the root component that caused this instantiation has completed construction.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QDeclarativeScriptString class encapsulates a script and its context.
The QDeclarativeItem class provides the most basic of all visual items in QML.
static bool init
The QDeclarativeParserStatus class provides updates on the QML parser state.
The QAbstractAnimation class is the base of all animations.
#define Q_DECLARATIVE_PRIVATE_EXPORT
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
#define Q_OBJECT
Definition: qobjectdefs.h:157
virtual void classBegin()=0
Invoked after class creation, but before any properties have been set.
#define Q_INTERFACES(x)
This macro tells Qt which interfaces the class implements.
Definition: qobjectdefs.h:79
const char * property
Definition: qwizard.cpp:138
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
static const QCssKnownValue properties[NumProperties - 1]
Definition: qcssparser.cpp:67
virtual void setTarget(const QDeclarativeProperty &)=0
Set the target property for the value source.
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QDeclarativePropertyValueSource class is an interface for property value sources such as animatio...
#define class
#define QT_END_HEADER
Definition: qglobal.h:137
#define private
Definition: qregion_qws.cpp:43
The QDeclarativeListProperty class allows applications to expose list-like properties to QML...
Qt::LayoutDirection direction