Przeglądaj źródła

Merge conflicts

flabbet 1 rok temu
rodzic
commit
1e511e8236

+ 1 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Filter.cs

@@ -1,5 +1,5 @@
 using System.Diagnostics.Contracts;
-using PixiEditor.DrawingApi.Core.Surface.PaintImpl;
+using PixiEditor.DrawingApi.Core.Surfaces.PaintImpl;
 
 namespace PixiEditor.ChangeableDocument.Changeables.Graph;
 

+ 3 - 3
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/FilterNodes/ApplyFilterNode.cs

@@ -1,15 +1,15 @@
 using PixiEditor.ChangeableDocument.Helpers;
 using PixiEditor.ChangeableDocument.Rendering;
-using PixiEditor.DrawingApi.Core.Surface.PaintImpl;
+using PixiEditor.DrawingApi.Core;
+using PixiEditor.DrawingApi.Core.Surfaces.PaintImpl;
 
 namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes.FilterNodes;
 
+[NodeInfo("ApplyFilter")]
 public class ApplyFilterNode : Node
 {
     private Paint _paint = new();
     
-    protected override string NodeUniqueName { get; } = "ApplyFilter";
-
     public override string DisplayName { get; set; } = "APPLY_FILTER_NODE";
     
     public OutputProperty<Surface?> Output { get; }

+ 2 - 3
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/FilterNodes/ColorMatrixFilterNode.cs

@@ -1,8 +1,9 @@
-using PixiEditor.DrawingApi.Core.Surface.PaintImpl;
+using PixiEditor.DrawingApi.Core.Surfaces.PaintImpl;
 using PixiEditor.Numerics;
 
 namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes.FilterNodes;
 
+[NodeInfo("ColorMatrixFilter")]
 public class ColorMatrixFilterNode : FilterNode
 {
     public InputProperty<ColorMatrix> Matrix { get; }
@@ -14,8 +15,6 @@ public class ColorMatrixFilterNode : FilterNode
         Matrix = CreateInput(nameof(Matrix), "MATRIX", ColorMatrix.Identity);
     }
 
-    protected override string NodeUniqueName => "ColorMatrixFilter";
-
     protected override ColorFilter? GetColorFilter() => ColorFilter.CreateColorMatrix(Matrix.Value);
 
     public override Node CreateCopy() => new ColorMatrixFilterNode();

+ 2 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/FilterNodes/FilterNode.cs

@@ -1,5 +1,6 @@
 using PixiEditor.ChangeableDocument.Rendering;
-using PixiEditor.DrawingApi.Core.Surface.PaintImpl;
+using PixiEditor.DrawingApi.Core;
+using PixiEditor.DrawingApi.Core.Surfaces.PaintImpl;
 
 namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes.FilterNodes;
 

+ 3 - 4
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/FilterNodes/KernelFilterNode.cs

@@ -1,9 +1,10 @@
-using PixiEditor.DrawingApi.Core.Surface;
-using PixiEditor.DrawingApi.Core.Surface.PaintImpl;
+using PixiEditor.DrawingApi.Core.Surfaces;
+using PixiEditor.DrawingApi.Core.Surfaces.PaintImpl;
 using PixiEditor.Numerics;
 
 namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes.FilterNodes;
 
+[NodeInfo("KernelFilter")]
 public class KernelFilterNode : FilterNode
 {
     private readonly Paint _paint = new();
@@ -28,8 +29,6 @@ public class KernelFilterNode : FilterNode
         OnAlpha = CreateInput(nameof(OnAlpha), "ON_ALPHA", false);
     }
 
-    protected override string NodeUniqueName => "KernelFilter";
-
     protected override ImageFilter? GetImageFilter()
     {
         var kernel = Kernel.Value;

+ 11 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Node.cs

@@ -338,6 +338,17 @@ public abstract class Node : IReadOnlyNode, IDisposable
         return outputs.FirstOrDefault(x => x.InternalPropertyName == outputProperty);
     }
 
+
+    public bool HasInputProperty(string propertyName)
+    {
+        return inputs.Any(x => x.InternalPropertyName == propertyName);
+    }
+
+    public bool HasOutputProperty(string propertyName)
+    {
+        return outputs.Any(x => x.InternalPropertyName == propertyName);
+    }
+
     IInputProperty? IReadOnlyNode.GetInputProperty(string inputProperty)
     {
         return GetInputProperty(inputProperty);

+ 11 - 2
src/PixiEditor.ChangeableDocument/Changes/NodeGraph/UpdateProperty_Change.cs

@@ -1,4 +1,5 @@
 using PixiEditor.ChangeableDocument.Changeables.Graph;
+using PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
 using PixiEditor.ChangeableDocument.ChangeInfos.NodeGraph;
 
 namespace PixiEditor.ChangeableDocument.Changes.NodeGraph;
@@ -17,8 +18,16 @@ internal class UpdatePropertyValue_Change : Change
         _propertyName = property;
         _value = value;
     }
-    
-    public override bool InitializeAndValidate(Document target) => true;
+
+    public override bool InitializeAndValidate(Document target)
+    {
+        if(target.TryFindNode<Node>(_nodeId, out var node))
+        {
+            return node.HasInputProperty(_propertyName);
+        }
+        
+        return false;
+    }
 
     public override OneOf<None, IChangeInfo, List<IChangeInfo>> Apply(Document target, bool firstApply, out bool ignoreInUndo)
     {

+ 1 - 1
src/PixiEditor.ChangeableDocument/Helpers/PaintHelper.cs

@@ -1,5 +1,5 @@
 using PixiEditor.ChangeableDocument.Changeables.Graph;
-using PixiEditor.DrawingApi.Core.Surface.PaintImpl;
+using PixiEditor.DrawingApi.Core.Surfaces.PaintImpl;
 
 namespace PixiEditor.ChangeableDocument.Helpers;
 

+ 1 - 0
src/PixiEditor.DrawingApi.Core/Bridge/NativeObjectsImpl/IImageFilterImplementation.cs

@@ -1,5 +1,6 @@
 using System;
 using PixiEditor.DrawingApi.Core.Surfaces;
+using PixiEditor.DrawingApi.Core.Surfaces.PaintImpl;
 using PixiEditor.Numerics;
 
 namespace PixiEditor.DrawingApi.Core.Bridge.NativeObjectsImpl;

+ 1 - 0
src/PixiEditor.DrawingApi.Skia/Implementations/SkiaImageFilterImplementation.cs

@@ -2,6 +2,7 @@
 using PixiEditor.DrawingApi.Core.Bridge.NativeObjectsImpl;
 using PixiEditor.DrawingApi.Core.ColorsImpl;
 using PixiEditor.DrawingApi.Core.Surfaces;
+using PixiEditor.DrawingApi.Core.Surfaces.PaintImpl;
 using PixiEditor.Numerics;
 using SkiaSharp;