fix(docking): address final code quality issues in docking layout

This commit is contained in:
2026-03-28 23:03:32 +09:00
parent 2946b905c6
commit c8f24edfd8
2 changed files with 27 additions and 13 deletions

View File

@@ -3,6 +3,9 @@ using Microsoft.UI.Xaml.Controls;
namespace Ghost.Editor.View.Controls.Docking; namespace Ghost.Editor.View.Controls.Docking;
/// <summary>
/// Represents a document module in the docking system.
/// </summary>
public partial class DockDocument : DockModule public partial class DockDocument : DockModule
{ {
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
@@ -29,6 +32,9 @@ public partial class DockDocument : DockModule
set => SetValue(ContentProperty, value); set => SetValue(ContentProperty, value);
} }
/// <summary>
/// Initializes a new instance of the <see cref="DockDocument"/> class.
/// </summary>
public DockDocument() public DockDocument()
{ {
DefaultStyleKey = typeof(DockDocument); DefaultStyleKey = typeof(DockDocument);

View File

@@ -95,22 +95,28 @@ public class DockingLayout : Control
throw new ArgumentException("targetGroup does not belong to this DockingLayout", nameof(targetGroup)); throw new ArgumentException("targetGroup does not belong to this DockingLayout", nameof(targetGroup));
} }
if (RootModule == null)
{
RootModule = new DockPanel();
}
if (targetGroup == null) if (targetGroup == null)
{ {
targetGroup = FindFirstDockGroup(RootModule as DockContainer); if (RootModule != null)
{
if (targetGroup == null) targetGroup = FindFirstDockGroup(RootModule as DockContainer);
if (targetGroup == null)
{
// Root is not a container, or contains no groups. Wrap it.
var newGroup = new DockGroup();
if (RootModule is DockDocument existingDoc)
{
RootModule = null; // Detach first
newGroup.AddChild(existingDoc);
}
RootModule = newGroup;
targetGroup = newGroup;
}
}
else
{ {
targetGroup = new DockGroup(); targetGroup = new DockGroup();
if (RootModule is DockContainer container) RootModule = targetGroup;
{
container.AddChild(targetGroup);
}
} }
} }
@@ -191,8 +197,10 @@ public class DockingLayout : Control
} }
} }
private static DockGroup? FindFirstDockGroup(DockContainer container) private static DockGroup? FindFirstDockGroup(DockContainer? container)
{ {
if (container == null) return null;
if (container is DockGroup group) if (container is DockGroup group)
{ {
return group; return group;