Browse Source

Delete actions boilerplate

Equbuxu 3 years ago
parent
commit
e7f09a4f8e
61 changed files with 135 additions and 564 deletions
  1. 1 1
      src/PixiEditor.ChangeableDocument.Gen/ChangeActionGenerator.cs
  2. 8 3
      src/PixiEditor.ChangeableDocument.Gen/Helpers.cs
  3. 12 5
      src/PixiEditor.ChangeableDocument.Gen/Result.cs
  4. 21 15
      src/PixiEditor.ChangeableDocument.Gen/UpdateableChangeActionGenerator.cs
  5. 3 0
      src/PixiEditor.ChangeableDocument/Actions/Attributes/GenerateMakeChangeActionAttribute.cs
  6. 3 0
      src/PixiEditor.ChangeableDocument/Actions/Attributes/GenerateUpdateableChangeActionsAttribute.cs
  7. 3 0
      src/PixiEditor.ChangeableDocument/Actions/Attributes/UpdateChangeMethodAttribute.cs
  8. 0 20
      src/PixiEditor.ChangeableDocument/Actions/Drawing/CombineStructureMembersOnto_Action.cs
  9. 0 11
      src/PixiEditor.ChangeableDocument/Actions/Drawing/PasteImage/EndPasteImage_Action.cs
  10. 0 31
      src/PixiEditor.ChangeableDocument/Actions/Drawing/PasteImage/PasteImage_Action.cs
  11. 0 29
      src/PixiEditor.ChangeableDocument/Actions/Drawing/Rectangle/DrawRectangle_Action.cs
  12. 0 12
      src/PixiEditor.ChangeableDocument/Actions/Drawing/Rectangle/EndDrawRectangle_Action.cs
  13. 0 12
      src/PixiEditor.ChangeableDocument/Actions/Drawing/Selection/ClearSelection_Action.cs
  14. 0 12
      src/PixiEditor.ChangeableDocument/Actions/Drawing/Selection/EndSelectRectangle_Action.cs
  15. 0 26
      src/PixiEditor.ChangeableDocument/Actions/Drawing/Selection/SelectRectangle_Action.cs
  16. 0 3
      src/PixiEditor.ChangeableDocument/Actions/GenerateMakeChangeActionAttribute.cs
  17. 0 3
      src/PixiEditor.ChangeableDocument/Actions/GenerateUpdateableChangeActionsAttribute.cs
  18. 0 19
      src/PixiEditor.ChangeableDocument/Actions/Properties/CreateStructureMemberMask_Action.cs
  19. 0 19
      src/PixiEditor.ChangeableDocument/Actions/Properties/DeleteStructureMemberMask_Action.cs
  20. 0 9
      src/PixiEditor.ChangeableDocument/Actions/Properties/EndOpacityChange_Action.cs
  21. 0 26
      src/PixiEditor.ChangeableDocument/Actions/Properties/OpacityChange_Action.cs
  22. 0 20
      src/PixiEditor.ChangeableDocument/Actions/Properties/SetLayerLockTransparency_Action.cs
  23. 0 21
      src/PixiEditor.ChangeableDocument/Actions/Properties/SetStructureMemberBlendMode_Action.cs
  24. 0 20
      src/PixiEditor.ChangeableDocument/Actions/Properties/SetStructureMemberClipToMemberBelow_Action.cs
  25. 0 21
      src/PixiEditor.ChangeableDocument/Actions/Properties/SetStructureMemberName_Action.cs
  26. 0 21
      src/PixiEditor.ChangeableDocument/Actions/Properties/SetStructureMemberVisibility_Action.cs
  27. 0 18
      src/PixiEditor.ChangeableDocument/Actions/Root/ResizeCanvas_Action.cs
  28. 0 21
      src/PixiEditor.ChangeableDocument/Actions/Root/SetSymmetryAxisState_Action.cs
  29. 0 11
      src/PixiEditor.ChangeableDocument/Actions/Root/SymmetryPosition/EndSetSymmetryAxisPosition_Action.cs
  30. 0 26
      src/PixiEditor.ChangeableDocument/Actions/Root/SymmetryPosition/SetSymmetryAxisPosition_Action.cs
  31. 0 26
      src/PixiEditor.ChangeableDocument/Actions/Structure/CreateStructureMember_Action.cs
  32. 0 19
      src/PixiEditor.ChangeableDocument/Actions/Structure/DeleteStructureMember_Action.cs
  33. 0 23
      src/PixiEditor.ChangeableDocument/Actions/Structure/MoveStructureMember_Action.cs
  34. 0 3
      src/PixiEditor.ChangeableDocument/Actions/UpdateChangeMethodAttribute.cs
  35. 4 0
      src/PixiEditor.ChangeableDocument/Changes/Drawing/ClearSelection_Change.cs
  36. 1 0
      src/PixiEditor.ChangeableDocument/Changes/Drawing/CombineStructureMembersOnto_Change.cs
  37. 6 2
      src/PixiEditor.ChangeableDocument/Changes/Drawing/DrawRectangle_UpdateableChange.cs
  38. 8 5
      src/PixiEditor.ChangeableDocument/Changes/Drawing/PasteImage_UpdateableChange.cs
  39. 4 0
      src/PixiEditor.ChangeableDocument/Changes/Drawing/SelectRectangle_UpdateableChange.cs
  40. 2 0
      src/PixiEditor.ChangeableDocument/Changes/Properties/CreateStructureMemberMask_Change.cs
  41. 1 0
      src/PixiEditor.ChangeableDocument/Changes/Properties/DeleteStructureMemberMask_Change.cs
  42. 4 2
      src/PixiEditor.ChangeableDocument/Changes/Properties/LayerLockTransparency_Change.cs
  43. 4 3
      src/PixiEditor.ChangeableDocument/Changes/Properties/StructureMemberBlendMode_Change.cs
  44. 3 2
      src/PixiEditor.ChangeableDocument/Changes/Properties/StructureMemberClipToMemberBelow_Change.cs
  45. 4 3
      src/PixiEditor.ChangeableDocument/Changes/Properties/StructureMemberIsVisible_Change.cs
  46. 5 3
      src/PixiEditor.ChangeableDocument/Changes/Properties/StructureMemberName_Change.cs
  47. 6 3
      src/PixiEditor.ChangeableDocument/Changes/Properties/StructureMemberOpacity_UpdateableChange.cs
  48. 2 0
      src/PixiEditor.ChangeableDocument/Changes/Root/ResizeCanvas_Change.cs
  49. 2 0
      src/PixiEditor.ChangeableDocument/Changes/Root/SymmetryAxisPosition_UpdateableChange.cs
  50. 1 0
      src/PixiEditor.ChangeableDocument/Changes/Root/SymmetryAxisState_Change.cs
  51. 1 0
      src/PixiEditor.ChangeableDocument/Changes/Structure/CreateStructureMember_Change.cs
  52. 2 0
      src/PixiEditor.ChangeableDocument/Changes/Structure/DeleteStructureMember_Change.cs
  53. 1 0
      src/PixiEditor.ChangeableDocument/Changes/Structure/MoveStructureMember_Change.cs
  54. 1 0
      src/PixiEditor.ChangeableDocument/GlobalUsings.cs
  55. 1 4
      src/PixiEditor.ChangeableDocument/PixiEditor.ChangeableDocument.csproj
  56. 1 0
      src/PixiEditorPrototype/GlobalUsings.cs
  57. 0 1
      src/PixiEditorPrototype/Models/DocumentStructureHelper.cs
  58. 6 6
      src/PixiEditorPrototype/Models/Rendering/AffectedChunkGatherer.cs
  59. 6 14
      src/PixiEditorPrototype/ViewModels/DocumentViewModel.cs
  60. 2 3
      src/PixiEditorPrototype/ViewModels/LayerViewModel.cs
  61. 6 7
      src/PixiEditorPrototype/ViewModels/StructureMemberViewModel.cs

+ 1 - 1
src/PixiEditor.ChangeableDocument.Gen/ChangeActionGenerator.cs

