mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Layers - Finished effects on layers, groups still missing
Effects - Added filter effect with different SkiaSharp image filters
This commit is contained in:
1 parent
58a964b872
commit
a62d5544cf
18 files changed
+264
-55
No files matched your search
@@ -166,6 +166,7 @@ namespace Artemis.Core.Models.Profile
|
||||
{
|
||||
var layerEffectEntity = new LayerEffectEntity
|
||||
{
|
||||
Id = layerEffect.EntityId,
|
||||
PluginGuid = layerEffect.PluginInfo.Guid,
|
||||
EffectType = layerEffect.GetType().Name,
|
||||
Name = layerEffect.Name,
|
||||
@@ -524,7 +525,7 @@ namespace Artemis.Core.Models.Profile
|
||||
var index = 0;
|
||||
foreach (var baseLayerEffect in LayerEffects.OrderBy(e => e.Order))
|
||||
{
|
||||
baseLayerEffect.UpdateOrder(index + 1);
|
||||
baseLayerEffect.Order = Order = index + 1;
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,11 @@ namespace Artemis.Core.Models.Profile
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the group is expanded in the UI
|
||||
/// </summary>
|
||||
public bool IsExpanded { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A list of all layer properties in this group
|
||||
/// </summary>
|
||||
@@ -107,21 +112,6 @@ namespace Artemis.Core.Models.Profile
|
||||
return _allLayerProperties;
|
||||
}
|
||||
|
||||
public void UpdateOrder(int oldOrder)
|
||||
{
|
||||
// Expanded state is tied to the path so save it before changing the path
|
||||
var expanded = Layer.IsPropertyGroupExpanded(this);
|
||||
Layer.SetPropertyGroupExpanded(this, false);
|
||||
|
||||
Path = Path.Replace($"LayerEffect.{oldOrder}.", $"LayerEffect.{LayerEffect.Order}.");
|
||||
// Restore the expanded state with the new path
|
||||
Layer.SetPropertyGroupExpanded(this, expanded);
|
||||
|
||||
// Update children
|
||||
foreach (var layerPropertyGroup in LayerPropertyGroups)
|
||||
layerPropertyGroup.UpdateOrder(oldOrder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before properties are fully initialized to allow you to populate
|
||||
/// <see cref="LayerProperty{T}.DefaultValue" /> on the properties you want
|
||||
|
||||
@@ -12,6 +12,11 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
|
||||
/// </summary>
|
||||
public abstract class BaseLayerEffect : PropertyChangedBase, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the unique ID of this effect
|
||||
/// </summary>
|
||||
public Guid EntityId { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the layer this effect is applied to
|
||||
/// </summary>
|
||||
@@ -36,7 +41,7 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
|
||||
/// <summary>
|
||||
/// Gets the order in which this effect appears in the update loop and editor
|
||||
/// </summary>
|
||||
public int Order { get; internal set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the descriptor of this effect
|
||||
@@ -53,7 +58,7 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
|
||||
/// </summary>
|
||||
public virtual LayerPropertyGroup BaseProperties => null;
|
||||
|
||||
internal string PropertyRootPath => $"LayerEffect.{Order}.{GetType().Name}.";
|
||||
internal string PropertyRootPath => $"LayerEffect.{EntityId}.{GetType().Name}.";
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -85,17 +90,7 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
|
||||
/// Called after the layer of folder has been rendered
|
||||
/// </summary>
|
||||
public abstract void PostProcess(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint);
|
||||
|
||||
public void UpdateOrder(int newOrder)
|
||||
{
|
||||
if (newOrder == Order)
|
||||
return;
|
||||
|
||||
var oldOrder = Order;
|
||||
Order = newOrder;
|
||||
BaseProperties.UpdateOrder(oldOrder);
|
||||
}
|
||||
|
||||
|
||||
internal void InternalPreProcess(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
|
||||
{
|
||||
// Move the canvas to the top-left of the render path
|
||||
|
||||
@@ -17,6 +17,12 @@ namespace Artemis.Core.Services.Interfaces
|
||||
/// <returns></returns>
|
||||
Layer CreateLayer(Profile profile, ProfileElement parent, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the currently active layer brush from the <see cref="Layer" /> and deletes any settings
|
||||
/// </summary>
|
||||
/// <param name="layer">The layer to remove the active brush from</param>
|
||||
void RemoveLayerBrush(Layer layer);
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates and adds the <see cref="BaseLayerBrush" /> described by the provided
|
||||
/// <see cref="LayerBrushDescriptor" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
@@ -40,6 +41,12 @@ namespace Artemis.Core.Services
|
||||
return layer;
|
||||
}
|
||||
|
||||
public void RemoveLayerBrush(Layer layer)
|
||||
{
|
||||
layer.RemoveLayerBrush();
|
||||
layer.OnLayerBrushUpdated();
|
||||
}
|
||||
|
||||
public BaseLayerBrush InstantiateLayerBrush(Layer layer)
|
||||
{
|
||||
if (layer.LayerBrush != null)
|
||||
@@ -87,6 +94,7 @@ namespace Artemis.Core.Services
|
||||
continue;
|
||||
|
||||
var effect = (BaseLayerEffect) _kernel.Get(descriptor.LayerEffectType);
|
||||
effect.EntityId = layerEntityLayerEffect.Id;
|
||||
effect.Layer = layer;
|
||||
effect.Order = layerEntityLayerEffect.Order;
|
||||
effect.Name = layerEntityLayerEffect.Name;
|
||||
@@ -104,6 +112,7 @@ namespace Artemis.Core.Services
|
||||
public BaseLayerEffect AddLayerEffect(Layer layer, LayerEffectDescriptor layerEffectDescriptor)
|
||||
{
|
||||
var effect = (BaseLayerEffect) _kernel.Get(layerEffectDescriptor.LayerEffectType);
|
||||
effect.EntityId = Guid.NewGuid();
|
||||
effect.Layer = layer;
|
||||
effect.Order = layer.LayerEffects.Count + 1;
|
||||
effect.Descriptor = layerEffectDescriptor;
|
||||
@@ -113,7 +122,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
layer.AddLayerEffect(effect);
|
||||
_logger.Debug("Added layer effect with root path {rootPath}", effect.PropertyRootPath);
|
||||
|
||||
|
||||
layer.OnLayerEffectsUpdated();
|
||||
return effect;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user