Skip to content

Commit

Permalink
Add TitleBar style. #234. Fix #246
Browse files Browse the repository at this point in the history
  • Loading branch information
SKProCH committed Mar 31, 2024
1 parent 9144b02 commit 8527bb2
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions Material.Styles/MaterialToolKit.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/TextBox.axaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/ThemeVariantScope.axaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/TimePicker.axaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/TitleBar.xaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/ToggleButton.axaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/ToggleSwitch.axaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/ToolTip.axaml" />
Expand Down
63 changes: 63 additions & 0 deletions Material.Styles/Resources/Themes/TitleBar.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Height="24" Width="300">
<TitleBar Background="SkyBlue" Foreground="Black" />
</Border>
</Design.PreviewWith>

<ControlTheme x:Key="MaterialTitleBar" TargetType="TitleBar">
<Setter Property="Foreground" Value="{DynamicResource MaterialBodyBrush}" />
<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"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Foreground="{TemplateBinding Foreground}" />
</Panel>
</Panel>
</ControlTemplate>
</Setter>

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

<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(-30px)" />
<Setter Property="Transitions">
<Transitions>
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:.25" />
</Transitions>
</Setter>
</Style>

<Style Selector="^:fullscreen:pointerover /template/ Panel#PART_Container">
<Setter Property="RenderTransform" Value="none" />
</Style>
</ControlTheme>

<ControlTheme x:Key="{x:Type TitleBar}" TargetType="TitleBar"
BasedOn="{StaticResource MaterialTitleBar}" />
</ResourceDictionary>

0 comments on commit 8527bb2

Please sign in to comment.