summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Martin <notmart@gmail.com>2015-09-25 14:33:46 (GMT)
committerMarco Martin <notmart@gmail.com>2015-09-25 14:33:46 (GMT)
commitc8838e94c9c6baba9ccc3bee0d8b5f8817ddb7d6 (patch)
tree913c1ce5c0e2658385ee3a772b532fbe3bde6463
parentbe805e906ea9dae6c31af65e57618d1c8f694b70 (diff)
directly scale the content item when pinching
when pinching, just scale the item, this scales the texture with the GPU, avoiding costrly redraws. redraw at the correct size only when the gesture ends
-rw-r--r--mobile/components/DocumentView.qml18
1 files changed, 15 insertions, 3 deletions
diff --git a/mobile/components/DocumentView.qml b/mobile/components/DocumentView.qml
index c953892..117c6be 100644
--- a/mobile/components/DocumentView.qml
+++ b/mobile/components/DocumentView.qml
@@ -32,8 +32,12 @@ QtControls.ScrollView {
id: root
property DocumentItem document
property PageItem page: mouseArea.currPageDelegate.pageItem
+
+ onWidthChanged: resizeTimer.restart()
+ onHeightChanged: resizeTimer.restart()
Flickable {
id: flick
+ anchors.fill: parent
clip: true
@@ -41,8 +45,6 @@ QtControls.ScrollView {
flick.contentWidth = flick.width
flick.contentHeight = flick.width / mouseArea.currPageDelegate.pageRatio
}
- onWidthChanged: resizeTimer.restart()
- onHeightChanged: resizeTimer.restart()
Connections {
target: root.document
onPathChanged: resizeTimer.restart()
@@ -74,7 +76,17 @@ QtControls.ScrollView {
flick.contentY += pinch.previousCenter.y - pinch.center.y
// resize content
- flick.resizeContent(Math.max(flick.width+1, initialWidth * pinch.scale), Math.max(flick.height, initialHeight * pinch.scale), pinch.center);
+ //use the scale property during pinch, for speed reasons
+ if (initialHeight * pinch.scale > flick.height &&
+ initialHeight * pinch.scale < flick.height * 3) {
+ mouseArea.scale = pinch.scale;
+ }
+ flick.returnToBounds();
+ }
+ onPinchFinished: {
+ flick.resizeContent(Math.max(flick.width+1, initialWidth * mouseArea.scale), Math.max(flick.height, initialHeight * mouseArea.scale), pinch.center);
+ mouseArea.scale = 1;
+
flick.returnToBounds();
}
MouseArea {