@@ -18,7 +18,7 @@ namespace PixiEditor.ChangeableDocument.Gen
                         context,
                         cancelToken,
                         constructor,
-                        new NamespacedType("GenerateMakeChangeActionAttribute", "PixiEditor.ChangeableDocument.Actions")
+                        new NamespacedType("GenerateMakeChangeActionAttribute", "PixiEditor.ChangeableDocument.Actions.Attributes")
                         ))
                         return null;
 

+ 8 - 3
src/PixiEditor.ChangeableDocument.Gen/Helpers.cs

@@ -6,6 +6,8 @@ namespace PixiEditor.ChangeableDocument.Gen;
 
 internal static class Helpers
 {
+    private static SymbolDisplayFormat TypeWithGenerics =
+        new SymbolDisplayFormat(genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters | SymbolDisplayGenericsOptions.IncludeTypeConstraints);
     public static string CreateMakeChangeAction(MethodInfo changeConstructorInfo)
     {
         string actionName = changeConstructorInfo.ContainingClass.Name.Split('_')[0] + "_Action";
@@ -32,7 +34,8 @@ internal static class Helpers
         return sb.ToString();
     }
 
-    public static Result<string> CreateStartUpdateChangeAction(MethodInfo changeConstructorInfo, MethodInfo updateMethodInfo)
+    public static Result<string> CreateStartUpdateChangeAction
+        (MethodInfo changeConstructorInfo, MethodInfo updateMethodInfo, ClassDeclarationSyntax containingClass)
     {
         string actionName = changeConstructorInfo.ContainingClass.Name.Split('_')[0] + "_Action";
         List<TypeWithName> constructorArgs = changeConstructorInfo.Arguments;
@@ -44,7 +47,7 @@ internal static class Helpers
         var constructorAssignments = MatchMembers(properties, constructorArgs);
         var updatePropsToPass = MatchMembers(updateMethodInfo.Arguments, properties).Select(pair => pair.Item2).ToList();
         if (updatePropsToPass.Count != updateMethodInfo.Arguments.Count)
-            return Result<string>.Error("Couldn't match update method arguments with constructor arguments");
+            return Result<string>.Error("Couldn't match update method arguments with constructor arguments", containingClass.SyntaxTree, containingClass.Span);
 
         StringBuilder sb = new();
 
@@ -83,12 +86,13 @@ public record class {actionName} : PixiEditor.ChangeableDocument.Actions.IEndCha
         List<TypeWithName> variables = method.Parameters.Select(static parameter =>
         {
             return new TypeWithName(
-                parameter.Type.Name,
+                parameter.Type.ToDisplayString(TypeWithGenerics),
                 parameter.Type.ContainingNamespace.ToDisplayString(),
                 parameter.Name
                 );
         }).ToList();
         string changeName = method.ContainingType.Name;
+
         string changeFullNamespace = method.ContainingNamespace.ToDisplayString();
         return new MethodInfo(method.Name, variables, new NamespacedType(changeName, changeFullNamespace));
     }
@@ -117,6 +121,7 @@ public record class {actionName} : PixiEditor.ChangeableDocument.Actions.IEndCha
                 }
             }
         }
+        paired.Reverse();
         return paired;
     }
 

+ 12 - 5
src/PixiEditor.ChangeableDocument.Gen/Result.cs

@@ -1,21 +1,28 @@
-namespace PixiEditor.ChangeableDocument.Gen;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace PixiEditor.ChangeableDocument.Gen;
 internal struct Result<T>
 {
     public string? ErrorText { get; }
+    public SyntaxTree? SyntaxTree { get; }
+    public TextSpan? Span { get; }
     public T? Value { get; }
 
-    private Result(string? error, T? value)
+    private Result(string? error, T? value, SyntaxTree? syntaxTree, TextSpan? span)
     {
         ErrorText = error;
         Value = value;
+        SyntaxTree = syntaxTree;
+        Span = span;
     }
-    public static Result<T> Error(string text)
+    public static Result<T> Error(string text, SyntaxTree tree, TextSpan span)
     {
-        return new Result<T>(text, default(T));
+        return new Result<T>(text, default(T), tree, span);
     }
 
     public static implicit operator Result<T>(T value)
     {
-        return new Result<T>(null, value);
+        return new Result<T>(null, value, null, null);
     }
 }

+ 21 - 15
src/PixiEditor.ChangeableDocument.Gen/UpdateableChangeActionGenerator.cs

@@ -1,17 +1,19 @@
 using Microsoft.CodeAnalysis;
 using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Text;
 
 namespace PixiEditor.ChangeableDocument.Gen;
 [Generator]
 public class UpdateableChangeActionGenerator : IIncrementalGenerator
 {
-    private const string ActionsNamespace = "PixiEditor.ChangeableDocument.Actions";
+    private const string AttributesNamespace = "PixiEditor.ChangeableDocument.Actions.Attributes";
     private const string ConstructorAttribute = "GenerateUpdateableChangeActionsAttribute";
     private const string UpdateMethodAttribute = "UpdateChangeMethodAttribute";
-    private static NamespacedType ConstructorAttributeType = new NamespacedType(ConstructorAttribute, ActionsNamespace);
-    private static NamespacedType UpdateMethodAttributeType = new NamespacedType(UpdateMethodAttribute, ActionsNamespace);
+    private static NamespacedType ConstructorAttributeType = new NamespacedType(ConstructorAttribute, AttributesNamespace);
+    private static NamespacedType UpdateMethodAttributeType = new NamespacedType(UpdateMethodAttribute, AttributesNamespace);
 
-    private static Result<(IMethodSymbol, IMethodSymbol)>? TransformSyntax(GeneratorSyntaxContext context, CancellationToken cancelToken)
+    private static Result<(IMethodSymbol, IMethodSymbol, ClassDeclarationSyntax)>? TransformSyntax
+        (GeneratorSyntaxContext context, CancellationToken cancelToken)
     {
         ClassDeclarationSyntax containingClass;
         ConstructorDeclarationSyntax constructorSyntax;
@@ -31,8 +33,8 @@ public class UpdateableChangeActionGenerator : IIncrementalGenerator
         var classSymbol = (INamedTypeSymbol)context.SemanticModel.GetDeclaredSymbol(containingClass)!;
         if (!Helpers.IsInheritedFrom(classSymbol, new("UpdateableChange", "PixiEditor.ChangeableDocument.Changes")))
         {
-            return Result<(IMethodSymbol, IMethodSymbol)>.Error
-                ("The GenerateUpdateableChangeActions and UpdateChangeMethodAttribute can only be used inside UpdateableChanges");
+            return Result<(IMethodSymbol, IMethodSymbol, ClassDeclarationSyntax)>.Error
+                ("The GenerateUpdateableChangeActions and UpdateChangeMethodAttribute can only be used inside UpdateableChanges", containingClass.SyntaxTree, containingClass.Span);
         }
 
         // here we are sure we are inside an updateable change, time to find the update method
@@ -40,7 +42,8 @@ public class UpdateableChangeActionGenerator : IIncrementalGenerator
         var members = containingClass.Members.Where(node => node is MethodDeclarationSyntax);
         const string errorMessage = $"Update method isn't marked with {UpdateMethodAttribute}";
         if (!members.Any())
-            return Result<(IMethodSymbol, IMethodSymbol)>.Error(errorMessage);
+            return Result<(IMethodSymbol, IMethodSymbol, ClassDeclarationSyntax)>.Error
+                (errorMessage, containingClass.SyntaxTree, containingClass.Span);
         foreach (var member in members)
         {
             cancelToken.ThrowIfCancellationRequested();
@@ -54,7 +57,8 @@ public class UpdateableChangeActionGenerator : IIncrementalGenerator
         }
         if (methodSyntax is null)
         {
-            return Result<(IMethodSymbol, IMethodSymbol)>.Error(errorMessage);
+            return Result<(IMethodSymbol, IMethodSymbol, ClassDeclarationSyntax)>.Error
+                (errorMessage, containingClass.SyntaxTree, containingClass.Span);
         }
 
         // finally, get symbols
@@ -62,22 +66,24 @@ public class UpdateableChangeActionGenerator : IIncrementalGenerator
         var contructorSymbol = context.SemanticModel.GetDeclaredSymbol(constructorSyntax, cancelToken);
         if (contructorSymbol is not IMethodSymbol || methodSymbol is not IMethodSymbol)
             return null;
-        return ((IMethodSymbol)contructorSymbol, (IMethodSymbol)methodSymbol);
+        return ((IMethodSymbol)contructorSymbol, (IMethodSymbol)methodSymbol, containingClass);
     }
 
     private static Result<(NamedSourceCode, NamedSourceCode)> GenerateActions
-        (Result<(IMethodSymbol, IMethodSymbol)>? prevResult, CancellationToken cancelToken)
+        (Result<(IMethodSymbol, IMethodSymbol, ClassDeclarationSyntax)>? prevResult, CancellationToken cancelToken)
     {
         if (prevResult!.Value.ErrorText is not null)
-            return Result<(NamedSourceCode, NamedSourceCode)>.Error(prevResult.Value.ErrorText);
-        var (constructor, update) = prevResult.Value.Value;
+            return Result<(NamedSourceCode, NamedSourceCode)>.Error
+                (prevResult.Value.ErrorText, prevResult.Value.SyntaxTree!, (TextSpan)prevResult.Value.Span!);
+        var (constructor, update, containingClass) = prevResult.Value.Value;
 
         var constructorInfo = Helpers.ExtractMethodInfo(constructor!);
         var updateInfo = Helpers.ExtractMethodInfo(update!);
 
-        var maybeStartUpdateAction = Helpers.CreateStartUpdateChangeAction(constructorInfo, updateInfo);
+        var maybeStartUpdateAction = Helpers.CreateStartUpdateChangeAction(constructorInfo, updateInfo, containingClass);
         if (maybeStartUpdateAction.ErrorText is not null)
-            return Result<(NamedSourceCode, NamedSourceCode)>.Error(maybeStartUpdateAction.ErrorText);
+            return Result<(NamedSourceCode, NamedSourceCode)>.Error
+                (maybeStartUpdateAction.ErrorText, maybeStartUpdateAction.SyntaxTree!, (TextSpan)maybeStartUpdateAction.Span!);
 
         var endAction = Helpers.CreateEndChangeAction(constructorInfo);
 
@@ -106,7 +112,7 @@ public class UpdateableChangeActionGenerator : IIncrementalGenerator
                 context.ReportDiagnostic(
                     Diagnostic.Create(
                         new DiagnosticDescriptor("AGErr", "", namedActions.ErrorText, "UpdateableActionGenerator", DiagnosticSeverity.Error, true),
-                        null));
+                        Location.Create(namedActions.SyntaxTree!, (TextSpan)namedActions.Span!)));
                 return;
             }
 

