diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-03-22 12:16:58 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-03-23 20:49:05 -0700 |
commit | c7dd1e1bab889bf2a55a42d6e9a586938c305884 (patch) | |
tree | 63541878eeb895d9f11f240e4460541af7561b46 | |
parent | bba73fdc87928ee68274b7e2958216cfa8a01939 (diff) | |
download | subsurface-c7dd1e1bab889bf2a55a42d6e9a586938c305884.tar.gz |
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>
-rw-r--r-- | mobile-widgets/qml/DiveDetailsView.qml | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/mobile-widgets/qml/DiveDetailsView.qml b/mobile-widgets/qml/DiveDetailsView.qml index 196c89617..c07cce038 100644 --- a/mobile-widgets/qml/DiveDetailsView.qml +++ b/mobile-widgets/qml/DiveDetailsView.qml @@ -256,19 +256,35 @@ Item { } MouseArea { - anchors.fill: parent - drag.target: qmlProfile - drag.axis: Drag.XAndYAxis - drag.smoothed: true - pressAndHoldInterval: 50 // very short - feels about right + // we want to pan the profile if we are zoomed in, but we want to immediately + // pass the mouse events through to the ListView if we are not. That way you + // can swipe through the dive list, even if you happen to swipe the profile + property bool isZoomed: qmlProfile.scale - 1.0 > 0.02 + + // this indicates that we are actually dragging + property bool dragging: false // cursor/finger position as we start dragging property real initialX property real initialY // the offset previously used to show the profile property real oldXOffset 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: { dragging = true; oldXOffset = qmlProfile.xOffset @@ -289,12 +305,24 @@ Item { qmlProfile.xOffset = oldXOffset + x qmlProfile.yOffset = oldYOffset + y qmlProfile.update() + } else { + mouse.accepted = false } } onReleased: { - // reset things - dragging = false - qmlProfile.opacity = 1.0 + if (dragging) { + // reset things + dragging = false + 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 + } } } } |