From 290d8a52f95605fb15d6bc09154213ee0eb6a40d Mon Sep 17 00:00:00 2001 From: United600 Date: Sat, 4 Jan 2025 15:08:28 +0000 Subject: [PATCH 1/4] improve custom appbar button styles --- Screenbox/Pages/AlbumDetailsPage.xaml | 9 +-- Screenbox/Pages/ArtistDetailsPage.xaml | 9 +-- Screenbox/Styles/CommandBar.xaml | 105 +++++++++++-------------- 3 files changed, 52 insertions(+), 71 deletions(-) diff --git a/Screenbox/Pages/AlbumDetailsPage.xaml b/Screenbox/Pages/AlbumDetailsPage.xaml index ea2f9fbd4..09c98bfdf 100644 --- a/Screenbox/Pages/AlbumDetailsPage.xaml +++ b/Screenbox/Pages/AlbumDetailsPage.xaml @@ -192,15 +192,12 @@ @@ -208,14 +205,12 @@ diff --git a/Screenbox/Pages/ArtistDetailsPage.xaml b/Screenbox/Pages/ArtistDetailsPage.xaml index ef4b10efa..ed295e3cb 100644 --- a/Screenbox/Pages/ArtistDetailsPage.xaml +++ b/Screenbox/Pages/ArtistDetailsPage.xaml @@ -273,14 +273,11 @@ @@ -288,14 +285,12 @@ diff --git a/Screenbox/Styles/CommandBar.xaml b/Screenbox/Styles/CommandBar.xaml index 045c2c924..073e4cd0d 100644 --- a/Screenbox/Styles/CommandBar.xaml +++ b/Screenbox/Styles/CommandBar.xaml @@ -34,26 +34,25 @@ Duration="{StaticResource ControlFastAnimationDuration}" /> - + + - - + --> - - - - - @@ -218,6 +212,7 @@ + @@ -232,15 +227,11 @@ - - - - - + - - - + + + @@ -315,7 +306,7 @@ - + @@ -327,7 +318,7 @@ - + @@ -339,7 +330,7 @@ - + @@ -347,8 +338,9 @@ - + + @@ -360,6 +352,8 @@ + + @@ -374,6 +368,8 @@ + + @@ -388,6 +384,8 @@ + + @@ -441,25 +439,25 @@ - - - + --> - - - - - @@ -624,6 +617,7 @@ + @@ -638,15 +632,11 @@ - - - - - + - - - + + + @@ -721,7 +711,7 @@ - + @@ -733,7 +723,7 @@ - + @@ -742,10 +732,10 @@ - + - + @@ -753,8 +743,9 @@ - + + From 92a62a17c8b47857687d95f9e92b6620e7b22615 Mon Sep 17 00:00:00 2001 From: United600 Date: Wed, 15 Jan 2025 18:59:50 +0000 Subject: [PATCH 2/4] improve media details command bar add command bar extension add ellipsis button style add more button animation invert selection command bar translation animation improve gamepad navigation --- Screenbox/App.xaml | 8 +- .../Extensions/CommandBarExtensions.cs | 122 +++++++++++++++ Screenbox/Controls/PlaylistView.xaml | 4 +- Screenbox/Pages/AlbumDetailsPage.xaml | 38 +++-- Screenbox/Pages/ArtistDetailsPage.xaml | 38 +++-- Screenbox/Pages/FolderViewPage.xaml | 4 + Screenbox/Pages/MainPage.xaml | 4 +- Screenbox/Pages/PlayerPage.xaml | 4 +- Screenbox/Screenbox.csproj | 1 + Screenbox/Styles/CommandBar.xaml | 142 ++++++++++++++++-- 10 files changed, 305 insertions(+), 60 deletions(-) create mode 100644 Screenbox/Controls/Extensions/CommandBarExtensions.cs diff --git a/Screenbox/App.xaml b/Screenbox/App.xaml index 7aa72a1f2..974459a07 100644 --- a/Screenbox/App.xaml +++ b/Screenbox/App.xaml @@ -84,15 +84,17 @@ 99 - + + Duration="{StaticResource ControlFasterAnimationDuration}" /> - + diff --git a/Screenbox/Controls/Extensions/CommandBarExtensions.cs b/Screenbox/Controls/Extensions/CommandBarExtensions.cs new file mode 100644 index 000000000..87ac1cce7 --- /dev/null +++ b/Screenbox/Controls/Extensions/CommandBarExtensions.cs @@ -0,0 +1,122 @@ +using CommunityToolkit.WinUI; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Input; + +namespace Screenbox.Controls.Extensions; + +/// +/// Provides attached dependency properties for the control. +/// +internal class CommandBarExtensions +{ + /// + /// Attached for binding a to the more of the associated + /// + public static readonly DependencyProperty MoreButtonKeyboardAcceleratorsProperty = DependencyProperty.RegisterAttached( + "MoreButtonKeyboardAccelerators", typeof(KeyboardAccelerator), typeof(CommandBarExtensions), new PropertyMetadata(null, OnMoreButtonKeyboardAcceleratorsPropertyChanged)); + + /// + /// Gets the for the more of the associated + /// + /// The associated with the more . + public static KeyboardAccelerator GetMoreButtonKeyboardAccelerators(CommandBar obj) + { + return (KeyboardAccelerator)obj.GetValue(MoreButtonKeyboardAcceleratorsProperty); + } + + /// + /// Sets the to the more of the associated + /// + public static void SetMoreButtonKeyboardAccelerators(CommandBar obj, KeyboardAccelerator value) + { + obj.SetValue(MoreButtonKeyboardAcceleratorsProperty, value); + } + + /// + /// Attached for binding a to the more of the associated + /// + public static readonly DependencyProperty MoreButtonStyleProperty = DependencyProperty.RegisterAttached( + "MoreButtonStyle", typeof(Style), typeof(CommandBarExtensions), new PropertyMetadata(null, OnMoreButtonStylePropertyChanged)); + + /// + /// Gets the for the more of the associated + /// + /// The associated with the more . + public static Style GetMoreButtonStyle(CommandBar obj) + { + return (Style)obj.GetValue(MoreButtonStyleProperty); + } + + /// + /// Sets the to the more of the associated + /// + public static void SetMoreButtonStyle(CommandBar obj, Style value) + { + obj.SetValue(MoreButtonStyleProperty, value); + } + + private static void OnCommandBarUnloaded(object sender, RoutedEventArgs args) + { + if (sender is CommandBar commandBar) + { + commandBar.Loaded -= ChangeCommandBarMoreButtonKeyboardAccelerators; + commandBar.Loaded -= ChangeCommandBarMoreButtonStyle; + commandBar.Unloaded -= OnCommandBarUnloaded; + } + } + + private static void OnMoreButtonKeyboardAcceleratorsPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) + { + if (sender is CommandBar commandBar) + { + commandBar.Loaded -= ChangeCommandBarMoreButtonKeyboardAccelerators; + commandBar.Unloaded -= OnCommandBarUnloaded; + + if (MoreButtonKeyboardAcceleratorsProperty != null) + { + commandBar.Loaded += ChangeCommandBarMoreButtonKeyboardAccelerators; + commandBar.Unloaded += OnCommandBarUnloaded; + } + } + } + + private static void ChangeCommandBarMoreButtonKeyboardAccelerators(object sender, RoutedEventArgs args) + { + if (sender is CommandBar commandBar) + { + Button moreButton = commandBar.FindDescendant