[polari] chatView: Consider opacity style property for theme colors



commit 1697d31b823beca0a79b020dae513d11a98a4029
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Jul 4 19:56:35 2016 +0200

    chatView: Consider opacity style property for theme colors
    
    GTK+ has supported an 'opacity' CSS property for a while, and designers
    have used it to dim elements (namely: .dim-label). This is not reflected
    by the return value of gtk_style_context_get_color() though, which returns
    the exact color as defined in the theme. To correctly get the intended
    appearance, we need to apply the opacity to the returned color.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768381

 src/chatView.js |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 5a3cf3c..867a7a7 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -37,6 +37,12 @@ const NICK_SPACING = 14; // space after nicks, matching the following elements
 
 const NICKTAG_PREFIX = 'nick';
 
+function _getColor(context) {
+    let color = context.get_color(context.get_state());
+    color.alpha *= context.get_property('opacity', context.get_state());
+    return color;
+}
+
 // Workaround for GtkTextView growing horizontally over time when
 // added to a GtkScrolledWindow with horizontal scrolling disabled
 const TextView = new Lang.Class({
@@ -59,7 +65,7 @@ const TextView = new Lang.Class({
         context.save();
         context.add_class('dim-label');
         context.set_state(Gtk.StateFlags.NORMAL);
-        this._dimColor = context.get_color(context.get_state());
+        this._dimColor = _getColor(context);
         context.restore();
 
         this.parent();
@@ -396,16 +402,16 @@ const ChatView = new Lang.Class({
         context.save();
         context.add_class('dim-label');
         context.set_state(Gtk.StateFlags.NORMAL);
-        let dimColor = context.get_color(context.get_state());
+        let dimColor = _getColor(context);
         context.restore();
 
         context.save();
         context.set_state(Gtk.StateFlags.LINK);
-        let linkColor = context.get_color(context.get_state());
-        this._activeNickColor = context.get_color(context.get_state());
+        let linkColor = _getColor(context);
+        this._activeNickColor = _getColor(context);
 
         context.set_state(Gtk.StateFlags.LINK | Gtk.StateFlags.PRELIGHT);
-        this._hoveredLinkColor = context.get_color(context.get_state());
+        this._hoveredLinkColor = _getColor(context);
         context.restore();
 
         let desaturatedNickColor = (this._activeNickColor.red +
@@ -421,7 +427,7 @@ const ChatView = new Lang.Class({
         context.save();
         context.add_class('view');
         context.set_state(Gtk.StateFlags.NORMAL);
-        this._statusHeaderHoverColor = context.get_color(context.get_state());
+        this._statusHeaderHoverColor = _getColor(context);
         context.restore();
 
         let buffer = this._view.get_buffer();


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