Răsfoiți Sursa

add platform specific compensation levels.

Dan Walmsley 5 ani în urmă
părinte
comite
7b7411a3a2

+ 7 - 0
src/Avalonia.Controls/AcrylicPlatformCompensationLevels.cs

@@ -7,6 +7,13 @@
     /// </summary>
     public struct AcrylicPlatformCompensationLevels
     {
+        public AcrylicPlatformCompensationLevels(double transparent, double blurred, double acrylic)
+        {
+            TransparentLevel = transparent;
+            BlurLevel = blurred;
+            AcrylicBlurLevel = acrylic;
+        }
+
         public double TransparentLevel { get; }
 
         public double BlurLevel { get; }

+ 3 - 0
src/Avalonia.Controls/Embedding/Offscreen/OffscreenTopLevelImpl.cs

@@ -52,6 +52,9 @@ namespace Avalonia.Controls.Embedding.Offscreen
 
         public Action<WindowTransparencyLevel> TransparencyLevelChanged { get; set; }
 
+        /// <inheritdoc/>
+        public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } = new AcrylicPlatformCompensationLevels(1, 1, 1);
+
         public void SetInputRoot(IInputRoot inputRoot) => InputRoot = inputRoot;
 
         public virtual Point PointToClient(PixelPoint point) => point.ToPoint(1);

+ 3 - 3
src/Avalonia.Controls/ExperimentalAcrylicBorder.cs

@@ -52,15 +52,15 @@ namespace Avalonia.Controls
                     {
                         case WindowTransparencyLevel.Transparent:
                         case WindowTransparencyLevel.None:
-                            Material.PlatformTransparencyCompensationLevel = 1;
+                            Material.PlatformTransparencyCompensationLevel = tl.PlatformImpl.AcrylicCompensationLevels.TransparentLevel;
                             break;
 
                         case WindowTransparencyLevel.Blur:
-                            Material.PlatformTransparencyCompensationLevel = 0.80;
+                            Material.PlatformTransparencyCompensationLevel = tl.PlatformImpl.AcrylicCompensationLevels.BlurLevel;
                             break;
 
                         case WindowTransparencyLevel.AcrylicBlur:
-                            Material.PlatformTransparencyCompensationLevel = 0.0;
+                            Material.PlatformTransparencyCompensationLevel = tl.PlatformImpl.AcrylicCompensationLevels.AcrylicBlurLevel;
                             break;
                     }
                 });

+ 2 - 0
src/Avalonia.DesignerSupport/Remote/Stubs.cs

@@ -174,6 +174,8 @@ namespace Avalonia.DesignerSupport.Remote
         public bool IsClientAreaExtendedToDecorations { get; }
 
         public bool NeedsManagedDecorations => false;
+        
+        public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } = new AcrylicPlatformCompensationLevels(1, 1, 1);
     }
 
     class ClipboardStub : IClipboard

+ 2 - 0
src/Avalonia.Native/WindowImplBase.cs

@@ -439,6 +439,8 @@ namespace Avalonia.Native
 
         public WindowTransparencyLevel TransparencyLevel { get; private set; } = WindowTransparencyLevel.Transparent;
 
+        public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } = new AcrylicPlatformCompensationLevels(1, 0, 0);
+
         public IPlatformHandle Handle { get; private set; }
     }
 }

+ 2 - 0
src/Avalonia.X11/X11Window.cs

@@ -1128,6 +1128,8 @@ namespace Avalonia.X11
 
         public WindowTransparencyLevel TransparencyLevel => _transparencyHelper.CurrentLevel;
 
+        public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } = new AcrylicPlatformCompensationLevels(1, 0.8, 0.8);
+
         public bool NeedsManagedDecorations => false;
     }
 }

+ 2 - 0
src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs

@@ -82,5 +82,7 @@ namespace Avalonia.LinuxFramebuffer
         public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel) { }
 
         public WindowTransparencyLevel TransparencyLevel { get; private set; }
+
+        public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } = new AcrylicPlatformCompensationLevels(1, 1, 1);
     }
 }

+ 3 - 0
src/Windows/Avalonia.Win32/WindowImpl.cs

@@ -1071,6 +1071,9 @@ namespace Avalonia.Win32
         /// <inheritdoc/>
         public Thickness OffScreenMargin => _offScreenMargin;
 
+        /// <inheritdoc/>
+        public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } = new AcrylicPlatformCompensationLevels(1, 0.8, 0);
+
         private struct SavedWindowInfo
         {
             public WindowStyles Style { get; set; }