Update CaptionButtonForeground resource and WindowDrawnDecorations layout (#779)

* fix: update CaptionButtonForeground resource key and remove cursor setter.

* fix: update WindowDrawnDecorations layout.

* feat: add CaptionButtonDisabledForeground for disabled state and WindowCustomizationsPage.
This commit is contained in:
Zhang Dian
2026-03-26 14:15:47 +08:00
committed by GitHub
parent 0fbcf43309
commit f22709fcb1
7 changed files with 61 additions and 12 deletions

View File

@@ -0,0 +1,32 @@
<UserControl xmlns="https://github.com/avaloniaui"
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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Semi.Avalonia.Demo.Pages.WindowCustomizationsPage"
x:CompileBindings="True">
<StackPanel
Spacing="10"
IsEnabled="{OnFormFactor False, Desktop=True}">
<TextBlock Classes="H2" Text="Desktop properties" />
<CheckBox Content="Extend Client Area to Decorations"
IsChecked="{Binding $parent[Window].ExtendClientAreaToDecorationsHint}" />
<Slider IsEnabled="{Binding $parent[Window].ExtendClientAreaToDecorationsHint}"
HorizontalAlignment="Left"
Width="201" Minimum="-1" Maximum="200"
Value="{Binding $parent[Window].ExtendClientAreaTitleBarHeightHint}" />
<CheckBox Content="Can Resize"
IsChecked="{Binding $parent[Window].CanResize}" />
<CheckBox Content="Can Minimize"
IsChecked="{Binding $parent[Window].CanMinimize}" />
<CheckBox Content="Can Maximize"
IsChecked="{Binding $parent[Window].CanMaximize}"
IsEnabled="{Binding $parent[Window].CanResize}" />
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,12 @@
using Avalonia.Controls;
namespace Semi.Avalonia.Demo.Pages
{
public partial class WindowCustomizationsPage : UserControl
{
public WindowCustomizationsPage()
{
InitializeComponent();
}
}
}

View File

@@ -278,6 +278,9 @@
<TabItem Header="ThemeVariantScope">
<pages:ThemeVariantDemo />
</TabItem>
<TabItem Header="WindowCustomizationsPage">
<pages:WindowCustomizationsPage />
</TabItem>
</TabControl>
</Grid>
</UserControl>

View File

@@ -7,7 +7,6 @@
<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="WindowDecorationProperties.ElementRole" Value="DecorationsElement" />
<Setter Property="Template">
<ControlTemplate TargetType="Button">
@@ -39,6 +38,10 @@
<Style Selector="^:pressed">
<Setter Property="Background" Value="{DynamicResource CaptionButtonPressedBackground}" />
</Style>
<Style Selector="^:disabled">
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonDisabledForeground}" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type WindowDrawnDecorations}" TargetType="WindowDrawnDecorations">
@@ -50,14 +53,13 @@
<WindowDrawnDecorationsContent>
<WindowDrawnDecorationsContent.Underlay>
<!-- Full-size: covers shadow area + frame + behind client area -->
<Panel>
<Panel Name="PART_UnderlayWrapper">
<Border
Name="PART_WindowBorder"
Margin="{TemplateBinding ShadowThickness}"
Background="{DynamicResource WindowBackground}"
BorderBrush="{DynamicResource WindowBorderBrush}"
BorderThickness="1"
BoxShadow="{DynamicResource WindowBorderShadow}" />
BorderThickness="{TemplateBinding FrameThickness}"
IsHitTestVisible="False" />
<!-- Titlebar: background, title text, and drag area live in underlay -->
<Panel Name="PART_TitleBar"
VerticalAlignment="Top"
@@ -81,7 +83,6 @@
<TextBlock
Margin="12,0,0,0"
VerticalAlignment="Center"
FontSize="12"
Text="{TemplateBinding Title}" />
</Panel>
<StackPanel
@@ -90,9 +91,7 @@
HorizontalAlignment="Right"
VerticalAlignment="Top"
IsVisible="{TemplateBinding HasTitleBar}"
Orientation="Horizontal"
Spacing="2"
TextElement.FontSize="10">
Orientation="Horizontal">
<Button
Name="PART_FullScreenButton"
Theme="{StaticResource CaptionButton}"
@@ -137,7 +136,7 @@
WindowDecorationProperties.ElementRole="CloseButton" />
</StackPanel>
<TextBlock
Margin="12,0"
Margin="12,0,0,0"
VerticalAlignment="Center"
Text="{TemplateBinding Title}" />
</DockPanel>

View File

@@ -7,5 +7,6 @@
<StaticResource x:Key="CaptionButtonCloseForeground" ResourceKey="SemiColorWhite" />
<StaticResource x:Key="CaptionButtonClosePointeroverBackground" ResourceKey="SemiColorDangerPointerover" />
<StaticResource x:Key="CaptionButtonClosePressedBackground" ResourceKey="SemiColorDangerActive" />
<StaticResource x:Key="CaptionButtonForeground" ResourceKey="SemiColorText2" />
<StaticResource x:Key="CaptionButtonForeground" ResourceKey="SemiColorText1" />
<StaticResource x:Key="CaptionButtonDisabledForeground" ResourceKey="SemiColorDisabledText" />
</ResourceDictionary>

View File

@@ -7,4 +7,5 @@
<StaticResource x:Key="CaptionButtonClosePointeroverBackground" ResourceKey="SemiColorHotlight" />
<StaticResource x:Key="CaptionButtonClosePressedBackground" ResourceKey="SemiColorHotlight" />
<StaticResource x:Key="CaptionButtonForeground" ResourceKey="SemiColorWindowText" />
<StaticResource x:Key="CaptionButtonDisabledForeground" ResourceKey="SemiColorGrayText" />
</ResourceDictionary>

View File

@@ -7,5 +7,6 @@
<StaticResource x:Key="CaptionButtonCloseForeground" ResourceKey="SemiColorWhite" />
<StaticResource x:Key="CaptionButtonClosePointeroverBackground" ResourceKey="SemiColorDangerPointerover" />
<StaticResource x:Key="CaptionButtonClosePressedBackground" ResourceKey="SemiColorDangerActive" />
<StaticResource x:Key="CaptionButtonForeground" ResourceKey="SemiColorText2" />
<StaticResource x:Key="CaptionButtonForeground" ResourceKey="SemiColorText1" />
<StaticResource x:Key="CaptionButtonDisabledForeground" ResourceKey="SemiColorDisabledText" />
</ResourceDictionary>