From 07aaa7c1b68f035f71a6ef77d330dddac6a96512 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 31 Mar 2023 20:45:04 +0200 Subject: Fix PinchHandler.persistentTranslation; test cumulative native gestures Since we do not want persistentTranslation to be always the same as target.position, clearly we cannot use xAxis/yAxis to store the initial target position: thus the startPos() function was wrong, and is now removed. We need to store it in a separate m_startTargetPos variable like DragHandler does, and as PinchHandler did before 7867a683fcb938939fb2837a26ac8e1941e3fe08. Add an internal doc comment to clarify the arguments to QQuickItemPrivate::adjustedPosForTransform(). tst_QQuickPinchHandler::cumulativeNativeGestures() now checks the result of adjustedPosForTransform(): how far the target item moved. Pick-to: 6.5 Fixes: QTBUG-111220 Change-Id: I04237cb82a1abaaeab873a0d887acaf322f262ce Reviewed-by: Qt CI Bot Reviewed-by: Richard Moe Gustavsen --- src/quick/items/qquickitem.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/quick/items/qquickitem.cpp') diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index e745e4d110..ba161f5b27 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -5337,13 +5337,30 @@ bool QQuickItemPrivate::transformChanged(QQuickItem *transformedItem) return ret; } +/*! \internal + Returns the new position (proposed values for the x and y properties) + to which this item should be moved to compensate for the given change + in scale from \a startScale to \a activeScale and in rotation from + \a startRotation to \a activeRotation. \a centroidParentPos is the + point that we wish to hold in place (and then apply \a activeTranslation to), + in this item's parent's coordinate system. \a startPos is this item's + position in its parent's coordinate system when the gesture began. + \a activeTranslation is the amount of translation that should be added to + the return value, i.e. the displacement by which the centroid is expected + to move. + + If \a activeTranslation is \c (0, 0) the centroid is to be held in place. + If \a activeScale is \c 1, it means scale is intended to be held constant, + the same as \a startScale. If \a activeRotation is \c 0, it means rotation + is intended to be held constant, the same as \a startRotation. +*/ QPointF QQuickItemPrivate::adjustedPosForTransform(const QPointF ¢roidParentPos, const QPointF &startPos, - const QVector2D &activeTranslation, //[0,0] means no additional translation from startPos + const QVector2D &activeTranslation, qreal startScale, - qreal activeScale, // 1.0 means no additional scale from startScale + qreal activeScale, qreal startRotation, - qreal activeRotation) // 0.0 means no additional rotation from startRotation + qreal activeRotation) { Q_Q(QQuickItem); QVector3D xformOrigin(q->transformOriginPoint()); -- cgit v1.2.3