From cbd888e7452726ccbefee6ab8010f344af2bfd3b Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Sun, 5 Apr 2026 16:34:50 +0800 Subject: [PATCH] Rename legacy shell demo toggle away from ImGui --- docs/plan/XCUI_Phase_Status_2026-04-05.md | 1 + new_editor/src/Application.h | 14 +++++----- new_editor/src/ApplicationLegacyImGui.cpp | 20 ++++++------- .../src/XCUIBackend/XCUIShellChromeState.cpp | 28 +++++++++---------- .../src/XCUIBackend/XCUIShellChromeState.h | 6 ++-- ...est_application_shell_command_bindings.cpp | 14 +++++----- .../test_xcui_shell_chrome_state.cpp | 16 +++++------ 7 files changed, 50 insertions(+), 49 deletions(-) diff --git a/docs/plan/XCUI_Phase_Status_2026-04-05.md b/docs/plan/XCUI_Phase_Status_2026-04-05.md index c4b32d61..4b2d584b 100644 --- a/docs/plan/XCUI_Phase_Status_2026-04-05.md +++ b/docs/plan/XCUI_Phase_Status_2026-04-05.md @@ -120,6 +120,7 @@ Current gap: - `XCUIDemoRuntime` now bridges pointer activation, text-edit commands, and shortcut-triggered commands through a unified command path, and `DrainPendingCommandIds()` now preserves mixed pointer/text/shortcut ordering. - `new_editor` now also has a pure `XCUIShellChromeState` model covering panel visibility, hosted-preview mode, and shell-level view toggles without depending on ImGui, `Application`, or the old editor. - `XCUIShellChromeState` hosted-preview mode naming is now backend-neutral (`HostedPresenter` / `NativeOffscreen`) instead of encoding `ImGui` into the XCUI shell model. +- The shell chrome view-toggle model no longer encodes the legacy Dear ImGui demo window as a generic `ImGuiDemoWindow` concept; that compatibility-only toggle is now named `LegacyHostDemoWindow` / `new_editor.view.legacy_host_demo` at the editor-layer seam. - `new_editor` now also has a concrete `NativeWindowUICompositor` path and native-focused compositor tests, so the window compositor seam is no longer ImGui-only. - `Application` now also has a native XCUI shell path that: - becomes the default `new_editor` startup path diff --git a/new_editor/src/Application.h b/new_editor/src/Application.h index 4cc68abd..e55e0af9 100644 --- a/new_editor/src/Application.h +++ b/new_editor/src/Application.h @@ -60,8 +60,8 @@ public: ::XCEngine::Editor::XCUIBackend::XCUIShellChromeCommandIds::ToggleXCUIDemoPanel; static constexpr const char* ToggleXCUILayoutLabPanel = ::XCEngine::Editor::XCUIBackend::XCUIShellChromeCommandIds::ToggleXCUILayoutLabPanel; - static constexpr const char* ToggleImGuiDemoWindow = - ::XCEngine::Editor::XCUIBackend::XCUIShellChromeCommandIds::ToggleImGuiDemoWindow; + static constexpr const char* ToggleLegacyHostDemoWindow = + ::XCEngine::Editor::XCUIBackend::XCUIShellChromeCommandIds::ToggleLegacyHostDemoWindow; static constexpr const char* ToggleNativeBackdrop = ::XCEngine::Editor::XCUIBackend::XCUIShellChromeCommandIds::ToggleNativeBackdrop; static constexpr const char* TogglePulseAccent = @@ -81,8 +81,8 @@ public: std::function setXCUIDemoPanelVisible = {}; std::function getXCUILayoutLabPanelVisible = {}; std::function setXCUILayoutLabPanelVisible = {}; - std::function getImGuiDemoWindowVisible = {}; - std::function setImGuiDemoWindowVisible = {}; + std::function getLegacyHostDemoWindowVisible = {}; + std::function setLegacyHostDemoWindowVisible = {}; std::function getNativeBackdropVisible = {}; std::function setNativeBackdropVisible = {}; std::function getPulseAccentEnabled = {}; @@ -214,9 +214,9 @@ public: true, false } }); bindToggleCommand( - ShellCommandIds::ToggleImGuiDemoWindow, - bindings.getImGuiDemoWindowVisible, - bindings.setImGuiDemoWindowVisible, + ShellCommandIds::ToggleLegacyHostDemoWindow, + bindings.getLegacyHostDemoWindowVisible, + bindings.setLegacyHostDemoWindowVisible, { XCUIEditorCommandAccelerator{ static_cast(KeyCode::Three), ctrlOnly, diff --git a/new_editor/src/ApplicationLegacyImGui.cpp b/new_editor/src/ApplicationLegacyImGui.cpp index 59d4698a..9fa53be7 100644 --- a/new_editor/src/ApplicationLegacyImGui.cpp +++ b/new_editor/src/ApplicationLegacyImGui.cpp @@ -155,11 +155,11 @@ void Application::ConfigureShellCommandRouter() { m_layoutLabPanel->SetVisible(visible); } }; - bindings.getImGuiDemoWindowVisible = [this]() { - return IsShellViewToggleEnabled(ShellViewToggleId::ImGuiDemoWindow); + bindings.getLegacyHostDemoWindowVisible = [this]() { + return IsShellViewToggleEnabled(ShellViewToggleId::LegacyHostDemoWindow); }; - bindings.setImGuiDemoWindowVisible = [this](bool visible) { - SetShellViewToggleEnabled(ShellViewToggleId::ImGuiDemoWindow, visible); + bindings.setLegacyHostDemoWindowVisible = [this](bool visible) { + SetShellViewToggleEnabled(ShellViewToggleId::LegacyHostDemoWindow, visible); }; bindings.getNativeBackdropVisible = [this]() { return IsShellViewToggleEnabled(ShellViewToggleId::NativeBackdrop); @@ -308,9 +308,9 @@ void Application::RenderLegacyImGuiUiFrame() { m_layoutLabPanel->RenderIfVisible(); } - bool showImGuiDemoWindow = IsShellViewToggleEnabled(ShellViewToggleId::ImGuiDemoWindow); - if (::XCEngine::Editor::XCUIBackend::RenderLegacyImGuiDemoWindow(showImGuiDemoWindow)) { - SetShellViewToggleEnabled(ShellViewToggleId::ImGuiDemoWindow, showImGuiDemoWindow); + bool showLegacyHostDemoWindow = IsShellViewToggleEnabled(ShellViewToggleId::LegacyHostDemoWindow); + if (::XCEngine::Editor::XCUIBackend::RenderLegacyImGuiDemoWindow(showLegacyHostDemoWindow)) { + SetShellViewToggleEnabled(ShellViewToggleId::LegacyHostDemoWindow, showLegacyHostDemoWindow); } SyncShellChromePanelStateFromPanels(); @@ -369,10 +369,10 @@ void Application::RenderShellChrome() { TryGetShellPanelState(ShellPanelId::XCUILayoutLab)->visible, ShellCommandIds::ToggleXCUILayoutLabPanel); drawCommandMenuItem( - "ImGui Demo", + "Legacy Host Demo", "Ctrl+3", - IsShellViewToggleEnabled(ShellViewToggleId::ImGuiDemoWindow), - ShellCommandIds::ToggleImGuiDemoWindow); + IsShellViewToggleEnabled(ShellViewToggleId::LegacyHostDemoWindow), + ShellCommandIds::ToggleLegacyHostDemoWindow); ImGui::Separator(); drawCommandMenuItem( "Native Backdrop", diff --git a/new_editor/src/XCUIBackend/XCUIShellChromeState.cpp b/new_editor/src/XCUIBackend/XCUIShellChromeState.cpp index 4c66683b..8305ae88 100644 --- a/new_editor/src/XCUIBackend/XCUIShellChromeState.cpp +++ b/new_editor/src/XCUIBackend/XCUIShellChromeState.cpp @@ -13,7 +13,7 @@ constexpr std::size_t ToIndex(XCUIShellPanelId panelId) { constexpr std::string_view kViewMenuLabel = "View"; constexpr std::string_view kXCUIDemoShortcut = "Ctrl+1"; constexpr std::string_view kXCUILayoutLabShortcut = "Ctrl+2"; -constexpr std::string_view kImGuiDemoShortcut = "Ctrl+3"; +constexpr std::string_view kLegacyHostDemoShortcut = "Ctrl+3"; constexpr std::string_view kNativeBackdropShortcut = "Ctrl+Shift+B"; constexpr std::string_view kPulseAccentShortcut = "Ctrl+Shift+P"; constexpr std::string_view kNativeXCUIOverlayShortcut = "Ctrl+Shift+O"; @@ -164,8 +164,8 @@ bool XCUIShellChromeState::ToggleHostedPreviewMode(XCUIShellPanelId panelId) { bool XCUIShellChromeState::GetViewToggle(XCUIShellViewToggleId toggleId) const { switch (toggleId) { - case XCUIShellViewToggleId::ImGuiDemoWindow: - return m_viewToggles.imguiDemoWindowVisible; + case XCUIShellViewToggleId::LegacyHostDemoWindow: + return m_viewToggles.legacyHostDemoWindowVisible; case XCUIShellViewToggleId::NativeBackdrop: return m_viewToggles.nativeBackdropVisible; case XCUIShellViewToggleId::PulseAccent: @@ -183,8 +183,8 @@ bool XCUIShellChromeState::GetViewToggle(XCUIShellViewToggleId toggleId) const { bool XCUIShellChromeState::SetViewToggle(XCUIShellViewToggleId toggleId, bool enabled) { bool* target = nullptr; switch (toggleId) { - case XCUIShellViewToggleId::ImGuiDemoWindow: - target = &m_viewToggles.imguiDemoWindowVisible; + case XCUIShellViewToggleId::LegacyHostDemoWindow: + target = &m_viewToggles.legacyHostDemoWindowVisible; break; case XCUIShellViewToggleId::NativeBackdrop: target = &m_viewToggles.nativeBackdropVisible; @@ -227,8 +227,8 @@ bool XCUIShellChromeState::InvokeCommand(std::string_view commandId) { if (commandId == XCUIShellChromeCommandIds::ToggleXCUILayoutLabPanel) { return TogglePanelVisible(XCUIShellPanelId::XCUILayoutLab); } - if (commandId == XCUIShellChromeCommandIds::ToggleImGuiDemoWindow) { - return ToggleViewToggle(XCUIShellViewToggleId::ImGuiDemoWindow); + if (commandId == XCUIShellChromeCommandIds::ToggleLegacyHostDemoWindow) { + return ToggleViewToggle(XCUIShellViewToggleId::LegacyHostDemoWindow); } if (commandId == XCUIShellChromeCommandIds::ToggleNativeBackdrop) { return ToggleViewToggle(XCUIShellViewToggleId::NativeBackdrop); @@ -288,12 +288,12 @@ bool XCUIShellChromeState::TryGetCommandDescriptor( return true; } - if (commandId == GetViewToggleCommandId(XCUIShellViewToggleId::ImGuiDemoWindow)) { - outDescriptor.label = "ImGui Demo"; - outDescriptor.shortcut = kImGuiDemoShortcut; + if (commandId == GetViewToggleCommandId(XCUIShellViewToggleId::LegacyHostDemoWindow)) { + outDescriptor.label = "Legacy Host Demo"; + outDescriptor.shortcut = kLegacyHostDemoShortcut; outDescriptor.commandId = commandId; outDescriptor.checkable = true; - outDescriptor.checked = GetViewToggle(XCUIShellViewToggleId::ImGuiDemoWindow); + outDescriptor.checked = GetViewToggle(XCUIShellViewToggleId::LegacyHostDemoWindow); outDescriptor.enabled = true; return true; } @@ -374,7 +374,7 @@ XCUIShellMenuDescriptor XCUIShellChromeState::BuildViewMenuDescriptor() const { appendCommandItem(GetPanelVisibilityCommandId(XCUIShellPanelId::XCUIDemo)); appendCommandItem(GetPanelVisibilityCommandId(XCUIShellPanelId::XCUILayoutLab)); - appendCommandItem(GetViewToggleCommandId(XCUIShellViewToggleId::ImGuiDemoWindow)); + appendCommandItem(GetViewToggleCommandId(XCUIShellViewToggleId::LegacyHostDemoWindow)); descriptor.items.push_back({ XCUIShellMenuItemKind::Separator, {} }); @@ -414,8 +414,8 @@ std::string_view XCUIShellChromeState::GetPanelPreviewModeCommandId(XCUIShellPan std::string_view XCUIShellChromeState::GetViewToggleCommandId(XCUIShellViewToggleId toggleId) { switch (toggleId) { - case XCUIShellViewToggleId::ImGuiDemoWindow: - return XCUIShellChromeCommandIds::ToggleImGuiDemoWindow; + case XCUIShellViewToggleId::LegacyHostDemoWindow: + return XCUIShellChromeCommandIds::ToggleLegacyHostDemoWindow; case XCUIShellViewToggleId::NativeBackdrop: return XCUIShellChromeCommandIds::ToggleNativeBackdrop; case XCUIShellViewToggleId::PulseAccent: diff --git a/new_editor/src/XCUIBackend/XCUIShellChromeState.h b/new_editor/src/XCUIBackend/XCUIShellChromeState.h index 9ad416f1..8c40463d 100644 --- a/new_editor/src/XCUIBackend/XCUIShellChromeState.h +++ b/new_editor/src/XCUIBackend/XCUIShellChromeState.h @@ -16,7 +16,7 @@ enum class XCUIShellPanelId : std::uint8_t { }; enum class XCUIShellViewToggleId : std::uint8_t { - ImGuiDemoWindow = 0, + LegacyHostDemoWindow = 0, NativeBackdrop, PulseAccent, NativeXCUIOverlay, @@ -46,7 +46,7 @@ struct XCUIShellPanelChromeState { }; struct XCUIShellViewToggleState { - bool imguiDemoWindowVisible = false; + bool legacyHostDemoWindowVisible = false; bool nativeBackdropVisible = true; bool pulseAccentEnabled = true; bool nativeXCUIOverlayVisible = true; @@ -56,7 +56,7 @@ struct XCUIShellViewToggleState { struct XCUIShellChromeCommandIds { static constexpr const char* ToggleXCUIDemoPanel = "new_editor.view.xcui_demo"; static constexpr const char* ToggleXCUILayoutLabPanel = "new_editor.view.xcui_layout_lab"; - static constexpr const char* ToggleImGuiDemoWindow = "new_editor.view.imgui_demo"; + static constexpr const char* ToggleLegacyHostDemoWindow = "new_editor.view.legacy_host_demo"; static constexpr const char* ToggleNativeBackdrop = "new_editor.view.native_backdrop"; static constexpr const char* TogglePulseAccent = "new_editor.view.pulse_accent"; static constexpr const char* ToggleNativeXCUIOverlay = "new_editor.view.native_xcui_overlay"; diff --git a/tests/NewEditor/test_application_shell_command_bindings.cpp b/tests/NewEditor/test_application_shell_command_bindings.cpp index 4c424b58..a1b5e0fc 100644 --- a/tests/NewEditor/test_application_shell_command_bindings.cpp +++ b/tests/NewEditor/test_application_shell_command_bindings.cpp @@ -71,11 +71,11 @@ struct ShellCommandHarness { bindings.setXCUILayoutLabPanelVisible = [this](bool visible) { panels[ToPanelIndex(Application::ShellPanelId::XCUILayoutLab)].visible = visible; }; - bindings.getImGuiDemoWindowVisible = [this]() { - return viewToggles.imguiDemoWindowVisible; + bindings.getLegacyHostDemoWindowVisible = [this]() { + return viewToggles.legacyHostDemoWindowVisible; }; - bindings.setImGuiDemoWindowVisible = [this](bool visible) { - viewToggles.imguiDemoWindowVisible = visible; + bindings.setLegacyHostDemoWindowVisible = [this](bool visible) { + viewToggles.legacyHostDemoWindowVisible = visible; }; bindings.getNativeBackdropVisible = [this]() { return viewToggles.nativeBackdropVisible; @@ -134,7 +134,7 @@ TEST(ApplicationShellCommandBindingsTest, RegisterShellViewCommandsInvokesBoundT EXPECT_TRUE(router.HasCommand(Application::ShellCommandIds::ToggleXCUIDemoPanel)); EXPECT_TRUE(router.HasCommand(Application::ShellCommandIds::ToggleXCUILayoutLabPanel)); - EXPECT_TRUE(router.HasCommand(Application::ShellCommandIds::ToggleImGuiDemoWindow)); + EXPECT_TRUE(router.HasCommand(Application::ShellCommandIds::ToggleLegacyHostDemoWindow)); EXPECT_TRUE(router.HasCommand(Application::ShellCommandIds::ToggleNativeBackdrop)); EXPECT_TRUE(router.HasCommand(Application::ShellCommandIds::TogglePulseAccent)); EXPECT_TRUE(router.HasCommand(Application::ShellCommandIds::ToggleNativeXCUIOverlay)); @@ -144,8 +144,8 @@ TEST(ApplicationShellCommandBindingsTest, RegisterShellViewCommandsInvokesBoundT EXPECT_TRUE(router.InvokeCommand(Application::ShellCommandIds::ToggleXCUIDemoPanel)); EXPECT_FALSE(harness.Panel(Application::ShellPanelId::XCUIDemo).visible); - EXPECT_TRUE(router.InvokeCommand(Application::ShellCommandIds::ToggleImGuiDemoWindow)); - EXPECT_TRUE(harness.viewToggles.imguiDemoWindowVisible); + EXPECT_TRUE(router.InvokeCommand(Application::ShellCommandIds::ToggleLegacyHostDemoWindow)); + EXPECT_TRUE(harness.viewToggles.legacyHostDemoWindowVisible); EXPECT_TRUE(router.InvokeCommand(Application::ShellCommandIds::ToggleNativeBackdrop)); EXPECT_FALSE(harness.viewToggles.nativeBackdropVisible); EXPECT_TRUE(router.InvokeCommand(Application::ShellCommandIds::ToggleNativeXCUIOverlay)); diff --git a/tests/NewEditor/test_xcui_shell_chrome_state.cpp b/tests/NewEditor/test_xcui_shell_chrome_state.cpp index 3ee58afd..67ebaf8a 100644 --- a/tests/NewEditor/test_xcui_shell_chrome_state.cpp +++ b/tests/NewEditor/test_xcui_shell_chrome_state.cpp @@ -17,7 +17,7 @@ TEST(XCUIShellChromeStateTest, DefaultsMatchCurrentShellChromeConfiguration) { XCUIShellChromeState state = {}; const auto& viewToggles = state.GetViewToggles(); - EXPECT_FALSE(viewToggles.imguiDemoWindowVisible); + EXPECT_FALSE(viewToggles.legacyHostDemoWindowVisible); EXPECT_TRUE(viewToggles.nativeBackdropVisible); EXPECT_TRUE(viewToggles.pulseAccentEnabled); EXPECT_TRUE(viewToggles.nativeXCUIOverlayVisible); @@ -118,9 +118,9 @@ TEST(XCUIShellChromeStateTest, HostedPreviewStateSeparatesEnablementFromRequeste TEST(XCUIShellChromeStateTest, ViewToggleMutatorsOnlyFlipRequestedFlags) { XCUIShellChromeState state = {}; - EXPECT_TRUE(state.SetViewToggle(XCUIShellViewToggleId::ImGuiDemoWindow, true)); - EXPECT_TRUE(state.GetViewToggle(XCUIShellViewToggleId::ImGuiDemoWindow)); - EXPECT_FALSE(state.SetViewToggle(XCUIShellViewToggleId::ImGuiDemoWindow, true)); + EXPECT_TRUE(state.SetViewToggle(XCUIShellViewToggleId::LegacyHostDemoWindow, true)); + EXPECT_TRUE(state.GetViewToggle(XCUIShellViewToggleId::LegacyHostDemoWindow)); + EXPECT_FALSE(state.SetViewToggle(XCUIShellViewToggleId::LegacyHostDemoWindow, true)); EXPECT_TRUE(state.ToggleViewToggle(XCUIShellViewToggleId::HostedPreviewHud)); EXPECT_FALSE(state.GetViewToggle(XCUIShellViewToggleId::HostedPreviewHud)); @@ -204,9 +204,9 @@ TEST(XCUIShellChromeStateTest, ViewMenuDescriptorMatchesCurrentApplicationOrderi EXPECT_EQ(menu.items[1].command.commandId, XCUIShellChromeCommandIds::ToggleXCUILayoutLabPanel); ASSERT_EQ(menu.items[2].kind, XCUIShellMenuItemKind::Command); - EXPECT_EQ(menu.items[2].command.label, "ImGui Demo"); + EXPECT_EQ(menu.items[2].command.label, "Legacy Host Demo"); EXPECT_EQ(menu.items[2].command.shortcut, "Ctrl+3"); - EXPECT_EQ(menu.items[2].command.commandId, XCUIShellChromeCommandIds::ToggleImGuiDemoWindow); + EXPECT_EQ(menu.items[2].command.commandId, XCUIShellChromeCommandIds::ToggleLegacyHostDemoWindow); EXPECT_EQ(menu.items[3].kind, XCUIShellMenuItemKind::Separator); @@ -276,8 +276,8 @@ TEST(XCUIShellChromeStateTest, PanelCommandIdHelpersMatchCurrentShellCommands) { TEST(XCUIShellChromeStateTest, ViewToggleCommandIdHelpersMatchCurrentShellCommands) { EXPECT_EQ( - XCUIShellChromeState::GetViewToggleCommandId(XCUIShellViewToggleId::ImGuiDemoWindow), - XCUIShellChromeCommandIds::ToggleImGuiDemoWindow); + XCUIShellChromeState::GetViewToggleCommandId(XCUIShellViewToggleId::LegacyHostDemoWindow), + XCUIShellChromeCommandIds::ToggleLegacyHostDemoWindow); EXPECT_EQ( XCUIShellChromeState::GetViewToggleCommandId(XCUIShellViewToggleId::NativeBackdrop), XCUIShellChromeCommandIds::ToggleNativeBackdrop);