diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-05-03 20:33:56 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-05-05 06:17:06 +0200 |
commit | defe68463230b454d3ddfb039ca423c01cddab91 (patch) | |
tree | 2ab1e3d9da35d3532a8f42b2b1d3de7636bdfb22 /src/quick/items | |
parent | db2bf9152013c97753d10ed46b05b59b6ab22849 (diff) |
Make PinchArea translate correctly inside a rotated parent
Also includes 9dacc312e5b0f5aeb0f8370f4f7722b57754a3c2:
fuzzy comparison in the test to avoid failure due to roundoff.
Fixes: QTBUG-63673
Change-Id: I91231bb8555b7eb02a9580f9f184b261d8bd44c8
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 7642205be45135add120373299df02e05f4ffc58)
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items')
-rw-r--r-- | src/quick/items/qquickpincharea.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/quick/items/qquickpincharea.cpp b/src/quick/items/qquickpincharea.cpp index b41815d88b..ed8506b440 100644 --- a/src/quick/items/qquickpincharea.cpp +++ b/src/quick/items/qquickpincharea.cpp @@ -563,7 +563,10 @@ void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering) setKeepTouchGrab(true); d->inPinch = true; if (d->pinch && d->pinch->target()) { - d->pinchStartPos = pinch()->target()->position(); + auto targetParent = pinch()->target()->parentItem(); + d->pinchStartPos = targetParent ? + targetParent->mapToScene(pinch()->target()->position()) : + pinch()->target()->position(); d->pinchStartScale = d->pinch->target()->scale(); d->pinchStartRotation = d->pinch->target()->rotation(); d->pinch->setActive(true); @@ -611,6 +614,9 @@ void QQuickPinchArea::updatePinchTarget() s = qMin(qMax(pinch()->minimumScale(),s), pinch()->maximumScale()); pinch()->target()->setScale(s); QPointF pos = d->sceneLastCenter - d->sceneStartCenter + d->pinchStartPos; + if (auto targetParent = pinch()->target()->parentItem()) + pos = targetParent->mapFromScene(pos); + if (pinch()->axis() & QQuickPinch::XAxis) { qreal x = pos.x(); if (x < pinch()->xmin()) |