+ 3 - 0
src/PixiEditor.ChangeableDocument/Actions/Attributes/GenerateMakeChangeActionAttribute.cs

@@ -0,0 +1,3 @@
+namespace PixiEditor.ChangeableDocument.Actions.Attributes;
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)]
+internal sealed class GenerateMakeChangeActionAttribute : Attribute { }

+ 3 - 0
src/PixiEditor.ChangeableDocument/Actions/Attributes/GenerateUpdateableChangeActionsAttribute.cs

@@ -0,0 +1,3 @@
+namespace PixiEditor.ChangeableDocument.Actions.Attributes;
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)]
+internal sealed class GenerateUpdateableChangeActionsAttribute : Attribute { }

+ 3 - 0
src/PixiEditor.ChangeableDocument/Actions/Attributes/UpdateChangeMethodAttribute.cs

@@ -0,0 +1,3 @@
+namespace PixiEditor.ChangeableDocument.Actions.Attributes;
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)]
+internal sealed class UpdateChangeMethodAttribute : Attribute { }

+ 0 - 20
src/PixiEditor.ChangeableDocument/Actions/Drawing/CombineStructureMembersOnto_Action.cs

@@ -1,20 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Drawing;
-
-namespace PixiEditor.ChangeableDocument.Actions.Drawing;
-
-public record class CombineStructureMembersOnto_Action : IMakeChangeAction
-{
-    public CombineStructureMembersOnto_Action(Guid targetLayer, HashSet<Guid> membersToCombine)
-    {
-        TargetLayer = targetLayer;
-        MembersToCombine = membersToCombine;
-    }
-
-    public Guid TargetLayer { get; }
-    public HashSet<Guid> MembersToCombine { get; }
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new CombineStructureMembersOnto_Change(MembersToCombine, TargetLayer);
-    }
-}

+ 0 - 11
src/PixiEditor.ChangeableDocument/Actions/Drawing/PasteImage/EndPasteImage_Action.cs

@@ -1,11 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Drawing;
-
-namespace PixiEditor.ChangeableDocument.Actions.Drawing.PasteImage;
-public record class EndPasteImage_Action : IEndChangeAction
-{
-    bool IEndChangeAction.IsChangeTypeMatching(Change change)
-    {
-        return change is PasteImage_UpdateableChange;
-    }
-}

+ 0 - 31
src/PixiEditor.ChangeableDocument/Actions/Drawing/PasteImage/PasteImage_Action.cs

@@ -1,31 +0,0 @@
-using ChunkyImageLib;
-using ChunkyImageLib.DataHolders;
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Drawing;
-
-namespace PixiEditor.ChangeableDocument.Actions.Drawing.PasteImage;
-public record class PasteImage_Action : IStartOrUpdateChangeAction
-{
-    public PasteImage_Action(Surface image, ShapeCorners corners, Guid layerGuid, bool isDrawingOnMask)
-    {
-        Image = image;
-        Corners = corners;
-        GuidValue = layerGuid;
-        IsDrawingOnMask = isDrawingOnMask;
-    }
-
-    public Surface Image { get; }
-    public ShapeCorners Corners { get; }
-    public Guid GuidValue { get; }
-    public bool IsDrawingOnMask { get; }
-
-    UpdateableChange IStartOrUpdateChangeAction.CreateCorrespondingChange()
-    {
-        return new PasteImage_UpdateableChange(Corners, Image, GuidValue, IsDrawingOnMask);
-    }
-
-    void IStartOrUpdateChangeAction.UpdateCorrespodingChange(UpdateableChange change)
-    {
-        ((PasteImage_UpdateableChange)change).Update(Corners);
-    }
-}

+ 0 - 29
src/PixiEditor.ChangeableDocument/Actions/Drawing/Rectangle/DrawRectangle_Action.cs

@@ -1,29 +0,0 @@
-using ChunkyImageLib.DataHolders;
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Drawing;
-
-namespace PixiEditor.ChangeableDocument.Actions.Drawing.Rectangle;
-
-public record class DrawRectangle_Action : IStartOrUpdateChangeAction
-{
-    public DrawRectangle_Action(Guid layerGuid, ShapeData rectangle, bool drawOnMask)
-    {
-        LayerGuid = layerGuid;
-        Rectangle = rectangle;
-        DrawOnMask = drawOnMask;
-    }
-
-    public Guid LayerGuid { get; }
-    public bool DrawOnMask { get; }
-    public ShapeData Rectangle { get; }
-
-    void IStartOrUpdateChangeAction.UpdateCorrespodingChange(UpdateableChange change)
-    {
-        ((DrawRectangle_UpdateableChange)change).Update(Rectangle);
-    }
-
-    UpdateableChange IStartOrUpdateChangeAction.CreateCorrespondingChange()
-    {
-        return new DrawRectangle_UpdateableChange(LayerGuid, Rectangle, DrawOnMask);
-    }
-}

+ 0 - 12
src/PixiEditor.ChangeableDocument/Actions/Drawing/Rectangle/EndDrawRectangle_Action.cs

