Skip to content

Commit

Permalink
changing sidemenu depending on Window titlebar background state
Browse files Browse the repository at this point in the history
  • Loading branch information
kikipoulet committed Dec 30, 2024
1 parent bec4e1c commit a47e2d4
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
13 changes: 10 additions & 3 deletions SukiUI/Controls/SukiSideMenu.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@
IsPaneOpen="{TemplateBinding IsMenuExpanded}"
OpenPaneLength="{TemplateBinding OpenPaneLength}">
<SplitView.Pane>
<Border>
<Border Margin="{Binding ShowTitlebarBackground, Converter={x:Static suki:WindowBackgroundToMarginConverter.Instance}, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type suki:SukiWindow}}}"
>
<Grid Background="Transparent">
<suki:GlassCard Name="Glass" Classes=""
<Grid.Styles>
<Style Selector="suki|GlassCard">
<!-- in case someone use sukisidemenu without sukiwindow -->
<Setter Property="CornerRadius" Value="0"></Setter>
</Style>
</Grid.Styles>
<suki:GlassCard Name="Glass"
BorderThickness="0,0,1,0"
CornerRadius="0"
CornerRadius="{Binding ShowTitlebarBackground, Converter={x:Static suki:WindowBackgroundToCornerRadiusConverter.Instance}, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type suki:SukiWindow}}}"
IsAnimated="False" />
<DockPanel>
<Button Name="PART_SidebarToggleButton"
Expand Down
50 changes: 50 additions & 0 deletions SukiUI/Controls/SukiSideMenu.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
using Avalonia.Controls.Primitives;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Avalonia.Interactivity;
using Avalonia.Layout;
using SukiUI.Enums;
using Avalonia.Controls.Templates;
using Avalonia.Data.Converters;
using SukiUI.Theme;

namespace SukiUI.Controls;

Expand Down Expand Up @@ -243,3 +246,50 @@ protected override bool NeedsContainerOverride(object? item, int index, out obje
return NeedsContainer<SukiSideMenuItem>(item, out recycleKey);
}
}



public class WindowBackgroundToCornerRadiusConverter : IValueConverter
{
public static readonly WindowBackgroundToCornerRadiusConverter Instance = new();

public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value == null)
return new CornerRadius(0);

if((bool)value == false)
return new CornerRadius(17);

return new CornerRadius(0);
}

public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}


public class WindowBackgroundToMarginConverter : IValueConverter
{
public static readonly WindowBackgroundToMarginConverter Instance = new();

public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value == null)
return new Thickness(0);

if((bool)value == false)
return new Thickness(10,5,0,10);

return new Thickness(0);
}

public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}


0 comments on commit a47e2d4

Please sign in to comment.