From ba35123420710ff6ad9b6b665d8e28fc7aaf80b9 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Tue, 11 Feb 2025 18:15:46 +0100 Subject: [PATCH] add minimum tab width --- Source/Editor/GUI/Docking/DockPanelProxy.cs | 12 ++++++++++++ Source/Editor/Options/InterfaceOptions.cs | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Source/Editor/GUI/Docking/DockPanelProxy.cs b/Source/Editor/GUI/Docking/DockPanelProxy.cs index 23ba6c577..ef6c2cb1a 100644 --- a/Source/Editor/GUI/Docking/DockPanelProxy.cs +++ b/Source/Editor/GUI/Docking/DockPanelProxy.cs @@ -16,6 +16,8 @@ namespace FlaxEditor.GUI.Docking private DockPanel _panel; private double _dragEnterTime = -1; private float _tabHeight = Editor.Instance.Options.Options.Interface.TabHeight; + private bool _useMinimumTabWidth = Editor.Instance.Options.Options.Interface.UseMinimumTabWidth; + private float _minimumTabWidth = Editor.Instance.Options.Options.Interface.MinimumTabWidth; #if PLATFORM_WINDOWS private readonly bool _hideTabForSingleTab = Editor.Instance.Options.Options.Interface.HideSingleTabWindowTabBars; #else @@ -56,6 +58,7 @@ namespace FlaxEditor.GUI.Docking /// The start drag asynchronous window. /// public DockWindow StartDragAsyncWindow; + private Rectangle HeaderRectangle => new Rectangle(0, 0, Width, _tabHeight); private bool IsSingleFloatingWindow => _hideTabForSingleTab && _panel.TabsCount == 1 && _panel.IsFloating && _panel.ChildPanelsCount == 0; @@ -97,6 +100,10 @@ namespace FlaxEditor.GUI.Docking var titleSize = tab.TitleSize; var iconWidth = tab.Icon.IsValid ? DockPanel.DefaultButtonsSize + DockPanel.DefaultLeftTextMargin : 0; var width = titleSize.X + DockPanel.DefaultButtonsSize + 2 * DockPanel.DefaultButtonsMargin + DockPanel.DefaultLeftTextMargin + DockPanel.DefaultRightTextMargin + iconWidth; + + if (_useMinimumTabWidth && width < _minimumTabWidth) + width = _minimumTabWidth; + var tabRect = new Rectangle(x, 0, width, HeaderRectangle.Height); var isMouseOver = tabRect.Contains(position); if (isMouseOver) @@ -248,7 +255,12 @@ namespace FlaxEditor.GUI.Docking var tabColor = Color.Black; var titleSize = tab.TitleSize; var iconWidth = tab.Icon.IsValid ? DockPanel.DefaultButtonsSize + DockPanel.DefaultLeftTextMargin : 0; + var width = titleSize.X + DockPanel.DefaultButtonsSize + 2 * DockPanel.DefaultButtonsMargin + DockPanel.DefaultLeftTextMargin + DockPanel.DefaultRightTextMargin + iconWidth; + + if (_useMinimumTabWidth && width < _minimumTabWidth) + width = _minimumTabWidth; + var tabRect = new Rectangle(x, 0, width, headerRect.Height); var isMouseOver = tabRect.Contains(MousePosition); var isSelected = _panel.SelectedTab == tab; diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index 925fb8c60..1e58b2a23 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -260,6 +260,20 @@ namespace FlaxEditor.Options public bool HideSingleTabWindowTabBars { get; set; } = true; #endif + /// + /// Gets or sets a value indicating wether the minum tab width should be used. Editor restart required. + /// + [DefaultValue(false)] + [EditorDisplay("Tabs & Windows"), EditorOrder(99)] + public bool UseMinimumTabWidth { get; set; } = false; + + /// + /// Gets or sets a value indicating the minimum tab width. If a tab is smaller than this width, its width will be set to this. Editor restart required. + /// + [DefaultValue(80.0f), Limit(50.0f, 150.0f)] + [EditorDisplay("Tabs & Windows"), EditorOrder(99), VisibleIf(nameof(UseMinimumTabWidth))] + public float MinimumTabWidth { get; set; } = 80.0f; + /// /// Gets or sets a value indicating the height of window tabs. Editor restart required. ///