diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-02-25 16:53:15 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-02-29 10:55:52 +0000 |
commit | cc385cae0fc43d9d4090280e9d2b5699759e2b1d (patch) | |
tree | ffc13b43a073f1b9047dc74f0e8a6fc15df0e427 /src/input/frontend/qaxis.cpp | |
parent | 2d197c6c1226cba097a5a0a100776c62a37472a7 (diff) |
QAxis: add value property
Change-Id: Ibfa241029b3906b4cbe94789c4b12565aec2a335
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input/frontend/qaxis.cpp')
-rw-r--r-- | src/input/frontend/qaxis.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/input/frontend/qaxis.cpp b/src/input/frontend/qaxis.cpp index b463f041e..11a001594 100644 --- a/src/input/frontend/qaxis.cpp +++ b/src/input/frontend/qaxis.cpp @@ -50,10 +50,22 @@ class QAxisPrivate : public Qt3DCore::QNodePrivate public: QAxisPrivate() : Qt3DCore::QNodePrivate() + , m_value(0.0f) {} + Q_DECLARE_PUBLIC(QAxis) + QString m_name; QVector<QAxisInput *> m_inputs; + float m_value; + + void setValue(float value) + { + if (value != m_value) { + m_value = value; + q_func()->valueChanged(m_value); + } + } }; /*! @@ -137,6 +149,12 @@ QVector<QAxisInput *> QAxis::inputs() const return d->m_inputs; } +float QAxis::value() const +{ + Q_D(const QAxis); + return d->m_value; +} + void QAxis::copy(const Qt3DCore::QNode *ref) { QNode::copy(ref); @@ -147,6 +165,15 @@ void QAxis::copy(const Qt3DCore::QNode *ref) } +void QAxis::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) +{ + Q_D(QAxis); + Qt3DCore::QScenePropertyChangePtr e = qSharedPointerCast<Qt3DCore::QScenePropertyChange>(change); + if (e->type() == Qt3DCore::NodeUpdated && e->propertyName() == QByteArrayLiteral("value")) { + d->setValue(e->value().toFloat()); + } +} + } // Qt3DInput QT_END_NAMESPACE |