[gnome-maps] mapView: Do not animate to stored location
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] mapView: Do not animate to stored location
- Date: Wed, 31 Jul 2019 18:57:07 +0000 (UTC)
commit 8b9057036a46b1ad03e9a998b34b2a596b533c92
Author: James Westman <flyingpimonster flyingpimonster net>
Date: Tue Jul 16 21:58:33 2019 -0500
mapView: Do not animate to stored location
This avoids the gotoBBox function, which uses animations, and instead
sets the zoom level and calls center_on() on the view.
This involves storing the last viewed location by coordinates and zoom
level rather than by a bounding box. A migration path is provided so
that the old bounding boxes use the old, animated method.
data/org.gnome.Maps.gschema.xml | 7 ++++++-
src/mapView.js | 38 ++++++++++++++++++++------------------
2 files changed, 26 insertions(+), 19 deletions(-)
---
diff --git a/data/org.gnome.Maps.gschema.xml b/data/org.gnome.Maps.gschema.xml
index 640f6be..dae9ad9 100644
--- a/data/org.gnome.Maps.gschema.xml
+++ b/data/org.gnome.Maps.gschema.xml
@@ -7,10 +7,15 @@
</enum>
<schema id="org.gnome.Maps" path="/org/gnome/maps/">
<key type="ad" name="last-viewed-location">
- <default>[0.0,0.0,0.0,0.0]</default>
+ <default>[0.0,0.0]</default>
<summary>last viewed location</summary>
<description>Coordinates of last viewed location.</description>
</key>
+ <key type="i" name="zoom-level">
+ <default>0</default>
+ <summary>zoom</summary>
+ <description>Zoom level</description>
+ </key>
<key name="window-size" type="ai">
<default>[768, 600]</default>
<summary>Window size</summary>
diff --git a/src/mapView.js b/src/mapView.js
index 703ee5b..90aaf16 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -180,11 +180,6 @@ var MapView = GObject.registerClass({
_initView() {
let view = this.get_view();
- // Start all the way zoomed out and centered on (0, 0)
- // This way you can see the whole map on startup
- view.zoom_level = MapMinZoom;
- view.center_on(0, 0);
-
view.min_zoom_level = MapMinZoom;
view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_OUT_CUBIC;
view.reactive = true;
@@ -192,7 +187,7 @@ var MapView = GObject.registerClass({
view.horizontal_wrap = true;
if (Application.normalStartup)
- view.connect('notify::realized', this._goToStoredLocation.bind(this));
+ this._goToStoredLocation(view);
view.connect('notify::latitude', this._onViewMoved.bind(this));
// switching map type will set view min-zoom-level from map source
view.connect('notify::min-zoom-level', () => {
@@ -460,21 +455,28 @@ var MapView = GObject.registerClass({
}
_storeLocation() {
- let box = this.view.get_bounding_box();
- let lastViewedLocation = [box.top, box.bottom, box.left, box.right];
- Application.settings.set('last-viewed-location', lastViewedLocation);
+ Application.settings.set('zoom-level', this.view.zoom_level);
+ let location = [this.view.latitude, this.view.longitude];
+ Application.settings.set('last-viewed-location', location);
}
- _goToStoredLocation() {
- if (!this.view.realized)
- return;
+ _goToStoredLocation(view) {
+ let location = Application.settings.get('last-viewed-location');
- let box = Application.settings.get('last-viewed-location');
- let bounding_box = new Champlain.BoundingBox({ top: box[0],
- bottom: box[1],
- left: box[2],
- right: box[3] });
- this.gotoBBox(bounding_box, true);
+ if (location.length === 2) {
+ view.zoom_level = Application.settings.get('zoom-level');
+ view.center_on(location[0], location[1]);
+ } else {
+ /* bounding box. for backwards compatibility, not used anymore */
+ let bbox = new Champlain.BoundingBox({ top: location[0],
+ bottom: location[1],
+ left: location[2],
+ right: location[3] });
+ view.connect("notify::realized", () => {
+ if (view.realized)
+ this.gotoBBox(bbox, true);
+ });
+ }
}
gotoBBox(bbox, linear) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]