diff --git a/Source/Editor/GUI/Docking/DockWindow.cs b/Source/Editor/GUI/Docking/DockWindow.cs
index 8cde79ce8..a6c98a1f6 100644
--- a/Source/Editor/GUI/Docking/DockWindow.cs
+++ b/Source/Editor/GUI/Docking/DockWindow.cs
@@ -50,7 +50,7 @@ namespace FlaxEditor.GUI.Docking
///
/// Gets a value indicating whether this window is docked.
///
- public bool IsDocked => _dockedTo != null;
+ public bool IsDocked => _dockedTo != null && _dockedTo.TabsCount > 1;
///
/// Gets a value indicating whether this window is selected.
@@ -488,7 +488,7 @@ namespace FlaxEditor.GUI.Docking
base.Focus();
SelectTab(false);
- BringToFront();
+ _dockedTo?.RootWindow?.Focus();
}
///
diff --git a/Source/Editor/GUI/Docking/FloatWindowDockPanel.cs b/Source/Editor/GUI/Docking/FloatWindowDockPanel.cs
index b47d76bdd..1ba732d84 100644
--- a/Source/Editor/GUI/Docking/FloatWindowDockPanel.cs
+++ b/Source/Editor/GUI/Docking/FloatWindowDockPanel.cs
@@ -49,6 +49,7 @@ namespace FlaxEditor.GUI.Docking
private MasterDockPanel _masterPanel;
private WindowRootControl _window;
+ private bool _showDecorations;
///
/// Gets the master panel.
@@ -65,6 +66,31 @@ namespace FlaxEditor.GUI.Docking
///
public bool IsDragging { get; internal set; }
+ ///
+ /// Shows client-side window decorations around this panel.
+ ///
+ public bool ShowDecorations
+ {
+ get => _showDecorations;
+ set
+ {
+ if (value == _showDecorations)
+ return;
+ _showDecorations = value;
+ if (value)
+ {
+ var decorations = Parent.AddChild(new FloatWindowDecorations(this));
+ decorations.SetAnchorPreset(AnchorPresets.HorizontalStretchTop, false);
+ }
+ else
+ {
+ var decorations = Parent.GetChild();
+ if (decorations != null)
+ decorations.Dispose();
+ }
+ }
+ }
+
///
/// Initializes a new instance of the class.
///
@@ -82,11 +108,7 @@ namespace FlaxEditor.GUI.Docking
_window.Window.Closing += OnClosing;
_window.Window.LeftButtonHit += OnLeftButtonHit;
- if (Utilities.Utils.UseCustomWindowDecorations())
- {
- var decorations = Parent.AddChild(new FloatWindowDecorations(this));
- decorations.SetAnchorPreset(AnchorPresets.HorizontalStretchTop, false);
- }
+ ShowDecorations = Utilities.Utils.UseCustomWindowDecorations();
}
///
@@ -94,13 +116,10 @@ namespace FlaxEditor.GUI.Docking
{
base.PerformLayoutBeforeChildren();
- var decorations = Parent.GetChild();
- if (decorations != null)
- {
- // Apply offset for the title bar
- foreach (var child in Children)
- child.Bounds = child.Bounds with { Y = decorations.Height, Height = Parent.Height - decorations.Height };
- }
+ // Apply offset for the title bar
+ var decorationsHeight = Parent.GetChild()?.Height ?? 0;
+ foreach (var child in Children)
+ child.Bounds = child.Bounds with { Y = decorationsHeight, Height = Parent.Height - decorationsHeight };
}
///
diff --git a/Source/Editor/States/PlayingState.cs b/Source/Editor/States/PlayingState.cs
index 51dfd3677..a81487e43 100644
--- a/Source/Editor/States/PlayingState.cs
+++ b/Source/Editor/States/PlayingState.cs
@@ -159,11 +159,11 @@ namespace FlaxEditor.States
SceneDuplicated?.Invoke();
RestoreSelection();
+ Time.Synchronize(true);
+
Editor.OnPlayBegin();
IsPlayModeStarting = false;
Profiler.EndEvent();
-
- Time.Synchronize(true);
}
private void SetupEditorEnvOptions()
diff --git a/Source/Editor/Windows/GameWindow.cs b/Source/Editor/Windows/GameWindow.cs
index 8c3793627..d351147cb 100644
--- a/Source/Editor/Windows/GameWindow.cs
+++ b/Source/Editor/Windows/GameWindow.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Xml;
using FlaxEditor.Gizmo;
using FlaxEditor.GUI.ContextMenu;
+using FlaxEditor.GUI.Docking;
using FlaxEditor.GUI.Input;
using FlaxEditor.Modules;
using FlaxEditor.Options;
@@ -132,6 +133,8 @@ namespace FlaxEditor.Windows
private float _gameStartTime;
private GUI.Docking.DockState _maximizeRestoreDockState;
private GUI.Docking.DockPanel _maximizeRestoreDockTo;
+ private GUI.Docking.DockPanel _maximizeRestoreDockToParent;
+ private float _maximizeRestoreSplitterValue;
private CursorLockMode _cursorLockMode = CursorLockMode.None;
// Viewport scaling variables
@@ -295,7 +298,10 @@ namespace FlaxEditor.Windows
if (value)
{
_maximizeRestoreDockTo = _dockedTo;
- _maximizeRestoreDockState = _dockedTo.TryGetDockState(out _);
+ _maximizeRestoreDockToParent = _dockedTo.ParentDockPanel;
+ _maximizeRestoreDockState = _dockedTo.TryGetDockState(out _maximizeRestoreSplitterValue);
+ if (_dockedTo.Tabs.Count > 1)
+ _maximizeRestoreDockState = DockState.DockFill;
if (_maximizeRestoreDockState != GUI.Docking.DockState.Float)
{
var monitorBounds = Platform.GetMonitorBounds(PointToScreen(Size * 0.5f));
@@ -309,9 +315,11 @@ namespace FlaxEditor.Windows
// Restore
if (rootWindow != null)
rootWindow.Restore();
- if (_maximizeRestoreDockTo != null && _maximizeRestoreDockTo.IsDisposing)
- _maximizeRestoreDockTo = null;
- Show(_maximizeRestoreDockState, _maximizeRestoreDockTo);
+ var dockTo = _maximizeRestoreDockTo;
+ if (dockTo != null && dockTo.IsDisposing)
+ dockTo = _maximizeRestoreDockToParent;
+ if (_dockedTo != dockTo)
+ Show(_maximizeRestoreDockState, dockTo, splitterValue: _maximizeRestoreSplitterValue);
}
}
}
@@ -331,6 +339,9 @@ namespace FlaxEditor.Windows
{
IsFloating = true;
var rootWindow = RootWindow;
+ var floatWin = rootWindow.GetChild();
+ if (floatWin != null && floatWin.ShowDecorations)
+ floatWin.ShowDecorations = false;
var monitorBounds = Platform.GetMonitorBounds(rootWindow.RootWindow.Window.ClientPosition);
rootWindow.Window.Position = monitorBounds.Location;
rootWindow.Window.SetBorderless(true);
@@ -338,6 +349,9 @@ namespace FlaxEditor.Windows
}
else
{
+ var floatWin = RootWindow.GetChild();
+ if (floatWin != null && !floatWin.ShowDecorations && Utilities.Utils.UseCustomWindowDecorations())
+ floatWin.ShowDecorations = true;
IsFloating = false;
}
}
@@ -899,7 +913,7 @@ namespace FlaxEditor.Windows
///
public void FocusGameViewport()
{
- if (!IsDocked)
+ if (ParentDockPanel == null)
{
ShowFloating();
}
@@ -1004,7 +1018,7 @@ namespace FlaxEditor.Windows
Screen.CursorVisible = true;
Screen.CursorLock = CursorLockMode.None;
- if (Editor.IsPlayMode && IsDocked && IsSelected && RootWindow.FocusedControl == null)
+ if (Editor.IsPlayMode && ParentDockPanel != null && IsSelected && RootWindow.FocusedControl == null)
{
// Game UI cleared focus so regain it to maintain UI navigation just like game window does
FlaxEngine.Scripting.InvokeOnUpdate(Focus);