Commit 8ad7d0ec authored by Alberto Mardegan's avatar Alberto Mardegan
Browse files

ViewerPage: enable pinching in the move-view mode

Just reparenting the flickable to be a child of the Pinch area is
enough, because the pinch area is inspecting the events from its
children.
parent df1946a2
......@@ -35,71 +35,71 @@ Page {
anchors.fill: parent
enabled: !root.moveViewMode && !parent.pinch.active
}
}
Flickable {
id: flickable
Flickable {
id: flickable
property real __startCenterX: 0
property real __startCenterY: 0
property real __startContentX: 0
property real __startContentY: 0
property real __startCenterX: 0
property real __startCenterY: 0
property real __startContentX: 0
property real __startContentY: 0
anchors.fill: parent
contentWidth: viewer.remoteScreenSize.width * viewer.scale
contentHeight: viewer.remoteScreenSize.height * viewer.scale
bottomMargin: viewer.bottomMargin
leftMargin: viewer.leftMargin
rightMargin: viewer.rightMargin
topMargin: viewer.topMargin
enabled: root.moveViewMode
onContentXChanged: if (moving) updateView()
onContentYChanged: if (moving) updateView()
onMovementStarted: updateOffset()
onMovementEnded: updateContentPosition()
Connections {
target: viewer
enabled: !flickable.moving
onCenterChanged: flickable.updateContentPosition()
onScaleChanged: flickable.updateContentPosition()
}
anchors.fill: parent
contentWidth: viewer.remoteScreenSize.width * viewer.scale
contentHeight: viewer.remoteScreenSize.height * viewer.scale
bottomMargin: viewer.bottomMargin
leftMargin: viewer.leftMargin
rightMargin: viewer.rightMargin
topMargin: viewer.topMargin
enabled: root.moveViewMode
onContentXChanged: if (moving) updateView()
onContentYChanged: if (moving) updateView()
onMovementStarted: updateOffset()
onMovementEnded: updateContentPosition()
Connections {
target: viewer
enabled: !flickable.moving
onCenterChanged: flickable.updateContentPosition()
onScaleChanged: flickable.updateContentPosition()
}
function updateContentPosition() {
var topLeft = viewer.vncToItem(Qt.point(0, 0))
contentX = -topLeft.x
contentY = -topLeft.y
updateOffset()
}
function updateContentPosition() {
var topLeft = viewer.vncToItem(Qt.point(0, 0))
contentX = -topLeft.x
contentY = -topLeft.y
updateOffset()
}
function updateOffset() {
__startContentX = contentX
__startContentY = contentY
__startCenterX = viewer.center.x
__startCenterY = viewer.center.y
}
function updateOffset() {
__startContentX = contentX
__startContentY = contentY
__startCenterX = viewer.center.x
__startCenterY = viewer.center.y
}
function updateView() {
var s = viewer.scale
var cx = (contentX - __startContentX) / s + __startCenterX
var cy = (contentY - __startContentY) / s + __startCenterY
viewer.center = Qt.point(cx, cy)
}
function updateView() {
var s = viewer.scale
var cx = (contentX - __startContentX) / s + __startCenterX
var cy = (contentY - __startContentY) / s + __startCenterY
viewer.center = Qt.point(cx, cy)
}
/* We keep this here for debugging
Rectangle {
color: "red"
opacity: 0.5
width: viewer.remoteScreenSize.width * viewer.scale
height: viewer.remoteScreenSize.height * viewer.scale
/* We keep this here for debugging
Rectangle {
width: parent.width / 2
height: parent.height / 2
color: "blue"
anchors.centerIn: parent
color: "red"
opacity: 0.5
width: viewer.remoteScreenSize.width * viewer.scale
height: viewer.remoteScreenSize.height * viewer.scale
Rectangle {
width: parent.width / 2
height: parent.height / 2
color: "blue"
anchors.centerIn: parent
}
}
*/
}
*/
}
OsdButton {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment