committed by
GitHub
37 changed files with 1541 additions and 243 deletions
@ -0,0 +1,37 @@ |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Input; |
|||
|
|||
namespace Avalonia.Controls.Mixins |
|||
{ |
|||
/// <summary>
|
|||
/// Adds pressed functionality to control classes.
|
|||
///
|
|||
/// Adds the ':pressed' class when the item is pressed.
|
|||
/// </summary>
|
|||
public static class PressedMixin |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="PressedMixin"/> class.
|
|||
/// </summary>
|
|||
/// <typeparam name="TControl">The control type.</typeparam>
|
|||
public static void Attach<TControl>() where TControl : Control |
|||
{ |
|||
InputElement.PointerPressedEvent.AddClassHandler<TControl>((x, e) => HandlePointerPressed(x, e), RoutingStrategies.Tunnel); |
|||
InputElement.PointerReleasedEvent.AddClassHandler<TControl>((x, e) => HandlePointerReleased(x), RoutingStrategies.Tunnel); |
|||
InputElement.PointerCaptureLostEvent.AddClassHandler<TControl>((x, e) => HandlePointerReleased(x), RoutingStrategies.Tunnel); |
|||
} |
|||
|
|||
private static void HandlePointerPressed<TControl>(TControl sender, PointerPressedEventArgs e) where TControl : Control |
|||
{ |
|||
if (e.GetCurrentPoint(sender).Properties.IsLeftButtonPressed) |
|||
{ |
|||
((IPseudoClasses)sender.Classes).Set(":pressed", true); |
|||
} |
|||
} |
|||
|
|||
private static void HandlePointerReleased<TControl>(TControl sender) where TControl : Control |
|||
{ |
|||
((IPseudoClasses)sender.Classes).Set(":pressed", false); |
|||
} |
|||
} |
|||
} |
|||
@ -1,64 +1,192 @@ |
|||
<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="10"> |
|||
<ComboBox PlaceholderText="Select an item"> |
|||
<ComboBoxItem>Item 1</ComboBoxItem> |
|||
<ComboBoxItem>Item 2</ComboBoxItem> |
|||
</ComboBox> |
|||
|
|||
<ComboBox IsEnabled="False"> |
|||
<ComboBoxItem>Item 1</ComboBoxItem> |
|||
<ComboBoxItem>Item 2</ComboBoxItem> |
|||
</ComboBox> |
|||
</StackPanel> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
<Styles.Resources> |
|||
<Thickness x:Key="ComboBoxTopHeaderMargin">0,0,0,4</Thickness> |
|||
<x:Int32 x:Key="ComboBoxPopupMaxNumberOfItems">15</x:Int32> |
|||
<x:Int32 x:Key="ComboBoxPopupMaxNumberOfItemsThatCanBeShownOnOneSide">7</x:Int32> |
|||
|
|||
<Thickness x:Key="ComboBoxPadding">12,5,0,7</Thickness> |
|||
<Thickness x:Key="ComboBoxEditableTextPadding">11,5,32,6</Thickness> |
|||
<x:Double x:Key="ComboBoxMinHeight">32</x:Double> |
|||
</Styles.Resources> |
|||
<Style Selector="ComboBox"> |
|||
<Setter Property="Background" Value="Transparent"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
|||
<Setter Property="Padding" Value="4"/> |
|||
<Setter Property="MinHeight" Value="20"/> |
|||
<Setter Property="Padding" Value="{DynamicResource ComboBoxPadding}" /> |
|||
<Setter Property="MaxDropDownHeight" Value="504" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForeground}" /> |
|||
<Setter Property="Background" Value="{DynamicResource ComboBoxBackground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ComboBoxBorderThemeThickness}" /> |
|||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> |
|||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="VerticalAlignment" Value="Top" /> |
|||
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> |
|||
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> |
|||
<Setter Property="PlaceholderForeground" Value="{DynamicResource ComboBoxPlaceHolderForeground}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Name="border" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}"> |
|||
<Grid ColumnDefinitions="*,Auto"> |
|||
<ContentControl Content="{TemplateBinding SelectionBoxItem}" |
|||
ContentTemplate="{TemplateBinding ItemTemplate}" |
|||
Margin="{TemplateBinding Padding}" |
|||
HorizontalAlignment="Left" |
|||
VerticalAlignment="Center"/> |
|||
<ToggleButton Name="toggle" |
|||
BorderThickness="0" |
|||
<Grid RowDefinitions="Auto, *, Auto" ColumnDefinitions="*,32"> |
|||
<ContentPresenter x:Name="HeaderContentPresenter" |
|||
Grid.Row="0" |
|||
Grid.Column="0" |
|||
Grid.ColumnSpan="2" |
|||
TextBlock.FontWeight="{DynamicResource ComboBoxHeaderThemeFontWeight}" |
|||
Margin="{DynamicResource ComboBoxTopHeaderMargin}" |
|||
VerticalAlignment="Top" /> |
|||
<Border x:Name="Background" |
|||
Grid.Row="1" |
|||
Grid.Column="0" |
|||
Grid.ColumnSpan="2" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
CornerRadius="{DynamicResource ControlCornerRadius}" |
|||
MinWidth="{DynamicResource ComboBoxThemeMinWidth}" /> |
|||
|
|||
<Border x:Name="HighlightBackground" |
|||
Grid.Row="1" |
|||
Grid.Column="0" |
|||
Grid.ColumnSpan="2" |
|||
Background="{DynamicResource ComboBoxBackgroundUnfocused}" |
|||
BorderBrush="{DynamicResource ComboBoxBackgroundBorderBrushUnfocused}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
CornerRadius="{DynamicResource ControlCornerRadius}" |
|||
Opacity="0" /> |
|||
<TextBlock x:Name="PlaceholderTextBlock" |
|||
Grid.Row="1" |
|||
Grid.Column="0" |
|||
HorizontalAlignment="Left" |
|||
VerticalAlignment="Center" |
|||
Margin="{TemplateBinding Padding}" |
|||
Foreground="{TemplateBinding PlaceholderForeground}" |
|||
Text="{TemplateBinding PlaceholderText}" IsVisible="{TemplateBinding SelectionBoxItem, Converter={x:Static ObjectConverters.IsNull}}"/> |
|||
<ContentControl x:Name="ContentPresenter" |
|||
Content="{TemplateBinding SelectionBoxItem}" |
|||
ContentTemplate="{TemplateBinding ItemTemplate}" |
|||
Grid.Row="1" |
|||
Grid.Column="0" |
|||
Margin="{TemplateBinding Padding}" |
|||
HorizontalAlignment="Left" |
|||
VerticalAlignment="Center"> |
|||
</ContentControl> |
|||
|
|||
<Border x:Name="DropDownOverlay" |
|||
Grid.Row="1" |
|||
Grid.Column="1" |
|||
Background="Transparent" |
|||
ClickMode="Press" |
|||
Focusable="False" |
|||
IsChecked="{TemplateBinding IsDropDownOpen, Mode=TwoWay}" |
|||
Grid.Column="1"> |
|||
<Path Fill="{DynamicResource ThemeForegroundBrush}" |
|||
Width="8" |
|||
Height="4" |
|||
Stretch="Uniform" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z"/> |
|||
</ToggleButton> |
|||
<Popup Name="PART_Popup" |
|||
IsOpen="{TemplateBinding IsDropDownOpen, Mode=TwoWay}" |
|||
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}" |
|||
MaxHeight="{TemplateBinding MaxDropDownHeight}" |
|||
PlacementTarget="{TemplateBinding}" |
|||
StaysOpen="False"> |
|||
<Border BorderBrush="{DynamicResource ThemeBorderMidBrush}" |
|||
BorderThickness="1"> |
|||
<ScrollViewer> |
|||
<ItemsPresenter Name="PART_ItemsPresenter" |
|||
Items="{TemplateBinding Items}" |
|||
ItemsPanel="{TemplateBinding ItemsPanel}" |
|||
ItemTemplate="{TemplateBinding ItemTemplate}" |
|||
VirtualizationMode="{TemplateBinding VirtualizationMode}" |
|||
Margin="0,1,1,1" |
|||
Width="30" IsVisible="False" |
|||
HorizontalAlignment="Right" /> |
|||
|
|||
<Viewbox UseLayoutRounding="False" |
|||
MinHeight="{DynamicResource ComboBoxMinHeight}" |
|||
Grid.Row="1" |
|||
Grid.Column="1" |
|||
IsHitTestVisible="False" |
|||
Margin="0,0,10,0" Height="12" Width="12" |
|||
HorizontalAlignment="Right" |
|||
VerticalAlignment="Center"> |
|||
<Panel> |
|||
<Panel Height="12" Width="12" /> |
|||
<Path x:Name="DropDownGlyph" Stretch="Uniform" VerticalAlignment="Center" Data="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" /> |
|||
</Panel> |
|||
</Viewbox> |
|||
<Popup Name="PART_Popup" |
|||
WindowManagerAddShadowHint="False" |
|||
IsOpen="{TemplateBinding IsDropDownOpen, Mode=TwoWay}" |
|||
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}" |
|||
MaxHeight="{TemplateBinding MaxDropDownHeight}" |
|||
PlacementTarget="{TemplateBinding}" |
|||
StaysOpen="False"> |
|||
<Border x:Name="PopupBorder" |
|||
Background="{DynamicResource ComboBoxDropDownBackground}" |
|||
BorderBrush="{DynamicResource ComboBoxDropDownBorderBrush}" |
|||
BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}" |
|||
Margin="0,-1,0,-1" |
|||
Padding="{DynamicResource ComboBoxDropdownBorderPadding}" |
|||
HorizontalAlignment="Stretch" |
|||
CornerRadius="{DynamicResource OverlayCornerRadius}"> |
|||
<ScrollViewer> |
|||
<ItemsPresenter Name="PART_ItemsPresenter" |
|||
Items="{TemplateBinding Items}" |
|||
Margin="{DynamicResource ComboBoxDropdownContentMargin}" |
|||
ItemsPanel="{TemplateBinding ItemsPanel}" |
|||
ItemTemplate="{TemplateBinding ItemTemplate}" |
|||
VirtualizationMode="{TemplateBinding VirtualizationMode}" |
|||
/> |
|||
</ScrollViewer> |
|||
</Border> |
|||
</Popup> |
|||
</Grid> |
|||
</Border> |
|||
</ScrollViewer> |
|||
</Border> |
|||
</Popup> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ComboBox:pointerover /template/ Border#border"> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}"/> |
|||
|
|||
<!-- NormalState --> |
|||
<Style Selector="ComboBox /template/ TextBlock#PlaceholderTextBlock"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForeground}"/> |
|||
</Style> |
|||
<Style Selector="ComboBox:disabled /template/ Border#border"> |
|||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" /> |
|||
|
|||
<Style Selector="ComboBox /template/ Path#DropDownGlyph"> |
|||
<Setter Property="Fill" Value="{DynamicResource ComboBoxDropDownGlyphForeground}"/> |
|||
</Style> |
|||
|
|||
<!-- PointerOver State --> |
|||
<Style Selector="ComboBox:pointerover /template/ Border#Background"> |
|||
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundPointerOver}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Pressed State --> |
|||
<Style Selector="ComboBox:pressed /template/ Border#Background"> |
|||
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundPressed}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Disabled State --> |
|||
<Style Selector="ComboBox:disabled /template/ Border#Background"> |
|||
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundDisabled}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ComboBox:disabled /template/ ContentPresenter#HeaderContentPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="ComboBox:disabled /template/ ContentControl#ContentPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="ComboBox:disabled /template/ TextBlock#PlaceholderTextBlock"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="ComboBox:disabled /template/ TextBlock#PlaceholderTextBlock"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="ComboBox:disabled /template/ Path#DropDownGlyph"> |
|||
<Setter Property="Fill" Value="{DynamicResource ComboBoxDropDownGlyphForegroundDisabled}"/> |
|||
</Style> |
|||
|
|||
<!-- Focused State --> |
|||
|
|||
<!-- Focus Pressed State --> |
|||
|
|||
<!-- Unfocused State --> |
|||
|
|||
</Styles> |
|||
|
|||
@ -1,31 +1,43 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Style Selector="ListBox"> |
|||
<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="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/> |
|||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Name="border" BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}"> |
|||
<ScrollViewer Name="PART_ScrollViewer" |
|||
Background="{TemplateBinding Background}" |
|||
HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}" |
|||
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}"> |
|||
<ItemsPresenter Name="PART_ItemsPresenter" |
|||
Items="{TemplateBinding Items}" |
|||
ItemsPanel="{TemplateBinding ItemsPanel}" |
|||
ItemTemplate="{TemplateBinding ItemTemplate}" |
|||
Margin="{TemplateBinding Padding}" |
|||
VirtualizationMode="{TemplateBinding VirtualizationMode}"/> |
|||
</ScrollViewer> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ListBox:disabled /template/ Border#border"> |
|||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" /> |
|||
</Style> |
|||
<Design.PreviewWith> |
|||
<Border Padding="20"> |
|||
<ListBox> |
|||
<ListBoxItem>Test</ListBoxItem> |
|||
<ListBoxItem>Test</ListBoxItem> |
|||
<ListBoxItem>Test</ListBoxItem> |
|||
<ListBoxItem>Test</ListBoxItem> |
|||
</ListBox> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
<Style Selector="ListBox"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" /> |
|||
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ListBoxBorderThemeThickness}" /> |
|||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> |
|||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /> |
|||
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> |
|||
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Name="border" BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}"> |
|||
<ScrollViewer Name="PART_ScrollViewer" |
|||
Background="{TemplateBinding Background}" |
|||
HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}" |
|||
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}"> |
|||
<ItemsPresenter Name="PART_ItemsPresenter" |
|||
Items="{TemplateBinding Items}" |
|||
ItemsPanel="{TemplateBinding ItemsPanel}" |
|||
ItemTemplate="{TemplateBinding ItemTemplate}" |
|||
Margin="{TemplateBinding Padding}" |
|||
VirtualizationMode="{TemplateBinding VirtualizationMode}"/> |
|||
</ScrollViewer> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ListBox:disabled /template/ Border#border"> |
|||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" /> |
|||
</Style> |
|||
</Styles> |
|||
|
|||
@ -1,17 +1,21 @@ |
|||
<Style xmlns="https://github.com/avaloniaui" Selector="PopupRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Panel> |
|||
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" /> |
|||
<VisualLayerManager IsPopup="True"> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding Content}" |
|||
Padding="{TemplateBinding Padding}"/> |
|||
</VisualLayerManager> |
|||
</Panel> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Style Selector="PopupRoot"> |
|||
<Setter Property="TransparencyLevelHint" Value="Transparent" /> |
|||
<Setter Property="Background" Value="{x:Null}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Panel> |
|||
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" /> |
|||
<VisualLayerManager IsPopup="True"> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding Content}" |
|||
Padding="{TemplateBinding Padding}"/> |
|||
</VisualLayerManager> |
|||
</Panel> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
</Styles> |
|||
|
|||
@ -1,60 +1,173 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui"> |
|||
<Design.PreviewWith> |
|||
<Border Padding="20"> |
|||
<StackPanel Spacing="10"> |
|||
<RadioButton Content="Option 1" /> |
|||
<RadioButton Content="Option 2" /> |
|||
<RadioButton IsEnabled="False" Content="Option 3" /> |
|||
<RadioButton Content="Option 2" /> |
|||
</StackPanel> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
<Style Selector="RadioButton"> |
|||
<Setter Property="Background" Value="Transparent"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
|||
<Setter Property="Background" Value="{DynamicResource RadioButtonBackground}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource RadioButtonForeground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrush}" /> |
|||
<Setter Property="Padding" Value="8,6,0,0" /> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="VerticalAlignment" Value="Center" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Left" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Top" /> |
|||
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> |
|||
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> |
|||
<Setter Property="MinWidth" Value="120" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid ColumnDefinitions="Auto,*" Background="{TemplateBinding Background}"> |
|||
<Ellipse Name="border" |
|||
Stroke="{TemplateBinding BorderBrush}" |
|||
StrokeThickness="1" |
|||
Width="18" |
|||
Height="18" |
|||
VerticalAlignment="Center"/> |
|||
<Ellipse Name="checkMark" |
|||
Width="10" |
|||
Height="10" |
|||
Stretch="Uniform" |
|||
UseLayoutRounding="False" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center"/> |
|||
<Ellipse Name="indeterminateMark" |
|||
Fill="{DynamicResource ThemeAccentBrush}" |
|||
Width="10" |
|||
Height="10" |
|||
Stretch="Uniform" |
|||
UseLayoutRounding="False" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center"/> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding Content}" |
|||
Margin="4,0,0,0" |
|||
VerticalAlignment="Center" |
|||
Grid.Column="1"/> |
|||
</Grid> |
|||
<ControlTemplate TargetType="RadioButton"> |
|||
<Border Name="RootBorder" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
CornerRadius="{DynamicResource ControlCornerRadius}"> |
|||
<Grid ColumnDefinitions="20,*"> |
|||
<Grid VerticalAlignment="Top" |
|||
Height="32"> |
|||
|
|||
<Ellipse Name="OuterEllipse" |
|||
Width="20" Height="20" |
|||
UseLayoutRounding="False" |
|||
StrokeThickness="{DynamicResource RadioButtonBorderThemeThickness}" /> |
|||
|
|||
<Ellipse Name="CheckOuterEllipse" |
|||
Width="20" Height="20" |
|||
UseLayoutRounding="False" |
|||
StrokeThickness="{DynamicResource RadioButtonBorderThemeThickness}" /> |
|||
|
|||
<Ellipse Name="CheckGlyph" |
|||
Width="8" Height="8" |
|||
UseLayoutRounding="False" /> |
|||
</Grid> |
|||
|
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
TextBlock.Foreground="{TemplateBinding Foreground}" |
|||
Margin="{TemplateBinding Padding}" |
|||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
Grid.Column="1" /> |
|||
</Grid> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:pointerover /template/ Ellipse#border"> |
|||
<Setter Property="Stroke" Value="{DynamicResource ThemeBorderHighBrush}"/> |
|||
|
|||
<!-- Normal State --> |
|||
<Style Selector="RadioButton /template/ Ellipse#OuterEllipse"> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseStroke}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseFill}" /> |
|||
</Style> |
|||
<Style Selector="RadioButton /template/ Ellipse#checkMark"> |
|||
<Setter Property="Fill" Value="{DynamicResource HighlightBrush}"/> |
|||
<Setter Property="IsVisible" Value="False"/> |
|||
|
|||
<Style Selector="RadioButton /template/ Ellipse#CheckOuterEllipse"> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseCheckedStroke}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseCheckedFill}" /> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
<Style Selector="RadioButton /template/ Ellipse#indeterminateMark"> |
|||
<Setter Property="IsVisible" Value="False"/> |
|||
|
|||
<Style Selector="RadioButton /template/ Ellipse#CheckGlyph"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonCheckGlyphStroke}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonCheckGlyphFill}" /> |
|||
</Style> |
|||
<Style Selector="RadioButton:checked /template/ Ellipse#checkMark"> |
|||
<Setter Property="IsVisible" Value="True"/> |
|||
|
|||
|
|||
<!-- PointerOver State --> |
|||
<Style Selector="RadioButton:pointerover /template/ ContentPresenter#PART_ContentPresenter"> |
|||
<Setter Property="(TextBlock.Foreground)" Value="{DynamicResource RadioButtonForegroundPointerOver}" /> |
|||
</Style> |
|||
<Style Selector="RadioButton:indeterminate /template/ Ellipse#indeterminateMark"> |
|||
<Setter Property="IsVisible" Value="True"/> |
|||
|
|||
<Style Selector="RadioButton:pointerover /template/ Border#RootBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource RadioButtonBackgroundPointerOver}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrushPointerOver}" /> |
|||
</Style> |
|||
<Style Selector="RadioButton:disabled /template/ Ellipse#border"> |
|||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/> |
|||
|
|||
<Style Selector="RadioButton:pointerover /template/ Ellipse#OuterEllipse"> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseStrokePointerOver}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseFillPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:pointerover /template/ Ellipse#CheckOuterEllipse"> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseCheckedStrokePointerOver}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseCheckedFillPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:pointerover /template/ Ellipse#CheckGlyph"> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonCheckGlyphStrokePointerOver}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonCheckGlyphFillPointerOver}" /> |
|||
</Style> |
|||
|
|||
|
|||
<!-- Pressed State --> |
|||
<Style Selector="RadioButton:pressed /template/ ContentPresenter#PART_ContentPresenter"> |
|||
<Setter Property="(TextBlock.Foreground)" Value="{DynamicResource RadioButtonForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:pressed /template/ Border#RootBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource RadioButtonBackgroundPressed}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrushPressed}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:pressed /template/ Ellipse#OuterEllipse"> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseStrokePressed}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseFillPressed}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:pressed /template/ Ellipse#CheckOuterEllipse"> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseCheckedStrokePressed}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseCheckedFillPressed}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:pressed /template/ Ellipse#CheckGlyph"> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonCheckGlyphStrokePressed}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonCheckGlyphFillPressed}" /> |
|||
</Style> |
|||
|
|||
|
|||
<!-- Disabled State --> |
|||
<Style Selector="RadioButton:disabled /template/ ContentPresenter#PART_ContentPresenter"> |
|||
<Setter Property="(TextBlock.Foreground)" Value="{DynamicResource RadioButtonForegroundDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:disabled /template/ Border#RootBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource RadioButtonBackgroundDisabled}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrushDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:disabled /template/ Ellipse#OuterEllipse"> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseStrokeDisabled}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseFillDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:disabled /template/ Ellipse#CheckOuterEllipse"> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseCheckedStrokeDisabled}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseCheckedFillDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:disabled /template/ Ellipse#CheckGlyph"> |
|||
<Setter Property="Stroke" Value="{DynamicResource RadioButtonCheckGlyphFillDisabled}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource RadioButtonCheckGlyphStrokeDisabled}" /> |
|||
</Style> |
|||
|
|||
|
|||
<!-- Checked State --> |
|||
<Style Selector="RadioButton:checked /template/ Ellipse#CheckGlyph"> |
|||
<Setter Property="Opacity" Value="1" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:checked /template/ Ellipse#OuterEllipse"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
|
|||
<Style Selector="RadioButton:checked /template/ Ellipse#CheckOuterEllipse"> |
|||
<Setter Property="Opacity" Value="1" /> |
|||
</Style> |
|||
</Styles> |
|||
|
|||
@ -0,0 +1,37 @@ |
|||
using Avalonia.Controls.Mixins; |
|||
using Avalonia.UnitTests; |
|||
using Xunit; |
|||
|
|||
namespace Avalonia.Controls.UnitTests.Mixins |
|||
{ |
|||
public class PressedMixinTests |
|||
{ |
|||
private MouseTestHelper _mouse = new MouseTestHelper(); |
|||
|
|||
[Fact] |
|||
public void Selected_Class_Should_Not_Initially_Be_Added() |
|||
{ |
|||
var target = new TestControl(); |
|||
|
|||
Assert.Empty(target.Classes); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Setting_IsSelected_Should_Add_Selected_Class() |
|||
{ |
|||
var target = new TestControl(); |
|||
|
|||
_mouse.Down(target); |
|||
|
|||
Assert.Equal(new[] { ":pressed" }, target.Classes); |
|||
} |
|||
|
|||
private class TestControl : Control |
|||
{ |
|||
static TestControl() |
|||
{ |
|||
PressedMixin.Attach<TestControl>(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue