Skip to content

Commit a9e9bfd

Browse files
committed
Added deselect on esc when selection tool active
1 parent c15162a commit a9e9bfd

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Pinta.Core/Actions/EditActions.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public sealed class EditActions
4747
public Command OffsetSelection { get; }
4848
public Command SelectAll { get; }
4949
public Command Deselect { get; }
50+
public Command DeselectSelection { get; }
5051
public Command LoadPalette { get; }
5152
public Command SavePalette { get; }
5253
public Command ResetPalette { get; }
@@ -55,6 +56,8 @@ public sealed class EditActions
5556
private Gio.File? last_palette_dir = null;
5657
private Document? active_document = null;
5758

59+
private static readonly string[] selection_tools = ["Pinta.Tools.EllipseSelectTool", "Pinta.Tools.RectangleSelectTool", "Pinta.Tools.LassoSelectTool"];
60+
5861
private readonly ChromeManager chrome;
5962
private readonly PaletteFormatManager palette_formats;
6063
private readonly PaletteManager palette;
@@ -166,6 +169,13 @@ public EditActions (
166169
Resources.Icons.EditSelectionNone,
167170
shortcuts: ["<Primary><Shift>A", "<Ctrl>D"]);
168171

172+
DeselectSelection = new Command (
173+
"deselect",
174+
Translations.GetString ("Deselect All"),
175+
null,
176+
Resources.Icons.EditSelectionNone,
177+
shortcuts: ["Escape"]);
178+
169179
LoadPalette = new Command (
170180
"loadpalette",
171181
Translations.GetString ("Open..."),
@@ -250,6 +260,7 @@ public void RegisterActions (Gtk.Application app, Gio.Menu menu)
250260

251261
SelectAll,
252262
Deselect,
263+
DeselectSelection,
253264

254265
EraseSelection,
255266
FillSelection,
@@ -270,6 +281,7 @@ public void CreateHistoryWindowToolBar (Gtk.Box toolbar)
270281
public void RegisterHandlers ()
271282
{
272283
Deselect.Activated += HandlePintaCoreActionsEditDeselectActivated;
284+
DeselectSelection.Activated += HandlePintaCoreActionsEditDeselectSelectionActivated;
273285
EraseSelection.Activated += HandlePintaCoreActionsEditEraseSelectionActivated;
274286
SelectAll.Activated += HandlePintaCoreActionsEditSelectAllActivated;
275287
FillSelection.Activated += HandlePintaCoreActionsEditFillSelectionActivated;
@@ -391,6 +403,16 @@ private void HandlePintaCoreActionsEditDeselectActivated (object sender, EventAr
391403
doc.Workspace.Invalidate ();
392404
}
393405

406+
private void HandlePintaCoreActionsEditDeselectSelectionActivated (object sender, EventArgs e)
407+
{
408+
409+
if (!selection_tools.Contains (tools.CurrentTool?.ToString ())) {
410+
return;
411+
}
412+
413+
HandlePintaCoreActionsEditDeselectActivated (sender,e);
414+
}
415+
394416
private void HandlerPintaCoreActionsEditCopyActivated (object sender, EventArgs e)
395417
{
396418
Document doc = workspace.ActiveDocument;

0 commit comments

Comments
 (0)