[gnome-maps/wip/mlundblad/transit-routing: 16/17] turnPointMarker: Add support for showing markers for transit stops
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/transit-routing: 16/17] turnPointMarker: Add support for showing markers for transit stops
- Date: Tue, 30 Aug 2016 21:08:14 +0000 (UTC)
commit 2cd3b20af1ca4786022ac4162f3fa776f4854004
Author: Marcus Lundblad <ml update uu se>
Date: Fri Jul 15 23:46:57 2016 +0200
turnPointMarker: Add support for showing markers for transit stops
src/turnPointMarker.js | 57 +++++++++++++++++++++++++++++++++++++++--------
1 files changed, 47 insertions(+), 10 deletions(-)
---
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index 9bc9036..a48a0c6 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -30,6 +30,8 @@ const MapMarker = imports.mapMarker;
const Place = imports.place;
const Utils = imports.utils;
+const DEFAULT_TRANSIT_COLOR = '000000';
+
const TurnPointMarker = new Lang.Class({
Name: 'TurnPointMarker',
Extends: MapMarker.MapMarker,
@@ -41,12 +43,29 @@ const TurnPointMarker = new Lang.Class({
this._turnPoint = params.turnPoint;
delete params.turnPoint;
+ this._transitStop = params.transitStop;
+ delete params.transitStop;
+
+ this._transitLeg = params.transitLeg;
+ delete params.transitLeg;
+
+ this._defaultColor = params.defaultColor;
+ delete params.defaultColor;
+
+ let latitude;
+ let longitude;
+
+ if (this._turnPoint) {
+ latitude = this._turnPoint.coordinate.get_latitude();
+ longitude = this._turnPoint.coordinate.get_longitude();
+ } else {
+ latitude = this._transitStop.coordinate[0];
+ longitude = this._transitStop.coordinate[1];
+ }
+
params.place = new Place.Place({
- location: new Location.Location({
- latitude: this._turnPoint.coordinate.get_latitude(),
- longitude: this._turnPoint.coordinate.get_longitude()
- })
- });
+ location: new Location.Location({ latitude: latitude,
+ longitude: longitude }) });
this.parent(params);
let actor;
@@ -57,11 +76,7 @@ const TurnPointMarker = new Lang.Class({
}).bind(this));
actor = this._actorFromIconName(this._turnPoint.iconName, 0);
} else {
- // A GNOMEish blue color
- let color = new Gdk.RGBA({ red: 33 / 255,
- green: 93 / 255,
- blue: 156 / 255,
- alpha: 255 });
+ let color = this._getColor();
actor = this._actorFromIconName('maps-point-end-symbolic',
0,
color);
@@ -69,6 +84,28 @@ const TurnPointMarker = new Lang.Class({
this.add_actor(actor);
},
+ _getColor: function() {
+ let color;
+ if (this._turnPoint) {
+ if (this._defaultColor) {
+ color = this._defaultColor;
+ } else {
+ /* A GNOMEish blue color */
+ color = '215D9C';
+ }
+ } else {
+ /* get color from transit leg, if available */
+ color = this._transitLeg.color ?
+ this._transitLeg.color : this._defaultColor;
+ }
+
+ let red = parseInt(color.substring(0, 2), 16) / 255;
+ let green = parseInt(color.substring(2, 4), 16) / 255;
+ let blue = parseInt(color.substring(4, 6), 16) / 255;
+
+ return new Gdk.RGBA({ red: red, green: green, blue: blue, alpha: 255 });
+ },
+
get anchor() {
return { x: Math.floor(this.width / 2) - 1,
y: Math.floor(this.height / 2) - 1 };
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]