Skip to content

Commit

Permalink
Make the tool box fixed on the left with a single column.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpobst committed Dec 21, 2020
1 parent f4e1508 commit 0518f7c
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 216 deletions.
6 changes: 6 additions & 0 deletions Pinta.Core/Actions/ViewActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class ViewActions
public ToggleCommand ImageTabs { get; private set; }
public ToggleCommand PixelGrid { get; private set; }
public ToggleCommand StatusBar { get; private set; }
public ToggleCommand ToolBox { get; private set; }
public ToggleCommand Rulers { get; private set; }
public GLib.SimpleAction RulerMetric { get; private set; }
public Command Fullscreen { get; private set; }
Expand Down Expand Up @@ -71,6 +72,7 @@ public ViewActions ()
ImageTabs = new ToggleCommand ("ImageTabs", Translations.GetString ("Image Tabs"), null, null);
PixelGrid = new ToggleCommand ("PixelGrid", Translations.GetString ("Pixel 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);
Rulers = new ToggleCommand ("Rulers", Translations.GetString ("Rulers"), null, Resources.Icons.ViewRulers);
RulerMetric = new GLib.SimpleAction("rulermetric", GLib.VariantType.Int32, new GLib.Variant(0));
Fullscreen = new Command ("Fullscreen", Translations.GetString ("Fullscreen"), null, Resources.StandardIcons.DocumentNew);
Expand Down Expand Up @@ -107,6 +109,7 @@ public ViewActions ()
ToolBar.Value = true;
ImageTabs.Value = true;
StatusBar.Value = true;
ToolBox.Value = true;
}

#region Initialization
Expand All @@ -118,6 +121,9 @@ public void RegisterActions(Gtk.Application app, GLib.Menu menu)
app.AddAction (StatusBar);
menu.AppendItem (StatusBar.CreateMenuItem ());

app.AddAction (ToolBox);
menu.AppendItem (ToolBox.CreateMenuItem ());

app.AddAction(PixelGrid);
menu.AppendItem(PixelGrid.CreateMenuItem());

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 class ChromeManager
public Toolbar MainToolBar { get { return main_toolbar; } }
public Window MainWindow { get { return main_window; } }
public Statusbar StatusBar { get; private set; }
public Toolbar ToolBox { get; private set; }

public IProgressDialog ProgressDialog { get { return progress_dialog; } }
public GLib.Menu AdjustmentsMenu { get; private set; }
Expand Down Expand Up @@ -99,6 +100,11 @@ public void InitializeStatusBar (Statusbar statusbar)
StatusBar = statusbar;
}

public void InitializeToolBox (Toolbar toolbox)
{
ToolBox = toolbox;
}

