committed by
GitHub
56 changed files with 1664 additions and 448 deletions
@ -1,104 +1,140 @@ |
|||||
<Styles xmlns="https://github.com/avaloniaui"> |
<Styles xmlns="https://github.com/avaloniaui" |
||||
<Style Selector="ButtonSpinner"> |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
<Setter Property="Background" Value="Transparent"/> |
xmlns:sys="clr-namespace:System;assembly=netstandard" |
||||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"> |
||||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
<Design.PreviewWith> |
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/> |
<Border Padding="20" |
||||
<Setter Property="VerticalContentAlignment" Value="Center"/> |
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> |
||||
<Style Selector="ButtonSpinner /template/ RepeatButton"> |
|
||||
<Setter Property="Background" Value="Transparent"/> |
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton /template/ ContentPresenter"> |
||||
<Setter Property="BorderBrush" Value="Transparent"/> |
<Setter Property="CornerRadius" Value="0" /> |
||||
|
<Setter Property="BorderBrush" Value="{TemplateBinding BorderBrush}" /> |
||||
</Style> |
</Style> |
||||
<Style Selector="ButtonSpinner /template/ RepeatButton:pointerover"> |
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton:disabled"> |
||||
<Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/> |
<Setter Property="BorderBrush" Value="{TemplateBinding BorderBrush}" /> |
||||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
|
||||
</Style> |
</Style> |
||||
<Style Selector="ButtonSpinner /template/ RepeatButton#PART_IncreaseButton"> |
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton:disabled > Path"> |
||||
<Setter Property="Content"> |
<Setter Property="Fill" Value="{DynamicResource RepeatButtonForegroundDisabled}" /> |
||||
<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> |
</Style> |
||||
<Style Selector="ButtonSpinner /template/ RepeatButton#PART_DecreaseButton"> |
|
||||
<Setter Property="Content"> |
<!-- ButtonSpinner --> |
||||
<Template> |
<Style Selector="ButtonSpinner"> |
||||
<Path Fill="{DynamicResource ThemeForegroundBrush}" |
<Setter Property="Background" Value="Transparent" /> |
||||
Width="8" |
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" /> |
||||
Height="4" |
<Setter Property="Padding" Value="10, 0" /> |
||||
Stretch="Uniform" |
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" /> |
||||
HorizontalAlignment="Center" |
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" /> |
||||
VerticalAlignment="Center" |
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" /> |
||||
Data="M0,0 L3,0 4.5,1.5 6,0 9,0 4.5,4.5 z"/> |
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" /> |
||||
</Template> |
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" /> |
||||
</Setter> |
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> |
||||
</Style> |
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> |
||||
<Style Selector="ButtonSpinner:right"> |
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> |
||||
|
<Setter Property="VerticalContentAlignment" Value="Center" /> |
||||
<Setter Property="Template"> |
<Setter Property="Template"> |
||||
<ControlTemplate> |
<ControlTemplate> |
||||
<Border Name="border" |
<Border Background="{TemplateBinding Background}" |
||||
Background="{TemplateBinding Background}" |
|
||||
BorderBrush="{TemplateBinding BorderBrush}" |
BorderBrush="{TemplateBinding BorderBrush}" |
||||
BorderThickness="{TemplateBinding BorderThickness}" |
BorderThickness="{TemplateBinding BorderThickness}" |
||||
Margin="{TemplateBinding Padding}" |
CornerRadius="{DynamicResource ControlCornerRadius}"> |
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" |
<Grid ColumnDefinitions="Auto,*,Auto"> |
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"> |
<ContentPresenter Name="PART_ContentPresenter" |
||||
<Grid ColumnDefinitions="*,Auto"> |
Grid.Column="1" |
||||
<ContentPresenter Name="PART_ContentPresenter" Grid.Column="0" |
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" |
ContentTemplate="{TemplateBinding ContentTemplate}" |
||||
Content="{TemplateBinding Content}" |
Content="{TemplateBinding Content}" |
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
||||
Padding="{TemplateBinding Padding}"/> |
Padding="{TemplateBinding Padding}" /> |
||||
<Grid Grid.Column="1" RowDefinitions="*,*" IsVisible="{TemplateBinding ShowButtonSpinner}"> |
|
||||
<RepeatButton Grid.Row="0" Name="PART_IncreaseButton"/> |
<StackPanel Name="PART_SpinnerPanel" |
||||
<RepeatButton Grid.Row="1" Name="PART_DecreaseButton"/> |
Orientation="Horizontal" |
||||
</Grid> |
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> |
</Grid> |
||||
</Border> |
</Border> |
||||
</ControlTemplate> |
</ControlTemplate> |
||||
</Setter> |
</Setter> |
||||
</Style> |
</Style> |
||||
<Style Selector="ButtonSpinner:left"> |
|
||||
<Setter Property="Template"> |
<!-- ButtonSpinnerLocation=Right --> |
||||
<ControlTemplate> |
<Style Selector="ButtonSpinner:right /template/ StackPanel#PART_SpinnerPanel"> |
||||
<Border Name="border" |
<Setter Property="Grid.Column" Value="2" /> |
||||
Background="{TemplateBinding Background}" |
</Style> |
||||
BorderBrush="{TemplateBinding BorderBrush}" |
<Style Selector="ButtonSpinner:right /template/ RepeatButton.ButtonSpinnerRepeatButton"> |
||||
BorderThickness="{TemplateBinding BorderThickness}" |
<Setter Property="BorderThickness" Value="{Binding $parent[ButtonSpinner].BorderThickness, Converter={StaticResource ButtonSpinner_OnlyLeftThinknessConverter}}" /> |
||||
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> |
|
||||
</Style> |
</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> |
||||
<Style Selector="ButtonSpinner:focus /template/ Border#border"> |
<Style Selector="ButtonSpinner:left /template/ RepeatButton.ButtonSpinnerRepeatButton"> |
||||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}"/> |
<Setter Property="BorderThickness" Value="{Binding $parent[ButtonSpinner].BorderThickness, Converter={StaticResource ButtonSpinner_OnlyRightThinknessConverter}}" /> |
||||
</Style> |
</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> |
</Style> |
||||
|
|
||||
</Styles> |
</Styles> |
||||
|
|||||
@ -0,0 +1,6 @@ |
|||||
|
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
|
<Style Selector="TextBlock.CaptionTextBlockStyle"> |
||||
|
<Setter Property="FontSize" Value="12" /> |
||||
|
<Setter Property="FontWeight" Value="Normal" /> |
||||
|
</Style> |
||||
|
</Styles> |
||||
@ -1,16 +1,34 @@ |
|||||
<Style xmlns="https://github.com/avaloniaui" Selector="Menu"> |
<Style xmlns="https://github.com/avaloniaui" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
Selector="Menu"> |
||||
|
<Design.PreviewWith> |
||||
|
<Border Padding="20"> |
||||
|
<Menu> |
||||
|
<MenuItem Header="New" /> |
||||
|
<MenuItem Header="Open" /> |
||||
|
</Menu> |
||||
|
</Border> |
||||
|
</Design.PreviewWith> |
||||
|
|
||||
|
<Style.Resources> |
||||
|
<x:Double x:Key="MenuHeight">32</x:Double> |
||||
|
</Style.Resources> |
||||
|
<Setter Property="Background" Value="Transparent" /> |
||||
|
<Setter Property="Height" Value="{StaticResource MenuHeight}" /> |
||||
<Setter Property="Template"> |
<Setter Property="Template"> |
||||
<ControlTemplate> |
<ControlTemplate> |
||||
<Border Background="{TemplateBinding Background}" |
<Border Background="{TemplateBinding Background}" |
||||
BorderBrush="{TemplateBinding BorderBrush}" |
BorderBrush="{TemplateBinding BorderBrush}" |
||||
BorderThickness="{TemplateBinding BorderThickness}" |
BorderThickness="{TemplateBinding BorderThickness}" |
||||
|
HorizontalAlignment="Stretch" |
||||
Padding="{TemplateBinding Padding}"> |
Padding="{TemplateBinding Padding}"> |
||||
<ItemsPresenter Name="PART_ItemsPresenter" |
<ItemsPresenter Name="PART_ItemsPresenter" |
||||
Items="{TemplateBinding Items}" |
Items="{TemplateBinding Items}" |
||||
ItemsPanel="{TemplateBinding ItemsPanel}" |
ItemsPanel="{TemplateBinding ItemsPanel}" |
||||
ItemTemplate="{TemplateBinding ItemTemplate}" |
ItemTemplate="{TemplateBinding ItemTemplate}" |
||||
KeyboardNavigation.TabNavigation="Continue"/> |
VerticalAlignment="Stretch" |
||||
|
KeyboardNavigation.TabNavigation="Continue" /> |
||||
</Border> |
</Border> |
||||
</ControlTemplate> |
</ControlTemplate> |
||||
</Setter> |
</Setter> |
||||
</Style> |
</Style> |
||||
|
|||||
@ -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"> |
<Style Selector="NumericUpDown"> |
||||
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}" /> |
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" /> |
||||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" /> |
||||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" /> |
||||
<Setter Property="Padding" Value="4"/> |
<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"> |
<Setter Property="Template"> |
||||
<ControlTemplate> |
<ControlTemplate> |
||||
<ButtonSpinner Name="PART_Spinner" |
<ButtonSpinner Name="PART_Spinner" |
||||
Background="{TemplateBinding Background}" |
Background="{TemplateBinding Background}" |
||||
BorderThickness="{TemplateBinding BorderThickness}" |
BorderThickness="{TemplateBinding BorderThickness}" |
||||
BorderBrush="{TemplateBinding BorderBrush}" |
BorderBrush="{TemplateBinding BorderBrush}" |
||||
|
Padding="0" |
||||
HorizontalContentAlignment="Stretch" |
HorizontalContentAlignment="Stretch" |
||||
VerticalContentAlignment="Stretch" |
VerticalContentAlignment="Stretch" |
||||
AllowSpin="{TemplateBinding AllowSpin}" |
AllowSpin="{TemplateBinding AllowSpin}" |
||||
ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}" |
ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}" |
||||
ButtonSpinnerLocation="{TemplateBinding ButtonSpinnerLocation}"> |
ButtonSpinnerLocation="{TemplateBinding ButtonSpinnerLocation}"> |
||||
<TextBox Name="PART_TextBox" |
<TextBox Name="PART_TextBox" |
||||
BorderThickness="0" |
Background="Transparent" |
||||
Background="{TemplateBinding Background}" |
BorderBrush="Transparent" |
||||
BorderBrush="{TemplateBinding BorderBrush}" |
Margin="-2" |
||||
Padding="{TemplateBinding Padding}" |
Padding="{TemplateBinding Padding}" |
||||
Watermark="{TemplateBinding Watermark}" |
Watermark="{TemplateBinding Watermark}" |
||||
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" |
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" |
||||
IsReadOnly="{TemplateBinding IsReadOnly}" |
IsReadOnly="{TemplateBinding IsReadOnly}" |
||||
Text="{TemplateBinding Text}" |
Text="{TemplateBinding Text}" |
||||
AcceptsReturn="False" |
AcceptsReturn="False" |
||||
TextWrapping="NoWrap"> |
TextWrapping="NoWrap" /> |
||||
</TextBox> |
|
||||
</ButtonSpinner> |
</ButtonSpinner> |
||||
</ControlTemplate> |
</ControlTemplate> |
||||
</Setter> |
</Setter> |
||||
</Style> |
</Style> |
||||
<Style Selector="NumericUpDown /template/ TextBox#PART_TextBox"> |
|
||||
<Setter Property="Margin" Value="4"/> |
</Styles> |
||||
<Setter Property="MinWidth" Value="20"/> |
|
||||
</Style> |
|
||||
</Styles> |
|
||||
|
|||||
@ -0,0 +1,62 @@ |
|||||
|
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
|
<Design.PreviewWith> |
||||
|
<Border Padding="20"> |
||||
|
<StackPanel Spacing="20"> |
||||
|
<RepeatButton Content="Click Me!" /> |
||||
|
</StackPanel> |
||||
|
</Border> |
||||
|
</Design.PreviewWith> |
||||
|
<Styles.Resources> |
||||
|
<Thickness x:Key="ButtonPadding">8,5,8,6</Thickness> |
||||
|
</Styles.Resources> |
||||
|
<Style Selector="RepeatButton"> |
||||
|
<Setter Property="Background" Value="{DynamicResource RepeatButtonBackground}" /> |
||||
|
<!--<Setter Property="BackgroundSizing" Value="OuterBorderEdge" />--> |
||||
|
<Setter Property="Foreground" Value="{DynamicResource RepeatButtonForeground}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrush}" /> |
||||
|
<Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" /> |
||||
|
<Setter Property="Padding" Value="{StaticResource ButtonPadding}" /> |
||||
|
<Setter Property="HorizontalAlignment" Value="Left" /> |
||||
|
<Setter Property="VerticalAlignment" Value="Center" /> |
||||
|
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> |
||||
|
<Setter Property="FontWeight" Value="Normal" /> |
||||
|
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> |
||||
|
<!--<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" /> |
||||
|
<Setter Property="FocusVisualMargin" Value="-3" />--> |
||||
|
<Setter Property="Template"> |
||||
|
<ControlTemplate> |
||||
|
<ContentPresenter x:Name="PART_ContentPresenter" |
||||
|
Background="{TemplateBinding Background}" |
||||
|
BorderBrush="{TemplateBinding BorderBrush}" |
||||
|
BorderThickness="{TemplateBinding BorderThickness}" |
||||
|
Content="{TemplateBinding Content}" |
||||
|
ContentTemplate="{TemplateBinding ContentTemplate}" |
||||
|
Padding="{TemplateBinding Padding}" |
||||
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
||||
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> |
||||
|
</ControlTemplate> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="RepeatButton /template/ ContentPresenter"> |
||||
|
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="RepeatButton:pointerover /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource RepeatButtonBackgroundPointerOver}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrushPointerOver}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource RepeatButtonForegroundPointerOver}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="RepeatButton:pressed /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource RepeatButtonBackgroundPressed}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrushPressed}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource RepeatButtonForegroundPressed}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="RepeatButton:disabled /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource RepeatButtonBackgroundDisabled}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrushDisabled}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource RepeatButtonForegroundDisabled}" /> |
||||
|
</Style> |
||||
|
</Styles> |
||||
@ -1,38 +1,108 @@ |
|||||
<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"> |
||||
|
<StackPanel Spacing="20"> |
||||
|
<ToggleButton Content="Click Me!" /> |
||||
|
<ToggleButton Content="Disabled" IsEnabled="False" /> |
||||
|
<ToggleButton Content="Three state" IsThreeState="True" /> |
||||
|
</StackPanel> |
||||
|
</Border> |
||||
|
</Design.PreviewWith> |
||||
|
|
||||
|
<Styles.Resources> |
||||
|
<Thickness x:Key="ButtonPadding">8,5,8,6</Thickness> |
||||
|
</Styles.Resources> |
||||
<Style Selector="ToggleButton"> |
<Style Selector="ToggleButton"> |
||||
<Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/> |
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackground}" /> |
||||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}"/> |
<Setter Property="Foreground" Value="{DynamicResource ToggleButtonForeground}" /> |
||||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrush}" /> |
||||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
<Setter Property="BorderThickness" Value="{DynamicResource ToggleButtonBorderThemeThickness}" /> |
||||
<Setter Property="Padding" Value="4"/> |
<Setter Property="Padding" Value="{DynamicResource ButtonPadding}" /> |
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/> |
<Setter Property="HorizontalAlignment" Value="Left" /> |
||||
<Setter Property="VerticalContentAlignment" Value="Center"/> |
<Setter Property="VerticalAlignment" Value="Center" /> |
||||
|
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> |
||||
|
<Setter Property="FontWeight" Value="Normal" /> |
||||
|
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> |
||||
<Setter Property="Template"> |
<Setter Property="Template"> |
||||
<ControlTemplate> |
<ControlTemplate> |
||||
<ContentPresenter Name="PART_ContentPresenter" |
<ContentPresenter x:Name="PART_ContentPresenter" |
||||
Background="{TemplateBinding Background}" |
Background="{TemplateBinding Background}" |
||||
BorderBrush="{TemplateBinding BorderBrush}" |
BorderBrush="{TemplateBinding BorderBrush}" |
||||
BorderThickness="{TemplateBinding BorderThickness}" |
BorderThickness="{TemplateBinding BorderThickness}" |
||||
ContentTemplate="{TemplateBinding ContentTemplate}" |
CornerRadius="{DynamicResource ControlCornerRadius}" |
||||
Content="{TemplateBinding Content}" |
Content="{TemplateBinding Content}" |
||||
|
ContentTemplate="{TemplateBinding ContentTemplate}" |
||||
Padding="{TemplateBinding Padding}" |
Padding="{TemplateBinding Padding}" |
||||
TextBlock.Foreground="{TemplateBinding Foreground}" |
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> |
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> |
||||
</ControlTemplate> |
</ControlTemplate> |
||||
</Setter> |
</Setter> |
||||
</Style> |
</Style> |
||||
<Style Selector="ToggleButton:checked /template/ ContentPresenter"> |
|
||||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighBrush}"/> |
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
|
||||
</Style> |
|
||||
<Style Selector="ToggleButton:pointerover /template/ ContentPresenter"> |
<Style Selector="ToggleButton:pointerover /template/ ContentPresenter"> |
||||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundPointerOver}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrushPointerOver}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ToggleButtonForegroundPointerOver}" /> |
||||
</Style> |
</Style> |
||||
|
|
||||
<Style Selector="ToggleButton:pressed /template/ ContentPresenter"> |
<Style Selector="ToggleButton:pressed /template/ ContentPresenter"> |
||||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighBrush}"/> |
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundPressed}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrushPressed}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ToggleButtonForegroundPressed}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ToggleButton:disabled /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundDisabled}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrushDisabled}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ToggleButtonForegroundDisabled}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ToggleButton:checked /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundChecked}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrushChecked}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ToggleButtonForegroundChecked}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ToggleButton:checked:pointerover /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundCheckedPointerOver}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrushCheckedPointerOver}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ToggleButtonForegroundCheckedPointerOver}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ToggleButton:checked:pressed /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundCheckedPressed}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrushCheckedPressed}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ToggleButtonForegroundCheckedPressed}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ToggleButton:checked:disabled /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundCheckedDisabled}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrushCheckedDisabled}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ToggleButtonForegroundCheckedDisabled}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ToggleButton:indeterminate /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundIndeterminate}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrushIndeterminate}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ToggleButtonForegroundIndeterminate}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ToggleButton:indeterminate:pointerover /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundIndeterminatePointerOver}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrushIndeterminatePointerOver}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ToggleButtonForegroundIndeterminatePointerOver}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ToggleButton:indeterminate:pressed /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundIndeterminatePressed}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrushIndeterminatePressed}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ToggleButtonForegroundIndeterminatePressed}" /> |
||||
</Style> |
</Style> |
||||
<Style Selector="ToggleButton:disabled"> |
|
||||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/> |
<Style Selector="ToggleButton:indeterminate:disabled /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundIndeterminateDisabled}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrushIndeterminateDisabled}" /> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ToggleButtonForegroundIndeterminateDisabled}" /> |
||||
</Style> |
</Style> |
||||
</Styles> |
</Styles> |
||||
|
|||||
@ -0,0 +1,119 @@ |
|||||
|
using System; |
||||
|
using Avalonia.Utilities; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Avalonia.Base.UnitTests.Utilities |
||||
|
{ |
||||
|
public class MathUtilitiesTests |
||||
|
{ |
||||
|
private const double AnyValue = 42.42; |
||||
|
private readonly double _calculatedAnyValue; |
||||
|
private readonly double _one; |
||||
|
private readonly double _zero; |
||||
|
|
||||
|
public MathUtilitiesTests() |
||||
|
{ |
||||
|
_calculatedAnyValue = 0.0; |
||||
|
_one = 0.0; |
||||
|
_zero = 1.0; |
||||
|
|
||||
|
const int N = 10; |
||||
|
var dxAny = AnyValue / N; |
||||
|
var dxOne = 1.0 / N; |
||||
|
var dxZero = _zero / N; |
||||
|
|
||||
|
for (var i = 0; i < N; ++i) |
||||
|
{ |
||||
|
_calculatedAnyValue += dxAny; |
||||
|
_one += dxOne; |
||||
|
_zero -= dxZero; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Two_Equivalent_Double_Values_Are_Close() |
||||
|
{ |
||||
|
var actual = MathUtilities.AreClose(AnyValue, _calculatedAnyValue); |
||||
|
|
||||
|
Assert.True(actual); |
||||
|
Assert.Equal(AnyValue, Math.Round(_calculatedAnyValue, 14)); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Two_Equivalent_Single_Values_Are_Close() |
||||
|
{ |
||||
|
var expectedValue = (float)AnyValue; |
||||
|
var actualValue = (float)_calculatedAnyValue; |
||||
|
|
||||
|
var actual = MathUtilities.AreClose(expectedValue, actualValue); |
||||
|
|
||||
|
Assert.True(actual); |
||||
|
Assert.Equal((float) Math.Round(expectedValue, 5), (float) Math.Round(actualValue, 4)); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Calculated_Double_One_Is_One() |
||||
|
{ |
||||
|
var actual = MathUtilities.IsOne(_one); |
||||
|
|
||||
|
Assert.True(actual); |
||||
|
Assert.Equal(1.0, Math.Round(_one, 15)); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Calculated_Single_One_Is_One() |
||||
|
{ |
||||
|
var actualValue = (float)_one; |
||||
|
|
||||
|
var actual = MathUtilities.IsOne(actualValue); |
||||
|
|
||||
|
Assert.True(actual); |
||||
|
Assert.Equal(1.0f, (float) Math.Round(actualValue, 7)); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Calculated_Double_Zero_Is_Zero() |
||||
|
{ |
||||
|
var actual = MathUtilities.IsZero(_zero); |
||||
|
|
||||
|
Assert.True(actual); |
||||
|
Assert.Equal(0.0, Math.Round(_zero, 15)); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Calculated_Single_Zero_Is_Zero() |
||||
|
{ |
||||
|
var actualValue = (float)_zero; |
||||
|
|
||||
|
var actual = MathUtilities.IsZero(actualValue); |
||||
|
|
||||
|
Assert.True(actual); |
||||
|
Assert.Equal(0.0f, (float) Math.Round(actualValue, 7)); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Clamp_Input_NaN_Return_NaN() |
||||
|
{ |
||||
|
var clamp = MathUtilities.Clamp(double.NaN, 0.0, 1.0); |
||||
|
Assert.True(double.IsNaN(clamp)); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Clamp_Input_NegativeInfinity_Return_Min() |
||||
|
{ |
||||
|
const double min = 0.0; |
||||
|
const double max = 1.0; |
||||
|
var actual = MathUtilities.Clamp(double.NegativeInfinity, min, max); |
||||
|
Assert.Equal(min, actual); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Clamp_Input_PositiveInfinity_Return_Max() |
||||
|
{ |
||||
|
const double min = 0.0; |
||||
|
const double max = 1.0; |
||||
|
var actual = MathUtilities.Clamp(double.PositiveInfinity, min, max); |
||||
|
Assert.Equal(max, actual); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
using System.ComponentModel; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using JetBrains.Annotations; |
||||
|
|
||||
|
namespace Avalonia.Benchmarks.Data |
||||
|
{ |
||||
|
internal class AccessorTestObject : INotifyPropertyChanged |
||||
|
{ |
||||
|
private string _test; |
||||
|
|
||||
|
public string Test |
||||
|
{ |
||||
|
get => _test; |
||||
|
set |
||||
|
{ |
||||
|
if (_test == value) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
_test = value; |
||||
|
|
||||
|
OnPropertyChanged(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public event PropertyChangedEventHandler PropertyChanged; |
||||
|
|
||||
|
public void Execute() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public void Execute(object p0) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public void Execute(object p0, object p1) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
[NotifyPropertyChangedInvocator] |
||||
|
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) |
||||
|
{ |
||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,60 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Avalonia.Data.Core.Plugins; |
||||
|
using BenchmarkDotNet.Attributes; |
||||
|
|
||||
|
namespace Avalonia.Benchmarks.Data |
||||
|
{ |
||||
|
[MemoryDiagnoser, InProcess] |
||||
|
public class PropertyAccessorPluginBenchmarks |
||||
|
{ |
||||
|
private readonly AccessorTestObject _targetStrongRef = new AccessorTestObject(); |
||||
|
|
||||
|
private readonly List<IPropertyAccessorPlugin> _oldPlugins; |
||||
|
private readonly List<IPropertyAccessorPlugin> _newPlugins; |
||||
|
|
||||
|
public PropertyAccessorPluginBenchmarks() |
||||
|
{ |
||||
|
_oldPlugins = new List<IPropertyAccessorPlugin> |
||||
|
{ |
||||
|
new AvaloniaPropertyAccessorPlugin(), |
||||
|
new MethodAccessorPlugin(), |
||||
|
new InpcPropertyAccessorPlugin() |
||||
|
}; |
||||
|
|
||||
|
_newPlugins = new List<IPropertyAccessorPlugin> |
||||
|
{ |
||||
|
new AvaloniaPropertyAccessorPlugin(), |
||||
|
new InpcPropertyAccessorPlugin(), |
||||
|
new MethodAccessorPlugin() |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
[Benchmark] |
||||
|
public void MatchAccessorOld() |
||||
|
{ |
||||
|
var propertyName = nameof(AccessorTestObject.Test); |
||||
|
|
||||
|
foreach (IPropertyAccessorPlugin x in _oldPlugins) |
||||
|
{ |
||||
|
if (x.Match(_targetStrongRef, propertyName)) |
||||
|
{ |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Benchmark] |
||||
|
public void MatchAccessorNew() |
||||
|
{ |
||||
|
var propertyName = nameof(AccessorTestObject.Test); |
||||
|
|
||||
|
foreach (IPropertyAccessorPlugin x in _newPlugins) |
||||
|
{ |
||||
|
if (x.Match(_targetStrongRef, propertyName)) |
||||
|
{ |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue