add minimum tab width
This commit is contained in:
@@ -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.
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
@@ -260,6 +260,20 @@ namespace FlaxEditor.Options
|
||||
public bool HideSingleTabWindowTabBars { get; set; } = true;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating wether the minum tab width should be used. Editor restart required.
|
||||
/// </summary>
|
||||
[DefaultValue(false)]
|
||||
[EditorDisplay("Tabs & Windows"), EditorOrder(99)]
|
||||
public bool UseMinimumTabWidth { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[DefaultValue(80.0f), Limit(50.0f, 150.0f)]
|
||||
[EditorDisplay("Tabs & Windows"), EditorOrder(99), VisibleIf(nameof(UseMinimumTabWidth))]
|
||||
public float MinimumTabWidth { get; set; } = 80.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating the height of window tabs. Editor restart required.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user