feat(dock): implement tab tear-off to new window

This commit is contained in:
2026-03-28 15:41:39 +09:00
parent 095fcc87a7
commit 07274b6699
3 changed files with 50 additions and 0 deletions

View File

@@ -290,10 +290,27 @@ public sealed partial class DockLayout : Control
tabView.DragLeave += TabView_DragLeave; tabView.DragLeave += TabView_DragLeave;
tabView.Drop += TabView_Drop; tabView.Drop += TabView_Drop;
tabView.TabDragStarting += TabView_TabDragStarting; tabView.TabDragStarting += TabView_TabDragStarting;
tabView.TabDroppedOutside += TabView_TabDroppedOutside;
return tabView; return tabView;
} }
private void TabView_TabDroppedOutside(Microsoft.UI.Xaml.Controls.TabView sender, Microsoft.UI.Xaml.Controls.TabViewTabDroppedOutsideEventArgs args)
{
if (_sourceNode != null && _draggedItem != null)
{
// Remove from current tree
_sourceNode.Items.Remove(_draggedItem);
DockMutationEngine.CleanupEmptyNodes(_sourceNode, Root);
// Create new window
var newWindow = new Ghost.Editor.View.Windows.DockWindow(_draggedItem);
newWindow.Activate();
ClearDragOperationState();
}
}
private object? _draggedItem; private object? _draggedItem;
private DockPanelNode? _sourceNode; private DockPanelNode? _sourceNode;
private DockPosition _currentDropPosition = DockPosition.None; private DockPosition _currentDropPosition = DockPosition.None;

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<winex:WindowEx
x:Class="Ghost.Editor.View.Windows.DockWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Ghost.Editor.View.Controls"
xmlns:winex="using:WinUIEx">
<Grid>
<controls:DockLayout x:Name="PART_DockLayout" />
</Grid>
</winex:WindowEx>

View File

@@ -0,0 +1,22 @@
using Ghost.Editor.Core.Controls.Internal.Docking;
using WinUIEx;
namespace Ghost.Editor.View.Windows;
public sealed partial class DockWindow : WindowEx
{
public DockWindow(object initialTabContent)
{
InitializeComponent();
// Setup initial single panel layout
var rootGroup = new DockGroupNode();
var panel = new DockPanelNode();
panel.Items.Add(initialTabContent);
rootGroup.AddChild(panel);
PART_DockLayout.Root = rootGroup;
// Optional: Titlebar setup etc.
}
}