diff --git a/Directory.Packages.props b/Directory.Packages.props index 00ada12ad..17b02ae55 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,7 +10,7 @@ - + diff --git a/src/AtomUI.Base/Animations/Transitions/INotifyTransitionCompleted.cs b/src/AtomUI.Base/Animations/Transitions/INotifyTransitionCompleted.cs index 1e99ca9d9..a0ce41303 100644 --- a/src/AtomUI.Base/Animations/Transitions/INotifyTransitionCompleted.cs +++ b/src/AtomUI.Base/Animations/Transitions/INotifyTransitionCompleted.cs @@ -1,3 +1,5 @@ +using Avalonia.Animation; + namespace AtomUI.Animations; public class TransitionCompletedEventArgs : EventArgs @@ -10,7 +12,7 @@ public class TransitionCompletedEventArgs : EventArgs } } -internal interface INotifyTransitionCompleted +public interface INotifyTransitionCompleted : ITransition { public IObservable CompletedObservable { get; } public event EventHandler? TransitionCompleted; diff --git a/src/AtomUI.Base/Animations/Transitions/SolidColorBrushTransition.cs b/src/AtomUI.Base/Animations/Transitions/SolidColorBrushTransition.cs index 76b73cd66..250c5c958 100644 --- a/src/AtomUI.Base/Animations/Transitions/SolidColorBrushTransition.cs +++ b/src/AtomUI.Base/Animations/Transitions/SolidColorBrushTransition.cs @@ -1,13 +1,16 @@ using Avalonia.Animation; using Avalonia.Media; -using Avalonia.Media.Immutable; namespace AtomUI.Animations; -public class SolidColorBrushTransition : InterpolatingTransitionBase +public class SolidColorBrushTransition : InterpolatingTransitionBase { - protected override ISolidColorBrush? Interpolate(double progress, ISolidColorBrush? from, ISolidColorBrush? to) + protected override IBrush? Interpolate(double progress, IBrush? from, IBrush? to) { - return InterpolateUtils.SolidColorBrushInterpolate(progress, from, to); + if (from is ISolidColorBrush fromBrush && to is ISolidColorBrush toBrush) + { + return InterpolateUtils.SolidColorBrushInterpolate(progress, fromBrush, toBrush); + } + return InterpolateUtils.BrushInterpolate(progress, from, to); } } \ No newline at end of file diff --git a/src/AtomUI.Base/AtomUI.Base.csproj b/src/AtomUI.Base/AtomUI.Base.csproj index 4ff190c67..e0108529a 100644 --- a/src/AtomUI.Base/AtomUI.Base.csproj +++ b/src/AtomUI.Base/AtomUI.Base.csproj @@ -7,6 +7,7 @@ + diff --git a/src/AtomUI.Base/MotionScene/AbstractMotion.cs b/src/AtomUI.Base/MotionScene/AbstractMotion.cs index 79a0e7966..8a9845c6e 100644 --- a/src/AtomUI.Base/MotionScene/AbstractMotion.cs +++ b/src/AtomUI.Base/MotionScene/AbstractMotion.cs @@ -1,8 +1,11 @@ -using Avalonia; +using System.Reactive.Linq; +using AtomUI.Animations; +using Avalonia; using Avalonia.Animation; using Avalonia.Animation.Easings; using Avalonia.Controls; using Avalonia.Media.Transformation; +using Avalonia.ReactiveUI; using Avalonia.Threading; namespace AtomUI.MotionScene; @@ -11,6 +14,7 @@ public class AbstractMotion : IMotion { public RelativePoint RenderTransformOrigin { get; protected set; } public IList Animations { get; } + public IList Transitions { get; } public TimeSpan Duration { get; } public Easing Easing { get; } public FillMode PropertyValueFillMode { get; } @@ -21,6 +25,7 @@ public class AbstractMotion : IMotion Duration = duration; Easing = easing ?? new LinearEasing(); PropertyValueFillMode = fillMode; + Transitions = new List(); } public async Task RunAsync(MotionActorControl actor, @@ -48,11 +53,76 @@ public class AbstractMotion : IMotion completedAction?.Invoke(); }); } + + internal void RunTransitions(MotionActorControl actor, + Action? aboutToStart = null, + Action? completedAction = null) + { + ConfigureTransitions(); + using var originRestore = new RenderTransformOriginRestore(actor); + actor.NotifyMotionPreStart(); + NotifyPreStart(); + aboutToStart?.Invoke(); + + actor.RenderTransformOrigin = RenderTransformOrigin; + var observables = new List>(); + + // 暂时先不保存 actor 原有的 transitions + actor.Transitions ??= new Transitions(); + actor.Transitions.Clear(); + foreach (var transition in Transitions) + { + observables.Add(transition.CompletedObservable); + actor.Transitions.Add(transition); + } + + actor.DisableTransitions(); + ConfigureMotionStartValue(actor); + actor.EnableTransitions(); + ConfigureMotionEndValue(actor); + + observables.Zip() + .LastAsync() + .ObserveOn(AvaloniaScheduler.Instance) + .Subscribe((v) => + { + actor.NotifyMotionCompleted(); + NotifyCompleted(); + completedAction?.Invoke(); + }); + } protected virtual void Configure() { } + protected virtual void ConfigureTransitions() + { + var opacityTransition = new NotifiableDoubleTransition() + { + Duration = Duration, + Easing = Easing, + Property = MotionActorControl.OpacityProperty, + }; + Transitions.Add(opacityTransition); + + var transformOperationsTransition = new NotifiableTransformOperationsTransition() + { + Duration = Duration, + Easing = Easing, + Property = MotionActorControl.MotionTransformProperty, + }; + Transitions.Add(transformOperationsTransition); + } + + protected virtual void ConfigureMotionStartValue(MotionActorControl actor) + { + } + + protected virtual void ConfigureMotionEndValue(MotionActorControl actor) + { + } + protected virtual void NotifyPreStart() { } diff --git a/src/AtomUI.Base/MotionScene/CollapseMotions.cs b/src/AtomUI.Base/MotionScene/CollapseMotions.cs index bdd0024be..1e4be449f 100644 --- a/src/AtomUI.Base/MotionScene/CollapseMotions.cs +++ b/src/AtomUI.Base/MotionScene/CollapseMotions.cs @@ -18,75 +18,9 @@ public class CollapseMotion : AbstractMotion Direction = direction; } - protected override void Configure() + protected override void ConfigureTransitions() { - var isHorizontal = Direction == Direction.Left || Direction == Direction.Right; - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - if (isHorizontal) - { - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(1.0) - }; - startFrame.Setters.Add(scaleXSetter); - } - else - { - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(1.0) - }; - startFrame.Setters.Add(scaleYSetter); - } - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - if (isHorizontal) - { - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(0.0) - }; - endFrame.Setters.Add(scaleXSetter); - } - else - { - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(0.0) - }; - endFrame.Setters.Add(scaleYSetter); - } - } - animation.Children.Add(endFrame); - + base.ConfigureTransitions(); if (Direction == Direction.Left) { RenderTransformOrigin = new RelativePoint(1, 0.5, RelativeUnit.Relative); @@ -103,8 +37,34 @@ public class CollapseMotion : AbstractMotion { RenderTransformOrigin = new RelativePoint(0.5, 0.0, RelativeUnit.Relative); } + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + var isHorizontal = Direction == Direction.Left || Direction == Direction.Right; + actor.Opacity = 1.0; + if (isHorizontal) + { + actor.MotionTransform = BuildScaleXTransform(1.0); + } + else + { + actor.MotionTransform = BuildScaleYTransform(1.0); + } + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + var isHorizontal = Direction == Direction.Left || Direction == Direction.Right; + actor.Opacity = 0.0; + if (isHorizontal) + { + actor.MotionTransform = BuildScaleXTransform(0.0); + } + else + { + actor.MotionTransform = BuildScaleYTransform(0.0); + } } } @@ -120,76 +80,10 @@ public class ExpandMotion : AbstractMotion { Direction = direction; } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var isHorizontal = Direction == Direction.Left || Direction == Direction.Right; - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - if (isHorizontal) - { - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(0.01) - }; - startFrame.Setters.Add(scaleXSetter); - } - else - { - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(0.01) - }; - startFrame.Setters.Add(scaleYSetter); - } - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - if (isHorizontal) - { - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(1.0) - }; - endFrame.Setters.Add(scaleXSetter); - } - else - { - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(1.0) - }; - endFrame.Setters.Add(scaleYSetter); - } - } - - animation.Children.Add(endFrame); - + base.ConfigureTransitions(); if (Direction == Direction.Left) { RenderTransformOrigin = new RelativePoint(1.0, 0.5, RelativeUnit.Relative); @@ -207,6 +101,33 @@ public class ExpandMotion : AbstractMotion RenderTransformOrigin = new RelativePoint(0.5, 1.0, RelativeUnit.Relative); } - Animations.Add(animation); + } + + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + var isHorizontal = Direction == Direction.Left || Direction == Direction.Right; + actor.Opacity = 0.0; + if (isHorizontal) + { + actor.MotionTransform = BuildScaleXTransform(0.0); + } + else + { + actor.MotionTransform = BuildScaleYTransform(0.0); + } + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + var isHorizontal = Direction == Direction.Left || Direction == Direction.Right; + actor.Opacity = 1.0; + if (isHorizontal) + { + actor.MotionTransform = BuildScaleXTransform(1.0); + } + else + { + actor.MotionTransform = BuildScaleYTransform(1.0); + } } } \ No newline at end of file diff --git a/src/AtomUI.Base/MotionScene/FadeMotions.cs b/src/AtomUI.Base/MotionScene/FadeMotions.cs index e2aeec769..a7b2a3e3e 100644 --- a/src/AtomUI.Base/MotionScene/FadeMotions.cs +++ b/src/AtomUI.Base/MotionScene/FadeMotions.cs @@ -13,40 +13,21 @@ public class FadeInMotion : AbstractMotion : base(duration, easing ?? new LinearEasing(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; } } @@ -58,39 +39,20 @@ public class FadeOutMotion : AbstractMotion : base(duration, easing ?? new LinearEasing(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; } } \ No newline at end of file diff --git a/src/AtomUI.Base/MotionScene/IMotion.cs b/src/AtomUI.Base/MotionScene/IMotion.cs index 863138965..2c5ec0566 100644 --- a/src/AtomUI.Base/MotionScene/IMotion.cs +++ b/src/AtomUI.Base/MotionScene/IMotion.cs @@ -1,4 +1,5 @@ -using Avalonia; +using AtomUI.Animations; +using Avalonia; using Avalonia.Animation; using Avalonia.Animation.Easings; @@ -8,6 +9,7 @@ internal interface IMotion { public RelativePoint RenderTransformOrigin { get; } public IList Animations { get; } + public IList Transitions { get; } public TimeSpan Duration { get; } public Easing Easing { get; } public FillMode PropertyValueFillMode { get; } diff --git a/src/AtomUI.Base/MotionScene/MotionActorControl.cs b/src/AtomUI.Base/MotionScene/MotionActorControl.cs index b3649a4c7..616fc255c 100644 --- a/src/AtomUI.Base/MotionScene/MotionActorControl.cs +++ b/src/AtomUI.Base/MotionScene/MotionActorControl.cs @@ -2,7 +2,6 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Media; -using Avalonia.Media.Transformation; namespace AtomUI.MotionScene; @@ -10,13 +9,13 @@ public class MotionActorControl : Decorator { #region 公共属性定义 - public static readonly StyledProperty MotionTransformProperty = - AvaloniaProperty.Register(nameof(MotionTransform)); + public static readonly StyledProperty MotionTransformProperty = + AvaloniaProperty.Register(nameof(MotionTransform)); public static readonly StyledProperty UseRenderTransformProperty = AvaloniaProperty.Register(nameof(UseRenderTransform)); - public TransformOperations? MotionTransform + public ITransform? MotionTransform { get => GetValue(MotionTransformProperty); set => SetValue(MotionTransformProperty, value); diff --git a/src/AtomUI.Base/MotionScene/MotionInvoker.cs b/src/AtomUI.Base/MotionScene/MotionInvoker.cs index 1e7871ccf..d9e85fc70 100644 --- a/src/AtomUI.Base/MotionScene/MotionInvoker.cs +++ b/src/AtomUI.Base/MotionScene/MotionInvoker.cs @@ -8,20 +8,15 @@ internal static class MotionInvoker public static void Invoke(MotionActorControl actor, AbstractMotion motion, Action? aboutToStart = null, - Action? completedAction = null, - CancellationToken cancellationToken = default) + Action? completedAction = null) { - Dispatcher.UIThread.Invoke(async () => - { - await motion.RunAsync(actor, aboutToStart, completedAction, cancellationToken); - }); + motion.RunTransitions(actor, aboutToStart, completedAction); } - public static void DispatchInMotionSceneLayer(SceneMotionActorControl actor, + public static void DispatchMotionInSceneLayer(SceneMotionActorControl actor, AbstractMotion motion, Action? aboutToStart = null, - Action? completedAction = null, - CancellationToken cancellationToken = default) + Action? completedAction = null) { var sceneLayer = PrepareSceneLayer(motion, actor); var compositeDisposable = new CompositeDisposable(); @@ -38,60 +33,11 @@ internal static class MotionInvoker actor.NotifySceneShowed(); aboutToStart?.Invoke(); // 等待一个事件循环,让动画窗口置顶 - Dispatcher.UIThread.Post(() => + motion.RunTransitions(actor, null, () => { - Dispatcher.UIThread.InvokeAsync(async () => - { - await motion.RunAsync(actor, () => - { - actor.IsVisible = true; - }, () => - { - completedAction?.Invoke(); - Dispatcher.UIThread.Post(() => actor.Opacity = 0d); - }, cancellationToken); - DispatcherTimer.RunOnce(() => - { - compositeDisposable.Dispose(); - compositeDisposable = null; - }, TimeSpan.FromMilliseconds(600)); - }); - }); - } - - public static void DispatchOutMotionSceneLayer(SceneMotionActorControl actor, - AbstractMotion motion, - Action? aboutToStart = null, - Action? completedAction = null, - CancellationToken cancellationToken = default) - { - var sceneLayer = PrepareSceneLayer(motion, actor); - var compositeDisposable = new CompositeDisposable(); - compositeDisposable.Add(Disposable.Create(sceneLayer, (state) => - { - sceneLayer.Hide(); - sceneLayer.Dispose(); - })); - sceneLayer.SetMotionActor(actor); - actor.NotifyMotionTargetAddedToScene(); - sceneLayer.Topmost = true; - sceneLayer.Show(); - actor.NotifySceneShowed(); - aboutToStart?.Invoke(); - // 等待一个事件循环,让动画窗口置顶 - Dispatcher.UIThread.Post(() => - { - Dispatcher.UIThread.InvokeAsync(async () => - { - // 主要等待正常窗体显示出来再隐藏对话层,不然感觉会闪屏 - await motion.RunAsync(actor, null, () => - { - completedAction?.Invoke(); - Dispatcher.UIThread.Post(() => actor.IsVisible = false); - }, cancellationToken); - compositeDisposable.Dispose(); - compositeDisposable = null; - }); + completedAction?.Invoke(); + compositeDisposable.Dispose(); + compositeDisposable = null; }); } diff --git a/src/AtomUI.Base/MotionScene/MoveMotions.cs b/src/AtomUI.Base/MotionScene/MoveMotions.cs index 74cee194f..5334278ee 100644 --- a/src/AtomUI.Base/MotionScene/MoveMotions.cs +++ b/src/AtomUI.Base/MotionScene/MoveMotions.cs @@ -17,75 +17,23 @@ public class MoveDownInMotion : AbstractMotion { Offset = offset; } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, Offset) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var middleFrame = new KeyFrame - { - Cue = new Cue(0.8) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - middleFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, Offset / 4) - }; - middleFrame.Setters.Add(transformSetter); - } - animation.Children.Add(middleFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, Offset); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0); } internal override Size CalculateSceneSize(Size actorSize) @@ -111,76 +59,23 @@ public class MoveDownOutMotion : AbstractMotion { Offset = offset; } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); + base.ConfigureTransitions(); + RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0) - }; + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0); + } - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var middleFrame = new KeyFrame - { - Cue = new Cue(0.8) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - middleFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, Offset / 4) - }; - middleFrame.Setters.Add(transformSetter); - } - animation.Children.Add(middleFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, Offset) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); - RenderTransformOrigin = new RelativePoint(0, 0, RelativeUnit.Relative); - - Animations.Add(animation); + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, Offset); } internal override Size CalculateSceneSize(Size actorSize) @@ -201,75 +96,23 @@ public class MoveUpInMotion : AbstractMotion { Offset = offset; } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 0.01, 0.0, -Offset) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var middleFrame = new KeyFrame - { - Cue = new Cue(0.8) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - middleFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, -Offset / 4) - }; - middleFrame.Setters.Add(transformSetter); - } - animation.Children.Add(middleFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 0.01, 0.0, -Offset); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0); } internal override Size CalculateSceneSize(Size actorSize) @@ -295,78 +138,23 @@ public class MoveUpOutMotion : AbstractMotion { Offset = offset; } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); + base.ConfigureTransitions(); + RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0) - }; + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0); + } - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var middleFrame = new KeyFrame - { - Cue = new Cue(0.8) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - middleFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, -Offset / 4) - }; - - middleFrame.Setters.Add(transformSetter); - } - animation.Children.Add(middleFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, -Offset) - }; - - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); - RenderTransformOrigin = new RelativePoint(0, 0, RelativeUnit.Relative); - - Animations.Add(animation); + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, -Offset); } internal override Size CalculateSceneSize(Size actorSize) @@ -387,78 +175,23 @@ public class MoveLeftInMotion : AbstractMotion { Offset = offset; } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, -Offset, 0.0) - }; - - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var middleFrame = new KeyFrame - { - Cue = new Cue(0.8) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - middleFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, -Offset / 2, 0.0) - }; - - middleFrame.Setters.Add(transformSetter); - } - animation.Children.Add(middleFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0) - }; - - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, -Offset, 0.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0); } internal override Size CalculateSceneSize(Size actorSize) @@ -485,75 +218,24 @@ public class MoveLeftOutMotion : AbstractMotion Offset = offset; } - protected override void Configure() + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var middleFrame = new KeyFrame - { - Cue = new Cue(0.8) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - middleFrame.Setters.Add(opacitySetter); - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, -Offset / 2, 0.0) - }; - middleFrame.Setters.Add(transformSetter); - } - animation.Children.Add(middleFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, -Offset, 0.0) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); - RenderTransformOrigin = new RelativePoint(0, 0, RelativeUnit.Relative); - - Animations.Add(animation); + base.ConfigureTransitions(); + RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); } + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, -Offset, 0.0); + } + internal override Size CalculateSceneSize(Size actorSize) { return actorSize.WithHeight(actorSize.Width * 2); @@ -572,76 +254,23 @@ public class MoveRightInMotion : AbstractMotion { Offset = offset; } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, Offset, 0.0) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var middleFrame = new KeyFrame - { - Cue = new Cue(0.8) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - middleFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, Offset / 2, 0.0) - }; - middleFrame.Setters.Add(transformSetter); - } - animation.Children.Add(middleFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, Offset, 0.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0); } internal override Size CalculateSceneSize(Size actorSize) @@ -667,75 +296,23 @@ public class MoveRightOutMotion : AbstractMotion { Offset = offset; } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); + base.ConfigureTransitions(); + RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, 0.0, 0.0); + } - var middleFrame = new KeyFrame - { - Cue = new Cue(0.8) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - middleFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, Offset / 2, 0.0) - }; - middleFrame.Setters.Add(transformSetter); - } - animation.Children.Add(middleFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildTranslateScaleAndTransform(1.0, 1.0, Offset, 0.0) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); - RenderTransformOrigin = new RelativePoint(0, 0, RelativeUnit.Relative); - - Animations.Add(animation); + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildTranslateScaleAndTransform(1.0, 1.0, Offset, 0.0); } internal override Size CalculateSceneSize(Size actorSize) diff --git a/src/AtomUI.Base/MotionScene/SlideMotions.cs b/src/AtomUI.Base/MotionScene/SlideMotions.cs index 5a3554358..b33535fbc 100644 --- a/src/AtomUI.Base/MotionScene/SlideMotions.cs +++ b/src/AtomUI.Base/MotionScene/SlideMotions.cs @@ -14,51 +14,22 @@ public class SlideUpInMotion : AbstractMotion { } - protected override void Configure() + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(0.01) // 不知道为啥设置成 0.0, 子元素渲染不正常 - }; - startFrame.Setters.Add(scaleYSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(1.0) - }; - endFrame.Setters.Add(scaleYSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleYTransform(0.8); // 不知道为啥设置成 0.0, 子元素渲染不正常; + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleYTransform(1.0); } } @@ -71,52 +42,22 @@ public class SlideUpOutMotion : AbstractMotion { } - protected override void Configure() + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(1.0) - }; - startFrame.Setters.Add(scaleYSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(0.0) - }; - endFrame.Setters.Add(scaleYSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleYTransform(1.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleYTransform(0.8); } } @@ -129,52 +70,22 @@ public class SlideDownInMotion : AbstractMotion { } - protected override void Configure() + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(0.01) - }; - startFrame.Setters.Add(scaleYSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(1.0) - }; - endFrame.Setters.Add(scaleYSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(1.0, 1.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleYTransform(0.8); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleYTransform(1.0); } } @@ -187,52 +98,22 @@ public class SlideDownOutMotion : AbstractMotion { } - protected override void Configure() + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(1.0) - }; - startFrame.Setters.Add(scaleYSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - var scaleYSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleYTransform(0.8) - }; - endFrame.Setters.Add(scaleYSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(1.0, 1.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleYTransform(1.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleYTransform(0.8); } } @@ -244,53 +125,23 @@ public class SlideLeftInMotion : AbstractMotion : base(duration, easing ?? new CubicEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(0.01) - }; - startFrame.Setters.Add(scaleXSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(1.0) - }; - endFrame.Setters.Add(scaleXSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleXTransform(0.8); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleXTransform(1.0); } } @@ -303,52 +154,22 @@ public class SlideLeftOutMotion : AbstractMotion { } - protected override void Configure() + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(1.0) - }; - startFrame.Setters.Add(scaleXSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(0.8) - }; - endFrame.Setters.Add(scaleXSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleXTransform(1.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleXTransform(0.8); } } @@ -361,52 +182,22 @@ public class SlideRightInMotion : AbstractMotion { } - protected override void Configure() + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(0.01) - }; - startFrame.Setters.Add(scaleXSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(1.0) - }; - endFrame.Setters.Add(scaleXSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(1.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleXTransform(0.8); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleXTransform(1.0); } } @@ -419,51 +210,21 @@ public class SlideRightOutMotion : AbstractMotion { } - protected override void Configure() + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(1.0) - }; - startFrame.Setters.Add(scaleXSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - var scaleXSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleXTransform(0.8) - }; - endFrame.Setters.Add(scaleXSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(1.0, 0.0, RelativeUnit.Relative); + } - Animations.Add(animation); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleXTransform(1.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleXTransform(0.8); } } diff --git a/src/AtomUI.Base/MotionScene/ZoomMotions.cs b/src/AtomUI.Base/MotionScene/ZoomMotions.cs index 541c53d97..66446fa6a 100644 --- a/src/AtomUI.Base/MotionScene/ZoomMotions.cs +++ b/src/AtomUI.Base/MotionScene/ZoomMotions.cs @@ -13,54 +13,23 @@ internal class ZoomInMotion : AbstractMotion : base(duration, easing ?? new CircularEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.01) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); - Animations.Add(animation); + } + + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.2); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); } } @@ -72,54 +41,23 @@ public class ZoomOutMotion : AbstractMotion : base(duration, easing ?? new CircularEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.01) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); - Animations.Add(animation); + } + + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.2); } } @@ -132,53 +70,22 @@ public class ZoomBigInMotion : AbstractMotion { } - protected override void Configure() + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); + base.ConfigureTransitions(); + RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.85); + } - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.85) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); - RenderTransformOrigin = new RelativePoint(1.0, 1.0, RelativeUnit.Relative); - Animations.Add(animation); + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); } } @@ -190,54 +97,23 @@ public class ZoomBigOutMotion : AbstractMotion : base(duration, easing ?? new CircularEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); + base.ConfigureTransitions(); + RenderTransformOrigin = new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + } - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); + } - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.85) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); - RenderTransformOrigin = new RelativePoint(1.0, 1.0, RelativeUnit.Relative); - Animations.Add(animation); + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.85); } } @@ -249,54 +125,23 @@ public class ZoomUpInMotion : AbstractMotion : base(duration, easing ?? new CircularEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.01) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.5, 0.0, RelativeUnit.Relative); - Animations.Add(animation); + } + + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.8); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); } } @@ -308,54 +153,23 @@ public class ZoomUpOutMotion : AbstractMotion : base(duration, easing ?? new CircularEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.01) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.5, 0.0, RelativeUnit.Relative); - Animations.Add(animation); + } + + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.8); } } @@ -367,54 +181,23 @@ public class ZoomLeftInMotion : AbstractMotion : base(duration, easing ?? new CircularEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.01) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.5, RelativeUnit.Relative); - Animations.Add(animation); + } + + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.8); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); } } @@ -426,54 +209,23 @@ public class ZoomLeftOutMotion : AbstractMotion : base(duration, easing ?? new CircularEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.01) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.0, 0.5, RelativeUnit.Relative); - Animations.Add(animation); + } + + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.8); } } @@ -485,54 +237,23 @@ public class ZoomRightInMotion : AbstractMotion : base(duration, easing ?? new CircularEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.01) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(1.0, 0.5, RelativeUnit.Relative); - Animations.Add(animation); + } + + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.8); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); } } @@ -544,54 +265,23 @@ public class ZoomRightOutMotion : AbstractMotion : base(duration, easing ?? new CircularEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.01) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(1.0, 0.5, RelativeUnit.Relative); - Animations.Add(animation); + } + + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.8); } } @@ -603,54 +293,23 @@ public class ZoomDownInMotion : AbstractMotion : base(duration, easing ?? new CircularEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.1 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.01) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.5, 1.0, RelativeUnit.Relative); - Animations.Add(animation); + } + + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.8); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); } } @@ -662,53 +321,22 @@ public class ZoomDownOutMotion : AbstractMotion : base(duration, easing ?? new CircularEaseOut(), fillMode) { } - - protected override void Configure() + + protected override void ConfigureTransitions() { - var animation = CreateAnimation(); - - var startFrame = new KeyFrame - { - Cue = new Cue(0.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 1.0 - }; - startFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(1.0) - }; - startFrame.Setters.Add(transformSetter); - } - animation.Children.Add(startFrame); - - var endFrame = new KeyFrame - { - Cue = new Cue(1.0) - }; - { - var opacitySetter = new Setter - { - Property = Visual.OpacityProperty, - Value = 0.0 - }; - endFrame.Setters.Add(opacitySetter); - - var transformSetter = new Setter - { - Property = MotionActorControl.MotionTransformProperty, - Value = BuildScaleTransform(0.01) - }; - endFrame.Setters.Add(transformSetter); - } - animation.Children.Add(endFrame); + base.ConfigureTransitions(); RenderTransformOrigin = new RelativePoint(0.5, 1.0, RelativeUnit.Relative); - Animations.Add(animation); + } + + protected override void ConfigureMotionStartValue(MotionActorControl actor) + { + actor.Opacity = 1.0; + actor.MotionTransform = BuildScaleTransform(1.0); + } + + protected override void ConfigureMotionEndValue(MotionActorControl actor) + { + actor.Opacity = 0.0; + actor.MotionTransform = BuildScaleTransform(0.8); } } \ No newline at end of file diff --git a/src/AtomUI.Controls/Badge/CountBadgeAdorner.cs b/src/AtomUI.Controls/Badge/CountBadgeAdorner.cs index 1a2a650cf..e6472ab65 100644 --- a/src/AtomUI.Controls/Badge/CountBadgeAdorner.cs +++ b/src/AtomUI.Controls/Badge/CountBadgeAdorner.cs @@ -249,8 +249,7 @@ internal class CountBadgeAdorner : TemplatedControl { _indicatorMotionActor.IsVisible = false; var motion = new BadgeZoomBadgeInMotion(MotionDuration); - MotionInvoker.Invoke(_indicatorMotionActor, motion, () => { _indicatorMotionActor.IsVisible = true; }, null, - _motionCancellationTokenSource!.Token); + MotionInvoker.Invoke(_indicatorMotionActor, motion, () => { _indicatorMotionActor.IsVisible = true; }); } } @@ -262,8 +261,7 @@ internal class CountBadgeAdorner : TemplatedControl _motionCancellationTokenSource?.Cancel(); _motionCancellationTokenSource = new CancellationTokenSource(); - MotionInvoker.Invoke(_indicatorMotionActor, motion, null, () => completedAction(), - _motionCancellationTokenSource.Token); + MotionInvoker.Invoke(_indicatorMotionActor, motion, null, () => completedAction()); } else { diff --git a/src/AtomUI.Controls/Badge/DotBadgeAdorner.cs b/src/AtomUI.Controls/Badge/DotBadgeAdorner.cs index bc6cbc960..bb8e10065 100644 --- a/src/AtomUI.Controls/Badge/DotBadgeAdorner.cs +++ b/src/AtomUI.Controls/Badge/DotBadgeAdorner.cs @@ -122,8 +122,7 @@ internal class DotBadgeAdorner : TemplatedControl _motionCancellationTokenSource?.Cancel(); _motionCancellationTokenSource = new CancellationTokenSource(); var motion = new BadgeZoomBadgeInMotion(MotionDuration, null, FillMode.Forward); - MotionInvoker.Invoke(_indicatorMotionActor, motion, () => _indicatorMotionActor.IsVisible = true, - null, _motionCancellationTokenSource.Token); + MotionInvoker.Invoke(_indicatorMotionActor, motion, () => _indicatorMotionActor.IsVisible = true); } } @@ -134,8 +133,7 @@ internal class DotBadgeAdorner : TemplatedControl _motionCancellationTokenSource?.Cancel(); _motionCancellationTokenSource = new CancellationTokenSource(); var motion = new BadgeZoomBadgeOutMotion(MotionDuration, null, FillMode.Forward); - MotionInvoker.Invoke(_indicatorMotionActor, motion, null, () => completedAction(), - _motionCancellationTokenSource.Token); + MotionInvoker.Invoke(_indicatorMotionActor, motion, null, () => completedAction()); } } diff --git a/src/AtomUI.Controls/Popup/IPopupBuddyLayer.cs b/src/AtomUI.Controls/Popup/IPopupBuddyLayer.cs index c6334299e..2d717fb37 100644 --- a/src/AtomUI.Controls/Popup/IPopupBuddyLayer.cs +++ b/src/AtomUI.Controls/Popup/IPopupBuddyLayer.cs @@ -5,9 +5,7 @@ internal interface IPopupBuddyLayer void Attach(); void Detach(); void AttachWithMotion(Action? aboutToStart = null, - Action? completedAction = null, - CancellationToken cancellationToken = default); + Action? completedAction = null); void DetachWithMotion(Action? aboutToStart = null, - Action? completedAction = null, - CancellationToken cancellationToken = default); + Action? completedAction = null); } \ No newline at end of file diff --git a/src/AtomUI.Controls/Popup/Popup.cs b/src/AtomUI.Controls/Popup/Popup.cs index b9e430d78..408e3899d 100644 --- a/src/AtomUI.Controls/Popup/Popup.cs +++ b/src/AtomUI.Controls/Popup/Popup.cs @@ -144,7 +144,7 @@ public class Popup : AvaloniaPopup, this.AddResourceBindingDisposable( TokenResourceBinder.CreateTokenBinding(this, MaskShadowsProperty, SharedTokenKey.BoxShadowsSecondary)); this.AddResourceBindingDisposable(TokenResourceBinder.CreateTokenBinding(this, MotionDurationProperty, - SharedTokenKey.MotionDurationFast)); + SharedTokenKey.MotionDurationMid)); CreateBuddyLayer(); } diff --git a/src/AtomUI.Controls/Popup/PopupBuddyLayer.cs b/src/AtomUI.Controls/Popup/PopupBuddyLayer.cs index 7ed5932dd..11a1051bf 100644 --- a/src/AtomUI.Controls/Popup/PopupBuddyLayer.cs +++ b/src/AtomUI.Controls/Popup/PopupBuddyLayer.cs @@ -129,8 +129,7 @@ internal class PopupBuddyLayer : SceneLayer, IPopupBuddyLayer, IShadowAwareLayer } public void AttachWithMotion(Action? aboutToStart = null, - Action? completedAction = null, - CancellationToken cancellationToken = default) + Action? completedAction = null) { Show(); @@ -138,38 +137,25 @@ internal class PopupBuddyLayer : SceneLayer, IPopupBuddyLayer, IShadowAwareLayer aboutToStart?.Invoke(); var motion = new ZoomBigInMotion(MotionDuration); NotifyAboutToRunAttachMotion(); - Dispatcher.UIThread.Post(() => + motion.RunTransitions(_buddyDecorator, null, () => { - Dispatcher.UIThread.InvokeAsync(async () => - { - await motion.RunAsync(_buddyDecorator, null, () => - { - completedAction?.Invoke(); - NotifyAttachMotionCompleted(); - }, cancellationToken); - }); + completedAction?.Invoke(); + NotifyAttachMotionCompleted(); }); } public void DetachWithMotion(Action? aboutToStart = null, - Action? completedAction = null, - CancellationToken cancellationToken = default) + Action? completedAction = null) { aboutToStart?.Invoke(); var motion = new ZoomBigOutMotion(MotionDuration); NotifyAboutToRunDetachMotion(); - Dispatcher.UIThread.Post(() => + motion.RunTransitions(_buddyDecorator, null, () => { - Dispatcher.UIThread.InvokeAsync(async () => - { - await motion.RunAsync(_buddyDecorator, null, () => - { - Hide(); - completedAction?.Invoke(); - NotifyDetachMotionCompleted(); - }, cancellationToken); - }); + Hide(); + completedAction?.Invoke(); + NotifyDetachMotionCompleted(); }); } diff --git a/src/AtomUI.Controls/Popup/PopupMotionActor.cs b/src/AtomUI.Controls/Popup/PopupMotionActor.cs deleted file mode 100644 index e52ef0d4a..000000000 --- a/src/AtomUI.Controls/Popup/PopupMotionActor.cs +++ /dev/null @@ -1,21 +0,0 @@ -using AtomUI.Controls.Primitives; -using AtomUI.MotionScene; -using Avalonia; - -namespace AtomUI.Controls; - -internal class PopupMotionActor : SceneMotionActorControl -{ - private readonly Point _offset; - - public PopupMotionActor(Point offset, MotionGhostControl motionGhost) - : base(motionGhost) - { - _offset = offset; - } - - protected override Point CalculateTopLevelGhostPosition() - { - return _offset; - } -} \ No newline at end of file