From c135bfb817d0a7b28b94a3f84f638178d5d321bd Mon Sep 17 00:00:00 2001
From: Lehonti Ramos <17771375+Lehonti@users.noreply.github.com>
Date: Tue, 24 Mar 2026 12:54:37 +0100
Subject: [PATCH 1/4] Removed `ToolManager` dependency from `DocumentWorkspace`
---
Pinta.Core/Actions/ImageActions.cs | 2 +-
Pinta.Core/Classes/Document.cs | 6 ++--
Pinta.Core/Classes/DocumentWorkspace.cs | 37 ++++++++++---------------
Pinta.Core/Managers/WorkspaceManager.cs | 2 +-
4 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/Pinta.Core/Actions/ImageActions.cs b/Pinta.Core/Actions/ImageActions.cs
index 195e5fe758..027fa3140e 100644
--- a/Pinta.Core/Actions/ImageActions.cs
+++ b/Pinta.Core/Actions/ImageActions.cs
@@ -300,7 +300,7 @@ void CropImageToRectangle (Document doc, RectangleI rect, Path? selection)
double original_scale = doc.Workspace.Scale;
doc.ImageSize = rect.Size;
doc.Workspace.ViewSize = rect.Size;
- doc.Workspace.Scale = original_scale;
+ doc.Workspace.SetScale (original_scale, tools);
view.UpdateCanvasScale ();
diff --git a/Pinta.Core/Classes/Document.cs b/Pinta.Core/Classes/Document.cs
index 98d2bd8298..57bc470840 100644
--- a/Pinta.Core/Classes/Document.cs
+++ b/Pinta.Core/Classes/Document.cs
@@ -80,7 +80,7 @@ public Document (
Selection = new DocumentSelection ();
Layers = new DocumentLayers (tools, this);
- Workspace = new DocumentWorkspace (actions, tools, this);
+ Workspace = new DocumentWorkspace (actions, this);
IsDirty = false;
HasBeenSavedInSession = false;
ImageSize = size;
@@ -345,7 +345,7 @@ public void ResizeCanvas (
ResetSelectionPaths ();
- Workspace.Scale = scale;
+ Workspace.SetScale (scale, tools);
}
public void ResizeImage (
@@ -374,7 +374,7 @@ public void ResizeImage (
ResetSelectionPaths ();
- Workspace.Scale = scale;
+ Workspace.SetScale (scale, tools);
actions.View.UpdateCanvasScale ();
}
diff --git a/Pinta.Core/Classes/DocumentWorkspace.cs b/Pinta.Core/Classes/DocumentWorkspace.cs
index b68bd9e6a2..f6091622a8 100644
--- a/Pinta.Core/Classes/DocumentWorkspace.cs
+++ b/Pinta.Core/Classes/DocumentWorkspace.cs
@@ -30,10 +30,8 @@ namespace Pinta.Core;
public sealed class DocumentWorkspace
{
- private readonly Document document;
-
private readonly ActionManager actions;
- private readonly ToolManager tools;
+ private readonly Document document;
private enum ZoomType
{
@@ -42,16 +40,10 @@ private enum ZoomType
ZoomManually,
}
- internal DocumentWorkspace (
- ActionManager actions,
- ToolManager tools,
- Document document)
+ internal DocumentWorkspace (ActionManager actions, Document document)
{
this.actions = actions;
- this.tools = tools;
-
this.document = document;
-
History = new DocumentHistory (actions.Edit, document);
}
@@ -106,21 +98,22 @@ public bool ImageFitsInWindow {
///
/// Scale factor for the zoomed image.
///
- public double Scale {
- get => ViewSize.Width / (double) document.ImageSize.Width;
- set {
- if (value == ViewSize.Width / (double) document.ImageSize.Width && value == ViewSize.Height / (double) document.ImageSize.Height)
- return;
+ public double Scale
+ => ViewSize.Width / (double) document.ImageSize.Width;
+
+ public void SetScale (double value, ToolManager tools)
+ {
+ if (value == ViewSize.Width / (double) document.ImageSize.Width && value == ViewSize.Height / (double) document.ImageSize.Height)
+ return;
- document.ImageSize = CoercedToPositive (document.ImageSize);
- ViewSize = GetNewViewSize (document.ImageSize, value);
+ document.ImageSize = CoercedToPositive (document.ImageSize);
+ ViewSize = GetNewViewSize (document.ImageSize, value);
- Invalidate ();
+ Invalidate ();
- if (tools.CurrentTool?.CursorChangesOnZoom == true) {
- //The current tool's cursor changes when the zoom changes.
- tools.CurrentTool.SetCursor (tools.CurrentTool.CurrentCursor);
- }
+ if (tools.CurrentTool?.CursorChangesOnZoom == true) {
+ //The current tool's cursor changes when the zoom changes.
+ tools.CurrentTool.SetCursor (tools.CurrentTool.CurrentCursor);
}
}
diff --git a/Pinta.Core/Managers/WorkspaceManager.cs b/Pinta.Core/Managers/WorkspaceManager.cs
index 2f3581a3b9..c01cd8dfea 100644
--- a/Pinta.Core/Managers/WorkspaceManager.cs
+++ b/Pinta.Core/Managers/WorkspaceManager.cs
@@ -194,7 +194,7 @@ public Size CanvasSize {
public double Scale {
get => ActiveWorkspace.Scale;
- set => ActiveWorkspace.Scale = value;
+ set => ActiveWorkspace.SetScale (value, PintaCore.Tools);
}
private readonly List open_documents;
From ff6d6be87f3dbfdb7cc85166f62e4e1143c89568 Mon Sep 17 00:00:00 2001
From: Lehonti Ramos <17771375+Lehonti@users.noreply.github.com>
Date: Tue, 24 Mar 2026 13:29:47 +0100
Subject: [PATCH 2/4] Removed dependency of `EditActions` in `DocumentHistory`
---
Pinta.Core/Actions/EditActions.cs | 16 +++--
Pinta.Core/Actions/ImageActions.cs | 17 +++--
Pinta.Core/Actions/LayerActions.cs | 21 +++---
Pinta.Core/Classes/Document.cs | 8 +--
Pinta.Core/Classes/DocumentHistory.cs | 15 ++--
Pinta.Core/Classes/DocumentWorkspace.cs | 2 +-
Pinta.Core/Managers/ActionManager.cs | 4 +-
Pinta.Core/Managers/LivePreviewManager.cs | 5 +-
Pinta.Core/Managers/WorkspaceManager.cs | 4 +-
Pinta.Core/PintaCore.cs | 2 +-
.../Widgets/History/HistoryListView.cs | 10 ++-
.../Layers/LayersListViewItemWidget.cs | 2 +-
.../Editable/EditEngines/BaseEditEngine.cs | 69 ++++++++++++++-----
Pinta.Tools/Tools/BaseBrushTool.cs | 9 ++-
Pinta.Tools/Tools/FreeformShapeTool.cs | 12 +++-
Pinta.Tools/Tools/GradientTool.cs | 26 +++++--
Pinta.Tools/Tools/LassoSelectTool.cs | 2 +-
Pinta.Tools/Tools/MagicWandTool.cs | 2 +-
Pinta.Tools/Tools/MoveSelectedTool.cs | 2 +-
Pinta.Tools/Tools/MoveSelectionTool.cs | 2 +-
Pinta.Tools/Tools/PaintBucketTool.cs | 2 +-
Pinta.Tools/Tools/PencilTool.cs | 12 +++-
Pinta.Tools/Tools/SelectTool.cs | 2 +-
Pinta.Tools/Tools/TextTool.cs | 8 +--
Pinta/Actions/Edit/OffsetSelectionAction.cs | 2 +-
Pinta/Actions/Edit/PasteAction.cs | 2 +-
Pinta/Actions/Layers/LayerPropertiesAction.cs | 2 +-
Pinta/Actions/Layers/RotateZoomLayerAction.cs | 4 +-
Pinta/Pads/HistoryPad.cs | 2 +-
29 files changed, 176 insertions(+), 90 deletions(-)
diff --git a/Pinta.Core/Actions/EditActions.cs b/Pinta.Core/Actions/EditActions.cs
index c0dc0757cd..b1bad74291 100644
--- a/Pinta.Core/Actions/EditActions.cs
+++ b/Pinta.Core/Actions/EditActions.cs
@@ -321,7 +321,8 @@ private void HandlePintaCoreActionsEditFillSelectionActivated (object sender, Ev
Translations.GetString ("Fill Selection"),
old,
doc.Layers.CurrentUserLayerIndex
- )
+ ),
+ this
);
}
@@ -341,7 +342,7 @@ private void HandlePintaCoreActionsEditSelectAllActivated (object sender, EventA
doc.ResetSelectionPaths ();
doc.Selection.Visible = true;
- doc.History.PushNewItem (hist);
+ doc.History.PushNewItem (hist, this);
doc.Workspace.Invalidate ();
}
@@ -367,7 +368,8 @@ private void HandlePintaCoreActionsEditEraseSelectionActivated (object sender, E
sender switch {
string and "Cut" => new SimpleHistoryItem (Resources.StandardIcons.EditCut, Translations.GetString ("Cut"), old, doc.Layers.CurrentUserLayerIndex),
_ => new SimpleHistoryItem (Resources.Icons.EditSelectionErase, Translations.GetString ("Erase Selection"), old, doc.Layers.CurrentUserLayerIndex),
- }
+ },
+ this
);
}
@@ -386,7 +388,7 @@ private void HandlePintaCoreActionsEditDeselectActivated (object sender, EventAr
doc.ResetSelectionPaths ();
- doc.History.PushNewItem (hist);
+ doc.History.PushNewItem (hist, this);
doc.Workspace.Invalidate ();
}
@@ -456,7 +458,7 @@ private void HandlerPintaCoreActionsEditUndoActivated (object sender, EventArgs
if (tools.CurrentTool?.DoHandleUndo (doc) == true)
return;
- doc.History.Undo ();
+ doc.History.Undo (this);
tools.CurrentTool?.DoAfterUndo (doc);
}
@@ -468,7 +470,7 @@ private void HandlerPintaCoreActionsEditRedoActivated (object sender, EventArgs
if (tools.CurrentTool?.DoHandleRedo (doc) == true)
return;
- doc.History.Redo ();
+ doc.History.Redo (this);
tools.CurrentTool?.DoAfterRedo (doc);
}
@@ -610,7 +612,7 @@ void HandleInvertSelectionActivated (object sender, EventArgs e)
doc.Selection.Invert (doc.ImageSize);
- doc.History.PushNewItem (historyItem);
+ doc.History.PushNewItem (historyItem, this);
doc.Workspace.Invalidate ();
}
diff --git a/Pinta.Core/Actions/ImageActions.cs b/Pinta.Core/Actions/ImageActions.cs
index 027fa3140e..d814c2a4a8 100644
--- a/Pinta.Core/Actions/ImageActions.cs
+++ b/Pinta.Core/Actions/ImageActions.cs
@@ -44,11 +44,13 @@ public sealed class ImageActions
private readonly ToolManager tools;
private readonly WorkspaceManager workspace;
+ private readonly EditActions edit;
private readonly ViewActions view;
public ImageActions (
ToolManager tools,
WorkspaceManager workspace,
+ EditActions edit,
ViewActions view)
{
CropToSelection = new Command (
@@ -121,6 +123,7 @@ public ImageActions (
this.tools = tools;
this.workspace = workspace;
+ this.edit = edit;
this.view = view;
}
@@ -191,7 +194,7 @@ private void HandlePintaCoreActionsImageRotateCCWActivated (object sender, Event
tools.Commit ();
doc.RotateImageCCW ();
- doc.History.PushNewItem (new InvertHistoryItem (InvertType.Rotate90CCW));
+ doc.History.PushNewItem (new InvertHistoryItem (InvertType.Rotate90CCW), edit);
}
private void HandlePintaCoreActionsImageRotateCWActivated (object sender, EventArgs e)
@@ -201,7 +204,7 @@ private void HandlePintaCoreActionsImageRotateCWActivated (object sender, EventA
tools.Commit ();
doc.RotateImageCW ();
- doc.History.PushNewItem (new InvertHistoryItem (InvertType.Rotate90CW));
+ doc.History.PushNewItem (new InvertHistoryItem (InvertType.Rotate90CW), edit);
}
private void HandlePintaCoreActionsImageFlattenActivated (object sender, EventArgs e)
@@ -227,7 +230,7 @@ private void HandlePintaCoreActionsImageFlattenActivated (object sender, EventAr
hist.Push (new SimpleHistoryItem (string.Empty, string.Empty, oldBottomSurface, 0));
- doc.History.PushNewItem (hist);
+ doc.History.PushNewItem (hist, edit);
}
private void HandlePintaCoreActionsImageRotate180Activated (object sender, EventArgs e)
@@ -237,7 +240,7 @@ private void HandlePintaCoreActionsImageRotate180Activated (object sender, Event
tools.Commit ();
doc.RotateImage180 ();
- doc.History.PushNewItem (new InvertHistoryItem (InvertType.Rotate180));
+ doc.History.PushNewItem (new InvertHistoryItem (InvertType.Rotate180), edit);
}
private void HandlePintaCoreActionsImageFlipVerticalActivated (object sender, EventArgs e)
@@ -247,7 +250,7 @@ private void HandlePintaCoreActionsImageFlipVerticalActivated (object sender, Ev
tools.Commit ();
doc.FlipImageVertical ();
- doc.History.PushNewItem (new InvertHistoryItem (InvertType.FlipVertical));
+ doc.History.PushNewItem (new InvertHistoryItem (InvertType.FlipVertical), edit);
}
private void HandlePintaCoreActionsImageFlipHorizontalActivated (object sender, EventArgs e)
@@ -257,7 +260,7 @@ private void HandlePintaCoreActionsImageFlipHorizontalActivated (object sender,
tools.Commit ();
doc.FlipImageHorizontal ();
- doc.History.PushNewItem (new InvertHistoryItem (InvertType.FlipHorizontal));
+ doc.History.PushNewItem (new InvertHistoryItem (InvertType.FlipHorizontal), edit);
}
private void HandlePintaCoreActionsImageCropToSelectionActivated (object sender, EventArgs e)
@@ -309,7 +312,7 @@ void CropImageToRectangle (Document doc, RectangleI rect, Path? selection)
hist.FinishSnapshotOfImage ();
- doc.History.PushNewItem (hist);
+ doc.History.PushNewItem (hist, edit);
doc.ResetSelectionPaths ();
doc.Workspace.Invalidate ();
diff --git a/Pinta.Core/Actions/LayerActions.cs b/Pinta.Core/Actions/LayerActions.cs
index f8ffced920..2fa8528082 100644
--- a/Pinta.Core/Actions/LayerActions.cs
+++ b/Pinta.Core/Actions/LayerActions.cs
@@ -47,6 +47,7 @@ public sealed class LayerActions
private readonly RecentFileManager recent_files;
private readonly ToolManager tools;
private readonly WorkspaceManager workspace;
+ private readonly EditActions edit;
private readonly ImageActions image;
public LayerActions (
ChromeManager chrome,
@@ -54,6 +55,7 @@ public LayerActions (
RecentFileManager recentFiles,
ToolManager tools,
WorkspaceManager workspace,
+ EditActions edit,
ImageActions image)
{
AddNewLayer = new Command (
@@ -132,6 +134,7 @@ public LayerActions (
recent_files = recentFiles;
this.tools = tools;
this.workspace = workspace;
+ this.edit = edit;
this.image = image;
}
@@ -273,7 +276,7 @@ private async void HandlePintaCoreActionsLayersImportFromFileActivated (object s
// --- Changes to document go after everything else is completed successfully
doc.Layers.SetCurrentUserLayer (layer);
- doc.History.PushNewItem (hist);
+ doc.History.PushNewItem (hist, edit);
doc.Workspace.Invalidate ();
}
@@ -285,7 +288,7 @@ private void HandlePintaCoreActionsLayersFlipVerticalActivated (object sender, E
doc.Layers.CurrentUserLayer.FlipVertical ();
doc.Workspace.Invalidate ();
- doc.History.PushNewItem (new InvertHistoryItem (InvertType.FlipLayerVertical, doc.Layers.CurrentUserLayerIndex));
+ doc.History.PushNewItem (new InvertHistoryItem (InvertType.FlipLayerVertical, doc.Layers.CurrentUserLayerIndex), edit);
}
private void HandlePintaCoreActionsLayersFlipHorizontalActivated (object sender, EventArgs e)
@@ -296,7 +299,7 @@ private void HandlePintaCoreActionsLayersFlipHorizontalActivated (object sender,
doc.Layers.CurrentUserLayer.FlipHorizontal ();
doc.Workspace.Invalidate ();
- doc.History.PushNewItem (new InvertHistoryItem (InvertType.FlipLayerHorizontal, doc.Layers.CurrentUserLayerIndex));
+ doc.History.PushNewItem (new InvertHistoryItem (InvertType.FlipLayerHorizontal, doc.Layers.CurrentUserLayerIndex), edit);
}
private void HandlePintaCoreActionsLayersMoveLayerUpActivated (object sender, EventArgs e)
@@ -312,7 +315,7 @@ private void HandlePintaCoreActionsLayersMoveLayerUpActivated (object sender, Ev
doc.Layers.CurrentUserLayerIndex + 1);
doc.Layers.MoveCurrentLayerUp ();
- doc.History.PushNewItem (hist);
+ doc.History.PushNewItem (hist, edit);
}
private void HandlePintaCoreActionsLayersMoveLayerDownActivated (object sender, EventArgs e)
@@ -328,7 +331,7 @@ private void HandlePintaCoreActionsLayersMoveLayerDownActivated (object sender,
doc.Layers.CurrentUserLayerIndex - 1);
doc.Layers.MoveCurrentLayerDown ();
- doc.History.PushNewItem (hist);
+ doc.History.PushNewItem (hist, edit);
}
private void HandlePintaCoreActionsLayersMergeLayerDownActivated (object sender, EventArgs e)
@@ -360,7 +363,7 @@ private void HandlePintaCoreActionsLayersMergeLayerDownActivated (object sender,
hist.Push (h1);
hist.Push (h2);
- doc.History.PushNewItem (hist);
+ doc.History.PushNewItem (hist, edit);
}
private void HandlePintaCoreActionsLayersDuplicateLayerActivated (object sender, EventArgs e)
@@ -378,7 +381,7 @@ private void HandlePintaCoreActionsLayersDuplicateLayerActivated (object sender,
Resources.Icons.LayerDuplicate,
Translations.GetString ("Duplicate Layer"),
doc.Layers.IndexOf (l));
- doc.History.PushNewItem (hist);
+ doc.History.PushNewItem (hist, edit);
}
private void HandlePintaCoreActionsLayersDeleteLayerActivated (object sender, EventArgs e)
@@ -395,7 +398,7 @@ private void HandlePintaCoreActionsLayersDeleteLayerActivated (object sender, Ev
doc.Layers.DeleteLayer (doc.Layers.CurrentUserLayerIndex);
- doc.History.PushNewItem (hist);
+ doc.History.PushNewItem (hist, edit);
}
private void HandlePintaCoreActionsLayersAddNewLayerActivated (object sender, EventArgs e)
@@ -412,6 +415,6 @@ private void HandlePintaCoreActionsLayersAddNewLayerActivated (object sender, Ev
Resources.Icons.LayerNew,
Translations.GetString ("Add New Layer"),
doc.Layers.IndexOf (l));
- doc.History.PushNewItem (hist);
+ doc.History.PushNewItem (hist, edit);
}
}
diff --git a/Pinta.Core/Classes/Document.cs b/Pinta.Core/Classes/Document.cs
index 57bc470840..dcb4dbe214 100644
--- a/Pinta.Core/Classes/Document.cs
+++ b/Pinta.Core/Classes/Document.cs
@@ -197,7 +197,7 @@ public void ClearFileReference ()
public void Close ()
{
Layers.Close ();
- Workspace.History.Clear ();
+ Workspace.History.Clear (actions.Edit);
}
public Context CreateClippedContext ()
@@ -233,7 +233,7 @@ public void FinishSelection ()
Layers.DestroySelectionLayer ();
Workspace.Invalidate ();
- Workspace.History.PushNewItem (hist);
+ Workspace.History.PushNewItem (hist, actions.Edit);
}
// Flip image horizontally
@@ -341,7 +341,7 @@ public void ResizeCanvas (
if (compoundAction is not null)
compoundAction.Push (hist);
else
- Workspace.History.PushNewItem (hist);
+ Workspace.History.PushNewItem (hist, actions.Edit);
ResetSelectionPaths ();
@@ -370,7 +370,7 @@ public void ResizeImage (
hist.FinishSnapshotOfImage ();
- Workspace.History.PushNewItem (hist);
+ Workspace.History.PushNewItem (hist, actions.Edit);
ResetSelectionPaths ();
diff --git a/Pinta.Core/Classes/DocumentHistory.cs b/Pinta.Core/Classes/DocumentHistory.cs
index 402babbf50..fdf734edd2 100644
--- a/Pinta.Core/Classes/DocumentHistory.cs
+++ b/Pinta.Core/Classes/DocumentHistory.cs
@@ -31,8 +31,6 @@ namespace Pinta.Core;
public sealed class DocumentHistory
{
- private readonly EditActions edit;
-
private readonly Document document;
private readonly List history = [];
@@ -42,11 +40,8 @@ public sealed class DocumentHistory
public event EventHandler? ActionUndone;
public event EventHandler? ActionRedone;
- internal DocumentHistory (
- EditActions edit,
- Document document)
+ internal DocumentHistory (Document document)
{
- this.edit = edit;
this.document = document;
}
@@ -63,7 +58,7 @@ internal DocumentHistory (
public IEnumerable Items => history;
- public void PushNewItem (BaseHistoryItem newItem)
+ public void PushNewItem (BaseHistoryItem newItem, EditActions edit)
{
// Remove all old redos starting from the end of the list
for (var i = history.Count - 1; i >= 0; i--) {
@@ -89,7 +84,7 @@ public void PushNewItem (BaseHistoryItem newItem)
HistoryItemAdded?.Invoke (this, new HistoryItemAddedEventArgs (newItem));
}
- public void Undo ()
+ public void Undo (EditActions edit)
{
if (Pointer < 0)
throw new InvalidOperationException ("Undo stack is empty");
@@ -114,7 +109,7 @@ public void Undo ()
ActionUndone?.Invoke (this, EventArgs.Empty);
}
- public void Redo ()
+ public void Redo (EditActions edit)
{
if (Pointer >= history.Count - 1)
throw new InvalidOperationException ("Redo stack is empty");
@@ -160,7 +155,7 @@ public void SetDirty ()
document.IsDirty = true;
}
- public void Clear ()
+ public void Clear (EditActions edit)
{
history.Clear ();
Pointer = -1;
diff --git a/Pinta.Core/Classes/DocumentWorkspace.cs b/Pinta.Core/Classes/DocumentWorkspace.cs
index f6091622a8..2177881a33 100644
--- a/Pinta.Core/Classes/DocumentWorkspace.cs
+++ b/Pinta.Core/Classes/DocumentWorkspace.cs
@@ -44,7 +44,7 @@ internal DocumentWorkspace (ActionManager actions, Document document)
{
this.actions = actions;
this.document = document;
- History = new DocumentHistory (actions.Edit, document);
+ History = new DocumentHistory (document);
}
#region Public Events
diff --git a/Pinta.Core/Managers/ActionManager.cs b/Pinta.Core/Managers/ActionManager.cs
index 910936178a..25ce6d531c 100644
--- a/Pinta.Core/Managers/ActionManager.cs
+++ b/Pinta.Core/Managers/ActionManager.cs
@@ -66,8 +66,8 @@ public ActionManager (
FileActions file = new (system, app);
HelpActions help = new (system, app);
- ImageActions image = new (tools, workspace, view);
- LayerActions layers = new (chrome, imageFormats, recentFiles, tools, workspace, image);
+ ImageActions image = new (tools, workspace, edit, view);
+ LayerActions layers = new (chrome, imageFormats, recentFiles, tools, workspace, edit, image);
// --- References to keep
diff --git a/Pinta.Core/Managers/LivePreviewManager.cs b/Pinta.Core/Managers/LivePreviewManager.cs
index 3a65f5958b..8c4c2a0c43 100644
--- a/Pinta.Core/Managers/LivePreviewManager.cs
+++ b/Pinta.Core/Managers/LivePreviewManager.cs
@@ -44,12 +44,14 @@ public interface ILivePreview
public sealed class LivePreviewManager : ILivePreview
{
+ private readonly ActionManager actions;
private readonly WorkspaceManager workspace;
private readonly ToolManager tools;
private readonly SystemManager system;
private readonly ChromeManager chrome;
internal LivePreviewManager (
+ ActionManager actions,
WorkspaceManager workspaceManager,
ToolManager toolManager,
SystemManager systemManager,
@@ -57,6 +59,7 @@ internal LivePreviewManager (
{
IsEnabled = false;
+ this.actions = actions;
workspace = workspaceManager;
tools = toolManager;
system = systemManager;
@@ -181,7 +184,7 @@ public async void Start (BaseEffect effect)
layer.DrawWithOperator (context, LivePreviewSurface, Cairo.Operator.Source);
context.Restore ();
- workspace.ActiveDocument.History.PushNewItem (historyItem);
+ workspace.ActiveDocument.History.PushNewItem (historyItem, actions.Edit);
} finally {
diff --git a/Pinta.Core/Managers/WorkspaceManager.cs b/Pinta.Core/Managers/WorkspaceManager.cs
index c01cd8dfea..7be295a6b2 100644
--- a/Pinta.Core/Managers/WorkspaceManager.cs
+++ b/Pinta.Core/Managers/WorkspaceManager.cs
@@ -135,7 +135,7 @@ public static Document NewDocument (
g.Paint ();
}
- doc.Workspace.History.PushNewItem (new BaseHistoryItem (Resources.StandardIcons.DocumentNew, Translations.GetString ("New Image")));
+ doc.Workspace.History.PushNewItem (new BaseHistoryItem (Resources.StandardIcons.DocumentNew, Translations.GetString ("New Image")), PintaCore.Actions.Edit);
doc.Workspace.History.SetClean ();
return doc;
@@ -332,7 +332,7 @@ public bool OpenFile (
}
}
- ActiveWorkspace.History.PushNewItem (new BaseHistoryItem (Resources.StandardIcons.DocumentOpen, Translations.GetString ("Open Image")));
+ ActiveWorkspace.History.PushNewItem (new BaseHistoryItem (Resources.StandardIcons.DocumentOpen, Translations.GetString ("Open Image")), PintaCore.Actions.Edit);
ActiveDocument.History.SetClean ();
return true;
diff --git a/Pinta.Core/PintaCore.cs b/Pinta.Core/PintaCore.cs
index abdba7e115..802d05bc0c 100644
--- a/Pinta.Core/PintaCore.cs
+++ b/Pinta.Core/PintaCore.cs
@@ -82,7 +82,7 @@ static PintaCore ()
ToolManager tools = new (workspace, chrome);
PaletteManager palette = new (settings, paletteFormats);
ActionManager actions = new (chrome, imageFormats, paletteFormats, palette, recentFiles, system, tools, workspace);
- LivePreviewManager livePreview = new (workspace, tools, system, chrome);
+ LivePreviewManager livePreview = new (actions, workspace, tools, system, chrome);
EffectsManager effects = new (actions, chrome, livePreview);
CanvasGridManager canvasGrid = new (workspace, settings);
diff --git a/Pinta.Gui.Widgets/Widgets/History/HistoryListView.cs b/Pinta.Gui.Widgets/Widgets/History/HistoryListView.cs
index ae5d755123..f8ec682a6b 100644
--- a/Pinta.Gui.Widgets/Widgets/History/HistoryListView.cs
+++ b/Pinta.Gui.Widgets/Widgets/History/HistoryListView.cs
@@ -38,7 +38,9 @@ public sealed class HistoryListView : Gtk.ScrolledWindow
private Document? active_document;
- public HistoryListView ()
+ private readonly EditActions edit;
+
+ public HistoryListView (EditActions edit)
{
Gio.ListStore listModel = Gio.ListStore.New (HistoryListViewItem.GetGType ());
@@ -79,6 +81,8 @@ public HistoryListView ()
// --- Event handlers for the application
// TODO: Move handlers out of this constructor
+ this.edit = edit;
+
PintaCore.Workspace.ActiveDocumentChanged += OnActiveDocumentChanged;
}
@@ -89,10 +93,10 @@ private void HandleSelectionChanged (Gtk.SelectionModel sender, EventArgs e)
int index = (int) selection_model.Selected;
while (active_document.History.Pointer < index)
- active_document.History.Redo ();
+ active_document.History.Redo (edit);
while (active_document.History.Pointer > index)
- active_document.History.Undo ();
+ active_document.History.Undo (edit);
}
private void OnActiveDocumentChanged (object? sender, EventArgs e)
diff --git a/Pinta.Gui.Widgets/Widgets/Layers/LayersListViewItemWidget.cs b/Pinta.Gui.Widgets/Widgets/Layers/LayersListViewItemWidget.cs
index ae690376a1..4827c139d7 100644
--- a/Pinta.Gui.Widgets/Widgets/Layers/LayersListViewItemWidget.cs
+++ b/Pinta.Gui.Widgets/Widgets/Layers/LayersListViewItemWidget.cs
@@ -104,7 +104,7 @@ public void HandleVisibilityToggled (bool visible)
historyItem.Redo ();
- doc.History.PushNewItem (historyItem);
+ doc.History.PushNewItem (historyItem, PintaCore.Actions.Edit);
}
public event EventHandler? LayerModified;
diff --git a/Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs b/Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs
index e8de10ad4e..64ba43730d 100644
--- a/Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs
+++ b/Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs
@@ -296,8 +296,12 @@ public virtual void HandleBuildToolBar (Gtk.Box tb, ISettingsService settings, s
//if shape is selected it will be converted to new shape and shape type will be changed, otherwise only shape type will be changed.
//Create a new ShapesModifyHistoryItem so that the changing of the shape type can be undone.
- workspace.ActiveDocument.History.PushNewItem (new ShapesModifyHistoryItem (
- this, owner.Icon, Translations.GetString ("Changed Shape Type")));
+ workspace.ActiveDocument.History.PushNewItem (
+ new ShapesModifyHistoryItem (
+ this,
+ owner.Icon,
+ Translations.GetString ("Changed Shape Type")),
+ actions.Edit);
//Clone the old shape; it should be automatically garbage-collected. newShapeType already has the updated value.
selEngine = selEngine.Convert (newShapeType, SelectedShapeIndex);
@@ -609,8 +613,8 @@ private void HandleSpace (ToolKeyEventArgs e)
new ShapesModifyHistoryItem (
this,
owner.Icon,
- ShapeName + " " + Translations.GetString ("Point Added")
- )
+ ShapeName + " " + Translations.GetString ("Point Added")),
+ actions.Edit
);
bool shiftKey = e.IsShiftPressed;
@@ -660,8 +664,8 @@ private void HandleDelete ()
new ShapesModifyHistoryItem (
this,
owner.Icon,
- ShapeName + " " + Translations.GetString ("Point Deleted")
- )
+ ShapeName + " " + Translations.GetString ("Point Deleted")),
+ actions.Edit
);
//Delete the selected point from the shape.
@@ -684,8 +688,8 @@ private void HandleDelete ()
doc.Layers.CurrentUserLayer,
SelectedPointIndex,
SelectedShapeIndex,
- false
- )
+ false),
+ actions.Edit
);
@@ -812,7 +816,13 @@ public virtual void HandleMouseDown (Document document, ToolMouseEventArgs e)
//Only create a new shape if the user isn't holding the control key down.
if (!ctrlKey) {
//Create a new ShapesModifyHistoryItem so that the adding of a control point can be undone.
- doc.History.PushNewItem (new ShapesModifyHistoryItem (this, owner.Icon, ShapeName + " " + Translations.GetString ("Point Added")));
+ doc.History.PushNewItem (
+ new ShapesModifyHistoryItem (
+ this,
+ owner.Icon,
+ ShapeName + " " + Translations.GetString ("Point Added")),
+ actions.Edit
+ );
SEngines[closestShapeIndex].ControlPoints.Insert (closestPointIndex,
new ControlPoint (new PointD (current_point.X, current_point.Y), DefaultMidPointTension));
@@ -841,8 +851,17 @@ public virtual void HandleMouseDown (Document document, ToolMouseEventArgs e)
}
//Create a new ShapesHistoryItem so that the creation of a new shape can be undone.
- doc.History.PushNewItem (new ShapesHistoryItem (this, owner.Icon, ShapeName + " " + Translations.GetString ("Added"),
- doc.Layers.CurrentUserLayer.Surface.Clone (), doc.Layers.CurrentUserLayer, SelectedPointIndex, SelectedShapeIndex, false));
+ doc.History.PushNewItem (
+ new ShapesHistoryItem (
+ this,
+ owner.Icon,
+ ShapeName + " " + Translations.GetString ("Added"),
+ doc.Layers.CurrentUserLayer.Surface.Clone (),
+ doc.Layers.CurrentUserLayer,
+ SelectedPointIndex,
+ SelectedShapeIndex,
+ false),
+ actions.Edit);
//Create the shape, add its starting points, and add it to SEngines.
SEngines.Add (CreateShape (ctrlKey, clicked_control_point, prevSelPoint));
@@ -921,9 +940,15 @@ public virtual void HandleMouseMove (Document document, ToolMouseEventArgs e)
}
if (clicked_without_modifying) {
- //Create a new ShapesModifyHistoryItem so that the modification of the shape can be undone.
+
+ // Create a new ShapesModifyHistoryItem so that the modification of the shape can be undone.
doc.History.PushNewItem (
- new ShapesModifyHistoryItem (this, owner.Icon, ShapeName + " " + Translations.GetString ("Modified")));
+ new ShapesModifyHistoryItem (
+ this,
+ owner.Icon,
+ ShapeName + " " + Translations.GetString ("Modified")),
+ actions.Edit
+ );
clicked_without_modifying = false;
}
@@ -1111,8 +1136,8 @@ private RectangleD DrawFinalized (ShapeEngine engine, bool createHistoryItem, bo
doc.Layers.CurrentUserLayer,
SelectedPointIndex,
SelectedShapeIndex,
- false
- )
+ false),
+ actions.Edit
);
}
@@ -1392,8 +1417,18 @@ protected void FinalizeAllShapes ()
//Make sure that the undo surface isn't null.
if (undoSurface != null) {
//Create a new ShapesHistoryItem so that the finalization of the shapes can be undone.
- doc.History.PushNewItem (new ShapesHistoryItem (this, owner.Icon, Translations.GetString ("Finalized"),
- undoSurface, doc.Layers.CurrentUserLayer, previousSelectedPointIndex, prev_selected_shape_index, true));
+ doc.History.PushNewItem (
+ new ShapesHistoryItem (
+ this,
+ owner.Icon,
+ Translations.GetString ("Finalized"),
+ undoSurface,
+ doc.Layers.CurrentUserLayer,
+ previousSelectedPointIndex,
+ prev_selected_shape_index,
+ true),
+ actions.Edit
+ );
}
if (totalDirty.HasValue) {
diff --git a/Pinta.Tools/Tools/BaseBrushTool.cs b/Pinta.Tools/Tools/BaseBrushTool.cs
index 778bf0c59b..aac02990ec 100644
--- a/Pinta.Tools/Tools/BaseBrushTool.cs
+++ b/Pinta.Tools/Tools/BaseBrushTool.cs
@@ -82,7 +82,14 @@ protected override void OnMouseDown (Document document, ToolMouseEventArgs e)
protected override void OnMouseUp (Document document, ToolMouseEventArgs e)
{
if (undo_surface != null && surface_modified) {
- document.History.PushNewItem (new SimpleHistoryItem (Icon, Name, undo_surface, document.Layers.CurrentUserLayerIndex));
+ document.History.PushNewItem (
+ new SimpleHistoryItem (
+ Icon,
+ Name,
+ undo_surface,
+ document.Layers.CurrentUserLayerIndex),
+ PintaCore.Actions.Edit
+ );
}
surface_modified = false;
diff --git a/Pinta.Tools/Tools/FreeformShapeTool.cs b/Pinta.Tools/Tools/FreeformShapeTool.cs
index f025b7e9f7..66847a2306 100644
--- a/Pinta.Tools/Tools/FreeformShapeTool.cs
+++ b/Pinta.Tools/Tools/FreeformShapeTool.cs
@@ -189,8 +189,16 @@ protected override void OnMouseUp (Document document, ToolMouseEventArgs e)
g.Stroke ();
}
- if (surface_modified && undo_surface != null)
- document.History.PushNewItem (new SimpleHistoryItem (Icon, Name, undo_surface, document.Layers.CurrentUserLayerIndex));
+ if (surface_modified && undo_surface != null) {
+ document.History.PushNewItem (
+ new SimpleHistoryItem (
+ Icon,
+ Name,
+ undo_surface,
+ document.Layers.CurrentUserLayerIndex),
+ PintaCore.Actions.Edit
+ );
+ }
undo_surface = null;
surface_modified = false;
diff --git a/Pinta.Tools/Tools/GradientTool.cs b/Pinta.Tools/Tools/GradientTool.cs
index a742f5d8ad..095a5c6dc6 100644
--- a/Pinta.Tools/Tools/GradientTool.cs
+++ b/Pinta.Tools/Tools/GradientTool.cs
@@ -114,11 +114,21 @@ protected override void OnMouseUp (Document document, ToolMouseEventArgs e)
document.Layers.ToolLayer.Clear ();
if (undo_surface != null) {
+
string name = is_newly_created
? Translations.GetString ("Gradient Created")
: Translations.GetString ("Gradient Modified");
- document.History.PushNewItem (new GradientHistoryItem (Icon, name, undo_surface,
- document.Layers.CurrentUserLayerIndex, undo_data!.Value, this));
+
+ document.History.PushNewItem (
+ new GradientHistoryItem (
+ Icon,
+ name,
+ undo_surface,
+ document.Layers.CurrentUserLayerIndex,
+ undo_data!.Value,
+ this),
+ PintaCore.Actions.Edit
+ );
}
is_newly_created = false;
@@ -211,8 +221,16 @@ private void Finalize (Document? document)
if (document != null) {
undo_data = Data;
undo_surface = document.Layers.CurrentUserLayer.Surface.Clone ();
- document.History.PushNewItem (new GradientHistoryItem (Icon, Name + " " + Translations.GetString ("Finalized"), undo_surface,
- document.Layers.CurrentUserLayerIndex, undo_data!.Value, this));
+ document.History.PushNewItem (
+ new GradientHistoryItem (
+ Icon,
+ Name + " " + Translations.GetString ("Finalized"),
+ undo_surface,
+ document.Layers.CurrentUserLayerIndex,
+ undo_data!.Value,
+ this),
+ PintaCore.Actions.Edit
+ );
}
handle.Active = false;
}
diff --git a/Pinta.Tools/Tools/LassoSelectTool.cs b/Pinta.Tools/Tools/LassoSelectTool.cs
index 4392d1d64c..e8d9a2a3fb 100644
--- a/Pinta.Tools/Tools/LassoSelectTool.cs
+++ b/Pinta.Tools/Tools/LassoSelectTool.cs
@@ -149,7 +149,7 @@ private void FinalizeShape (Document document)
{
if (hist != null) {
if (lasso_polygon.Count > 1)
- document.History.PushNewItem (hist);
+ document.History.PushNewItem (hist, PintaCore.Actions.Edit);
hist = null;
}
lasso_polygon.Clear ();
diff --git a/Pinta.Tools/Tools/MagicWandTool.cs b/Pinta.Tools/Tools/MagicWandTool.cs
index 25adb05a5b..2353141bf0 100644
--- a/Pinta.Tools/Tools/MagicWandTool.cs
+++ b/Pinta.Tools/Tools/MagicWandTool.cs
@@ -80,7 +80,7 @@ protected override void OnFillRegionComputed (Document document, IReadOnlyList
Date: Mon, 20 Apr 2026 02:56:29 +0200
Subject: [PATCH 3/4] Deleted unnecessary code
---
Pinta.Core/Classes/DocumentWorkspace.cs | 5 -----
1 file changed, 5 deletions(-)
diff --git a/Pinta.Core/Classes/DocumentWorkspace.cs b/Pinta.Core/Classes/DocumentWorkspace.cs
index 2177881a33..b28eef86bc 100644
--- a/Pinta.Core/Classes/DocumentWorkspace.cs
+++ b/Pinta.Core/Classes/DocumentWorkspace.cs
@@ -110,11 +110,6 @@ public void SetScale (double value, ToolManager tools)
ViewSize = GetNewViewSize (document.ImageSize, value);
Invalidate ();
-
- if (tools.CurrentTool?.CursorChangesOnZoom == true) {
- //The current tool's cursor changes when the zoom changes.
- tools.CurrentTool.SetCursor (tools.CurrentTool.CurrentCursor);
- }
}
///
From 500f60edecd311f8d35240df63c58ea6ad992b1c Mon Sep 17 00:00:00 2001
From: Lehonti Ramos <17771375+Lehonti@users.noreply.github.com>
Date: Sat, 25 Apr 2026 23:10:51 +0200
Subject: [PATCH 4/4] Removed unused (?) `tools` parameter
---
Pinta.Core/Actions/ImageActions.cs | 2 +-
Pinta.Core/Classes/Document.cs | 4 ++--
Pinta.Core/Classes/DocumentWorkspace.cs | 2 +-
Pinta.Core/Managers/WorkspaceManager.cs | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Pinta.Core/Actions/ImageActions.cs b/Pinta.Core/Actions/ImageActions.cs
index d814c2a4a8..46a7baf212 100644
--- a/Pinta.Core/Actions/ImageActions.cs
+++ b/Pinta.Core/Actions/ImageActions.cs
@@ -303,7 +303,7 @@ void CropImageToRectangle (Document doc, RectangleI rect, Path? selection)
double original_scale = doc.Workspace.Scale;
doc.ImageSize = rect.Size;
doc.Workspace.ViewSize = rect.Size;
- doc.Workspace.SetScale (original_scale, tools);
+ doc.Workspace.SetScale (original_scale);
view.UpdateCanvasScale ();
diff --git a/Pinta.Core/Classes/Document.cs b/Pinta.Core/Classes/Document.cs
index dcb4dbe214..4be18bf85b 100644
--- a/Pinta.Core/Classes/Document.cs
+++ b/Pinta.Core/Classes/Document.cs
@@ -345,7 +345,7 @@ public void ResizeCanvas (
ResetSelectionPaths ();
- Workspace.SetScale (scale, tools);
+ Workspace.SetScale (scale);
}
public void ResizeImage (
@@ -374,7 +374,7 @@ public void ResizeImage (
ResetSelectionPaths ();
- Workspace.SetScale (scale, tools);
+ Workspace.SetScale (scale);
actions.View.UpdateCanvasScale ();
}
diff --git a/Pinta.Core/Classes/DocumentWorkspace.cs b/Pinta.Core/Classes/DocumentWorkspace.cs
index b28eef86bc..e8e5e30bfa 100644
--- a/Pinta.Core/Classes/DocumentWorkspace.cs
+++ b/Pinta.Core/Classes/DocumentWorkspace.cs
@@ -101,7 +101,7 @@ public bool ImageFitsInWindow {
public double Scale
=> ViewSize.Width / (double) document.ImageSize.Width;
- public void SetScale (double value, ToolManager tools)
+ public void SetScale (double value)
{
if (value == ViewSize.Width / (double) document.ImageSize.Width && value == ViewSize.Height / (double) document.ImageSize.Height)
return;
diff --git a/Pinta.Core/Managers/WorkspaceManager.cs b/Pinta.Core/Managers/WorkspaceManager.cs
index ad3a38110c..2bc17bd32f 100644
--- a/Pinta.Core/Managers/WorkspaceManager.cs
+++ b/Pinta.Core/Managers/WorkspaceManager.cs
@@ -203,7 +203,7 @@ public Size CanvasSize {
public double Scale {
get => ActiveWorkspace.Scale;
- set => ActiveWorkspace.SetScale (value, PintaCore.Tools);
+ set => ActiveWorkspace.SetScale (value);
}
private readonly List open_documents;