Core - Added ways for the core to easily access brush properties

%*/@ me, dealing with generic types in APIs is tricky
This commit is contained in:
Robert committed 2020-04-29 12:49:11 +02:00
1 parent 492ee5c8c1
commit bbeb471754
7 files changed
+145 -41

No files matched your search

@@ -1,13 +1,46 @@
using Artemis.Storage.Entities.Profile;
using System;
using System.Collections.Generic;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Models.Profile.LayerProperties
{
/// <summary>
/// For internal use only, to implement your own layer property type, extend <see cref="LayerProperty{T}"/> instead.
/// </summary>
public abstract class BaseLayerProperty
{
/// <summary>
/// Used to declare that this property doesn't belong to a plugin and should use the core plugin GUID
/// </summary>
internal bool IsCoreProperty { get; set; }
internal PropertyEntity PropertyEntity { get; set; }
internal LayerPropertyGroup LayerPropertyGroup { get; set; }
/// <summary>
/// Gets whether keyframes are supported on this property
/// </summary>
public bool KeyframesSupported { get; protected set; }
/// <summary>
/// Gets or sets whether keyframes are enabled on this property, has no effect if <see cref="KeyframesSupported" /> is
/// False
/// </summary>
public bool KeyframesEnabled { get; set; }
/// <summary>
/// Gets or sets whether the property is hidden in the UI
/// </summary>
public bool IsHidden { get; set; }
/// <summary>
/// Indicates whether the BaseValue was loaded from storage, useful to check whether a default value must be applied
/// </summary>
public bool IsLoadedFromStorage { get; internal set; }
/// <summary>
/// Gets the total progress on the timeline
/// </summary>
public TimeSpan TimelineProgress { get; internal set; }
/// <summary>
/// Applies the provided property entity to the layer property by deserializing the JSON base value and keyframe values
@@ -21,5 +54,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// <see cref="ApplyToLayerProperty" />
/// </summary>
internal abstract void ApplyToEntity();
internal abstract List<TimeSpan> GetKeyframePositions();
internal abstract TimeSpan GetLastKeyframePosition();
}
}
@@ -53,38 +53,12 @@ namespace Artemis.Core.Models.Profile.LayerProperties
get => !KeyframesEnabled || !KeyframesSupported ? BaseValue : _currentValue;
internal set => _currentValue = value;
}
/// <summary>
/// Gets whether keyframes are supported on this property
/// </summary>
public bool KeyframesSupported { get; internal set; }
/// <summary>
/// Gets or sets whether keyframes are enabled on this property, has no effect if <see cref="KeyframesSupported" /> is
/// False
/// </summary>
public bool KeyframesEnabled { get; set; }
/// <summary>
/// Gets or sets whether the property is hidden in the UI
/// </summary>
public bool IsHidden { get; set; }
/// <summary>
/// Indicates whether the BaseValue was loaded from storage, useful to check whether a default value must be applied
/// </summary>
public bool IsLoadedFromStorage { get; internal set; }
/// <summary>
/// Gets a read-only list of all the keyframes on this layer property
/// </summary>
public IReadOnlyList<LayerPropertyKeyframe<T>> Keyframes => _keyframes.AsReadOnly();
/// <summary>
/// Gets the total progress on the timeline
/// </summary>
public TimeSpan TimelineProgress { get; private set; }
/// <summary>
/// Gets the current keyframe in the timeline according to the current progress
/// </summary>
@@ -94,10 +68,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// Gets the next keyframe in the timeline according to the current progress
/// </summary>
public LayerPropertyKeyframe<T> NextKeyframe { get; protected set; }
internal PropertyEntity PropertyEntity { get; set; }
internal LayerPropertyGroup LayerPropertyGroup { get; set; }
/// <summary>
/// Adds a keyframe to the layer property
/// </summary>
@@ -232,6 +203,16 @@ namespace Artemis.Core.Models.Profile.LayerProperties
}));
}
internal override List<TimeSpan> GetKeyframePositions()
{
return Keyframes.Select(k => k.Position).ToList();
}
internal override TimeSpan GetLastKeyframePosition()
{
return Keyframes.LastOrDefault()?.Position ?? TimeSpan.Zero;
}
#region Events
public event EventHandler Updated;
@@ -1,9 +1,10 @@
using Artemis.Core.Exceptions;
using System;
using Artemis.Core.Exceptions;
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
public class EnumLayerProperty<T> : LayerProperty<T> where T : System.Enum
/// <inheritdoc />
public class EnumLayerProperty<T> : LayerProperty<T> where T : Enum
{
public EnumLayerProperty()
{