1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Profiles - Fixed elements updating while disabled

This commit is contained in:
Robert 2022-11-26 22:59:24 +01:00
parent b607690286
commit 6b6ea0f973
2 changed files with 71 additions and 53 deletions

View File

@ -99,19 +99,26 @@ public sealed class Folder : RenderProfileElement
return;
}
UpdateDisplayCondition();
UpdateTimeline(deltaTime);
try
{
UpdateDisplayCondition();
UpdateTimeline(deltaTime);
if (ShouldBeEnabled)
Enable();
else if (Timeline.IsFinished)
Disable();
if (ShouldBeEnabled)
Enable();
else if (Timeline.IsFinished)
Disable();
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
baseLayerEffect.InternalUpdate(Timeline);
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
baseLayerEffect.InternalUpdate(Timeline);
foreach (ProfileElement child in Children)
child.Update(deltaTime);
foreach (ProfileElement child in Children)
child.Update(deltaTime);
}
finally
{
Timeline.ClearDelta();
}
}
/// <inheritdoc />
@ -224,8 +231,6 @@ public sealed class Folder : RenderProfileElement
canvas.Restore();
layerPaint.DisposeSelfAndProperties();
}
Timeline.ClearDelta();
}
#endregion
@ -233,8 +238,10 @@ public sealed class Folder : RenderProfileElement
/// <inheritdoc />
public override void Enable()
{
// No checks here, effects will do their own checks to ensure they never enable twice
// Also not enabling children, they'll enable themselves during their own Update
if (!Enabled)
return;
// Not enabling children, they'll enable themselves during their own Update
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
baseLayerEffect.InternalEnable();
@ -244,7 +251,9 @@ public sealed class Folder : RenderProfileElement
/// <inheritdoc />
public override void Disable()
{
// No checks here, effects will do their own checks to ensure they never disable twice
if (!Enabled)
return;
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
baseLayerEffect.InternalDisable();

View File

@ -40,7 +40,7 @@ public sealed class Layer : RenderProfileElement
Suspended = false;
Leds = new ReadOnlyCollection<ArtemisLed>(_leds);
Adapter = new LayerAdapter(this);
Initialize();
}
@ -60,7 +60,7 @@ public sealed class Layer : RenderProfileElement
Parent = parent;
Leds = new ReadOnlyCollection<ArtemisLed>(_leds);
Adapter = new LayerAdapter(this);
Load();
Initialize();
if (loadNodeScript)
@ -370,41 +370,48 @@ public sealed class Layer : RenderProfileElement
return;
}
UpdateDisplayCondition();
UpdateTimeline(deltaTime);
if (ShouldBeEnabled)
Enable();
else if (Suspended || (Timeline.IsFinished && !_renderCopies.Any()))
Disable();
if (Timeline.Delta == TimeSpan.Zero)
return;
General.Update(Timeline);
Transform.Update(Timeline);
LayerBrush?.InternalUpdate(Timeline);
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
try
{
if (!baseLayerEffect.Suspended)
baseLayerEffect.InternalUpdate(Timeline);
UpdateDisplayCondition();
UpdateTimeline(deltaTime);
if (ShouldBeEnabled)
Enable();
else if (Suspended || (Timeline.IsFinished && !_renderCopies.Any()))
Disable();
if (!Enabled || Timeline.Delta == TimeSpan.Zero)
return;
General.Update(Timeline);
Transform.Update(Timeline);
LayerBrush?.InternalUpdate(Timeline);
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
{
if (!baseLayerEffect.Suspended)
baseLayerEffect.InternalUpdate(Timeline);
}
// Remove render copies that finished their timeline and update the rest
for (int index = 0; index < _renderCopies.Count; index++)
{
Layer child = _renderCopies[index];
if (!child.Timeline.IsFinished)
{
child.Update(deltaTime);
}
else
{
_renderCopies.Remove(child);
child.Dispose();
index--;
}
}
}
// Remove render copies that finished their timeline and update the rest
for (int index = 0; index < _renderCopies.Count; index++)
finally
{
Layer child = _renderCopies[index];
if (!child.Timeline.IsFinished)
{
child.Update(deltaTime);
}
else
{
_renderCopies.Remove(child);
child.Dispose();
index--;
}
Timeline.ClearDelta();
}
}
@ -485,8 +492,6 @@ public sealed class Layer : RenderProfileElement
{
layerPaint.DisposeSelfAndProperties();
}
Timeline.ClearDelta();
}
private void RenderCopies(SKCanvas canvas, SKPointI basePosition)
@ -498,7 +503,9 @@ public sealed class Layer : RenderProfileElement
/// <inheritdoc />
public override void Enable()
{
// No checks here, the brush and effects will do their own checks to ensure they never enable twice
if (Enabled)
return;
bool tryOrBreak = TryOrBreak(() => LayerBrush?.InternalEnable(), "Failed to enable layer brush");
if (!tryOrBreak)
return;
@ -517,7 +524,9 @@ public sealed class Layer : RenderProfileElement
/// <inheritdoc />
public override void Disable()
{
// No checks here, the brush and effects will do their own checks to ensure they never disable twice
if (!Enabled)
return;
LayerBrush?.InternalDisable();
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
baseLayerEffect.InternalDisable();