feat(dock): implement tab tear-off to new window
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
11
src/Editor/Ghost.Editor/View/Windows/DockWindow.xaml
Normal file
11
src/Editor/Ghost.Editor/View/Windows/DockWindow.xaml
Normal 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>
|
||||||
22
src/Editor/Ghost.Editor/View/Windows/DockWindow.xaml.cs
Normal file
22
src/Editor/Ghost.Editor/View/Windows/DockWindow.xaml.cs
Normal 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.
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user