Skip to content

Commit

Permalink
Experiment with using a flowbox layout to handle the toolbox widget o…
Browse files Browse the repository at this point in the history
…verflowing

This produces multiple columns instead of introducing a scrollbar that can interfere with clicks.
  • Loading branch information
cameronwhite committed Jan 4, 2024
1 parent 2123881 commit ae7dbfd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Pinta.Core/Managers/ChromeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public sealed class ChromeManager

public Box MainToolBar { get; private set; } = null!;
public Box ToolToolBar { get; private set; } = null!;
public Box ToolBox { get; private set; } = null!;
public Widget ToolBox { get; private set; } = null!;
public Box StatusBar { get; private set; } = null!;

public IProgressDialog ProgressDialog => progress_dialog;
Expand Down Expand Up @@ -108,7 +108,7 @@ public void InitializeStatusBar (Box statusbar)
StatusBar = statusbar;
}

public void InitializeToolBox (Box toolbox)
public void InitializeToolBox (Widget toolbox)
{
ToolBox = toolbox;
}
Expand Down
20 changes: 9 additions & 11 deletions Pinta.Gui.Widgets/Widgets/ToolBoxWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Pinta.Gui.Widgets;

public sealed class ToolBoxWidget : Box
public sealed class ToolBoxWidget : FlowBox
{
public ToolBoxWidget ()
{
Expand All @@ -15,21 +15,19 @@ public ToolBoxWidget ()
PintaCore.Tools.ToolRemoved += HandleToolRemoved;

SetOrientation (Orientation.Vertical);
Spacing = 0;
ColumnSpacing = 0;
RowSpacing = 0;
Homogeneous = true;
MinChildrenPerLine = 6;
MaxChildrenPerLine = 1024; // If there is enough vertical space, only use one column
Vexpand = false;
Valign = Align.Start;
}

public void AddItem (ToolBoxButton item)
{
var index = PintaCore.Tools.ToList ().IndexOf (item.Tool);

Widget? prev_widget = null;
if (index > 0) {
prev_widget = GetFirstChild ();
for (int i = 1; i < index; ++i)
prev_widget = prev_widget!.GetNextSibling ();
}

InsertChildAfter (item.Tool.ToolItem, prev_widget);
Insert (item.Tool.ToolItem, index);
}

public void RemoveItem (ToolBoxButton item)
Expand Down
2 changes: 1 addition & 1 deletion Pinta/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ private void CreateDockAndPads (Box container)
var toolbox_scroll = new ScrolledWindow () {
Child = toolbox,
HscrollbarPolicy = PolicyType.Never,
VscrollbarPolicy = PolicyType.Automatic,
VscrollbarPolicy = PolicyType.Never,
HasFrame = false,
OverlayScrolling = true,
WindowPlacement = CornerType.BottomRight
Expand Down

0 comments on commit ae7dbfd

Please sign in to comment.