@@ -1,12 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Drawing;
-
-namespace PixiEditor.ChangeableDocument.Actions.Drawing.Rectangle;
-
-public record class EndDrawRectangle_Action : IEndChangeAction
-{
-    bool IEndChangeAction.IsChangeTypeMatching(Change change)
-    {
-        return change is DrawRectangle_UpdateableChange;
-    }
-}

+ 0 - 12
src/PixiEditor.ChangeableDocument/Actions/Drawing/Selection/ClearSelection_Action.cs

@@ -1,12 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Drawing;
-
-namespace PixiEditor.ChangeableDocument.Actions.Drawing.Selection;
-
-public record class ClearSelection_Action : IMakeChangeAction
-{
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new ClearSelection_Change();
-    }
-}

+ 0 - 12
src/PixiEditor.ChangeableDocument/Actions/Drawing/Selection/EndSelectRectangle_Action.cs

@@ -1,12 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Drawing;
-
-namespace PixiEditor.ChangeableDocument.Actions.Drawing.Selection;
-
-public record class EndSelectRectangle_Action : IEndChangeAction
-{
-    bool IEndChangeAction.IsChangeTypeMatching(Change change)
-    {
-        return change is SelectRectangle_UpdateableChange;
-    }
-}

+ 0 - 26
src/PixiEditor.ChangeableDocument/Actions/Drawing/Selection/SelectRectangle_Action.cs

@@ -1,26 +0,0 @@
-using ChunkyImageLib.DataHolders;
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Drawing;
-
-namespace PixiEditor.ChangeableDocument.Actions.Drawing.Selection;
-
-public record class SelectRectangle_Action : IStartOrUpdateChangeAction
-{
-    public VecI Pos { get; }
-    public VecI Size { get; }
-    public SelectRectangle_Action(VecI pos, VecI size)
-    {
-        Pos = pos;
-        Size = size;
-    }
-
-    UpdateableChange IStartOrUpdateChangeAction.CreateCorrespondingChange()
-    {
-        return new SelectRectangle_UpdateableChange(Pos, Size);
-    }
-
-    void IStartOrUpdateChangeAction.UpdateCorrespodingChange(UpdateableChange change)
-    {
-        ((SelectRectangle_UpdateableChange)change).Update(Pos, Size);
-    }
-}

+ 0 - 3
src/PixiEditor.ChangeableDocument/Actions/GenerateMakeChangeActionAttribute.cs

@@ -1,3 +0,0 @@
-namespace PixiEditor.ChangeableDocument.Actions;
-[System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)]
-internal sealed class GenerateMakeChangeActionAttribute : Attribute { }

+ 0 - 3
src/PixiEditor.ChangeableDocument/Actions/GenerateUpdateableChangeActionsAttribute.cs

@@ -1,3 +0,0 @@
-namespace PixiEditor.ChangeableDocument.Actions;
-[System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)]
-internal sealed class GenerateUpdateableChangeActionsAttribute : Attribute { }

+ 0 - 19
src/PixiEditor.ChangeableDocument/Actions/Properties/CreateStructureMemberMask_Action.cs

@@ -1,19 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Properties;
-
-namespace PixiEditor.ChangeableDocument.Actions.Properties;
-
-public record class CreateStructureMemberMask_Action : IMakeChangeAction
-{
-    public Guid GuidValue { get; }
-
-    public CreateStructureMemberMask_Action(Guid guidValue)
-    {
-        GuidValue = guidValue;
-    }
-
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new CreateStructureMemberMask_Change(GuidValue);
-    }
-}

+ 0 - 19
src/PixiEditor.ChangeableDocument/Actions/Properties/DeleteStructureMemberMask_Action.cs

@@ -1,19 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Properties;
-
-namespace PixiEditor.ChangeableDocument.Actions.Properties;
-
-public record class DeleteStructureMemberMask_Action : IMakeChangeAction
-{
-    public Guid GuidValue { get; }
-
-    public DeleteStructureMemberMask_Action(Guid guidValue)
-    {
-        GuidValue = guidValue;
-    }
-
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new DeleteStructureMemberMask_Change(GuidValue);
-    }
-}

+ 0 - 9
src/PixiEditor.ChangeableDocument/Actions/Properties/EndOpacityChange_Action.cs

@@ -1,9 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Properties;
-
-namespace PixiEditor.ChangeableDocument.Actions.Properties;
-
-public record class EndOpacityChange_Action : IEndChangeAction
-{
-    bool IEndChangeAction.IsChangeTypeMatching(Change change) => change is StructureMemberOpacity_UpdateableChange;
-}

+ 0 - 26
src/PixiEditor.ChangeableDocument/Actions/Properties/OpacityChange_Action.cs

@@ -1,26 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Properties;
-
-namespace PixiEditor.ChangeableDocument.Actions.Properties;
-
-public record class OpacityChange_Action : IStartOrUpdateChangeAction
-{
-    public OpacityChange_Action(Guid memberGuid, float opacity)
-    {
-        Opacity = opacity;
-        MemberGuid = memberGuid;
-    }
-
-    public Guid MemberGuid { get; }
-    public float Opacity { get; }
-
-    UpdateableChange IStartOrUpdateChangeAction.CreateCorrespondingChange()
-    {
-        return new StructureMemberOpacity_UpdateableChange(MemberGuid, Opacity);
-    }
-
-    void IStartOrUpdateChangeAction.UpdateCorrespodingChange(UpdateableChange change)
-    {
-        ((StructureMemberOpacity_UpdateableChange)change).Update(Opacity);
-    }
-}

+ 0 - 20
src/PixiEditor.ChangeableDocument/Actions/Properties/SetLayerLockTransparency_Action.cs

@@ -1,20 +0,0 @@
-using PixiEditor.ChangeableDocument.ChangeInfos.Properties;
-using PixiEditor.ChangeableDocument.Changes;
-
-namespace PixiEditor.ChangeableDocument.Actions.Properties;
-public record class SetLayerLockTransparency_Action : IMakeChangeAction
-{
-    public SetLayerLockTransparency_Action(Guid guidValue, bool lockTranparency)
-    {
-        GuidValue = guidValue;
-        LockTranparency = lockTranparency;
-    }
-
-    public Guid GuidValue { get; }
-    public bool LockTranparency { get; }
-
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new LayerLockTransparency_Change(GuidValue, LockTranparency);
-    }
-}

+ 0 - 21
src/PixiEditor.ChangeableDocument/Actions/Properties/SetStructureMemberBlendMode_Action.cs

@@ -1,21 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Properties;
-using PixiEditor.ChangeableDocument.Enums;
-
-namespace PixiEditor.ChangeableDocument.Actions.Properties;
-public record class SetStructureMemberBlendMode_Action : IMakeChangeAction
-{
-    public BlendMode BlendMode { get; }
-    public Guid GuidValue { get; }
-
-    public SetStructureMemberBlendMode_Action(BlendMode blendMode, Guid guidValue)
-    {
-        BlendMode = blendMode;
-        GuidValue = guidValue;
-    }
-
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new StructureMemberBlendMode_Change(BlendMode, GuidValue);
-    }
-}

+ 0 - 20
src/PixiEditor.ChangeableDocument/Actions/Properties/SetStructureMemberClipToMemberBelow_Action.cs

@@ -1,20 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Properties;
-
-namespace PixiEditor.ChangeableDocument.Actions.Properties;
-public record class SetStructureMemberClipToMemberBelow_Action : IMakeChangeAction
-{
-    public bool IsEnabled { get; }
-    public Guid GuidValue { get; }
-
-    public SetStructureMemberClipToMemberBelow_Action(bool isEnabled, Guid guidValue)
-    {
-        IsEnabled = isEnabled;
-        GuidValue = guidValue;
-    }
-
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new StructureMemberClipToMemberBelow_Change(IsEnabled, GuidValue);
-    }
-}

+ 0 - 21
src/PixiEditor.ChangeableDocument/Actions/Properties/SetStructureMemberName_Action.cs

