summaryrefslogtreecommitdiffstats
path: root/src/animation/backend/animationutils.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2017-05-07 23:23:01 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2017-06-14 10:41:37 +0000
commite423907090e2ba1a3f5980b2cbf7e7b4fbc37dfe (patch)
tree9f51943060113e181ae49c25f00d58a2aa028ef5 /src/animation/backend/animationutils.cpp
parent920d2e6e2b28ccf8e29d174b1009ef1e2766345b (diff)
Add support for animating a QColor
Using components R, G, B and expecting redF(), greenF() and blueF() in the corresponding keyframes. Change-Id: Ibac1488fe87bdf39d3446b23120114952874a5dc Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/animation/backend/animationutils.cpp')
-rw-r--r--src/animation/backend/animationutils.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp
index ef6aec058..c0287e9f2 100644
--- a/src/animation/backend/animationutils.cpp
+++ b/src/animation/backend/animationutils.cpp
@@ -46,6 +46,7 @@
#include <QtGui/qvector3d.h>
#include <QtGui/qvector4d.h>
#include <QtGui/qquaternion.h>
+#include <QtGui/qcolor.h>
#include <QtCore/qvariant.h>
#include <Qt3DAnimation/private/animationlogging_p.h>
@@ -69,6 +70,7 @@ int componentsForType(int type)
break;
case QVariant::Vector3D:
+ case QVariant::Color:
componentCount = 3;
break;
@@ -149,15 +151,21 @@ ComponentIndices channelComponentsToIndices(const Channel &channel, int dataType
#if defined Q_COMPILER_UNIFORM_INIT
static const QVector<char> standardSuffixes = { 'X', 'Y', 'Z', 'W' };
static const QVector<char> quaternionSuffixes = { 'W', 'X', 'Y', 'Z' };
+ static const QVector<char> colorSuffixes = { 'R', 'G', 'B' };
#else
static const QVector<char> standardSuffixes = (QVector<char>() << 'X' << 'Y' << 'Z' << 'W');
static const QVector<char> quaternionSuffixes = (QVector<char>() << 'W' << 'X' << 'Y' << 'Z');
+ static const QVector<char> colorSuffixes = (QVector<char>() << 'R' << 'G' << 'B');
#endif
- if (dataType != QVariant::Quaternion)
- return channelComponentsToIndicesHelper(channel, dataType, offset, standardSuffixes);
- else
+ switch (dataType) {
+ case QVariant::Quaternion:
return channelComponentsToIndicesHelper(channel, dataType, offset, quaternionSuffixes);
+ case QVariant::Color:
+ return channelComponentsToIndicesHelper(channel, dataType, offset, colorSuffixes);
+ default:
+ return channelComponentsToIndicesHelper(channel, dataType, offset, standardSuffixes);
+ }
}
ComponentIndices channelComponentsToIndicesHelper(const Channel &channel,
@@ -268,6 +276,14 @@ QVector<Qt3DCore::QSceneChangePtr> preparePropertyChanges(Qt3DCore::QNodeId anim
break;
}
+ case QVariant::Color: {
+ const QColor color = QColor::fromRgbF(channelResults[mappingData.channelIndices[0]],
+ channelResults[mappingData.channelIndices[1]],
+ channelResults[mappingData.channelIndices[2]]);
+ v = QVariant::fromValue(color);
+ break;
+ }
+
default:
qWarning() << "Unhandled animation type";
continue;