Browse Source

Fixed paste image not being interruptable

Krzysztof Krysiński 2 months ago
parent
commit
48c659dead

+ 1 - 1
src/PixiEditor.ChangeableDocument/Changes/Drawing/PasteImage_UpdateableChange.cs

@@ -4,7 +4,7 @@ using Drawie.Backend.Core.Surfaces;
 using Drawie.Backend.Core.Surfaces.PaintImpl;
 using Drawie.Backend.Core.Surfaces.PaintImpl;
 
 
 namespace PixiEditor.ChangeableDocument.Changes.Drawing;
 namespace PixiEditor.ChangeableDocument.Changes.Drawing;
-internal class PasteImage_UpdateableChange : UpdateableChange
+internal class PasteImage_UpdateableChange : InterruptableUpdateableChange
 {
 {
     private ShapeCorners corners;
     private ShapeCorners corners;
     private readonly Guid memberGuid;
     private readonly Guid memberGuid;

+ 2 - 0
src/PixiEditor/Models/Controllers/ClipboardController.cs

@@ -215,6 +215,8 @@ internal static class ClipboardController
                 }
                 }
             }
             }
 
 
+            manager.Owner.ToolsSubViewModel.SetActiveTool<MoveToolViewModel>(false);
+
             return true;
             return true;
         }
         }
 
 

+ 2 - 0
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/PasteImageExecutor.cs

@@ -17,6 +17,8 @@ internal class PasteImageExecutor : UpdateableChangeExecutor, ITransformableExec
     private bool drawOnMask;
     private bool drawOnMask;
     private Guid? memberGuid;
     private Guid? memberGuid;
 
 
+    public override bool BlocksOtherActions => false;
+
     public PasteImageExecutor(Surface image, VecI pos)
     public PasteImageExecutor(Surface image, VecI pos)
     {
     {
         this.image = image;
         this.image = image;

+ 6 - 2
src/PixiEditor/ViewModels/SubViewModels/ClipboardViewModel.cs

@@ -87,7 +87,11 @@ internal class ClipboardViewModel : SubViewModel<ViewModelMain>
             Guid[] guids = doc.StructureHelper.GetAllLayers().Select(x => x.Id).ToArray();
             Guid[] guids = doc.StructureHelper.GetAllLayers().Select(x => x.Id).ToArray();
             await ClipboardController.TryPasteFromClipboard(doc, Owner.DocumentManagerSubViewModel, pasteAsNewLayer);
             await ClipboardController.TryPasteFromClipboard(doc, Owner.DocumentManagerSubViewModel, pasteAsNewLayer);
 
 
-            doc.Operations.InvokeCustomAction(() =>
+            // Leaving the code below commented out in case something breaks.
+            // It instantly ended paste image operation after I made it interruptable,
+            // I did test it, and it seems everything works fine without it.
+            /*doc.Operations.InvokeCustomAction(
+                () =>
             {
             {
                 Guid[] newGuids = doc.StructureHelper.GetAllLayers().Select(x => x.Id).ToArray();
                 Guid[] newGuids = doc.StructureHelper.GetAllLayers().Select(x => x.Id).ToArray();
 
 
@@ -102,7 +106,7 @@ internal class ClipboardViewModel : SubViewModel<ViewModelMain>
                         doc.Operations.AddSoftSelectedMember(diff[i]);
                         doc.Operations.AddSoftSelectedMember(diff[i]);
                     }
                     }
                 }
                 }
-            });
+            }, false);*/
         });
         });
     }
     }