diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-11-16 18:20:19 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-12-10 03:13:57 +0100 |
commit | 7867a683fcb938939fb2837a26ac8e1941e3fe08 (patch) | |
tree | 271faa101a68abdd55c5c88146ee8bc223a413a8 /examples/quick | |
parent | f064497bd5021e5d28266cabbb703d548f6961b0 (diff) |
Add PinchHandler.scaleAxis, rotationAxis; hold values in axes
Pointer Handlers that manipulate target item properties should now
use QQuickDragAxis consistently to:
- enforce minimum and maximum values
- hold the persistent and active values
- make those available via properties
- emit a new activeValueChanged(delta) signal when the value changes,
so that it's possible to incrementally update a target item
property in JS (onValueDelta: target.property += delta)
In the pinchHandler.qml example, you can use the PinchHandler to adjust
4 properties of one Rectangle independently (it requires coordination).
m_boundedActiveValue controls whether m_activeValue will be
kept between minimum and maximum. For rotation,
tst_QQuickPinchHandler::scaleNativeGesture() expects it to be,
although that seems questionable now, and may be addressed later.
[ChangeLog][QtQuick][Event Handlers] PinchHandler now has scaleAxis and
rotationAxis grouped properties, alongside the existing xAxis and yAxis;
and all of these now have activeValue and persistentValue properties.
The activeValueChanged signal includes a delta value, giving the
incremental change since the previous activeValue. The persistentValue
is settable, in case some target item property can be adjusted in
multiple ways: the handler's stored value can then be synced up with the
item property value after each external change. These features are
also added to DragHandler's xAxis and yAxis properties.
Task-number: QTBUG-68108
Task-number: QTBUG-76380
Task-number: QTBUG-76379
Task-number: QTBUG-94168
Change-Id: I78a5b43e9ba580448ef05054b6c4bc71b1834dd6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'examples/quick')
-rw-r--r-- | examples/quick/pointerhandlers/pinchHandler.qml | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/quick/pointerhandlers/pinchHandler.qml b/examples/quick/pointerhandlers/pinchHandler.qml index f8febc47ee..016bb0c00c 100644 --- a/examples/quick/pointerhandlers/pinchHandler.qml +++ b/examples/quick/pointerhandlers/pinchHandler.qml @@ -142,6 +142,41 @@ Rectangle { TapHandler { gesturePolicy: TapHandler.DragThreshold; onTapped: rect3.z = rect2.z + 1 } MomentumAnimation { id: anim; target: rect3 } } + + Rectangle { + id: rect4 + x: 400 + y: 250 + width: 300 + height: 220 + color: "#609cbc3d" + radius: 10 + antialiasing: true + border { + width: 5 + color: "maroon" + } + PinchHandler { + id: pinch4 + target: null + xAxis.onActiveValueChanged: (delta) => rect4.width = Math.min(500, Math.max(120, 15 * Math.round((rect4.width + delta) / 15))) + yAxis.onActiveValueChanged: (delta) => rect4.opacity = Math.max(0.1, Math.min(0.9, rect4.opacity - delta / 200)) + rotationAxis.onActiveValueChanged: (delta) => rect4.radius = Math.max(0, Math.min(60, rect4.radius + delta)) + scaleAxis.onActiveValueChanged: (delta) => rect4.border.width *= delta + } + Text { + anchors.fill: parent + anchors.margins: rect4.radius / Math.PI + rect4.border.width + text: "Pinch with 2 fingers to tweak various properties" + wrapMode: Text.WordWrap + } + Text { + anchors.top: rect4.bottom + anchors.left: rect4.left + text: "opacity " + rect4.opacity.toFixed(3) + " width " + rect4.width + + " border " + rect4.border.width.toFixed(1) + " radius " + rect4.radius.toFixed(1) + } + } } } Rectangle { |