From ed21ac3ca285b664ad3d6eeddd5af44e84212a4a Mon Sep 17 00:00:00 2001 From: Clement Sepulchre Date: Fri, 31 May 2024 11:42:18 +0200 Subject: [PATCH] sorry for that --- SukiUI/Controls/GlassMorphism/GlassCard.axaml | 29 +++--- .../Controls/GlassMorphism/GlassCard.axaml.cs | 98 ++++++++++++++++++- 2 files changed, 115 insertions(+), 12 deletions(-) diff --git a/SukiUI/Controls/GlassMorphism/GlassCard.axaml b/SukiUI/Controls/GlassMorphism/GlassCard.axaml index 6e1de1821..0be3ddd48 100644 --- a/SukiUI/Controls/GlassMorphism/GlassCard.axaml +++ b/SukiUI/Controls/GlassMorphism/GlassCard.axaml @@ -6,14 +6,27 @@ + - + + + + + + + + @@ -65,16 +78,10 @@ + ("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); + }; + + + + } + + + public static void MakeOpacityAnimated(CompositionVisual compositionVisual) + { + if (compositionVisual == null) + return; + + Compositor compositor = compositionVisual.Compositor; + + var animationGroup = compositor.CreateAnimationGroup(); + + + ScalarKeyFrameAnimation opacityAnimation = compositor.CreateScalarKeyFrameAnimation(); + opacityAnimation.Target = "Opacity"; + opacityAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue"); + opacityAnimation.Duration = TimeSpan.FromMilliseconds(700); + + + + Vector3KeyFrameAnimation offsetAnimation = compositor.CreateVector3KeyFrameAnimation(); + offsetAnimation.Target = "Offset"; + offsetAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue"); + offsetAnimation.Duration = TimeSpan.FromMilliseconds(700); + + + animationGroup.Add(offsetAnimation); + animationGroup.Add(opacityAnimation); + + + ImplicitAnimationCollection implicitAnimationCollection = compositor.CreateImplicitAnimationCollection(); + implicitAnimationCollection["Opacity"] = animationGroup; + implicitAnimationCollection["Offset"] = animationGroup; + + + compositionVisual.ImplicitAnimations = implicitAnimationCollection; + + } + + public static void MakeSizeAnimated(CompositionVisual compositionVisual) + { + if (compositionVisual == null) + return; + + Compositor compositor = compositionVisual.Compositor; + + var animationGroup = compositor.CreateAnimationGroup(); + + Vector2KeyFrameAnimation sizeAnimation = compositor.CreateVector2KeyFrameAnimation(); + sizeAnimation.Target = "Size"; + sizeAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue"); + sizeAnimation.Duration = TimeSpan.FromMilliseconds(450); + + + + Vector3KeyFrameAnimation offsetAnimation = compositor.CreateVector3KeyFrameAnimation(); + offsetAnimation.Target = "Offset"; + offsetAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue"); + offsetAnimation.Duration = TimeSpan.FromMilliseconds(450); + + animationGroup.Add(sizeAnimation); + + animationGroup.Add(offsetAnimation); + + ImplicitAnimationCollection implicitAnimationCollection = compositor.CreateImplicitAnimationCollection(); + implicitAnimationCollection["Size"] = animationGroup; + implicitAnimationCollection["Offset"] = animationGroup; + + + compositionVisual.ImplicitAnimations = implicitAnimationCollection; + + } + private void ContextMenuOnOpening(object sender, CancelEventArgs e) { PseudoClasses.Set(":pointerdown", false);