diff options
author | Chip Collier <gregory.collier@kdab.com> | 2017-07-21 11:02:35 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-07-24 09:02:37 +0000 |
commit | 721c44edfdedb0360181f8160144709867ed8749 (patch) | |
tree | 59f63b8a52a71632fac358b928daef35fb57a0ff /src/animation/frontend | |
parent | e256972b2f1be3a0ccf2a0fa31424171ba856e01 (diff) |
Add clock property to QAbstractClipAnimator
Introduces "clock" property to QAbstractClipAnimator and updates
associated tests. Updated backend animator nodes and associated
evaluation jobs.
Change-Id: Id18cabdd710b9b7253772642f21f63043d316a42
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/animation/frontend')
-rw-r--r-- | src/animation/frontend/qabstractclipanimator.cpp | 26 | ||||
-rw-r--r-- | src/animation/frontend/qabstractclipanimator.h | 5 | ||||
-rw-r--r-- | src/animation/frontend/qabstractclipanimator_p.h | 3 | ||||
-rw-r--r-- | src/animation/frontend/qanimationaspect.cpp | 6 | ||||
-rw-r--r-- | src/animation/frontend/qclipanimator.cpp | 2 |
5 files changed, 41 insertions, 1 deletions
diff --git a/src/animation/frontend/qabstractclipanimator.cpp b/src/animation/frontend/qabstractclipanimator.cpp index 9484aea44..d72085b6e 100644 --- a/src/animation/frontend/qabstractclipanimator.cpp +++ b/src/animation/frontend/qabstractclipanimator.cpp @@ -40,6 +40,7 @@ #include "qabstractclipanimator.h" #include "qabstractclipanimator_p.h" #include <Qt3DAnimation/qchannelmapper.h> +#include <Qt3DAnimation/qclock.h> QT_BEGIN_NAMESPACE @@ -48,6 +49,7 @@ namespace Qt3DAnimation { QAbstractClipAnimatorPrivate::QAbstractClipAnimatorPrivate() : Qt3DCore::QComponentPrivate() , m_mapper(nullptr) + , m_clock(nullptr) , m_running(false) , m_loops(1) { @@ -174,6 +176,12 @@ int QAbstractClipAnimator::loopCount() const return d->m_loops; } +QClock *QAbstractClipAnimator::clock() const +{ + Q_D(const QAbstractClipAnimator); + return d->m_clock; +} + void QAbstractClipAnimator::setRunning(bool running) { Q_D(QAbstractClipAnimator); @@ -213,6 +221,24 @@ void QAbstractClipAnimator::setLoopCount(int loops) emit loopCountChanged(loops); } +void QAbstractClipAnimator::setClock(QClock *clock) +{ + Q_D(QAbstractClipAnimator); + if (d->m_clock == clock) + return; + + if (d->m_clock) + d->unregisterDestructionHelper(d->m_clock); + + if (clock && !clock->parent()) + clock->setParent(this); + d->m_clock = clock; + + if (d->m_clock) + d->registerDestructionHelper(d->m_clock, &QAbstractClipAnimator::setClock, d->m_clock); + emit clockChanged(clock); +} + /*! Starts the animation. */ diff --git a/src/animation/frontend/qabstractclipanimator.h b/src/animation/frontend/qabstractclipanimator.h index bd38fd68b..8fdb114f3 100644 --- a/src/animation/frontend/qabstractclipanimator.h +++ b/src/animation/frontend/qabstractclipanimator.h @@ -49,6 +49,7 @@ namespace Qt3DAnimation { class QAnimationClip; class QChannelMapper; +class QClock; class QAbstractClipAnimatorPrivate; class QT3DANIMATIONSHARED_EXPORT QAbstractClipAnimator : public Qt3DCore::QComponent @@ -57,6 +58,7 @@ class QT3DANIMATIONSHARED_EXPORT QAbstractClipAnimator : public Qt3DCore::QCompo Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) Q_PROPERTY(int loops READ loopCount WRITE setLoopCount NOTIFY loopCountChanged) Q_PROPERTY(Qt3DAnimation::QChannelMapper *channelMapper READ channelMapper WRITE setChannelMapper NOTIFY channelMapperChanged) + Q_PROPERTY(Qt3DAnimation::QClock *clock READ clock WRITE setClock NOTIFY clockChanged) public: enum Loops { Infinite = -1 }; @@ -67,11 +69,13 @@ public: bool isRunning() const; Qt3DAnimation::QChannelMapper *channelMapper() const; int loopCount() const; + Qt3DAnimation::QClock *clock() const; public Q_SLOTS: void setRunning(bool running); void setChannelMapper(Qt3DAnimation::QChannelMapper *channelMapper); void setLoopCount(int loops); + void setClock(Qt3DAnimation::QClock *clock); void start(); void stop(); @@ -80,6 +84,7 @@ Q_SIGNALS: void runningChanged(bool running); void channelMapperChanged(Qt3DAnimation::QChannelMapper *channelMapper); void loopCountChanged(int loops); + void clockChanged(Qt3DAnimation::QClock *clock); protected: explicit QAbstractClipAnimator(Qt3DCore::QNode *parent = nullptr); diff --git a/src/animation/frontend/qabstractclipanimator_p.h b/src/animation/frontend/qabstractclipanimator_p.h index 58553c8c1..4b0ef3339 100644 --- a/src/animation/frontend/qabstractclipanimator_p.h +++ b/src/animation/frontend/qabstractclipanimator_p.h @@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE namespace Qt3DAnimation { class QChannelMapper; +class QClock; class QAbstractClipAnimatorPrivate : public Qt3DCore::QComponentPrivate { @@ -67,6 +68,7 @@ public: Q_DECLARE_PUBLIC(QAbstractClipAnimator) Qt3DAnimation::QChannelMapper *m_mapper; + Qt3DAnimation::QClock *m_clock; bool m_running; int m_loops; }; @@ -74,6 +76,7 @@ public: struct QAbstractClipAnimatorData { Qt3DCore::QNodeId mapperId; + Qt3DCore::QNodeId clockId; bool running; int loops; }; diff --git a/src/animation/frontend/qanimationaspect.cpp b/src/animation/frontend/qanimationaspect.cpp index 00f97d5b6..bb786afff 100644 --- a/src/animation/frontend/qanimationaspect.cpp +++ b/src/animation/frontend/qanimationaspect.cpp @@ -40,6 +40,7 @@ #include "qanimationaspect.h" #include "qanimationaspect_p.h" #include <Qt3DAnimation/qabstractanimationclip.h> +#include <Qt3DAnimation/qclock.h> #include <Qt3DAnimation/qblendedclipanimator.h> #include <Qt3DAnimation/qclipanimator.h> #include <Qt3DAnimation/qchannelmapping.h> @@ -95,7 +96,10 @@ QAnimationAspect::QAnimationAspect(QAnimationAspectPrivate &dd, QObject *parent) registerBackendType<QAbstractAnimationClip>( QSharedPointer<Animation::NodeFunctor<Animation::AnimationClip, Animation::AnimationClipLoaderManager>>::create(d->m_handler.data(), - d->m_handler->animationClipLoaderManager())); + d->m_handler->animationClipLoaderManager())); + registerBackendType<QClock>( + QSharedPointer<Animation::NodeFunctor<Animation::Clock, Animation::ClockManager>>::create(d->m_handler.data(), + d->m_handler->clockManager())); registerBackendType<QClipAnimator>( QSharedPointer<Animation::NodeFunctor<Animation::ClipAnimator, Animation::ClipAnimatorManager>>::create(d->m_handler.data(), d->m_handler->clipAnimatorManager())); diff --git a/src/animation/frontend/qclipanimator.cpp b/src/animation/frontend/qclipanimator.cpp index 3359a70ea..4fe21828f 100644 --- a/src/animation/frontend/qclipanimator.cpp +++ b/src/animation/frontend/qclipanimator.cpp @@ -41,6 +41,7 @@ #include "qclipanimator_p.h" #include <Qt3DAnimation/qabstractanimationclip.h> #include <Qt3DAnimation/qchannelmapper.h> +#include <Qt3DAnimation/qclock.h> #include <Qt3DAnimation/private/qanimationcallbacktrigger_p.h> QT_BEGIN_NAMESPACE @@ -161,6 +162,7 @@ Qt3DCore::QNodeCreatedChangeBasePtr QClipAnimator::createNodeCreationChange() co Q_D(const QClipAnimator); data.clipId = Qt3DCore::qIdForNode(d->m_clip); data.mapperId = Qt3DCore::qIdForNode(d->m_mapper); + data.clockId = Qt3DCore::qIdForNode(d->m_clock); data.running = d->m_running; data.loops = d->m_loops; return creationChange; |