Timeline - Implemented segments

This commit is contained in:
Robert committed 2022-01-25 00:23:26 +01:00
1 parent 913117ad0a
commit 642823add5
35 files changed
+1569 -579

No files matched your search

@@ -18,7 +18,7 @@ namespace Artemis.Core
/// Gets the description attribute applied to this property
/// </summary>
PropertyDescriptionAttribute PropertyDescription { get; }
/// <summary>
/// Gets the profile element (such as layer or folder) this property is applied to
/// </summary>
@@ -68,7 +68,7 @@ namespace Artemis.Core
/// Indicates whether the BaseValue was loaded from storage, useful to check whether a default value must be applied
/// </summary>
bool IsLoadedFromStorage { get; }
/// <summary>
/// Initializes the layer property
/// <para>
@@ -102,6 +102,20 @@ namespace Artemis.Core
/// </summary>
void UpdateDataBinding();
/// <summary>
/// Removes a keyframe from the layer property without knowing it's type.
/// <para>Prefer <see cref="LayerProperty{T}.RemoveKeyframe"/>.</para>
/// </summary>
/// <param name="keyframe"></param>
void RemoveUntypedKeyframe(ILayerPropertyKeyframe keyframe);
/// <summary>
/// Adds a keyframe to the layer property without knowing it's type.
/// <para>Prefer <see cref="LayerProperty{T}.AddKeyframe"/>.</para>
/// </summary>
/// <param name="keyframe"></param>
void AddUntypedKeyframe(ILayerPropertyKeyframe keyframe);
/// <summary>
/// Occurs when the layer property is disposed
/// </summary>
@@ -96,6 +96,24 @@ namespace Artemis.Core
OnUpdated();
}
/// <inheritdoc />
public void RemoveUntypedKeyframe(ILayerPropertyKeyframe keyframe)
{
if (keyframe is not LayerPropertyKeyframe<T> typedKeyframe)
throw new ArtemisCoreException($"Can't remove a keyframe that is not of type {typeof(T).FullName}.");
RemoveKeyframe(typedKeyframe);
}
/// <inheritdoc />
public void AddUntypedKeyframe(ILayerPropertyKeyframe keyframe)
{
if (keyframe is not LayerPropertyKeyframe<T> typedKeyframe)
throw new ArtemisCoreException($"Can't add a keyframe that is not of type {typeof(T).FullName}.");
AddKeyframe(typedKeyframe);
}
/// <inheritdoc />
public void Dispose()
{
@@ -177,22 +195,25 @@ namespace Artemis.Core
/// An optional time to set the value add, if provided and property is using keyframes the value will be set to an new
/// or existing keyframe.
/// </param>
public void SetCurrentValue(T value, TimeSpan? time)
/// <returns>The new keyframe if one was created.</returns>
public LayerPropertyKeyframe<T>? SetCurrentValue(T value, TimeSpan? time)
{
if (_disposed)
throw new ObjectDisposedException("LayerProperty");
LayerPropertyKeyframe<T>? newKeyframe = null;
if (time == null || !KeyframesEnabled || !KeyframesSupported)
{
BaseValue = value;
}
else
{
// If on a keyframe, update the keyframe
LayerPropertyKeyframe<T>? currentKeyframe = Keyframes.FirstOrDefault(k => k.Position == time.Value);
// Create a new keyframe if none found
if (currentKeyframe == null)
AddKeyframe(new LayerPropertyKeyframe<T>(value, time.Value, Easings.Functions.Linear, this));
{
newKeyframe = new LayerPropertyKeyframe<T>(value, time.Value, Easings.Functions.Linear, this);
AddKeyframe(newKeyframe);
}
else
currentKeyframe.Value = value;
}
@@ -200,6 +221,7 @@ namespace Artemis.Core
// Force an update so that the base value is applied to the current value and
// keyframes/data bindings are applied using the new base value
ReapplyUpdate();
return newKeyframe;
}
/// <inheritdoc />
@@ -247,6 +269,7 @@ namespace Artemis.Core
{
if (_keyframesEnabled == value) return;
_keyframesEnabled = value;
ReapplyUpdate();
OnKeyframesToggled();
OnPropertyChanged(nameof(KeyframesEnabled));
}