From ac65b63a8f74f3ce293c78bdb95a41da1a8e252d Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Tue, 2 Jun 2026 14:01:58 -0500 Subject: [PATCH] Adopt Fluent/Mica look for light mode Replaces WinUI 2 grey brushes with WinUI 3 equivalents and enables the Mica system backdrop on Windows 11. RootGrid is transparent when Mica is active so the material shows through; falls back to ApplicationPageBackgroundThemeBrush on Win10. Sensor header uses LayerFillColorDefaultBrush; plot pane border uses DividerStrokeColorDefaultBrush. Black theme keeps a solid background and disables Mica. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../MainWindow.cs | 40 +++++++++++++++---- .../MainWindow.xaml | 2 +- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/LibreHardwareMonitor.Windows.WinUI/MainWindow.cs b/LibreHardwareMonitor.Windows.WinUI/MainWindow.cs index 7a48a37..22eef24 100644 --- a/LibreHardwareMonitor.Windows.WinUI/MainWindow.cs +++ b/LibreHardwareMonitor.Windows.WinUI/MainWindow.cs @@ -85,7 +85,7 @@ public sealed partial class MainWindow : Window _columnMeasurer.SettleTriggered += (_, _) => UpdateSensorColumnWidths(); MeasureStartup("MainWindow.InitializeComponent", InitializeComponent); - RootGrid.Background = new SolidColorBrush(Colors.White); + TryApplyMicaBackdrop(); RootGrid.Loaded += RootGrid_Loaded; RootGrid.LayoutUpdated += RootGrid_LayoutUpdated; Bind(ContentGrid, UIElement.IsHitTestVisibleProperty, ViewModel, nameof(ViewModel.IsHardwareInteractionEnabled)); @@ -350,7 +350,7 @@ public sealed partial class MainWindow : Window { Grid header = _columnMeasurer.CreateHeaderGrid(); header.Padding = new Thickness(8, 5, 8, 5); - header.Background = (Brush)Application.Current.Resources["SystemControlBackgroundChromeMediumLowBrush"]; + header.Background = (Brush)Application.Current.Resources["LayerFillColorDefaultBrush"]; header.Children.Add(CreateHeaderText("Sensor", 0, Visibility.Visible)); header.Children.Add(CreateHeaderText("Value", 1, ViewModel.ValueColumnVisibility, nameof(ViewModel.ValueColumnVisibility))); header.Children.Add(CreateHeaderText("Min", 2, ViewModel.MinColumnVisibility, nameof(ViewModel.MinColumnVisibility))); @@ -798,17 +798,43 @@ public sealed partial class MainWindow : Window _ => ElementTheme.Default }; - RootGrid.Background = ViewModel.ThemeMode switch + if (ViewModel.ThemeMode == AppThemeMode.Black) { - AppThemeMode.Black => new SolidColorBrush(Colors.Black), - AppThemeMode.Dark => new SolidColorBrush(global::Windows.UI.Color.FromArgb(255, 30, 30, 30)), - _ => (Brush)Application.Current.Resources["ApplicationPageBackgroundThemeBrush"] - }; + SystemBackdrop = null; + RootGrid.Background = new SolidColorBrush(Colors.Black); + } + else if (SystemBackdrop is MicaBackdrop) + { + RootGrid.Background = new SolidColorBrush(Colors.Transparent); + } + else + { + TryApplyMicaBackdrop(); + RootGrid.Background = SystemBackdrop is MicaBackdrop + ? new SolidColorBrush(Colors.Transparent) + : (Brush)Application.Current.Resources["ApplicationPageBackgroundThemeBrush"]; + } PlotControl.ApplyTheme(ViewModel.ThemeMode); _secondaryWindows.ApplyTheme(ViewModel.ThemeMode); } + private void TryApplyMicaBackdrop() + { + if (SystemBackdrop is MicaBackdrop) + return; + + try + { + if (Microsoft.UI.Composition.SystemBackdrops.MicaController.IsSupported()) + SystemBackdrop = new MicaBackdrop { Kind = Microsoft.UI.Composition.SystemBackdrops.MicaKind.Base }; + } + catch + { + // Mica unavailable (e.g. Win10) — fall back to theme brush in ApplyTheme. + } + } + private void UpdateSensorColumnWidths() { MeasureStartup("MainWindow.UpdateSensorColumnWidths", _columnMeasurer.UpdateWidths, () => FormattableString.Invariant($"rows={_columnMeasurer.RowCount}, cacheEntries={_columnMeasurer.CacheEntryCount}, deviceWidth={_columnMeasurer.DeviceColumnWidth:F0}, settled={_columnMeasurer.IsSettled}")); diff --git a/LibreHardwareMonitor.Windows.WinUI/MainWindow.xaml b/LibreHardwareMonitor.Windows.WinUI/MainWindow.xaml index 4323571..bdfd1c5 100644 --- a/LibreHardwareMonitor.Windows.WinUI/MainWindow.xaml +++ b/LibreHardwareMonitor.Windows.WinUI/MainWindow.xaml @@ -111,7 +111,7 @@ Grid.Row="0" Padding="8" BorderThickness="1,0,0,0" - BorderBrush="{ThemeResource SystemControlForegroundBaseLowBrush}"> + BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}">