Skip to content

Commit

Permalink
feat: redesign CaptionButtons.
Browse files Browse the repository at this point in the history
  • Loading branch information
zdpcdt committed Jan 16, 2025
1 parent 8651ae3 commit 5b39709
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 36 deletions.
33 changes: 33 additions & 0 deletions src/Ursa.Themes.Semi/Compatibles/Theme.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,37 @@
<Setter Property="Width" Value="24" />
</Style>
</ControlTheme>

<ControlTheme x:Key="CaptionButton" TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonForeground}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="Padding" Value="8" />
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Template">
<ControlTemplate TargetType="Button">
<ContentPresenter
Name="PART_ContentPresenter"
Padding="{TemplateBinding Padding}"
Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="{TemplateBinding CornerRadius}" />
</ControlTemplate>
</Setter>

<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource CaptionButtonPointeroverBackground}" />
</Style>

<Style Selector="^:pressed">
<Setter Property="Background" Value="{DynamicResource CaptionButtonPressedBackground}" />
</Style>
</ControlTheme>
</ResourceDictionary>
64 changes: 28 additions & 36 deletions src/Ursa.Themes.Semi/Controls/UrsaWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
<u:CaptionButtons
x:Name="PART_CaptionButtons"
Grid.Column="3"
Margin="8,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
DockPanel.Dock="Right"
Expand All @@ -139,63 +138,56 @@
</ControlTheme>

<ControlTheme x:Key="{x:Type u:CaptionButtons}" TargetType="u:CaptionButtons">
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonForeground}" />
<Setter Property="Template">
<ControlTemplate TargetType="u:CaptionButtons">
<StackPanel
VerticalAlignment="Stretch"
Orientation="Horizontal"
Spacing="2"
TextElement.FontSize="10">
<Button x:Name="PART_FullScreenButton" Theme="{DynamicResource CaptionButton}">
<StackPanel Orientation="Horizontal">
<Button Name="PART_FullScreenButton" Theme="{StaticResource CaptionButton}">
<PathIcon
Name="PART_FullScreenButtonIcon"
Width="12"
Height="12"
Data="{DynamicResource WindowExpandGlyph}"
Theme="{StaticResource InnerPathIcon}"
Data="{StaticResource WindowExpandGlyph}"
Foreground="{Binding $parent[Button].Foreground}" />
</Button>
<Button x:Name="PART_MinimizeButton" Theme="{DynamicResource CaptionButton}">
<Button Name="PART_MinimizeButton" Theme="{StaticResource CaptionButton}">
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource WindowMinimizeGlyph}"
Name="PART_MinimizeButtonIcon"
Theme="{StaticResource InnerPathIcon}"
Data="{StaticResource WindowMinimizeGlyph}"
Foreground="{Binding $parent[Button].Foreground}" />
</Button>
<Button x:Name="PART_RestoreButton" Theme="{DynamicResource CaptionButton}">
<Button Name="PART_RestoreButton" Theme="{StaticResource CaptionButton}">
<PathIcon
Name="PART_RestoreButtonIcon"
Width="12"
Height="12"
Data="{DynamicResource WindowMaximizeGlyph}"
Theme="{StaticResource InnerPathIcon}"
Data="{StaticResource WindowMaximizeGlyph}"
Foreground="{Binding $parent[Button].Foreground}" />
</Button>
<Button
x:Name="PART_CloseButton"
Background="{DynamicResource CaptionButtonClosePointeroverBackground}"
BorderBrush="{DynamicResource CaptionButtonClosePressedBackground}"
Theme="{DynamicResource 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>
<Button Name="PART_CloseButton" Theme="{StaticResource CaptionButton}">
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource WindowCloseIconGlyph}"
Name="PART_CloseButtonIcon"
Theme="{StaticResource InnerPathIcon}"
Data="{StaticResource WindowCloseIconGlyph}"
Foreground="{Binding $parent[Button].Foreground}" />
</Button>
</StackPanel>
</ControlTemplate>
</Setter>

<Style Selector="^ /template/ Button#PART_CloseButton:pointerover">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="{DynamicResource CaptionButtonClosePointeroverBackground}" />
</Style>
<Style Selector="^ /template/ Button#PART_CloseButton:pressed">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="{DynamicResource CaptionButtonClosePressedBackground}" />
</Style>

<Style Selector="^:maximized /template/ PathIcon#PART_RestoreButtonIcon">
<Setter Property="Data" Value="{DynamicResource WindowRestoreGlyph}" />
<Setter Property="Data" Value="{StaticResource WindowRestoreGlyph}" />
</Style>
<Style Selector="^:fullscreen /template/ PathIcon#PART_FullScreenButtonIcon">
<Setter Property="Data" Value="{DynamicResource WindowCollapseGlyph}" />
<Setter Property="Data" Value="{StaticResource WindowCollapseGlyph}" />
</Style>
</ControlTheme>
</ResourceDictionary>

0 comments on commit 5b39709

Please sign in to comment.