[libadwaita/wip/exalm/treeview-fix] stylesheet: Fix treeview accel editor color




commit 0dddb7568f7dd8467c4bb3dbfcf19664fd91d475
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu May 20 00:02:41 2021 +0500

    stylesheet: Fix treeview accel editor color
    
    It should be grey like the row selection. It's also overlaid on top of the
    row so it can't be transparent and has to be pre-blended on top of the
    background color.

 src/stylesheet/_common.scss        | 12 ++++++++++++
 src/stylesheet/widgets/_trees.scss |  8 +++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/src/stylesheet/_common.scss b/src/stylesheet/_common.scss
index e7072a3e..ae48c7ce 100644
--- a/src/stylesheet/_common.scss
+++ b/src/stylesheet/_common.scss
@@ -2,6 +2,18 @@
   @return unquote("alpha(#{$c},#{$a})");
 }
 
+@function blend($bg, $fg) {
+  /* $bg must be opaque */
+
+  $_a: alpha($fg);
+
+  @return rgb(
+    red($bg)   * (1 - $_a) + red($fg)   * $_a,
+    green($bg) * (1 - $_a) + green($fg) * $_a,
+    blue($bg)  * (1 - $_a) + blue($fg)  * $_a,
+  );
+}
+
 $ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
 $backdrop_transition: 200ms ease-out;
 $button_transition: all 200ms $ease-out-quad;
diff --git a/src/stylesheet/widgets/_trees.scss b/src/stylesheet/widgets/_trees.scss
index 04a6b698..bdc5aa4c 100644
--- a/src/stylesheet/widgets/_trees.scss
+++ b/src/stylesheet/widgets/_trees.scss
@@ -115,7 +115,13 @@ treeview.view {
     }
   }
 
-  acceleditor > label { background-color: $selected_bg_color; } // see tests/testaccel to test
+  acceleditor > label {
+    // see tests/testaccel in GTK to test
+    // the editor is overlaid on top of the selected row, and the background
+    // color must match it. Of course it means it can't be opaque so we blend
+    // it onto the default background instead
+    background-color: blend($base_color, $menu_selected_color);
+  }
 }
 
 %column_header_button {


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