summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Lundblad <ml@update.uu.se>2021-01-13 22:39:45 +0100
committerMarcus Lundblad <ml@update.uu.se>2021-01-14 23:03:29 +0100
commit505869b8cd53cfb315fa046d8097898e8fc3b36f (patch)
tree024ba8028bbff772da678a0e737c2e627b15017c
parent8531401db3e5b54b419dffad066a888a66e343ed (diff)
downloadgnome-maps-wip/mlundblad/fix-wrap-background.tar.gz
mapView: Don't set dark background pattern when wrappingwip/mlundblad/fix-wrap-background
The wrapping code in libchamplain seems to be broken when setting a background pattern. As a work-around, disable the custom dark background pattern when using the dark them if the view is wrapping around between 180 and -180 degrees longitude.
-rw-r--r--src/mapView.js30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/mapView.js b/src/mapView.js
index d0324c17..f4b72d92 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -167,6 +167,9 @@ var MapView = GObject.registerClass({
Application.geoclue.connect('notify::state',
this._updateUserLocation.bind(this));
this._connectRouteSignals();
+
+ // set dark background if we start up in dark theme
+ this._setBackgroundPatternIfNeeded();
}
_initScale(view) {
@@ -195,6 +198,8 @@ var MapView = GObject.registerClass({
view.horizontal_wrap = true;
view.connect('notify::latitude', this._onViewMoved.bind(this));
+ view.connect('notify::longitude',
+ () => this._setBackgroundPatternIfNeeded());
// switching map type will set view min-zoom-level from map source
view.connect('notify::min-zoom-level', () => {
if (view.min_zoom_level < MapMinZoom) {
@@ -217,12 +222,6 @@ var MapView = GObject.registerClass({
this._gtkSettings = Gtk.Settings.get_default();
this._gtkSettings.connect('notify::gtk-application-prefer-dark-theme',
this._onPreferDarkThemeChanged.bind(this));
- // set dark background if we start up in dark theme
- if (this._gtkSettings.gtk_application_prefer_dark_theme) {
- if (!this._darkBackgroud)
- this._createDarkBackground();
- view.set_background_pattern(this._darkBackground);
- }
this._initScale(view);
return view;
@@ -249,16 +248,29 @@ var MapView = GObject.registerClass({
this._darkBackground.invalidate();
}
- _onPreferDarkThemeChanged() {
- if (this._gtkSettings.gtk_application_prefer_dark_theme) {
+ _isWrappingAround() {
+ let bbox = this.view.get_bounding_box();
+
+ return bbox.left > bbox.right;
+ }
+
+ _setBackgroundPatternIfNeeded() {
+ if (this._gtkSettings.gtk_application_prefer_dark_theme &&
+ !this._isWrappingAround()) {
if (!this._darkBackgroud)
this._createDarkBackground();
this.view.set_background_pattern(this._darkBackground);
- } else {
+ this._customBackgroundSet = true;
+ } else if (this._customBackgroundSet) {
this.view.background_pattern = null;
+ this._customBackgroundSet = false;
}
}
+ _onPreferDarkThemeChanged() {
+ this._setBackgroundPatternIfNeeded();
+ }
+
_onNightModeChanged() {
if (this._mapType === MapType.STREET) {
let overlay_sources = this.view.get_overlay_sources();