diff --git a/RetroBar/Controls/Clock.xaml.cs b/RetroBar/Controls/Clock.xaml.cs index 7b16b40a..cb522af8 100644 --- a/RetroBar/Controls/Clock.xaml.cs +++ b/RetroBar/Controls/Clock.xaml.cs @@ -58,6 +58,16 @@ private void Initialize() Settings.Instance.PropertyChanged += Settings_PropertyChanged; SystemEvents.TimeChanged += TimeChanged; SystemEvents.UserPreferenceChanged += UserPreferenceChanged; + + UpdateTextScaling(); + } + + private void UpdateTextScaling() + { + // Only scale within the actual taskbar; the properties window preview hosts this + // same control without the taskbar's ScaleTransform, so it should stay unscaled. + double scale = Window.GetWindow(this) is RetroBar.Taskbar ? Settings.Instance.TaskbarScale : 1.0; + TextScaler.ApplyScaling(this, scale); } private void StartClock() @@ -93,6 +103,16 @@ private void Settings_PropertyChanged(object sender, System.ComponentModel.Prope { UpdateUserCulture(); } + else if (e.PropertyName == nameof(Settings.TaskbarScale)) + { + UpdateTextScaling(); + } + else if (e.PropertyName == nameof(Settings.Theme)) + { + // The clock template (and its base font size) is swapped on theme change; + // re-apply once that has happened. + Dispatcher.BeginInvoke(new Action(UpdateTextScaling), DispatcherPriority.Loaded); + } } private void Clock_Tick(object sender, EventArgs args) diff --git a/RetroBar/Controls/InputLanguage.xaml b/RetroBar/Controls/InputLanguage.xaml index 770c7529..9307d43b 100644 --- a/RetroBar/Controls/InputLanguage.xaml +++ b/RetroBar/Controls/InputLanguage.xaml @@ -22,10 +22,13 @@ - - + + + + diff --git a/RetroBar/Controls/InputLanguage.xaml.cs b/RetroBar/Controls/InputLanguage.xaml.cs index 90d97b27..498348f4 100644 --- a/RetroBar/Controls/InputLanguage.xaml.cs +++ b/RetroBar/Controls/InputLanguage.xaml.cs @@ -3,6 +3,7 @@ using System.Globalization; using System.Windows; using System.Windows.Controls; +using System.Windows.Media; using System.Windows.Threading; using ManagedShell.Common.Helpers; using ManagedShell.Common.Logging; @@ -46,6 +47,46 @@ private void Initialize() } Settings.Instance.PropertyChanged += Settings_PropertyChanged; + + UpdateTextScaling(); + } + + // The unscaled box size from the InputLanguageBox style, captured once so the scaling + // doesn't hard-code it. + private double _baseBoxHeight = double.NaN; + private double _baseBoxMinWidth = double.NaN; + + private void UpdateTextScaling() + { + // Only scale within the actual taskbar; the properties window preview hosts this + // same control without the taskbar's ScaleTransform, so it should stay unscaled. + double scale = Window.GetWindow(this) is RetroBar.Taskbar ? Settings.Instance.TaskbarScale : 1.0; + + if (double.IsNaN(_baseBoxHeight)) + { + _baseBoxHeight = InputLanguageBox.Height; + _baseBoxMinWidth = InputLanguageBox.MinWidth; + } + + // Render the whole indicator at real, pixel-aligned sizes with a 1/scale + // counter-transform, so both the box and the text stay crisp (no fractional-pixel + // blur) and the text centers in real-pixel space rather than in the taskbar's + // fractional scaled space. The base font size comes from the current theme's + // GlobalFontSize. + if (scale > 1.0 && Application.Current.TryFindResource("GlobalFontSize") is double baseFontSize) + { + InputLanguageBox.LayoutTransform = new ScaleTransform(1.0 / scale, 1.0 / scale); + InputLanguageBox.Height = Math.Round(_baseBoxHeight * scale); + InputLanguageBox.MinWidth = Math.Round(_baseBoxMinWidth * scale); + InputLanguageText.FontSize = Math.Round(baseFontSize * scale); + } + else + { + InputLanguageBox.LayoutTransform = null; + InputLanguageBox.ClearValue(FrameworkElement.HeightProperty); + InputLanguageBox.ClearValue(FrameworkElement.MinWidthProperty); + InputLanguageText.ClearValue(TextBlock.FontSizeProperty); + } } private void SetLocaleIdentifier() @@ -122,17 +163,17 @@ private void LayoutWatchTick(object sender, EventArgs args) if (InstalledLanguagesCount() == 1) { - InputLanguageText.Visibility = Visibility.Collapsed; + InputLanguageBox.Visibility = Visibility.Collapsed; } else { - InputLanguageText.Visibility = Visibility.Visible; + InputLanguageBox.Visibility = Visibility.Visible; } } else { JapaneseImeRemove(); - InputLanguageText.Visibility = Visibility.Visible; + InputLanguageBox.Visibility = Visibility.Visible; } } @@ -156,6 +197,15 @@ private void Settings_PropertyChanged(object sender, System.ComponentModel.Prope StopWatch(); } } + else if (e.PropertyName == nameof(Settings.TaskbarScale)) + { + UpdateTextScaling(); + } + else if (e.PropertyName == nameof(Settings.Theme)) + { + // The base font size can change with the theme; re-apply once it has loaded. + Dispatcher.BeginInvoke(new Action(UpdateTextScaling), DispatcherPriority.Loaded); + } } private void UserControl_Loaded(object sender, RoutedEventArgs e) diff --git a/RetroBar/Controls/TaskButton.xaml.cs b/RetroBar/Controls/TaskButton.xaml.cs index 3a6f28d9..94f1749b 100644 --- a/RetroBar/Controls/TaskButton.xaml.cs +++ b/RetroBar/Controls/TaskButton.xaml.cs @@ -6,6 +6,7 @@ using System.Windows.Data; using System.Windows.Input; using System.Windows.Media.Animation; +using System.Windows.Threading; using ManagedShell.Common.Helpers; using ManagedShell.Interop; using ManagedShell.WindowsTasks; @@ -83,6 +84,15 @@ private void Animate() storyboard.Begin(); } + private void UpdateTextScaling() + { + // Only scale within the actual taskbar; the properties window preview uses its own + // markup (not this control), so this never runs unscaled, but the guard keeps it + // consistent with the clock and input language indicator. + double scale = System.Windows.Window.GetWindow(this) is RetroBar.Taskbar ? Settings.Instance.TaskbarScale : 1.0; + TextScaler.ApplyScaling(this, scale); + } + private void TaskButton_OnLoaded(object sender, RoutedEventArgs e) { Window = DataContext as ApplicationWindow; @@ -105,6 +115,8 @@ private void TaskButton_OnLoaded(object sender, RoutedEventArgs e) Animate(); } + UpdateTextScaling(); + _isLoaded = true; } @@ -285,6 +297,12 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e) if (e.PropertyName == nameof(Settings.Theme)) { SetStyle(); + // The base font size can change with the theme; re-apply once it has loaded. + Dispatcher.BeginInvoke(new Action(UpdateTextScaling), DispatcherPriority.Loaded); + } + else if (e.PropertyName == nameof(Settings.TaskbarScale)) + { + UpdateTextScaling(); } } diff --git a/RetroBar/Themes/System.xaml b/RetroBar/Themes/System.xaml index 5a2f3cb2..0d11bfc6 100644 --- a/RetroBar/Themes/System.xaml +++ b/RetroBar/Themes/System.xaml @@ -910,21 +910,31 @@ + + -