Browse Source

Merge pull request #212 from rebizu/#203

BitmapOperationsUtility :  Shift functionality should not apply to PenTool
Krzysztof Krysiński 4 years ago
parent
commit
1b6c0cae65

+ 2 - 2
PixiEditor/Models/Controllers/BitmapOperationsUtility.cs

@@ -128,8 +128,8 @@ namespace PixiEditor.Models.Controllers
             int thickness = sizeSetting != null ? sizeSetting.Value : 1;
             int thickness = sizeSetting != null ? sizeSetting.Value : 1;
 
 
             bool shiftDown = Keyboard.IsKeyDown(Key.LeftShift);
             bool shiftDown = Keyboard.IsKeyDown(Key.LeftShift);
-
-            if (shiftDown)
+           
+            if (shiftDown && tool.UsesShift)
             {
             {
                 bool mouseInLine = MouseCordsNotInLine(mouseMoveCords, thickness);
                 bool mouseInLine = MouseCordsNotInLine(mouseMoveCords, thickness);
 
 

+ 31 - 30
PixiEditor/Models/Tools/BitmapOperationTool.cs

@@ -1,35 +1,36 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Windows.Documents;
 using System.Windows.Documents;
-using System.Windows.Media;
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Layers;
-using PixiEditor.Models.Position;
-
-namespace PixiEditor.Models.Tools
-{
-    public abstract class BitmapOperationTool : Tool
-    {
-        public bool RequiresPreviewLayer { get; set; }
-
-        public bool ClearPreviewLayerOnEachIteration { get; set; } = true;
+using System.Windows.Media;
+using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Layers;
+using PixiEditor.Models.Position;
 
 
-        public bool UseDefaultUndoMethod { get; set; } = true;
-
-        private readonly LayerChange[] onlyLayerArr = new LayerChange[] { new LayerChange(BitmapPixelChanges.Empty, Guid.Empty) };
+namespace PixiEditor.Models.Tools
+{
+    public abstract class BitmapOperationTool : Tool
+    {
+        public bool RequiresPreviewLayer { get; set; }
 
 
-        public abstract LayerChange[] Use(Layer layer, List<Coordinates> mouseMove, Color color);
-
-        protected LayerChange[] Only(BitmapPixelChanges changes, Layer layer)
-        {
-            onlyLayerArr[0] = new LayerChange(changes, layer);
-            return onlyLayerArr;
-        }
-
-        protected LayerChange[] Only(BitmapPixelChanges changes, Guid layerGuid)
-        {
-            onlyLayerArr[0] = new LayerChange(changes, layerGuid);
-            return onlyLayerArr;
-        }
-    }
-}
+        public bool ClearPreviewLayerOnEachIteration { get; set; } = true;
+
+        public bool UseDefaultUndoMethod { get; set; } = true;
+        public virtual bool UsesShift => true;
+
+        private readonly LayerChange[] onlyLayerArr = new LayerChange[] { new LayerChange(BitmapPixelChanges.Empty, Guid.Empty) };
+
+        public abstract LayerChange[] Use(Layer layer, List<Coordinates> mouseMove, Color color);
+
+        protected LayerChange[] Only(BitmapPixelChanges changes, Layer layer)
+        {
+            onlyLayerArr[0] = new LayerChange(changes, layer);
+            return onlyLayerArr;
+        }
+
+        protected LayerChange[] Only(BitmapPixelChanges changes, Guid layerGuid)
+        {
+            onlyLayerArr[0] = new LayerChange(changes, layerGuid);
+            return onlyLayerArr;
+        }
+    }
+}

+ 2 - 1
PixiEditor/Models/Tools/Tools/BrightnessTool.cs

@@ -26,7 +26,8 @@ namespace PixiEditor.Models.Tools.Tools
             Toolbar = new BrightnessToolToolbar(CorrectionFactor);
             Toolbar = new BrightnessToolToolbar(CorrectionFactor);
         }
         }
 
 
-        public override string Tooltip => "Makes pixel brighter or darker pixel (U). Hold Ctrl to make pixel darker.";
+		public override bool UsesShift => false;
+		public override string Tooltip => "Makes pixel brighter or darker pixel (U). Hold Ctrl to make pixel darker.";
 
 
         public BrightnessMode Mode { get; set; } = BrightnessMode.Default;
         public BrightnessMode Mode { get; set; } = BrightnessMode.Default;
 
 

+ 4 - 3
PixiEditor/Models/Tools/Tools/EraserTool.cs

@@ -18,9 +18,10 @@ namespace PixiEditor.Models.Tools.Tools
             ActionDisplay = "Draw to remove color from a pixel.";
             ActionDisplay = "Draw to remove color from a pixel.";
             Toolbar = new BasicToolbar();
             Toolbar = new BasicToolbar();
             pen = new PenTool(bitmapManager);
             pen = new PenTool(bitmapManager);
-        }
-
-        public override string Tooltip => "Erasers color from pixel. (E)";
+        }
+
+        public override bool UsesShift => false;
+		public override string Tooltip => "Erasers color from pixel. (E)";
 
 
         public override LayerChange[] Use(Layer layer, List<Coordinates> coordinates, Color color)
         public override LayerChange[] Use(Layer layer, List<Coordinates> coordinates, Color color)
         {
         {

+ 3 - 3
PixiEditor/Models/Tools/Tools/PenTool.cs

@@ -99,9 +99,9 @@ namespace PixiEditor.Models.Tools.Tools
             var result = BitmapPixelChanges.FromSingleColoredArray(GetThickShape(latestPixels, toolSize), color);
             var result = BitmapPixelChanges.FromSingleColoredArray(GetThickShape(latestPixels, toolSize), color);
 
 
             return result;
             return result;
-        }
-
-        private void MovePixelsToCheck(BitmapPixelChanges changes)
+        }
+		public override bool UsesShift => false;
+		private void MovePixelsToCheck(BitmapPixelChanges changes)
         {
         {
             if (changes.ChangedPixels[lastChangedPixels[1]].A != 0)
             if (changes.ChangedPixels[lastChangedPixels[1]].A != 0)
             {
             {