fix(docking): address final code quality issues in docking layout
This commit is contained in:
@@ -3,6 +3,9 @@ using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Ghost.Editor.View.Controls.Docking;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a document module in the docking system.
|
||||
/// </summary>
|
||||
public partial class DockDocument : DockModule
|
||||
{
|
||||
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
|
||||
@@ -29,6 +32,9 @@ public partial class DockDocument : DockModule
|
||||
set => SetValue(ContentProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DockDocument"/> class.
|
||||
/// </summary>
|
||||
public DockDocument()
|
||||
{
|
||||
DefaultStyleKey = typeof(DockDocument);
|
||||
|
||||
@@ -95,22 +95,28 @@ public class DockingLayout : Control
|
||||
throw new ArgumentException("targetGroup does not belong to this DockingLayout", nameof(targetGroup));
|
||||
}
|
||||
|
||||
if (RootModule == null)
|
||||
{
|
||||
RootModule = new DockPanel();
|
||||
}
|
||||
|
||||
if (targetGroup == null)
|
||||
{
|
||||
if (RootModule != null)
|
||||
{
|
||||
targetGroup = FindFirstDockGroup(RootModule as DockContainer);
|
||||
|
||||
if (targetGroup == null)
|
||||
{
|
||||
targetGroup = new DockGroup();
|
||||
if (RootModule is DockContainer container)
|
||||
// Root is not a container, or contains no groups. Wrap it.
|
||||
var newGroup = new DockGroup();
|
||||
if (RootModule is DockDocument existingDoc)
|
||||
{
|
||||
container.AddChild(targetGroup);
|
||||
RootModule = null; // Detach first
|
||||
newGroup.AddChild(existingDoc);
|
||||
}
|
||||
RootModule = newGroup;
|
||||
targetGroup = newGroup;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetGroup = new DockGroup();
|
||||
RootModule = 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)
|
||||
{
|
||||
return group;
|
||||
|
||||
Reference in New Issue
Block a user