committed by
GitHub
12 changed files with 204 additions and 116 deletions
@ -1,104 +1,140 @@ |
|||
<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"/> |
|||
<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 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> |
|||
</Styles.Resources> |
|||
|
|||
<!-- RepeatButton.ButtonSpinnerRepeatButton --> |
|||
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton"> |
|||
<Setter Property="MinWidth" Value="34" /> |
|||
<Setter Property="VerticalAlignment" Value="Stretch" /> |
|||
</Style> |
|||
<Style Selector="ButtonSpinner /template/ RepeatButton"> |
|||
<Setter Property="Background" Value="Transparent"/> |
|||
<Setter Property="BorderBrush" Value="Transparent"/> |
|||
|
|||
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton /template/ ContentPresenter"> |
|||
<Setter Property="CornerRadius" Value="0" /> |
|||
<Setter Property="BorderBrush" Value="{TemplateBinding BorderBrush}" /> |
|||
</Style> |
|||
<Style Selector="ButtonSpinner /template/ RepeatButton:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
|||
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton:disabled"> |
|||
<Setter Property="BorderBrush" Value="{TemplateBinding BorderBrush}" /> |
|||
</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:disabled > Path"> |
|||
<Setter Property="Fill" Value="{DynamicResource RepeatButtonForegroundDisabled}" /> |
|||
</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> |
|||
<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> |
|||
</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> |
|||
<Style Selector="ButtonSpinner:pointerover /template/ Border#border"> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}"/> |
|||
|
|||
<!-- ButtonSpinnerLocation=Left --> |
|||
<Style Selector="ButtonSpinner:left /template/ StackPanel#PART_SpinnerPanel"> |
|||
<Setter Property="Grid.Column" Value="0" /> |
|||
</Style> |
|||
<Style Selector="ButtonSpinner:focus /template/ Border#border"> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}"/> |
|||
<Style Selector="ButtonSpinner:left /template/ RepeatButton.ButtonSpinnerRepeatButton"> |
|||
<Setter Property="BorderThickness" Value="{Binding $parent[ButtonSpinner].BorderThickness, Converter={StaticResource ButtonSpinner_OnlyRightThinknessConverter}}" /> |
|||
</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> |
|||
|
|||
@ -1,38 +1,60 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui"> |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Design.PreviewWith> |
|||
<Border Padding="20" |
|||
Background="Black"> |
|||
<StackPanel Spacing="20"> |
|||
<NumericUpDown Minimum="0" |
|||
Maximum="10" |
|||
Increment="0.5" |
|||
Width="150" |
|||
Watermark="Enter text" /> |
|||
<NumericUpDown Minimum="0" |
|||
Maximum="10" |
|||
Increment="0.5" |
|||
Width="150" |
|||
ButtonSpinnerLocation="Left" |
|||
Watermark="Enter text" /> |
|||
</StackPanel> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
|
|||
<Style Selector="NumericUpDown"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
|||
<Setter Property="Padding" Value="4"/> |
|||
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" /> |
|||
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" /> |
|||
<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="Padding" Value="{DynamicResource TextControlThemePadding}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<ButtonSpinner Name="PART_Spinner" |
|||
Background="{TemplateBinding Background}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
Padding="0" |
|||
HorizontalContentAlignment="Stretch" |
|||
VerticalContentAlignment="Stretch" |
|||
AllowSpin="{TemplateBinding AllowSpin}" |
|||
ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}" |
|||
ButtonSpinnerLocation="{TemplateBinding ButtonSpinnerLocation}"> |
|||
<TextBox Name="PART_TextBox" |
|||
BorderThickness="0" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
Background="Transparent" |
|||
BorderBrush="Transparent" |
|||
Margin="-2" |
|||
Padding="{TemplateBinding Padding}" |
|||
Watermark="{TemplateBinding Watermark}" |
|||
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" |
|||
IsReadOnly="{TemplateBinding IsReadOnly}" |
|||
Text="{TemplateBinding Text}" |
|||
AcceptsReturn="False" |
|||
TextWrapping="NoWrap"> |
|||
</TextBox> |
|||
TextWrapping="NoWrap" /> |
|||
</ButtonSpinner> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="NumericUpDown /template/ TextBox#PART_TextBox"> |
|||
<Setter Property="Margin" Value="4"/> |
|||
<Setter Property="MinWidth" Value="20"/> |
|||
</Style> |
|||
</Styles> |
|||
|
|||
</Styles> |
|||
|
|||
Loading…
Reference in new issue