mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Profiles - Made data bindings compatible with timeline changes
This commit is contained in:
1 parent
997ab005d8
commit
0f5c2b80c4
23 files changed
+175
-163
No files matched your search
@@ -293,6 +293,10 @@ namespace Artemis.Core
|
||||
if (Operator == null || LeftPath == null || !LeftPath.IsValid)
|
||||
return false;
|
||||
|
||||
// If the operator does not support a right side, immediately evaluate with null
|
||||
if (Operator.RightSideType == null)
|
||||
return Operator.InternalEvaluate(LeftPath.GetValue(), null);
|
||||
|
||||
// Compare with a static value
|
||||
if (PredicateType == ProfileRightSideType.Static)
|
||||
{
|
||||
|
||||
@@ -55,11 +55,14 @@ namespace Artemis.Core
|
||||
|
||||
private object? GetEventPathValue(DataModelPath path, object target)
|
||||
{
|
||||
if (!(path.Target is EventPredicateWrapperDataModel wrapper))
|
||||
throw new ArtemisCoreException("Data model condition event predicate has a path with an invalid target");
|
||||
lock (path)
|
||||
{
|
||||
if (!(path.Target is EventPredicateWrapperDataModel wrapper))
|
||||
throw new ArtemisCoreException("Data model condition event predicate has a path with an invalid target");
|
||||
|
||||
wrapper.UntypedArguments = target;
|
||||
return path.GetValue();
|
||||
wrapper.UntypedArguments = target;
|
||||
return path.GetValue();
|
||||
}
|
||||
}
|
||||
|
||||
#region Initialization
|
||||
@@ -124,6 +127,10 @@ namespace Artemis.Core
|
||||
if (Operator == null || LeftPath == null || !LeftPath.IsValid)
|
||||
return false;
|
||||
|
||||
// If the operator does not support a right side, immediately evaluate with null
|
||||
if (Operator.RightSideType == null)
|
||||
return Operator.InternalEvaluate(GetEventPathValue(LeftPath, target), null);
|
||||
|
||||
// Compare with a static value
|
||||
if (PredicateType == ProfileRightSideType.Static)
|
||||
{
|
||||
|
||||
@@ -60,9 +60,9 @@ namespace Artemis.Core
|
||||
/// Gets ors ets the easing function of the data binding
|
||||
/// </summary>
|
||||
public Easings.Functions EasingFunction { get; set; }
|
||||
|
||||
|
||||
internal DataBindingEntity Entity { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current value of the data binding
|
||||
/// </summary>
|
||||
@@ -139,16 +139,24 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
/// <param name="timeline">The timeline to apply during update</param>
|
||||
public void Update(Timeline timeline)
|
||||
{
|
||||
UpdateWithDelta(timeline.Delta);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the smoothing progress of the data binding
|
||||
/// </summary>
|
||||
/// <param name="delta">The delta to apply during update</param>
|
||||
public void UpdateWithDelta(TimeSpan delta)
|
||||
{
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException("DataBinding");
|
||||
|
||||
// Data bindings cannot go back in time like brushes
|
||||
TimeSpan deltaTime = timeline.Delta;
|
||||
if (deltaTime < TimeSpan.Zero)
|
||||
deltaTime = TimeSpan.Zero;
|
||||
if (delta < TimeSpan.Zero)
|
||||
delta = TimeSpan.Zero;
|
||||
|
||||
_easingProgress = _easingProgress.Add(deltaTime);
|
||||
_easingProgress = _easingProgress.Add(delta);
|
||||
if (_easingProgress > EasingTime)
|
||||
_easingProgress = EasingTime;
|
||||
}
|
||||
|
||||
@@ -42,10 +42,8 @@ namespace Artemis.Core
|
||||
|
||||
CurrentValue = BaseValue;
|
||||
|
||||
if (ProfileElement.ApplyKeyframesEnabled)
|
||||
UpdateKeyframes(timeline);
|
||||
if (ProfileElement.ApplyDataBindingsEnabled)
|
||||
UpdateDataBindings(timeline);
|
||||
UpdateKeyframes(timeline);
|
||||
UpdateDataBindings(timeline);
|
||||
|
||||
OnUpdated();
|
||||
}
|
||||
@@ -421,6 +419,10 @@ namespace Artemis.Core
|
||||
|
||||
private void UpdateDataBindings(Timeline timeline)
|
||||
{
|
||||
// To avoid data bindings applying at non-regular updating (during editing) only update when not overriden
|
||||
if (timeline.IsOverridden)
|
||||
return;
|
||||
|
||||
foreach (IDataBinding dataBinding in _dataBindings)
|
||||
{
|
||||
dataBinding.Update(timeline);
|
||||
|
||||
@@ -15,8 +15,6 @@ namespace Artemis.Core
|
||||
{
|
||||
protected RenderProfileElement()
|
||||
{
|
||||
ApplyDataBindingsEnabled = true;
|
||||
ApplyKeyframesEnabled = true;
|
||||
Timeline = new Timeline();
|
||||
|
||||
LayerEffectStore.LayerEffectAdded += LayerEffectStoreOnLayerEffectAdded;
|
||||
@@ -300,16 +298,6 @@ namespace Artemis.Core
|
||||
set => SetAndNotify(ref _displayCondition, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether keyframes should be applied when this profile element updates
|
||||
/// </summary>
|
||||
public bool ApplyKeyframesEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether data bindings should be applied when this profile element updates
|
||||
/// </summary>
|
||||
public bool ApplyDataBindingsEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the display conditions on this element and applies any required changes to the <see cref="Timeline"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -137,6 +137,11 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public bool IsFinished => Position > Length || Length == TimeSpan.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether the timeline progress has been overridden
|
||||
/// </summary>
|
||||
public bool IsOverridden { get; private set; }
|
||||
|
||||
#region Segments
|
||||
|
||||
/// <summary>
|
||||
@@ -293,6 +298,7 @@ namespace Artemis.Core
|
||||
{
|
||||
Delta += delta;
|
||||
Position += delta;
|
||||
IsOverridden = false;
|
||||
|
||||
if (stickToMainSegment && Position >= MainSegmentStartPosition)
|
||||
{
|
||||
@@ -371,6 +377,8 @@ namespace Artemis.Core
|
||||
{
|
||||
Delta += position - Position;
|
||||
Position = position;
|
||||
IsOverridden = true;
|
||||
|
||||
if (stickToMainSegment && Position >= MainSegmentStartPosition)
|
||||
Position = MainSegmentStartPosition + TimeSpan.FromMilliseconds(Position.TotalMilliseconds % MainSegmentLength.TotalMilliseconds);
|
||||
|
||||
|
||||
Reference in new issue
Block a user