|
@@ -98,6 +98,7 @@ namespace PixiEditor.Models.Layers
|
|
if (SetProperty(ref isVisible, value))
|
|
if (SetProperty(ref isVisible, value))
|
|
{
|
|
{
|
|
RaisePropertyChanged(nameof(IsVisibleUndoTriggerable));
|
|
RaisePropertyChanged(nameof(IsVisibleUndoTriggerable));
|
|
|
|
+ InvokeLayerBitmapChange();
|
|
ViewModelMain.Current.ToolsSubViewModel.TriggerCacheOutdated();
|
|
ViewModelMain.Current.ToolsSubViewModel.TriggerCacheOutdated();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -137,10 +138,11 @@ namespace PixiEditor.Models.Layers
|
|
public Surface LayerBitmap
|
|
public Surface LayerBitmap
|
|
{
|
|
{
|
|
get => layerBitmap;
|
|
get => layerBitmap;
|
|
- set
|
|
|
|
|
|
+ private set
|
|
{
|
|
{
|
|
layerBitmap = value;
|
|
layerBitmap = value;
|
|
RaisePropertyChanged(nameof(LayerBitmap));
|
|
RaisePropertyChanged(nameof(LayerBitmap));
|
|
|
|
+ InvokeLayerBitmapChange();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -152,6 +154,7 @@ namespace PixiEditor.Models.Layers
|
|
if (SetProperty(ref opacity, value))
|
|
if (SetProperty(ref opacity, value))
|
|
{
|
|
{
|
|
RaisePropertyChanged(nameof(OpacityUndoTriggerable));
|
|
RaisePropertyChanged(nameof(OpacityUndoTriggerable));
|
|
|
|
+ InvokeLayerBitmapChange();
|
|
ViewModelMain.Current.ToolsSubViewModel.TriggerCacheOutdated();
|
|
ViewModelMain.Current.ToolsSubViewModel.TriggerCacheOutdated();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -198,6 +201,11 @@ namespace PixiEditor.Models.Layers
|
|
|
|
|
|
public event EventHandler<Int32Rect> LayerBitmapChanged;
|
|
public event EventHandler<Int32Rect> LayerBitmapChanged;
|
|
|
|
|
|
|
|
+ public void InvokeLayerBitmapChange()
|
|
|
|
+ {
|
|
|
|
+ LayerBitmapChanged?.Invoke(this, new Int32Rect(OffsetX, OffsetY, Width, Height));
|
|
|
|
+ }
|
|
|
|
+
|
|
public void InvokeLayerBitmapChange(Int32Rect dirtyArea)
|
|
public void InvokeLayerBitmapChange(Int32Rect dirtyArea)
|
|
{
|
|
{
|
|
LayerBitmapChanged?.Invoke(this, dirtyArea);
|
|
LayerBitmapChanged?.Invoke(this, dirtyArea);
|
|
@@ -331,6 +339,11 @@ namespace PixiEditor.Models.Layers
|
|
|
|
|
|
LastRelativeCoordinates = pixels.ChangedPixels;
|
|
LastRelativeCoordinates = pixels.ChangedPixels;
|
|
|
|
|
|
|
|
+ int minX = int.MaxValue;
|
|
|
|
+ int maxX = int.MinValue;
|
|
|
|
+ int minY = int.MaxValue;
|
|
|
|
+ int maxY = int.MinValue;
|
|
|
|
+
|
|
foreach (KeyValuePair<Coordinates, SKColor> coords in pixels.ChangedPixels)
|
|
foreach (KeyValuePair<Coordinates, SKColor> coords in pixels.ChangedPixels)
|
|
{
|
|
{
|
|
if (OutOfBounds(coords.Key))
|
|
if (OutOfBounds(coords.Key))
|
|
@@ -339,9 +352,15 @@ namespace PixiEditor.Models.Layers
|
|
}
|
|
}
|
|
|
|
|
|
LayerBitmap.SetSRGBPixel(coords.Key.X, coords.Key.Y, coords.Value);
|
|
LayerBitmap.SetSRGBPixel(coords.Key.X, coords.Key.Y, coords.Value);
|
|
|
|
+ minX = Math.Min(minX, coords.Key.X);
|
|
|
|
+ minY = Math.Min(minY, coords.Key.Y);
|
|
|
|
+ maxX = Math.Max(maxX, coords.Key.X);
|
|
|
|
+ maxY = Math.Max(maxY, coords.Key.Y);
|
|
}
|
|
}
|
|
|
|
|
|
ClipIfNecessary();
|
|
ClipIfNecessary();
|
|
|
|
+ if (minX != int.MaxValue)
|
|
|
|
+ InvokeLayerBitmapChange(new Int32Rect(minX + OffsetX, minY + OffsetY, maxX - minX + 1, maxY - minY + 1));
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|