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

Layer brushes - Render now always originates from 0,0

RGB.NET brushes - GetBrush is no called after properties are initialized
Profile editor - Fixed inputs not responding to updates from the visualization tools when keyframes are disabled
This commit is contained in:
SpoinkyNL 2020-06-03 19:22:08 +02:00
parent 72485e5d71
commit 97c85e238c
4 changed files with 16 additions and 10 deletions

View File

@ -207,12 +207,12 @@ namespace Artemis.Core.Models.Profile
if (LayerBrush?.BaseProperties == null || !LayerBrush.BaseProperties.PropertiesInitialized) if (LayerBrush?.BaseProperties == null || !LayerBrush.BaseProperties.PropertiesInitialized)
return; return;
// TODO: Remove, this is slow and stupid
// For now, reset all keyframe engines after the last keyframe was hit
// This is a placeholder method of repeating the animation until repeat modes are implemented
var properties = new List<BaseLayerProperty>(General.GetAllLayerProperties().Where(p => p.BaseKeyframes.Any())); var properties = new List<BaseLayerProperty>(General.GetAllLayerProperties().Where(p => p.BaseKeyframes.Any()));
properties.AddRange(Transform.GetAllLayerProperties().Where(p => p.BaseKeyframes.Any())); properties.AddRange(Transform.GetAllLayerProperties().Where(p => p.BaseKeyframes.Any()));
properties.AddRange(LayerBrush.BaseProperties.GetAllLayerProperties().Where(p => p.BaseKeyframes.Any())); properties.AddRange(LayerBrush.BaseProperties.GetAllLayerProperties().Where(p => p.BaseKeyframes.Any()));
// For now, reset all keyframe engines after the last keyframe was hit
// This is a placeholder method of repeating the animation until repeat modes are implemented
var timeLineEnd = properties.Any() ? properties.Max(p => p.BaseKeyframes.Max(k => k.Position)) : TimeSpan.MaxValue; var timeLineEnd = properties.Any() ? properties.Max(p => p.BaseKeyframes.Max(k => k.Position)) : TimeSpan.MaxValue;
if (properties.Any(p => p.TimelineProgress >= timeLineEnd)) if (properties.Any(p => p.TimelineProgress >= timeLineEnd))
{ {
@ -240,8 +240,12 @@ namespace Artemis.Core.Models.Profile
/// <inheritdoc /> /// <inheritdoc />
public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo) public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo)
{ {
// Ensure the layer is ready
if (Path == null || LayerShape?.Path == null || !General.PropertiesInitialized || !Transform.PropertiesInitialized) if (Path == null || LayerShape?.Path == null || !General.PropertiesInitialized || !Transform.PropertiesInitialized)
return; return;
// Ensure the brush is ready
if (LayerBrush?.BaseProperties?.PropertiesInitialized == false || LayerBrush?.BrushType != LayerBrushType.Regular)
return;
canvas.Save(); canvas.Save();
canvas.ClipPath(Path); canvas.ClipPath(Path);
@ -269,9 +273,6 @@ namespace Artemis.Core.Models.Profile
private void StretchRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint) private void StretchRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint)
{ {
if (LayerBrush == null || !LayerBrush.BaseProperties.PropertiesInitialized || LayerBrush.BrushType != LayerBrushType.Regular)
return;
// Apply transformations // Apply transformations
var sizeProperty = Transform.Scale.CurrentValue; var sizeProperty = Transform.Scale.CurrentValue;
var rotationProperty = Transform.Rotation.CurrentValue; var rotationProperty = Transform.Rotation.CurrentValue;
@ -293,9 +294,6 @@ namespace Artemis.Core.Models.Profile
private void ClipRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint) private void ClipRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint)
{ {
if (LayerBrush == null || !LayerBrush.BaseProperties.PropertiesInitialized || LayerBrush.BrushType != LayerBrushType.Regular)
return;
// Apply transformations // Apply transformations
var sizeProperty = Transform.Scale.CurrentValue; var sizeProperty = Transform.Scale.CurrentValue;
var rotationProperty = Transform.Rotation.CurrentValue; var rotationProperty = Transform.Rotation.CurrentValue;

View File

@ -26,6 +26,11 @@ namespace Artemis.Core.Plugins.LayerBrush
internal override void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint) internal override void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
{ {
// Move the canvas to the top-left of the render path
canvas.Translate(path.Bounds.Left, path.Bounds.Top);
// Pass the render path to the layer brush positioned at 0,0
path.Transform(SKMatrix.MakeTranslation(path.Bounds.Left * -1, path.Bounds.Top * -1));
Render(canvas, canvasInfo, path, paint); Render(canvas, canvasInfo, path, paint);
} }

View File

@ -17,7 +17,6 @@ namespace Artemis.Core.Plugins.LayerBrush
Layer = layer; Layer = layer;
Layer.RenderPropertiesUpdated += LayerOnRenderPropertiesUpdated; Layer.RenderPropertiesUpdated += LayerOnRenderPropertiesUpdated;
UpdateLedGroup();
} }
/// <summary> /// <summary>
@ -59,6 +58,7 @@ namespace Artemis.Core.Plugins.LayerBrush
internal override void Initialize(ILayerService layerService) internal override void Initialize(ILayerService layerService)
{ {
InitializeProperties(layerService); InitializeProperties(layerService);
UpdateLedGroup();
} }
// Not used in this brush type // Not used in this brush type

View File

@ -14,6 +14,7 @@ namespace Artemis.UI.Shared.PropertyInput
LayerProperty = layerProperty; LayerProperty = layerProperty;
ProfileEditorService = profileEditorService; ProfileEditorService = profileEditorService;
LayerProperty.Updated += LayerPropertyOnUpdated; LayerProperty.Updated += LayerPropertyOnUpdated;
LayerProperty.BaseValueChanged += LayerPropertyOnUpdated;
UpdateInputValue(); UpdateInputValue();
} }
@ -22,6 +23,7 @@ namespace Artemis.UI.Shared.PropertyInput
LayerProperty = layerProperty; LayerProperty = layerProperty;
ProfileEditorService = profileEditorService; ProfileEditorService = profileEditorService;
LayerProperty.Updated += LayerPropertyOnUpdated; LayerProperty.Updated += LayerPropertyOnUpdated;
LayerProperty.BaseValueChanged += LayerPropertyOnUpdated;
UpdateInputValue(); UpdateInputValue();
} }
@ -43,6 +45,7 @@ namespace Artemis.UI.Shared.PropertyInput
public virtual void Dispose() public virtual void Dispose()
{ {
LayerProperty.Updated -= LayerPropertyOnUpdated; LayerProperty.Updated -= LayerPropertyOnUpdated;
LayerProperty.BaseValueChanged -= LayerPropertyOnUpdated;
} }
protected virtual void OnInputValueApplied() protected virtual void OnInputValueApplied()