Skip to content
Draft
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions Pinta.Core/Actions/FileActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public sealed class FileActions
public Command Close { get; }
public Command Save { get; }
public Command SaveAs { get; }
public Command SelectionSettings { get; }
public Command Print { get; }

public event EventHandler<ModifyCompressionEventArgs>? ModifyCompression;
Expand Down Expand Up @@ -97,6 +98,12 @@ public FileActions (SystemManager system, AppActions app)
Resources.StandardIcons.DocumentSaveAs,
shortcuts: ["<Primary><Shift>S"]);

SelectionSettings = new Command (
"selectionSettings",
Translations.GetString ("Selection Settings..."),
null,
null);

Print = new Command (
"print",
Translations.GetString ("Print"),
Expand All @@ -115,6 +122,9 @@ public void RegisterActions (Gtk.Application application, Gio.Menu menu)
save_section.AppendItem (Save.CreateMenuItem ());
save_section.AppendItem (SaveAs.CreateMenuItem ());

var selection_settings_section = Gio.Menu.New ();
selection_settings_section.AppendItem (SelectionSettings.CreateMenuItem ());

Gio.Menu close_section = Gio.Menu.New ();
close_section.AppendItem (Close.CreateMenuItem ());
if (!isMac) close_section.AppendItem (app.Exit.CreateMenuItem ()); // This is part of the application menu on macOS
Expand All @@ -123,6 +133,7 @@ public void RegisterActions (Gtk.Application application, Gio.Menu menu)
menu.AppendItem (NewScreenshot.CreateMenuItem ());
menu.AppendItem (Open.CreateMenuItem ());
menu.AppendSection (null, save_section);
menu.AppendSection (null, selection_settings_section);
menu.AppendSection (null, close_section);
#if false
// Printing is disabled for now until it is fully functional.
Expand All @@ -137,6 +148,8 @@ public void RegisterActions (Gtk.Application application, Gio.Menu menu)
Save,
SaveAs,

SelectionSettings,

Close]);

if (!isMac)
Expand Down
2 changes: 2 additions & 0 deletions Pinta.Core/FriendAssemblies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
[assembly: InternalsVisibleTo ("Pinta.Core.Tests")]
[assembly: InternalsVisibleTo ("Pinta.Effects.Tests")]
[assembly: InternalsVisibleTo ("PintaBenchmarks")]
[assembly: InternalsVisibleTo ("Pinta.Gui.Widgets")]
[assembly: InternalsVisibleTo ("Pinta")]
2 changes: 2 additions & 0 deletions Pinta.Core/SettingNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ internal static string ToolAntialias (BaseTool tool)

internal static string ToolAlphaBlend (BaseTool tool)
=> $"{tool.GetType ().Name.ToLowerInvariant ()}-alpha-blend";

internal const string SELECTION_ANIMATION = "selection-animation";
}
4 changes: 3 additions & 1 deletion Pinta.Gui.Widgets/Widgets/Canvas/PintaCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public PintaCanvas (
document.SelectionChanged += (_, _) => QueueSelectionUpdate ();

// Timer for selection outline animation
selection_animation_timer_id = GLib.Functions.TimeoutAdd (GLib.Constants.PRIORITY_DEFAULT, 80, SelectionAnimationTick);
bool selectionAnimation = PintaCore.Settings.GetSetting ( SettingNames.SELECTION_ANIMATION, true);
if (selectionAnimation)
selection_animation_timer_id = GLib.Functions.TimeoutAdd (GLib.Constants.PRIORITY_DEFAULT, 80, SelectionAnimationTick);

// If there is additional space available, keep the image centered and prevent stretching.
Hexpand = false;
Expand Down
2 changes: 2 additions & 0 deletions Pinta/ActionHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

using System.Collections.Generic;
using Pinta.Actions;
using Pinta.Actions.File;
using Pinta.Core;

namespace Pinta;
Expand Down Expand Up @@ -58,6 +59,7 @@ public ActionHandlers ()
new SaveDocumentImplmentationAction (actions.File, actions.Image, chrome, imageFormats, recentFiles, tools),
new ModifyCompressionAction (actions.File),
//new PrintDocumentAction ();
new SelectionSettingsAction (chrome),
new CloseDocumentAction (actions, chrome, workspace, tools),
new ExitProgramAction (actions, chrome, workspace),

Expand Down
37 changes: 37 additions & 0 deletions Pinta/Actions/File/SelectionSettingsAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

using System;
using Pinta.Core;

namespace Pinta.Actions.File;

public sealed class SelectionSettingsAction : IActionHandler
{
private readonly ChromeManager chrome;

public SelectionSettingsAction (
ChromeManager chrome)
{
this.chrome = chrome;
}

public void Initialize ()
{
PintaCore.Actions.File.SelectionSettings.Activated += OnActivated;
}

public void Uninitialize ()
{
PintaCore.Actions.File.SelectionSettings.Activated -= OnActivated;
}

private void OnActivated (object? sender, EventArgs e)
{
var dialog = new SelectionSettingsDialog (
PintaCore.Chrome,
PintaCore.Settings.GetSetting(
Pinta.Core.SettingNames.SELECTION_ANIMATION,
true));

dialog.Show ();
}
}
48 changes: 48 additions & 0 deletions Pinta/Dialogs/SelectionSettingsDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Pinta.Core;
using Pinta.Gui.Widgets;

namespace Pinta;

public sealed class SelectionSettingsDialog : Gtk.Dialog
{
public SelectionSettingsDialog (
ChromeManager chrome,
bool selectionAnimation)
{
var checkbox = Gtk.CheckButton.NewWithLabel (
Translations.GetString ("Marching Ants"));

checkbox.Active = selectionAnimation;

var label = Gtk.Label.New (
Translations.GetString (
"Restart Pinta to apply this setting."));

var box = this.GetContentAreaBox ();
box.SetAllMargins (12);
box.Append (checkbox);
box.Append (label);


Title = Translations.GetString ("Selection Settings");
TransientFor = chrome.MainWindow;
Modal = true;


this.AddCancelOkButtons ();
this.SetDefaultResponse (Gtk.ResponseType.Ok);


OnResponse += (o,args) =>
{
if (args.ResponseId == (int) Gtk.ResponseType.Ok)
{
PintaCore.Settings.PutSetting (
Pinta.Core.SettingNames.SELECTION_ANIMATION,
checkbox.Active);
}

Destroy();
};
}
}