1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Profiles - Better implementation of Enable/Disable while in editor

This commit is contained in:
Robert 2021-04-11 09:34:18 +02:00
parent bd75f1038e
commit b8578a9cce
3 changed files with 23 additions and 15 deletions

View File

@ -180,7 +180,7 @@ namespace Artemis.Core
throw new ObjectDisposedException("Folder");
// Ensure the folder is ready
if (!Enabled || Suspended || Path == null)
if (!Enabled || Path == null)
return;
// No point rendering if all children are disabled

View File

@ -289,7 +289,7 @@ namespace Artemis.Core
throw new ObjectDisposedException("Layer");
// Ensure the layer is ready
if (!Enabled || Suspended || Path == null || LayerShape?.Path == null || !General.PropertiesInitialized || !Transform.PropertiesInitialized)
if (!Enabled || Path == null || LayerShape?.Path == null || !General.PropertiesInitialized || !Transform.PropertiesInitialized)
return;
// Ensure the brush is ready
if (LayerBrush == null || LayerBrush?.BaseProperties?.PropertiesInitialized == false)

View File

@ -124,22 +124,30 @@ namespace Artemis.UI.Shared.Services
if (SelectedProfile == null || _doTick)
return;
// Stick to the main segment for any element that is not currently selected
foreach (Folder folder in SelectedProfile.GetAllFolders())
{
folder.Enable();
folder.Timeline.Override(CurrentTime, folder.Timeline.PlayMode == TimelinePlayMode.Repeat);
}
foreach (Layer layer in SelectedProfile.GetAllLayers())
{
layer.Enable();
layer.Timeline.Override(CurrentTime, (layer != SelectedProfileElement || layer.Timeline.Length < CurrentTime) && layer.Timeline.PlayMode == TimelinePlayMode.Repeat);
}
TickProfileElement(SelectedProfile.GetRootFolder());
_doTick = true;
}
private void TickProfileElement(ProfileElement profileElement)
{
if (profileElement is not RenderProfileElement renderElement)
return;
if (renderElement.Suspended)
renderElement.Disable();
else
{
renderElement.Enable();
if (renderElement is Folder)
renderElement.Timeline.Override(CurrentTime, renderElement.Timeline.PlayMode == TimelinePlayMode.Repeat);
else
renderElement.Timeline.Override(CurrentTime, (renderElement != SelectedProfileElement || renderElement.Timeline.Length < CurrentTime) && renderElement.Timeline.PlayMode == TimelinePlayMode.Repeat);
foreach (ProfileElement child in renderElement.Children)
TickProfileElement(child);
}
}
private void SelectedProfileOnDeactivated(object? sender, EventArgs e)
{
// Execute.PostToUIThread(() => ChangeSelectedProfile(null));