Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qabstractanimation_p.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QABSTRACTANIMATION_P_H
6
#
define
QABSTRACTANIMATION_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API.
13
// This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtCore
/
qbasictimer
.
h
>
20
#
include
<
QtCore
/
qdatetime
.
h
>
21
#
include
<
QtCore
/
qelapsedtimer
.
h
>
22
#
include
<
private
/
qobject_p
.
h
>
23
#
include
<
private
/
qproperty_p
.
h
>
24
#
include
<
qabstractanimation
.
h
>
25
26
#
if
defined
(
Q_OS_WASM
)
27
#
include
<
QtCore
/
private
/
qwasmanimationdriver_p
.
h
>
28
#
endif
29
30
QT_REQUIRE_CONFIG
(
animation
);
31
32
QT_BEGIN_NAMESPACE
33
34
class
QAnimationGroup;
35
class
QAbstractAnimation;
36
class
Q_CORE_EXPORT
QAbstractAnimationPrivate
:
public
QObjectPrivate
37
{
38
public
:
39
QAbstractAnimationPrivate();
40
virtual
~QAbstractAnimationPrivate();
41
42
static
QAbstractAnimationPrivate *get(QAbstractAnimation *q)
43
{
44
return
q->d_func();
45
}
46
47
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QAbstractAnimationPrivate, QAbstractAnimation::State,
48
state, QAbstractAnimation::Stopped)
49
void
setState(QAbstractAnimation::State state);
50
51
void
setDirection(QAbstractAnimation::Direction direction)
52
{
53
q_func()->setDirection(direction);
54
}
55
void
emitDirectionChanged() { Q_EMIT q_func()->directionChanged(direction); }
56
Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QAbstractAnimationPrivate, QAbstractAnimation::Direction,
57
direction, &QAbstractAnimationPrivate::setDirection,
58
&QAbstractAnimationPrivate::emitDirectionChanged,
59
QAbstractAnimation::Forward)
60
61
void
setCurrentTime(
int
msecs) { q_func()->setCurrentTime(msecs); }
62
Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QAbstractAnimationPrivate,
int
, totalCurrentTime,
63
&QAbstractAnimationPrivate::setCurrentTime, 0)
64
int
currentTime = 0;
65
66
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QAbstractAnimationPrivate,
int
, loopCount, 1)
67
68
void
emitCurrentLoopChanged() { Q_EMIT q_func()->currentLoopChanged(currentLoop); }
69
Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QAbstractAnimationPrivate,
int
, currentLoop,
nullptr
,
70
&QAbstractAnimationPrivate::emitCurrentLoopChanged, 0)
71
72
bool
deleteWhenStopped =
false
;
73
bool
hasRegisteredTimer =
false
;
74
bool
isPause =
false
;
75
bool
isGroup =
false
;
76
77
QAnimationGroup *group =
nullptr
;
78
79
private
:
80
Q_DECLARE_PUBLIC(QAbstractAnimation)
81
};
82
83
84
class
QUnifiedTimer;
85
class
QDefaultAnimationDriver
:
public
QAnimationDriver
86
{
87
Q_OBJECT
88
public
:
89
explicit
QDefaultAnimationDriver
(
QUnifiedTimer
*
timer
);
90
~
QDefaultAnimationDriver
()
override
;
91
92
protected
:
93
void
timerEvent
(QTimerEvent *e)
override
;
94
95
private
Q_SLOTS
:
96
void
startTimer
();
97
void
stopTimer();
98
99
private
:
100
QBasicTimer m_timer;
101
QUnifiedTimer *m_unified_timer;
102
};
103
104
class
Q_CORE_EXPORT
QAnimationDriverPrivate
:
public
QObjectPrivate
105
{
106
public
:
107
QAnimationDriverPrivate();
108
~QAnimationDriverPrivate() override;
109
110
QElapsedTimer timer;
111
bool
running =
false
;
112
};
113
114
class
Q_CORE_EXPORT
QAbstractAnimationTimer
:
public
QObject
115
{
116
Q_OBJECT
117
public
:
118
QAbstractAnimationTimer();
119
~QAbstractAnimationTimer() override;
120
121
virtual
void
updateAnimationsTime(qint64 delta) = 0;
122
virtual
void
restartAnimationTimer() = 0;
123
#
define
QT_QAbstractAnimationTimer_runningAnimationCount_IS_CONST
124
virtual
qsizetype runningAnimationCount()
const
= 0;
125
126
bool
isRegistered =
false
;
127
bool
isPaused =
false
;
128
int
pauseDuration = 0;
129
};
130
131
class
Q_CORE_EXPORT
QUnifiedTimer
:
public
QObject
132
{
133
Q_OBJECT
134
private
:
135
QUnifiedTimer();
136
137
public
:
138
~QUnifiedTimer() override;
139
140
static
QUnifiedTimer *instance();
141
static
QUnifiedTimer *instance(
bool
create);
142
143
static
void
startAnimationTimer(QAbstractAnimationTimer *timer);
144
static
void
stopAnimationTimer(QAbstractAnimationTimer *timer);
145
146
static
void
pauseAnimationTimer(QAbstractAnimationTimer *timer,
int
duration);
147
static
void
resumeAnimationTimer(QAbstractAnimationTimer *timer);
148
149
//defines the timing interval. Default is DEFAULT_TIMER_INTERVAL
150
void
setTimingInterval(
int
interval);
151
152
/*
153
this allows to have a consistent timer interval at each tick from the timer
154
not taking the real time that passed into account.
155
*/
156
void
setConsistentTiming(
bool
consistent) { consistentTiming = consistent; }
157
158
// This facilitates both fine-tuning of complex animations by slowing them
159
// them down, and reducing execution time of auto tests by speeding them up.
160
qreal getSpeedModifier()
const
{
return
speedModifier; }
161
void
setSpeedModifier(qreal speed) { speedModifier = speed; }
162
163
void
installAnimationDriver(QAnimationDriver *driver);
164
void
uninstallAnimationDriver(QAnimationDriver *driver);
165
bool
canUninstallAnimationDriver(QAnimationDriver *driver);
166
167
void
restart();
168
void
maybeUpdateAnimationsToCurrentTime();
169
void
updateAnimationTimers();
170
171
//useful for profiling/debugging
172
qsizetype runningAnimationCount()
const
;
173
void
registerProfilerCallback(
void
(*cb)(qint64));
174
175
void
startAnimationDriver();
176
void
stopAnimationDriver();
177
qint64 elapsed()
const
;
178
179
protected
:
180
void
timerEvent(QTimerEvent *) override;
181
182
private
Q_SLOTS:
183
void
startTimers();
184
void
stopTimer();
185
186
private
:
187
friend
class
QDefaultAnimationDriver;
188
friend
class
QAnimationDriver;
189
190
QAnimationDriver *driver;
191
#
if
defined
(
Q_OS_WASM
)
192
QWasmAnimationDriver defaultDriver;
193
#
else
194
QDefaultAnimationDriver defaultDriver;
195
#
endif
196
197
QBasicTimer pauseTimer;
198
199
QElapsedTimer time;
200
201
qint64 lastTick;
202
int
timingInterval;
203
int
currentAnimationIdx;
204
bool
insideTick;
205
bool
insideRestart;
206
bool
consistentTiming;
207
bool
startTimersPending;
208
bool
stopTimerPending;
209
bool
allowNegativeDelta;
210
211
// This factor will be used to multiply the DEFAULT_TIMER_INTERVAL (16) at each tick
212
// if it's not equal to 1. Setting it to less than 1 / 16 (0.0625) stops all animations.
213
qreal speedModifier;
214
215
QList<QAbstractAnimationTimer*> animationTimers, animationTimersToStart;
216
QList<QAbstractAnimationTimer*> pausedAnimationTimers;
217
218
void
localRestart();
219
int
closestPausedAnimationTimerTimeToFinish();
220
221
void
(*profilerCallback)(qint64);
222
223
qint64 driverStartTime;
// The time the animation driver was started
224
qint64 temporalDrift;
// The delta between animation driver time and wall time.
225
};
226
227
class
QAnimationTimer
:
public
QAbstractAnimationTimer
228
{
229
Q_OBJECT
230
private
:
231
QAnimationTimer
();
232
233
public
:
234
~
QAnimationTimer
()
override
;
235
236
static
QAnimationTimer
*
instance
();
237
static
QAnimationTimer
*
instance
(
bool
create);
238
239
static
void
registerAnimation
(QAbstractAnimation *animation,
bool
isTopLevel);
240
static
void
unregisterAnimation
(QAbstractAnimation *animation);
241
242
/*
243
this is used for updating the currentTime of all animations in case the pause
244
timer is active or, otherwise, only of the animation passed as parameter.
245
*/
246
static
void
ensureTimerUpdate
();
247
248
/*
249
this will evaluate the need of restarting the pause timer in case there is still
250
some pause animations running.
251
*/
252
static
void
updateAnimationTimer
();
253
254
void
restartAnimationTimer
()
override
;
255
void
updateAnimationsTime
(qint64 delta)
override
;
256
257
//useful for profiling/debugging
258
qsizetype
runningAnimationCount
()
const
override
{
return
animations.size(); }
259
260
private
Q_SLOTS
:
261
void
startAnimations
();
262
void
stopTimer();
263
264
private
:
265
qint64 lastTick;
266
int
currentAnimationIdx;
267
bool
insideTick;
268
bool
startAnimationPending;
269
bool
stopTimerPending;
270
271
QList<QAbstractAnimation*> animations, animationsToStart;
272
273
// this is the count of running animations that are not a group neither a pause animation
274
int
runningLeafAnimations;
275
QList<QAbstractAnimation*> runningPauseAnimations;
276
277
void
registerRunningAnimation(QAbstractAnimation *animation);
278
void
unregisterRunningAnimation(QAbstractAnimation *animation);
279
280
int
closestPauseAnimationTimeToFinish();
281
};
282
283
QT_END_NAMESPACE
284
285
#
endif
//QABSTRACTANIMATION_P_H
QAbstractAnimationPrivate
Definition
qabstractanimation_p.h:37
QAbstractAnimationTimer
\inmodule QtCore
Definition
qabstractanimation_p.h:115
QAbstractAnimation
\inmodule QtCore
Definition
qabstractanimation.h:21
QAnimationDriverPrivate
Definition
qabstractanimation_p.h:105
QAnimationDriver
\inmodule QtCore
Definition
qabstractanimation.h:108
QAnimationGroup
\inmodule QtCore
Definition
qanimationgroup.h:16
QAnimationTimer
Definition
qabstractanimation_p.h:228
QAnimationTimer::unregisterAnimation
static void unregisterAnimation(QAbstractAnimation *animation)
Definition
qabstractanimation.cpp:667
QAnimationTimer::runningAnimationCount
qsizetype runningAnimationCount() const override
Definition
qabstractanimation_p.h:258
QAnimationTimer::instance
static QAnimationTimer * instance(bool create)
Definition
qabstractanimation.cpp:552
QAnimationTimer::updateAnimationTimer
static void updateAnimationTimer()
Definition
qabstractanimation.cpp:607
QAnimationTimer::updateAnimationsTime
void updateAnimationsTime(qint64 delta) override
Definition
qabstractanimation.cpp:584
QAnimationTimer::~QAnimationTimer
~QAnimationTimer() override
QAnimationTimer::restartAnimationTimer
void restartAnimationTimer() override
Definition
qabstractanimation.cpp:614
QAnimationTimer::ensureTimerUpdate
static void ensureTimerUpdate()
Definition
qabstractanimation.cpp:576
QAnimationTimer::registerAnimation
static void registerAnimation(QAbstractAnimation *animation, bool isTopLevel)
Definition
qabstractanimation.cpp:652
QAnimationTimer::instance
static QAnimationTimer * instance()
Definition
qabstractanimation.cpp:571
QDefaultAnimationDriver
Definition
qabstractanimation_p.h:86
QDefaultAnimationDriver::~QDefaultAnimationDriver
~QDefaultAnimationDriver() override
Definition
qabstractanimation.cpp:890
QDefaultAnimationDriver::timerEvent
void timerEvent(QTimerEvent *e) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
Definition
qabstractanimation.cpp:896
QUnifiedTimer
\inmodule QtCore
Definition
qabstractanimation_p.h:132
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
AnimationListConstIt
QList< QAbstractAnimation * >::ConstIterator AnimationListConstIt
Definition
qabstractanimation.cpp:134
DEFAULT_TIMER_INTERVAL
#define DEFAULT_TIMER_INTERVAL
Definition
qabstractanimation.cpp:128
TimerListConstIt
QT_BEGIN_NAMESPACE typedef QList< QAbstractAnimationTimer * >::ConstIterator TimerListConstIt
Definition
qabstractanimation.cpp:133
PAUSE_TIMER_COARSE_THRESHOLD
#define PAUSE_TIMER_COARSE_THRESHOLD
Definition
qabstractanimation.cpp:129
QT_REQUIRE_CONFIG
QT_REQUIRE_CONFIG(animation)
QT_REQUIRE_CONFIG
QT_REQUIRE_CONFIG(animation)
qtbase
src
corelib
animation
qabstractanimation_p.h
Generated on
for Qt by
1.18.0