fix(dock): address reviewer feedback on window tear-off
This commit is contained in:
@@ -23,6 +23,7 @@ namespace Ghost.Editor;
|
||||
public partial class App : Application
|
||||
{
|
||||
private Window? _window;
|
||||
private readonly List<Window> _secondaryWindows = new();
|
||||
|
||||
internal static Window? Window
|
||||
{
|
||||
@@ -39,6 +40,15 @@ public partial class App : Application
|
||||
}
|
||||
}
|
||||
|
||||
internal static void AddSecondaryWindow(Window window)
|
||||
{
|
||||
if (Current is App app)
|
||||
{
|
||||
app._secondaryWindows.Add(window);
|
||||
window.Closed += (s, e) => app._secondaryWindows.Remove(window);
|
||||
}
|
||||
}
|
||||
|
||||
internal IHost Host
|
||||
{
|
||||
get;
|
||||
|
||||
@@ -300,12 +300,15 @@ public sealed partial class DockLayout : Control
|
||||
if (_sourceNode != null && _draggedItem != null)
|
||||
{
|
||||
// Remove from current tree
|
||||
_sourceNode.Items.Remove(_draggedItem);
|
||||
DockMutationEngine.CleanupEmptyNodes(_sourceNode, Root);
|
||||
if (_sourceNode.Items.Remove(_draggedItem))
|
||||
{
|
||||
DockMutationEngine.CleanupEmptyNodes(_sourceNode);
|
||||
|
||||
// Create new window
|
||||
var newWindow = new Ghost.Editor.View.Windows.DockWindow(_draggedItem);
|
||||
newWindow.Activate();
|
||||
// Create new window and register it with App to prevent GC
|
||||
var newWindow = new Ghost.Editor.View.Windows.DockWindow(_draggedItem);
|
||||
App.AddSecondaryWindow(newWindow);
|
||||
newWindow.Activate();
|
||||
}
|
||||
|
||||
ClearDragOperationState();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using WinUIEx;
|
||||
|
||||
namespace Ghost.Editor.View.Windows;
|
||||
|
||||
public sealed partial class DockWindow : WindowEx
|
||||
internal sealed partial class DockWindow : WindowEx
|
||||
{
|
||||
public DockWindow(object initialTabContent)
|
||||
{
|
||||
@@ -16,7 +16,5 @@ public sealed partial class DockWindow : WindowEx
|
||||
rootGroup.AddChild(panel);
|
||||
|
||||
PART_DockLayout.Root = rootGroup;
|
||||
|
||||
// Optional: Titlebar setup etc.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user