From acbf315e8fe87b479e628fa4dfc794634fcae4f8 Mon Sep 17 00:00:00 2001 From: Misaki Date: Sat, 28 Mar 2026 21:53:50 +0900 Subject: [PATCH] feat(docking): add DockDocument and DockGroup --- .../View/Controls/Docking/DockDocument.cs | 30 ++++++++++++ .../View/Controls/Docking/DockGroup.cs | 47 +++++++++++++++++++ .../View/Controls/Docking/DockGroup.xaml | 22 +++++++++ 3 files changed, 99 insertions(+) create mode 100644 src/Editor/Ghost.Editor/View/Controls/Docking/DockDocument.cs create mode 100644 src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.cs create mode 100644 src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml diff --git a/src/Editor/Ghost.Editor/View/Controls/Docking/DockDocument.cs b/src/Editor/Ghost.Editor/View/Controls/Docking/DockDocument.cs new file mode 100644 index 0000000..28d1abd --- /dev/null +++ b/src/Editor/Ghost.Editor/View/Controls/Docking/DockDocument.cs @@ -0,0 +1,30 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace Ghost.Editor.View.Controls.Docking; + +public class DockDocument : DockModule +{ + public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( + nameof(Title), typeof(string), typeof(DockDocument), new PropertyMetadata(string.Empty)); + + public static readonly DependencyProperty ContentProperty = DependencyProperty.Register( + nameof(Content), typeof(object), typeof(DockDocument), new PropertyMetadata(null)); + + public string Title + { + get => (string)GetValue(TitleProperty); + set => SetValue(TitleProperty, value); + } + + public object Content + { + get => GetValue(ContentProperty); + set => SetValue(ContentProperty, value); + } + + public DockDocument() + { + DefaultStyleKey = typeof(DockDocument); + } +} diff --git a/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.cs b/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.cs new file mode 100644 index 0000000..dd2ca76 --- /dev/null +++ b/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.cs @@ -0,0 +1,47 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace Ghost.Editor.View.Controls.Docking; + +[TemplatePart(Name = "PART_TabView", Type = typeof(TabView))] +public class DockGroup : DockContainer +{ + private TabView? _tabView; + + public DockGroup() + { + DefaultStyleKey = typeof(DockGroup); + } + + protected override void OnApplyTemplate() + { + base.OnApplyTemplate(); + _tabView = GetTemplateChild("PART_TabView") as TabView; + UpdateTabs(); + } + + protected override void OnChildrenUpdated() + { + UpdateTabs(); + } + + private void UpdateTabs() + { + if (_tabView == null) return; + + _tabView.TabItems.Clear(); + foreach (var child in Children) + { + if (child is DockDocument doc) + { + var tabItem = new TabViewItem + { + Header = doc.Title, + Content = doc.Content, + Tag = doc + }; + _tabView.TabItems.Add(tabItem); + } + } + } +} diff --git a/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml b/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml new file mode 100644 index 0000000..417d045 --- /dev/null +++ b/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml @@ -0,0 +1,22 @@ + + + +