diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-06-15 15:17:04 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-06-23 10:05:22 +0000 |
commit | 6f40494310dab964600375f04391f21b4eccdb44 (patch) | |
tree | a2dc6542a70672c3bf901a36723cff35089b6b11 /src/animation/backend/clipanimator.cpp | |
parent | 11f092ce7c555814baeffc204f7fadc0f36fdcbb (diff) |
Add support for animation callbacks
Let QChannelMapping optionally specify a callback, which then gets
invoked either directly on a worker thread or the gui thread.
Change-Id: I871776f47cc921ceb254f9dc1a7b89ae5c5618d8
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/animation/backend/clipanimator.cpp')
-rw-r--r-- | src/animation/backend/clipanimator.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/animation/backend/clipanimator.cpp b/src/animation/backend/clipanimator.cpp index 65fd0f57f..ea31698d0 100644 --- a/src/animation/backend/clipanimator.cpp +++ b/src/animation/backend/clipanimator.cpp @@ -40,6 +40,7 @@ #include <Qt3DAnimation/private/animationclip_p.h> #include <Qt3DAnimation/private/managers_p.h> #include <Qt3DAnimation/private/animationlogging_p.h> +#include <Qt3DAnimation/private/qanimationcallbacktrigger_p.h> #include <Qt3DCore/qpropertyupdatedchange.h> #include <Qt3DCore/private/qpropertyupdatedchangebase_p.h> @@ -129,6 +130,21 @@ void ClipAnimator::sendPropertyChanges(const QVector<Qt3DCore::QSceneChangePtr> notifyObservers(change); } +void ClipAnimator::sendCallbacks(const QVector<AnimationCallbackAndValue> &callbacks) +{ + for (const AnimationCallbackAndValue &callback : callbacks) { + if (callback.flags.testFlag(QAnimationCallback::OnThreadPool)) { + callback.callback->valueChanged(callback.value); + } else { + auto e = QAnimationCallbackTriggerPtr::create(peerId()); + e->setCallback(callback.callback); + e->setValue(callback.value); + e->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes); + notifyObservers(e); + } + } +} + } // namespace Animation } // namespace Qt3DAnimation |