aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickpinchhandler.cpp
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2019-03-13 13:24:49 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2019-04-02 14:24:32 +0000
commit57c783152f54ea18d0a5a347e9f653bf07c2f446 (patch)
tree774a1b4936ef032df54f03af6e7356191976aa4b /src/quick/handlers/qquickpinchhandler.cpp
parent6a21c23bbb33afe3d318e425a6ea676ec260f716 (diff)
Refactor transform code in pinchhandler to a separate function
This is needed in order for the wheel handler to have the same behavior. Change-Id: I42851789787b8da96618d82227b34c53ace15e9b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickpinchhandler.cpp')
-rw-r--r--src/quick/handlers/qquickpinchhandler.cpp25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp
index 1bee656fc3..4025cd7fbf 100644
--- a/src/quick/handlers/qquickpinchhandler.cpp
+++ b/src/quick/handlers/qquickpinchhandler.cpp
@@ -464,27 +464,10 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event)
const QPointF centroidStartParentPos = target()->parentItem()->mapFromScene(centroid().sceneGrabPosition());
m_activeTranslation = QVector2D(centroidParentPos - centroidStartParentPos);
// apply rotation + scaling around the centroid - then apply translation.
- QMatrix4x4 mat, startMatrix;
-
- const QVector3D centroidParentVector(centroidParentPos);
- mat.translate(centroidParentVector);
- mat.rotate(float(m_activeRotation), 0, 0, 1);
- mat.scale(float(m_activeScale));
- mat.translate(-centroidParentVector);
- mat.translate(QVector3D(m_activeTranslation));
-
- QVector3D xformOrigin(target()->transformOriginPoint());
- startMatrix.translate(float(m_startPos.x()), float(m_startPos.y()));
- startMatrix.translate(xformOrigin);
- startMatrix.scale(float(m_startScale));
- startMatrix.rotate(float(m_startRotation), 0, 0, -1);
- startMatrix.translate(-xformOrigin);
-
- mat = mat * startMatrix;
-
- QPointF xformOriginPoint = target()->transformOriginPoint();
- QPointF pos = mat * xformOriginPoint;
- pos -= xformOriginPoint;
+ QPointF pos = QQuickItemPrivate::get(target())->adjustedPosForTransform(centroidParentPos,
+ m_startPos, m_activeTranslation,
+ m_startScale, m_activeScale,
+ m_startRotation, m_activeRotation);
if (xAxis()->enabled())
pos.setX(qBound(xAxis()->minimum(), pos.x(), xAxis()->maximum()));