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
frameworks
Marco Martin 11 years ago
parent be805e906e
commit c8838e94c9
  1. 18
      mobile/components/DocumentView.qml

@ -32,8 +32,12 @@ QtControls.ScrollView {
id: root id: root
property DocumentItem document property DocumentItem document
property PageItem page: mouseArea.currPageDelegate.pageItem property PageItem page: mouseArea.currPageDelegate.pageItem
onWidthChanged: resizeTimer.restart()
onHeightChanged: resizeTimer.restart()
Flickable { Flickable {
id: flick id: flick
anchors.fill: parent
clip: true clip: true
@ -41,8 +45,6 @@ QtControls.ScrollView {
flick.contentWidth = flick.width flick.contentWidth = flick.width
flick.contentHeight = flick.width / mouseArea.currPageDelegate.pageRatio flick.contentHeight = flick.width / mouseArea.currPageDelegate.pageRatio
} }
onWidthChanged: resizeTimer.restart()
onHeightChanged: resizeTimer.restart()
Connections { Connections {
target: root.document target: root.document
onPathChanged: resizeTimer.restart() onPathChanged: resizeTimer.restart()
@ -74,7 +76,17 @@ QtControls.ScrollView {
flick.contentY += pinch.previousCenter.y - pinch.center.y flick.contentY += pinch.previousCenter.y - pinch.center.y
// resize content // 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(); flick.returnToBounds();
} }
MouseArea { MouseArea {

Loading…
Cancel
Save