Files
Speckle.Material.Avalonia/Material.Styles/CheckBox.xaml
T
2022-04-17 22:28:08 +09:00

119 lines
6.2 KiB
XML

<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:assists="clr-namespace:Material.Styles.Assists"
xmlns:system="clr-namespace:System;assembly=netstandard"
xmlns:ripple="clr-namespace:Material.Ripple;assembly=Material.Ripple">
<Styles.Resources>
<system:Double x:Key="CheckBoxHoveredOpacity">0.12</system:Double>
<system:Double x:Key="CheckBoxPressedOpacity">0.26</system:Double>
</Styles.Resources>
<Style Selector="CheckBox">
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="assists:SelectionControlAssist.InnerForeground"
Value="{DynamicResource PrimaryHueMidBrush}" />
<Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}" />
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="assists:SelectionControlAssist.Size" Value="20" />
<Setter Property="Padding" Value="4,0,0,0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Name="PART_RootBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<DockPanel Name="PART_RootPanel">
<Viewbox
Width="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=(assists:SelectionControlAssist.Size)}"
Stretch="Uniform"
VerticalAlignment="Center"
ClipToBounds="False">
<Panel>
<Path Name="Graphic" Width="24" Height="24" Margin="0" />
<Ellipse Name="PART_HoverIndicator"
Fill="{TemplateBinding (assists:SelectionControlAssist.InnerForeground)}"
VerticalAlignment="Center" HorizontalAlignment="Center"
Width="42" Height="42" Margin="-100"
ClipToBounds="False"
IsHitTestVisible="False" />
<Border ClipToBounds="True" CornerRadius="100" Width="42" Height="42"
Margin="-100" VerticalAlignment="Center" HorizontalAlignment="Center">
<ripple:RippleEffect RaiseRippleCenter="True"
RippleFill="{TemplateBinding (assists:SelectionControlAssist.InnerForeground)}"
RippleOpacity="{StaticResource CheckBoxPressedOpacity}" />
</Border>
</Panel>
</Viewbox>
<ContentPresenter Name="contentPresenter"
Focusable="False"
Margin="{TemplateBinding Padding}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
</DockPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- RightToLeft content variant -->
<Style Selector="CheckBox.LeftHeader /template/ DockPanel#PART_RootPanel > Viewbox">
<Setter Property="DockPanel.Dock" Value="Right" />
</Style>
<!-- Default state -->
<Style Selector="CheckBox /template/ Path#Graphic">
<Setter Property="Data"
Value="M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M19,5V19H5V5H19Z" />
<Setter Property="Fill" Value="{DynamicResource MaterialDesignCheckBoxOff}" />
</Style>
<!-- Checked state -->
<Style Selector="CheckBox:checked /template/ Path#Graphic">
<Setter Property="Data"
Value="M10,17L5,12L6.41,10.58L10,14.17L17.59,6.58L19,8M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z" />
<Setter Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(assists:SelectionControlAssist.InnerForeground)}" />
</Style>
<!-- Disabled state -->
<Style Selector="CheckBox:disabled">
<Setter Property="Opacity" Value="0.56" />
</Style>
<Style Selector="CheckBox:disabled /template/ Path#Graphic">
<Setter Property="Fill" Value="{DynamicResource MaterialDesignCheckBoxDisabled}" />
</Style>
<!-- Indeterminate state -->
<Style Selector="CheckBox:indeterminate /template/ Path#Graphic">
<Setter Property="Data"
Value="M6,13L6,11L18,11L18,13M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z" />
<Setter Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(assists:SelectionControlAssist.InnerForeground)}" />
</Style>
<!-- Accent variant -->
<Style Selector="CheckBox.Accent">
<Setter Property="assists:SelectionControlAssist.InnerForeground"
Value="{DynamicResource SecondaryHueMidBrush}" />
</Style>
<!-- Hover effect -->
<Style Selector="CheckBox /template/ Ellipse#PART_HoverIndicator">
<Setter Property="Opacity" Value="0" />
</Style>
<Style Selector="CheckBox:not(:disabled):pointerover /template/ Ellipse#PART_HoverIndicator">
<Setter Property="Opacity" Value="{StaticResource CheckBoxHoveredOpacity}" />
</Style>
</Styles>