[PATCH] Make the map widget more pleasant to use

Linus Torvalds torvalds at linux-foundation.org
Mon Oct 23 07:26:26 PDT 2017


From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Mon, 23 Oct 2017 10:04:33 -0400
Subject: [PATCH] Make the map widget more pleasant to use

This does two main things to the map widget:

 - if there are no coordinates, do *not* zoom out to the whole-world
   view. Just leave the map alone.

 - when zooming out to move to a new dive site, zoom back in to the same
   zoom level it was before.

These two changes make it much more pleasant to move between dives,
particularly as you move back-and-forth without losing the zoom level.

NOTE! The zoom level gets reset if you move dives _while_ zooming is
happening, and so moving quickly between dives will still end up losing
the original zoom level, replacing it with a bigger zoom-out that was
active _during_ a previous zoom.

That could be seen as a feature (moving incrementally to an "overview"
zoom when moving quickly between dive sites), but honestly it smells
more like a bug to me.  But regardless of that feature/bug, this new
zoom behavior is more pleasant than our older "always reset when
moving".

But it might be a matter of taste, so people should try this out and
comment.

Signed-off-by: Linus Torvalds <torvalds at linux-foundation,org>
Cc: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 mobile-widgets/qml/MapWidget.qml | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml
index d291dd4d7..c467b9b21 100644
--- a/mobile-widgets/qml/MapWidget.qml
+++ b/mobile-widgets/qml/MapWidget.qml
@@ -152,14 +152,13 @@ Item {
 
 		function centerOnCoordinate(coord) {
 			stopZoomAnimations()
-			newCenter = coord
 			if (coord.latitude === 0.0 && coord.longitude === 0.0) {
-				newZoom = 2.6
-				newZoomOut = newZoom
+				// Do nothing
 			} else {
 				var newZoomOutFound = false
 				var zoomStored = zoomLevel
 				newZoomOut = zoomLevel
+				newCenter = coord
 				while (zoomLevel > minimumZoomLevel) {
 					var pt = fromCoordinate(coord)
 					if (pointIsVisible(pt)) {
@@ -172,22 +171,21 @@ Item {
 				if (!newZoomOutFound)
 					newZoomOut = defaultZoomOut
 				zoomLevel = zoomStored
-				newZoom = defaultZoomIn
+				newZoom = zoomStored
+				mapAnimationZoomIn.restart()
+				mapAnimationZoomOut.stop()
 			}
-			mapAnimationZoomIn.restart()
-			mapAnimationZoomOut.stop()
 		}
 
 		function centerOnRectangle(topLeft, bottomRight, centerRect) {
 			stopZoomAnimations()
-			newCenter = centerRect
 			if (newCenter.latitude === 0.0 && newCenter.longitude === 0.0) {
-				newZoom = 2.6
-				newZoomOut = newZoom
+				// Do nothing
 			} else {
 				var centerStored = QtPositioning.coordinate(center.latitude, center.longitude)
 				var zoomStored = zoomLevel
 				var newZoomOutFound = false
+				newCenter = centerRect
 				// calculate zoom out
 				newZoomOut = zoomLevel
 				while (zoomLevel > minimumZoomLevel) {
@@ -219,13 +217,13 @@ Item {
 					newZoom = defaultZoomIn
 				zoomLevel = zoomStored
 				center = centerStored
+				mapAnimationZoomIn.restart()
+				mapAnimationZoomOut.stop()
 			}
-			mapAnimationZoomIn.restart()
-			mapAnimationZoomOut.stop()
 		}
 
 		function deselectMapLocation() {
-			animateMapZoomOut()
+			stopZoomAnimations()
 		}
 	}
 
-- 
2.14.1.729.g59c0ea183



More information about the subsurface mailing list