mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-03-11 04:00:48 +08:00
Compare commits
1 Commits
WindowDraw
...
12.0.0-pre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c144056ab0 |
@@ -5,10 +5,12 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:views="clr-namespace:Semi.Avalonia.Demo.Views"
|
||||
Title="Semi.Avalonia.Demo"
|
||||
Title="Semi Avalonia Demo"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
ExtendClientAreaToDecorationsHint="True"
|
||||
ExtendClientAreaTitleBarHeightHint="40"
|
||||
Icon="/Assets/irihi.ico"
|
||||
mc:Ignorable="d">
|
||||
<views:MainView />
|
||||
<views:MainView Margin="{Binding $parent[Window].WindowDecorationMargin}" />
|
||||
</Window>
|
||||
@@ -1,66 +1,205 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ControlTheme x:Key="CaptionButton" TargetType="Button">
|
||||
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonForeground}" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="CornerRadius" Value="{StaticResource CaptionButtonCornerRadius}" />
|
||||
<Setter Property="Padding" Value="{StaticResource CaptionButtonPadding}" />
|
||||
<Setter Property="Width" Value="{StaticResource CaptionButtonWidth}" />
|
||||
<Setter Property="Height" Value="{StaticResource CaptionButtonHeight}" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="Button">
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Foreground="{TemplateBinding Foreground}" />
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:pointerover">
|
||||
<Setter Property="Background" Value="{DynamicResource CaptionButtonPointeroverBackground}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:pressed">
|
||||
<Setter Property="Background" Value="{DynamicResource CaptionButtonPressedBackground}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type WindowDrawnDecorations}" TargetType="WindowDrawnDecorations">
|
||||
<Setter Property="DefaultTitleBarHeight" Value="32" />
|
||||
<Setter Property="DefaultFrameThickness" Value="0,0,0,0" />
|
||||
<Setter Property="DefaultFrameThickness" Value="1" />
|
||||
<Setter Property="DefaultShadowThickness" Value="16" />
|
||||
<Setter Property="Template">
|
||||
<WindowDrawnDecorationsTemplate>
|
||||
<WindowDrawnDecorationsContent>
|
||||
|
||||
<WindowDrawnDecorationsContent.Underlay>
|
||||
<!-- Full-size: covers shadow area + frame + behind client area -->
|
||||
<!-- Full-size: covers shadow area + frame + behind client area -->
|
||||
<Panel>
|
||||
<Border Margin="{TemplateBinding ShadowThickness}"
|
||||
Background="{DynamicResource WindowBackground}"
|
||||
BorderThickness="1"
|
||||
BorderBrush="{DynamicResource WindowBorderBrush}"
|
||||
BoxShadow="0 8 32 0 #40000000" />
|
||||
<Border
|
||||
x:Name="PART_WindowBorder"
|
||||
Margin="{TemplateBinding ShadowThickness}"
|
||||
Background="{DynamicResource WindowBackground}"
|
||||
BorderBrush="{DynamicResource WindowBorderBrush}"
|
||||
BorderThickness="1"
|
||||
BoxShadow="0 8 32 0 #40000000" />
|
||||
<!-- Titlebar: background, title text, and drag area live in underlay -->
|
||||
<Panel x:Name="PART_TitleBar" VerticalAlignment="Top"
|
||||
Height="{TemplateBinding TitleBarHeight}"
|
||||
Background="{DynamicResource SystemControlBackgroundAltHighBrush}"
|
||||
IsVisible="{TemplateBinding HasTitleBar}"
|
||||
WindowDecorationProperties.ElementRole="TitleBar" />
|
||||
</Panel>
|
||||
</WindowDrawnDecorationsContent.Underlay>
|
||||
|
||||
<WindowDrawnDecorationsContent.Overlay>
|
||||
<!-- Positioned over the titlebar area -->
|
||||
<DockPanel Height="{TemplateBinding TitleBarHeight}"
|
||||
VerticalAlignment="Top"
|
||||
Margin="{TemplateBinding ShadowThickness}">
|
||||
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
|
||||
<Button x:Name="PART_MinimizeButton" Content="─" />
|
||||
<Button x:Name="PART_MaximizeButton" Content="□" />
|
||||
<Button x:Name="PART_CloseButton" Content="✕" />
|
||||
<!-- Positioned over the titlebar area -->
|
||||
<Panel x:Name="PART_OverlayWrapper">
|
||||
<!-- Title text lives in overlay so it renders above client content -->
|
||||
<Panel
|
||||
x:Name="PART_TitleTextPanel"
|
||||
Height="{TemplateBinding TitleBarHeight}"
|
||||
VerticalAlignment="Top"
|
||||
IsHitTestVisible="False"
|
||||
IsVisible="{TemplateBinding HasTitleBar}">
|
||||
<TextBlock
|
||||
Margin="12,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12"
|
||||
Text="{TemplateBinding Title}" />
|
||||
</Panel>
|
||||
<StackPanel
|
||||
x:Name="PART_OverlayPanel"
|
||||
Height="{TemplateBinding TitleBarHeight}"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
IsVisible="{TemplateBinding HasTitleBar}"
|
||||
Orientation="Horizontal"
|
||||
Spacing="2"
|
||||
TextElement.FontSize="10">
|
||||
<Button
|
||||
Name="PART_FullScreenButton"
|
||||
Theme="{StaticResource CaptionButton}"
|
||||
WindowDecorationProperties.ElementRole="FullScreenButton">
|
||||
<PathIcon
|
||||
Name="PART_FullScreenButtonIcon"
|
||||
Data="{StaticResource WindowExpandGlyph}"
|
||||
Foreground="{Binding $parent[Button].Foreground}"
|
||||
Theme="{StaticResource InnerPathIcon}" />
|
||||
</Button>
|
||||
<Button
|
||||
Name="PART_MinimizeButton"
|
||||
AutomationProperties.Name="Minimize"
|
||||
Theme="{StaticResource CaptionButton}"
|
||||
WindowDecorationProperties.ElementRole="MinimizeButton">
|
||||
<PathIcon
|
||||
Name="PART_MinimizeButtonIcon"
|
||||
Data="{StaticResource WindowMinimizeGlyph}"
|
||||
Foreground="{Binding $parent[Button].Foreground}"
|
||||
Theme="{StaticResource InnerPathIcon}" />
|
||||
</Button>
|
||||
<Button
|
||||
Name="PART_MaximizeButton"
|
||||
AutomationProperties.Name="Maximize"
|
||||
Theme="{StaticResource CaptionButton}"
|
||||
WindowDecorationProperties.ElementRole="MaximizeButton">
|
||||
<PathIcon
|
||||
Name="PART_MaximizeButtonIcon"
|
||||
Data="{StaticResource WindowMaximizeGlyph}"
|
||||
Foreground="{Binding $parent[Button].Foreground}"
|
||||
Theme="{StaticResource InnerPathIcon}" />
|
||||
</Button>
|
||||
<Button
|
||||
Name="PART_CloseButton"
|
||||
AutomationProperties.Name="Close"
|
||||
Theme="{StaticResource CaptionButton}"
|
||||
WindowDecorationProperties.ElementRole="CloseButton">
|
||||
<PathIcon
|
||||
Name="PART_CloseButtonIcon"
|
||||
Data="{StaticResource WindowCloseIconGlyph}"
|
||||
Foreground="{Binding $parent[Button].Foreground}"
|
||||
Theme="{StaticResource InnerPathIcon}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<TextBlock Text="{TemplateBinding Title}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="12,0"
|
||||
WindowDecorationProperties.ElementRole="TitleBar" />
|
||||
</DockPanel>
|
||||
</Panel>
|
||||
</WindowDrawnDecorationsContent.Overlay>
|
||||
|
||||
<WindowDrawnDecorationsContent.FullscreenPopover>
|
||||
<!-- Shown on hover at top edge in fullscreen -->
|
||||
<DockPanel Height="{TemplateBinding TitleBarHeight}"
|
||||
Background="#E0000000">
|
||||
<!-- Shown on hover at top edge in fullscreen -->
|
||||
<DockPanel Height="{TemplateBinding TitleBarHeight}" Background="#E0000000">
|
||||
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
|
||||
<Button x:Name="PART_MinimizeButton" Content="─" />
|
||||
<Button x:Name="PART_MaximizeButton" Content="□" />
|
||||
<Button x:Name="PART_CloseButton" Content="✕" />
|
||||
<Button
|
||||
x:Name="PART_PopoverFullScreenButton"
|
||||
Theme="{StaticResource CaptionButton}"
|
||||
WindowDecorationProperties.ElementRole="FullScreenButton">
|
||||
<PathIcon
|
||||
Data="{StaticResource WindowCollapseGlyph}"
|
||||
Foreground="{Binding $parent[Button].Foreground}"
|
||||
Theme="{StaticResource InnerPathIcon}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<TextBlock Text="{TemplateBinding Title}"
|
||||
Foreground="White"
|
||||
VerticalAlignment="Center"
|
||||
Margin="12,0" />
|
||||
<TextBlock
|
||||
Margin="12,0"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="White"
|
||||
Text="{TemplateBinding Title}" />
|
||||
</DockPanel>
|
||||
</WindowDrawnDecorationsContent.FullscreenPopover>
|
||||
|
||||
</WindowDrawnDecorationsContent>
|
||||
</WindowDrawnDecorationsTemplate>
|
||||
</Setter>
|
||||
|
||||
<!-- Pseudoclass styling -->
|
||||
<Style Selector="^:maximized /template/ Border">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
|
||||
<Style Selector="^ /template/ Button#PART_CloseButton:pointerover">
|
||||
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonCloseForeground}" />
|
||||
<Setter Property="Background" Value="{DynamicResource CaptionButtonClosePointeroverBackground}" />
|
||||
</Style>
|
||||
<Style Selector="^:fullscreen /template/ DockPanel">
|
||||
<Style Selector="^ /template/ Button#PART_CloseButton:pressed">
|
||||
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonCloseForeground}" />
|
||||
<Setter Property="Background" Value="{DynamicResource CaptionButtonClosePressedBackground}" />
|
||||
</Style>
|
||||
|
||||
<!-- Shadow: inset border and add drop shadow -->
|
||||
<Style Selector="^:has-shadow /template/ Panel#PART_UnderlayWrapper">
|
||||
<Setter Property="Margin" Value="{TemplateBinding ShadowThickness}" />
|
||||
</Style>
|
||||
<Style Selector="^:has-shadow /template/ Border#PART_WindowBorder">
|
||||
<Setter Property="BoxShadow" Value="0 2 10 2 #80000000" />
|
||||
</Style>
|
||||
<Style Selector="^:has-shadow /template/ Panel#PART_OverlayWrapper">
|
||||
<Setter Property="Margin" Value="{TemplateBinding ShadowThickness}" />
|
||||
</Style>
|
||||
|
||||
<!-- Maximized: restore button path changes -->
|
||||
<Style Selector="^:maximized /template/ Path#PART_MaximizeButtonIcon">
|
||||
<Setter Property="Data" Value="{StaticResource WindowRestoreGlyph}" />
|
||||
</Style>
|
||||
|
||||
<!-- Border: inset titlebar and buttons inside frame -->
|
||||
<Style Selector="^:has-border /template/ Panel#PART_TitleTextPanel">
|
||||
<Setter Property="Margin" Value="1,1,1,0" />
|
||||
</Style>
|
||||
<Style Selector="^:has-border /template/ Panel#PART_TitleBar">
|
||||
<Setter Property="Margin" Value="1,1,1,0" />
|
||||
</Style>
|
||||
<Style Selector="^:has-border /template/ StackPanel#PART_OverlayPanel">
|
||||
<Setter Property="Margin" Value="0,1,1,0" />
|
||||
</Style>
|
||||
|
||||
<!-- Fullscreen: hide overlay and titlebar (popover takes over) -->
|
||||
<Style Selector="^:fullscreen /template/ Panel#PART_TitleTextPanel">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
<Style Selector="^:fullscreen /template/ StackPanel#PART_OverlayPanel">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
<Style Selector="^:fullscreen /template/ Panel#PART_TitleBar">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
Reference in New Issue
Block a user