Skip to content

Commit

Permalink
Add a menu option to hide the tool window panel
Browse files Browse the repository at this point in the history
This allows the panel to be completely hidden (which takes up less space than minimizing the tool windows). The menu options for minimizing the individual panels were also unnecessary since the minimizing can be done through the UI widgets

Fixes: #1179
  • Loading branch information
cameronwhite committed Dec 22, 2024
1 parent 7e4bf3d commit 88567f7
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 49 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Thanks to the following contributors who worked on this release:
- Added a "Reseed" button for the random noise used by several effects (such as "Add Noise" and "Frosted Glass"). Previously, the noise pattern changed every time the effect was computed (including when other parameters were changed).
- Saving an image already saved in a format that supports multiple layers to a format that does not support layers will now explicitly prompt the user to flatten the image before saving, rather than silently flattening it (#909)
- The add-in manager dialog now filters out old versions incompatible with the current version of Pinta, or new addins requiring future version of Pinta ([#1580205](https://bugs.launchpad.net/pinta/+bug/1580205))
- The tool windows on the right side of the dock layout can now be completely hidden (#1179)

### Fixed
- Twist effect applied locally based on selection instead of entire image (#1089)
Expand Down
5 changes: 5 additions & 0 deletions Pinta.Core/Actions/ViewActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public sealed class ViewActions
public Command ActualSize { get; }
public ToggleCommand ToolBar { get; }
public ToggleCommand ImageTabs { get; }
public ToggleCommand ToolWindows { get; }
public Command EditCanvasGrid { get; }
public ToggleCommand StatusBar { get; }
public ToggleCommand ToolBox { get; }
Expand Down Expand Up @@ -72,6 +73,7 @@ public ViewActions (ChromeManager chrome, WorkspaceManager workspace)
ActualSize = new Command ("ActualSize", Translations.GetString ("Normal Size"), null, Resources.StandardIcons.ZoomOriginal);
ToolBar = new ToggleCommand ("Toolbar", Translations.GetString ("Toolbar"), null, null);
ImageTabs = new ToggleCommand ("ImageTabs", Translations.GetString ("Image Tabs"), null, null);
ToolWindows = new ToggleCommand ("ToolWindows", Translations.GetString ("Tool Windows"), null, null);
EditCanvasGrid = new Command ("EditCanvasGrid", Translations.GetString ("Canvas Grid..."), null, Resources.Icons.ViewGrid);
StatusBar = new ToggleCommand ("Statusbar", Translations.GetString ("Status Bar"), null, null);
ToolBox = new ToggleCommand ("ToolBox", Translations.GetString ("Tool Box"), null, null);
Expand All @@ -86,6 +88,7 @@ public ViewActions (ChromeManager chrome, WorkspaceManager workspace)
// The toolbar is shown by default.
ToolBar.Value = true;
ImageTabs.Value = true;
ToolWindows.Value = true;
StatusBar.Value = true;
ToolBox.Value = true;

Expand Down Expand Up @@ -149,6 +152,7 @@ public void RegisterActions (Gtk.Application app, Gio.Menu menu)
show_hide_menu.AppendItem (StatusBar.CreateMenuItem ());
show_hide_menu.AppendItem (ToolBox.CreateMenuItem ());
show_hide_menu.AppendItem (ImageTabs.CreateMenuItem ());
show_hide_menu.AppendItem (ToolWindows.CreateMenuItem ());
if (mainToolbarPresent) show_hide_menu.AppendItem (ToolBar.CreateMenuItem ());

Gio.Menu show_hide_section = Gio.Menu.New ();
Expand Down Expand Up @@ -177,6 +181,7 @@ public void RegisterActions (Gtk.Application app, Gio.Menu menu)
app.AddAction (StatusBar);
app.AddAction (ToolBox);
app.AddAction (ImageTabs);
app.AddAction (ToolWindows);
app.AddAction (ColorScheme);

menu.AppendSection (null, zoom_section);
Expand Down
6 changes: 6 additions & 0 deletions Pinta.Core/Managers/ChromeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public sealed class ChromeManager : IChromeService
// but it would be nice to rewrite it to provably non-null.
public Gtk.Application Application { get; private set; } = null!;
public Gtk.Window MainWindow { get; private set; } = null!;
public Gtk.Widget Dock { get; private set; } = null!;
public Gtk.Widget ImageTabsNotebook { get; private set; } = null!;
private IProgressDialog progress_dialog = null!;
private ErrorDialogHandler error_dialog_handler = null!;
Expand Down Expand Up @@ -112,6 +113,11 @@ public void InitializeToolBox (Gtk.Widget toolbox)
ToolBox = toolbox;
}

public void InitializeDock (Gtk.Widget dock)
{
Dock = dock;
}

public void InitializeImageTabsNotebook (Gtk.Widget notebook)
{
ImageTabsNotebook = notebook;
Expand Down
11 changes: 6 additions & 5 deletions Pinta.Docking/Dock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ namespace Pinta.Docking;
/// </summary>
public class Dock : Box
{
private readonly DockPanel right_panel = new ();
private readonly Paned pane = Paned.New (Orientation.Horizontal);

public DockPanel RightPanel {get; private init; } = new();

public Dock ()
{
SetOrientation (Orientation.Horizontal);

pane.EndChild = right_panel;
pane.EndChild = RightPanel;
pane.ResizeEndChild = false;
pane.ShrinkEndChild = false;
Append (pane);
Expand All @@ -54,7 +55,7 @@ public void AddItem (DockItem item, DockPlacement placement)
pane.ShrinkStartChild = false;
break;
case DockPlacement.Right:
right_panel.AddItem (item);
RightPanel.AddItem (item);
break;
}
}
Expand All @@ -66,7 +67,7 @@ public void SaveSettings (ISettingsService settings)
#if false
settings.PutSetting (RightSplitPosKey, pane.Position);
#endif
right_panel.SaveSettings (settings);
RightPanel.SaveSettings (settings);
}

public void LoadSettings (ISettingsService settings)
Expand All @@ -75,6 +76,6 @@ public void LoadSettings (ISettingsService settings)
#if false
pane.Position = settings.GetSetting<int> (RightSplitPosKey, pane.Position);
#endif
right_panel.LoadSettings (settings);
RightPanel.LoadSettings (settings);
}
}
1 change: 1 addition & 0 deletions Pinta/ActionHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public ActionHandlers ()
// View
new ToolBarToggledAction (actions.View, chrome),
new ImageTabsToggledAction (actions.View, chrome),
new ToolWindowsToggledAction (actions.View, chrome),
new StatusBarToggledAction (actions.View, chrome),
new ToolBoxToggledAction (actions.View, chrome),
new ColorSchemeChangedAction (actions.View),
Expand Down
34 changes: 34 additions & 0 deletions Pinta/Actions/View/ToolWindowsToggledAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Pinta.Core;

namespace Pinta.Actions;

internal sealed class ToolWindowsToggledAction : IActionHandler
{
private readonly ViewActions view;
private readonly ChromeManager chrome;
internal ToolWindowsToggledAction (
ViewActions view,
ChromeManager chrome)
{
this.view = view;
this.chrome = chrome;
}

void IActionHandler.Initialize ()
{
view.ToolWindows.Toggled += Activated;
}

void IActionHandler.Uninitialize ()
{
view.ToolWindows.Toggled -= Activated;
}

private void Activated (bool value)
{
var dock = (Docking.Dock) chrome.Dock;
dock.RightPanel.Visible = value;

System.Console.WriteLine ($"visible {value}");
}
}
11 changes: 5 additions & 6 deletions Pinta/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ internal sealed class MainWindow
// NRT - Created in OnActivated
WindowShell window_shell = null!;
Dock dock = null!;
Gio.Menu show_pad = null!;

CanvasPad canvas_pad = null!;

Expand Down Expand Up @@ -373,9 +372,6 @@ private void CreateMainMenu ()
var pad_section = Gio.Menu.New ();
view_menu.AppendSection (null, pad_section);

show_pad = Gio.Menu.New ();
pad_section.AppendSubmenu (Translations.GetString ("Tool Windows"), show_pad);

if (window_shell.HeaderBar is not null) {
var header_bar = window_shell.HeaderBar;
header_bar.PackEnd (new Gtk.MenuButton () {
Expand Down Expand Up @@ -463,6 +459,7 @@ private void CreateDockAndPads (Gtk.Box container)
Hexpand = true,
Halign = Gtk.Align.Fill,
};
PintaCore.Chrome.InitializeDock (dock);

// Canvas pad
canvas_pad = new CanvasPad ();
Expand All @@ -471,11 +468,11 @@ private void CreateDockAndPads (Gtk.Box container)

// Layer pad
LayersPad layers_pad = new (PintaCore.Actions.Layers);
layers_pad.Initialize (dock, app, show_pad);
layers_pad.Initialize (dock);

// History pad
HistoryPad history_pad = new (PintaCore.Actions.Edit);
history_pad.Initialize (dock, app, show_pad);
history_pad.Initialize (dock);

container.Append (dock);
}
Expand All @@ -496,6 +493,7 @@ private void LoadUserSettings ()
PintaCore.Actions.View.StatusBar.Value = PintaCore.Settings.GetSetting ("statusbar-shown", true);
PintaCore.Actions.View.ToolBox.Value = PintaCore.Settings.GetSetting ("toolbox-shown", true);
PintaCore.Actions.View.ImageTabs.Value = PintaCore.Settings.GetSetting ("image-tabs-shown", true);
PintaCore.Actions.View.ToolWindows.Value = PintaCore.Settings.GetSetting ("tool-windows-shown", true);

string dialog_uri = PintaCore.Settings.GetSetting (LastDialogDirSettingKey, PintaCore.RecentFiles.DefaultDialogDirectory?.GetUri () ?? "");
PintaCore.RecentFiles.LastDialogDirectory = Gio.FileHelper.NewForUri (dialog_uri);
Expand All @@ -522,6 +520,7 @@ private void SaveUserSettings ()
PintaCore.Settings.PutSetting ("window-maximized", window_shell.Window.IsMaximized ());
PintaCore.Settings.PutSetting ("ruler-shown", PintaCore.Actions.View.Rulers.Value);
PintaCore.Settings.PutSetting ("image-tabs-shown", PintaCore.Actions.View.ImageTabs.Value);
PintaCore.Settings.PutSetting ("tool-windows-shown", PintaCore.Actions.View.ToolWindows.Value);
PintaCore.Settings.PutSetting ("toolbar-shown", PintaCore.Actions.View.ToolBar.Value);
PintaCore.Settings.PutSetting ("statusbar-shown", PintaCore.Actions.View.StatusBar.Value);
PintaCore.Settings.PutSetting ("toolbox-shown", PintaCore.Actions.View.ToolBox.Value);
Expand Down
20 changes: 1 addition & 19 deletions Pinta/Pads/HistoryPad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ internal HistoryPad (EditActions edit)
this.edit = edit;
}

public void Initialize (
Dock workspace,
Gtk.Application app,
Gio.Menu padMenu)
public void Initialize (Dock workspace)
{
HistoryListView history = new ();
DockItem history_item = new (history, "History", iconName: Pinta.Resources.Icons.HistoryList) {
Expand All @@ -53,20 +50,5 @@ public void Initialize (
history_tb.Append (edit.Redo.CreateDockToolBarItem ());

workspace.AddItem (history_item, DockPlacement.Right);

ToggleCommand show_history = new ("history", Translations.GetString ("History"), null, Resources.Icons.LayerDuplicate) {
Value = true,
};
app.AddAction (show_history);
padMenu.AppendItem (show_history.CreateMenuItem ());

show_history.Toggled += (val) => {
if (val)
history_item.Maximize ();
else
history_item.Minimize ();
};
history_item.MaximizeClicked += (_, _) => show_history.Value = true;
history_item.MinimizeClicked += (_, _) => show_history.Value = false;
}
}
20 changes: 1 addition & 19 deletions Pinta/Pads/LayersPad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ internal LayersPad (LayerActions layerActions)
layer_actions = layerActions;
}

public void Initialize (
Dock workspace,
Gtk.Application app,
Gio.Menu padMenu)
public void Initialize (Dock workspace)
{
LayersListView layers = new ();
DockItem layers_item = new DockItem (layers, "Layers", iconName: Pinta.Resources.Icons.LayerDuplicate) {
Expand All @@ -57,20 +54,5 @@ public void Initialize (
layers_tb.Append (layer_actions.MoveLayerDown.CreateDockToolBarItem ());

workspace.AddItem (layers_item, DockPlacement.Right);

ToggleCommand show_layers = new ("layers", Translations.GetString ("Layers"), null, Resources.Icons.LayerMergeDown) {
Value = true,
};
app.AddAction (show_layers);
padMenu.AppendItem (show_layers.CreateMenuItem ());

show_layers.Toggled += (val) => {
if (val)
layers_item.Maximize ();
else
layers_item.Minimize ();
};
layers_item.MaximizeClicked += (_, _) => show_layers.Value = true;
layers_item.MinimizeClicked += (_, _) => show_layers.Value = false;
}
}

0 comments on commit 88567f7

Please sign in to comment.