aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-09-22 14:23:53 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-09-29 05:16:33 +0000
commitcff0864fa54a8d38f5fba90e6fc99a8c3598a498 (patch)
tree8c28d6fabd7c245d47a1658f4058c0bcae51445e /src
parent930aea8b9ca59a24838cf7f279653e3b2ee40cee (diff)
change the type of DragHandler::translation to QVector2D; document it
For consistency we use QVector2D to represent relative movements in all Pointer Handlers. Change-Id: I23dc20c360b482a995d232e8a6d7e87d9bd8f600 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/handlers/qquickdraghandler.cpp11
-rw-r--r--src/quick/handlers/qquickdraghandler_p.h8
2 files changed, 13 insertions, 6 deletions
diff --git a/src/quick/handlers/qquickdraghandler.cpp b/src/quick/handlers/qquickdraghandler.cpp
index 840459ba3e..5e7b6a4962 100644
--- a/src/quick/handlers/qquickdraghandler.cpp
+++ b/src/quick/handlers/qquickdraghandler.cpp
@@ -103,7 +103,7 @@ void QQuickDragHandler::handleEventPoint(QQuickEventPoint *point)
if (!m_yAxis.enabled())
delta.setY(0);
if (active()) {
- setTranslation(delta);
+ setTranslation(QVector2D(delta));
if (target() && target()->parentItem()) {
QPointF pos = target()->parentItem()->mapFromScene(m_targetStartPos + delta);
enforceAxisConstraints(&pos);
@@ -164,7 +164,7 @@ void QQuickDragHandler::initializeTargetStartPos(QQuickEventPoint *point)
}
}
-void QQuickDragHandler::setTranslation(const QPointF &trans)
+void QQuickDragHandler::setTranslation(const QVector2D &trans)
{
if (trans == m_translation) // fuzzy compare?
return;
@@ -207,4 +207,11 @@ void QQuickDragAxis::setEnabled(bool enabled)
emit enabledChanged();
}
+/*!
+ \readonly
+ \qmlproperty QVector2D QtQuick::DragHandler::translation
+
+ The translation since the gesture began.
+*/
+
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickdraghandler_p.h b/src/quick/handlers/qquickdraghandler_p.h
index b28fb630b8..d10084c654 100644
--- a/src/quick/handlers/qquickdraghandler_p.h
+++ b/src/quick/handlers/qquickdraghandler_p.h
@@ -90,7 +90,7 @@ class Q_AUTOTEST_EXPORT QQuickDragHandler : public QQuickSinglePointHandler
Q_OBJECT
Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT)
Q_PROPERTY(QQuickDragAxis * yAxis READ yAxis CONSTANT)
- Q_PROPERTY(QPointF translation READ translation NOTIFY translationChanged)
+ Q_PROPERTY(QVector2D translation READ translation NOTIFY translationChanged)
public:
explicit QQuickDragHandler(QObject *parent = 0);
@@ -101,8 +101,8 @@ public:
QQuickDragAxis *xAxis() { return &m_xAxis; }
QQuickDragAxis *yAxis() { return &m_yAxis; }
- QPointF translation() const { return m_translation; }
- void setTranslation(const QPointF &trans);
+ QVector2D translation() const { return m_translation; }
+ void setTranslation(const QVector2D &trans);
Q_INVOKABLE void enforceConstraints();
@@ -122,7 +122,7 @@ private:
private:
QPointF m_targetStartPos;
- QPointF m_translation;
+ QVector2D m_translation;
QQuickDragAxis m_xAxis;
QQuickDragAxis m_yAxis;