mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
mobile/profile: don't pan unless we are zoomed in
This way someone trying to swipe from dive to dive won't inadvertantly pan the profile instead. And panning it really only makes sense when zoomed in in the first place. This could leave us in a situation where we zoom in, pan, zoom out and now the profile is out of whack and we cannot correct it. A simple click on the profile fixes that. The real solution would be some constraining / adjusting as we zoom and pan to ensure we keep things correctly positioned. Maybe I'll figure out the correct way to do this later... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
bba73fdc87
commit
c7dd1e1bab
1 changed files with 38 additions and 10 deletions
|
@ -256,19 +256,35 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
// we want to pan the profile if we are zoomed in, but we want to immediately
|
||||||
drag.target: qmlProfile
|
// pass the mouse events through to the ListView if we are not. That way you
|
||||||
drag.axis: Drag.XAndYAxis
|
// can swipe through the dive list, even if you happen to swipe the profile
|
||||||
drag.smoothed: true
|
property bool isZoomed: qmlProfile.scale - 1.0 > 0.02
|
||||||
pressAndHoldInterval: 50 // very short - feels about right
|
|
||||||
|
// this indicates that we are actually dragging
|
||||||
|
property bool dragging: false
|
||||||
// cursor/finger position as we start dragging
|
// cursor/finger position as we start dragging
|
||||||
property real initialX
|
property real initialX
|
||||||
property real initialY
|
property real initialY
|
||||||
// the offset previously used to show the profile
|
// the offset previously used to show the profile
|
||||||
property real oldXOffset
|
property real oldXOffset
|
||||||
property real oldYOffset
|
property real oldYOffset
|
||||||
// this indicates that we are actually dragging
|
|
||||||
property bool dragging: false
|
// if the profile is not scaled in, don't start panning
|
||||||
|
// but if the profile is scaled in, then start almost immediately
|
||||||
|
pressAndHoldInterval: isZoomed ? 50 : 50000
|
||||||
|
|
||||||
|
// pass events through to the parent and eventually into the ListView
|
||||||
|
propagateComposedEvents: true
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
drag.target: qmlProfile
|
||||||
|
drag.axis: Drag.XAndYAxis
|
||||||
|
drag.smoothed: true
|
||||||
|
onPressed: {
|
||||||
|
if (!isZoomed)
|
||||||
|
mouse.accepted = false
|
||||||
|
}
|
||||||
onPressAndHold: {
|
onPressAndHold: {
|
||||||
dragging = true;
|
dragging = true;
|
||||||
oldXOffset = qmlProfile.xOffset
|
oldXOffset = qmlProfile.xOffset
|
||||||
|
@ -289,13 +305,25 @@ Item {
|
||||||
qmlProfile.xOffset = oldXOffset + x
|
qmlProfile.xOffset = oldXOffset + x
|
||||||
qmlProfile.yOffset = oldYOffset + y
|
qmlProfile.yOffset = oldYOffset + y
|
||||||
qmlProfile.update()
|
qmlProfile.update()
|
||||||
|
} else {
|
||||||
|
mouse.accepted = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
|
if (dragging) {
|
||||||
// reset things
|
// reset things
|
||||||
dragging = false
|
dragging = false
|
||||||
qmlProfile.opacity = 1.0
|
qmlProfile.opacity = 1.0
|
||||||
}
|
}
|
||||||
|
mouse.accepted = false
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
// reset the position if not zoomed in
|
||||||
|
if (!isZoomed) {
|
||||||
|
qmlProfile.xOffset = qmlProfile.yOffset = oldXOffset = oldYOffset = 0
|
||||||
|
mouse.accepted = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue