Align Acrylic10 tint behavior with official dark/light acrylic palette (#1915)

* Initial plan

* Align Acrylic10 tint color and opacity with official dark/light values

Agent-Logs-Url: https://github.com/QL-Win/QuickLook/sessions/7856deeb-578c-4683-879b-e2d924eb4224

Co-authored-by: emako <24737061+emako@users.noreply.github.com>

* Refine Acrylic10 constants for tint palette and opacity

Agent-Logs-Url: https://github.com/QL-Win/QuickLook/sessions/7856deeb-578c-4683-879b-e2d924eb4224

Co-authored-by: emako <24737061+emako@users.noreply.github.com>

* Narrow color parsing exception handling in ViewerWindow

Agent-Logs-Url: https://github.com/QL-Win/QuickLook/sessions/7856deeb-578c-4683-879b-e2d924eb4224

Co-authored-by: emako <24737061+emako@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
This commit is contained in:
Copilot
2026-04-15 00:24:21 +08:00
committed by GitHub
parent 39feab58a3
commit 2229c1691a
2 changed files with 29 additions and 6 deletions
+2 -2
View File
@@ -168,7 +168,7 @@ public static class WindowHelper
Marshal.FreeHGlobal(accentPtr);
}
public static void EnableAcrylicBlur(Window window, Color tintColor, bool isDarkTheme)
public static void EnableAcrylicBlur(Window window, Color tintColor, bool isDarkTheme, double tintOpacity = 0.8)
{
window.Background = Brushes.Transparent;
@@ -193,7 +193,7 @@ public static class WindowHelper
var accent = new AccentPolicy();
var accentStructSize = Marshal.SizeOf(accent);
accent.AccentState = AccentState.AccentEnableAcrylicblurbehind;
accent.GradientColor = ToAbgr(tintColor, 0.8);
accent.GradientColor = ToAbgr(tintColor, tintOpacity);
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
Marshal.StructureToPtr(accent, accentPtr, false);
+27 -4
View File
@@ -41,6 +41,10 @@ namespace QuickLook;
public partial class ViewerWindow : Window
{
private const double Acrylic10TintOpacity = 0.7;
private static readonly Color Acrylic10DarkTintColor = Color.FromRgb(0x17, 0x17, 0x17);
private static readonly Color Acrylic10LightTintColor = Color.FromRgb(0xF2, 0xF2, 0xF2);
private Size _customWindowSize = Size.Empty;
private bool _ignoreNextWindowSizeChange;
private string _path = string.Empty;
@@ -204,7 +208,7 @@ public partial class ViewerWindow : Window
{
Background = (Brush)new BrushConverter().ConvertFromString(customColor);
}
catch
catch (Exception ex) when (ex is FormatException || ex is NotSupportedException)
{
// Ignore invalid color
}
@@ -279,11 +283,11 @@ public partial class ViewerWindow : Window
case SystembackdropType.Acrylic10:
if (App.IsWin10 || App.IsWin11)
{
var acrylicTint = GetAcrylicTintColor();
var acrylicTint = GetAcrylic10TintColor();
WindowChrome.GetWindowChrome(this)?.GlassFrameThickness = new Thickness(0d);
WindowHelper.DisableDwmBlur(this); // Restore rounded corners on Windows 11
WindowHelper.EnableAcrylicBlur(this, acrylicTint, CurrentTheme == Themes.Dark);
WindowHelper.EnableAcrylicBlur(this, acrylicTint, CurrentTheme == Themes.Dark, Acrylic10TintOpacity);
Background = Brushes.Transparent;
}
else
@@ -356,7 +360,7 @@ public partial class ViewerWindow : Window
{
return ((SolidColorBrush)new BrushConverter().ConvertFromString(customColor)).Color;
}
catch
catch (Exception ex) when (ex is FormatException || ex is NotSupportedException)
{
// Ignore invalid color
}
@@ -365,6 +369,25 @@ public partial class ViewerWindow : Window
return ((SolidColorBrush)FindResource("MainWindowBackground")).Color;
}
private Color GetAcrylic10TintColor()
{
var customColor = SettingHelper.Get("WindowBackgroundColor", string.Empty, "QuickLook");
if (!string.IsNullOrEmpty(customColor))
{
try
{
return ((SolidColorBrush)new BrushConverter().ConvertFromString(customColor)).Color;
}
catch (Exception ex) when (ex is FormatException || ex is NotSupportedException)
{
// Ignore invalid color
}
}
return CurrentTheme == Themes.Dark ? Acrylic10DarkTintColor : Acrylic10LightTintColor;
}
private static SystembackdropType GetBackdropOption()
{
var option = SettingHelper.Get("WindowBackdrop", nameof(SystembackdropType.Auto), "QuickLook")?.Trim();