committed by
GitHub
26 changed files with 666 additions and 194 deletions
@ -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"> |
|||
<Setter Property="Background" Value="{DynamicResource RepeatButtonBackgroundDisabled}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrushDisabled}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource RepeatButtonForegroundDisabled}" /> |
|||
</Style> |
|||
</Styles> |
|||
@ -1,38 +1,109 @@ |
|||
<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"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}"/> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
<Setter Property="Padding" Value="4"/> |
|||
<Setter Property="HorizontalContentAlignment" Value="Center"/> |
|||
<Setter Property="VerticalContentAlignment" Value="Center"/> |
|||
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackground}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource ToggleButtonForeground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ToggleButtonBorderThemeThickness}" /> |
|||
<Setter Property="Padding" Value="{DynamicResource 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="Template"> |
|||
<ControlTemplate> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
<ContentPresenter x:Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
CornerRadius="{DynamicResource ControlCornerRadius}" |
|||
Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Padding="{TemplateBinding Padding}" |
|||
TextBlock.Foreground="{TemplateBinding Foreground}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ToggleButton:checked /template/ ContentPresenter"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighBrush}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
|||
</Style> |
|||
|
|||
<!-- PointerOverState --> |
|||
<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 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 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> |
|||
</Styles> |
|||
</Styles> |
|||
|
|||
@ -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