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 195e5fe758..46a7baf212 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) @@ -300,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.Scale = original_scale; + doc.Workspace.SetScale (original_scale); view.UpdateCanvasScale (); @@ -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 f6c9fade92..8dfd07ba8b 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; } @@ -261,7 +264,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 (); } @@ -273,7 +276,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) @@ -284,7 +287,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) @@ -300,7 +303,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) @@ -316,7 +319,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) @@ -348,7 +351,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) @@ -366,7 +369,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) @@ -383,7 +386,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) @@ -400,6 +403,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 c2143a62b8..4be18bf85b 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,11 +341,11 @@ public void ResizeCanvas ( if (compoundAction is not null) compoundAction.Push (hist); else - Workspace.History.PushNewItem (hist); + Workspace.History.PushNewItem (hist, actions.Edit); ResetSelectionPaths (); - Workspace.Scale = scale; + Workspace.SetScale (scale); } public void ResizeImage ( @@ -370,11 +370,11 @@ public void ResizeImage ( hist.FinishSnapshotOfImage (); - Workspace.History.PushNewItem (hist); + Workspace.History.PushNewItem (hist, actions.Edit); ResetSelectionPaths (); - Workspace.Scale = scale; + Workspace.SetScale (scale); actions.View.UpdateCanvasScale (); } 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 b9af931a07..e8e5e30bfa 100644 --- a/Pinta.Core/Classes/DocumentWorkspace.cs +++ b/Pinta.Core/Classes/DocumentWorkspace.cs @@ -30,9 +30,8 @@ namespace Pinta.Core; public sealed class DocumentWorkspace { - private readonly Document document; - private readonly ActionManager actions; + private readonly Document document; private enum ZoomType { @@ -41,15 +40,11 @@ private enum ZoomType ZoomManually, } - internal DocumentWorkspace ( - ActionManager actions, - Document document) + 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 @@ -103,17 +98,18 @@ 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) + { + 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 (); } /// 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 97e0b03328..2bc17bd32f 100644 --- a/Pinta.Core/Managers/WorkspaceManager.cs +++ b/Pinta.Core/Managers/WorkspaceManager.cs @@ -136,7 +136,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; @@ -203,7 +203,7 @@ public Size CanvasSize { public double Scale { get => ActiveWorkspace.Scale; - set => ActiveWorkspace.Scale = value; + set => ActiveWorkspace.SetScale (value); } private readonly List open_documents; @@ -348,7 +348,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 d229e59c72..032723b978 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 22c638b9a6..d1227b0cc2 100644 --- a/Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs +++ b/Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs @@ -296,8 +296,12 @@ public void HandleBuildToolBar (Gtk.Box tb, ISettingsService settings, string to //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); @@ -617,8 +621,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; @@ -668,8 +672,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. @@ -692,8 +696,8 @@ private void HandleDelete () doc.Layers.CurrentUserLayer, SelectedPointIndex, SelectedShapeIndex, - false - ) + false), + actions.Edit ); @@ -820,7 +824,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)); @@ -849,8 +859,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)); @@ -929,9 +948,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; } @@ -1119,8 +1144,8 @@ private RectangleD DrawFinalized (ShapeEngine engine, bool createHistoryItem, bo doc.Layers.CurrentUserLayer, SelectedPointIndex, SelectedShapeIndex, - false - ) + false), + actions.Edit ); } @@ -1400,8 +1425,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 11d98d7336..11219ea19c 100644 --- a/Pinta.Tools/Tools/BaseBrushTool.cs +++ b/Pinta.Tools/Tools/BaseBrushTool.cs @@ -85,7 +85,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 7a8902ce24..2a2e48747e 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 e64ac1fc74..500e99c5bd 100644 --- a/Pinta.Tools/Tools/GradientTool.cs +++ b/Pinta.Tools/Tools/GradientTool.cs @@ -123,11 +123,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; @@ -183,8 +193,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 039c37b1f9..021e298166 100644 --- a/Pinta.Tools/Tools/MagicWandTool.cs +++ b/Pinta.Tools/Tools/MagicWandTool.cs @@ -90,7 +90,7 @@ protected override void OnFillRegionComputed (Document document, IReadOnlyList