6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
63
64
65
66
67
68
71
72
73
74
75
76
77
78
79
82
83
84
85
86
87
88
89
92
93
94
95
96
97
98
101
102
103
104
105
106
107
112#include <QtCore/qdebug.h>
116#if defined(Q_OS_WASM)
117#include <QtCore/private/qwasmanimationdriver_p.h>
120#include <QtCore/qmath.h>
121#include <QtCore/qcoreevent.h>
122#include <QtCore/qpointer.h>
123#include <QtCore/qscopedvaluerollback.h>
125#define DEFAULT_TIMER_INTERVAL 16
126#define PAUSE_TIMER_COARSE_THRESHOLD 2000
134
135
136
137
138
139
140
141
142
143
144
145
148
149
150
151
152
153
156
157
158
159
160
161
162
163
166
167
168
169
170
171
174
175
176
177
178
179
180
181
182
183
185QUnifiedTimer::QUnifiedTimer() :
187 currentAnimationIdx(0), insideTick(
false), insideRestart(
false), consistentTiming(
false),
188 startTimersPending(
false), stopTimerPending(
false), allowNegativeDelta(
false),
189 speedModifier(1), profilerCallback(
nullptr),
190 driverStartTime(0), temporalDrift(0)
193 driver = &defaultDriver;
196QUnifiedTimer::~QUnifiedTimer()
199QUnifiedTimer *QUnifiedTimer::instance(
bool create)
202 static thread_local std::unique_ptr<QUnifiedTimer> unifiedTimer;
203 if (create && !unifiedTimer) {
204 inst =
new QUnifiedTimer;
205 unifiedTimer.reset(inst);
207 inst = unifiedTimer.get();
212QUnifiedTimer *QUnifiedTimer::instance()
214 return instance(
true);
217void QUnifiedTimer::maybeUpdateAnimationsToCurrentTime()
219 if (elapsed() - lastTick > 50)
220 updateAnimationTimers();
223qint64 QUnifiedTimer::elapsed()
const
225 if (driver->isRunning())
226 return driverStartTime + driver->elapsed();
227 else if (time.isValid())
228 return time.elapsed() + temporalDrift;
236void QUnifiedTimer::startAnimationDriver()
238 if (driver->isRunning()) {
239 qWarning(
"QUnifiedTimer::startAnimationDriver: driver is already running...");
245 driverStartTime = elapsed();
249void QUnifiedTimer::stopAnimationDriver()
251 if (!driver->isRunning()) {
252 qWarning(
"QUnifiedTimer::stopAnimationDriver: driver is not running");
258 temporalDrift = elapsed() - time.elapsed();
262void QUnifiedTimer::updateAnimationTimers()
268 const qint64 totalElapsed = elapsed();
271 qint64 delta = (consistentTiming && !pauseTimer.isActive()) ?
272 timingInterval : totalElapsed - lastTick;
275 if (speedModifier != 1) {
276 if (speedModifier > 0)
277 delta = qRound(delta * speedModifier);
282 lastTick = totalElapsed;
289 if (delta != 0 && (allowNegativeDelta || delta > 0)) {
290 QScopedValueRollback<
bool> guard(insideTick,
true);
291 if (profilerCallback)
292 profilerCallback(delta);
293 for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.size(); ++currentAnimationIdx) {
294 QAbstractAnimationTimer *animation = animationTimers.at(currentAnimationIdx);
295 animation->updateAnimationsTime(delta);
297 currentAnimationIdx = 0;
301qsizetype QUnifiedTimer::runningAnimationCount()
const
304 for (
const QAbstractAnimationTimer *timer : animationTimers)
305 count += timer->runningAnimationCount();
309void QUnifiedTimer::registerProfilerCallback(
void (*cb)(qint64))
311 profilerCallback = cb;
314void QUnifiedTimer::localRestart()
319 if (!pausedAnimationTimers.isEmpty() && (animationTimers.size() + animationTimersToStart.size() == pausedAnimationTimers.size())) {
321 int closestTimeToFinish = closestPausedAnimationTimerTimeToFinish();
324 pauseTimer.start(closestTimeToFinish, timerType,
this);
325 }
else if (!driver->isRunning()) {
326 if (pauseTimer.isActive())
328 startAnimationDriver();
333void QUnifiedTimer::restart()
336 QScopedValueRollback<
bool> guard(insideRestart,
true);
337 for (
int i = 0; i < animationTimers.size(); ++i)
338 animationTimers.at(i)->restartAnimationTimer();
344void QUnifiedTimer::setTimingInterval(
int interval)
346 timingInterval = interval;
348 if (driver->isRunning() && !pauseTimer.isActive()) {
350 stopAnimationDriver();
351 startAnimationDriver();
355void QUnifiedTimer::startTimers()
357 startTimersPending =
false;
360 animationTimers += animationTimersToStart;
361 animationTimersToStart.clear();
362 if (!animationTimers.isEmpty()) {
363 if (!time.isValid()) {
373void QUnifiedTimer::stopTimer()
375 stopTimerPending =
false;
376 if (animationTimers.isEmpty()) {
377 stopAnimationDriver();
384void QUnifiedTimer::timerEvent(QTimerEvent *event)
388 if (consistentTiming) {
389 if (stopTimerPending)
391 if (startTimersPending)
395 if (event->id() == pauseTimer.id()) {
397 updateAnimationTimers();
402void QUnifiedTimer::startAnimationTimer(QAbstractAnimationTimer *timer)
404 if (timer->isRegistered)
406 timer->isRegistered =
true;
408 QUnifiedTimer *inst = instance(
true);
409 inst->animationTimersToStart << timer;
410 if (!inst->startTimersPending) {
411 inst->startTimersPending =
true;
412 QMetaObject::invokeMethod(inst,
"startTimers", Qt::QueuedConnection);
416void QUnifiedTimer::stopAnimationTimer(QAbstractAnimationTimer *timer)
418 QUnifiedTimer *inst = QUnifiedTimer::instance(
false);
423 if (!timer->isRegistered)
425 timer->isRegistered =
false;
427 int idx = inst->animationTimers.indexOf(timer);
429 inst->animationTimers.removeAt(idx);
431 if (idx <= inst->currentAnimationIdx)
432 --inst->currentAnimationIdx;
434 if (inst->animationTimers.isEmpty() && !inst->stopTimerPending) {
435 inst->stopTimerPending =
true;
436 QMetaObject::invokeMethod(inst,
"stopTimer", Qt::QueuedConnection);
439 inst->animationTimersToStart.removeOne(timer);
444void QUnifiedTimer::pauseAnimationTimer(QAbstractAnimationTimer *timer,
int duration)
446 QUnifiedTimer *inst = QUnifiedTimer::instance();
447 if (!timer->isRegistered)
448 inst->startAnimationTimer(timer);
450 bool timerWasPaused = timer->isPaused;
451 timer->isPaused =
true;
452 timer->pauseDuration = duration;
454 inst->pausedAnimationTimers << timer;
455 inst->localRestart();
458void QUnifiedTimer::resumeAnimationTimer(QAbstractAnimationTimer *timer)
460 if (!timer->isPaused)
463 timer->isPaused =
false;
464 QUnifiedTimer *inst = QUnifiedTimer::instance();
465 inst->pausedAnimationTimers.removeOne(timer);
466 inst->localRestart();
469int QUnifiedTimer::closestPausedAnimationTimerTimeToFinish()
471 int closestTimeToFinish = INT_MAX;
472 for (TimerListConstIt it = pausedAnimationTimers.constBegin(), cend = pausedAnimationTimers.constEnd(); it != cend; ++it) {
473 const int timeToFinish = (*it)->pauseDuration;
474 if (timeToFinish < closestTimeToFinish)
475 closestTimeToFinish = timeToFinish;
477 return closestTimeToFinish;
480void QUnifiedTimer::installAnimationDriver(QAnimationDriver *d)
482 if (driver != &defaultDriver) {
483 qWarning(
"QUnifiedTimer: animation driver already installed...");
487 bool running = driver->isRunning();
489 stopAnimationDriver();
492 allowNegativeDelta = driver->property(
"allowNegativeDelta").toBool();
494 startAnimationDriver();
497void QUnifiedTimer::uninstallAnimationDriver(QAnimationDriver *d)
500 qWarning(
"QUnifiedTimer: trying to uninstall a driver that is not installed...");
504 bool running = driver->isRunning();
506 stopAnimationDriver();
507 driver = &defaultDriver;
508 allowNegativeDelta =
false;
510 startAnimationDriver();
514
515
516
517bool QUnifiedTimer::canUninstallAnimationDriver(QAnimationDriver *d)
519 return d == driver && driver != &defaultDriver;
523 QAbstractAnimationTimer(), lastTick(0),
524 currentAnimationIdx(0), insideTick(
false),
525 startAnimationPending(
false), stopTimerPending(
false),
526 runningLeafAnimations(0)
537 static thread_local std::unique_ptr<QAnimationTimer> animationTimer;
538 if (create && !animationTimer) {
539 inst =
new QAnimationTimer;
540 animationTimer.reset(inst);
542 inst = animationTimer.get();
547 inst = &animationTimer;
560 QUnifiedTimer *instU = QUnifiedTimer::instance(
false);
561 if (instU && inst && inst->isPaused)
562 instU->updateAnimationTimers();
577 QScopedValueRollback<
bool> guard(insideTick,
true);
578 for (currentAnimationIdx = 0; currentAnimationIdx < animations.size(); ++currentAnimationIdx) {
579 QAbstractAnimation *animation = animations.at(currentAnimationIdx);
580 int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
581 + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
582 animation->setCurrentTime(elapsed);
584 currentAnimationIdx = 0;
597 if (runningLeafAnimations == 0 && !runningPauseAnimations.isEmpty())
598 QUnifiedTimer::pauseAnimationTimer(
this, closestPauseAnimationTimeToFinish());
600 QUnifiedTimer::resumeAnimationTimer(
this);
601 else if (!isRegistered)
602 QUnifiedTimer::startAnimationTimer(
this);
607 if (!startAnimationPending)
609 startAnimationPending =
false;
612 QUnifiedTimer::instance()->maybeUpdateAnimationsToCurrentTime();
615 animations += animationsToStart;
616 animationsToStart.clear();
617 if (!animations.isEmpty())
623 stopTimerPending =
false;
624 bool pendingStart = startAnimationPending && animationsToStart.size() > 0;
625 if (animations.isEmpty() && !pendingStart) {
626 QUnifiedTimer::resumeAnimationTimer(
this);
627 QUnifiedTimer::stopAnimationTimer(
this);
636 inst->registerRunningAnimation(animation);
638 Q_ASSERT(!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer);
639 QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer =
true;
640 inst->animationsToStart << animation;
641 if (!inst->startAnimationPending) {
642 inst->startAnimationPending =
true;
643 QMetaObject::invokeMethod(inst,
"startAnimations", Qt::QueuedConnection);
655 inst->unregisterRunningAnimation(animation);
657 if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer)
660 int idx = inst->animations.indexOf(animation);
662 inst->animations.removeAt(idx);
664 if (idx <= inst->currentAnimationIdx)
665 --inst->currentAnimationIdx;
667 if (inst->animations.isEmpty() && !inst->stopTimerPending) {
668 inst->stopTimerPending =
true;
669 QMetaObject::invokeMethod(inst,
"stopTimer", Qt::QueuedConnection);
672 inst->animationsToStart.removeOne(animation);
675 QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer =
false;
678void QAnimationTimer::registerRunningAnimation(QAbstractAnimation *animation)
680 if (QAbstractAnimationPrivate::get(animation)->isGroup)
683 if (QAbstractAnimationPrivate::get(animation)->isPause) {
684 runningPauseAnimations << animation;
686 runningLeafAnimations++;
689void QAnimationTimer::unregisterRunningAnimation(QAbstractAnimation *animation)
691 if (QAbstractAnimationPrivate::get(animation)->isGroup)
694 if (QAbstractAnimationPrivate::get(animation)->isPause)
695 runningPauseAnimations.removeOne(animation);
697 runningLeafAnimations--;
698 Q_ASSERT(runningLeafAnimations >= 0);
703 int closestTimeToFinish = INT_MAX;
704 for (
AnimationListConstIt it = runningPauseAnimations.constBegin(), cend = runningPauseAnimations.constEnd(); it != cend; ++it) {
705 const QAbstractAnimation *animation = *it;
708 if (animation->direction() == QAbstractAnimation::Forward)
709 timeToFinish = animation->duration() - animation->currentLoopTime();
711 timeToFinish = animation->currentLoopTime();
713 if (timeToFinish < closestTimeToFinish)
714 closestTimeToFinish = timeToFinish;
716 return closestTimeToFinish;
720
721
722
723
724
725
726
727
728
729
730
732QAnimationDriver::QAnimationDriver(QObject *parent)
733 : QObject(*(
new QAnimationDriverPrivate), parent)
737QAnimationDriver::QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent)
738 : QObject(dd, parent)
742QAnimationDriver::~QAnimationDriver()
744 QUnifiedTimer *timer = QUnifiedTimer::instance(
false);
745 if (timer && timer->canUninstallAnimationDriver(
this))
750
751
752
753
754
755
757void QAnimationDriver::advanceAnimation()
759 QUnifiedTimer *instance = QUnifiedTimer::instance();
762 instance->updateAnimationTimers();
769
770
771
773void QAnimationDriver::advance()
781
782
783
785void QAnimationDriver::install()
787 QUnifiedTimer *timer = QUnifiedTimer::instance(
true);
788 timer->installAnimationDriver(
this);
794
795
797void QAnimationDriver::uninstall()
799 QUnifiedTimer *timer = QUnifiedTimer::instance(
true);
800 timer->uninstallAnimationDriver(
this);
803bool QAnimationDriver::isRunning()
const
805 return d_func()->running;
809void QAnimationDriver::start()
811 Q_D(QAnimationDriver);
820void QAnimationDriver::stop()
822 Q_D(QAnimationDriver);
831
832
833
834
836qint64 QAnimationDriver::elapsed()
const
838 Q_D(
const QAnimationDriver);
839 return d->running ? d->timer.elapsed() : 0;
843
844
845
846
847
848
849
852
853
854
855
856
857
858
861
862
863
865 : QAnimationDriver(
nullptr), m_unified_timer(timer)
867 connect(
this, &QAnimationDriver::started,
this, &QDefaultAnimationDriver::startTimer);
873 disconnect(
this, &QAnimationDriver::started,
this, &QDefaultAnimationDriver::startTimer);
879 Q_ASSERT(e->id() == m_timer.id());
887 m_timer.start(m_unified_timer->timingInterval, Qt::PreciseTimer,
this);
895QAnimationDriverPrivate::QAnimationDriverPrivate()
898QAnimationDriverPrivate::~QAnimationDriverPrivate()
901QAbstractAnimationTimer::QAbstractAnimationTimer()
904QAbstractAnimationTimer::~QAbstractAnimationTimer()
907QAbstractAnimationPrivate::QAbstractAnimationPrivate()
910QAbstractAnimationPrivate::~QAbstractAnimationPrivate() { }
912void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
914 Q_Q(QAbstractAnimation);
915 const QAbstractAnimation::State oldState = state.valueBypassingBindings();
916 if (oldState == newState)
922 int oldCurrentTime = currentTime;
923 int oldCurrentLoop = currentLoop;
924 QAbstractAnimation::Direction oldDirection = direction;
927 if ((newState == QAbstractAnimation::Paused || newState == QAbstractAnimation::Running)
928 && oldState == QAbstractAnimation::Stopped) {
929 const int oldTotalCurrentTime = totalCurrentTime;
933 totalCurrentTime = currentTime = (direction == QAbstractAnimation::Forward) ?
934 0 : (loopCount == -1 ? q->duration() : q->totalDuration());
935 if (totalCurrentTime != oldTotalCurrentTime)
936 totalCurrentTime.notify();
939 state.setValueBypassingBindings(newState);
940 QPointer<QAbstractAnimation> guard(q);
944 bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
945 if (oldState == QAbstractAnimation::Running) {
946 if (newState == QAbstractAnimation::Paused && hasRegisteredTimer)
947 QAnimationTimer::ensureTimerUpdate();
949 QAnimationTimer::unregisterAnimation(q);
950 }
else if (newState == QAbstractAnimation::Running) {
951 QAnimationTimer::registerAnimation(q, isTopLevel);
954 q->updateState(newState, oldState);
956 if (!guard || newState != state.valueBypassingBindings())
961 emit q->stateChanged(newState, oldState);
963 if (!guard || newState != state.valueBypassingBindings())
967 case QAbstractAnimation::Paused:
969 case QAbstractAnimation::Running:
973 if (oldState == QAbstractAnimation::Stopped) {
976 QAnimationTimer::ensureTimerUpdate();
977 q->setCurrentTime(totalCurrentTime);
982 case QAbstractAnimation::Stopped:
984 int dura = q->duration();
986 if (deleteWhenStopped)
989 if (dura == -1 || loopCount < 0
990 || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount))
991 || (oldDirection == QAbstractAnimation::Backward && oldCurrentTime == 0)) {
999
1000
1001
1002
1003
1004QAbstractAnimation::QAbstractAnimation(QObject *parent)
1005 : QObject(*
new QAbstractAnimationPrivate,
nullptr)
1012
1013
1014QAbstractAnimation::QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent)
1015 : QObject(dd,
nullptr)
1022
1023
1024
1025
1026QAbstractAnimation::~QAbstractAnimation()
1028 Q_D(QAbstractAnimation);
1030 if (d->state != Stopped) {
1031 QAbstractAnimation::State oldState = d->state;
1034 emit stateChanged(d->state, oldState);
1035 if (oldState == QAbstractAnimation::Running)
1036 QAnimationTimer::unregisterAnimation(
this);
1039 d->group->removeAnimation(
this);
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055QAbstractAnimation::State QAbstractAnimation::state()
const
1057 Q_D(
const QAbstractAnimation);
1061QBindable<QAbstractAnimation::State> QAbstractAnimation::bindableState()
const
1063 Q_D(
const QAbstractAnimation);
1068
1069
1070
1071
1072
1073QAnimationGroup *QAbstractAnimation::group()
const
1075 Q_D(
const QAbstractAnimation);
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124QAbstractAnimation::Direction QAbstractAnimation::direction()
const
1126 Q_D(
const QAbstractAnimation);
1127 return d->direction;
1129void QAbstractAnimation::setDirection(Direction direction)
1131 Q_D(QAbstractAnimation);
1132 if (d->direction == direction) {
1133 d->direction.removeBindingUnlessInWrapper();
1137 const QScopedPropertyUpdateGroup guard;
1138 const int oldCurrentLoop = d->currentLoop;
1139 if (state() == Stopped) {
1140 if (direction == Backward) {
1141 d->currentTime = duration();
1142 d->currentLoop = d->loopCount - 1;
1151 if (d->hasRegisteredTimer)
1152 QAnimationTimer::ensureTimerUpdate();
1154 d->direction = direction;
1155 updateDirection(direction);
1157 if (d->hasRegisteredTimer)
1159 QAnimationTimer::updateAnimationTimer();
1161 if (d->currentLoop != oldCurrentLoop)
1162 d->currentLoop.notify();
1163 d->direction.notify();
1166QBindable<QAbstractAnimation::Direction> QAbstractAnimation::bindableDirection()
1168 Q_D(QAbstractAnimation);
1169 return &d->direction;
1173
1174
1175
1176
1177
1178
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193int QAbstractAnimation::loopCount()
const
1195 Q_D(
const QAbstractAnimation);
1196 return d->loopCount;
1198void QAbstractAnimation::setLoopCount(
int loopCount)
1200 Q_D(QAbstractAnimation);
1201 d->loopCount = loopCount;
1204QBindable<
int> QAbstractAnimation::bindableLoopCount()
1206 Q_D(QAbstractAnimation);
1207 return &d->loopCount;
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223int QAbstractAnimation::currentLoop()
const
1225 Q_D(
const QAbstractAnimation);
1226 return d->currentLoop;
1229QBindable<
int> QAbstractAnimation::bindableCurrentLoop()
const
1231 Q_D(
const QAbstractAnimation);
1232 return &d->currentLoop;
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1254
1255
1256
1257
1258
1259int QAbstractAnimation::totalDuration()
const
1261 int dura = duration();
1264 int loopcount = loopCount();
1267 return dura * loopcount;
1271
1272
1273
1274
1276int QAbstractAnimation::currentLoopTime()
const
1278 Q_D(
const QAbstractAnimation);
1279 return d->currentTime;
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299int QAbstractAnimation::currentTime()
const
1301 Q_D(
const QAbstractAnimation);
1302 return d->totalCurrentTime;
1305QBindable<
int> QAbstractAnimation::bindableCurrentTime()
1307 Q_D(QAbstractAnimation);
1308 return &d->totalCurrentTime;
1311void QAbstractAnimation::setCurrentTime(
int msecs)
1313 Q_D(QAbstractAnimation);
1314 msecs = qMax(msecs, 0);
1317 const int dura = duration();
1318 const int totalLoopCount = d->loopCount;
1319 const int totalDura = dura <= 0 ? dura : ((totalLoopCount < 0) ? -1 : dura * totalLoopCount);
1320 if (totalDura != -1)
1321 msecs = qMin(totalDura, msecs);
1323 d->totalCurrentTime.removeBindingUnlessInWrapper();
1325 const int oldCurrentTime = d->totalCurrentTime.valueBypassingBindings();
1326 d->totalCurrentTime.setValueBypassingBindings(msecs);
1328 QAbstractAnimation::Direction currentDirection = d->direction;
1331 const int oldLoop = d->currentLoop.valueBypassingBindings();
1332 int newCurrentLoop = (dura <= 0) ? 0 : (msecs / dura);
1333 if (newCurrentLoop == totalLoopCount) {
1335 d->currentTime = qMax(0, dura);
1336 newCurrentLoop = qMax(0, totalLoopCount - 1);
1338 if (currentDirection == Forward) {
1339 d->currentTime = (dura <= 0) ? msecs : (msecs % dura);
1341 d->currentTime = (dura <= 0) ? msecs : ((msecs - 1) % dura) + 1;
1342 if (d->currentTime == dura)
1343 newCurrentLoop = newCurrentLoop - 1;
1346 d->currentLoop.setValueBypassingBindings(newCurrentLoop);
1349 updateCurrentTime(d->currentTime);
1352 newCurrentLoop = d->currentLoop.valueBypassingBindings();
1353 currentDirection = d->direction;
1354 const int newTotalCurrentTime = d->totalCurrentTime.valueBypassingBindings();
1356 if (newCurrentLoop != oldLoop)
1357 d->currentLoop.notify();
1360
1361
1362
1363 if (oldCurrentTime != newTotalCurrentTime)
1364 d->totalCurrentTime.notify();
1368 if ((currentDirection == Forward && newTotalCurrentTime == totalDura)
1369 || (currentDirection == Backward && newTotalCurrentTime == 0)) {
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390void QAbstractAnimation::start(DeletionPolicy policy)
1392 Q_D(QAbstractAnimation);
1393 if (d->state.valueBypassingBindings() == Running)
1395 d->deleteWhenStopped = policy;
1396 d->setState(Running);
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409void QAbstractAnimation::stop()
1411 Q_D(QAbstractAnimation);
1413 if (d->state.valueBypassingBindings() == Stopped)
1416 d->setState(Stopped);
1420
1421
1422
1423
1424
1425
1426void QAbstractAnimation::pause()
1428 Q_D(QAbstractAnimation);
1429 if (d->state.valueBypassingBindings() == Stopped) {
1430 qWarning(
"QAbstractAnimation::pause: Cannot pause a stopped animation");
1434 d->setState(Paused);
1438
1439
1440
1441
1442
1443void QAbstractAnimation::resume()
1445 Q_D(QAbstractAnimation);
1446 if (d->state.valueBypassingBindings() != Paused) {
1447 qWarning(
"QAbstractAnimation::resume: "
1448 "Cannot resume an animation that is not paused");
1452 d->setState(Running);
1456
1457
1458
1459
1460
1461void QAbstractAnimation::setPaused(
bool paused)
1471
1472
1473bool QAbstractAnimation::event(QEvent *event)
1475 return QObject::event(event);
1479
1480
1481
1482
1483
1484
1485
1488
1489
1490
1491
1492
1493void QAbstractAnimation::updateState(QAbstractAnimation::State newState,
1494 QAbstractAnimation::State oldState)
1501
1502
1503
1504
1505
1506void QAbstractAnimation::updateDirection(QAbstractAnimation::Direction direction)
1508 Q_UNUSED(direction);
1514#include "moc_qabstractanimation.cpp"
1515#include "moc_qabstractanimation_p.cpp"
static void unregisterAnimation(QAbstractAnimation *animation)
static QAnimationTimer * instance(bool create)
static void updateAnimationTimer()
void updateAnimationsTime(qint64 delta) override
~QAnimationTimer() override
void restartAnimationTimer() override
static void ensureTimerUpdate()
static void registerAnimation(QAbstractAnimation *animation, bool isTopLevel)
static QAnimationTimer * instance()
~QDefaultAnimationDriver() override
void timerEvent(QTimerEvent *e) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
Combined button and popup list for selecting options.
QList< QAbstractAnimation * >::ConstIterator AnimationListConstIt
#define DEFAULT_TIMER_INTERVAL
QT_BEGIN_NAMESPACE typedef QList< QAbstractAnimationTimer * >::ConstIterator TimerListConstIt
#define PAUSE_TIMER_COARSE_THRESHOLD