Qt 4.8
qabstractanimation_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 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_P_H
43 #define QABSTRACTANIMATION_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists for the convenience
50 // of QIODevice. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include <QtCore/qbasictimer.h>
57 #include <QtCore/qdatetime.h>
58 #include <QtCore/qtimer.h>
59 #include <QtCore/qelapsedtimer.h>
60 #include <private/qobject_p.h>
61 #include <qabstractanimation.h>
62 
63 #ifdef Q_OS_WIN
64 #include <qt_windows.h>
65 #endif
66 
67 #ifndef QT_NO_ANIMATION
68 
70 
71 class QAnimationGroup;
72 class QAbstractAnimation;
74 {
75 public:
77  : state(QAbstractAnimation::Stopped),
78  direction(QAbstractAnimation::Forward),
80  currentTime(0),
81  loopCount(1),
82  currentLoop(0),
83  deleteWhenStopped(false),
84  hasRegisteredTimer(false),
85  isPause(false),
86  isGroup(false),
87  group(0)
88  {
89  }
90 
92 
94  {
95  return q->d_func();
96  }
97 
101 
106 
109  bool isPause;
110  bool isGroup;
111 
113 
114 private:
116 };
117 
118 
119 class QUnifiedTimer;
121 {
122  Q_OBJECT
123 public:
125  void timerEvent(QTimerEvent *e);
126 
127  void started();
128  void stopped();
129 
130 private:
133 };
134 
136 {
137 public:
138  QAnimationDriverPrivate() : running(false) {}
139  bool running;
140 };
141 
143 
145 {
146 private:
147  QUnifiedTimer();
148 
149 public:
150  //XXX this is needed by dui
151  static QUnifiedTimer *instance();
152  static QUnifiedTimer *instance(bool create);
153 
154  static void registerAnimation(QAbstractAnimation *animation, bool isTopLevel);
155  static void unregisterAnimation(QAbstractAnimation *animation);
156 
157  //defines the timing interval. Default is DEFAULT_TIMER_INTERVAL
158  void setTimingInterval(int interval);
159 
160  /*
161  this allows to have a consistent timer interval at each tick from the timer
162  not taking the real time that passed into account.
163  */
164  void setConsistentTiming(bool consistent) { consistentTiming = consistent; }
165 
166  //these facilitate fine-tuning of complex animations
167  void setSlowModeEnabled(bool enabled) { slowMode = enabled; }
168  void setSlowdownFactor(qreal factor) { slowdownFactor = factor; }
169 
170  /*
171  this is used for updating the currentTime of all animations in case the pause
172  timer is active or, otherwise, only of the animation passed as parameter.
173  */
174  static void ensureTimerUpdate();
175 
176  /*
177  this will evaluate the need of restarting the pause timer in case there is still
178  some pause animations running.
179  */
180  static void updateAnimationTimer();
181 
182  void installAnimationDriver(QAnimationDriver *driver);
183 
184  void restartAnimationTimer();
185  void updateAnimationsTime();
186 
187  //useful for profiling/debugging
188  int runningAnimationCount() { return animations.count(); }
189 
190 protected:
191  void timerEvent(QTimerEvent *);
192 
193 private:
195 
198 
200  // timer used to delay the check if we should start/stop the animation timer
202 
204 
210  bool slowMode;
211 
212  // This factor will be used to divide the DEFAULT_TIMER_INTERVAL at each tick
213  // when slowMode is enabled. Setting it to 0 or higher than DEFAULT_TIMER_INTERVAL (16)
214  // stops all animations.
216 
217  // bool to indicate that only pause animations are active
219 
221 
222  // this is the count of running animations that are not a group neither a pause animation
225 
226  void registerRunningAnimation(QAbstractAnimation *animation);
227  void unregisterRunningAnimation(QAbstractAnimation *animation);
228 
229  int closestPauseAnimationTimeToFinish();
230 };
231 
233 
234 #endif //QT_NO_ANIMATION
235 
236 #endif //QABSTRACTANIMATION_P_H
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
State
This enum describes the state of the animation.
QDefaultAnimationDriver defaultDriver
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
EventLoopTimerRef timer
QAnimationDriver * driver
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
The QElapsedTimer class provides a fast way to calculate elapsed times.
Definition: qelapsedtimer.h:53
QBasicTimer animationTimer
QAbstractAnimation::Direction direction
void setState(QAbstractAnimation::State state)
QAbstractAnimation::State state
#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.
QList< QAbstractAnimation * > animationsToStart
QBasicTimer startStopAnimationTimer
void setSlowdownFactor(qreal factor)
__int64 qint64
Definition: qglobal.h:942
The QAbstractAnimation class is the base of all animations.
#define Q_OBJECT
Definition: qobjectdefs.h:157
void setConsistentTiming(bool consistent)
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
#define Q_CORE_EXPORT
Definition: qglobal.h:1449
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
QElapsedTimer ElapsedTimer
The QAnimationDriver class is used to exchange the mechanism that drives animations.
The QBasicTimer class provides timer events for objects.
Definition: qbasictimer.h:55
The QAnimationGroup class is an abstract base class for groups of animations.
QList< QAbstractAnimation * > runningPauseAnimations
#define enabled
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
void setSlowModeEnabled(bool enabled)