[libadwaita/wip/exalm/selection-color: 9/9] stylesheet: Overhaul text selection




commit 430d5b5c5430da6c4ee5456ed623ce07e651ccff
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon May 3 17:54:18 2021 +0500

    stylesheet: Overhaul text selection
    
    Use transparent blue for focused and transparent grey otherwise.
    
    Consolidate the selection styles in one place since they are identical
    in every widget now.
    
    Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/109
    Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/139

 src/stylesheet/_common.scss              | 11 +++++++++++
 src/stylesheet/widgets/_entries.scss     |  6 +-----
 src/stylesheet/widgets/_labels.scss      |  5 -----
 src/stylesheet/widgets/_spin-button.scss |  1 -
 src/stylesheet/widgets/_views.scss       |  2 --
 5 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/src/stylesheet/_common.scss b/src/stylesheet/_common.scss
index c6d071e..17dbc66 100644
--- a/src/stylesheet/_common.scss
+++ b/src/stylesheet/_common.scss
@@ -50,6 +50,17 @@ dnd {
   &:disabled { color: mix($selected_fg_color, $selected_bg_color, 50%); }
 }
 
+/* Text selection */
+
+selection {
+  background-color: transparentize($text_color, 0.9);
+  color: transparent;
+
+  &:focus-within {
+    background-color: transparentize($selected_bg_color, 0.7);
+  }
+}
+
 :not(window):drop(active):focus,
 :not(window):drop(active) { // FIXME needs to be done widget by widget, this wildcard should really die
   border-color: $drop_target_color;
diff --git a/src/stylesheet/widgets/_entries.scss b/src/stylesheet/widgets/_entries.scss
index 8ff330e..efa1511 100644
--- a/src/stylesheet/widgets/_entries.scss
+++ b/src/stylesheet/widgets/_entries.scss
@@ -21,10 +21,6 @@ entry {
       > block-cursor {
         @include entry(block_cursor);
       }
-
-      > selection {
-        @extend %selected_items;
-      }
     }
 
     &.flat {
@@ -47,7 +43,7 @@ entry {
 
         @include focus-ring($focus-state: 'focus-within', $fc: transparentize($e_color, 0.5));
 
-        > text > selection { background-color: $e_color; }
+        > text > selection:focus-within { background-color: transparentize($e_color, .8); }
       }
     }
 
diff --git a/src/stylesheet/widgets/_labels.scss b/src/stylesheet/widgets/_labels.scss
index d9decbc..297eeb9 100644
--- a/src/stylesheet/widgets/_labels.scss
+++ b/src/stylesheet/widgets/_labels.scss
@@ -5,11 +5,6 @@ label {
     @extend .dim-label;
   }
 
-  > selection {
-    background-color: $selected_bg_color;
-    color: $selected_fg_color;
-  }
-
   &:disabled {
     filter: opacity(0.5);
   }
diff --git a/src/stylesheet/widgets/_spin-button.scss b/src/stylesheet/widgets/_spin-button.scss
index 578217c..e8d4a56 100644
--- a/src/stylesheet/widgets/_spin-button.scss
+++ b/src/stylesheet/widgets/_spin-button.scss
@@ -109,7 +109,6 @@ spinbutton {
       padding: 0;
       border-radius: 0;
 
-      > selection { @extend %selected_items; }
       > block-cursor { @include entry(block_cursor); }
     }
 
diff --git a/src/stylesheet/widgets/_views.scss b/src/stylesheet/widgets/_views.scss
index 50167b8..3484116 100644
--- a/src/stylesheet/widgets/_views.scss
+++ b/src/stylesheet/widgets/_views.scss
@@ -20,8 +20,6 @@
 textview {
   > text {
     @extend %view;
-
-    > selection { &:focus, & { @extend %selected_items; }}
   }
 
   > border {


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