aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-04-24 12:53:58 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-04-28 13:25:49 +0000
commit93563959cd9e64087599a829fc7d6afe22d3b487 (patch)
tree996f0413e727eec47695a8f65205440ca5f6e971 /src/quick
parent8082698fff3ee87d0dfc75cdba0ae21ec523a3fe (diff)
Add and use QQuickPointerSingleHandler::moveTarget()
Until now, DragHandler::pos() was not staying constant during a drag, because we update m_pos from the EventPoint, then move the Item. scenePos() also returns mapToScene(m_pos). If the Item is being dragged to follow the finger or the mouse cursor exactly, unconstrained, then pos() should always be the same as the parent-relative position where the press occurred. Change-Id: Ia02738c0cf458e039cf90371f9c8a7becb75a035 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/handlers/qquickdraghandler.cpp2
-rw-r--r--src/quick/handlers/qquickpointersinglehandler.cpp6
-rw-r--r--src/quick/handlers/qquickpointersinglehandler_p.h2
3 files changed, 9 insertions, 1 deletions
diff --git a/src/quick/handlers/qquickdraghandler.cpp b/src/quick/handlers/qquickdraghandler.cpp
index b4006ab5c7..27edffd65a 100644
--- a/src/quick/handlers/qquickdraghandler.cpp
+++ b/src/quick/handlers/qquickdraghandler.cpp
@@ -107,7 +107,7 @@ void QQuickDragHandler::handleEventPoint(QQuickEventPoint *point)
if (target() && target()->parentItem()) {
QPointF pos = target()->parentItem()->mapFromScene(m_targetStartPos + delta);
enforceAxisConstraints(&pos);
- target()->setPosition(pos);
+ moveTarget(pos, point);
}
} else if (!point->exclusiveGrabber() &&
((m_xAxis.enabled() && QQuickWindowPrivate::dragOverThreshold(delta.x(), Qt::XAxis, point)) ||
diff --git a/src/quick/handlers/qquickpointersinglehandler.cpp b/src/quick/handlers/qquickpointersinglehandler.cpp
index 4e89d71eab..80632303f1 100644
--- a/src/quick/handlers/qquickpointersinglehandler.cpp
+++ b/src/quick/handlers/qquickpointersinglehandler.cpp
@@ -199,6 +199,12 @@ void QQuickPointerSingleHandler::setIgnoreAdditionalPoints(bool v)
m_ignoreAdditionalPoints = v;
}
+void QQuickPointerSingleHandler::moveTarget(QPointF pos, QQuickEventPoint *point)
+{
+ target()->setPosition(pos);
+ m_pos = target()->mapFromScene(point->scenePos());
+}
+
void QQuickPointerSingleHandler::setPressedButtons(Qt::MouseButtons buttons)
{
if (buttons != m_pressedButtons) {
diff --git a/src/quick/handlers/qquickpointersinglehandler_p.h b/src/quick/handlers/qquickpointersinglehandler_p.h
index 70aa26801f..06b8ec45dc 100644
--- a/src/quick/handlers/qquickpointersinglehandler_p.h
+++ b/src/quick/handlers/qquickpointersinglehandler_p.h
@@ -108,6 +108,8 @@ protected:
void setIgnoreAdditionalPoints(bool v = true);
+ void moveTarget(QPointF pos, QQuickEventPoint *point);
+
private:
void setPressedButtons(Qt::MouseButtons buttons);
void reset();