QtCore/qabstractanimation.h Source File

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 
59 class QAbstractAnimationPrivate;
60 class Q_CORE_EXPORT QAbstractAnimation : public QObject
61 {
62  Q_OBJECT
63  Q_ENUMS(State)
65  Q_PROPERTY(State state READ state NOTIFY stateChanged)
66  Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount)
67  Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime)
68  Q_PROPERTY(int currentLoop READ currentLoop NOTIFY currentLoopChanged)
69  Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged)
70  Q_PROPERTY(int duration READ 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:
124  QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent = 0);
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:
132  Q_DISABLE_COPY(QAbstractAnimation)
133  Q_DECLARE_PRIVATE(QAbstractAnimation)
134 };
135 
136 class QAnimationDriverPrivate;
137 class Q_CORE_EXPORT QAnimationDriver : public QObject
138 {
139  Q_OBJECT
140  Q_DECLARE_PRIVATE(QAnimationDriver)
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 
154  QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = 0);
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
Definition: qglobal.h:128
#define Q_PROPERTY(text)
Definition: qobjectdefs.h:80
GLuint start
Definition: GLee.h:872
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
virtual void started()
State
The state the media producing object is in at the moment.
#define Q_SLOTS
Definition: qobjectdefs.h:71
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
virtual void stopped()
#define Q_OBJECT
Definition: qobjectdefs.h:157
virtual bool event(QEvent *)
#define QT_END_HEADER
Definition: qglobal.h:142