From c92a84848fcca985e625b12f29a44e605abae952 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 7 Jun 2026 13:04:16 +0200 Subject: [PATCH] Lay document tabs out on multiple rows #3753: when many documents are open, the tab strip scrolls a single row, hiding most tabs behind the overflow scroller. Dock's DocumentTabStrip hardcodes a horizontal StackPanel inside a PART_ScrollViewer in its theme template and ignores an ItemsPanel set via a Style, so a MultiRowTabStripBehavior sets the WrapPanel ItemsPanel directly and disables the scroll-viewer's horizontal scrolling, giving the WrapPanel a bounded width so tabs wrap onto new rows. Enabled on the document strip (not tool tabs) from App.axaml. Drag-reorder across rows is not yet validated (Dock's drop-position logic assumes a single horizontal strip), so this stays an opt-in prototype for now rather than a closing fix for the issue. Assisted-by: Claude:claude-opus-4-8:Claude Code --- ILSpy.Tests/Docking/MultiRowTabStripTests.cs | 78 ++++++++++++++++++ ILSpy/App.axaml | 4 + ILSpy/Themes/MultiRowTabStripBehavior.cs | 84 ++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 ILSpy.Tests/Docking/MultiRowTabStripTests.cs create mode 100644 ILSpy/Themes/MultiRowTabStripBehavior.cs diff --git a/ILSpy.Tests/Docking/MultiRowTabStripTests.cs b/ILSpy.Tests/Docking/MultiRowTabStripTests.cs new file mode 100644 index 000000000..e19da8a49 --- /dev/null +++ b/ILSpy.Tests/Docking/MultiRowTabStripTests.cs @@ -0,0 +1,78 @@ +// Copyright (c) 2026 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Linq; +using System.Threading.Tasks; + +using Avalonia.Controls; +using Avalonia.Headless.NUnit; +using Avalonia.Threading; +using Avalonia.VisualTree; + +using AwesomeAssertions; + +using Dock.Avalonia.Controls; + +using ILSpy.AppEnv; +using ILSpy.TextView; +using ILSpy.ViewModels; +using ILSpy.Views; + +using NUnit.Framework; + +namespace ICSharpCode.ILSpy.Tests.Docking; + +/// +/// PROTOTYPE check: with MultiRowTabStripBehavior enabled (App.axaml), many document tabs flow onto +/// multiple rows (a WrapPanel) instead of a single scrolling row. +/// +[TestFixture] +public class MultiRowTabStripTests +{ + [AvaloniaTest] + public async Task Many_Document_Tabs_Wrap_To_Multiple_Rows() + { + var window = AppComposition.Current.GetExport(); + window.Show(); + var vm = (MainWindowViewModel)window.DataContext!; + await vm.AssemblyTreeModel.WaitForAssembliesAsync(minimumCount: 1); + + for (int i = 0; i < 40; i++) + vm.DockWorkspace.OpenNewTab(new DecompilerTabPageModel { Title = $"Tab number {i:00}" }); + + for (int i = 0; i < 12; i++) + { + Dispatcher.UIThread.RunJobs(); + window.UpdateLayout(); + await Task.Delay(20); + } + + var strip = window.GetVisualDescendants().OfType().FirstOrDefault(); + strip.Should().NotBeNull("the document tab strip must be realised"); + + strip!.GetVisualDescendants().OfType().Should().NotBeEmpty( + "the behaviour must swap the strip's ItemsPanel to a WrapPanel"); + + var rows = strip.GetVisualDescendants().OfType() + .Where(it => it.Bounds.Width > 0) + .Select(it => System.Math.Round(it.Bounds.Y)) + .Distinct().ToList(); + + rows.Count.Should().BeGreaterThan(1, "40 tabs must wrap onto more than one row"); + } +} diff --git a/ILSpy/App.axaml b/ILSpy/App.axaml index addac8231..b015ea473 100644 --- a/ILSpy/App.axaml +++ b/ILSpy/App.axaml @@ -285,6 +285,10 @@ + +