Refactored shape brushes to use the properties system

This commit is contained in:
Robert committed 2020-02-11 19:10:31 +01:00
1 parent 022e14e98d
commit 9b1d28840c
40 files changed
+650 -686

No files matched your search

@@ -1,32 +1,25 @@
using System;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerProperties;
using SkiaSharp;
namespace Artemis.Core.Plugins.LayerBrush
{
public abstract class LayerBrush : IDisposable
{
protected LayerBrush(Layer layer, LayerBrushSettings settings, LayerBrushDescriptor descriptor)
protected LayerBrush(Layer layer, LayerBrushDescriptor descriptor)
{
Layer = layer;
Settings = settings;
Descriptor = descriptor;
}
public Layer Layer { get; }
public LayerBrushSettings Settings { get; }
public LayerBrushDescriptor Descriptor { get; }
public virtual void Dispose()
{
}
/// <summary>
/// Called by the profile editor to populate the brush properties panel
/// </summary>
/// <returns></returns>
public abstract LayerBrushViewModel GetViewModel();
/// <summary>
/// Called before rendering every frame, write your update logic here
/// </summary>
@@ -46,5 +39,38 @@ namespace Artemis.Core.Plugins.LayerBrush
public virtual void Render(SKCanvas canvas, SKPath path, SKPaint paint)
{
}
/// <summary>
/// Provides an easy way to add your own properties to the layer, for more info see <see cref="LayerProperty{T}" />.
/// <para>Note: If found, the last value and keyframes are loaded and set when calling this method.</para>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="parent">The parent of this property, use this to create a tree-hierarchy in the editor</param>
/// <param name="id">A and ID identifying your property, must be unique within your plugin</param>
/// <param name="name">A name for your property, this is visible in the editor</param>
/// <param name="description">A description for your property, this is visible in the editor</param>
/// <returns>The layer property</returns>
protected LayerProperty<T> RegisterLayerProperty<T>(BaseLayerProperty parent, string id, string name, string description)
{
var property = new LayerProperty<T>(Layer, Descriptor.LayerBrushProvider.PluginInfo, parent, id, name, description);
Layer.RegisterLayerProperty(property);
return property;
}
/// <summary>
/// Provides an easy way to add your own properties to the layer, for more info see <see cref="LayerProperty{T}" />.
/// <para>Note: If found, the last value and keyframes are loaded and set when calling this method.</para>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="id">A and ID identifying your property, must be unique within your plugin</param>
/// <param name="name">A name for your property, this is visible in the editor</param>
/// <param name="description">A description for your property, this is visible in the editor</param>
/// <returns>The layer property</returns>
protected LayerProperty<T> RegisterLayerProperty<T>(string id, string name, string description)
{
var property = new LayerProperty<T>(Layer, Descriptor.LayerBrushProvider.PluginInfo, Layer.BrushReferenceProperty.Parent, id, name, description);
Layer.RegisterLayerProperty(property);
return property;
}
}
}
@@ -1,18 +0,0 @@
using System;
using System.Xml.Serialization;
using Newtonsoft.Json;
using Stylet;
namespace Artemis.Core.Plugins.LayerBrush
{
public abstract class LayerBrushSettings : PropertyChangedBase
{
/// <summary>
/// Gets or sets the dispatcher to use to dispatch PropertyChanged events. Defaults to
/// Execute.DefaultPropertyChangedDispatcher
/// </summary>
[XmlIgnore]
[JsonIgnore]
public override Action<Action> PropertyChangedDispatcher { get; set; } = Execute.DefaultPropertyChangedDispatcher;
}
}
@@ -1,14 +0,0 @@
using Stylet;
namespace Artemis.Core.Plugins.LayerBrush
{
public abstract class LayerBrushViewModel : PropertyChangedBase
{
protected LayerBrushViewModel(LayerBrush brush)
{
Brush = brush;
}
public LayerBrush Brush { get; }
}
}