aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-01-02 21:00:33 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2019-01-28 12:54:05 +0000
commit63bbaf837976bae45fdd2766da0ed4cc808cc0ac (patch)
tree8cab3b95e6c479d2c4969f72c8b2a628210843e9 /src
parent84b47be6c79761e274454d437b73a1ac2c6789c9 (diff)
PinchHandler: Avoid unwanted translations when axes are disabled
Fixes: QTBUG-72822 Change-Id: I2773ba14fcb24a47fe2ec04860b4aa305a051453 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/handlers/qquickpinchhandler.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp
index e6442e7258..6b18293c86 100644
--- a/src/quick/handlers/qquickpinchhandler.cpp
+++ b/src/quick/handlers/qquickpinchhandler.cpp
@@ -451,10 +451,6 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event)
// 3. Drag/translate
const QPointF centroidStartParentPos = target()->parentItem()->mapFromScene(m_centroid.sceneGrabPosition());
m_activeTranslation = QVector2D(centroidParentPos - centroidStartParentPos);
- if (!xAxis()->enabled())
- m_activeTranslation.setX(0);
- if (!yAxis()->enabled())
- m_activeTranslation.setY(0);
// apply rotation + scaling around the centroid - then apply translation.
QMatrix4x4 mat;
@@ -473,14 +469,16 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event)
if (xAxis()->enabled())
pos.setX(qBound(xAxis()->minimum(), pos.x(), xAxis()->maximum()));
+ else
+ pos.rx() -= m_activeTranslation.x();
if (yAxis()->enabled())
pos.setY(qBound(yAxis()->minimum(), pos.y(), yAxis()->maximum()));
+ else
+ pos.ry() -= m_activeTranslation.y();
target()->setPosition(pos);
target()->setRotation(rotation);
target()->setScale(m_accumulatedScale);
-
- // TODO some translation inadvertently happens; try to hold the chosen pinch origin in place
} else {
m_activeTranslation = QVector2D(m_centroid.scenePosition() - m_centroid.scenePressPosition());
}