Ver Fonte

Introduce FloodFillMode

Francespo há 2 semanas atrás
pai
commit
b737d2a61d

+ 4 - 1
src/PixiEditor.ChangeableDocument/Changes/Drawing/FloodFill/FloodFill_Change.cs

@@ -3,6 +3,7 @@ using Drawie.Backend.Core.Numerics;
 using Drawie.Backend.Core.Vector;
 using Drawie.Backend.Core.Vector;
 using Drawie.Numerics;
 using Drawie.Numerics;
 using PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
 using PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
+using PixiEditor.ChangeableDocument.Enums;
 
 
 namespace PixiEditor.ChangeableDocument.Changes.Drawing.FloodFill;
 namespace PixiEditor.ChangeableDocument.Changes.Drawing.FloodFill;
 
 
@@ -16,9 +17,10 @@ internal class FloodFill_Change : Change
     private CommittedChunkStorage? chunkStorage = null;
     private CommittedChunkStorage? chunkStorage = null;
     private int frame;
     private int frame;
     private float tolerance;
     private float tolerance;
+    private FloodFillMode fillMode;
 
 
     [GenerateMakeChangeAction]
     [GenerateMakeChangeAction]
-    public FloodFill_Change(Guid memberGuid, VecI pos, Color color, bool referenceAll, float tolerance, bool drawOnMask, int frame)
+    public FloodFill_Change(Guid memberGuid, VecI pos, Color color, bool referenceAll, float tolerance, FloodFillMode fillMode, bool drawOnMask, int frame)
     {
     {
         this.memberGuid = memberGuid;
         this.memberGuid = memberGuid;
         this.pos = pos;
         this.pos = pos;
@@ -27,6 +29,7 @@ internal class FloodFill_Change : Change
         this.drawOnMask = drawOnMask;
         this.drawOnMask = drawOnMask;
         this.frame = frame;
         this.frame = frame;
         this.tolerance = tolerance;
         this.tolerance = tolerance;
+        this.fillMode = fillMode;
     }
     }
 
 
     public override bool InitializeAndValidate(Document target)
     public override bool InitializeAndValidate(Document target)

+ 11 - 0
src/PixiEditor.ChangeableDocument/Enums/FloodFillMode.cs

@@ -0,0 +1,11 @@
+using System.ComponentModel;
+
+namespace PixiEditor.ChangeableDocument.Enums;
+
+public enum FloodFillMode
+{
+    [Description("OVERLAY")]
+    Overlay,
+    [Description("REPLACE")]
+    Replace,
+}

+ 4 - 2
src/PixiEditor/Data/Configs/ToolSetsConfig.json

@@ -30,7 +30,8 @@
       {
       {
         "ToolName": "FloodFill",
         "ToolName": "FloodFill",
         "Settings": {
         "Settings": {
-          "Tolerance": 0
+          "Tolerance": 0,
+          "FillMode": "Replace"
         }
         }
       },
       },
       "RasterLine",
       "RasterLine",
