feat(docking): add core enums and base classes
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Ghost.Editor.View.Controls.Docking;
|
||||
|
||||
public abstract class DockContainer : DockModule
|
||||
{
|
||||
public ObservableCollection<DockModule> Children { get; } = new();
|
||||
|
||||
protected DockContainer()
|
||||
{
|
||||
Children.CollectionChanged += OnChildrenChanged;
|
||||
}
|
||||
|
||||
private void OnChildrenChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.OldItems != null)
|
||||
{
|
||||
foreach (DockModule module in e.OldItems)
|
||||
{
|
||||
module.Owner = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (e.NewItems != null)
|
||||
{
|
||||
foreach (DockModule module in e.NewItems)
|
||||
{
|
||||
module.Owner = this;
|
||||
// module.Root = Root;
|
||||
}
|
||||
}
|
||||
|
||||
OnChildrenUpdated();
|
||||
}
|
||||
|
||||
protected virtual void OnChildrenUpdated() { }
|
||||
}
|
||||
16
src/Editor/Ghost.Editor/View/Controls/Docking/DockModule.cs
Normal file
16
src/Editor/Ghost.Editor/View/Controls/Docking/DockModule.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Ghost.Editor.View.Controls.Docking;
|
||||
|
||||
public abstract class DockModule : Control
|
||||
{
|
||||
public DockContainer? Owner { get; internal set; }
|
||||
// Note: DockingLayout will be implemented in a later task
|
||||
// public DockingLayout? Root { get; internal set; }
|
||||
|
||||
public void Detach()
|
||||
{
|
||||
// Owner?.Children.Remove(this);
|
||||
Owner = null;
|
||||
}
|
||||
}
|
||||
10
src/Editor/Ghost.Editor/View/Controls/Docking/Enums.cs
Normal file
10
src/Editor/Ghost.Editor/View/Controls/Docking/Enums.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Ghost.Editor.View.Controls.Docking;
|
||||
|
||||
public enum DockTarget
|
||||
{
|
||||
Center,
|
||||
Left,
|
||||
Right,
|
||||
Top,
|
||||
Bottom
|
||||
}
|
||||
Reference in New Issue
Block a user