Browse Source

almost fully working checkbox.

pull/4012/head
Dan Walmsley 6 years ago
parent
commit
50fe90f8b5
  1. 4
      src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml
  2. 4
      src/Avalonia.Themes.Fluent/Accents/BaseLight.xaml
  3. 4
      src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml
  4. 99
      src/Avalonia.Themes.Fluent/CheckBox.xaml

4
src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml

@ -161,8 +161,8 @@
<x:Double x:Key="AppBarExpandButtonCircleDiameter">3</x:Double>
<x:Double x:Key="AutoSuggestListMaxHeight">374</x:Double>
<x:Double x:Key="AutoSuggestListBorderOpacity">0</x:Double>
<x:Double x:Key="CheckBoxBorderThemeThickness">2</x:Double>
<x:Double x:Key="CheckBoxCheckedStrokeThickness">0</x:Double>
<Thickness x:Key="CheckBoxBorderThemeThickness">2</Thickness>
<Thickness x:Key="CheckBoxCheckedStrokeThickness">0</Thickness>
<x:Double x:Key="ComboBoxArrowThemeFontSize">21</x:Double>
<x:Double x:Key="ComboBoxThemeMinWidth">64</x:Double>
<x:Double x:Key="ComboBoxPopupThemeMinWidth">80</x:Double>

4
src/Avalonia.Themes.Fluent/Accents/BaseLight.xaml

@ -160,8 +160,8 @@
<x:Double x:Key="AppBarExpandButtonCircleDiameter">3</x:Double>
<x:Double x:Key="AutoSuggestListMaxHeight">374</x:Double>
<x:Double x:Key="AutoSuggestListBorderOpacity">0</x:Double>
<x:Double x:Key="CheckBoxBorderThemeThickness">2</x:Double>
<x:Double x:Key="CheckBoxCheckedStrokeThickness">0</x:Double>
<Thickness x:Key="CheckBoxBorderThemeThickness">2</Thickness>
<Thickness x:Key="CheckBoxCheckedStrokeThickness">0</Thickness>
<x:Double x:Key="ComboBoxArrowThemeFontSize">21</x:Double>
<x:Double x:Key="ComboBoxThemeMinWidth">64</x:Double>
<x:Double x:Key="ComboBoxPopupThemeMinWidth">80</x:Double>

4
src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml

@ -28,8 +28,8 @@
<StaticResource x:Key="TextControlPlaceholderForegroundFocused" ResourceKey="SystemControlForegroundBaseMediumLowBrush" />
<!-- Resources for Checkbox.xaml -->
<x:Double x:Key="CheckBoxBorderThemeThickness">1</x:Double>
<x:Double x:Key="CheckBoxCheckedStrokeThickness">0</x:Double>
<Thickness x:Key="CheckBoxBorderThemeThickness">1</Thickness>
<Thickness x:Key="CheckBoxCheckedStrokeThickness">0</Thickness>
<StaticResource x:Key="CheckBoxForegroundUnchecked" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CheckBoxForegroundUncheckedPointerOver" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CheckBoxForegroundUncheckedPressed" ResourceKey="SystemControlForegroundBaseHighBrush" />

99
src/Avalonia.Themes.Fluent/CheckBox.xaml

@ -1,4 +1,9 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<CheckBox IsThreeState="True" IsChecked="True" />
</Border>
</Design.PreviewWith>
<Style Selector="CheckBox">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUnchecked}" />
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUnchecked}" />
@ -16,20 +21,23 @@
<Setter Property="FocusVisualMargin" Value="-7,-3,-7,-3" />-->
<Setter Property="Template">
<ControlTemplate>
<Border Background="{TemplateBinding Background}"
<Border x:Name="PART_Border" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{DynamicResource ControlCornerRadius}">
<Grid x:Name="RootGrid" ColumnDefinitions="20,*">
<Grid VerticalAlignment="Top" Height="32">
<Border x:Name="NormalRectangle"
Background="{DynamicResource CheckBoxCheckBackgroundFillUnchecked}"
BorderBrush="{DynamicResource CheckBoxCheckBackgroundStrokeUnchecked}"
BorderThickness="{DynamicResource CheckBoxBorderThemeThickness}"
UseLayoutRounding="False"
Height="20"
Width="20"
CornerRadius="{DynamicResource ControlCornerRadius}" />
<Viewbox Margin="5" >
<Path x:Name="CheckGlyph" Stretch="Uniform"
Fill="{DynamicResource CheckBoxForegroundChecked}" />
</Viewbox>
<!--<FontIcon x:Name="CheckGlyph"
FontFamily="{DynamicResource SymbolThemeFontFamily}"
Glyph="&#xE001;"
@ -39,7 +47,7 @@
</Grid>
<ContentPresenter x:Name="ContentPresenter"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
@ -51,6 +59,89 @@
</ControlTemplate>
</Setter>
</Style>
<!-- Unchecked Normal State -->
<Style Selector="CheckBox /template/ ContentPresenter#ContentPresenter">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource CheckBoxForegroundUnchecked}" />
</Style>
<Style Selector="CheckBox /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUnchecked}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUnchecked}" />
</Style>
<Style Selector="CheckBox /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUnchecked}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUnchecked}" />
</Style>
<Style Selector="CheckBox /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundUnchecked}" />
<Setter Property="Opacity" Value="0" />
</Style>
<!-- Unchecked PointerOver State -->
<!-- Unchecked Pressed State -->
<!-- Unchecked Disabled state -->
<!-- Checked Normal State -->
<Style Selector="CheckBox:checked /template/ ContentPresenter#ContentPresenter">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource CheckBoxForegroundChecked}" />
</Style>
<Style Selector="CheckBox:checked /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundChecked}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushChecked}" />
</Style>
<Style Selector="CheckBox:checked /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeChecked}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillChecked}" />
</Style>
<Style Selector="CheckBox:checked /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundChecked}" />
<Setter Property="Data" Value="M1507 31L438 1101L-119 543L-29 453L438 919L1417 -59L1507 31Z" />
<Setter Property="Opacity" Value="1" />
</Style>
<!-- Checked PointerOver State -->
<!-- Checked Pressed State -->
<!-- Checked Disabled State -->
<!-- Indeterminate Normal State -->
<Style Selector="CheckBox:indeterminate /template/ ContentPresenter#ContentPresenter">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminate}" />
</Style>
<Style Selector="CheckBox:indeterminate /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminate}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminate}" />
</Style>
<Style Selector="CheckBox:indeterminate /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminate}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminate}" />
</Style>
<Style Selector="CheckBox:indeterminate /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminate}" />
<Setter Property="Data" Value="M1536 1536v-1024h-1024v1024h1024z" />
<Setter Property="Opacity" Value="1" />
</Style>
<!-- Indeterminate PointerOver State -->
<!-- Indeterminate Pressed State -->
<!-- Indeterminate Disabled State -->
<Style Selector="CheckBox:pointerover /template/ Border#border">
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}"/>
</Style>

Loading…
Cancel
Save