Browse Source

Changed the way the shift thing is working.
Now BitmapOperationTool has a virtual property called UsesShift.
This property is overridden in PenTool, EraseTool and BrightnessTool so it returns false.

This property is used in the shift functionality to indicate if it shoul be applyed or not.

Rene Brokholm 4 years ago
parent
commit
d27506f5c1

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

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

+ 1 - 0
PixiEditor/Models/Tools/BitmapOperationTool.cs

@@ -15,6 +15,7 @@ namespace PixiEditor.Models.Tools
         public bool ClearPreviewLayerOnEachIteration { get; set; } = true;
 
         public bool UseDefaultUndoMethod { get; set; } = true;
+        public virtual bool UsesShift { get => true; }
 
         private readonly LayerChange[] onlyLayerArr = new LayerChange[] { new LayerChange(BitmapPixelChanges.Empty, Guid.Empty) };
 

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

@@ -26,7 +26,8 @@ namespace PixiEditor.Models.Tools.Tools
             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;
 

+ 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.";
             Toolbar = new BasicToolbar();
             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)
         {

+ 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);
 
             return result;
-        }
-
-        private void MovePixelsToCheck(BitmapPixelChanges changes)
+        }
+		public override bool UsesShift => false;
+		private void MovePixelsToCheck(BitmapPixelChanges changes)
         {
             if (changes.ChangedPixels[lastChangedPixels[1]].A != 0)
             {