@@ -1,21 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Properties;
-
-namespace PixiEditor.ChangeableDocument.Actions.Properties;
-
-public record class SetStructureMemberName_Action : IMakeChangeAction
-{
-    public SetStructureMemberName_Action(string name, Guid guidValue)
-    {
-        Name = name;
-        GuidValue = guidValue;
-    }
-
-    public string Name { get; init; }
-    public Guid GuidValue { get; init; }
-
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new StructureMemberName_Change(GuidValue, Name);
-    }
-}

+ 0 - 21
src/PixiEditor.ChangeableDocument/Actions/Properties/SetStructureMemberVisibility_Action.cs

@@ -1,21 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Properties;
-
-namespace PixiEditor.ChangeableDocument.Actions.Properties;
-
-public record class SetStructureMemberVisibility_Action : IMakeChangeAction
-{
-    public SetStructureMemberVisibility_Action(bool isVisible, Guid guidValue)
-    {
-        this.isVisible = isVisible;
-        GuidValue = guidValue;
-    }
-
-    public bool isVisible { get; init; }
-    public Guid GuidValue { get; init; }
-
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new StructureMemberIsVisible_Change(GuidValue, isVisible);
-    }
-}

+ 0 - 18
src/PixiEditor.ChangeableDocument/Actions/Root/ResizeCanvas_Action.cs

@@ -1,18 +0,0 @@
-using ChunkyImageLib.DataHolders;
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Root;
-
-namespace PixiEditor.ChangeableDocument.Actions.Root;
-
-public record class ResizeCanvas_Action : IMakeChangeAction
-{
-    public VecI Size { get; }
-    public ResizeCanvas_Action(VecI size)
-    {
-        Size = size;
-    }
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new ResizeCanvas_Change(Size);
-    }
-}

+ 0 - 21
src/PixiEditor.ChangeableDocument/Actions/Root/SetSymmetryAxisState_Action.cs

@@ -1,21 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Root;
-using PixiEditor.ChangeableDocument.Enums;
-
-namespace PixiEditor.ChangeableDocument.Actions.Root;
-public record class SetSymmetryAxisState_Action : IMakeChangeAction
-{
-    public SetSymmetryAxisState_Action(SymmetryAxisDirection direction, bool state)
-    {
-        Direction = direction;
-        State = state;
-    }
-
-    public SymmetryAxisDirection Direction { get; }
-    public bool State { get; }
-
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new SymmetryAxisState_Change(Direction, State);
-    }
-}

+ 0 - 11
src/PixiEditor.ChangeableDocument/Actions/Root/SymmetryPosition/EndSetSymmetryAxisPosition_Action.cs

@@ -1,11 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Root;
-
-namespace PixiEditor.ChangeableDocument.Actions.Root.SymmetryPosition;
-public class EndSetSymmetryAxisPosition_Action : IEndChangeAction
-{
-    bool IEndChangeAction.IsChangeTypeMatching(Change change)
-    {
-        return change is SymmetryAxisPosition_UpdateableChange;
-    }
-}

+ 0 - 26
src/PixiEditor.ChangeableDocument/Actions/Root/SymmetryPosition/SetSymmetryAxisPosition_Action.cs

@@ -1,26 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Root;
-using PixiEditor.ChangeableDocument.Enums;
-
-namespace PixiEditor.ChangeableDocument.Actions.Root.SymmetryPosition;
-public class SetSymmetryAxisPosition_Action : IStartOrUpdateChangeAction
-{
-    public SetSymmetryAxisPosition_Action(SymmetryAxisDirection direction, int position)
-    {
-        Direction = direction;
-        Position = position;
-    }
-
-    public SymmetryAxisDirection Direction { get; }
-    public int Position { get; }
-
-    UpdateableChange IStartOrUpdateChangeAction.CreateCorrespondingChange()
-    {
-        return new SymmetryAxisPosition_UpdateableChange(Direction, Position);
-    }
-
-    void IStartOrUpdateChangeAction.UpdateCorrespodingChange(UpdateableChange change)
-    {
-        ((SymmetryAxisPosition_UpdateableChange)change).Update(Position);
-    }
-}

+ 0 - 26
src/PixiEditor.ChangeableDocument/Actions/Structure/CreateStructureMember_Action.cs

@@ -1,26 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Structure;
-using PixiEditor.ChangeableDocument.Enums;
-
-namespace PixiEditor.ChangeableDocument.Actions.Structure;
-
-public record class CreateStructureMember_Action : IMakeChangeAction
-{
-    public CreateStructureMember_Action(Guid parentGuid, Guid newGuid, int index, StructureMemberType type)
-    {
-        ParentGuid = parentGuid;
-        NewGuid = newGuid;
-        Index = index;
-        Type = type;
-    }
-
-    public Guid ParentGuid { get; init; }
-    public Guid NewGuid { get; init; }
-    public int Index { get; init; }
-    public StructureMemberType Type { get; init; }
-
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new CreateStructureMember_Change(ParentGuid, NewGuid, Index, Type);
-    }
-}

+ 0 - 19
src/PixiEditor.ChangeableDocument/Actions/Structure/DeleteStructureMember_Action.cs

@@ -1,19 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Structure;
-
-namespace PixiEditor.ChangeableDocument.Actions.Structure;
-
-public record class DeleteStructureMember_Action : IMakeChangeAction
-{
-    public DeleteStructureMember_Action(Guid guidValue)
-    {
-        GuidValue = guidValue;
-    }
-
-    public Guid GuidValue { get; }
-
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new DeleteStructureMember_Change(GuidValue);
-    }
-}

+ 0 - 23
src/PixiEditor.ChangeableDocument/Actions/Structure/MoveStructureMember_Action.cs

@@ -1,23 +0,0 @@
-using PixiEditor.ChangeableDocument.Changes;
-using PixiEditor.ChangeableDocument.Changes.Structure;
-
-namespace PixiEditor.ChangeableDocument.Actions.Structure;
-
-public record class MoveStructureMember_Action : IMakeChangeAction
-{
-    public MoveStructureMember_Action(Guid member, Guid targetFolder, int index)
-    {
-        Member = member;
-        TargetFolder = targetFolder;
-        Index = index;
-    }
-
-    public Guid Member { get; init; }
-    public Guid TargetFolder { get; init; }
-    public int Index { get; init; }
-
-    Change IMakeChangeAction.CreateCorrespondingChange()
-    {
-        return new MoveStructureMember_Change(Member, TargetFolder, Index);
-    }
-}

+ 0 - 3
src/PixiEditor.ChangeableDocument/Actions/UpdateChangeMethodAttribute.cs

@@ -1,3 +0,0 @@
-namespace PixiEditor.ChangeableDocument.Actions;
-[System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)]
-internal sealed class UpdateChangeMethodAttribute : Attribute { }

+ 4 - 0
src/PixiEditor.ChangeableDocument/Changes/Drawing/ClearSelection_Change.cs

@@ -12,6 +12,10 @@ internal class ClearSelection_Change : Change
     private bool originalIsEmpty;
     private CommittedChunkStorage? savedSelection;
     private SKPath? originalPath;
