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
[WIP] Feature/Fluent ButtonSpinner + NumericUpDown #4109
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
adcdeb0
Update MarginMultiplierConverter to support Thickness input
maxkatz6 d136dc6
NumericUpDownPage example shouldn't set strict Width to elements
maxkatz6 824fe86
Hide HeaderContentPresenter from TextBox because it isn't supported
maxkatz6 3271c5f
Initial Fluent ButtonSpinner
maxkatz6 09f7254
Initial Fluent NumericUpDown
maxkatz6 e29bc96
Merge branch 'master' into feature/fluent-numericupdown
b6634cd
Merge branch 'master' into feature/fluent-numericupdown
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,206 @@ | ||
<Styles xmlns="https://github.com/avaloniaui"> | ||
<Style Selector="ButtonSpinner"> | ||
<Setter Property="Background" Value="Transparent"/> | ||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> | ||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> | ||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/> | ||
<Setter Property="VerticalContentAlignment" Value="Center"/> | ||
</Style> | ||
<Style Selector="ButtonSpinner /template/ RepeatButton"> | ||
<Setter Property="Background" Value="Transparent"/> | ||
<Setter Property="BorderBrush" Value="Transparent"/> | ||
</Style> | ||
<Style Selector="ButtonSpinner /template/ RepeatButton:pointerover"> | ||
<Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/> | ||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> | ||
<Styles xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:sys="clr-namespace:System;assembly=netstandard" | ||
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"> | ||
<Design.PreviewWith> | ||
<Border Padding="20" | ||
Background="Black"> | ||
<StackPanel Spacing="20"> | ||
<ButtonSpinner ButtonSpinnerLocation="Right" | ||
Content="Right disabled inline spinner" | ||
AllowSpin="False" /> | ||
<ButtonSpinner ButtonSpinnerLocation="Left" | ||
Content="Left spinner" /> | ||
<ButtonSpinner ButtonSpinnerLocation="Right" | ||
Classes="CompactInlineButtonSpinner" | ||
Content="Right compact spinner" /> | ||
<ButtonSpinner ButtonSpinnerLocation="Left" | ||
Classes="CompactInlineButtonSpinner" | ||
AllowSpin="False" | ||
Content="Left disabled compact spinner" /> | ||
<ButtonSpinner ShowButtonSpinner="False" | ||
Content="Hide spinner" /> | ||
</StackPanel> | ||
</Border> | ||
</Design.PreviewWith> | ||
|
||
<Styles.Resources> | ||
<converters:MarginMultiplierConverter x:Key="ButtonSpinner_OnlyLeftThinknessConverter" | ||
Indent="1" | ||
Left="True" /> | ||
<converters:MarginMultiplierConverter x:Key="ButtonSpinner_OnlyRightThinknessConverter" | ||
Indent="1" | ||
Right="True" /> | ||
|
||
<StreamGeometry x:Key="ButtonSpinnerIncreaseButtonIcon">M0,9 L10,0 20,9 19,10 10,2 1,10 z</StreamGeometry> | ||
<StreamGeometry x:Key="ButtonSpinnerDecreaseButtonIcon">M0,1 L10,10 20,1 19,0 10,8 1,0 z</StreamGeometry> | ||
<StreamGeometry x:Key="ButtonSpinnerIncreaseDecreaseButtonIcon">M0,9 L10,0 20,9 19,10 10,2 1,10 z M0,16 L10,25 20,16 19,15 10,23 1,15 z</StreamGeometry> | ||
</Styles.Resources> | ||
|
||
<!-- RepeatButton.ButtonSpinnerRepeatButton --> | ||
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton"> | ||
<Setter Property="MinWidth" Value="34" /> | ||
<Setter Property="VerticalAlignment" Value="Stretch" /> | ||
</Style> | ||
<Style Selector="ButtonSpinner /template/ RepeatButton#PART_IncreaseButton"> | ||
<Setter Property="Content"> | ||
<Template> | ||
<Path Fill="{DynamicResource ThemeForegroundBrush}" | ||
Width="8" | ||
Height="4" | ||
Stretch="Uniform" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Data="M0,5 L4.5,.5 9,5 6,5 4.5,3.5 3,5 z"/> | ||
</Template> | ||
</Setter> | ||
|
||
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton /template/ ContentPresenter"> | ||
<Setter Property="BorderBrush" Value="{TemplateBinding BorderBrush}" /> | ||
</Style> | ||
<Style Selector="ButtonSpinner /template/ RepeatButton#PART_DecreaseButton"> | ||
<Setter Property="Content"> | ||
<Template> | ||
<Path Fill="{DynamicResource ThemeForegroundBrush}" | ||
Width="8" | ||
Height="4" | ||
Stretch="Uniform" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Data="M0,0 L3,0 4.5,1.5 6,0 9,0 4.5,4.5 z"/> | ||
</Template> | ||
</Setter> | ||
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton:disabled"> | ||
<Setter Property="BorderBrush" Value="{TemplateBinding BorderBrush}" /> | ||
</Style> | ||
<Style Selector="ButtonSpinner:right"> | ||
|
||
<!-- ButtonSpinner --> | ||
<Style Selector="ButtonSpinner"> | ||
<Setter Property="Background" Value="Transparent" /> | ||
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" /> | ||
<Setter Property="Padding" Value="10, 0" /> | ||
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" /> | ||
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" /> | ||
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" /> | ||
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" /> | ||
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" /> | ||
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> | ||
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> | ||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> | ||
<Setter Property="VerticalContentAlignment" Value="Center" /> | ||
<Setter Property="Template"> | ||
<ControlTemplate> | ||
<Border Name="border" | ||
Background="{TemplateBinding Background}" | ||
<Border Background="{TemplateBinding Background}" | ||
BorderBrush="{TemplateBinding BorderBrush}" | ||
BorderThickness="{TemplateBinding BorderThickness}" | ||
Margin="{TemplateBinding Padding}" | ||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" | ||
VerticalAlignment="{TemplateBinding VerticalAlignment}"> | ||
<Grid ColumnDefinitions="*,Auto"> | ||
<ContentPresenter Name="PART_ContentPresenter" Grid.Column="0" | ||
CornerRadius="{DynamicResource ControlCornerRadius}"> | ||
<Grid ColumnDefinitions="Auto,*,Auto"> | ||
<ContentPresenter Name="PART_ContentPresenter" | ||
Grid.Column="1" | ||
ContentTemplate="{TemplateBinding ContentTemplate}" | ||
Content="{TemplateBinding Content}" | ||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" | ||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" | ||
Padding="{TemplateBinding Padding}"/> | ||
<Grid Grid.Column="1" RowDefinitions="*,*" IsVisible="{TemplateBinding ShowButtonSpinner}"> | ||
<RepeatButton Grid.Row="0" Name="PART_IncreaseButton"/> | ||
<RepeatButton Grid.Row="1" Name="PART_DecreaseButton"/> | ||
</Grid> | ||
Padding="{TemplateBinding Padding}" /> | ||
|
||
<StackPanel Name="PART_SpinnerPanel" | ||
Orientation="Horizontal" | ||
IsVisible="{TemplateBinding ShowButtonSpinner}"> | ||
<RepeatButton Name="PART_IncreaseButton" | ||
Classes="ButtonSpinnerRepeatButton" | ||
VerticalContentAlignment="Center" | ||
Foreground="{TemplateBinding Foreground}" | ||
BorderBrush="{TemplateBinding BorderBrush}" | ||
Background="{TemplateBinding Background}" | ||
FontSize="{TemplateBinding FontSize}"> | ||
<Path Fill="{TemplateBinding Foreground}" | ||
Width="16" | ||
Height="8" | ||
Stretch="Uniform" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Data="{StaticResource ButtonSpinnerIncreaseButtonIcon}" /> | ||
</RepeatButton> | ||
|
||
<RepeatButton Name="PART_DecreaseButton" | ||
Classes="ButtonSpinnerRepeatButton" | ||
Foreground="{TemplateBinding Foreground}" | ||
BorderBrush="{TemplateBinding BorderBrush}" | ||
Background="{TemplateBinding Background}" | ||
VerticalContentAlignment="Center" | ||
FontSize="{TemplateBinding FontSize}"> | ||
<Path Fill="{TemplateBinding Foreground}" | ||
Width="16" | ||
Height="8" | ||
Stretch="Uniform" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Data="{StaticResource ButtonSpinnerDecreaseButtonIcon}" /> | ||
</RepeatButton> | ||
<Border Name="PART_UpDownIconBorder" | ||
MinWidth="34"> | ||
<Path Name="PART_UpDownPathIcon" | ||
Fill="{TemplateBinding Foreground}" | ||
Height="12" | ||
Stretch="Uniform" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Data="{StaticResource ButtonSpinnerIncreaseDecreaseButtonIcon}" /> | ||
</Border> | ||
|
||
<Popup x:Name="UpDownPopup" | ||
Grid.Row="1" | ||
Grid.Column="1" | ||
VerticalOffset="-20" | ||
HorizontalOffset="-28" | ||
PlacementMode="Right" | ||
PlacementTarget="{TemplateBinding}" | ||
HorizontalAlignment="Left"> | ||
|
||
<Border Background="{DynamicResource SystemControlBackgroundAltHighBrush}" | ||
BorderBrush="{DynamicResource ToolTipBorderBrush}" | ||
BorderThickness="{DynamicResource ToolTipBorderThemeThickness}" | ||
CornerRadius="{DynamicResource OverlayCornerRadius}"> | ||
<Grid x:Name="PopupContentRoot" | ||
RowDefinitions="*,*"> | ||
<RepeatButton x:Name="PopupUpSpinButton" | ||
Classes="ButtonSpinnerRepeatButton"> | ||
<Path Fill="{TemplateBinding Foreground}" | ||
Width="16" | ||
Height="8" | ||
Stretch="Uniform" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Data="{StaticResource ButtonSpinnerDecreaseButtonIcon}" /> | ||
</RepeatButton> | ||
|
||
<RepeatButton x:Name="PopupDownSpinButton" | ||
Grid.Row="1" | ||
Classes="ButtonSpinnerRepeatButton" | ||
Content="" /> | ||
</Grid> | ||
</Border> | ||
</Popup> | ||
</StackPanel> | ||
</Grid> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter> | ||
</Style> | ||
<Style Selector="ButtonSpinner:left"> | ||
<Setter Property="Template"> | ||
<ControlTemplate> | ||
<Border Name="border" | ||
Background="{TemplateBinding Background}" | ||
BorderBrush="{TemplateBinding BorderBrush}" | ||
BorderThickness="{TemplateBinding BorderThickness}" | ||
Margin="{TemplateBinding Padding}" | ||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" | ||
VerticalAlignment="{TemplateBinding VerticalAlignment}"> | ||
<Grid ColumnDefinitions="Auto,*"> | ||
<Grid Grid.Column="0" RowDefinitions="*,*" IsVisible="{TemplateBinding ShowButtonSpinner}"> | ||
<RepeatButton Grid.Row="0" Name="PART_IncreaseButton"/> | ||
<RepeatButton Grid.Row="1" Name="PART_DecreaseButton"/> | ||
</Grid> | ||
<ContentPresenter Name="PART_ContentPresenter" Grid.Column="1" | ||
ContentTemplate="{TemplateBinding ContentTemplate}" | ||
Content="{TemplateBinding Content}" | ||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" | ||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" | ||
Padding="{TemplateBinding Padding}"/> | ||
</Grid> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter> | ||
|
||
<!-- ButtonSpinnerLocation=Right --> | ||
<Style Selector="ButtonSpinner:right /template/ StackPanel#PART_SpinnerPanel"> | ||
<Setter Property="Grid.Column" Value="2" /> | ||
</Style> | ||
<Style Selector="ButtonSpinner:right /template/ RepeatButton.ButtonSpinnerRepeatButton"> | ||
<Setter Property="BorderThickness" Value="{Binding $parent[ButtonSpinner].BorderThickness, Converter={StaticResource ButtonSpinner_OnlyLeftThinknessConverter}}" /> | ||
</Style> | ||
|
||
<!-- ButtonSpinnerLocation=Left --> | ||
<Style Selector="ButtonSpinner:left /template/ StackPanel#PART_SpinnerPanel"> | ||
<Setter Property="Grid.Column" Value="0" /> | ||
</Style> | ||
<Style Selector="ButtonSpinner:left /template/ RepeatButton.ButtonSpinnerRepeatButton"> | ||
<Setter Property="BorderThickness" Value="{Binding $parent[ButtonSpinner].BorderThickness, Converter={StaticResource ButtonSpinner_OnlyRightThinknessConverter}}" /> | ||
</Style> | ||
|
||
<!-- Inline (default) --> | ||
<Style Selector="ButtonSpinner:not(.CompactInlineButtonSpinner) /template/ Border#PART_UpDownIconBorder"> | ||
<Setter Property="IsVisible" Value="False" /> | ||
</Style> | ||
|
||
<!-- CompactInline --> | ||
<Style Selector="ButtonSpinner.CompactInlineButtonSpinner /template/ RepeatButton.ButtonSpinnerRepeatButton"> | ||
<Setter Property="IsVisible" Value="False" /> | ||
</Style> | ||
<Style Selector="ButtonSpinner:pointerover /template/ Border#border"> | ||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}"/> | ||
|
||
<Style Selector="ButtonSpinner.CompactInlineButtonSpinner[AllowSpin=false] /template/ Path#PART_UpDownPathIcon"> | ||
<Setter Property="Opacity" Value="0.5" /> | ||
</Style> | ||
<Style Selector="ButtonSpinner:focus /template/ Border#border"> | ||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}"/> | ||
|
||
<Style Selector="ButtonSpinner.CompactInlineButtonSpinner:pointerover /template/ Popup#UpDownPopup"> | ||
<Setter Property="IsOpen" Value="True" /> | ||
</Style> | ||
<Style Selector="ButtonSpinner:error /template/ Border#border"> | ||
<Setter Property="BorderBrush" Value="{DynamicResource ErrorBrush}"/> | ||
|
||
<!-- Error state --> | ||
<Style Selector="ButtonSpinner:error"> | ||
<Setter Property="BorderBrush" Value="{DynamicResource ErrorBrush}" /> | ||
</Style> | ||
|
||
</Styles> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this class to be called "ThicknessMultiplierConverter", but it is public...