diff options
-rw-r--r-- | flickabletest/flickabletest.pro | 4 | ||||
-rw-r--r-- | flickabletest/image2.png | bin | 0 -> 14396 bytes | |||
-rw-r--r-- | flickabletest/main.qml | 83 |
3 files changed, 87 insertions, 0 deletions
diff --git a/flickabletest/flickabletest.pro b/flickabletest/flickabletest.pro new file mode 100644 index 0000000..88c0d60 --- /dev/null +++ b/flickabletest/flickabletest.pro @@ -0,0 +1,4 @@ + +TEMPLATE = subdirs + +# Directories diff --git a/flickabletest/image2.png b/flickabletest/image2.png Binary files differnew file mode 100644 index 0000000..c70d505 --- /dev/null +++ b/flickabletest/image2.png diff --git a/flickabletest/main.qml b/flickabletest/main.qml new file mode 100644 index 0000000..9a68f5c --- /dev/null +++ b/flickabletest/main.qml @@ -0,0 +1,83 @@ +import Qt 4.7 +import Qt.labs.gestures 2.0 + +Rectangle { + id: topWin + width: 200 + height: 200 + color: "#ff0000" + + function calculateBoundingBox(angle) { + angle = angle*Math.PI/180 + var sin = Math.abs(Math.sin(angle)) + var cos = Math.abs(Math.cos(angle)) + flicktarget.height = (sin*pinchable.width) + (cos*pinchable.height) + flicktarget.width = (sin*pinchable.height) + (cos*pinchable.width) + } + + + Flickable { + id: flickable + anchors.fill: parent + contentWidth: flicktarget.width; contentHeight: flicktarget.height + + GestureArea { + anchors.fill: parent + + Pinch { + onUpdated: { + if (gesture.changeFlags & PinchGesture.RotationAngleChanged) + pinchable.rotation += gesture.rotationAngle - gesture.lastRotationAngle + if (gesture.changeFlags & PinchGesture.ScaleFactorChanged) { + pinchable.width *= gesture.scaleFactor + pinchable.height *= gesture.scaleFactor + } + calculateBoundingBox(pinchable.rotation) + } + } + } + + Rectangle { + id: flicktarget + width: topWin.width + height: topWin.height + + Image { + id: pinchable + source: "image2.png" + anchors.centerIn: parent + width: topWin.width + height: topWin.height + + clip: true + } + + } + + + } + + Rectangle { + x: 826 + y: 0 + width: 40 + height: 40 + color: "grey" + Text { + anchors.centerIn: parent + text: "exit" + font.bold: true + font.pointSize: 12 + } + GestureArea { + anchors.fill: parent + Tap { + onFinished: { + Qt.quit() + } + } + } + } +} + + |