[gnome-shell] st/scroll-view-fade: Don't assume fade area at (0,0)



commit 5d65a424a8eecc3ffc88d028db71cd9f8bd9158c
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jan 14 16:58:20 2021 +0100

    st/scroll-view-fade: Don't assume fade area at (0,0)
    
    The shader code currently only accounts for padding for the
    bottom and right fades, but not for top and left.
    
    As a result, we only fade the right edge when swiping through app
    picker pages, whoops.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1569>

 src/st/st-scroll-view-fade.glsl | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/st/st-scroll-view-fade.glsl b/src/st/st-scroll-view-fade.glsl
index 9180aa1843..2eacfd9af5 100644
--- a/src/st/st-scroll-view-fade.glsl
+++ b/src/st/st-scroll-view-fade.glsl
@@ -44,16 +44,18 @@ void main ()
     if (x > fade_area_topleft[0] && x < fade_area_bottomright[0] &&
         y > fade_area_topleft[1] && y < fade_area_bottomright[1]) {
         float ratio = 1.0;
+        float fade_top_start = fade_area_topleft[1] + vfade_offset;
+        float fade_left_start = fade_area_topleft[0] + hfade_offset;
         float fade_bottom_start = fade_area_bottomright[1] - vfade_offset;
         float fade_right_start = fade_area_bottomright[0] - hfade_offset;
         bool fade_top = y < vfade_offset && fade_edges_top;
         bool fade_bottom = y > fade_bottom_start && fade_edges_bottom;
-        bool fade_left = x < hfade_offset && fade_edges_left;
+        bool fade_left = x < fade_left_start && fade_edges_left;
         bool fade_right = x > fade_right_start && fade_edges_right;
 
         float vfade_scale = height / vfade_offset;
         if (fade_top) {
-            ratio *= y / vfade_offset;
+            ratio *= (fade_area_topleft[1] - y) / (fade_area_topleft[1] - fade_bottom_start);
         }
 
         if (fade_bottom) {
@@ -62,7 +64,7 @@ void main ()
 
         float hfade_scale = width / hfade_offset;
         if (fade_left) {
-            ratio *= x / hfade_offset;
+            ratio *= (fade_area_topleft[0] - x) / (fade_area_topleft[0] - fade_left_start);
         }
 
         if (fade_right) {


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