diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-06-02 17:31:25 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-06-04 15:23:16 +0200 |
commit | 60d11e1f69470d588666b76092cd40ae5644a855 (patch) | |
tree | adb6040a00687438df7d39f58dafd1bddb305f02 /tests/manual/pointer/map.qml | |
parent | 63b1f379b710c510f00311e03641aa65e72aaf34 (diff) |
Add DragHandler.activeTranslation and persistentTranslation
If you want to set target: null and then bind translation to some
object's x and y properties directly (perhaps an Item, a Qt Quick 3D
Model object, etc.), it's a lot less trouble to use a translation
property that does not keep changing back to 0,0 every time a gesture
begins. In hindsight, the translation property should have been the
persistent one (for consistency with the fix for QTBUG-68941,
in which we made PinchHandler.scale persistent and added activeScale:
b4d31c9ff5f0c5821ea127c663532d9fc2cae43e). But for several years, the
translation property has been restarting with each gesture; so now we
add a persistentTranslation property. The new activeTranslation property
has the same value as the translation property (which is deprecated).
Also, the persistentTranslation property is settable, because
in some UIs there may be multiple ways to move the same object,
and there needs to be a way to sync them up.
Also fixed a bug: when minimumPointCount == 2,
QQuickMultiPointHandler::wantsPointerEvent() doesn't initialize
d->currentPoints until two points are pressed. But often, one point is
pressed, and in the next event, the second point is pressed while the
first is held Stationary. So QQuickHandlerPoint::reset() needs to set
pressPosition and scenePressPosition on both points at the same time,
because it is called on each HandlerPoint in d->currentPoints at that
time when both points are pressed. So if any point is pressed, act as if
they all were freshly pressed. Without this fix, the centroid's
scenePressPosition is wrong (based on the average of 0,0 and the second
point), therefore a "jump" was occurring when persistentTranslation
is used to directly drive a binding (like the tilt in map.qml).
[ChangeLog][QtQuick][Event Handlers] DragHandler.activeTranslation now
holds the amount of movement since the drag gesture began.
DragHandler.persistentTranslation holds the accumulated sum of
movement that has occurred during subsequent drag gestures, and can
be set to arbitrary values between gestures.
Task-number: QTBUG-94168
Change-Id: I1b2f8ea31d0f6ff55ccffe393bc9ba28c1a71d09
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/manual/pointer/map.qml')
-rw-r--r-- | tests/manual/pointer/map.qml | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/manual/pointer/map.qml b/tests/manual/pointer/map.qml index 0e815ccd9c..a45443f562 100644 --- a/tests/manual/pointer/map.qml +++ b/tests/manual/pointer/map.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. @@ -26,7 +26,7 @@ ** ****************************************************************************/ -import QtQuick 2.14 +import QtQuick Item { width: 640 @@ -39,7 +39,13 @@ Item { y: (parent.height - height) / 2 width: image.width height: image.height - transform: Rotation { id: tilt; origin.x: width / 2; origin.y: height / 2; axis { x: 1; y: 0; z: 0 } } + transform: Rotation { + id: tilt + origin.x: width / 2 + origin.y: height / 2 + axis { x: 1; y: 0; z: 0 } + angle: tiltHandler.persistentTranslation.y / -2 + } WheelHandler { id: wheelHandler @@ -82,7 +88,6 @@ Item { maximumPointCount: 2 xAxis.enabled: false target: null - onTranslationChanged: tilt.angle = translation.y / -2 } PinchHandler { |