Browse Source

Fixed too early color swapping

flabbet 11 months ago
parent
commit
8cbbfda951

+ 1 - 3
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/ShapeToolExecutor.cs

@@ -2,8 +2,6 @@
 using PixiEditor.Helpers.Extensions;
 using PixiEditor.Helpers.Extensions;
 using PixiEditor.ChangeableDocument.Actions;
 using PixiEditor.ChangeableDocument.Actions;
 using PixiEditor.DrawingApi.Core.ColorsImpl;
 using PixiEditor.DrawingApi.Core.ColorsImpl;
-using PixiEditor.DrawingApi.Core.Numerics;
-using PixiEditor.Extensions.CommonApi.Palettes;
 using PixiEditor.Models.Handlers;
 using PixiEditor.Models.Handlers;
 using PixiEditor.Models.Handlers.Toolbars;
 using PixiEditor.Models.Handlers.Toolbars;
 using PixiEditor.Models.Handlers.Tools;
 using PixiEditor.Models.Handlers.Tools;
@@ -31,7 +29,7 @@ internal abstract class ShapeToolExecutor<T> : UpdateableChangeExecutor where T
     private bool noMovement = true;
     private bool noMovement = true;
     private IBasicShapeToolbar toolbar;
     private IBasicShapeToolbar toolbar;
     private IColorsHandler? colorsVM;
     private IColorsHandler? colorsVM;
-
+    
     public override ExecutionState Start()
     public override ExecutionState Start()
     {
     {
         colorsVM = GetHandler<IColorsHandler>();
         colorsVM = GetHandler<IColorsHandler>();

+ 10 - 1
src/PixiEditor/ViewModels/SubViewModels/IoViewModel.cs

@@ -3,6 +3,7 @@ using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Controls;
 using Avalonia.Controls.ApplicationLifetimes;
 using Avalonia.Controls.ApplicationLifetimes;
 using Avalonia.Input;
 using Avalonia.Input;
+using Avalonia.Threading;
 using CommunityToolkit.Mvvm.Input;
 using CommunityToolkit.Mvvm.Input;
 using PixiDocks.Avalonia.Controls;
 using PixiDocks.Avalonia.Controls;
 using PixiEditor.Models.Preferences;
 using PixiEditor.Models.Preferences;
@@ -208,7 +209,15 @@ internal class IoViewModel : SubViewModel<ViewModelMain>
         {
         {
             case RightClickMode.SecondaryColor when tools.ActiveTool.UsesColor:
             case RightClickMode.SecondaryColor when tools.ActiveTool.UsesColor:
             case RightClickMode.Erase when tools.ActiveTool is ColorPickerToolViewModel:
             case RightClickMode.Erase when tools.ActiveTool is ColorPickerToolViewModel:
-                Owner.ColorsSubViewModel.SwapColors(null);
+                if (!Owner.DocumentManagerSubViewModel.ActiveDocument.UpdateableChangeActive)
+                {
+                    Owner.ColorsSubViewModel.SwapColors(null);
+                }
+                else
+                {
+                    Owner.DocumentManagerSubViewModel.ActiveDocument.FinishedChange += FinishedChange;
+                }
+
                 hadSwapped = true;
                 hadSwapped = true;
                 return true;
                 return true;
             case RightClickMode.Erase when tools.ActiveTool.IsErasable:
             case RightClickMode.Erase when tools.ActiveTool.IsErasable: