Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: improve command bar style and resources #533

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
remove unused method from extension
remove implicitanimation from property
United600 committed Jan 26, 2025
commit 5a7c309387d96878eb5289bd3fa71010aeccce97
2 changes: 0 additions & 2 deletions Screenbox/App.xaml
Original file line number Diff line number Diff line change
@@ -87,14 +87,12 @@
<ctAnimations:ImplicitAnimationSet x:Key="FadeInImplicitAnimation">
<ctAnimations:OpacityAnimation
EasingType="Linear"
From="0"
To="1"
Duration="{StaticResource ControlFasterAnimationDuration}" />
</ctAnimations:ImplicitAnimationSet>
<ctAnimations:ImplicitAnimationSet x:Key="FadeOutImplicitAnimation">
<ctAnimations:OpacityAnimation
EasingType="Linear"
From="1"
To="0"
Duration="{StaticResource ControlFasterAnimationDuration}" />
</ctAnimations:ImplicitAnimationSet>
52 changes: 0 additions & 52 deletions Screenbox/Controls/Extensions/CommandBarExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using CommunityToolkit.WinUI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;

namespace Screenbox.Controls.Extensions;

@@ -10,29 +9,6 @@ namespace Screenbox.Controls.Extensions;
/// </summary>
internal class CommandBarExtensions
{
/// <summary>
/// Attached <see cref="DependencyProperty"/> for binding a <see cref="KeyboardAccelerator"/> to the more <see cref="Button"/> of the associated <see cref="CommandBar"/>
/// </summary>
public static readonly DependencyProperty MoreButtonKeyboardAcceleratorsProperty = DependencyProperty.RegisterAttached(
"MoreButtonKeyboardAccelerators", typeof(KeyboardAccelerator), typeof(CommandBarExtensions), new PropertyMetadata(null, OnMoreButtonKeyboardAcceleratorsPropertyChanged));

/// <summary>
/// Gets the <see cref="KeyboardAccelerator"/> for the more <see cref="Button"/> of the associated <see cref="CommandBar"/>
/// </summary>
/// <returns>The <see cref="KeyboardAccelerator"/> associated with the <see cref="CommandBar"/> more <see cref="Button"/>.</returns>
public static KeyboardAccelerator GetMoreButtonKeyboardAccelerators(CommandBar obj)
{
return (KeyboardAccelerator)obj.GetValue(MoreButtonKeyboardAcceleratorsProperty);
}

/// <summary>
/// Sets the <see cref="KeyboardAccelerator"/> to the more <see cref="Button"/> of the associated <see cref="CommandBar"/>
/// </summary>
public static void SetMoreButtonKeyboardAccelerators(CommandBar obj, KeyboardAccelerator value)
{
obj.SetValue(MoreButtonKeyboardAcceleratorsProperty, value);
}

/// <summary>
/// Attached <see cref="DependencyProperty"/> for binding a <see cref="Style"/> to the more <see cref="Button"/> of the associated <see cref="CommandBar"/>
/// </summary>
@@ -60,39 +36,11 @@ 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<Button>(b => b.Name == "MoreButton");
if (moreButton != null)
{
moreButton.KeyboardAccelerators.Add(GetMoreButtonKeyboardAccelerators(commandBar));
}
}
}

private static void OnMoreButtonStylePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
{
if (sender is CommandBar commandBar)
3 changes: 1 addition & 2 deletions Screenbox/Controls/PlaylistView.xaml
Original file line number Diff line number Diff line change
@@ -168,16 +168,15 @@
Margin="{x:Bind Padding, Mode=OneWay}"
ctAnimations:Implicit.HideAnimations="{StaticResource SelectionRowExitImplicitAnimation}"
ctAnimations:Implicit.ShowAnimations="{StaticResource SelectionRowEntranceImplicitAnimation}"
Opacity="0"
Visibility="Collapsed">

<Border
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="{StaticResource CommandBarFlyoutBorderThemeThickness}"
CornerRadius="{StaticResource OverlayCornerRadius}"
Shadow="{StaticResource SharedShadow}"
Translation="0,0,32" />

<CommandBar
x:Name="SelectionCommandBar"
VerticalContentAlignment="Center"
3 changes: 0 additions & 3 deletions Screenbox/Styles/CommandBar.xaml
Original file line number Diff line number Diff line change
@@ -27,19 +27,16 @@
Duration="{StaticResource ControlNormalAnimationDuration}" />
<ctAnimations:OpacityAnimation
EasingType="Linear"
From="0"
To="1"
Duration="{StaticResource ControlFastAnimationDuration}" />
</ctAnimations:ImplicitAnimationSet>
<ctAnimations:ImplicitAnimationSet x:Key="SelectionRowExitImplicitAnimation">
<ctAnimations:TranslationAnimation
EasingMode="EaseIn"
From="0,0,0"
To="0,48,0"
Duration="{StaticResource ControlFastAnimationDuration}" />
<ctAnimations:OpacityAnimation
EasingType="Linear"
From="1"
To="0"
Duration="{StaticResource ControlFasterAnimationDuration}" />
</ctAnimations:ImplicitAnimationSet>