Browse Source

More cleanup.

pull/1768/head
Jeremy Koritzinsky 8 years ago
parent
commit
c2e2d8b49c
  1. 3
      src/Avalonia.Animation/Animation.cs
  2. 2
      src/Avalonia.Animation/AnimatorKeyFrame.cs
  3. 3
      src/Avalonia.Animation/AnimatorStateMachine`1.cs
  4. 4
      src/Avalonia.Animation/Animator`1.cs
  5. 2
      src/Avalonia.Animation/Cue.cs
  6. 16
      src/Avalonia.Animation/KeyFrame.cs

3
src/Avalonia.Animation/Animation.cs

@ -105,8 +105,7 @@ namespace Avalonia.Animation
Property = setter.Property, Property = setter.Property,
Cue = keyframe.Cue, Cue = keyframe.Cue,
KeyTime = keyframe.KeyTime, KeyTime = keyframe.KeyTime,
timeSpanSet = keyframe.timeSpanSet, TimingMode = keyframe.TimingMode,
cueSet = keyframe.cueSet,
Value = setter.Value Value = setter.Value
}; };

2
src/Avalonia.Animation/AnimatorKeyFrame.cs

@ -16,7 +16,7 @@ namespace Avalonia.Animation
public Type Handler; public Type Handler;
public Cue Cue; public Cue Cue;
public TimeSpan KeyTime; public TimeSpan KeyTime;
internal bool timeSpanSet, cueSet; internal KeyFrameTimingMode TimingMode;
public AvaloniaProperty Property; public AvaloniaProperty Property;
public object Value; public object Value;
} }

3
src/Avalonia.Animation/AnimatorStateMachine`1.cs

@ -246,6 +246,9 @@ namespace Avalonia.Animation
_targetObserver.OnCompleted(); _targetObserver.OnCompleted();
handled = true; handled = true;
break; break;
default:
handled = true;
break;
} }
} }
} }

4
src/Avalonia.Animation/Animator`1.cs

@ -19,7 +19,7 @@ namespace Avalonia.Animation
/// <summary> /// <summary>
/// List of type-converted keyframes. /// List of type-converted keyframes.
/// </summary> /// </summary>
private readonly IDictionary<double, (T, bool isNeutral)> _convertedKeyframes = new SortedDictionary<double, (T, bool)>(); private readonly SortedList<double, (T, bool isNeutral)> _convertedKeyframes = new SortedList<double, (T, bool)>();
private bool _isVerfifiedAndConverted; private bool _isVerfifiedAndConverted;
@ -134,7 +134,7 @@ namespace Avalonia.Animation
Cue _normalizedCue = k.Cue; Cue _normalizedCue = k.Cue;
if (k.timeSpanSet) if (k.TimingMode == KeyFrameTimingMode.TimeSpan)
{ {
_normalizedCue = new Cue(k.KeyTime.Ticks / animation.Duration.Ticks); _normalizedCue = new Cue(k.KeyTime.Ticks / animation.Duration.Ticks);
} }

2
src/Avalonia.Animation/Cue.cs

@ -10,7 +10,7 @@ namespace Avalonia.Animation
/// A Cue object for <see cref="KeyFrame"/>. /// A Cue object for <see cref="KeyFrame"/>.
/// </summary> /// </summary>
[TypeConverter(typeof(CueTypeConverter))] [TypeConverter(typeof(CueTypeConverter))]
public struct Cue : IEquatable<Cue>, IEquatable<double> public readonly struct Cue : IEquatable<Cue>, IEquatable<double>
{ {
/// <summary> /// <summary>
/// The normalized percent value, ranging from 0.0 to 1.0 /// The normalized percent value, ranging from 0.0 to 1.0

16
src/Avalonia.Animation/KeyFrame.cs

@ -7,6 +7,11 @@ using Avalonia.Collections;
namespace Avalonia.Animation namespace Avalonia.Animation
{ {
internal enum KeyFrameTimingMode
{
TimeSpan = 1,
Cue
}
/// <summary> /// <summary>
/// Stores data regarding a specific key /// Stores data regarding a specific key
@ -14,7 +19,6 @@ namespace Avalonia.Animation
/// </summary> /// </summary>
public class KeyFrame : AvaloniaList<IAnimationSetter> public class KeyFrame : AvaloniaList<IAnimationSetter>
{ {
internal bool timeSpanSet, cueSet;
private TimeSpan _ktimeSpan; private TimeSpan _ktimeSpan;
private Cue _kCue; private Cue _kCue;
@ -30,6 +34,8 @@ namespace Avalonia.Animation
{ {
} }
internal KeyFrameTimingMode TimingMode { get; private set; }
/// <summary> /// <summary>
/// Gets or sets the key time of this <see cref="KeyFrame"/>. /// Gets or sets the key time of this <see cref="KeyFrame"/>.
/// </summary> /// </summary>
@ -42,11 +48,11 @@ namespace Avalonia.Animation
} }
set set
{ {
if (cueSet) if (TimingMode == KeyFrameTimingMode.Cue)
{ {
throw new InvalidOperationException($"You can only set either {nameof(KeyTime)} or {nameof(Cue)}."); throw new InvalidOperationException($"You can only set either {nameof(KeyTime)} or {nameof(Cue)}.");
} }
timeSpanSet = true; TimingMode = KeyFrameTimingMode.TimeSpan;
_ktimeSpan = value; _ktimeSpan = value;
} }
} }
@ -63,11 +69,11 @@ namespace Avalonia.Animation
} }
set set
{ {
if (timeSpanSet) if (TimingMode == KeyFrameTimingMode.TimeSpan)
{ {
throw new InvalidOperationException($"You can only set either {nameof(KeyTime)} or {nameof(Cue)}."); throw new InvalidOperationException($"You can only set either {nameof(KeyTime)} or {nameof(Cue)}.");
} }
cueSet = true; TimingMode = KeyFrameTimingMode.Cue;
_kCue = value; _kCue = value;
} }
} }

Loading…
Cancel
Save