Browse Source

Implement secondary button span but disable it with commented reasons

pull/7422/head
robloo 5 years ago
parent
commit
a57bdbc254
  1. 23
      src/Avalonia.Controls/SplitButton/SplitButton.cs
  2. 23
      src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml

23
src/Avalonia.Controls/SplitButton/SplitButton.cs

@ -186,8 +186,24 @@ namespace Avalonia.Controls
protected void UpdatePseudoClasses()
{
// Place the secondary button
// These are mutually exclusive PseudoClasses handled separately from SetExclusivePseudoClass().
// They must be applied in addition to the others.
//
// In WinUI, the span of the secondary button is changed to full-width for touch-based
// devices in certain conditions. The full reasoning for this is unknown. Some theories
// include:
//
// My guess is that the design team at MS decided that it's a better experience
// for touch users to make them select from the drop down rather than the shortcut
// top level button, so touch basically just turns this into a drop down button.
// Whether that's ideal or not is going is a subjective opinion.
//
// For Avalonia, it may not always make sense to disable the primary button like that
// on touch-first platforms. Users and developers would normally expect a control to
// function the same on all platforms. Therefore, this functionality is disabled here
// but could be re-enabled in the future if more reasons become known.
//
// Finally, these are mutually exclusive PseudoClasses handled separately from
// SetExclusivePseudoClass(). They must be applied in addition to the others.
/*
if (_lastPointerType == PointerType.Touch || _isKeyDown)
{
PseudoClasses.Set(pcSecondaryButtonSpan, true);
@ -198,9 +214,10 @@ namespace Avalonia.Controls
PseudoClasses.Set(pcSecondaryButtonSpan, false);
PseudoClasses.Set(pcSecondaryButtonRight, true);
}
*/
// Change the visual state
if (!IsEnabled)
if (!IsEffectivelyEnabled)
{
SetExclusivePseudoClass(pcDisabled);
}

23
src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml

@ -10,7 +10,7 @@
<Styles.Resources>
<x:Double x:Key="SplitButtonPrimaryButtonSize">32</x:Double>
<x:Double x:Key="SplitButtonSecondaryButtonSize">32</x:Double>
<GridLength x:Key="SplitButtonSecondaryButtonSize">32</GridLength>
</Styles.Resources>
<Style Selector="SplitButton">
@ -43,9 +43,9 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"
MinWidth="{DynamicResource SplitButtonPrimaryButtonSize}" />
MinWidth="{StaticResource SplitButtonPrimaryButtonSize}" />
<ColumnDefinition Width="1" />
<ColumnDefinition Width="{DynamicResource SplitButtonSecondaryButtonSize}" />
<ColumnDefinition Width="{StaticResource SplitButtonSecondaryButtonSize}" />
</Grid.ColumnDefinitions>
<!-- Changed from Grid to Rectangle since Avalonia does not support Background on Grid directly -->
@ -89,11 +89,12 @@
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="Transparent"
HorizontalContentAlignment="Center"
HorizontalContentAlignment="Right"
VerticalContentAlignment="Center"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
KeyboardNavigation.IsTabStop="False">
KeyboardNavigation.IsTabStop="False"
Padding="0,0,10,0">
<Button.Content>
<!-- TextBlock converted to a Path and placed within Viewbox -->
<Viewbox UseLayoutRounding="False"
@ -384,10 +385,16 @@
</Style>
<!-- SecondaryButtonPlacement States -->
<!-- Note: ':secondary-button-right' is the default -->
<!--<Style Selector="SplitButton:secondary-button-span /template/ Button#PART_SecondaryButton">
<!-- Note: Setting Grid attached properties doesn't work here for some unknown reason.
They simply are never changed. In addition, touch-device changes of secondary button
size are currently disabled in code-behind. -->
<Style Selector="SplitButton:secondary-button-right /template/ Button#PART_SecondaryButton">
<Setter Property="(Grid.Column)" Value="2" />
<Setter Property="(Grid.ColumnSpan)" Value="1" />
</Style>
<Style Selector="SplitButton:secondary-button-span /template/ Button#PART_SecondaryButton">
<Setter Property="(Grid.Column)" Value="0" />
<Setter Property="(Grid.ColumnSpan)" Value="3" />
</Style>-->
</Style>
</Styles>

Loading…
Cancel
Save