Browse Source

Add a Display Options "Tab options" group for the tab strip

The document tab strip's multi-row layout and the mouse-wheel gesture
that toggles it were only reachable by the wheel itself, with no
discoverable UI and no way to opt out of the gesture. Surface both as
checkboxes under a new "Tab options" group on the Display page, and add
a MouseWheelTogglesTabStripRows setting (default on) so the wheel toggle
can be turned off while keeping the persisted multi-row choice.

Assisted-by: Claude:claude-opus-4-8:Claude Code
pull/3755/head
Siegfried Pammer 4 weeks ago
parent
commit
af7403c3f2
  1. 25
      ILSpy.Tests/Docking/DocumentTabStripModeTests.cs
  2. 100
      ILSpy.Tests/Options/TabOptionsGroupTests.cs
  3. 9
      ILSpy/Options/DisplaySettingsPanel.axaml
  4. 10
      ILSpy/SessionSettings.cs
  5. 2
      ILSpy/Themes/MultiRowTabStripBehavior.cs

25
ILSpy.Tests/Docking/DocumentTabStripModeTests.cs

@ -134,6 +134,31 @@ public class DocumentTabStripModeTests
{ Settings.MultiLineDocumentTabs = saved; } { Settings.MultiLineDocumentTabs = saved; }
} }
[AvaloniaTest]
public async Task Mouse_Wheel_Does_Not_Toggle_The_Mode_When_The_Setting_Is_Off()
{
var savedMode = Settings.MultiLineDocumentTabs;
var savedGate = Settings.MouseWheelTogglesTabStripRows;
try
{
var (window, strip) = await BootWithTabsAsync(multiLine: false);
Settings.MouseWheelTogglesTabStripRows = false;
await Pump(window);
var point = strip.TranslatePoint(new Point(8, 8), window) ?? new Point(8, 8);
window.MouseWheel(point, new Vector(0, 1));
await Pump(window);
Settings.MultiLineDocumentTabs.Should().BeFalse(
"with the 'mouse wheel toggles' setting off, the wheel must not flip the tab-strip mode");
}
finally
{
Settings.MultiLineDocumentTabs = savedMode;
Settings.MouseWheelTogglesTabStripRows = savedGate;
}
}
[AvaloniaTest] [AvaloniaTest]
public async Task Clicking_The_Dropdown_Opens_A_Populated_Menu() public async Task Clicking_The_Dropdown_Opens_A_Populated_Menu()
{ {

100
ILSpy.Tests/Options/TabOptionsGroupTests.cs

@ -0,0 +1,100 @@
// 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 Avalonia.Controls;
using Avalonia.Headless.NUnit;
using Avalonia.Threading;
using Avalonia.VisualTree;
using AwesomeAssertions;
using ICSharpCode.ILSpy.Properties;
using ILSpy.AppEnv;
using ILSpy.Commands;
using ILSpy.Options;
using ILSpy.ViewModels;
using ILSpy.Views;
using NUnit.Framework;
namespace ICSharpCode.ILSpy.Tests;
/// <summary>
/// The Display options page exposes a "Tab options" group with two checkboxes that bind two-way to
/// the persisted document-tab-strip settings on SessionSettings: one toggles multi-row tabs, the
/// other gates the mouse-wheel toggle gesture.
/// </summary>
[TestFixture]
public class TabOptionsGroupTests
{
const string MultiRowLabel = "Enable multiple rows in tab strip";
const string WheelGateLabel = "Mouse wheel scroll toggles single/multiple row tab strip";
[AvaloniaTest]
public void Tab_Options_Checkboxes_Two_Way_Bind_To_SessionSettings()
{
var window = AppComposition.Current.GetExport<MainWindow>();
window.Width = 900;
window.Height = 600;
window.Show();
Dispatcher.UIThread.RunJobs();
var command = AppComposition.Current.GetExport<MainMenuCommandRegistry>()
.GetCommand(nameof(Resources._Options));
command.Execute(null);
Dispatcher.UIThread.RunJobs();
var view = window.GetVisualDescendants().OfType<OptionsPageView>().Single();
var model = (OptionsPageModel)((ContentTabPage)((MainWindowViewModel)window.DataContext!)
.DockWorkspace.Documents!.VisibleDockables!
.OfType<ContentTabPage>().Single(t => t.Content is OptionsPageModel)).Content!;
var page = model.Pages.OfType<DisplaySettingsViewModel>().Single();
model.SelectedPage = page;
Dispatcher.UIThread.RunJobs();
var multiRow = view.GetVisualDescendants().OfType<CheckBox>()
.FirstOrDefault(cb => cb.Content?.ToString() == MultiRowLabel);
var wheelGate = view.GetVisualDescendants().OfType<CheckBox>()
.FirstOrDefault(cb => cb.Content?.ToString() == WheelGateLabel);
multiRow.Should().NotBeNull("the Tab options group must expose the multi-row toggle checkbox");
wheelGate.Should().NotBeNull("the Tab options group must expose the mouse-wheel-gate checkbox");
var session = page.SessionSettings;
// Checkbox 1 <-> MultiLineDocumentTabs
session.MultiLineDocumentTabs = false;
Dispatcher.UIThread.RunJobs();
multiRow!.IsChecked.Should().BeFalse("the checkbox reflects the current MultiLineDocumentTabs");
multiRow.IsChecked = true;
Dispatcher.UIThread.RunJobs();
session.MultiLineDocumentTabs.Should().BeTrue("checking the box flows back to MultiLineDocumentTabs");
// Checkbox 2 <-> MouseWheelTogglesTabStripRows
session.MouseWheelTogglesTabStripRows = true;
Dispatcher.UIThread.RunJobs();
wheelGate!.IsChecked.Should().BeTrue("the checkbox reflects the current MouseWheelTogglesTabStripRows");
wheelGate.IsChecked = false;
Dispatcher.UIThread.RunJobs();
session.MouseWheelTogglesTabStripRows.Should().BeFalse(
"unchecking the box flows back to MouseWheelTogglesTabStripRows");
}
}

9
ILSpy/Options/DisplaySettingsPanel.axaml

@ -99,6 +99,15 @@
</StackPanel> </StackPanel>
</HeaderedContentControl> </HeaderedContentControl>
<HeaderedContentControl Header="Tab options">
<StackPanel Spacing="2" Margin="12,4,0,0">
<CheckBox IsChecked="{Binding SessionSettings.MultiLineDocumentTabs, Mode=TwoWay}"
Content="Enable multiple rows in tab strip" />
<CheckBox IsChecked="{Binding SessionSettings.MouseWheelTogglesTabStripRows, Mode=TwoWay}"
Content="Mouse wheel scroll toggles single/multiple row tab strip" />
</StackPanel>
</HeaderedContentControl>
<HeaderedContentControl Header="{x:Static res:Resources.Other}"> <HeaderedContentControl Header="{x:Static res:Resources.Other}">
<StackPanel Spacing="2" Margin="12,4,0,0"> <StackPanel Spacing="2" Margin="12,4,0,0">
<CheckBox IsChecked="{Binding Settings.SortResults, Mode=TwoWay}" <CheckBox IsChecked="{Binding Settings.SortResults, Mode=TwoWay}"

10
ILSpy/SessionSettings.cs

@ -64,6 +64,14 @@ namespace ILSpy
[ObservableProperty] [ObservableProperty]
private bool multiLineDocumentTabs; private bool multiLineDocumentTabs;
/// <summary>
/// When true (the default) the mouse wheel over the document tab strip toggles
/// <see cref="MultiLineDocumentTabs"/> (wheel up flows to multiple rows, wheel down collapses
/// to one). When false the wheel gesture is ignored. Persisted across sessions.
/// </summary>
[ObservableProperty]
private bool mouseWheelTogglesTabStripRows = true;
/// <summary> /// <summary>
/// Path to the previously-selected tree node (one ToString() per ancestor, root-first). /// Path to the previously-selected tree node (one ToString() per ancestor, root-first).
/// Used to restore the selection on the next launch. /// Used to restore the selection on the next launch.
@ -100,6 +108,7 @@ namespace ILSpy
var culture = (string?)section.Element(nameof(CurrentCulture)); var culture = (string?)section.Element(nameof(CurrentCulture));
CurrentCulture = string.IsNullOrEmpty(culture) ? null : culture; CurrentCulture = string.IsNullOrEmpty(culture) ? null : culture;
MultiLineDocumentTabs = (bool?)section.Element(nameof(MultiLineDocumentTabs)) ?? false; MultiLineDocumentTabs = (bool?)section.Element(nameof(MultiLineDocumentTabs)) ?? false;
MouseWheelTogglesTabStripRows = (bool?)section.Element(nameof(MouseWheelTogglesTabStripRows)) ?? true;
var bounds = section.Element("WindowBounds"); var bounds = section.Element("WindowBounds");
if (bounds != null) if (bounds != null)
@ -151,6 +160,7 @@ namespace ILSpy
if (!string.IsNullOrEmpty(CurrentCulture)) if (!string.IsNullOrEmpty(CurrentCulture))
section.Add(new XElement(nameof(CurrentCulture), CurrentCulture)); section.Add(new XElement(nameof(CurrentCulture), CurrentCulture));
section.Add(new XElement(nameof(MultiLineDocumentTabs), MultiLineDocumentTabs)); section.Add(new XElement(nameof(MultiLineDocumentTabs), MultiLineDocumentTabs));
section.Add(new XElement(nameof(MouseWheelTogglesTabStripRows), MouseWheelTogglesTabStripRows));
if (FilterStates.Count > 0) if (FilterStates.Count > 0)
{ {

2
ILSpy/Themes/MultiRowTabStripBehavior.cs

@ -93,7 +93,7 @@ namespace ILSpy.Themes
static void OnPointerWheel(object? sender, PointerWheelEventArgs e) static void OnPointerWheel(object? sender, PointerWheelEventArgs e)
{ {
var settings = TryGetSessionSettings(); var settings = TryGetSessionSettings();
if (settings is null || e.Delta.Y == 0) if (settings is null || e.Delta.Y == 0 || !settings.MouseWheelTogglesTabStripRows)
return; return;
// Idempotent set: rolling further in the same direction keeps the same mode rather than // Idempotent set: rolling further in the same direction keeps the same mode rather than
// flip-flopping, so a multi-detent gesture settles cleanly. // flip-flopping, so a multi-detent gesture settles cleanly.

Loading…
Cancel
Save