@@ -90,7 +91,8 @@
       {
       {
         "ToolName": "FloodFill",
         "ToolName": "FloodFill",
         "Settings": {
         "Settings": {
-          "ExposeTolerance": true
+          "ExposeTolerance": true,
+          "ExposeFillMode" : true
         }
         }
       },
       },
       {
       {

+ 2 - 0
src/PixiEditor/Data/Localization/Languages/en.json

@@ -321,6 +321,8 @@
   "ELLIPSE_TOOL": "Ellipse",
   "ELLIPSE_TOOL": "Ellipse",
   "ERASER_TOOL": "Eraser",
   "ERASER_TOOL": "Eraser",
   "FLOOD_FILL_TOOL": "Flood Fill",
   "FLOOD_FILL_TOOL": "Flood Fill",
+  "FLOOD_FILL_MODE_LABEL" : "Fill mode",
+  "OVERLAY" : "Overlay",
   "LASSO_TOOL": "Lasso",
   "LASSO_TOOL": "Lasso",
   "LINE_TOOL": "Line",
   "LINE_TOOL": "Line",
   "MAGIC_WAND_TOOL": "Magic Wand",
   "MAGIC_WAND_TOOL": "Magic Wand",

+ 6 - 3
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/FloodFillToolExecutor.cs

@@ -7,6 +7,7 @@ using PixiEditor.Models.Handlers;
 using PixiEditor.Models.Handlers.Tools;
 using PixiEditor.Models.Handlers.Tools;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Tools;
 using Drawie.Numerics;
 using Drawie.Numerics;
+using PixiEditor.ChangeableDocument.Enums;
 
 
 namespace PixiEditor.Models.DocumentModels.UpdateableChangeExecutors;
 namespace PixiEditor.Models.DocumentModels.UpdateableChangeExecutors;
 #nullable enable
 #nullable enable
@@ -17,6 +18,7 @@ internal class FloodFillToolExecutor : UpdateableChangeExecutor
     private Guid memberGuid;
     private Guid memberGuid;
     private Color color;
     private Color color;
     private float tolerance;
     private float tolerance;
+    private FloodFillMode fillMode;
 
 
     public override ExecutionState Start()
     public override ExecutionState Start()
     {
     {
@@ -39,15 +41,16 @@ internal class FloodFillToolExecutor : UpdateableChangeExecutor
         color = colorsVM.PrimaryColor;
         color = colorsVM.PrimaryColor;
         var pos = controller!.LastPixelPosition;
         var pos = controller!.LastPixelPosition;
         tolerance = fillTool.Tolerance;
         tolerance = fillTool.Tolerance;
-
-        internals!.ActionAccumulator.AddActions(new FloodFill_Action(memberGuid, pos, color, considerAllLayers, tolerance, drawOnMask, document!.AnimationHandler.ActiveFrameBindable));
+        fillMode = fillTool.FillMode;
+        
+        internals!.ActionAccumulator.AddActions(new FloodFill_Action(memberGuid, pos, color, considerAllLayers, tolerance, fillMode, drawOnMask, document!.AnimationHandler.ActiveFrameBindable));
 
 
         return ExecutionState.Success;
         return ExecutionState.Success;
     }
     }
 
 
     public override void OnPixelPositionChange(VecI pos)
     public override void OnPixelPositionChange(VecI pos)
     {
     {
-        internals!.ActionAccumulator.AddActions(new FloodFill_Action(memberGuid, pos, color, considerAllLayers, tolerance, drawOnMask, document!.AnimationHandler.ActiveFrameBindable));
+        internals!.ActionAccumulator.AddActions(new FloodFill_Action(memberGuid, pos, color, considerAllLayers, tolerance, fillMode, drawOnMask, document!.AnimationHandler.ActiveFrameBindable));
     }
     }
 
 
     public override void OnLeftMouseButtonUp(VecD argsPositionOnCanvas)
     public override void OnLeftMouseButtonUp(VecD argsPositionOnCanvas)

+ 4 - 1
src/PixiEditor/Models/Handlers/Tools/IFloodFillToolHandler.cs

@@ -1,7 +1,10 @@
-namespace PixiEditor.Models.Handlers.Tools;
+using PixiEditor.ChangeableDocument.Enums;
+
+namespace PixiEditor.Models.Handlers.Tools;
 
 
 internal interface IFloodFillToolHandler : IToolHandler
 internal interface IFloodFillToolHandler : IToolHandler
 {
 {
     public bool ConsiderAllLayers { get; }
     public bool ConsiderAllLayers { get; }
     public float Tolerance { get; }
     public float Tolerance { get; }
+    FloodFillMode FillMode { get; }
 }
 }

+ 3 - 0
src/PixiEditor/ViewModels/Tools/Tools/FloodFillToolViewModel.cs

@@ -5,6 +5,7 @@ using PixiEditor.Models.Commands.Attributes.Commands;
 using PixiEditor.Models.Handlers;
 using PixiEditor.Models.Handlers;
 using PixiEditor.Models.Handlers.Tools;
 using PixiEditor.Models.Handlers.Tools;
 using Drawie.Numerics;
 using Drawie.Numerics;
+using PixiEditor.ChangeableDocument.Enums;
 using PixiEditor.UI.Common.Fonts;
 using PixiEditor.UI.Common.Fonts;
 using PixiEditor.UI.Common.Localization;
 using PixiEditor.UI.Common.Localization;
 using PixiEditor.ViewModels.Tools.ToolSettings.Toolbars;
 using PixiEditor.ViewModels.Tools.ToolSettings.Toolbars;
@@ -31,6 +32,8 @@ internal class FloodFillToolViewModel : ToolViewModel, IFloodFillToolHandler
 
 
     [Settings.Percent("TOLERANCE_LABEL", ExposedByDefault = false)]
     [Settings.Percent("TOLERANCE_LABEL", ExposedByDefault = false)]
     public float Tolerance => GetValue<float>();
     public float Tolerance => GetValue<float>();
+    [Settings.Enum("FLOOD_FILL_MODE_LABEL", FloodFillMode.Overlay, ExposedByDefault = false)]
+    public FloodFillMode FillMode => GetValue<FloodFillMode>();
 
 
     public override string DefaultIcon => PixiPerfectIcons.Bucket;
     public override string DefaultIcon => PixiPerfectIcons.Bucket;