4#include <QtCore/qthreadstorage.h>
6#include "private/qabstractanimationjob_p.h"
7#include "private/qanimationgroupjob_p.h"
8#include "private/qanimationjobutil_p.h"
9#include "private/qqmlengine_p.h"
10#include "private/qqmlglobal_p.h"
11#include "private/qdoubleendedlist_p.h"
25QQmlAnimationTimer::QQmlAnimationTimer() :
27 currentAnimationIdx(0), insideTick(
false),
28 startAnimationPending(
false), stopTimerPending(
false),
29 runningLeafAnimations(0)
51 for (
const auto &
animation : std::as_const(animations))
53 for (
const auto &
animation : std::as_const(animationsToStart))
55 for (
const auto &
animation : std::as_const(runningPauseAnimations))
62 if (
create && !animationTimer()->hasLocalData()) {
64 animationTimer()->setLocalData(inst);
66 inst = animationTimer() ? animationTimer()->localData() : 0;
96 for (currentAnimationIdx = 0; currentAnimationIdx < animations.
size(); ++currentAnimationIdx) {
102 if (animationTickDump()) {
103 qDebug() <<
"***** Dumping Animation Tree ***** ( tick:" << lastTick <<
"delta:" << delta <<
")";
104 for (
int i = 0;
i < animations.
size(); ++
i)
108 currentAnimationIdx = 0;
119 if (runningLeafAnimations == 0 && !runningPauseAnimations.
isEmpty())
129 if (!startAnimationPending)
131 startAnimationPending =
false;
136 animations += animationsToStart;
137 animationsToStart.
clear();
144 stopTimerPending =
false;
145 bool pendingStart = startAnimationPending && animationsToStart.
size() > 0;
146 if (animations.
isEmpty() && !pendingStart) {
164 if (!startAnimationPending) {
165 startAnimationPending =
true;
182 if (idx <= currentAnimationIdx)
183 --currentAnimationIdx;
185 if (animations.
isEmpty() && !stopTimerPending) {
186 stopTimerPending =
true;
205 runningLeafAnimations++;
220 runningLeafAnimations--;
221 Q_ASSERT(runningLeafAnimations >= 0);
224int QQmlAnimationTimer::closestPauseAnimationTimeToFinish()
226 int closestTimeToFinish = INT_MAX;
227 for (
int i = 0;
i < runningPauseAnimations.
size(); ++
i) {
236 if (timeToFinish < closestTimeToFinish)
237 closestTimeToFinish = timeToFinish;
239 return closestTimeToFinish;
249 , m_totalCurrentTime(0)
252 , m_uncontrolledFinishTime(-1)
253 , m_currentLoopStartTime(0)
254 , m_hasRegisteredTimer(
false)
257 , m_disableUserControl(
false)
258 , m_hasCurrentTimeChangeListeners(
false)
259 , m_isRenderThreadJob(
false)
260 , m_isRenderThreadProxy(
false)
375 || (oldDirection ==
Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura *
m_loopCount))
376 || (oldDirection ==
Backward && oldCurrentTime == 0)) {
427 return dura * loopcount;
432 msecs =
qMax(msecs, 0);
455 msecs =
qMin(totalDura, msecs);
468 m_currentTime = (dura <= 0) ? msecs : ((msecs - 1) % dura) + 1;
534 qWarning(
"QAbstractAnimationJob::pause: Cannot pause a stopped animation");
544 qWarning(
"QAbstractAnimationJob::resume: "
545 "Cannot resume an animation that is not paused");
650 d <<
"AbstractAnimationJob(" <<
Qt::hex << (
const void *)
this <<
Qt::dec <<
") state:"
657 d <<
"AbstractAnimationJob(null)";
667#include "moc_qabstractanimationjob_p.cpp"
void setDirection(QAbstractAnimationJob::Direction direction)
std::vector< ChangeListener > changeListeners
int totalDuration() const
virtual void debugAnimation(QDebug d) const
virtual void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState)
bool m_hasCurrentTimeChangeListeners
int m_uncontrolledFinishTime
QAbstractAnimationJob::State m_state
virtual int duration() const
int m_currentLoopStartTime
bool m_hasRegisteredTimer
void addAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes)
virtual void updateDirection(QAbstractAnimationJob::Direction direction)
QQmlAnimationTimer * m_timer
virtual ~QAbstractAnimationJob()
void setCurrentTime(int msecs)
QAbstractAnimationJob::State state() const
void fireTopLevelAnimationLoopChanged()
void currentTimeChanged(int currentTime)
bool userControlDisabled() const
void setLoopCount(int loopCount)
bool m_disableUserControl
void currentLoopChanged()
void setDisableUserControl()
virtual void updateLoopCount(int)
QAbstractAnimationJob::Direction m_direction
void stateChanged(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState)
virtual void topLevelAnimationLoopChanged()
QAbstractAnimationJob::Direction direction() const
virtual void updateCurrentTime(int)
void setState(QAbstractAnimationJob::State state)
QAnimationGroupJob * m_group
void setEnableUserControl()
void removeAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes)
Direction direction
the direction of the animation when it is in \l Running state.
int currentLoopTime() const
Returns the current time inside the current loop.
void setCurrentTime(int msecs)
virtual void uncontrolledAnimationFinished(QAbstractAnimationJob *animation)
void removeAnimation(QAbstractAnimationJob *animation)
virtual ~QAnimationJobChangeListener()
qsizetype size() const noexcept
bool isEmpty() const noexcept
void removeAt(qsizetype i)
bool removeOne(const AT &t)
const_reference at(qsizetype i) const noexcept
const QObjectList & children() const
Returns a list of child objects.
void unregisterAnimation(QAbstractAnimationJob *animation)
static QQmlAnimationTimer * instance()
void updateAnimationTimer()
void updateAnimationsTime(qint64 timeStep) override
void registerAnimation(QAbstractAnimationJob *animation, bool isTopLevel)
void restartAnimationTimer() override
static bool designerMode()
static void stopAnimationTimer(QAbstractAnimationTimer *timer)
static void startAnimationTimer(QAbstractAnimationTimer *timer)
void maybeUpdateAnimationsToCurrentTime()
static void resumeAnimationTimer(QAbstractAnimationTimer *timer)
void updateAnimationTimers()
static QUnifiedTimer * instance()
static void pauseAnimationTimer(QAbstractAnimationTimer *timer, int duration)
int duration
the duration of the animation
QSet< QString >::iterator it
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
QDebug operator<<(QDebug d, const QAbstractAnimationJob *job)
#define RETURN_IF_DELETED(func)
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
#define DEFINE_BOOL_CONFIG_OPTION(name, var)
static double elapsed(qint64 after, qint64 before)
static double currentTime()
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept