diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2014-12-09 10:28:25 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-02-13 14:03:47 +0000 |
commit | 5b31071e56ef6e241e27b66ff91f4e9222f2cddb (patch) | |
tree | 6f87fffdc4225cff1ac97f87ef3ab045c4c1e2e1 /examples/quick/demos/photosurface/photosurface.qml | |
parent | 3f3be0fa64f8745b05a417d3e9c8c20da74d5fa9 (diff) |
PinchArea: handle smart zoom gesture
This is the double-finger double-tap trackpad gesture on OS X.
Change-Id: Ie79dc533adf382170867318bc9b61b367f819e9b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Diffstat (limited to 'examples/quick/demos/photosurface/photosurface.qml')
-rw-r--r-- | examples/quick/demos/photosurface/photosurface.qml | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/examples/quick/demos/photosurface/photosurface.qml b/examples/quick/demos/photosurface/photosurface.qml index c7d59ffa9b..fc3b505bcf 100644 --- a/examples/quick/demos/photosurface/photosurface.qml +++ b/examples/quick/demos/photosurface/photosurface.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.4 +import QtQuick 2.5 import QtQuick.Dialogs 1.0 import QtQuick.Window 2.1 import Qt.labs.folderlistmodel 1.0 @@ -104,6 +104,25 @@ Window { pinch.maximumScale: 10 pinch.dragAxis: Pinch.XAndYAxis onPinchStarted: setFrameColor(); + property real zRestore: 0 + onSmartZoom: { + if (pinch.scale > 0) { + photoFrame.rotation = 0; + photoFrame.scale = Math.min(root.width, root.height) / Math.max(image.sourceSize.width, image.sourceSize.height) * 0.85 + photoFrame.x = flick.contentX + (flick.width - photoFrame.width) / 2 + photoFrame.y = flick.contentY + (flick.height - photoFrame.height) / 2 + zRestore = photoFrame.z + photoFrame.z = ++root.highestZ; + } else { + photoFrame.rotation = pinch.previousAngle + photoFrame.scale = pinch.previousScale + photoFrame.x = pinch.previousCenter.x - photoFrame.width / 2 + photoFrame.y = pinch.previousCenter.y - photoFrame.height / 2 + photoFrame.z = zRestore + --root.highestZ + } + } + MouseArea { id: dragArea hoverEnabled: true |