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#include <QtCore/qmath.h>
117#include <QtCore/qcoreevent.h>
118#include <QtCore/qpointer.h>
119#include <QtCore/qscopedvaluerollback.h>
121#define DEFAULT_TIMER_INTERVAL 16
122#define PAUSE_TIMER_COARSE_THRESHOLD 2000
130
131
132
133
134
135
136
137
138
139
140
141
144
145
146
147
148
149
152
153
154
155
156
157
158
159
162
163
164
165
166
167
170
171
172
173
174
175
176
177
178
179
181QUnifiedTimer::QUnifiedTimer() :
183 currentAnimationIdx(0), insideTick(
false), insideRestart(
false), consistentTiming(
false),
184 startTimersPending(
false), stopTimerPending(
false), allowNegativeDelta(
false),
185 speedModifier(1), profilerCallback(
nullptr),
186 driverStartTime(0), temporalDrift(0)
189 driver = &defaultDriver;
192QUnifiedTimer::~QUnifiedTimer()
195QUnifiedTimer *QUnifiedTimer::instance(
bool create)
198 static thread_local std::unique_ptr<QUnifiedTimer> unifiedTimer;
199 if (create && !unifiedTimer) {
200 inst =
new QUnifiedTimer;
201 unifiedTimer.reset(inst);
203 inst = unifiedTimer.get();
208QUnifiedTimer *QUnifiedTimer::instance()
210 return instance(
true);
213void QUnifiedTimer::maybeUpdateAnimationsToCurrentTime()
215 if (elapsed() - lastTick > 50)
216 updateAnimationTimers();
219qint64 QUnifiedTimer::elapsed()
const
221 if (driver->isRunning())
222 return driverStartTime + driver->elapsed();
223 else if (time.isValid())
224 return time.elapsed() + temporalDrift;
232void QUnifiedTimer::startAnimationDriver()
234 if (driver->isRunning()) {
235 qWarning(
"QUnifiedTimer::startAnimationDriver: driver is already running...");
241 driverStartTime = elapsed();
245void QUnifiedTimer::stopAnimationDriver()
247 if (!driver->isRunning()) {
248 qWarning(
"QUnifiedTimer::stopAnimationDriver: driver is not running");
254 temporalDrift = elapsed() - time.elapsed();
258void QUnifiedTimer::updateAnimationTimers()
264 const qint64 totalElapsed = elapsed();
267 qint64 delta = (consistentTiming && !pauseTimer.isActive()) ?
268 timingInterval : totalElapsed - lastTick;
271 if (speedModifier != 1) {
272 if (speedModifier > 0)
273 delta = qRound(delta * speedModifier);
278 lastTick = totalElapsed;
285 if (delta != 0 && (allowNegativeDelta || delta > 0)) {
286 QScopedValueRollback<
bool> guard(insideTick,
true);
287 if (profilerCallback)
288 profilerCallback(delta);
289 for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.size(); ++currentAnimationIdx) {
290 QAbstractAnimationTimer *animation = animationTimers.at(currentAnimationIdx);
291 animation->updateAnimationsTime(delta);
293 currentAnimationIdx = 0;
297qsizetype QUnifiedTimer::runningAnimationCount()
const
300 for (
const QAbstractAnimationTimer *timer : animationTimers)
301 count += timer->runningAnimationCount();
305void QUnifiedTimer::registerProfilerCallback(
void (*cb)(qint64))
307 profilerCallback = cb;
310void QUnifiedTimer::localRestart()
315 if (!pausedAnimationTimers.isEmpty() && (animationTimers.size() + animationTimersToStart.size() == pausedAnimationTimers.size())) {
317 int closestTimeToFinish = closestPausedAnimationTimerTimeToFinish();
320 pauseTimer.start(closestTimeToFinish, timerType,
this);
321 }
else if (!driver->isRunning()) {
322 if (pauseTimer.isActive())
324 startAnimationDriver();
329void QUnifiedTimer::restart()
332 QScopedValueRollback<
bool> guard(insideRestart,
true);
333 for (
int i = 0; i < animationTimers.size(); ++i)
334 animationTimers.at(i)->restartAnimationTimer();
340void QUnifiedTimer::setTimingInterval(
int interval)
342 timingInterval = interval;
344 if (driver->isRunning() && !pauseTimer.isActive()) {
346 stopAnimationDriver();
347 startAnimationDriver();
351void QUnifiedTimer::startTimers()
353 startTimersPending =
false;
356 animationTimers += animationTimersToStart;
357 animationTimersToStart.clear();
358 if (!animationTimers.isEmpty()) {
359 if (!time.isValid()) {
369void QUnifiedTimer::stopTimer()
371 stopTimerPending =
false;
372 if (animationTimers.isEmpty()) {
373 stopAnimationDriver();
380void QUnifiedTimer::timerEvent(QTimerEvent *event)
384 if (consistentTiming) {
385 if (stopTimerPending)
387 if (startTimersPending)
391 if (event->id() == pauseTimer.id()) {
393 updateAnimationTimers();
398void QUnifiedTimer::startAnimationTimer(QAbstractAnimationTimer *timer)
400 if (timer->isRegistered)
402 timer->isRegistered =
true;
404 QUnifiedTimer *inst = instance(
true);
405 inst->animationTimersToStart << timer;
406 if (!inst->startTimersPending) {
407 inst->startTimersPending =
true;
408 QMetaObject::invokeMethod(inst,
"startTimers", Qt::QueuedConnection);
412void QUnifiedTimer::stopAnimationTimer(QAbstractAnimationTimer *timer)
414 QUnifiedTimer *inst = QUnifiedTimer::instance(
false);
419 if (!timer->isRegistered)
421 timer->isRegistered =
false;
423 int idx = inst->animationTimers.indexOf(timer);
425 inst->animationTimers.removeAt(idx);
427 if (idx <= inst->currentAnimationIdx)
428 --inst->currentAnimationIdx;
430 if (inst->animationTimers.isEmpty() && !inst->stopTimerPending) {
431 inst->stopTimerPending =
true;
432 QMetaObject::invokeMethod(inst,
"stopTimer", Qt::QueuedConnection);
435 inst->animationTimersToStart.removeOne(timer);
440void QUnifiedTimer::pauseAnimationTimer(QAbstractAnimationTimer *timer,
int duration)
442 QUnifiedTimer *inst = QUnifiedTimer::instance();
443 if (!timer->isRegistered)
444 inst->startAnimationTimer(timer);
446 bool timerWasPaused = timer->isPaused;
447 timer->isPaused =
true;
448 timer->pauseDuration = duration;
450 inst->pausedAnimationTimers << timer;
451 inst->localRestart();
454void QUnifiedTimer::resumeAnimationTimer(QAbstractAnimationTimer *timer)
456 if (!timer->isPaused)
459 timer->isPaused =
false;
460 QUnifiedTimer *inst = QUnifiedTimer::instance();
461 inst->pausedAnimationTimers.removeOne(timer);
462 inst->localRestart();
465int QUnifiedTimer::closestPausedAnimationTimerTimeToFinish()
467 int closestTimeToFinish = INT_MAX;
468 for (TimerListConstIt it = pausedAnimationTimers.constBegin(), cend = pausedAnimationTimers.constEnd(); it != cend; ++it) {
469 const int timeToFinish = (*it)->pauseDuration;
470 if (timeToFinish < closestTimeToFinish)
471 closestTimeToFinish = timeToFinish;
473 return closestTimeToFinish;
476void QUnifiedTimer::installAnimationDriver(QAnimationDriver *d)
478 if (driver != &defaultDriver) {
479 qWarning(
"QUnifiedTimer: animation driver already installed...");
483 bool running = driver->isRunning();
485 stopAnimationDriver();
488 allowNegativeDelta = driver->property(
"allowNegativeDelta").toBool();
490 startAnimationDriver();
493void QUnifiedTimer::uninstallAnimationDriver(QAnimationDriver *d)
496 qWarning(
"QUnifiedTimer: trying to uninstall a driver that is not installed...");
500 bool running = driver->isRunning();
502 stopAnimationDriver();
503 driver = &defaultDriver;
504 allowNegativeDelta =
false;
506 startAnimationDriver();
510
511
512
513bool QUnifiedTimer::canUninstallAnimationDriver(QAnimationDriver *d)
515 return d == driver && driver != &defaultDriver;
519 QAbstractAnimationTimer(), lastTick(0),
520 currentAnimationIdx(0), insideTick(
false),
521 startAnimationPending(
false), stopTimerPending(
false),
522 runningLeafAnimations(0)
533 static thread_local std::unique_ptr<QAnimationTimer> animationTimer;
534 if (create && !animationTimer) {
535 inst =
new QAnimationTimer;
536 animationTimer.reset(inst);
538 inst = animationTimer.get();
543 inst = &animationTimer;
556 QUnifiedTimer *instU = QUnifiedTimer::instance(
false);
557 if (instU && inst && inst->isPaused)
558 instU->updateAnimationTimers();
573 QScopedValueRollback<
bool> guard(insideTick,
true);
574 for (currentAnimationIdx = 0; currentAnimationIdx < animations.size(); ++currentAnimationIdx) {
575 QAbstractAnimation *animation = animations.at(currentAnimationIdx);
576 int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
577 + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
578 animation->setCurrentTime(elapsed);
580 currentAnimationIdx = 0;
593 if (runningLeafAnimations == 0 && !runningPauseAnimations.isEmpty())
594 QUnifiedTimer::pauseAnimationTimer(
this, closestPauseAnimationTimeToFinish());
596 QUnifiedTimer::resumeAnimationTimer(
this);
597 else if (!isRegistered)
598 QUnifiedTimer::startAnimationTimer(
this);
603 if (!startAnimationPending)
605 startAnimationPending =
false;
608 QUnifiedTimer::instance()->maybeUpdateAnimationsToCurrentTime();
611 animations += animationsToStart;
612 animationsToStart.clear();
613 if (!animations.isEmpty())
619 stopTimerPending =
false;
620 bool pendingStart = startAnimationPending && animationsToStart.size() > 0;
621 if (animations.isEmpty() && !pendingStart) {
622 QUnifiedTimer::resumeAnimationTimer(
this);
623 QUnifiedTimer::stopAnimationTimer(
this);
632 inst->registerRunningAnimation(animation);
634 Q_ASSERT(!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer);
635 QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer =
true;
636 inst->animationsToStart << animation;
637 if (!inst->startAnimationPending) {
638 inst->startAnimationPending =
true;
639 QMetaObject::invokeMethod(inst,
"startAnimations", Qt::QueuedConnection);
651 inst->unregisterRunningAnimation(animation);
653 if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer)
656 int idx = inst->animations.indexOf(animation);
658 inst->animations.removeAt(idx);
660 if (idx <= inst->currentAnimationIdx)
661 --inst->currentAnimationIdx;
663 if (inst->animations.isEmpty() && !inst->stopTimerPending) {
664 inst->stopTimerPending =
true;
665 QMetaObject::invokeMethod(inst,
"stopTimer", Qt::QueuedConnection);
668 inst->animationsToStart.removeOne(animation);
671 QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer =
false;
674void QAnimationTimer::registerRunningAnimation(QAbstractAnimation *animation)
676 if (QAbstractAnimationPrivate::get(animation)->isGroup)
679 if (QAbstractAnimationPrivate::get(animation)->isPause) {
680 runningPauseAnimations << animation;
682 runningLeafAnimations++;
685void QAnimationTimer::unregisterRunningAnimation(QAbstractAnimation *animation)
687 if (QAbstractAnimationPrivate::get(animation)->isGroup)
690 if (QAbstractAnimationPrivate::get(animation)->isPause)
691 runningPauseAnimations.removeOne(animation);
693 runningLeafAnimations--;
694 Q_ASSERT(runningLeafAnimations >= 0);
699 int closestTimeToFinish = INT_MAX;
700 for (
AnimationListConstIt it = runningPauseAnimations.constBegin(), cend = runningPauseAnimations.constEnd(); it != cend; ++it) {
701 const QAbstractAnimation *animation = *it;
704 if (animation->direction() == QAbstractAnimation::Forward)
705 timeToFinish = animation->duration() - animation->currentLoopTime();
707 timeToFinish = animation->currentLoopTime();
709 if (timeToFinish < closestTimeToFinish)
710 closestTimeToFinish = timeToFinish;
712 return closestTimeToFinish;
716
717
718
719
720
721
722
723
724
725
726
728QAnimationDriver::QAnimationDriver(QObject *parent)
729 : QObject(*(
new QAnimationDriverPrivate), parent)
733QAnimationDriver::QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent)
734 : QObject(dd, parent)
738QAnimationDriver::~QAnimationDriver()
740 QUnifiedTimer *timer = QUnifiedTimer::instance(
false);
741 if (timer && timer->canUninstallAnimationDriver(
this))
746
747
748
749
750
751
753void QAnimationDriver::advanceAnimation()
755 QUnifiedTimer *instance = QUnifiedTimer::instance();
758 instance->updateAnimationTimers();
765
766
767
769void QAnimationDriver::advance()
777
778
779
781void QAnimationDriver::install()
783 QUnifiedTimer *timer = QUnifiedTimer::instance(
true);
784 timer->installAnimationDriver(
this);
790
791
793void QAnimationDriver::uninstall()
795 QUnifiedTimer *timer = QUnifiedTimer::instance(
true);
796 timer->uninstallAnimationDriver(
this);
799bool QAnimationDriver::isRunning()
const
801 return d_func()->running;
805void QAnimationDriver::start()
807 Q_D(QAnimationDriver);
816void QAnimationDriver::stop()
818 Q_D(QAnimationDriver);
827
828
829
830
832qint64 QAnimationDriver::elapsed()
const
834 Q_D(
const QAnimationDriver);
835 return d->running ? d->timer.elapsed() : 0;
839
840
841
842
843
844
845
848
849
850
851
852
853
854
857
858
860 : QAnimationDriver(
nullptr), m_unified_timer(timer)
862 connect(
this, &QAnimationDriver::started,
this, &QDefaultAnimationDriver::startTimer);
863 connect(
this, &QAnimationDriver::stopped,
this, &QDefaultAnimationDriver::stopTimer);
868 disconnect(
this, &QAnimationDriver::started,
this, &QDefaultAnimationDriver::startTimer);
869 disconnect(
this, &QAnimationDriver::stopped,
this, &QDefaultAnimationDriver::stopTimer);
874 Q_ASSERT(e->id() == m_timer.id());
882 m_timer.start(m_unified_timer->timingInterval, Qt::PreciseTimer,
this);
890QAnimationDriverPrivate::QAnimationDriverPrivate()
893QAnimationDriverPrivate::~QAnimationDriverPrivate()
896QAbstractAnimationTimer::QAbstractAnimationTimer()
899QAbstractAnimationTimer::~QAbstractAnimationTimer()
902QAbstractAnimationPrivate::QAbstractAnimationPrivate()
905QAbstractAnimationPrivate::~QAbstractAnimationPrivate() { }
907void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
909 Q_Q(QAbstractAnimation);
910 const QAbstractAnimation::State oldState = state.valueBypassingBindings();
911 if (oldState == newState)
917 int oldCurrentTime = currentTime;
918 int oldCurrentLoop = currentLoop;
919 QAbstractAnimation::Direction oldDirection = direction;
922 if ((newState == QAbstractAnimation::Paused || newState == QAbstractAnimation::Running)
923 && oldState == QAbstractAnimation::Stopped) {
924 const int oldTotalCurrentTime = totalCurrentTime;
928 totalCurrentTime = currentTime = (direction == QAbstractAnimation::Forward) ?
929 0 : (loopCount == -1 ? q->duration() : q->totalDuration());
930 if (totalCurrentTime != oldTotalCurrentTime)
931 totalCurrentTime.notify();
934 state.setValueBypassingBindings(newState);
935 QPointer<QAbstractAnimation> guard(q);
939 bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
940 if (oldState == QAbstractAnimation::Running) {
941 if (newState == QAbstractAnimation::Paused && hasRegisteredTimer)
942 QAnimationTimer::ensureTimerUpdate();
944 QAnimationTimer::unregisterAnimation(q);
945 }
else if (newState == QAbstractAnimation::Running) {
946 QAnimationTimer::registerAnimation(q, isTopLevel);
949 q->updateState(newState, oldState);
951 if (!guard || newState != state.valueBypassingBindings())
956 emit q->stateChanged(newState, oldState);
958 if (!guard || newState != state.valueBypassingBindings())
962 case QAbstractAnimation::Paused:
964 case QAbstractAnimation::Running:
968 if (oldState == QAbstractAnimation::Stopped) {
971 QAnimationTimer::ensureTimerUpdate();
972 q->setCurrentTime(totalCurrentTime);
977 case QAbstractAnimation::Stopped:
979 int dura = q->duration();
981 if (deleteWhenStopped)
984 if (dura == -1 || loopCount < 0
985 || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount))
986 || (oldDirection == QAbstractAnimation::Backward && oldCurrentTime == 0)) {
994
995
996
997
998
999QAbstractAnimation::QAbstractAnimation(QObject *parent)
1000 : QObject(*
new QAbstractAnimationPrivate,
nullptr)
1007
1008
1009QAbstractAnimation::QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent)
1010 : QObject(dd,
nullptr)
1017
1018
1019
1020
1021QAbstractAnimation::~QAbstractAnimation()
1023 Q_D(QAbstractAnimation);
1025 if (d->state != Stopped) {
1026 QAbstractAnimation::State oldState = d->state;
1029 emit stateChanged(d->state, oldState);
1030 if (oldState == QAbstractAnimation::Running)
1031 QAnimationTimer::unregisterAnimation(
this);
1034 d->group->removeAnimation(
this);
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050QAbstractAnimation::State QAbstractAnimation::state()
const
1052 Q_D(
const QAbstractAnimation);
1056QBindable<QAbstractAnimation::State> QAbstractAnimation::bindableState()
const
1058 Q_D(
const QAbstractAnimation);
1063
1064
1065
1066
1067
1068QAnimationGroup *QAbstractAnimation::group()
const
1070 Q_D(
const QAbstractAnimation);
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119QAbstractAnimation::Direction QAbstractAnimation::direction()
const
1121 Q_D(
const QAbstractAnimation);
1122 return d->direction;
1124void QAbstractAnimation::setDirection(Direction direction)
1126 Q_D(QAbstractAnimation);
1127 if (d->direction == direction) {
1128 d->direction.removeBindingUnlessInWrapper();
1132 const QScopedPropertyUpdateGroup guard;
1133 const int oldCurrentLoop = d->currentLoop;
1134 if (state() == Stopped) {
1135 if (direction == Backward) {
1136 d->currentTime = duration();
1137 d->currentLoop = d->loopCount - 1;
1146 if (d->hasRegisteredTimer)
1147 QAnimationTimer::ensureTimerUpdate();
1149 d->direction = direction;
1150 updateDirection(direction);
1152 if (d->hasRegisteredTimer)
1154 QAnimationTimer::updateAnimationTimer();
1156 if (d->currentLoop != oldCurrentLoop)
1157 d->currentLoop.notify();
1158 d->direction.notify();
1161QBindable<QAbstractAnimation::Direction> QAbstractAnimation::bindableDirection()
1163 Q_D(QAbstractAnimation);
1164 return &d->direction;
1168
1169
1170
1171
1172
1173
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188int QAbstractAnimation::loopCount()
const
1190 Q_D(
const QAbstractAnimation);
1191 return d->loopCount;
1193void QAbstractAnimation::setLoopCount(
int loopCount)
1195 Q_D(QAbstractAnimation);
1196 d->loopCount = loopCount;
1199QBindable<
int> QAbstractAnimation::bindableLoopCount()
1201 Q_D(QAbstractAnimation);
1202 return &d->loopCount;
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218int QAbstractAnimation::currentLoop()
const
1220 Q_D(
const QAbstractAnimation);
1221 return d->currentLoop;
1224QBindable<
int> QAbstractAnimation::bindableCurrentLoop()
const
1226 Q_D(
const QAbstractAnimation);
1227 return &d->currentLoop;
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1249
1250
1251
1252
1253
1254int QAbstractAnimation::totalDuration()
const
1256 int dura = duration();
1259 int loopcount = loopCount();
1262 return dura * loopcount;
1266
1267
1268
1269
1271int QAbstractAnimation::currentLoopTime()
const
1273 Q_D(
const QAbstractAnimation);
1274 return d->currentTime;
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294int QAbstractAnimation::currentTime()
const
1296 Q_D(
const QAbstractAnimation);
1297 return d->totalCurrentTime;
1300QBindable<
int> QAbstractAnimation::bindableCurrentTime()
1302 Q_D(QAbstractAnimation);
1303 return &d->totalCurrentTime;
1306void QAbstractAnimation::setCurrentTime(
int msecs)
1308 Q_D(QAbstractAnimation);
1309 msecs = qMax(msecs, 0);
1312 const int dura = duration();
1313 const int totalLoopCount = d->loopCount;
1314 const int totalDura = dura <= 0 ? dura : ((totalLoopCount < 0) ? -1 : dura * totalLoopCount);
1315 if (totalDura != -1)
1316 msecs = qMin(totalDura, msecs);
1318 d->totalCurrentTime.removeBindingUnlessInWrapper();
1320 const int oldCurrentTime = d->totalCurrentTime.valueBypassingBindings();
1321 d->totalCurrentTime.setValueBypassingBindings(msecs);
1323 QAbstractAnimation::Direction currentDirection = d->direction;
1326 const int oldLoop = d->currentLoop.valueBypassingBindings();
1327 int newCurrentLoop = (dura <= 0) ? 0 : (msecs / dura);
1328 if (newCurrentLoop == totalLoopCount) {
1330 d->currentTime = qMax(0, dura);
1331 newCurrentLoop = qMax(0, totalLoopCount - 1);
1333 if (currentDirection == Forward) {
1334 d->currentTime = (dura <= 0) ? msecs : (msecs % dura);
1336 d->currentTime = (dura <= 0) ? msecs : ((msecs - 1) % dura) + 1;
1337 if (d->currentTime == dura)
1338 newCurrentLoop = newCurrentLoop - 1;
1341 d->currentLoop.setValueBypassingBindings(newCurrentLoop);
1344 updateCurrentTime(d->currentTime);
1347 newCurrentLoop = d->currentLoop.valueBypassingBindings();
1348 currentDirection = d->direction;
1349 const int newTotalCurrentTime = d->totalCurrentTime.valueBypassingBindings();
1351 if (newCurrentLoop != oldLoop)
1352 d->currentLoop.notify();
1355
1356
1357
1358 if (oldCurrentTime != newTotalCurrentTime)
1359 d->totalCurrentTime.notify();
1363 if ((currentDirection == Forward && newTotalCurrentTime == totalDura)
1364 || (currentDirection == Backward && newTotalCurrentTime == 0)) {
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385void QAbstractAnimation::start(DeletionPolicy policy)
1387 Q_D(QAbstractAnimation);
1388 if (d->state.valueBypassingBindings() == Running)
1390 d->deleteWhenStopped = policy;
1391 d->setState(Running);
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404void QAbstractAnimation::stop()
1406 Q_D(QAbstractAnimation);
1408 if (d->state.valueBypassingBindings() == Stopped)
1411 d->setState(Stopped);
1415
1416
1417
1418
1419
1420
1421void QAbstractAnimation::pause()
1423 Q_D(QAbstractAnimation);
1424 if (d->state.valueBypassingBindings() == Stopped) {
1425 qWarning(
"QAbstractAnimation::pause: Cannot pause a stopped animation");
1429 d->setState(Paused);
1433
1434
1435
1436
1437
1438void QAbstractAnimation::resume()
1440 Q_D(QAbstractAnimation);
1441 if (d->state.valueBypassingBindings() != Paused) {
1442 qWarning(
"QAbstractAnimation::resume: "
1443 "Cannot resume an animation that is not paused");
1447 d->setState(Running);
1451
1452
1453
1454
1455
1456void QAbstractAnimation::setPaused(
bool paused)
1466
1467
1468bool QAbstractAnimation::event(QEvent *event)
1470 return QObject::event(event);
1474
1475
1476
1477
1478
1479
1480
1483
1484
1485
1486
1487
1488void QAbstractAnimation::updateState(QAbstractAnimation::State newState,
1489 QAbstractAnimation::State oldState)
1496
1497
1498
1499
1500
1501void QAbstractAnimation::updateDirection(QAbstractAnimation::Direction direction)
1503 Q_UNUSED(direction);
1509#include "moc_qabstractanimation.cpp"
1510#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.
QList< QAbstractAnimation * >::ConstIterator AnimationListConstIt
#define DEFAULT_TIMER_INTERVAL
QT_BEGIN_NAMESPACE typedef QList< QAbstractAnimationTimer * >::ConstIterator TimerListConstIt
#define PAUSE_TIMER_COARSE_THRESHOLD