Skip to content

Commit

Permalink
Fixed tools undo
Browse files Browse the repository at this point in the history
  • Loading branch information
flabbet committed Dec 16, 2021
1 parent 4d06ec2 commit 700016e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 0 additions & 1 deletion PixiEditor/Models/DataHolders/Document/Document.Layers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ public Layer MergeLayers(Layer[] layersToMerge, bool nameOfLast, int index)
LayerStructure.AssignParent(mergedLayer.LayerGuid, groupParent?.GroupGuid);

RemoveLayer(placeholderLayer, false);

RemoveLayer(layersToMerge[^1], false);

SetMainActiveLayer(Layers.IndexOf(mergedLayer));
Expand Down
10 changes: 9 additions & 1 deletion PixiEditor/Models/Tools/BitmapOperationTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public abstract class BitmapOperationTool : Tool

public bool UseDefaultUndoMethod { get; set; } = true;

public bool UseDocumentRectForUndo { get; set; } = false;

private StorageBasedChange _change;

public abstract void Use(Layer activeLayer, Layer previewLayer, IEnumerable<Layer> allLayers, IReadOnlyList<Coordinates> recordedMouseMovement, SKColor color);
Expand Down Expand Up @@ -62,8 +64,14 @@ private void InitializeStorageBasedChange(SKRectI toolSessionRect)

if (toolSessionRect.IsEmpty)
{
finalRect = SKRectI.Create(0, 0, doc.ActiveLayer.MaxWidth, doc.ActiveLayer.MaxHeight);
finalRect = SKRectI.Create(doc.ActiveLayer.OffsetX, doc.ActiveLayer.OffsetY, doc.ActiveLayer.Width, doc.ActiveLayer.Height);
}

if (UseDocumentRectForUndo)
{
finalRect = SKRectI.Create(0, 0, doc.Width, doc.Height);
}

_change = new StorageBasedChange(doc, new[] { new LayerChunk(doc.ActiveLayer, finalRect) });
}

Expand Down
1 change: 1 addition & 0 deletions PixiEditor/Models/Tools/Tools/FloodFillTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public FloodFillTool(BitmapManager bitmapManager)
{
ActionDisplay = "Press on an area to fill it.";
BitmapManager = bitmapManager;
UseDocumentRectForUndo = true;
}

public override string Tooltip => "Fills area with color. (G)";
Expand Down

0 comments on commit 700016e

Please sign in to comment.