1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +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,6 +99,8 @@ public sealed class Folder : RenderProfileElement
return; return;
} }
try
{
UpdateDisplayCondition(); UpdateDisplayCondition();
UpdateTimeline(deltaTime); UpdateTimeline(deltaTime);
@ -113,6 +115,11 @@ public sealed class Folder : RenderProfileElement
foreach (ProfileElement child in Children) foreach (ProfileElement child in Children)
child.Update(deltaTime); child.Update(deltaTime);
} }
finally
{
Timeline.ClearDelta();
}
}
/// <inheritdoc /> /// <inheritdoc />
public override void Reset() public override void Reset()
@ -224,8 +231,6 @@ public sealed class Folder : RenderProfileElement
canvas.Restore(); canvas.Restore();
layerPaint.DisposeSelfAndProperties(); layerPaint.DisposeSelfAndProperties();
} }
Timeline.ClearDelta();
} }
#endregion #endregion
@ -233,8 +238,10 @@ public sealed class Folder : RenderProfileElement
/// <inheritdoc /> /// <inheritdoc />
public override void Enable() public override void Enable()
{ {
// No checks here, effects will do their own checks to ensure they never enable twice if (!Enabled)
// Also not enabling children, they'll enable themselves during their own Update return;
// Not enabling children, they'll enable themselves during their own Update
foreach (BaseLayerEffect baseLayerEffect in LayerEffects) foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
baseLayerEffect.InternalEnable(); baseLayerEffect.InternalEnable();
@ -244,7 +251,9 @@ public sealed class Folder : RenderProfileElement
/// <inheritdoc /> /// <inheritdoc />
public override void Disable() 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) foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
baseLayerEffect.InternalDisable(); baseLayerEffect.InternalDisable();

View File

@ -370,6 +370,8 @@ public sealed class Layer : RenderProfileElement
return; return;
} }
try
{
UpdateDisplayCondition(); UpdateDisplayCondition();
UpdateTimeline(deltaTime); UpdateTimeline(deltaTime);
@ -378,7 +380,7 @@ public sealed class Layer : RenderProfileElement
else if (Suspended || (Timeline.IsFinished && !_renderCopies.Any())) else if (Suspended || (Timeline.IsFinished && !_renderCopies.Any()))
Disable(); Disable();
if (Timeline.Delta == TimeSpan.Zero) if (!Enabled || Timeline.Delta == TimeSpan.Zero)
return; return;
General.Update(Timeline); General.Update(Timeline);
@ -407,6 +409,11 @@ public sealed class Layer : RenderProfileElement
} }
} }
} }
finally
{
Timeline.ClearDelta();
}
}
/// <inheritdoc /> /// <inheritdoc />
public override void Render(SKCanvas canvas, SKPointI basePosition, ProfileElement? editorFocus) public override void Render(SKCanvas canvas, SKPointI basePosition, ProfileElement? editorFocus)
@ -485,8 +492,6 @@ public sealed class Layer : RenderProfileElement
{ {
layerPaint.DisposeSelfAndProperties(); layerPaint.DisposeSelfAndProperties();
} }
Timeline.ClearDelta();
} }
private void RenderCopies(SKCanvas canvas, SKPointI basePosition) private void RenderCopies(SKCanvas canvas, SKPointI basePosition)
@ -498,7 +503,9 @@ public sealed class Layer : RenderProfileElement
/// <inheritdoc /> /// <inheritdoc />
public override void Enable() 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"); bool tryOrBreak = TryOrBreak(() => LayerBrush?.InternalEnable(), "Failed to enable layer brush");
if (!tryOrBreak) if (!tryOrBreak)
return; return;
@ -517,7 +524,9 @@ public sealed class Layer : RenderProfileElement
/// <inheritdoc /> /// <inheritdoc />
public override void Disable() 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(); LayerBrush?.InternalDisable();
foreach (BaseLayerEffect baseLayerEffect in LayerEffects) foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
baseLayerEffect.InternalDisable(); baseLayerEffect.InternalDisable();