Browse Source

Fixed interrupting transform selected

flabbet 8 months ago
parent
commit
0318725327

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

@@ -12,7 +12,7 @@ using Drawie.Numerics;
 
 
 namespace PixiEditor.ChangeableDocument.Changes.Drawing;
 namespace PixiEditor.ChangeableDocument.Changes.Drawing;
 
 
-internal class TransformSelected_UpdateableChange : UpdateableChange
+internal class TransformSelected_UpdateableChange : InterruptableUpdateableChange
 {
 {
     private readonly bool drawOnMask;
     private readonly bool drawOnMask;
     private bool keepOriginal;
     private bool keepOriginal;

+ 28 - 3
src/PixiEditor.ChangeableDocument/DocumentChangeTracker.cs

@@ -203,11 +203,30 @@ public class DocumentChangeTracker : IDisposable
     private OneOf<None, IChangeInfo, List<IChangeInfo>> ProcessMakeChangeAction(IMakeChangeAction act,
     private OneOf<None, IChangeInfo, List<IChangeInfo>> ProcessMakeChangeAction(IMakeChangeAction act,
         ActionSource source)
         ActionSource source)
     {
     {
-        if (activeUpdateableChange is not null)
+        if (activeUpdateableChange is not null && activeUpdateableChange is not InterruptableUpdateableChange)
         {
         {
             Trace.WriteLine($"Attempted to execute make change action {act} while {activeUpdateableChange} is active");
             Trace.WriteLine($"Attempted to execute make change action {act} while {activeUpdateableChange} is active");
             return new None();
             return new None();
         }
         }
+        
+        bool ignoreInUndo = false;
+        List<IChangeInfo> changeInfos = new();
+
+        if (activeUpdateableChange is InterruptableUpdateableChange interruptable)
+        {
+            var applyInfo = interruptable.Apply(document, false, out ignoreInUndo);
+            if (!ignoreInUndo)
+                AddToUndo(interruptable, source);
+            else
+                interruptable.Dispose();
+            
+            applyInfo.Switch(
+                static (None _) => { },
+                (IChangeInfo info) => changeInfos.Add(info),
+                (List<IChangeInfo> infos) => changeInfos.AddRange(infos));
+            
+            activeUpdateableChange = null;
+        }
 
 
         var change = act.CreateCorrespondingChange();
         var change = act.CreateCorrespondingChange();
         var validationResult = change.InitializeAndValidate(document);
         var validationResult = change.InitializeAndValidate(document);
@@ -218,12 +237,18 @@ public class DocumentChangeTracker : IDisposable
             return new None();
             return new None();
         }
         }
 
 
-        var info = change.Apply(document, true, out bool ignoreInUndo);
+        var info = change.Apply(document, true, out ignoreInUndo);
+        
+        info.Switch(
+            static (None _) => { },
+            (IChangeInfo changeInfo) => changeInfos.Add(changeInfo),
+            (List<IChangeInfo> infos) => changeInfos.AddRange(infos));
+        
         if (!ignoreInUndo)
         if (!ignoreInUndo)
             AddToUndo(change, source);
             AddToUndo(change, source);
         else
         else
             change.Dispose();
             change.Dispose();
-        return info;
+        return changeInfos;
     }
     }
 
 
     private OneOf<None, IChangeInfo, List<IChangeInfo>> ProcessStartOrUpdateChangeAction(IStartOrUpdateChangeAction act,
     private OneOf<None, IChangeInfo, List<IChangeInfo>> ProcessStartOrUpdateChangeAction(IStartOrUpdateChangeAction act,

+ 1 - 1
src/PixiEditor/Views/Shortcuts/KeyCombinationBox.axaml.cs

@@ -52,7 +52,7 @@ internal partial class KeyCombinationBox : UserControl
 
 
         ViewModelMain.Current.LocalizationProvider.OnLanguageChanged += _ => UpdateText();
         ViewModelMain.Current.LocalizationProvider.OnLanguageChanged += _ => UpdateText();
 
 
-        //TOOD: Fix
+        //TODO: Fix
         //InputLanguageManager.Current.InputLanguageChanged += (_, _) => UpdateText();
         //InputLanguageManager.Current.InputLanguageChanged += (_, _) => UpdateText();
     }
     }