Skip to content

Commit

Permalink
Show or hide titlebar glass background and modify menu style for diff…
Browse files Browse the repository at this point in the history
…erent configs
  • Loading branch information
kikipoulet committed Dec 30, 2024
1 parent 4457bac commit bec4e1c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
10 changes: 9 additions & 1 deletion SukiUI.Demo/SukiUIDemoView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
CanResize="{Binding !WindowLocked}"
Icon="Assets/OIG.N5o-removebg-preview.png"
IsMenuVisible="True"
ShowTitlebarBackground="{Binding ShowTitleBar}" ShowBottomBorder="{Binding ShowBottomBar}"
IsTitleBarVisible="{Binding TitleBarVisible, Mode=TwoWay}"
mc:Ignorable="d">
<suki:SukiWindow.Hosts>
Expand Down Expand Up @@ -138,6 +139,13 @@
Kind="{Binding TitleBarVisible, Converter={x:Static converters:BoolToIconConverters.Visibility}}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="{Binding ToggleTitleBackgroundCommand}"
Header="Change TitleBar Visibility"
>
<MenuItem.Icon>
<avalonia:MaterialIcon Kind="Visibility" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="{Binding ToggleRightToLeftCommand}"
Header="Right To Left"
ToolTip.Tip="Toggles the right to left.">
Expand Down Expand Up @@ -214,7 +222,7 @@
IsVisible="{Binding $parent[suki:SukiWindow].((demo:SukiUIDemoViewModel)DataContext).TitleBarVisible}"
PointerPressed="InputElement_OnPointerPressed"
Source="Assets/OIG.N5o-removebg-preview.png"
ToolTip.ShowDelay="0"

ToolTip.Tip="Click To Toggle Top Menu." />
</suki:SukiSideMenu.HeaderContent>
<suki:SukiSideMenu.FooterContent>
Expand Down
10 changes: 10 additions & 0 deletions SukiUI.Demo/SukiUIDemoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public partial class SukiUIDemoViewModel : ObservableObject
[ObservableProperty] private string? _customShaderFile;
[ObservableProperty] private bool _transitionsEnabled;
[ObservableProperty] private double _transitionTime;

[ObservableProperty] private bool _showTitleBar = true;
[ObservableProperty] private bool _showBottomBar = true;

private readonly SukiTheme _theme;
private readonly ThemingViewModel _theming;
Expand Down Expand Up @@ -137,6 +140,13 @@ private void ToggleWindowLock()
.WithContent($"Window has been {(WindowLocked ? "locked" : "unlocked")}.")
.Queue();
}

[RelayCommand]
private void ToggleTitleBackground()
{
ShowTitleBar = !ShowTitleBar;
ShowBottomBar = !ShowBottomBar;
}

[RelayCommand]
private void ToggleTitleBar()
Expand Down
15 changes: 13 additions & 2 deletions SukiUI/Controls/SukiWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<StackPanel>
<LayoutTransformControl Name="PART_LayoutTransform" RenderTransformOrigin="0%,0%">
<Panel>
<suki:GlassCard Name="PART_TitleBarBackground"
<suki:GlassCard Name="PART_TitleBarBackground" IsVisible="{TemplateBinding ShowTitlebarBackground}"
BorderThickness="0"
CornerRadius="0"
IsAnimated="False" />
Expand Down Expand Up @@ -114,7 +114,11 @@
</DockPanel>
</Panel>
</LayoutTransformControl>
<Menu IsEnabled="{TemplateBinding IsMenuVisible}" ItemsSource="{TemplateBinding MenuItems}" />
<Panel IsVisible="{TemplateBinding IsMenuVisible}">
<suki:GlassCard CornerRadius="0" BorderThickness="0" Margin="0,0,0,0" IsVisible="{TemplateBinding ShowTitlebarBackground}"></suki:GlassCard>
<suki:GlassCard CornerRadius="13" Margin="10,2,10,10" Name="AlternativeGlassMenuBackground"></suki:GlassCard>
<Menu Name="PART_Menu" IsEnabled="{TemplateBinding IsMenuVisible}" ItemsSource="{TemplateBinding MenuItems}" />
</Panel>
<Border Name="PART_BottomBorder" BorderBrush="{DynamicResource SukiBorderBrush}" />
</StackPanel>
</Panel>
Expand All @@ -131,6 +135,13 @@
</Border>
</ControlTemplate>
</Setter>

<Style Selector="^[ShowTitlebarBackground=False] /template/ Menu#PART_Menu">
<Setter Property="Margin" Value="10,0,0,7"></Setter>
</Style>
<Style Selector="^[ShowTitlebarBackground=True] /template/ suki|GlassCard#AlternativeGlassMenuBackground">
<Setter Property="IsVisible" Value="False"></Setter>
</Style>

<Style Selector="^[WindowState=Maximized] /template/ PathIcon#MaximizeIcon">
<Setter Property="Data" Value="{x:Static icons:Icons.WindowRestore}" />
Expand Down
8 changes: 8 additions & 0 deletions SukiUI/Controls/SukiWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ public bool CanMinimize
get => GetValue(CanMinimizeProperty);
set => SetValue(CanMinimizeProperty, value);
}

public static readonly StyledProperty<bool> ShowTitlebarBackgroundProperty =
AvaloniaProperty.Register<SukiWindow, bool>(nameof(ShowTitlebarBackground), defaultValue: true);
public bool ShowTitlebarBackground
{
get => GetValue(ShowTitlebarBackgroundProperty);
set => SetValue(ShowTitlebarBackgroundProperty, value);
}

public static readonly StyledProperty<bool> CanMaximizeProperty =
AvaloniaProperty.Register<SukiWindow, bool>(nameof(CanMaximize), defaultValue: true);
Expand Down
6 changes: 3 additions & 3 deletions SukiUI/Theme/Menu.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@
<Setter Property="Template">
<ControlTemplate>
<LayoutTransformControl Name="PART_LayoutTransform" RenderTransformOrigin="50%, 0%">
<controls:GlassCard Height="45"
<Border Height="45"
Padding="{TemplateBinding Padding}"
BorderBrush="{DynamicResource SukiBorderBrush}"
BorderThickness="0"
CornerRadius="{TemplateBinding CornerRadius}"
IsAnimated="False">
>
<ItemsPresenter Name="PART_ItemsPresenter"
ItemsPanel="{TemplateBinding ItemsPanel}"
KeyboardNavigation.TabNavigation="Continue" />
</controls:GlassCard>
</Border>
</LayoutTransformControl>
</ControlTemplate>
</Setter>
Expand Down

0 comments on commit bec4e1c

Please sign in to comment.