feat: Add CaptionButtons
This commit is contained in:
parent
dc010357ba
commit
eccf82f706
@ -8,6 +8,8 @@
|
||||
Title="Semi.Avalonia.Demo"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
ExtendClientAreaChromeHints="Default"
|
||||
ExtendClientAreaToDecorationsHint="True"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
mc:Ignorable="d">
|
||||
<views:MainView />
|
||||
|
@ -1,3 +1,101 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
|
||||
<ControlTheme x:Key="CaptionButton" TargetType="Button">
|
||||
<Setter Property="Background" Value="{DynamicResource CaptionButtonPointeroverBackground}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource CaptionButtonPressedBackground}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonForeground}" />
|
||||
<Setter Property="CornerRadius" Value="6" />
|
||||
<Setter Property="Margin" Value="4" />
|
||||
<Setter Property="Padding" Value="4" />
|
||||
<Setter Property="Height" Value="28" />
|
||||
<Setter Property="Width" Value="28" />
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="Button">
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="Transparent"
|
||||
Content="{TemplateBinding Content}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}" />
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:pointerover /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="{TemplateBinding Background}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:pressed /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="{TemplateBinding BorderBrush}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type CaptionButtons}" TargetType="CaptionButtons">
|
||||
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonForeground}" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="CaptionButtons">
|
||||
<StackPanel
|
||||
VerticalAlignment="Stretch"
|
||||
Orientation="Horizontal"
|
||||
Spacing="2"
|
||||
TextElement.FontSize="10">
|
||||
<Button x:Name="PART_FullScreenButton" Theme="{StaticResource CaptionButton}">
|
||||
<PathIcon
|
||||
Name="PART_FullScreenButtonIcon"
|
||||
Width="12"
|
||||
Height="12"
|
||||
Data="{DynamicResource WindowExpandGlyph}"
|
||||
Foreground="{Binding $parent[Button].Foreground}" />
|
||||
</Button>
|
||||
<Button x:Name="PART_MinimiseButton" Theme="{StaticResource CaptionButton}">
|
||||
<PathIcon
|
||||
Width="12"
|
||||
Height="12"
|
||||
Data="{DynamicResource WindowMinimizeGlyph}"
|
||||
Foreground="{Binding $parent[Button].Foreground}" />
|
||||
</Button>
|
||||
<Button x:Name="PART_RestoreButton" Theme="{StaticResource CaptionButton}">
|
||||
<PathIcon
|
||||
Name="PART_RestoreButtonIcon"
|
||||
Width="12"
|
||||
Height="12"
|
||||
Data="{DynamicResource WindowMaximizeGlyph}"
|
||||
Foreground="{Binding $parent[Button].Foreground}" />
|
||||
</Button>
|
||||
<Button
|
||||
x:Name="PART_CloseButton"
|
||||
Background="{DynamicResource CaptionButtonClosePointeroverBackground}"
|
||||
BorderBrush="{DynamicResource CaptionButtonClosePressedBackground}"
|
||||
Theme="{StaticResource CaptionButton}">
|
||||
<Button.Styles>
|
||||
<Style Selector="Button:pointerover">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</Style>
|
||||
<Style Selector="Button:pressed">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</Style>
|
||||
</Button.Styles>
|
||||
<PathIcon
|
||||
Width="12"
|
||||
Height="12"
|
||||
Data="{DynamicResource WindowCloseIconGlyph}"
|
||||
Foreground="{Binding $parent[Button].Foreground}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^:maximized /template/ PathIcon#PART_RestoreButtonIcon">
|
||||
<Setter Property="Data" Value="{DynamicResource WindowRestoreGlyph}" />
|
||||
</Style>
|
||||
<Style Selector="^:fullscreen /template/ PathIcon#PART_FullScreenButtonIcon">
|
||||
<Setter Property="Data" Value="{DynamicResource WindowCollapseGlyph}" />
|
||||
</Style>
|
||||
<Style Selector="^:fullscreen /template/ Button#PART_RestoreButton">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
<Style Selector="^:fullscreen /template/ Button#PART_MinimiseButton">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
|
@ -1,3 +1,50 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<ControlTheme x:Key="{x:Type TitleBar}" TargetType="TitleBar">
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Panel HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="Stretch">
|
||||
<Panel
|
||||
x:Name="PART_MouseTracker"
|
||||
Height="1"
|
||||
VerticalAlignment="Top" />
|
||||
<Panel x:Name="PART_Container">
|
||||
<Border
|
||||
x:Name="PART_Background"
|
||||
Background="{TemplateBinding Background}"
|
||||
IsHitTestVisible="False" />
|
||||
<CaptionButtons
|
||||
x:Name="PART_CaptionButtons"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{TemplateBinding Foreground}" />
|
||||
</Panel>
|
||||
</Panel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:fullscreen /template/ Border#PART_Background">
|
||||
<Setter Property="IsHitTestVisible" Value="True" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:fullscreen /template/ Panel#PART_MouseTracker">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:fullscreen /template/ Panel#PART_Container">
|
||||
<Setter Property="RenderTransform" Value="translateY(-50px)" />
|
||||
<Setter Property="Transitions">
|
||||
<Transitions>
|
||||
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.1" />
|
||||
</Transitions>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:fullscreen:pointerover /template/ Panel#PART_Container">
|
||||
<Setter Property="RenderTransform" Value="none" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
|
14
src/Semi.Avalonia/Themes/Light/CaptionButtons.axaml
Normal file
14
src/Semi.Avalonia/Themes/Light/CaptionButtons.axaml
Normal file
@ -0,0 +1,14 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<PathGeometry x:Key="WindowCloseIconGlyph">M13.46,12L19,17.54V19H17.54L12,13.46L6.46,19H5V17.54L10.54,12L5,6.46V5H6.46L12,10.54L17.54,5H19V6.46L13.46,12Z</PathGeometry>
|
||||
<PathGeometry x:Key="WindowMaximizeGlyph">M4,4H20V20H4V4M6,8V18H18V8H6Z</PathGeometry>
|
||||
<PathGeometry x:Key="WindowMinimizeGlyph">M20,14H4V10H20</PathGeometry>
|
||||
<PathGeometry x:Key="WindowRestoreGlyph">M4,8H8V4H20V16H16V20H4V8M16,8V14H18V6H10V8H16M6,12V18H14V12H6Z</PathGeometry>
|
||||
<PathGeometry x:Key="WindowExpandGlyph">M10,21V19H6.41L10.91,14.5L9.5,13.09L5,17.59V14H3V21H10M14.5,10.91L19,6.41V10H21V3H14V5H17.59L13.09,9.5L14.5,10.91Z</PathGeometry>
|
||||
<PathGeometry x:Key="WindowCollapseGlyph">M19.5,3.09L15,7.59V4H13V11H20V9H16.41L20.91,4.5L19.5,3.09M4,13V15H7.59L3.09,19.5L4.5,20.91L9,16.41V20H11V13H4Z</PathGeometry>
|
||||
<SolidColorBrush x:Key="CaptionButtonPointeroverBackground" Opacity="0.09" Color="#2E3238" />
|
||||
<SolidColorBrush x:Key="CaptionButtonPressedBackground" Opacity="0.13" Color="#2E3238" />
|
||||
<SolidColorBrush x:Key="CaptionButtonClosePointeroverBackground" Color="#D52515" />
|
||||
<SolidColorBrush x:Key="CaptionButtonClosePressedBackground" Color="#B2140C" />
|
||||
<SolidColorBrush x:Key="CaptionButtonForeground" Opacity="0.62" Color="#1C1F23" />
|
||||
</ResourceDictionary>
|
@ -8,6 +8,7 @@
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/ButtonSpinner.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Calendar.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/CalendarDatePicker.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/CaptionButtons.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/CheckBox.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/ComboBox.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/DatePicker.axaml" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user