diff --git a/src/Avalonia.Animation/Animation.cs b/src/Avalonia.Animation/Animation.cs index 4301e8b3c0..98c4961681 100644 --- a/src/Avalonia.Animation/Animation.cs +++ b/src/Avalonia.Animation/Animation.cs @@ -7,6 +7,7 @@ using Avalonia.Collections; using Avalonia.Metadata; using System; using System.Collections.Generic; +using System.Collections.Specialized; namespace Avalonia.Animation { @@ -16,6 +17,7 @@ namespace Avalonia.Animation public class Animation : IDisposable, IAnimation { private List _subscription = new List(); + public AvaloniaList _animators { get; set; } = new AvaloniaList(); /// /// Run time of this animation. @@ -53,17 +55,30 @@ namespace Avalonia.Animation public Easing Easing { get; set; } = new LinearEasing(); /// - /// A list of objects. + /// A list of objects. /// [Content] - public AvaloniaList Children { get; set; } = new AvaloniaList(); + public AvaloniaList Children { get; set; } = new AvaloniaList(); + + public Animation() + { + InterpretKeyframes(); + } + + private void InterpretKeyframes() + { + foreach (var keyframe in Children) + { + + } + } /// /// Cancels the animation. /// public void Dispose() { - foreach (var sub in _subscription) + foreach (var sub in _subscription) { sub.Dispose(); } @@ -72,12 +87,11 @@ namespace Avalonia.Animation /// public IDisposable Apply(Animatable control, IObservable matchObs) { - foreach (IKeyFrames keyframes in Children) + foreach (IAnimator keyframes in _animators) { _subscription.Add(keyframes.Apply(this, control, matchObs)); } return this; } - } } diff --git a/src/Avalonia.Animation/AnimationSetter.cs b/src/Avalonia.Animation/AnimationSetter.cs new file mode 100644 index 0000000000..bd6d395c20 --- /dev/null +++ b/src/Avalonia.Animation/AnimationSetter.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Linq; +using System.Reactive.Linq; +using System.Diagnostics; +using Avalonia.Animation.Utils; +using Avalonia.Data; + +namespace Avalonia.Animation +{ + public abstract class Setter : IAnimationSetter + { + public AvaloniaProperty Property { get; set; } + public object Value { get; set; } + } +} diff --git a/src/Avalonia.Animation/AnimatorAttribute.cs b/src/Avalonia.Animation/AnimatorAttribute.cs new file mode 100644 index 0000000000..41fa78ec53 --- /dev/null +++ b/src/Avalonia.Animation/AnimatorAttribute.cs @@ -0,0 +1,14 @@ +using System; + +namespace Avalonia.Animation +{ + public class AnimatorAttribute : Attribute + { + public Type HandlerType; + + public AnimatorAttribute(Type handler) + { + this.HandlerType = handler; + } + } +} \ No newline at end of file diff --git a/src/Avalonia.Animation/KeyFramesStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs similarity index 97% rename from src/Avalonia.Animation/KeyFramesStateMachine`1.cs rename to src/Avalonia.Animation/AnimatorStateMachine`1.cs index d9fcff086c..360940f8e7 100644 --- a/src/Avalonia.Animation/KeyFramesStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -5,9 +5,9 @@ using Avalonia.Data; namespace Avalonia.Animation { /// - /// Provides statefulness for an iteration of a keyframe group animation. + /// Provides statefulness for an iteration of a keyframe animation. /// - internal class KeyFramesStateMachine : IObservable, IDisposable + internal class AnimatorStateMachine : IObservable, IDisposable { object _lastInterpValue; object _firstKFValue; @@ -29,7 +29,7 @@ namespace Avalonia.Animation private PlaybackDirection _animationDirection; private KeyFramesStates _currentState; private KeyFramesStates _savedState; - private KeyFrames _parent; + private Animator _parent; private Animation _targetAnimation; private Animatable _targetControl; private T _neutralValue; @@ -51,7 +51,7 @@ namespace Avalonia.Animation Disposed } - public void Initialize(Animation animation, Animatable control, KeyFrames keyframes) + public void Initialize(Animation animation, Animatable control, Animator keyframes) { _parent = keyframes; _targetAnimation = animation; diff --git a/src/Avalonia.Animation/KeyFrames`1.cs b/src/Avalonia.Animation/Animator`1.cs similarity index 97% rename from src/Avalonia.Animation/KeyFrames`1.cs rename to src/Avalonia.Animation/Animator`1.cs index e67462403d..83e32c7739 100644 --- a/src/Avalonia.Animation/KeyFrames`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -14,7 +14,7 @@ namespace Avalonia.Animation /// /// Base class for KeyFrames objects /// - public abstract class KeyFrames : AvaloniaList, IKeyFrames + public abstract class Animator : AvaloniaList, IAnimator { /// /// List of type-converted keyframes. @@ -92,7 +92,7 @@ namespace Avalonia.Animation /// private IDisposable RunKeyFrames(Animation animation, Animatable control) { - var _kfStateMach = new KeyFramesStateMachine(); + var _kfStateMach = new AnimatorStateMachine(); _kfStateMach.Initialize(animation, control, this); Timing.AnimationStateTimer diff --git a/src/Avalonia.Animation/DoubleKeyFrames.cs b/src/Avalonia.Animation/DoubleAnimator.cs similarity index 89% rename from src/Avalonia.Animation/DoubleKeyFrames.cs rename to src/Avalonia.Animation/DoubleAnimator.cs index 1a45ca403d..5b994377f1 100644 --- a/src/Avalonia.Animation/DoubleKeyFrames.cs +++ b/src/Avalonia.Animation/DoubleAnimator.cs @@ -10,9 +10,9 @@ using Avalonia.Data; namespace Avalonia.Animation { /// - /// Key frames that handles properties. + /// Animator that handles properties. /// - public class DoubleKeyFrames : KeyFrames + public class DoubleAnimator : Animator { /// diff --git a/src/Avalonia.Animation/DoubleSetter.cs b/src/Avalonia.Animation/DoubleSetter.cs new file mode 100644 index 0000000000..cf5c685f82 --- /dev/null +++ b/src/Avalonia.Animation/DoubleSetter.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Linq; +using System.Reactive.Linq; +using System.Diagnostics; +using Avalonia.Animation.Utils; +using Avalonia.Data; + +namespace Avalonia.Animation +{ + [Animator(typeof(DoubleAnimator))] + public class DoubleSetter : Setter + { + + } +} diff --git a/src/Avalonia.Animation/IAnimationSetter.cs b/src/Avalonia.Animation/IAnimationSetter.cs new file mode 100644 index 0000000000..28f6f911c4 --- /dev/null +++ b/src/Avalonia.Animation/IAnimationSetter.cs @@ -0,0 +1,9 @@ +namespace Avalonia.Animation +{ + public interface IAnimationSetter + { + AvaloniaProperty Property { get; set; } + object Value { get; set; } + + } +} \ No newline at end of file diff --git a/src/Avalonia.Animation/IKeyFrames.cs b/src/Avalonia.Animation/IAnimator.cs similarity index 92% rename from src/Avalonia.Animation/IKeyFrames.cs rename to src/Avalonia.Animation/IAnimator.cs index d570f95b8b..060236bb65 100644 --- a/src/Avalonia.Animation/IKeyFrames.cs +++ b/src/Avalonia.Animation/IAnimator.cs @@ -7,7 +7,7 @@ namespace Avalonia.Animation /// /// Interface for Keyframe group object /// - public interface IKeyFrames + public interface IAnimator { /// /// Applies the current KeyFrame group to the specified control. diff --git a/src/Avalonia.Animation/KeyFrame.cs b/src/Avalonia.Animation/KeyFrame.cs index d38d533715..07af6b406c 100644 --- a/src/Avalonia.Animation/KeyFrame.cs +++ b/src/Avalonia.Animation/KeyFrame.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Text; using System.ComponentModel; +using Avalonia.Metadata; +using Avalonia.Collections; namespace Avalonia.Animation { @@ -63,5 +65,8 @@ namespace Avalonia.Animation /// public object Value { get; set; } + [Content] + public AvaloniaList Children { get; set; } = new AvaloniaList(); + } } diff --git a/src/Avalonia.Animation/KeyFramePair`1.cs b/src/Avalonia.Animation/KeyFramePair`1.cs index ecb5f33857..c192479a1d 100644 --- a/src/Avalonia.Animation/KeyFramePair`1.cs +++ b/src/Avalonia.Animation/KeyFramePair`1.cs @@ -13,7 +13,7 @@ namespace Avalonia.Animation { /// /// Represents a pair of keyframe, usually the - /// Start and End keyframes of a object. + /// Start and End keyframes of a object. /// public struct KeyFramePair { diff --git a/src/Avalonia.Visuals/Animation/TransformKeyFrames.cs b/src/Avalonia.Visuals/Animation/TransformAnimator.cs similarity index 93% rename from src/Avalonia.Visuals/Animation/TransformKeyFrames.cs rename to src/Avalonia.Visuals/Animation/TransformAnimator.cs index dc803f0900..9f2138225f 100644 --- a/src/Avalonia.Visuals/Animation/TransformKeyFrames.cs +++ b/src/Avalonia.Visuals/Animation/TransformAnimator.cs @@ -12,11 +12,11 @@ using Avalonia.Logging; namespace Avalonia.Animation { /// - /// Keyframes that handles properties. + /// Animator that handles properties. /// - public class TransformKeyFrames : KeyFrames + public class TransformAnimator : Animator { - DoubleKeyFrames childKeyFrames; + DoubleAnimator childKeyFrames; /// public override IDisposable Apply(Animation animation, Animatable control, IObservable obsMatch) @@ -82,7 +82,7 @@ namespace Avalonia.Animation void InitializeChildKeyFrames() { - childKeyFrames = new DoubleKeyFrames(); + childKeyFrames = new DoubleAnimator(); foreach (KeyFrame keyframe in this) {