[gnome-maps] Animate going to turnPoint



commit 4d4f7d1b9bc5e86ffc4f45039cc61765894a38aa
Author: Jonas Danielsson <jonas danielsson threetimestwo org>
Date:   Thu Oct 30 08:25:36 2014 -0400

    Animate going to turnPoint
    
    Set a linear transition and a fixed zoom for going to a
    turning point.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737318

 src/mapView.js         |    2 +-
 src/turnPointMarker.js |   23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 1576974..bc40b95 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -186,7 +186,7 @@ const MapView = new Lang.Class({
         this._turnPointMarker = new TurnPointMarker.TurnPointMarker({ turnPoint: turnPoint,
                                                                       mapView: this });
         this._instructionMarkerLayer.add_marker(this._turnPointMarker);
-        this._turnPointMarker.goToAndSelect(false);
+        this._turnPointMarker.goToAndSelect(true);
     },
 
     showSearchResult: function(place) {
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index c2f2e6a..e5e659c 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -20,8 +20,10 @@
  * Author: Dario Di Nucci <linkin88mail gmail com>
  */
 
+const Clutter = imports.gi.Clutter;
 const Geocode = imports.gi.GeocodeGlib;
 const Lang = imports.lang;
+const Mainloop = imports.mainloop;
 
 const Application = imports.application;
 const MapMarker = imports.mapMarker;
@@ -59,6 +61,27 @@ const TurnPointMarker = new Lang.Class({
                  y: Math.floor(this.height / 2) - 1 };
     },
 
+    goToAndSelect: function(animate) {
+        if (!animate) {
+            this.parent(animate);
+        } else {
+            let view = this._mapView.view;
+            let turnPointZoomLevel = 16;
+
+            view.goto_animation_mode = Clutter.AnimationMode.LINEAR;
+            view.goto_duration = 0;
+
+            Utils.once(view, 'animation-completed::go-to', (function() {
+                view.zoom_level = turnPointZoomLevel;
+                view.center_on(this.place.location.latitude,
+                               this.place.location.longitude);
+                this.selected = true;
+            }).bind(this));
+            view.go_to(this.place.location.latitude,
+                       this.place.location.longitude);
+        }
+    },
+
     _createBubble: function() {
         return new TurnPointBubble.TurnPointBubble({ turnPoint: this.turnPoint,
                                                      place: this.place,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]