[gnome-maps] transitRouteLabel: Override label colors for high contrast mode
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] transitRouteLabel: Override label colors for high contrast mode
- Date: Mon, 16 Oct 2017 19:15:09 +0000 (UTC)
commit a868596168ffceee02d055c7f670262826c80e1d
Author: Marcus Lundblad <ml update uu se>
Date: Tue Oct 10 21:41:43 2017 +0200
transitRouteLabel: Override label colors for high contrast mode
When in high contrast mode, override colors with high contrasting ones.
Except when there's no actual label, as in this case the color could
be more relevant to show, and there's no text to give contrast to.
https://bugzilla.gnome.org/show_bug.cgi?id=788738
src/transitRouteLabel.js | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/transitRouteLabel.js b/src/transitRouteLabel.js
index e33c5e2..16efa36 100644
--- a/src/transitRouteLabel.js
+++ b/src/transitRouteLabel.js
@@ -37,6 +37,10 @@ const OUTLINE_LUMINANCE_THREASHHOLD = 0.9;
*/
const DARK_OUTLINE_LUMINANCE_THREASHHOLD = 0.1;
+// fallback high contrast colors
+const HIGH_CONTRAST_COLOR = '000000';
+const HIGH_CONTRAST_TEXT_COLOR = 'ffffff';
+
var TransitRouteLabel = new Lang.Class({
Name: 'TransitRouteLabel',
Extends: Gtk.Label,
@@ -61,9 +65,19 @@ var TransitRouteLabel = new Lang.Class({
let textColor = leg.textColor;
let label = leg.route;
let usingDarkTheme = Utils.isUsingDarkThemeVariant() && !print;
+ let usingHighContrastTheme = Utils.isUsingHighContrastTheme();
textColor = Color.getContrastingForegroundColor(color, textColor);
+ /* if using the high contrast theme and a label is set, fallback to
+ * hight-contrasting colors, if no label, assume the route color is
+ * more relevant and keep it also for high contrast
+ */
+ if (usingHighContrastTheme && label) {
+ color = HIGH_CONTRAST_COLOR;
+ textColor = HIGH_CONTRAST_TEXT_COLOR;
+ }
+
this._bgRed = Color.parseColor(color, 0);
this._bgGreen = Color.parseColor(color, 1);
this._bgBlue = Color.parseColor(color, 2);
@@ -71,7 +85,6 @@ var TransitRouteLabel = new Lang.Class({
this._fgGreen = Color.parseColor(textColor, 1);
this._fgBlue = Color.parseColor(textColor, 2);
-
if ((!usingDarkTheme &&
Color.relativeLuminance(color) > OUTLINE_LUMINANCE_THREASHHOLD) ||
(usingDarkTheme &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]