From 1b9f8fb11d0de1fd76e71e8a2f9a4cf254778a70 Mon Sep 17 00:00:00 2001 From: Clement Sepulchre Date: Fri, 31 May 2024 15:37:48 +0200 Subject: [PATCH] IsAnimated property for glasscard, disabled on menu and window to focus on content --- .../Controls/GlassMorphism/GlassCard.axaml.cs | 54 +++++++++++-------- SukiUI/Controls/SukiSideMenu.axaml | 2 +- SukiUI/Controls/SukiWindow.axaml | 2 +- SukiUI/Theme/Menu.axaml | 2 +- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/SukiUI/Controls/GlassMorphism/GlassCard.axaml.cs b/SukiUI/Controls/GlassMorphism/GlassCard.axaml.cs index e2d153ce4..2295aeb31 100644 --- a/SukiUI/Controls/GlassMorphism/GlassCard.axaml.cs +++ b/SukiUI/Controls/GlassMorphism/GlassCard.axaml.cs @@ -33,6 +33,15 @@ public class GlassCard : ContentControl set => SetValue(BorderThicknessProperty, value); } + public static readonly StyledProperty IsAnimatedProperty = + AvaloniaProperty.Register(nameof(IsAnimated), true); + + public bool IsAnimated + { + get => GetValue(IsAnimatedProperty); + set => SetValue(IsAnimatedProperty, value); + } + public static readonly StyledProperty IsOpaqueProperty = AvaloniaProperty.Register(nameof(IsOpaque), false); @@ -76,28 +85,31 @@ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); - var b = e.NameScope.Get("RootPanel"); - b.Loaded += (sender, args) => - { - var v = ElementComposition.GetElementVisual(b); - MakeOpacityAnimated(v); - }; - - var b2 = e.NameScope.Get("PART_BorderCard"); - b2.Loaded += (sender, args) => - { - var v = ElementComposition.GetElementVisual(b2); - MakeSizeAnimated(v); - }; - - var b3 = e.NameScope.Get("PART_ClipBorder"); - b3.Loaded += (sender, args) => - { - var v = ElementComposition.GetElementVisual(b3); - MakeSizeAnimated(v); - }; - + if (IsAnimated) + { + var b = e.NameScope.Get("RootPanel"); + b.Loaded += (sender, args) => + { + var v = ElementComposition.GetElementVisual(b); + MakeOpacityAnimated(v); + }; + + var b2 = e.NameScope.Get("PART_BorderCard"); + b2.Loaded += (sender, args) => + { + var v = ElementComposition.GetElementVisual(b2); + MakeSizeAnimated(v); + }; + + var b3 = e.NameScope.Get("PART_ClipBorder"); + b3.Loaded += (sender, args) => + { + var v = ElementComposition.GetElementVisual(b3); + MakeSizeAnimated(v); + }; + + } } diff --git a/SukiUI/Controls/SukiSideMenu.axaml b/SukiUI/Controls/SukiSideMenu.axaml index ec325b9f1..4d2485015 100644 --- a/SukiUI/Controls/SukiSideMenu.axaml +++ b/SukiUI/Controls/SukiSideMenu.axaml @@ -13,7 +13,7 @@ - diff --git a/SukiUI/Controls/SukiWindow.axaml b/SukiUI/Controls/SukiWindow.axaml index 7e8de2a78..7be94b1cc 100644 --- a/SukiUI/Controls/SukiWindow.axaml +++ b/SukiUI/Controls/SukiWindow.axaml @@ -30,7 +30,7 @@ - diff --git a/SukiUI/Theme/Menu.axaml b/SukiUI/Theme/Menu.axaml index 017f00b72..edd7a8b08 100644 --- a/SukiUI/Theme/Menu.axaml +++ b/SukiUI/Theme/Menu.axaml @@ -89,7 +89,7 @@ -