+
+    [GenerateMakeChangeAction]
+    public ClearSelection_Change() { }
+
     public override void Initialize(Document target)
     {
         originalIsEmpty = target.Selection.IsEmptyAndInactive;

+ 1 - 0
src/PixiEditor.ChangeableDocument/Changes/Drawing/CombineStructureMembersOnto_Change.cs

@@ -17,6 +17,7 @@ internal class CombineStructureMembersOnto_Change : Change
     private Guid targetLayer;
     private CommittedChunkStorage? originalChunks;
 
+    [GenerateMakeChangeAction]
     public CombineStructureMembersOnto_Change(HashSet<Guid> membersToMerge, Guid targetLayer)
     {
         this.membersToMerge = new HashSet<Guid>(membersToMerge);

+ 6 - 2
src/PixiEditor.ChangeableDocument/Changes/Drawing/DrawRectangle_UpdateableChange.cs

@@ -1,5 +1,6 @@
 using ChunkyImageLib;
 using ChunkyImageLib.DataHolders;
+using PixiEditor.ChangeableDocument.Actions;
 using PixiEditor.ChangeableDocument.Changeables;
 using PixiEditor.ChangeableDocument.ChangeInfos;
 
@@ -11,6 +12,8 @@ internal class DrawRectangle_UpdateableChange : UpdateableChange
     private ShapeData rect;
     private readonly bool drawOnMask;
     private CommittedChunkStorage? storedChunks;
+
+    [GenerateUpdateableChangeActions]
     public DrawRectangle_UpdateableChange(Guid memberGuid, ShapeData rectangle, bool drawOnMask)
     {
         this.memberGuid = memberGuid;
@@ -18,9 +21,10 @@ internal class DrawRectangle_UpdateableChange : UpdateableChange
         this.drawOnMask = drawOnMask;
     }
 
-    public void Update(ShapeData updatedRectangle)
+    [UpdateChangeMethod]
+    public void Update(ShapeData rectangle)
     {
-        rect = updatedRectangle;
+        rect = rectangle;
     }
 
     private HashSet<VecI> UpdateRectangle(Document target, ChunkyImage targetImage)

+ 8 - 5
src/PixiEditor.ChangeableDocument/Changes/Drawing/PasteImage_UpdateableChange.cs

@@ -1,5 +1,6 @@
 using ChunkyImageLib;
 using ChunkyImageLib.DataHolders;
+using PixiEditor.ChangeableDocument.Actions;
 using PixiEditor.ChangeableDocument.Changeables;
 using PixiEditor.ChangeableDocument.ChangeInfos;
 
@@ -14,17 +15,19 @@ internal class PasteImage_UpdateableChange : UpdateableChange
 
     private bool hasEnqueudImage = false;
 
-    public PasteImage_UpdateableChange(ShapeCorners corners, Surface imageToPaste, Guid memberGuid, bool drawOnMask)
+    [GenerateUpdateableChangeActions]
+    public PasteImage_UpdateableChange(Surface image, ShapeCorners corners, Guid memberGuid, bool isDrawingOnMask)
     {
         this.corners = corners;
         this.memberGuid = memberGuid;
-        this.drawOnMask = drawOnMask;
-        this.imageToPaste = new Surface(imageToPaste);
+        this.drawOnMask = isDrawingOnMask;
+        this.imageToPaste = new Surface(image);
     }
 
-    public void Update(ShapeCorners newCorners)
+    [UpdateChangeMethod]
+    public void Update(ShapeCorners corners)
     {
-        corners = newCorners;
+        this.corners = corners;
     }
 
     private HashSet<VecI> DrawImage(Document target, ChunkyImage targetImage)

+ 4 - 0
src/PixiEditor.ChangeableDocument/Changes/Drawing/SelectRectangle_UpdateableChange.cs

@@ -1,5 +1,6 @@
 using ChunkyImageLib;
 using ChunkyImageLib.DataHolders;
+using PixiEditor.ChangeableDocument.Actions;
 using PixiEditor.ChangeableDocument.Changeables;
 using PixiEditor.ChangeableDocument.ChangeInfos;
 using PixiEditor.ChangeableDocument.ChangeInfos.Drawing;
@@ -14,6 +15,8 @@ internal class SelectRectangle_UpdateableChange : UpdateableChange
     private VecI size;
     private CommittedChunkStorage? originalSelectionState;
     private SKPath? originalPath;
+
+    [GenerateUpdateableChangeActions]
     public SelectRectangle_UpdateableChange(VecI pos, VecI size)
     {
         Update(pos, size);
@@ -24,6 +27,7 @@ internal class SelectRectangle_UpdateableChange : UpdateableChange
         originalPath = new SKPath(target.Selection.SelectionPath);
     }
 
+    [UpdateChangeMethod]
     public void Update(VecI pos, VecI size)
     {
         this.pos = pos;

+ 2 - 0
src/PixiEditor.ChangeableDocument/Changes/Properties/CreateStructureMemberMask_Change.cs

@@ -8,6 +8,8 @@ namespace PixiEditor.ChangeableDocument.Changes.Properties;
 internal class CreateStructureMemberMask_Change : Change
 {
     private Guid targetMember;
+
+    [GenerateMakeChangeAction]
     public CreateStructureMemberMask_Change(Guid memberGuid)
     {
         targetMember = memberGuid;

+ 1 - 0
src/PixiEditor.ChangeableDocument/Changes/Properties/DeleteStructureMemberMask_Change.cs

@@ -10,6 +10,7 @@ internal class DeleteStructureMemberMask_Change : Change
     private readonly Guid memberGuid;
     private ChunkyImage? storedMask;
 
+    [GenerateMakeChangeAction]
     public DeleteStructureMemberMask_Change(Guid memberGuid)
     {
         this.memberGuid = memberGuid;

+ 4 - 2
src/PixiEditor.ChangeableDocument/ChangeInfos/Properties/LayerLockTransparency_Change.cs → src/PixiEditor.ChangeableDocument/Changes/Properties/LayerLockTransparency_Change.cs

@@ -1,13 +1,15 @@
 using PixiEditor.ChangeableDocument.Changeables;
-using PixiEditor.ChangeableDocument.Changes;
+using PixiEditor.ChangeableDocument.ChangeInfos;
+using PixiEditor.ChangeableDocument.ChangeInfos.Properties;
 
-namespace PixiEditor.ChangeableDocument.ChangeInfos.Properties;
+namespace PixiEditor.ChangeableDocument.Changes.Properties;
 internal class LayerLockTransparency_Change : Change
 {
     private readonly Guid layerGuid;
     private bool originalValue;
     private readonly bool newValue;
 
+    [GenerateMakeChangeAction]
     public LayerLockTransparency_Change(Guid layerGuid, bool newValue)
     {
         this.layerGuid = layerGuid;

+ 4 - 3
src/PixiEditor.ChangeableDocument/Changes/Properties/StructureMemberBlendMode_Change.cs

@@ -10,10 +10,11 @@ internal class StructureMemberBlendMode_Change : Change
     private readonly BlendMode newBlendMode;
     private readonly Guid targetGuid;
 
-    public StructureMemberBlendMode_Change(BlendMode newBlendMode, Guid targetGuid)
+    [GenerateMakeChangeAction]
+    public StructureMemberBlendMode_Change(BlendMode blendMode, Guid memberGuid)
     {
-        this.newBlendMode = newBlendMode;
-        this.targetGuid = targetGuid;
+        this.newBlendMode = blendMode;
+        this.targetGuid = memberGuid;
     }
 
     public override void Initialize(Document target)

+ 3 - 2
src/PixiEditor.ChangeableDocument/Changes/Properties/StructureMemberClipToMemberBelow_Change.cs

@@ -9,9 +9,10 @@ internal class StructureMemberClipToMemberBelow_Change : Change
     private readonly bool newValue;
     private readonly Guid memberGuid;
 
-    public StructureMemberClipToMemberBelow_Change(bool newValue, Guid memberGuid)
+    [GenerateMakeChangeAction]
+    public StructureMemberClipToMemberBelow_Change(bool enabled, Guid memberGuid)
     {
-        this.newValue = newValue;
+        this.newValue = enabled;
         this.memberGuid = memberGuid;
     }
 

+ 4 - 3
src/PixiEditor.ChangeableDocument/Changes/Properties/StructureMemberIsVisible_Change.cs

@@ -9,10 +9,11 @@ internal class StructureMemberIsVisible_Change : Change
     private bool? originalIsVisible;
     private bool newIsVisible;
     private Guid targetMember;
-    public StructureMemberIsVisible_Change(Guid targetMember, bool newIsVisible)
+    [GenerateMakeChangeAction]
+    public StructureMemberIsVisible_Change(bool isVisible, Guid memberGuid)
     {
-        this.targetMember = targetMember;
-        this.newIsVisible = newIsVisible;
+        this.targetMember = memberGuid;
+        this.newIsVisible = isVisible;
     }
 
     public override void Initialize(Document target)

+ 5 - 3
src/PixiEditor.ChangeableDocument/Changes/Properties/StructureMemberName_Change.cs

@@ -9,10 +9,12 @@ internal class StructureMemberName_Change : Change
     private string? originalName;
     private string newName;
     private Guid targetMember;
-    public StructureMemberName_Change(Guid targetMember, string newName)
+
+    [GenerateMakeChangeAction]
+    public StructureMemberName_Change(Guid memberGuid, string name)
     {
-        this.targetMember = targetMember;
-        this.newName = newName;
+        this.targetMember = memberGuid;
+        this.newName = name;
     }
 
     public override void Initialize(Document target)

+ 6 - 3
src/PixiEditor.ChangeableDocument/Changes/Properties/StructureMemberOpacity_UpdateableChange.cs

@@ -1,4 +1,5 @@
-using PixiEditor.ChangeableDocument.Changeables;
+using PixiEditor.ChangeableDocument.Actions;
+using PixiEditor.ChangeableDocument.Changeables;
 using PixiEditor.ChangeableDocument.ChangeInfos;
 using PixiEditor.ChangeableDocument.ChangeInfos.Properties;
 
@@ -11,15 +12,17 @@ internal class StructureMemberOpacity_UpdateableChange : UpdateableChange
     private float originalOpacity;
     private float newOpacity;
 
+    [GenerateUpdateableChangeActions]
     public StructureMemberOpacity_UpdateableChange(Guid memberGuid, float opacity)
     {
         this.memberGuid = memberGuid;
         newOpacity = opacity;
     }
 
-    public void Update(float updatedOpacity)
+    [UpdateChangeMethod]
+    public void Update(float opacity)
     {
-        newOpacity = updatedOpacity;
+        newOpacity = opacity;
     }
 
     public override void Initialize(Document document)

+ 2 - 0
src/PixiEditor.ChangeableDocument/Changes/Root/ResizeCanvas_Change.cs

@@ -15,6 +15,8 @@ internal class ResizeCanvas_Change : Change
     private Dictionary<Guid, CommittedChunkStorage> deletedMaskChunks = new();
     private CommittedChunkStorage? selectionChunkStorage;
     private VecI newSize;
+
+    [GenerateMakeChangeAction]
     public ResizeCanvas_Change(VecI size)
     {
         newSize = size;

+ 2 - 0
src/PixiEditor.ChangeableDocument/Changes/Root/SymmetryAxisPosition_UpdateableChange.cs

@@ -10,12 +10,14 @@ internal class SymmetryAxisPosition_UpdateableChange : UpdateableChange
     private int newPos;
     private int originalPos;
 
+    [GenerateUpdateableChangeActions]
     public SymmetryAxisPosition_UpdateableChange(SymmetryAxisDirection direction, int pos)
     {
         this.direction = direction;
         newPos = pos;
     }
 
+    [UpdateChangeMethod]
     public void Update(int pos)
     {
         newPos = pos;

+ 1 - 0
src/PixiEditor.ChangeableDocument/Changes/Root/SymmetryAxisState_Change.cs

@@ -10,6 +10,7 @@ internal class SymmetryAxisState_Change : Change
     private readonly bool newEnabled;
     private bool originalEnabled;
 
+    [GenerateMakeChangeAction]
     public SymmetryAxisState_Change(SymmetryAxisDirection direction, bool enabled)
     {
         this.direction = direction;

+ 1 - 0
src/PixiEditor.ChangeableDocument/Changes/Structure/CreateStructureMember_Change.cs

@@ -13,6 +13,7 @@ internal class CreateStructureMember_Change : Change
     private int parentFolderIndex;
     private StructureMemberType type;
 
+    [GenerateMakeChangeAction]
     public CreateStructureMember_Change(Guid parentFolder, Guid newGuid, int parentFolderIndex, StructureMemberType type)
     {
         this.parentFolderGuid = parentFolder;

+ 2 - 0
src/PixiEditor.ChangeableDocument/Changes/Structure/DeleteStructureMember_Change.cs

@@ -10,6 +10,8 @@ internal class DeleteStructureMember_Change : Change
     private Guid parentGuid;
     private int originalIndex;
     private StructureMember? savedCopy;
+
+    [GenerateMakeChangeAction]
     public DeleteStructureMember_Change(Guid memberGuid)
     {
         this.memberGuid = memberGuid;

+ 1 - 0
src/PixiEditor.ChangeableDocument/Changes/Structure/MoveStructureMember_Change.cs

@@ -14,6 +14,7 @@ internal class MoveStructureMember_Change : Change
     private Guid originalFolderGuid;
     private int originalFolderIndex;
 
+    [GenerateMakeChangeAction]
     public MoveStructureMember_Change(Guid memberGuid, Guid targetFolder, int targetFolderIndex)
     {
         this.memberGuid = memberGuid;

+ 1 - 0
src/PixiEditor.ChangeableDocument/GlobalUsings.cs

@@ -0,0 +1 @@
+global using PixiEditor.ChangeableDocument.Actions.Attributes;

+ 1 - 4
src/PixiEditor.ChangeableDocument/PixiEditor.ChangeableDocument.csproj

@@ -9,10 +9,7 @@
 
   <ItemGroup>
     <ProjectReference Include="..\ChunkyImageLib\ChunkyImageLib.csproj" />
-    <ProjectReference 
-      Include="..\PixiEditor.ChangeableDocument.Gen\PixiEditor.ChangeableDocument.Gen.csproj" 
-      OutputItemType="Analyzer" 
-      ReferenceOutputAssembly="false"/>
+    <ProjectReference Include="..\PixiEditor.ChangeableDocument.Gen\PixiEditor.ChangeableDocument.Gen.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
   </ItemGroup>
 
 </Project>

+ 1 - 0
src/PixiEditorPrototype/GlobalUsings.cs

@@ -0,0 +1 @@
+global using PixiEditor.ChangeableDocument.Actions.Generated;

+ 0 - 1
src/PixiEditorPrototype/Models/DocumentStructureHelper.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using PixiEditor.ChangeableDocument.Actions.Structure;
 using PixiEditor.ChangeableDocument.Enums;
 using PixiEditorPrototype.ViewModels;
 

+ 6 - 6
src/PixiEditorPrototype/Models/Rendering/AffectedChunkGatherer.cs

@@ -91,7 +91,7 @@ internal class AffectedChunkGatherer
 
     private void AddAllToImagePreviews(Guid memberGuid, bool ignoreSelf = false)
     {
-        var member = tracker.Document.FindMemberOrThrow(memberGuid);
+        var member = tracker.Document.FindMember(memberGuid);
         if (member is IReadOnlyLayer layer)
         {
             var chunks = layer.ReadOnlyLayerImage.FindAllChunks();
@@ -104,7 +104,7 @@ internal class AffectedChunkGatherer
     }
     private void AddAllToMainImage(Guid memberGuid)
     {
-        var member = tracker.Document.FindMemberOrThrow(memberGuid);
+        var member = tracker.Document.FindMember(memberGuid);
         if (member is IReadOnlyLayer layer)
         {
             var chunks = layer.ReadOnlyLayerImage.FindAllChunks();
@@ -119,8 +119,8 @@ internal class AffectedChunkGatherer
     }
     private void AddAllToMaskPreview(Guid memberGuid)
     {
-        var member = tracker.Document.FindMemberOrThrow(memberGuid);
-        if (member.ReadOnlyMask is null)
+        var member = tracker.Document.FindMember(memberGuid);
+        if (member is null || member.ReadOnlyMask is null)
             return;
         var chunks = member.ReadOnlyMask.FindAllChunks();
         AddToMaskPreview(memberGuid, chunks);
@@ -135,7 +135,7 @@ internal class AffectedChunkGatherer
     {
         var path = tracker.Document.FindMemberPath(memberGuid);
         if (path.Count < 2)
-            throw new ArgumentException($"Member with guid {memberGuid} was not found");
+            return;
         for (int i = ignoreSelf ? 1 : 0; i < path.Count - 1; i++)
         {
             var member = path[i];
@@ -162,7 +162,7 @@ internal class AffectedChunkGatherer
     {
         var path = tracker.Document.FindMemberPath(memberGuid);
         if (path.Count < 2)
-            throw new ArgumentException($"Member with guid {memberGuid} was not found");
+            return;
         // skip root folder
         for (int i = ignoreSelf ? 1 : 0; i < path.Count - 1; i++)
         {

+ 6 - 14
src/PixiEditorPrototype/ViewModels/DocumentViewModel.cs

@@ -8,14 +8,6 @@ using System.Windows.Media.Imaging;
 using ChunkyImageLib;
 using ChunkyImageLib.DataHolders;
 using Microsoft.Win32;
-using PixiEditor.ChangeableDocument.Actions.Drawing;
-using PixiEditor.ChangeableDocument.Actions.Drawing.PasteImage;
-using PixiEditor.ChangeableDocument.Actions.Drawing.Rectangle;
-using PixiEditor.ChangeableDocument.Actions.Drawing.Selection;
-using PixiEditor.ChangeableDocument.Actions.Properties;
-using PixiEditor.ChangeableDocument.Actions.Root;
-using PixiEditor.ChangeableDocument.Actions.Root.SymmetryPosition;
-using PixiEditor.ChangeableDocument.Actions.Structure;
 using PixiEditor.ChangeableDocument.Actions.Undo;
 using PixiEditor.ChangeableDocument.Enums;
 using PixiEditorPrototype.CustomControls.SymmetryOverlay;
@@ -84,12 +76,12 @@ internal class DocumentViewModel : INotifyPropertyChanged
     public bool HorizontalSymmetryAxisEnabled
     {
         get => Helpers.Tracker.Document.HorizontalSymmetryAxisEnabled;
-        set => Helpers.ActionAccumulator.AddFinishedActions(new SetSymmetryAxisState_Action(SymmetryAxisDirection.Horizontal, value));
+        set => Helpers.ActionAccumulator.AddFinishedActions(new SymmetryAxisState_Action(SymmetryAxisDirection.Horizontal, value));
     }
     public bool VerticalSymmetryAxisEnabled
     {
         get => Helpers.Tracker.Document.VerticalSymmetryAxisEnabled;
-        set => Helpers.ActionAccumulator.AddFinishedActions(new SetSymmetryAxisState_Action(SymmetryAxisDirection.Vertical, value));
+        set => Helpers.ActionAccumulator.AddFinishedActions(new SymmetryAxisState_Action(SymmetryAxisDirection.Vertical, value));
     }
 
     public int ResizeWidth { get; set; }
@@ -163,14 +155,14 @@ internal class DocumentViewModel : INotifyPropertyChanged
         if (obj is null)
             return;
         var info = (SymmetryAxisDragInfo)obj;
-        Helpers.ActionAccumulator.AddActions(new SetSymmetryAxisPosition_Action(info.Direction, info.NewPosition));
+        Helpers.ActionAccumulator.AddActions(new SymmetryAxisPosition_Action(info.Direction, info.NewPosition));
     }
 
     private void EndDragSymmetry(object? obj)
     {
         if (obj is null)
             return;
-        Helpers.ActionAccumulator.AddFinishedActions(new EndSetSymmetryAxisPosition_Action());
+        Helpers.ActionAccumulator.AddFinishedActions(new EndSymmetryAxisPosition_Action());
     }
 
     public void StartUpdateRectangle(ShapeData data)
@@ -361,8 +353,8 @@ internal class DocumentViewModel : INotifyPropertyChanged
         //make a new layer, put combined image onto it, delete layers that were merged
         Helpers.ActionAccumulator.AddActions(
             new CreateStructureMember_Action(parent.GuidValue, newGuid, index, StructureMemberType.Layer),
-            new SetStructureMemberName_Action(child.Name + "-comb", newGuid),
-            new CombineStructureMembersOnto_Action(newGuid, selected.ToHashSet()));
+            new StructureMemberName_Action(newGuid, child.Name + "-comb"),
+            new CombineStructureMembersOnto_Action(selected.ToHashSet(), newGuid));
         foreach (var member in selected)
             Helpers.ActionAccumulator.AddActions(new DeleteStructureMember_Action(member));
         Helpers.ActionAccumulator.AddActions(new ChangeBoundary_Action());

+ 2 - 3
src/PixiEditorPrototype/ViewModels/LayerViewModel.cs

@@ -1,5 +1,4 @@
-using PixiEditor.ChangeableDocument.Actions.Properties;
-using PixiEditor.ChangeableDocument.Changeables.Interfaces;
+using PixiEditor.ChangeableDocument.Changeables.Interfaces;
 using PixiEditorPrototype.Models;
 
 namespace PixiEditorPrototype.ViewModels;
@@ -9,7 +8,7 @@ internal class LayerViewModel : StructureMemberViewModel
     public bool LockTransparency
     {
         get => ((IReadOnlyLayer)member).LockTransparency;
-        set => Helpers.ActionAccumulator.AddFinishedActions(new SetLayerLockTransparency_Action(member.GuidValue, value));
+        set => Helpers.ActionAccumulator.AddFinishedActions(new LayerLockTransparency_Action(member.GuidValue, value));
     }
     public LayerViewModel(DocumentViewModel doc, DocumentHelpers helpers, IReadOnlyLayer layer) : base(doc, helpers, layer)
     {

+ 6 - 7
src/PixiEditorPrototype/ViewModels/StructureMemberViewModel.cs

@@ -3,7 +3,6 @@ using System.ComponentModel;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using ChunkyImageLib.DataHolders;
-using PixiEditor.ChangeableDocument.Actions.Properties;
 using PixiEditor.ChangeableDocument.Changeables.Interfaces;
 using PixiEditor.ChangeableDocument.Enums;
 using PixiEditorPrototype.Models;
@@ -22,25 +21,25 @@ internal abstract class StructureMemberViewModel : INotifyPropertyChanged
     public string Name
     {
         get => member.Name;
-        set => Helpers.ActionAccumulator.AddFinishedActions(new SetStructureMemberName_Action(value, member.GuidValue));
+        set => Helpers.ActionAccumulator.AddFinishedActions(new StructureMemberName_Action(member.GuidValue, value));
     }
 
     public bool IsVisible
     {
         get => member.IsVisible;
-        set => Helpers.ActionAccumulator.AddFinishedActions(new SetStructureMemberVisibility_Action(value, member.GuidValue));
+        set => Helpers.ActionAccumulator.AddFinishedActions(new StructureMemberIsVisible_Action(value, member.GuidValue));
     }
 
     public BlendMode BlendMode
     {
         get => member.BlendMode;
-        set => Helpers.ActionAccumulator.AddFinishedActions(new SetStructureMemberBlendMode_Action(value, member.GuidValue));
+        set => Helpers.ActionAccumulator.AddFinishedActions(new StructureMemberBlendMode_Action(value, member.GuidValue));
     }
 
     public bool ClipToMemberBelowEnabled
     {
         get => member.ClipToMemberBelow;
-        set => Helpers.ActionAccumulator.AddFinishedActions(new SetStructureMemberClipToMemberBelow_Action(value, member.GuidValue));
+        set => Helpers.ActionAccumulator.AddFinishedActions(new StructureMemberClipToMemberBelow_Action(value, member.GuidValue));
     }
 
     public bool IsSelected { get; set; }
@@ -101,13 +100,13 @@ internal abstract class StructureMemberViewModel : INotifyPropertyChanged
 
     private void EndOpacityUpdate(object? opacity)
     {
-        Helpers.ActionAccumulator.AddFinishedActions(new EndOpacityChange_Action());
+        Helpers.ActionAccumulator.AddFinishedActions(new EndStructureMemberOpacity_Action());
     }
 
     private void UpdateOpacity(object? opacity)
     {
         if (opacity is not double value)
             throw new ArgumentException("The passed value isn't a double");
-        Helpers.ActionAccumulator.AddActions(new OpacityChange_Action(GuidValue, (float)value));
+        Helpers.ActionAccumulator.AddActions(new StructureMemberOpacity_Action(GuidValue, (float)value));
     }
 }