Browse Source
The transparency level is not yet communicated to the backends though. Co-Authored-By: Max Katz <maxkatz6@outlook.com>pull/11509/head
13 changed files with 211 additions and 165 deletions
@ -1,35 +1,51 @@ |
|||||
namespace Avalonia.Controls |
using System.Collections.Generic; |
||||
|
using System.Collections.ObjectModel; |
||||
|
|
||||
|
namespace Avalonia.Controls; |
||||
|
|
||||
|
public readonly record struct WindowTransparencyLevel |
||||
{ |
{ |
||||
public enum WindowTransparencyLevel |
private readonly string _value; |
||||
|
|
||||
|
private WindowTransparencyLevel(string value) |
||||
{ |
{ |
||||
/// <summary>
|
_value = value; |
||||
/// The window background is Black where nothing is drawn in the window.
|
} |
||||
/// </summary>
|
|
||||
None, |
/// <summary>
|
||||
|
/// The window background is Black where nothing is drawn in the window.
|
||||
/// <summary>
|
/// </summary>
|
||||
/// The window background is Transparent where nothing is drawn in the window.
|
public static WindowTransparencyLevel None { get; } = new(nameof(None)); |
||||
/// </summary>
|
|
||||
Transparent, |
/// <summary>
|
||||
|
/// The window background is Transparent where nothing is drawn in the window.
|
||||
/// <summary>
|
/// </summary>
|
||||
/// The window background is a blur-behind where nothing is drawn in the window.
|
public static WindowTransparencyLevel Transparent { get; } = new(nameof(Transparent)); |
||||
/// </summary>
|
|
||||
Blur, |
/// <summary>
|
||||
|
/// The window background is a blur-behind where nothing is drawn in the window.
|
||||
/// <summary>
|
/// </summary>
|
||||
/// The window background is a blur-behind with a high blur radius. This level may fallback to Blur.
|
public static WindowTransparencyLevel Blur { get; } = new(nameof(Blur)); |
||||
/// </summary>
|
|
||||
AcrylicBlur, |
/// <summary>
|
||||
|
/// The window background is a blur-behind with a high blur radius. This level may fallback to Blur.
|
||||
/// <summary>
|
/// </summary>
|
||||
/// Force acrylic on some incompatible versions of Windows 10.
|
public static WindowTransparencyLevel AcrylicBlur { get; } = new(nameof(AcrylicBlur)); |
||||
/// </summary>
|
|
||||
ForceAcrylicBlur, |
/// <summary>
|
||||
|
/// The window background is based on desktop wallpaper tint with a blur. This will only work on Windows 11
|
||||
/// <summary>
|
/// </summary>
|
||||
/// The window background is based on desktop wallpaper tint with a blur. This will only work on Windows 11
|
public static WindowTransparencyLevel Mica { get; } = new(nameof(Mica)); |
||||
/// </summary>
|
|
||||
Mica |
public override string ToString() |
||||
|
{ |
||||
|
return _value; |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
|
public class WindowTransparencyLevelCollection : ReadOnlyCollection<WindowTransparencyLevel> |
||||
|
{ |
||||
|
public WindowTransparencyLevelCollection(IList<WindowTransparencyLevel> list) : base(list) |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
|||||
@ -0,0 +1,26 @@ |
|||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.UnitTests; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Avalonia.Markup.Xaml.UnitTests.Xaml |
||||
|
{ |
||||
|
public class WindowTests : XamlTestBase |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void Can_Specify_TransparencyLevelHint() |
||||
|
{ |
||||
|
using var app = UnitTestApplication.Start(TestServices.MockWindowingPlatform); |
||||
|
var xaml = @"<Window xmlns='https://github.com/avaloniaui' TransparencyLevelHint='Blur,Transparent,None'/>"; |
||||
|
|
||||
|
var target = AvaloniaRuntimeXamlLoader.Parse<Window>(xaml); |
||||
|
|
||||
|
Assert.Equal( |
||||
|
new[] |
||||
|
{ |
||||
|
WindowTransparencyLevel.Blur, |
||||
|
WindowTransparencyLevel.Transparent, |
||||
|
WindowTransparencyLevel.None, |
||||
|
}, target.TransparencyLevelHint); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue