Profile - Blending mode fixes

Nodes editor - Adhere to cable display settings
Profile - Added focus layer option
This commit is contained in:
Robert committed 2022-08-14 10:18:17 +02:00
1 parent e401fdf964
commit 3f52279305
13 files changed
+115 -32

No files matched your search

+6 -2
View File
@@ -176,7 +176,7 @@ namespace Artemis.Core
#region Rendering
/// <inheritdoc />
public override void Render(SKCanvas canvas, SKPointI basePosition)
public override void Render(SKCanvas canvas, SKPointI basePosition, ProfileElement? editorFocus)
{
if (Disposed)
throw new ObjectDisposedException("Folder");
@@ -188,6 +188,10 @@ namespace Artemis.Core
// No point rendering if all children are disabled
if (!Children.Any(c => c is RenderProfileElement {Enabled: true}))
return;
// If the editor focus is on this folder, discard further focus for children to effectively focus the entire folder and all descendants
if (editorFocus == this)
editorFocus = null;
SKPaint layerPaint = new() {FilterQuality = SKFilterQuality.Low};
try
@@ -208,7 +212,7 @@ namespace Artemis.Core
// Iterate the children in reverse because the first layer must be rendered last to end up on top
for (int index = Children.Count - 1; index > -1; index--)
Children[index].Render(canvas, new SKPointI(Bounds.Left, Bounds.Top));
Children[index].Render(canvas, new SKPointI(Bounds.Left, Bounds.Top), editorFocus);
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
{
+24 -10
View File
@@ -416,11 +416,14 @@ namespace Artemis.Core
}
/// <inheritdoc />
public override void Render(SKCanvas canvas, SKPointI basePosition)
public override void Render(SKCanvas canvas, SKPointI basePosition, ProfileElement? editorFocus)
{
if (Disposed)
throw new ObjectDisposedException("Layer");
if (editorFocus != null && editorFocus != this)
return;
RenderLayer(canvas, basePosition);
RenderCopies(canvas, basePosition);
}
@@ -496,7 +499,7 @@ namespace Artemis.Core
private void RenderCopies(SKCanvas canvas, SKPointI basePosition)
{
for (int i = _renderCopies.Count - 1; i >= 0; i--)
_renderCopies[i].Render(canvas, basePosition);
_renderCopies[i].Render(canvas, basePosition, null);
}
/// <inheritdoc />
@@ -627,20 +630,31 @@ namespace Artemis.Core
if (LayerBrush == null)
throw new ArtemisCoreException("The layer is not yet ready for rendering");
using SKAutoCanvasRestore _ = new(canvas);
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
{
if (!baseLayerEffect.Suspended)
baseLayerEffect.InternalPreProcess(canvas, bounds, layerPaint);
}
canvas.ClipPath(renderPath);
LayerBrush.InternalRender(canvas, bounds, layerPaint);
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
try
{
if (!baseLayerEffect.Suspended)
baseLayerEffect.InternalPostProcess(canvas, bounds, layerPaint);
canvas.SaveLayer(layerPaint);
canvas.ClipPath(renderPath);
// Restore the blend mode before doing the actual render
layerPaint.BlendMode = SKBlendMode.SrcOver;
LayerBrush.InternalRender(canvas, bounds, layerPaint);
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
{
if (!baseLayerEffect.Suspended)
baseLayerEffect.InternalPostProcess(canvas, bounds, layerPaint);
}
}
finally
{
canvas.Restore();
}
}
+2 -2
View File
@@ -101,7 +101,7 @@ namespace Artemis.Core
}
/// <inheritdoc />
public override void Render(SKCanvas canvas, SKPointI basePosition)
public override void Render(SKCanvas canvas, SKPointI basePosition, ProfileElement? editorFocus)
{
lock (_lock)
{
@@ -112,7 +112,7 @@ namespace Artemis.Core
profileScript.OnProfileRendering(canvas, canvas.LocalClipBounds);
foreach (ProfileElement profileElement in Children)
profileElement.Render(canvas, basePosition);
profileElement.Render(canvas, basePosition, editorFocus);
foreach (ProfileScript profileScript in Scripts)
profileScript.OnProfileRendered(canvas, canvas.LocalClipBounds);
@@ -105,9 +105,12 @@ namespace Artemis.Core
public abstract void Update(double deltaTime);
/// <summary>
/// Renders the element
/// Renders the element
/// </summary>
public abstract void Render(SKCanvas canvas, SKPointI basePosition);
/// <param name="canvas">The canvas to render upon.</param>
/// <param name="basePosition">The base position to use to translate relative positions to absolute positions.</param>
/// <param name="editorFocus">An optional element to focus on while rendering (other elements will not render).</param>
public abstract void Render(SKCanvas canvas, SKPointI basePosition, ProfileElement? editorFocus);
/// <summary>
/// Resets the internal state of the element