From d15bd22743e10080141412c42ccad60cc9b74d49 Mon Sep 17 00:00:00 2001 From: Misaki Date: Sun, 29 Mar 2026 16:07:18 +0900 Subject: [PATCH] feat(docking): improve tab management and error handling Refactored DockGroup to only remove obsolete TabViewItems and restore tab selection more reliably. Updated DockGroup.xaml to enable tab reordering and add-tab button. Switched to CommunityToolkit.WinUI.Controls for GridSplitter and added a style for it. Made DockPanel, DockRegionHighlight, and DockingLayout partial classes. In App.xaml.cs, wrapped initialization in a try-catch to exit on error, and ensured process exit on window close. Improved ProjectBrowser scrollbar behavior and layout settings. --- src/Editor/Ghost.Editor/App.xaml.cs | 35 ++++++----- src/Editor/Ghost.Editor/Themes/Generic.xaml | 7 ++- .../View/Controls/Docking/DockGroup.cs | 59 ++++++++----------- .../View/Controls/Docking/DockGroup.xaml | 18 +++--- .../View/Controls/Docking/DockPanel.cs | 5 +- .../Controls/Docking/DockRegionHighlight.cs | 2 +- .../View/Controls/Docking/DockingLayout.cs | 2 +- .../View/Controls/ProjectBrowser.xaml | 4 +- .../View/Controls/ProjectBrowser.xaml.cs | 3 + 9 files changed, 71 insertions(+), 64 deletions(-) diff --git a/src/Editor/Ghost.Editor/App.xaml.cs b/src/Editor/Ghost.Editor/App.xaml.cs index f64375e..87a6bad 100644 --- a/src/Editor/Ghost.Editor/App.xaml.cs +++ b/src/Editor/Ghost.Editor/App.xaml.cs @@ -116,25 +116,32 @@ public partial class App : Application return; } - EditorApplication.Initialize(Host.Services, arguments.ProjectPath, arguments.ProjectName); + try + { + EditorApplication.Initialize(Host.Services, arguments.ProjectPath, arguments.ProjectName); - // NOTE: We must call DispatcherQueue.GetForCurrentThread() on the UI thread before any await. - EditorApplication.SetDispatcherQueue(DispatcherQueue.GetForCurrentThread()); + // NOTE: We must call DispatcherQueue.GetForCurrentThread() on the UI thread before any await. + EditorApplication.SetDispatcherQueue(DispatcherQueue.GetForCurrentThread()); - var splashWindow = new SplashWindow(); - splashWindow.Activate(); - Window = splashWindow; + var splashWindow = new SplashWindow(); + splashWindow.Activate(); + Window = splashWindow; - await Host.StartAsync(); - await ActivationHandler.HandleAsync(arguments); + await Host.StartAsync(); + await ActivationHandler.HandleAsync(arguments); - splashWindow.Hide(); + splashWindow.Hide(); - var editorWindow = new EngineEditorWindow(); - editorWindow.Activate(); - Window = editorWindow; + var editorWindow = new EngineEditorWindow(); + editorWindow.Activate(); + Window = editorWindow; - splashWindow.Close(); + splashWindow.Close(); + } + catch (Exception ex) + { + Environment.Exit(ex.HResult); + } } private void OnClosed(object? sender, WindowEventArgs args) @@ -153,7 +160,7 @@ public partial class App : Application } finally { - //Environment.Exit(0); + Environment.Exit(0); } } diff --git a/src/Editor/Ghost.Editor/Themes/Generic.xaml b/src/Editor/Ghost.Editor/Themes/Generic.xaml index df492fe..cd64256 100644 --- a/src/Editor/Ghost.Editor/Themes/Generic.xaml +++ b/src/Editor/Ghost.Editor/Themes/Generic.xaml @@ -1,7 +1,7 @@ @@ -42,6 +42,11 @@