Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Pinta.Core/Actions/EditActions.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//

Check failure on line 1 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.

Check failure on line 1 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.
// EditActions.cs

Check failure on line 2 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.

Check failure on line 2 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.
//

Check failure on line 3 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.

Check failure on line 3 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.
// Author:

Check failure on line 4 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.

Check failure on line 4 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.
// Jonathan Pobst <monkey@jpobst.com>

Check failure on line 5 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.

Check failure on line 5 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.
//

Check failure on line 6 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.

Check failure on line 6 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.
// Copyright (c) 2010 Jonathan Pobst

Check failure on line 7 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.

Check failure on line 7 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.
//

Check failure on line 8 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.

Check failure on line 8 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.
// Permission is hereby granted, free of charge, to any person obtaining a copy

Check failure on line 9 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.

Check failure on line 9 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.
// of this software and associated documentation files (the "Software"), to deal

Check failure on line 10 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.

Check failure on line 10 in Pinta.Core/Actions/EditActions.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (10.0.x)

Fix whitespace formatting. Replace 1 characters with '\n'.
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
Expand Down Expand Up @@ -47,6 +47,7 @@
public Command OffsetSelection { get; }
public Command SelectAll { get; }
public Command Deselect { get; }
public Command DeselectSelection { get; }
public Command LoadPalette { get; }
public Command SavePalette { get; }
public Command ResetPalette { get; }
Expand All @@ -55,6 +56,8 @@
private Gio.File? last_palette_dir = null;
private Document? active_document = null;

private static readonly string[] selection_tools = ["Pinta.Tools.EllipseSelectTool", "Pinta.Tools.RectangleSelectTool", "Pinta.Tools.LassoSelectTool"];

private readonly ChromeManager chrome;
private readonly PaletteFormatManager palette_formats;
private readonly PaletteManager palette;
Expand Down Expand Up @@ -166,6 +169,13 @@
Resources.Icons.EditSelectionNone,
shortcuts: ["<Primary><Shift>A", "<Ctrl>D"]);

DeselectSelection = new Command (
"deselect",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Giving this command the same identifier as the other deselect command will probably cause some issues - e.g. on macOS this seems to cause the menu item to not show its shortcut.

However, I think it'd be worth trying to just merge this with the other command and just add Escape as an alternative shortcut which works while in any tool (matching Paint.NET behaviour). The only thing to test would be to verify that the text tool can still handle Escape to finish editing the text while a selection is active, then pressing Escape again would clear the selection

Translations.GetString ("Deselect All"),
null,
Resources.Icons.EditSelectionNone,
shortcuts: ["Escape"]);

LoadPalette = new Command (
"loadpalette",
Translations.GetString ("Open..."),
Expand Down Expand Up @@ -250,6 +260,7 @@

SelectAll,
Deselect,
DeselectSelection,

EraseSelection,
FillSelection,
Expand All @@ -270,6 +281,7 @@
public void RegisterHandlers ()
{
Deselect.Activated += HandlePintaCoreActionsEditDeselectActivated;
DeselectSelection.Activated += HandlePintaCoreActionsEditDeselectSelectionActivated;
EraseSelection.Activated += HandlePintaCoreActionsEditEraseSelectionActivated;
SelectAll.Activated += HandlePintaCoreActionsEditSelectAllActivated;
FillSelection.Activated += HandlePintaCoreActionsEditFillSelectionActivated;
Expand Down Expand Up @@ -391,6 +403,16 @@
doc.Workspace.Invalidate ();
}

private void HandlePintaCoreActionsEditDeselectSelectionActivated (object sender, EventArgs e)
{

if (!selection_tools.Contains (tools.CurrentTool?.ToString ())) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an IsSelectionTool property that can be checked on the current tool instead of hardcoding names, but we may not need to check this anyways (see other comment)

return;
}

HandlePintaCoreActionsEditDeselectActivated (sender,e);
}

private void HandlerPintaCoreActionsEditCopyActivated (object sender, EventArgs e)
{
Document doc = workspace.ActiveDocument;
Expand Down
Loading