Browse Source

Merge branch 'master' into fixes/11212-attached-property-coercion

pull/11341/head
Max Katz 3 years ago
committed by GitHub
parent
commit
6b9b771c53
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      src/Avalonia.Controls/Chrome/CaptionButtons.cs
  2. 8
      src/Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml
  3. 8
      src/Avalonia.Themes.Simple/Controls/CaptionButtons.xaml
  4. 2
      tests/Avalonia.IntegrationTests.Appium/WindowTests.cs

23
src/Avalonia.Controls/Chrome/CaptionButtons.cs

@ -8,13 +8,18 @@ namespace Avalonia.Controls.Chrome
/// <summary>
/// Draws window minimize / maximize / close buttons in a <see cref="TitleBar"/> when managed client decorations are enabled.
/// </summary>
[TemplatePart("PART_CloseButton", typeof(Button))]
[TemplatePart("PART_RestoreButton", typeof(Button))]
[TemplatePart("PART_MinimiseButton", typeof(Button))]
[TemplatePart("PART_FullScreenButton", typeof(Button))]
[TemplatePart(PART_CloseButton, typeof(Button))]
[TemplatePart(PART_RestoreButton, typeof(Button))]
[TemplatePart(PART_MinimizeButton, typeof(Button))]
[TemplatePart(PART_FullScreenButton, typeof(Button))]
[PseudoClasses(":minimized", ":normal", ":maximized", ":fullscreen")]
public class CaptionButtons : TemplatedControl
{
private const string PART_CloseButton = "PART_CloseButton";
private const string PART_RestoreButton = "PART_RestoreButton";
private const string PART_MinimizeButton = "PART_MinimizeButton";
private const string PART_FullScreenButton = "PART_FullScreenButton";
private Button? _restoreButton;
private IDisposable? _disposables;
@ -95,14 +100,14 @@ namespace Avalonia.Controls.Chrome
{
base.OnApplyTemplate(e);
var closeButton = e.NameScope.Get<Button>("PART_CloseButton");
var restoreButton = e.NameScope.Get<Button>("PART_RestoreButton");
var minimiseButton = e.NameScope.Get<Button>("PART_MinimiseButton");
var fullScreenButton = e.NameScope.Get<Button>("PART_FullScreenButton");
var closeButton = e.NameScope.Get<Button>(PART_CloseButton);
var restoreButton = e.NameScope.Get<Button>(PART_RestoreButton);
var minimizeButton = e.NameScope.Get<Button>(PART_MinimizeButton);
var fullScreenButton = e.NameScope.Get<Button>(PART_FullScreenButton);
closeButton.Click += (sender, e) => OnClose();
restoreButton.Click += (sender, e) => OnRestore();
minimiseButton.Click += (sender, e) => OnMinimize();
minimizeButton.Click += (sender, e) => OnMinimize();
fullScreenButton.Click += (sender, e) => OnToggleFullScreen();
restoreButton.IsEnabled = HostWindow?.CanResize ?? true;

8
src/Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml

@ -47,9 +47,9 @@
Data="M2048 2048v-819h-205v469l-1493 -1493h469v-205h-819v819h205v-469l1493 1493h-469v205h819z" />
</Viewbox>
</Button>
<Button x:Name="PART_MinimiseButton"
<Button x:Name="PART_MinimizeButton"
Theme="{StaticResource FluentCaptionButton}"
AutomationProperties.Name="Minimise">
AutomationProperties.Name="Minimize">
<Viewbox Width="11" Margin="2">
<Path Stretch="UniformToFill"
Fill="{TemplateBinding Foreground}"
@ -58,7 +58,7 @@
</Button>
<Button x:Name="PART_RestoreButton"
Theme="{StaticResource FluentCaptionButton}"
AutomationProperties.Name="Maximise">
AutomationProperties.Name="Maximize">
<Viewbox Width="11" Margin="2">
<Viewbox.RenderTransform>
<RotateTransform Angle="-90" />
@ -93,7 +93,7 @@
<Style Selector="^:fullscreen /template/ Button#PART_RestoreButton">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^:fullscreen /template/ Button#PART_MinimiseButton">
<Style Selector="^:fullscreen /template/ Button#PART_MinimizeButton">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^ /template/ Button#PART_RestoreButton:disabled">

8
src/Avalonia.Themes.Simple/Controls/CaptionButtons.xaml

@ -53,9 +53,9 @@
Stretch="UniformToFill" />
</Viewbox>
</Button>
<Button x:Name="PART_MinimiseButton"
<Button x:Name="PART_MinimizeButton"
Theme="{StaticResource SimpleCaptionButton}"
AutomationProperties.Name="Minimise">
AutomationProperties.Name="Minimize">
<Viewbox Width="11"
Margin="2">
<Path Data="M2048 1229v-205h-2048v205h2048z"
@ -65,7 +65,7 @@
</Button>
<Button x:Name="PART_RestoreButton"
Theme="{StaticResource SimpleCaptionButton}"
AutomationProperties.Name="Maximise">
AutomationProperties.Name="Maximize">
<Viewbox Width="11"
Margin="2">
<Viewbox.RenderTransform>
@ -102,7 +102,7 @@
<Style Selector="^:fullscreen /template/ Button#PART_RestoreButton">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^:fullscreen /template/ Button#PART_MinimiseButton">
<Style Selector="^:fullscreen /template/ Button#PART_MinimizeButton">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^ /template/ Button#PART_RestoreButton:disabled">

2
tests/Avalonia.IntegrationTests.Appium/WindowTests.cs

@ -263,7 +263,7 @@ namespace Avalonia.IntegrationTests.Appium
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
maximizeButton = extendClientArea ?
secondaryWindow.FindElementByXPath("//Button[@Name='Maximise']") :
secondaryWindow.FindElementByXPath("//Button[@Name='Maximize']") :
secondaryWindow.FindElementByXPath("//TitleBar/Button[2]");
}
else

Loading…
Cancel
Save