From bc5a4f3934dfe73edeb9423d0b4d3015c03bb7b1 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 7 Jun 2026 20:56:34 +0200 Subject: [PATCH] Add single/multi-line document tabs with an overflow dropdown The document tab strip can now flow tabs onto multiple rows or stay a single scrolling row; the mode is toggled by the mouse wheel over the strip and persisted in SessionSettings. In single-line mode an overflow dropdown at the strip's trailing edge lists every open document for quick switching. Popups render in the window overlay layer (OverlayPopups) so the dropdown's menu doesn't open as a native X11 child window that loses focus and self-dismisses before it becomes visible. Assisted-by: Claude:claude-opus-4-8:Claude Code --- .../Docking/DocumentTabStripModeTests.cs | 192 ++++++++++++++++++ ILSpy.Tests/Docking/MultiRowTabStripTests.cs | 55 ++--- .../SessionSettingsMultiLineTabsTests.cs | 59 ++++++ ILSpy/App.axaml | 5 +- ILSpy/Program.cs | 7 +- ILSpy/SessionSettings.cs | 10 + .../DocumentSwitcherDropdownBehavior.cs | 179 ++++++++++++++++ ILSpy/Themes/MultiRowTabStripBehavior.cs | 87 ++++++-- 8 files changed, 552 insertions(+), 42 deletions(-) create mode 100644 ILSpy.Tests/Docking/DocumentTabStripModeTests.cs create mode 100644 ILSpy.Tests/Settings/SessionSettingsMultiLineTabsTests.cs create mode 100644 ILSpy/Themes/DocumentSwitcherDropdownBehavior.cs diff --git a/ILSpy.Tests/Docking/DocumentTabStripModeTests.cs b/ILSpy.Tests/Docking/DocumentTabStripModeTests.cs new file mode 100644 index 000000000..6743f4316 --- /dev/null +++ b/ILSpy.Tests/Docking/DocumentTabStripModeTests.cs @@ -0,0 +1,192 @@ +// 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; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Primitives; +using Avalonia.Headless; +using Avalonia.Input; +using Avalonia.Headless.NUnit; +using Avalonia.Threading; +using Avalonia.VisualTree; + +using AwesomeAssertions; + +using Dock.Avalonia.Controls; + +using ILSpy; +using ILSpy.AppEnv; +using ILSpy.TextView; +using ILSpy.ViewModels; +using ILSpy.Views; + +using NUnit.Framework; + +namespace ICSharpCode.ILSpy.Tests.Docking; + +/// +/// The document tab strip toggles between a single scrolling row and multiple wrapped rows, driven by +/// the persisted setting and the mouse wheel. The +/// overflow dropdown that lists open documents shows only in single-line mode. +/// +[TestFixture] +public class DocumentTabStripModeTests +{ + static SessionSettings Settings => AppComposition.Current.GetExport().SessionSettings; + + static async Task<(MainWindow window, DocumentTabStrip strip)> BootWithTabsAsync(bool multiLine) + { + var (window, vm) = await TestHarness.BootAsync(1); + Settings.MultiLineDocumentTabs = multiLine; + for (int i = 0; i < 30; i++) + vm.DockWorkspace.OpenNewTab(new DecompilerTabPageModel { Title = $"Tab {i:00}" }); + await Pump(window); + var strip = window.GetVisualDescendants().OfType().First(); + return (window, strip); + } + + static async Task Pump(MainWindow window) + { + for (int i = 0; i < 12; i++) + { + Dispatcher.UIThread.RunJobs(); + window.UpdateLayout(); + await Task.Delay(20); + } + } + + static Button? Dropdown(DocumentTabStrip strip) + => strip.GetVisualDescendants().OfType