Browse Source

Implement :large-selector pseudo class

pull/7842/head
robloo 5 years ago
parent
commit
2a343dcf01
  1. 28
      src/Avalonia.Controls/ColorPicker/ColorSpectrum/ColorSpectrum.cs
  2. 29
      src/Avalonia.Themes.Fluent/Controls/ColorSpectrum.xaml

28
src/Avalonia.Controls/ColorPicker/ColorSpectrum/ColorSpectrum.cs

@ -20,9 +20,10 @@ namespace Avalonia.Controls.Primitives
/// <summary> /// <summary>
/// A two dimensional spectrum for color selection. /// A two dimensional spectrum for color selection.
/// </summary> /// </summary>
[PseudoClasses(pcLightSelector)] [PseudoClasses(pcLargeSelector, pcLightSelector)]
public partial class ColorSpectrum : TemplatedControl public partial class ColorSpectrum : TemplatedControl
{ {
protected const string pcLargeSelector = ":large-selector";
protected const string pcLightSelector = ":light-selector"; protected const string pcLightSelector = ":light-selector";
/// <summary> /// <summary>
@ -514,18 +515,19 @@ namespace Avalonia.Controls.Primitives
/// </summary> /// </summary>
private void UpdatePseudoClasses() private void UpdatePseudoClasses()
{ {
//if (m_isPointerPressed) if (_isPointerPressed)
//{ {
// VisualStateManager.GoToState(this, m_shouldShowLargeSelection ? "PressedLarge" : "Pressed", useTransitions); PseudoClasses.Set(pcLargeSelector, _shouldShowLargeSelection);
//} }
//else if (m_isPointerOver) else if (_isPointerOver)
//{ {
// VisualStateManager.GoToState(this, "PointerOver", useTransitions); //VisualStateManager.GoToState(this, "PointerOver", useTransitions);
//} PseudoClasses.Set(pcLargeSelector, false);
//else }
//{ else
// VisualStateManager.GoToState(this, "Normal", useTransitions); {
//} PseudoClasses.Set(pcLargeSelector, false);
}
PseudoClasses.Set(pcLightSelector, SelectionEllipseShouldBeLight()); PseudoClasses.Set(pcLightSelector, SelectionEllipseShouldBeLight());

29
src/Avalonia.Themes.Fluent/Controls/ColorSpectrum.xaml

@ -52,9 +52,7 @@
Background="Transparent" Background="Transparent"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"> VerticalAlignment="Stretch">
<Grid x:Name="PART_SelectionEllipsePanel" <Grid x:Name="PART_SelectionEllipsePanel">
Width="16"
Height="16">
<Ellipse x:Name="FocusEllipse" <Ellipse x:Name="FocusEllipse"
Margin="-2" Margin="-2"
StrokeThickness="2" StrokeThickness="2"
@ -98,7 +96,7 @@
</Setter> </Setter>
</Style> </Style>
<!-- SelectionEllipseColor --> <!-- Selector Color -->
<Style Selector="ColorSpectrum /template/ Ellipse#FocusEllipse"> <Style Selector="ColorSpectrum /template/ Ellipse#FocusEllipse">
<Setter Property="Stroke" Value="{DynamicResource SystemControlBackgroundChromeWhiteBrush}" /> <Setter Property="Stroke" Value="{DynamicResource SystemControlBackgroundChromeWhiteBrush}" />
</Style> </Style>
@ -112,11 +110,19 @@
<Setter Property="Stroke" Value="{DynamicResource SystemControlBackgroundChromeWhiteBrush}" /> <Setter Property="Stroke" Value="{DynamicResource SystemControlBackgroundChromeWhiteBrush}" />
</Style> </Style>
<!-- Selector Size -->
<Style Selector="ColorSpectrum /template/ Grid#PART_SelectionEllipsePanel">
<Setter Property="Width" Value="16" />
<Setter Property="Height" Value="16" />
</Style>
<Style Selector="ColorSpectrum:large-selector /template/ Grid#PART_SelectionEllipsePanel">
<Setter Property="Width" Value="48" />
<Setter Property="Height" Value="48" />
</Style>
<!--<VisualStateManager.VisualStateGroups> <!--<VisualStateManager.VisualStateGroups>
<VisualStateGroup <VisualStateGroup
x:Name="CommonStates"> x:Name="CommonStates">
<VisualState
x:Name="Normal" />
<VisualState <VisualState
x:Name="PointerOver"> x:Name="PointerOver">
<VisualState.Setters> <VisualState.Setters>
@ -127,17 +133,6 @@
</VisualState> </VisualState>
<VisualState <VisualState
x:Name="Pressed" /> x:Name="Pressed" />
<VisualState
x:Name="PressedLarge">
<VisualState.Setters>
<Setter
Target="SelectionEllipsePanel.Width"
Value="48" />
<Setter
Target="SelectionEllipsePanel.Height"
Value="48" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup> </VisualStateGroup>
<VisualStateGroup <VisualStateGroup
x:Name="FocusStates"> x:Name="FocusStates">

Loading…
Cancel
Save