From 12f70572b0f30b5eeb3cc1eac2aca3ee3c7c95d2 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Tue, 16 Jul 2024 20:05:27 -0500 Subject: [PATCH 1/2] Remove redundant first tab on floating window. --- Source/Editor/GUI/Docking/DockPanelProxy.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Editor/GUI/Docking/DockPanelProxy.cs b/Source/Editor/GUI/Docking/DockPanelProxy.cs index 1234c7777..5ca4a024a 100644 --- a/Source/Editor/GUI/Docking/DockPanelProxy.cs +++ b/Source/Editor/GUI/Docking/DockPanelProxy.cs @@ -187,6 +187,10 @@ namespace FlaxEditor.GUI.Docking var headerRect = HeaderRectangle; var tabsCount = _panel.TabsCount; + // Return and don't draw tab if only 1 window and it is floating + if (_panel.IsFloating && tabsCount == 1 && _panel.ChildPanelsCount == 0) + return; + // Check if has only one window docked if (tabsCount == 1) { @@ -501,7 +505,10 @@ namespace FlaxEditor.GUI.Docking /// public override void GetDesireClientArea(out Rectangle rect) { - rect = new Rectangle(0, DockPanel.DefaultHeaderHeight, Width, Height - DockPanel.DefaultHeaderHeight); + if (_panel.TabsCount == 1 && _panel.IsFloating && _panel.ChildPanelsCount == 0) + rect = new Rectangle(0, 0, Width, Height); + else + rect = new Rectangle(0, DockPanel.DefaultHeaderHeight, Width, Height - DockPanel.DefaultHeaderHeight); } private DragDropEffect TrySelectTabUnderLocation(ref Float2 location) From fe41ef619b103e61f2c6abb402fe3a5fa3334534 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 18 Jul 2024 10:47:46 +0200 Subject: [PATCH 2/2] Improve floating dock window hidden header to handle inputs properly #2770 --- Source/Editor/GUI/Docking/DockPanelProxy.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Source/Editor/GUI/Docking/DockPanelProxy.cs b/Source/Editor/GUI/Docking/DockPanelProxy.cs index 5ca4a024a..f489b0c39 100644 --- a/Source/Editor/GUI/Docking/DockPanelProxy.cs +++ b/Source/Editor/GUI/Docking/DockPanelProxy.cs @@ -51,6 +51,7 @@ namespace FlaxEditor.GUI.Docking public DockWindow StartDragAsyncWindow; private Rectangle HeaderRectangle => new Rectangle(0, 0, Width, DockPanel.DefaultHeaderHeight); + private bool IsSingleFloatingWindow => _panel.TabsCount == 1 && _panel.IsFloating && _panel.ChildPanelsCount == 0; /// /// Initializes a new instance of the class. @@ -188,9 +189,9 @@ namespace FlaxEditor.GUI.Docking var tabsCount = _panel.TabsCount; // Return and don't draw tab if only 1 window and it is floating - if (_panel.IsFloating && tabsCount == 1 && _panel.ChildPanelsCount == 0) + if (IsSingleFloatingWindow) return; - + // Check if has only one window docked if (tabsCount == 1) { @@ -325,6 +326,9 @@ namespace FlaxEditor.GUI.Docking /// public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { + if (IsSingleFloatingWindow) + return base.OnMouseDoubleClick(location, button); + // Maximize/restore on double click var tab = GetTabAtPos(location, out _); var rootWindow = tab?.RootWindow; @@ -343,6 +347,8 @@ namespace FlaxEditor.GUI.Docking /// public override bool OnMouseDown(Float2 location, MouseButton button) { + if (IsSingleFloatingWindow) + return base.OnMouseDown(location, button); MouseDownWindow = GetTabAtPos(location, out IsMouseDownOverCross); // Check buttons @@ -372,6 +378,9 @@ namespace FlaxEditor.GUI.Docking /// public override bool OnMouseUp(Float2 location, MouseButton button) { + if (IsSingleFloatingWindow) + return base.OnMouseUp(location, button); + // Check tabs under mouse position at the beginning and at the end var tab = GetTabAtPos(location, out var overCross); @@ -414,7 +423,7 @@ namespace FlaxEditor.GUI.Docking public override void OnMouseMove(Float2 location) { MousePosition = location; - if (IsMouseLeftButtonDown) + if (IsMouseLeftButtonDown && !IsSingleFloatingWindow) { // Check if mouse is outside the header if (!HeaderRectangle.Contains(location)) @@ -505,7 +514,7 @@ namespace FlaxEditor.GUI.Docking /// public override void GetDesireClientArea(out Rectangle rect) { - if (_panel.TabsCount == 1 && _panel.IsFloating && _panel.ChildPanelsCount == 0) + if (IsSingleFloatingWindow) rect = new Rectangle(0, 0, Width, Height); else rect = new Rectangle(0, DockPanel.DefaultHeaderHeight, Width, Height - DockPanel.DefaultHeaderHeight);