Skip to content

Commit

Permalink
IsAnimated property for glasscard, disabled on menu and window to foc…
Browse files Browse the repository at this point in the history
…us on content
  • Loading branch information
kikipoulet committed May 31, 2024
1 parent 35e9f09 commit 1b9f8fb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
54 changes: 33 additions & 21 deletions SukiUI/Controls/GlassMorphism/GlassCard.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ public class GlassCard : ContentControl
set => SetValue(BorderThicknessProperty, value);
}

public static readonly StyledProperty<bool> IsAnimatedProperty =
AvaloniaProperty.Register<GlassCard, bool>(nameof(IsAnimated), true);

public bool IsAnimated
{
get => GetValue(IsAnimatedProperty);
set => SetValue(IsAnimatedProperty, value);
}

public static readonly StyledProperty<bool> IsOpaqueProperty =
AvaloniaProperty.Register<GlassCard, bool>(nameof(IsOpaque), false);

Expand Down Expand Up @@ -76,28 +85,31 @@ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
var b = e.NameScope.Get<Panel>("RootPanel");
b.Loaded += (sender, args) =>
{
var v = ElementComposition.GetElementVisual(b);
MakeOpacityAnimated(v);
};

var b2 = e.NameScope.Get<Border>("PART_BorderCard");
b2.Loaded += (sender, args) =>
{
var v = ElementComposition.GetElementVisual(b2);
MakeSizeAnimated(v);
};

var b3 = e.NameScope.Get<Border>("PART_ClipBorder");
b3.Loaded += (sender, args) =>
{
var v = ElementComposition.GetElementVisual(b3);
MakeSizeAnimated(v);
};


if (IsAnimated)
{
var b = e.NameScope.Get<Panel>("RootPanel");
b.Loaded += (sender, args) =>
{
var v = ElementComposition.GetElementVisual(b);
MakeOpacityAnimated(v);
};

var b2 = e.NameScope.Get<Border>("PART_BorderCard");
b2.Loaded += (sender, args) =>
{
var v = ElementComposition.GetElementVisual(b2);
MakeSizeAnimated(v);
};

var b3 = e.NameScope.Get<Border>("PART_ClipBorder");
b3.Loaded += (sender, args) =>
{
var v = ElementComposition.GetElementVisual(b3);
MakeSizeAnimated(v);
};

}

}

Expand Down
2 changes: 1 addition & 1 deletion SukiUI/Controls/SukiSideMenu.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<SplitView.Pane>
<Border>
<Grid Background="Transparent">
<suki:GlassCard Name="Glass"
<suki:GlassCard Name="Glass" IsAnimated="False"
BorderThickness="0"
CornerRadius="0" />
<DockPanel>
Expand Down
2 changes: 1 addition & 1 deletion SukiUI/Controls/SukiWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<StackPanel>
<LayoutTransformControl Name="PART_LayoutTransform" RenderTransformOrigin="0%,0%">
<Panel>
<suki:GlassCard Name="PART_TitleBarBackground"
<suki:GlassCard Name="PART_TitleBarBackground" IsAnimated="False"
BorderThickness="0"
CornerRadius="0" />
<DockPanel Margin="12,9" LastChildFill="True">
Expand Down
2 changes: 1 addition & 1 deletion SukiUI/Theme/Menu.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<Setter Property="Template">
<ControlTemplate>
<LayoutTransformControl Name="PART_LayoutTransform" RenderTransformOrigin="50%, 0%">
<controls:GlassCard Height="45"
<controls:GlassCard Height="45" IsAnimated="False"
Padding="{TemplateBinding Padding}"
BorderBrush="{DynamicResource SukiBorderBrush}"
BorderThickness="0"
Expand Down

0 comments on commit 1b9f8fb

Please sign in to comment.