summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2016-10-25 13:14:52 +0300
committerAntti Määttä <antti.maatta@qt.io>2017-01-27 08:33:49 +0000
commit29807dbcd23b47940311e45bbb789f1be1b8f66d (patch)
tree99e2bd66838a64456ae81f03f663f69675b93d78 /src
parent2395b1fa9b9c5f66fd9c3b175d5eb8635cda6582 (diff)
Add focus to EventForward
Change-Id: I6e8d2c65bfbc3ba0373a119b6c244eb2a634be28 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/render/picking/eventforward.cpp15
-rw-r--r--src/render/picking/eventforward_p.h3
-rw-r--r--src/render/picking/qeventforward.cpp27
-rw-r--r--src/render/picking/qeventforward.h4
-rw-r--r--src/render/picking/qeventforward_p.h3
5 files changed, 52 insertions, 0 deletions
diff --git a/src/render/picking/eventforward.cpp b/src/render/picking/eventforward.cpp
index 7e24557ab..132e022ce 100644
--- a/src/render/picking/eventforward.cpp
+++ b/src/render/picking/eventforward.cpp
@@ -54,6 +54,7 @@ EventForward::EventForward()
: m_target(nullptr)
, m_forwardMouseEvents(false)
, m_forwardKeyboardEvents(false)
+ , m_focus(false)
{
}
@@ -71,6 +72,7 @@ void EventForward::cleanup()
m_coordinateTransform.setToIdentity();
m_forwardMouseEvents = false;
m_forwardKeyboardEvents = false;
+ m_focus = false;
}
QObject *EventForward::target() const
@@ -98,6 +100,11 @@ bool EventForward::forwardKeyboardEvents() const
return m_forwardKeyboardEvents;
}
+bool EventForward::focus() const
+{
+ return m_focus;
+}
+
void EventForward::setTarget(QObject *target)
{
m_target = target;
@@ -123,6 +130,11 @@ void EventForward::setForwardKeyboardEvents(bool enabled)
m_forwardKeyboardEvents = enabled;
}
+void EventForward::setFocus(bool focus)
+{
+ m_focus = focus;
+}
+
void EventForward::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
{
const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QEventForwardData>>(change);
@@ -132,6 +144,7 @@ void EventForward::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr
setCoordinateTransform(data.coordinateTransform);
setForwardMouseEvents(data.forwardMouseEvents);
setForwardKeyboardEvents(data.forwardKeyboardEvents);
+ setFocus(data.focus);
}
void EventForward::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
@@ -150,6 +163,8 @@ void EventForward::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
setForwardMouseEvents(propertyChange->value().toBool());
else if (propertyChange->propertyName() == QByteArrayLiteral("forwardKeyboardEvents"))
setForwardKeyboardEvents(propertyChange->value().toBool());
+ else if (propertyChange->propertyName() == QByteArrayLiteral("focus"))
+ setFocus(propertyChange->value().toBool());
}
BackendNode::sceneChangeEvent(e);
diff --git a/src/render/picking/eventforward_p.h b/src/render/picking/eventforward_p.h
index 1fc56ead2..e090ba5e4 100644
--- a/src/render/picking/eventforward_p.h
+++ b/src/render/picking/eventforward_p.h
@@ -74,12 +74,14 @@ public:
QMatrix4x4 coordinateTransform() const;
bool forwardMouseEvents() const;
bool forwardKeyboardEvents() const;
+ bool focus() const;
void setTarget(QObject *target);
void setCoordinateTransform(const QMatrix4x4 &transform);
void setCoordinateAttribute(const QString &attribute);
void setForwardMouseEvents(bool enabled);
void setForwardKeyboardEvents(bool enabled);
+ void setFocus(bool focus);
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_FINAL;
@@ -94,6 +96,7 @@ private:
QMatrix4x4 m_coordinateTransform;
bool m_forwardMouseEvents;
bool m_forwardKeyboardEvents;
+ bool m_focus;
};
} // Render
diff --git a/src/render/picking/qeventforward.cpp b/src/render/picking/qeventforward.cpp
index 74b52989e..8aa22e276 100644
--- a/src/render/picking/qeventforward.cpp
+++ b/src/render/picking/qeventforward.cpp
@@ -99,6 +99,10 @@ namespace Qt3DRender {
\qmlproperty string Qt3D.Render::EventForward::coordinateAttribute
Holds the name of the coordinate attribute the mouse coordinates are calculated from.
*/
+/*!
+ \qmlproperty bool Qt3D.Render::EventForward::focus
+ Holds whether the QObjectPicker has focus.
+*/
/*!
\property QEventForward::target
@@ -120,7 +124,14 @@ namespace Qt3DRender {
\property QEventForward::coordinateAttribute
Holds the name of the coordinate attribute the mouse coordinates are calculated from.
*/
+/*!
+ \property QEventForward::focus
+ Holds whether the ObjectPicker has focus.
+ */
+/*!
+
+ */
QEventForward::QEventForward(Qt3DCore::QNode *parent)
: Qt3DCore::QNode(*new QEventForwardPrivate(), parent)
{
@@ -206,6 +217,21 @@ void QEventForward::setForwardKeyboardEvents(bool forward)
}
}
+bool QEventForward::focus() const
+{
+ Q_D(const QEventForward);
+ return d->m_focus;
+}
+
+void QEventForward::setFocus(bool focus)
+{
+ Q_D(QEventForward);
+ if (d->m_focus != focus) {
+ d->m_focus = focus;
+ emit focusChanged(focus);
+ }
+}
+
/*!
\internal
*/
@@ -219,6 +245,7 @@ Qt3DCore::QNodeCreatedChangeBasePtr QEventForward::createNodeCreationChange() co
data.coordinateAttribute = d->m_attribute;
data.forwardMouseEvents = d->m_forwardMouseEvents;
data.forwardKeyboardEvents = d->m_forwardKeyboardEvents;
+ data.focus = d->m_focus;
return creationChange;
}
diff --git a/src/render/picking/qeventforward.h b/src/render/picking/qeventforward.h
index 694ad0d2d..28659606b 100644
--- a/src/render/picking/qeventforward.h
+++ b/src/render/picking/qeventforward.h
@@ -58,6 +58,7 @@ class QT3DRENDERSHARED_EXPORT QEventForward : public Qt3DCore::QNode
Q_PROPERTY(bool forwardKeyboardEvents READ forwardKeyboardEvents WRITE setForwardKeyboardEvents NOTIFY forwardKeyboardEventsChanged)
Q_PROPERTY(QMatrix4x4 coordinateTransform READ coordinateTransform WRITE setCoordinateTransform NOTIFY coordinateTransformChanged)
Q_PROPERTY(QString coordinateAttribute READ coordinateAttribute WRITE setCoordinateAttribute NOTIFY coordinateAttributeChanged)
+ Q_PROPERTY(bool focus READ focus WRITE setFocus NOTIFY focusChanged)
public:
explicit QEventForward(Qt3DCore::QNode *parent = nullptr);
@@ -68,6 +69,7 @@ public:
QString coordinateAttribute() const;
bool forwardMouseEvents() const;
bool forwardKeyboardEvents() const;
+ bool focus() const;
public Q_SLOTS:
void setTarget(QObject *target);
@@ -75,6 +77,7 @@ public Q_SLOTS:
void setCoordinateAttribute(const QString &coordinateAttribute);
void setForwardMouseEvents(bool forward);
void setForwardKeyboardEvents(bool forward);
+ void setFocus(bool focus);
Q_SIGNALS:
void targetChanged(QObject *target);
@@ -82,6 +85,7 @@ Q_SIGNALS:
void coordinateAttributeChanged(const QString &coordinateAttribute);
void forwardMouseEventsChanged(bool forward);
void forwardKeyboardEventsChanged(bool forward);
+ void focusChanged(bool focus);
private:
Q_DECLARE_PRIVATE(QEventForward)
diff --git a/src/render/picking/qeventforward_p.h b/src/render/picking/qeventforward_p.h
index be2e832d8..4aa6834df 100644
--- a/src/render/picking/qeventforward_p.h
+++ b/src/render/picking/qeventforward_p.h
@@ -68,6 +68,7 @@ public:
, m_attribute("default")
, m_forwardMouseEvents(true)
, m_forwardKeyboardEvents(false)
+ , m_focus(false)
{
}
@@ -79,6 +80,7 @@ public:
QString m_attribute;
bool m_forwardMouseEvents;
bool m_forwardKeyboardEvents;
+ bool m_focus;
};
struct QEventForwardData
@@ -88,6 +90,7 @@ struct QEventForwardData
QString coordinateAttribute;
bool forwardMouseEvents;
bool forwardKeyboardEvents;
+ bool focus;
};
} // namespace Qt3DRender