diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-03-31 20:45:04 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-04-11 17:27:42 +0200 |
commit | 07aaa7c1b68f035f71a6ef77d330dddac6a96512 (patch) | |
tree | c05054c32642c5a26319b381a76685fdee61806e /src/quick/items/qquickitem.cpp | |
parent | 79d61b3ab7fcc75454b81d5e78d4f404a9c4bd6c (diff) |
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 <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r-- | src/quick/items/qquickitem.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
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()); |