Skip to content

Commit

Permalink
Merge pull request #147 from tdgroot/palette_switch_shortcut_key
Browse files Browse the repository at this point in the history
Add shortcut key for switching palette color
  • Loading branch information
cameronwhite authored Sep 16, 2020
2 parents 57e3769 + ae5625b commit 6cca013
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Pinta.Core/Managers/PaletteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
// THE SOFTWARE.

using System;
using Gtk;
using Cairo;

namespace Pinta.Core
Expand Down Expand Up @@ -71,6 +72,15 @@ public PaletteManager ()
SecondaryColor = new Color (1, 1, 1);
}

public void DoKeyRelease (object o, KeyReleaseEventArgs e)
{
if (e.Event.Key.ToString().ToUpper() == "X") {
Color temp = PintaCore.Palette.PrimaryColor;
PintaCore.Palette.PrimaryColor = PintaCore.Palette.SecondaryColor;
PintaCore.Palette.SecondaryColor = temp;
}
}

#region Protected Methods
protected void OnPrimaryColorChanged ()
{
Expand Down
1 change: 1 addition & 0 deletions Pinta.Gui.Widgets/Widgets/Canvas/PintaCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ public void DoKeyPressEvent (object o, KeyPressEventArgs e)
public void DoKeyReleaseEvent (object o, KeyReleaseEventArgs e)
{
PintaCore.Tools.CurrentTool.DoKeyRelease (this, e);
PintaCore.Palette.DoKeyRelease (this, e);
}
#endregion
}
Expand Down
7 changes: 6 additions & 1 deletion Pinta.Gui.Widgets/Widgets/ColorPaletteWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,12 @@ private void HandleQueryTooltip (object o, Gtk.QueryTooltipArgs args)
string text = null;

if (swap_rect.ContainsPoint (x, y)) {
text = Catalog.GetString ("Click to switch between primary and secondary color.");
text = string.Format (
"{0} {1}: {2}",
Catalog.GetString ("Click to switch between primary and secondary color."),
Catalog.GetString ("Shortcut key"),
"X"
);
} else if (reset_rect.ContainsPoint (x, y)) {
text = Catalog.GetString ("Click to reset primary and secondary color.");
} else if (primary_rect.ContainsPoint (x, y)) {
Expand Down

0 comments on commit 6cca013

Please sign in to comment.