terminal/src/cascadia/TerminalApp/MinMaxCloseControl.xaml
Breece W d367c6b6b0
Smoothen close caption button animation (#9763)
The red close button animation fades to gray then to transparent, when
standard behavior skips the gray part. I manually tested in light/dark/high
contrast mode.

Closes #9762
2021-04-12 13:13:18 +00:00

313 lines
19 KiB
XML

<!--
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
the MIT License. See LICENSE in the project root for license information.
-->
<StackPanel x:Class="TerminalApp.MinMaxCloseControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
HorizontalAlignment="Left"
VerticalAlignment="Top"
d:DesignHeight="36"
d:DesignWidth="400"
Background="Transparent"
Orientation="Horizontal"
mc:Ignorable="d">
<StackPanel.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<x:Double x:Key="CaptionButtonStrokeWidth">1.0</x:Double>
<StaticResource x:Key="CaptionButtonBackgroundPointerOver"
ResourceKey="SystemControlBackgroundBaseLowBrush" />
<StaticResource x:Key="CaptionButtonBackgroundPressed"
ResourceKey="SystemControlBackgroundBaseMediumLowBrush" />
<StaticResource x:Key="CaptionButtonStroke"
ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CaptionButtonStrokeColor"
ResourceKey="SystemBaseHighColor" />
<StaticResource x:Key="CaptionButtonStrokePointerOver"
ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CaptionButtonStrokePressed"
ResourceKey="SystemControlForegroundBaseHighBrush" />
<SolidColorBrush x:Key="CaptionButtonBackground"
Color="Transparent" />
<Color x:Key="CaptionButtonBackgroundColor">Transparent</Color>
<SolidColorBrush x:Key="CloseButtonBackgroundPointerOver"
Color="#e81123" />
<SolidColorBrush x:Key="CloseButtonStrokePointerOver"
Color="White" />
<SolidColorBrush x:Key="CloseButtonBackgroundPressed"
Color="#f1707a" />
<SolidColorBrush x:Key="CloseButtonStrokePressed"
Color="Black" />
<SolidColorBrush x:Key="CloseButtonBackground"
Color="#00e81123" />
<Color x:Key="CloseButtonBackgroundColor">#00e81123</Color>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<x:Double x:Key="CaptionButtonStrokeWidth">1.0</x:Double>
<StaticResource x:Key="CaptionButtonBackgroundPointerOver"
ResourceKey="SystemControlBackgroundBaseLowBrush" />
<StaticResource x:Key="CaptionButtonBackgroundPressed"
ResourceKey="SystemControlBackgroundBaseMediumLowBrush" />
<StaticResource x:Key="CaptionButtonStroke"
ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CaptionButtonStrokeColor"
ResourceKey="SystemBaseHighColor" />
<StaticResource x:Key="CaptionButtonStrokePointerOver"
ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CaptionButtonStrokePressed"
ResourceKey="SystemControlForegroundBaseHighBrush" />
<SolidColorBrush x:Key="CaptionButtonBackground"
Color="Transparent" />
<Color x:Key="CaptionButtonBackgroundColor">Transparent</Color>
<SolidColorBrush x:Key="CloseButtonBackgroundPointerOver"
Color="#e81123" />
<SolidColorBrush x:Key="CloseButtonStrokePointerOver"
Color="White" />
<SolidColorBrush x:Key="CloseButtonBackgroundPressed"
Color="#f1707a" />
<SolidColorBrush x:Key="CloseButtonStrokePressed"
Color="Black" />
<SolidColorBrush x:Key="CloseButtonBackground"
Color="#00e81123" />
<Color x:Key="CloseButtonBackgroundColor">#00e81123</Color>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<x:Double x:Key="CaptionButtonStrokeWidth">3.0</x:Double>
<SolidColorBrush x:Key="CaptionButtonBackground"
Color="{ThemeResource SystemColorButtonFaceColor}" />
<StaticResource x:Key="CaptionButtonBackgroundColor"
ResourceKey="SystemColorButtonFaceColor" />
<SolidColorBrush x:Key="CaptionButtonBackgroundPointerOver"
Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="CaptionButtonBackgroundPressed"
Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="CaptionButtonStroke"
Color="{ThemeResource SystemColorButtonTextColor}" />
<StaticResource x:Key="CaptionButtonStrokeColor"
ResourceKey="SystemColorButtonTextColor" />
<SolidColorBrush x:Key="CaptionButtonStrokePointerOver"
Color="{ThemeResource SystemColorHighlightTextColor}" />
<SolidColorBrush x:Key="CaptionButtonStrokePressed"
Color="{ThemeResource SystemColorHighlightTextColor}" />
<SolidColorBrush x:Key="CloseButtonBackgroundPointerOver"
Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="CloseButtonStrokePointerOver"
Color="{ThemeResource SystemColorHighlightTextColor}" />
<SolidColorBrush x:Key="CloseButtonBackgroundPressed"
Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="CloseButtonStrokePressed"
Color="{ThemeResource SystemColorHighlightTextColor}" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<!--
These strings need to be initialized to something, so they're
just initialized to the path for the close button. Each specific
button should override them as needed.
-->
<x:String x:Key="CaptionButtonPath">M 0 0 L 10 10 M 10 0 L 0 10</x:String>
<x:String x:Key="CaptionButtonPathWindowMaximized">M 0 0 L 10 10 M 10 0 L 0 10</x:String>
<!--
"CaptionButtonHeightWindowed" and
"CaptionButtonHeightMaximized" define the size we should use
for the caption buttons height for the windowed and maximized
states, respectively.
32 was chosen for the Maximized height to match the height of
the TabRowControl. This way, when the window is maximized, the
tabs will be flush with the top of the window. See GH#2541 for
details.
-->
<x:Double x:Key="CaptionButtonHeightWindowed">36.0</x:Double>
<x:Double x:Key="CaptionButtonHeightMaximized">32.0</x:Double>
<Style x:Key="CaptionButton"
TargetType="Button">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="{ThemeResource CaptionButtonBackground}" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="ButtonBaseElement"
Padding="{TemplateBinding Padding}"
AutomationProperties.AccessibilityView="Raw"
Background="{TemplateBinding Background}"
BackgroundSizing="{TemplateBinding BackgroundSizing}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Path x:Name="Path"
Width="10"
Height="10"
Data="{ThemeResource CaptionButtonPath}"
Stretch="Fill"
Stroke="{ThemeResource CaptionButtonStroke}"
StrokeEndLineCap="Square"
StrokeStartLineCap="Square"
StrokeThickness="{ThemeResource CaptionButtonStrokeWidth}"
UseLayoutRounding="True" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition From="PointerOver"
To="Normal">
<Storyboard>
<ColorAnimation Storyboard.TargetName="ButtonBaseElement"
Storyboard.TargetProperty="(UIElement.Background).(SolidColorBrush.Color)"
To="{ThemeResource CaptionButtonBackgroundColor}"
Duration="0:0:0.2" />
<ColorAnimation Storyboard.TargetName="Path"
Storyboard.TargetProperty="(UIElement.Stroke).(SolidColorBrush.Color)"
To="{ThemeResource CaptionButtonStrokeColor}"
Duration="0:0:0.1" />
</Storyboard>
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Target="ButtonBaseElement.Background" Value="{ThemeResource CaptionButtonBackground}" />
<Setter Target="Path.Stroke" Value="{ThemeResource CaptionButtonStroke}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="ButtonBaseElement.Background" Value="{ThemeResource CaptionButtonBackgroundPointerOver}" />
<Setter Target="Path.Stroke" Value="{ThemeResource CaptionButtonStrokePointerOver}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Target="ButtonBaseElement.Background" Value="{ThemeResource CaptionButtonBackgroundPressed}" />
<Setter Target="Path.Stroke" Value="{ThemeResource CaptionButtonStrokePressed}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled" />
</VisualStateGroup>
<VisualStateGroup x:Name="MinMaxStates">
<VisualState x:Name="WindowStateNormal" />
<VisualState x:Name="WindowStateMaximized">
<VisualState.Setters>
<Setter Target="Path.Data" Value="{ThemeResource CaptionButtonPathWindowMaximized}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</StackPanel.Resources>
<Button x:Name="MinimizeButton"
x:Uid="WindowMinimizeButton"
Width="46.0"
Height="{StaticResource CaptionButtonHeightWindowed}"
MinWidth="46.0"
AutomationProperties.AccessibilityView="Raw"
Click="_MinimizeClick"
Style="{StaticResource CaptionButton}">
<Button.Resources>
<ResourceDictionary>
<x:String x:Key="CaptionButtonPath">M 0 0 H 10</x:String>
</ResourceDictionary>
</Button.Resources>
</Button>
<Button x:Name="MaximizeButton"
x:Uid="WindowMaximizeButton"
Width="46.0"
Height="{StaticResource CaptionButtonHeightWindowed}"
MinWidth="46.0"
AutomationProperties.AccessibilityView="Raw"
Click="_MaximizeClick"
Style="{StaticResource CaptionButton}">
<Button.Resources>
<ResourceDictionary>
<x:String x:Key="CaptionButtonPath">M 0 0 H 10 V 10 H 0 V 0</x:String>
<x:String x:Key="CaptionButtonPathWindowMaximized">M 0 2 h 8 v 8 h -8 v -8 M 2 2 v -2 h 8 v 8 h -2</x:String>
</ResourceDictionary>
</Button.Resources>
<ToolTipService.ToolTip>
<ToolTip>
<TextBlock>
<Run x:Name="MaximizeToolTip" />
</TextBlock>
</ToolTip>
</ToolTipService.ToolTip>
</Button>
<Button x:Name="CloseButton"
x:Uid="WindowCloseButton"
Width="46.0"
Height="{StaticResource CaptionButtonHeightWindowed}"
MinWidth="46.0"
AutomationProperties.AccessibilityView="Raw"
Click="_CloseClick"
Style="{StaticResource CaptionButton}">
<Button.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<StaticResource x:Key="CaptionButtonBackgroundPointerOver"
ResourceKey="CloseButtonBackgroundPointerOver" />
<StaticResource x:Key="CaptionButtonBackgroundPressed"
ResourceKey="CloseButtonBackgroundPressed" />
<StaticResource x:Key="CaptionButtonStrokePointerOver"
ResourceKey="CloseButtonStrokePointerOver" />
<StaticResource x:Key="CaptionButtonStrokePressed"
ResourceKey="CloseButtonStrokePressed" />
<StaticResource x:Key="CaptionButtonBackground"
ResourceKey="CloseButtonBackground" />
<StaticResource x:Key="CaptionButtonBackgroundColor"
ResourceKey="CloseButtonBackgroundColor" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<StaticResource x:Key="CaptionButtonBackgroundPointerOver"
ResourceKey="CloseButtonBackgroundPointerOver" />
<StaticResource x:Key="CaptionButtonBackgroundPressed"
ResourceKey="CloseButtonBackgroundPressed" />
<StaticResource x:Key="CaptionButtonStrokePointerOver"
ResourceKey="CloseButtonStrokePointerOver" />
<StaticResource x:Key="CaptionButtonStrokePressed"
ResourceKey="CloseButtonStrokePressed" />
<StaticResource x:Key="CaptionButtonBackground"
ResourceKey="CloseButtonBackground" />
<StaticResource x:Key="CaptionButtonBackgroundColor"
ResourceKey="CloseButtonBackgroundColor" />
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<StaticResource x:Key="CaptionButtonBackgroundPointerOver"
ResourceKey="CloseButtonBackgroundPointerOver" />
<StaticResource x:Key="CaptionButtonBackgroundPressed"
ResourceKey="CloseButtonBackgroundPressed" />
<StaticResource x:Key="CaptionButtonStrokePointerOver"
ResourceKey="CloseButtonStrokePointerOver" />
<StaticResource x:Key="CaptionButtonStrokePressed"
ResourceKey="CloseButtonStrokePressed" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<x:String x:Key="CaptionButtonPath">M 0 0 L 10 10 M 10 0 L 0 10</x:String>
</ResourceDictionary>
</Button.Resources>
</Button>
</StackPanel>