public void InitializeWindowShell (Window shell)
{
main_window = shell;
Expand Down
16 changes: 9 additions & 7 deletions Pinta.Gui.Widgets/Widgets/ToolBoxWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,31 @@

namespace Pinta.Gui.Widgets
{
[System.ComponentModel.ToolboxItem (true)]
public class ToolBoxWidget : WrappingPaletteContainer
public class ToolBoxWidget : Toolbar
{
public ToolBoxWidget () : base(16)
public ToolBoxWidget ()
{
HeightRequest = 375;

PintaCore.Tools.ToolAdded += HandleToolAdded;
PintaCore.Tools.ToolRemoved += HandleToolRemoved;

Orientation = Orientation.Vertical;
ToolbarStyle = ToolbarStyle.Icons;

ShowAll ();
}

// TODO: This should handle sorting the items
public void AddItem (ToolButton item)
{
Append(item);
item.IsImportant = false;
Add (item);
}

public void RemoveItem (ToolButton item)
{
//Run a remove on both tables since it might be in either
Remove(item);
Remove (item);
}

private void HandleToolAdded (object sender, ToolEventArgs e)
Expand Down
164 changes: 0 additions & 164 deletions Pinta.Gui.Widgets/WrappingPaletteContainer.cs

This file was deleted.

18 changes: 9 additions & 9 deletions Pinta.Tools/CoreToolsExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,28 @@ public void Initialize ()
PintaCore.PaintBrushes.AddPaintBrush (new Brushes.SplatterBrush ());
PintaCore.PaintBrushes.AddPaintBrush (new Brushes.SquaresBrush ());

PintaCore.Tools.AddTool (new RectangleSelectTool ());
PintaCore.Tools.AddTool (new MoveSelectedTool ());
PintaCore.Tools.AddTool (new LassoSelectTool ());
PintaCore.Tools.AddTool (new MoveSelectionTool ());
PintaCore.Tools.AddTool (new EllipseSelectTool ());
PintaCore.Tools.AddTool (new ZoomTool ());
PintaCore.Tools.AddTool (new MagicWandTool ());
PintaCore.Tools.AddTool (new PanTool ());
PintaCore.Tools.AddTool (new PaintBucketTool ());
PintaCore.Tools.AddTool (new GradientTool ());
PintaCore.Tools.AddTool (new RectangleSelectTool ());
PintaCore.Tools.AddTool (new EllipseSelectTool ());
PintaCore.Tools.AddTool (new LassoSelectTool ());
PintaCore.Tools.AddTool (new MagicWandTool ());
PintaCore.Tools.AddTool (new PaintBrushTool ());
PintaCore.Tools.AddTool (new EraserTool ());
PintaCore.Tools.AddTool (new PencilTool ());
PintaCore.Tools.AddTool (new EraserTool ());
PintaCore.Tools.AddTool (new PaintBucketTool ());
PintaCore.Tools.AddTool (new GradientTool ());
PintaCore.Tools.AddTool (new ColorPickerTool ());
PintaCore.Tools.AddTool (new CloneStampTool ());
PintaCore.Tools.AddTool (new RecolorTool ());
PintaCore.Tools.AddTool (new TextTool ());
PintaCore.Tools.AddTool (new LineCurveTool ());
PintaCore.Tools.AddTool (new RectangleTool ());
PintaCore.Tools.AddTool (new RoundedRectangleTool ());
PintaCore.Tools.AddTool (new EllipseTool ());
PintaCore.Tools.AddTool (new FreeformShapeTool ());
PintaCore.Tools.AddTool (new CloneStampTool ());
PintaCore.Tools.AddTool (new RecolorTool ());
}

public void Uninitialize ()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//
// ToolBoxPad.cs
//
// ToolBoxToggledAction.cs
//
// Author:
// Jonathan Pobst <[email protected]>
//
// Copyright (c) 2011 Jonathan Pobst
// Copyright (c) 2020 Jonathan Pobst
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,42 +24,29 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using Gtk;
using Pinta.Docking;
using System;
using Pinta.Core;
using Pinta.Gui.Widgets;
using Gtk;

namespace Pinta
namespace Pinta.Actions
{
public class ToolBoxPad : IDockPad
class ToolBoxToggledAction : IActionHandler
{
public void Initialize (Dock workspace, Application app, GLib.Menu padMenu)
#region IActionHandler Members
public void Initialize ()
{
ToolBoxWidget toolbox = new ToolBoxWidget () { Name = "toolbox" };

DockItem toolbox_item = new DockItem(toolbox, "Toolbox")
{
Label = Translations.GetString("Tools")
};

// TODO-GTK3 (docking)
#if false
toolbox_item.Content = toolbox;
toolbox_item.Icon = Gtk.IconTheme.Default.LoadIcon(Resources.Icons.ToolPencil, 16);
toolbox_item.Behavior |= DockItemBehavior.CantClose;
toolbox_item.DefaultWidth = 35;
#endif
workspace.AddItem(toolbox_item, DockPlacement.Left);
PintaCore.Actions.View.ToolBox.Toggled += Activated;
}

var show_toolbox = new ToggleCommand("Tools", Translations.GetString("Tools"), null, Resources.Icons.ToolPencil)
{
Value = true
};
app.AddAction(show_toolbox);
padMenu.AppendItem(show_toolbox.CreateMenuItem());
public void Uninitialize ()
{
PintaCore.Actions.View.ToolBox.Toggled -= Activated;
}
#endregion

show_toolbox.Toggled += (val) => { toolbox_item.Visible = val; };
toolbox_item.VisibilityNotifyEvent += (o, args) => { show_toolbox.Value = toolbox_item.Visible; };
private void Activated (bool value)
{
PintaCore.Chrome.ToolBox.Visible = value;
}
}
}
1 change: 1 addition & 0 deletions Pinta/DialogHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public ActionHandlers ()
action_handlers.Add (new ToolBarToggledAction ());
action_handlers.Add (new ImageTabsToggledAction ());
action_handlers.Add (new StatusBarToggledAction ());
action_handlers.Add (new ToolBoxToggledAction ());

// Window
action_handlers.Add (new CloseAllDocumentsAction ());
Expand Down
8 changes: 4 additions & 4 deletions Pinta/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,13 @@ private void CreateDockAndPads (HBox container)
fact.Add ("Pinta.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Pinta.png")));
fact.AddDefault ();

var toolbox = new ToolBoxWidget ();
container.PackStart (toolbox, false, false, 0);
PintaCore.Chrome.InitializeToolBox (toolbox);

// Dock widget
dock = new Dock ();

// Toolbox pad
var toolboxpad = new ToolBoxPad ();
toolboxpad.Initialize (dock, this, show_pad);

// Canvas pad
canvas_pad = new CanvasPad ();
canvas_pad.Initialize (dock);
Expand Down

0 comments on commit 0518f7c

Please sign in to comment.