mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Keyframes - Copy/paste WIP
Timeline - Improved sizing, avoid unnecessary scrolling Timeline - Fix selection rectangle appearing on mousedown
This commit is contained in:
1 parent
7c955d1134
commit
f110383ed4
18 files changed
+381
-122
No files matched your search
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a keyframe on a <see cref="ILayerProperty" /> containing a value and a timestamp
|
||||
/// </summary>
|
||||
public interface ILayerPropertyKeyframe
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an untyped reference to the layer property of this keyframe
|
||||
/// </summary>
|
||||
ILayerProperty UntypedLayerProperty { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The position of this keyframe in the timeline
|
||||
/// </summary>
|
||||
TimeSpan Position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The easing function applied on the value of the keyframe
|
||||
/// </summary>
|
||||
Easings.Functions EasingFunction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the entity this keyframe uses for persistent storage
|
||||
/// </summary>
|
||||
KeyframeEntity GetKeyframeEntity();
|
||||
|
||||
/// <summary>
|
||||
/// Removes the keyframe from the layer property
|
||||
/// </summary>
|
||||
void Remove();
|
||||
}
|
||||
}
|
||||
@@ -559,12 +559,7 @@ namespace Artemis.Core
|
||||
Entity.Value = CoreJson.SerializeObject(BaseValue);
|
||||
Entity.KeyframesEnabled = KeyframesEnabled;
|
||||
Entity.KeyframeEntities.Clear();
|
||||
Entity.KeyframeEntities.AddRange(Keyframes.Select(k => new KeyframeEntity
|
||||
{
|
||||
Value = CoreJson.SerializeObject(k.Value),
|
||||
Position = k.Position,
|
||||
EasingFunction = (int) k.EasingFunction
|
||||
}));
|
||||
Entity.KeyframeEntities.AddRange(Keyframes.Select(k => k.GetKeyframeEntity()));
|
||||
|
||||
Entity.DataBindingEntities.Clear();
|
||||
foreach (IDataBinding dataBinding in _dataBindings)
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a keyframe on a <see cref="LayerProperty{T}" /> containing a value and a timestamp
|
||||
/// </summary>
|
||||
public class LayerPropertyKeyframe<T> : CorePropertyChanged
|
||||
public class LayerPropertyKeyframe<T> : CorePropertyChanged, ILayerPropertyKeyframe
|
||||
{
|
||||
private LayerProperty<T> _layerProperty;
|
||||
private TimeSpan _position;
|
||||
@@ -45,10 +46,10 @@ namespace Artemis.Core
|
||||
set => SetAndNotify(ref _value, value);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The position of this keyframe in the timeline
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public ILayerProperty UntypedLayerProperty => LayerProperty;
|
||||
|
||||
/// <inheritdoc />
|
||||
public TimeSpan Position
|
||||
{
|
||||
get => _position;
|
||||
@@ -59,14 +60,21 @@ namespace Artemis.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The easing function applied on the value of the keyframe
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public Easings.Functions EasingFunction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Removes the keyframe from the layer property
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public KeyframeEntity GetKeyframeEntity()
|
||||
{
|
||||
return new KeyframeEntity
|
||||
{
|
||||
Value = CoreJson.SerializeObject(Value),
|
||||
Position = Position,
|
||||
EasingFunction = (int) EasingFunction
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Remove()
|
||||
{
|
||||
LayerProperty.RemoveKeyframe(this);
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Artemis.Core
|
||||
/// Adds a profile element to the <see cref="Children" /> collection, optionally at the given position (1-based)
|
||||
/// </summary>
|
||||
/// <param name="child">The profile element to add</param>
|
||||
/// <param name="order">The order where to place the child (1-based), defaults to the end of the collection</param>
|
||||
/// <param name="order">The order where to place the child (0-based), defaults to the end of the collection</param>
|
||||
public virtual void AddChild(ProfileElement child, int? order = null)
|
||||
{
|
||||
if (Disposed)
|
||||
@@ -136,31 +136,19 @@ namespace Artemis.Core
|
||||
|
||||
// Add to the end of the list
|
||||
if (order == null)
|
||||
{
|
||||
ChildrenList.Add(child);
|
||||
child.Order = ChildrenList.Count;
|
||||
}
|
||||
// Shift everything after the given order
|
||||
// Insert at the given index
|
||||
else
|
||||
{
|
||||
if (order < 0)
|
||||
order = 0;
|
||||
foreach (ProfileElement profileElement in ChildrenList.Where(c => c.Order >= order).ToList())
|
||||
profileElement.Order++;
|
||||
|
||||
int targetIndex;
|
||||
if (order == 0)
|
||||
targetIndex = 0;
|
||||
else if (order > ChildrenList.Count)
|
||||
targetIndex = ChildrenList.Count;
|
||||
else
|
||||
targetIndex = ChildrenList.FindIndex(c => c.Order == order + 1);
|
||||
|
||||
ChildrenList.Insert(targetIndex, child);
|
||||
child.Order = order.Value;
|
||||
if (order > ChildrenList.Count)
|
||||
order = ChildrenList.Count;
|
||||
ChildrenList.Insert(order.Value, child);
|
||||
}
|
||||
|
||||
child.Parent = this;
|
||||
StreamlineOrder();
|
||||
}
|
||||
|
||||
OnChildAdded();
|
||||
@@ -178,10 +166,7 @@ namespace Artemis.Core
|
||||
lock (ChildrenList)
|
||||
{
|
||||
ChildrenList.Remove(child);
|
||||
|
||||
// Shift everything after the given order
|
||||
foreach (ProfileElement profileElement in ChildrenList.Where(c => c.Order > child.Order).ToList())
|
||||
profileElement.Order--;
|
||||
StreamlineOrder();
|
||||
|
||||
child.Parent = null;
|
||||
}
|
||||
@@ -189,6 +174,12 @@ namespace Artemis.Core
|
||||
OnChildRemoved();
|
||||
}
|
||||
|
||||
private void StreamlineOrder()
|
||||
{
|
||||
for (int index = 0; index < ChildrenList.Count; index++)
|
||||
ChildrenList[index].Order = index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a flattened list of all child folders
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user