From 75ac1521a8dc6bba0b106eeb8f677107e379c9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Pol=C3=A1=C5=A1ek?= Date: Sun, 17 May 2026 19:43:12 +0200 Subject: [PATCH] CmdPal: Extension Gallery - Move storyboards used to show/hide breadcrumbs to XAML (#47900) ## Summary of the Pull Request This PR moves storyboard that handles showing and hiding breadcrumbs in Settings windows to a XAML resources. ## PR Checklist - [ ] Closes: #xxx - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --- .../Settings/SettingsWindow.xaml | 27 ++++++++ .../Settings/SettingsWindow.xaml.cs | 64 ++++++++----------- 2 files changed, 53 insertions(+), 38 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml index 934526a78b..efaf133218 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml @@ -23,6 +23,33 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml.cs index bebe8bee19..28518518b0 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml.cs @@ -33,8 +33,9 @@ public sealed partial class SettingsWindow : WindowEx, private readonly LocalKeyboardListener _localKeyboardListener; private readonly NavigationViewItem? _internalNavItem; + private readonly Storyboard _breadcrumbFadeInStoryboard; + private readonly Storyboard _breadcrumbFadeOutStoryboard; - private Storyboard? _breadcrumbStoryboard; private IReadOnlyList _currentScreenshotSet = []; private ExtensionGalleryScreenshotViewModel? _currentScreenshot; @@ -53,6 +54,8 @@ public sealed partial class SettingsWindow : WindowEx, public SettingsWindow() { this.InitializeComponent(); + _breadcrumbFadeInStoryboard = (Storyboard)RootElement.Resources["BreadcrumbFadeInStoryboard"]; + _breadcrumbFadeOutStoryboard = (Storyboard)RootElement.Resources["BreadcrumbFadeOutStoryboard"]; this.ExtendsContentIntoTitleBar = true; this.SetIcon(); var title = RS_.GetString("SettingsWindowTitle"); @@ -320,54 +323,30 @@ public sealed partial class SettingsWindow : WindowEx, private void HideBreadcrumb() { - _breadcrumbStoryboard?.Stop(); - - var fadeOut = new DoubleAnimation + if (BreadcrumbContainer.Visibility == Visibility.Collapsed) { - To = 0, - Duration = new Duration(TimeSpan.FromMilliseconds(200)), - EasingFunction = new CubicEase { EasingMode = EasingMode.EaseIn }, - }; - Storyboard.SetTarget(fadeOut, BreadcrumbContainer); - Storyboard.SetTargetProperty(fadeOut, "Opacity"); + return; + } - _breadcrumbStoryboard = new Storyboard(); - _breadcrumbStoryboard.Children.Add(fadeOut); - _breadcrumbStoryboard.Completed += (_, _) => - { - BreadcrumbContainer.Visibility = Visibility.Collapsed; - BreadcrumbContainer.Opacity = 1; - _breadcrumbStoryboard = null; - }; - _breadcrumbStoryboard.Begin(); + _breadcrumbFadeInStoryboard.Stop(); + _breadcrumbFadeOutStoryboard.Stop(); + _breadcrumbFadeOutStoryboard.Begin(); } private void ShowBreadcrumb() { - _breadcrumbStoryboard?.Stop(); - _breadcrumbStoryboard = null; + _breadcrumbFadeInStoryboard.Stop(); + _breadcrumbFadeOutStoryboard.Stop(); if (BreadcrumbContainer.Visibility == Visibility.Collapsed) { BreadcrumbContainer.Opacity = 0; BreadcrumbContainer.Visibility = Visibility.Visible; - - var fadeIn = new DoubleAnimation - { - To = 1, - Duration = new Duration(TimeSpan.FromMilliseconds(250)), - EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }, - }; - Storyboard.SetTarget(fadeIn, BreadcrumbContainer); - Storyboard.SetTargetProperty(fadeIn, "Opacity"); - - _breadcrumbStoryboard = new Storyboard(); - _breadcrumbStoryboard.Children.Add(fadeIn); - _breadcrumbStoryboard.Completed += (_, _) => _breadcrumbStoryboard = null; - _breadcrumbStoryboard.Begin(); + _breadcrumbFadeInStoryboard.Begin(); } else { + BreadcrumbContainer.Visibility = Visibility.Visible; BreadcrumbContainer.Opacity = 1; } } @@ -382,7 +361,7 @@ public sealed partial class SettingsWindow : WindowEx, private void NavFrame_OnNavigated(object sender, NavigationEventArgs e) { BreadCrumbs.Clear(); - ShowBreadcrumb(); + var shouldShowBreadcrumb = true; if (e.SourcePageType == typeof(GeneralPage)) { @@ -405,14 +384,14 @@ public sealed partial class SettingsWindow : WindowEx, else if (e.SourcePageType == typeof(ExtensionGalleryPage)) { NavView.SelectedItem = GalleryPageNavItem; - HideBreadcrumb(); + shouldShowBreadcrumb = false; var pageType = RS_.GetString("Settings_PageTitles_GalleryPage"); BreadCrumbs.Add(new(pageType, pageType)); } else if (e.SourcePageType == typeof(ExtensionGalleryItemPage) && e.Parameter is ExtensionGalleryItemViewModel galleryExtension) { NavView.SelectedItem = GalleryPageNavItem; - HideBreadcrumb(); + shouldShowBreadcrumb = false; var galleryPageType = RS_.GetString("Settings_PageTitles_GalleryPage"); BreadCrumbs.Add(new(galleryPageType, "Gallery")); BreadCrumbs.Add(new(galleryExtension.Title, galleryExtension)); @@ -441,6 +420,15 @@ public sealed partial class SettingsWindow : WindowEx, BreadCrumbs.Add(new($"[{e.SourcePageType?.Name}]", string.Empty)); Logger.LogError($"Unknown breadcrumb for page type '{e.SourcePageType}'"); } + + if (shouldShowBreadcrumb) + { + ShowBreadcrumb(); + } + else + { + HideBreadcrumb(); + } } private void CloseScreenshotViewerButton_Click(object sender, RoutedEventArgs e)