Browse Source

Some highlight changes

Equbuxu 3 years ago
parent
commit
03a99cba8c
1 changed files with 5 additions and 1 deletions
  1. 5 1
      PixiEditor/Models/Controllers/BitmapManager.cs

+ 5 - 1
PixiEditor/Models/Controllers/BitmapManager.cs

@@ -12,6 +12,7 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Diagnostics;
 using System.Linq;
+using System.Windows;
 using System.Windows.Input;
 
 namespace PixiEditor.Models.Controllers
@@ -234,7 +235,7 @@ namespace PixiEditor.Models.Controllers
                 return;
             }
 
-            if (ToolSize != previewLayerSize)
+            if (ToolSize != previewLayerSize || ActiveDocument.PreviewLayer.IsCleared)
             {
                 cachedHighlight = CoordinatesCalculator.RectangleToCoordinates(
                     CoordinatesCalculator.CalculateThicknessCenter(newPosition, ToolSize));
@@ -244,10 +245,13 @@ namespace PixiEditor.Models.Controllers
 
                 cachedPixels = BitmapPixelChanges.FromSingleColoredArray(cachedHighlight, new SKColor(0, 0, 0, 77));
 
+                if (!ActiveDocument.PreviewLayer.IsCleared)
+                    ActiveDocument.PreviewLayer.Clear();
                 ActiveDocument.PreviewLayer.SetPixels(cachedPixels);
             }
 
             Coordinates start = newPosition - halfSize;
+            ActiveDocument.PreviewLayer.Offset = new Thickness(start.X, start.Y, 0, 0);
 
             if (!IsInsideBounds(cachedHighlight))
             {