Qt 4.8
qabstractanimation.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 QtCore 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 QABSTRACTANIMATION_H
43 #define QABSTRACTANIMATION_H
44 
45 #include <QtCore/qobject.h>
46 
48 
50 
51 QT_MODULE(Core)
52 
53 #ifndef QT_NO_ANIMATION
54 
55 class QAnimationGroup;
57 class QAnimationDriver;
58 
61 {
62  Q_OBJECT
63  Q_ENUMS(State)
65  State state;
66  int loopCount;
67  int currentTime;
68  int currentLoop;
70  int duration;
71 
72 public:
73  enum Direction {
75  Backward
76  };
77 
78  enum State {
81  Running
82  };
83 
85  KeepWhenStopped = 0,
86  DeleteWhenStopped
87  };
88 
89  QAbstractAnimation(QObject *parent = 0);
90  virtual ~QAbstractAnimation();
91 
92  State state() const;
93 
94  QAnimationGroup *group() const;
95 
96  Direction direction() const;
97  void setDirection(Direction direction);
98 
99  int currentTime() const;
100  int currentLoopTime() const;
101 
102  int loopCount() const;
103  void setLoopCount(int loopCount);
104  int currentLoop() const;
105 
106  virtual int duration() const = 0;
107  int totalDuration() const;
108 
109 Q_SIGNALS:
110  void finished();
111  void stateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
112  void currentLoopChanged(int currentLoop);
113  void directionChanged(QAbstractAnimation::Direction);
114 
115 public Q_SLOTS:
116  void start(QAbstractAnimation::DeletionPolicy policy = KeepWhenStopped);
117  void pause();
118  void resume();
119  void setPaused(bool);
120  void stop();
121  void setCurrentTime(int msecs);
122 
123 protected:
125  bool event(QEvent *event);
126 
127  virtual void updateCurrentTime(int currentTime) = 0;
128  virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
129  virtual void updateDirection(QAbstractAnimation::Direction direction);
130 
131 private:
134 };
135 
138 {
139  Q_OBJECT
141 
142 public:
143  QAnimationDriver(QObject *parent = 0);
144 
145  void advance();
146  void install();
147 
148  bool isRunning() const;
149 
150 protected:
151  virtual void started() {};
152  virtual void stopped() {};
153 
155 
156 private:
157  friend class QUnifiedTimer;
158 
159  void start();
160  void stop();
161 };
162 
163 
164 
165 
166 #endif //QT_NO_ANIMATION
167 
169 
171 
172 #endif // QABSTRACTANIMATION_H
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
State
This enum describes the state of the animation.
EventRef event
#define QT_MODULE(x)
Definition: qglobal.h:2783
virtual void started()
This function is called by the animation framework to notify the driver that it should start running...
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
The QSequentialAnimationGroup class provides a sequential group of animations.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Direction
This enum describes the direction of the animation when in Running state.
virtual void stopped()
This function is called by the animation framework to notify the driver that it should stop running...
The State element defines configurations of objects and properties.
The QAbstractAnimation class is the base of all animations.
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define Q_CORE_EXPORT
Definition: qglobal.h:1449
The QAnimationDriver class is used to exchange the mechanism that drives animations.
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QAnimationGroup class is an abstract base class for groups of animations.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
Qt::LayoutDirection direction