Stabilize XCEditor shell foundation widgets

This commit is contained in:
2026-04-07 01:42:02 +08:00
parent 998df9013a
commit 3b2a05a098
20 changed files with 4118 additions and 23 deletions

View File

@@ -8,6 +8,8 @@ add_custom_target(editor_ui_integration_tests
DEPENDS
editor_ui_workspace_shell_compose_validation
editor_ui_menu_bar_basic_validation
editor_ui_panel_frame_basic_validation
editor_ui_tab_strip_basic_validation
editor_ui_panel_session_flow_validation
editor_ui_layout_persistence_validation
editor_ui_shortcut_dispatch_validation

View File

@@ -14,6 +14,8 @@ Layout:
- `shared/`: shared host wrapper, scenario registry, shared theme
- `shell/workspace_shell_compose/`: split/tab/panel shell compose only
- `shell/menu_bar_basic/`: menu bar open/close/hover/dispatch only
- `shell/panel_frame_basic/`: panel frame layout/state/hit-test only
- `shell/tab_strip_basic/`: tab strip layout/state/hit-test/close/navigation only
- `state/panel_session_flow/`: panel session state flow only
- `state/layout_persistence/`: layout save/load/reset only
- `state/shortcut_dispatch/`: shortcut match/suppression/dispatch only
@@ -30,6 +32,16 @@ Scenarios:
Executable: `XCUIEditorMenuBarBasicValidation.exe`
Scope: menu bar open/close, hover, dismiss, menu command dispatch only
- `editor.shell.panel_frame_basic`
Build target: `editor_ui_panel_frame_basic_validation`
Executable: `XCUIEditorPanelFrameBasicValidation.exe`
Scope: panel frame header/body/footer layout, focus/active/hover chrome, pin/close hit target only
- `editor.shell.tab_strip_basic`
Build target: `editor_ui_tab_strip_basic_validation`
Executable: `XCUIEditorTabStripBasicValidation.exe`
Scope: tab header layout, selected/hover/focus, close hit target, close fallback, Left/Right/Home/End navigation only
- `editor.state.panel_session_flow`
Build target: `editor_ui_panel_session_flow_validation`
Executable: `XCUIEditorPanelSessionFlowValidation.exe`
@@ -59,6 +71,12 @@ Selected controls:
- `shell/menu_bar_basic/`
Click `File / Window / Layout`, move the mouse across menu items, click outside the menu or press `Esc`, press `F12`.
- `shell/panel_frame_basic/`
Move the mouse over the preview panel, click `Body / Pin / Close`, toggle `Active / Focus / Closable / Footer`, press `F12`.
- `shell/tab_strip_basic/`
Click `Document A / B / C`, click `X` on closable tabs, click content to focus, press `Left / Right / Home / End`, press `Reset`, press `F12`.
- `state/panel_session_flow/`
Click `Hide Active / Show Doc A / Close Doc B / Open Doc B / Activate Details / Reset`, press `F12`.

View File

@@ -1,4 +1,6 @@
add_subdirectory(workspace_shell_compose)
add_subdirectory(panel_frame_basic)
add_subdirectory(tab_strip_basic)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/menu_bar_basic/CMakeLists.txt")
add_subdirectory(menu_bar_basic)
endif()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
add_executable(editor_ui_panel_frame_basic_validation WIN32
main.cpp
)
target_include_directories(editor_ui_panel_frame_basic_validation PRIVATE
${CMAKE_SOURCE_DIR}/new_editor/include
${CMAKE_SOURCE_DIR}/new_editor/app
${CMAKE_SOURCE_DIR}/engine/include
)
target_compile_definitions(editor_ui_panel_frame_basic_validation PRIVATE
UNICODE
_UNICODE
XCENGINE_EDITOR_UI_TESTS_REPO_ROOT="${XCENGINE_EDITOR_UI_TESTS_REPO_ROOT_PATH}"
)
if(MSVC)
target_compile_options(editor_ui_panel_frame_basic_validation PRIVATE /utf-8 /FS)
set_property(TARGET editor_ui_panel_frame_basic_validation PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
target_link_libraries(editor_ui_panel_frame_basic_validation PRIVATE
XCUIEditorLib
XCUIEditorHost
)
set_target_properties(editor_ui_panel_frame_basic_validation PROPERTIES
OUTPUT_NAME "XCUIEditorPanelFrameBasicValidation"
)

View File

@@ -0,0 +1,520 @@
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <XCEditor/Widgets/UIEditorPanelFrame.h>
#include "Host/AutoScreenshot.h"
#include "Host/NativeRenderer.h"
#include <XCEngine/UI/DrawData.h>
#include <windows.h>
#include <windowsx.h>
#include <algorithm>
#include <filesystem>
#include <string>
#include <string_view>
#include <vector>
#ifndef XCENGINE_EDITOR_UI_TESTS_REPO_ROOT
#define XCENGINE_EDITOR_UI_TESTS_REPO_ROOT "."
#endif
namespace {
using XCEngine::UI::UIColor;
using XCEngine::UI::UIDrawData;
using XCEngine::UI::UIDrawList;
using XCEngine::UI::UIPoint;
using XCEngine::UI::UIRect;
using XCEngine::UI::Editor::Host::AutoScreenshotController;
using XCEngine::UI::Editor::Host::NativeRenderer;
using XCEngine::UI::Editor::Widgets::AppendUIEditorPanelFrameBackground;
using XCEngine::UI::Editor::Widgets::AppendUIEditorPanelFrameForeground;
using XCEngine::UI::Editor::Widgets::BuildUIEditorPanelFrameLayout;
using XCEngine::UI::Editor::Widgets::HitTestUIEditorPanelFrame;
using XCEngine::UI::Editor::Widgets::UIEditorPanelFrameHitTarget;
using XCEngine::UI::Editor::Widgets::UIEditorPanelFrameLayout;
using XCEngine::UI::Editor::Widgets::UIEditorPanelFrameState;
using XCEngine::UI::Editor::Widgets::UIEditorPanelFrameText;
constexpr const wchar_t* kWindowClassName = L"XCUIEditorPanelFrameBasicValidation";
constexpr const wchar_t* kWindowTitle = L"XCUI Editor | PanelFrame Basic";
constexpr UIColor kWindowBg(0.13f, 0.13f, 0.13f, 1.0f);
constexpr UIColor kCardBg(0.18f, 0.18f, 0.18f, 1.0f);
constexpr UIColor kCardBorder(0.30f, 0.30f, 0.30f, 1.0f);
constexpr UIColor kCardAccent(0.82f, 0.82f, 0.82f, 1.0f);
constexpr UIColor kTextPrimary(0.94f, 0.94f, 0.94f, 1.0f);
constexpr UIColor kTextMuted(0.72f, 0.72f, 0.72f, 1.0f);
constexpr UIColor kTextWeak(0.56f, 0.56f, 0.56f, 1.0f);
constexpr UIColor kButtonBg(0.26f, 0.26f, 0.26f, 1.0f);
constexpr UIColor kButtonOnBg(0.42f, 0.42f, 0.42f, 1.0f);
constexpr UIColor kButtonBorder(0.48f, 0.48f, 0.48f, 1.0f);
enum class ActionId : unsigned char {
ToggleFooter = 0,
TogglePin,
ToggleClose,
Reset
};
struct ButtonState {
ActionId action = ActionId::ToggleFooter;
std::string label = {};
UIRect rect = {};
bool selected = false;
};
std::filesystem::path ResolveRepoRootPath() {
std::string root = XCENGINE_EDITOR_UI_TESTS_REPO_ROOT;
if (root.size() >= 2u && root.front() == '"' && root.back() == '"') {
root = root.substr(1u, root.size() - 2u);
}
return std::filesystem::path(root).lexically_normal();
}
bool ContainsPoint(const UIRect& rect, float x, float y) {
return x >= rect.x &&
x <= rect.x + rect.width &&
y >= rect.y &&
y <= rect.y + rect.height;
}
std::string DescribePart(UIEditorPanelFrameHitTarget part) {
switch (part) {
case UIEditorPanelFrameHitTarget::Header: return "Header";
case UIEditorPanelFrameHitTarget::Body: return "Body";
case UIEditorPanelFrameHitTarget::Footer: return "Footer";
case UIEditorPanelFrameHitTarget::PinButton: return "Pin";
case UIEditorPanelFrameHitTarget::CloseButton: return "Close";
default: return "None";
}
}
void DrawCard(
UIDrawList& drawList,
const UIRect& rect,
std::string_view title,
std::string_view subtitle = {}) {
drawList.AddFilledRect(rect, kCardBg, 10.0f);
drawList.AddRectOutline(rect, kCardBorder, 1.0f, 10.0f);
drawList.AddText(UIPoint(rect.x + 16.0f, rect.y + 14.0f), std::string(title), kTextPrimary, 17.0f);
if (!subtitle.empty()) {
drawList.AddText(UIPoint(rect.x + 16.0f, rect.y + 38.0f), std::string(subtitle), kTextMuted, 12.0f);
}
}
void DrawButton(
UIDrawList& drawList,
const ButtonState& button) {
drawList.AddFilledRect(button.rect, button.selected ? kButtonOnBg : kButtonBg, 8.0f);
drawList.AddRectOutline(button.rect, button.selected ? kCardAccent : kButtonBorder, 1.0f, 8.0f);
drawList.AddText(
UIPoint(button.rect.x + 12.0f, button.rect.y + 10.0f),
button.label,
kTextPrimary,
12.0f);
}
class ScenarioApp {
public:
int Run(HINSTANCE hInstance, int nCmdShow) {
if (!Initialize(hInstance, nCmdShow)) {
Shutdown();
return 1;
}
MSG message = {};
while (message.message != WM_QUIT) {
if (PeekMessageW(&message, nullptr, 0U, 0U, PM_REMOVE)) {
TranslateMessage(&message);
DispatchMessageW(&message);
continue;
}
RenderFrame();
Sleep(8);
}
Shutdown();
return static_cast<int>(message.wParam);
}
private:
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
if (message == WM_NCCREATE) {
const auto* createStruct = reinterpret_cast<CREATESTRUCTW*>(lParam);
auto* app = reinterpret_cast<ScenarioApp*>(createStruct->lpCreateParams);
SetWindowLongPtrW(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(app));
return TRUE;
}
auto* app = reinterpret_cast<ScenarioApp*>(GetWindowLongPtrW(hwnd, GWLP_USERDATA));
switch (message) {
case WM_SIZE:
if (app != nullptr && wParam != SIZE_MINIMIZED) {
app->OnResize(static_cast<UINT>(LOWORD(lParam)), static_cast<UINT>(HIWORD(lParam)));
}
return 0;
case WM_MOUSEMOVE:
if (app != nullptr) {
app->HandleMouseMove(
static_cast<float>(GET_X_LPARAM(lParam)),
static_cast<float>(GET_Y_LPARAM(lParam)));
return 0;
}
break;
case WM_MOUSELEAVE:
if (app != nullptr) {
app->HandleMouseLeave();
return 0;
}
break;
case WM_LBUTTONUP:
if (app != nullptr) {
app->HandleClick(
static_cast<float>(GET_X_LPARAM(lParam)),
static_cast<float>(GET_Y_LPARAM(lParam)));
return 0;
}
break;
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
if (app != nullptr && wParam == VK_F12) {
app->m_autoScreenshot.RequestCapture("manual_f12");
return 0;
}
break;
case WM_PAINT:
if (app != nullptr) {
PAINTSTRUCT paintStruct = {};
BeginPaint(hwnd, &paintStruct);
app->RenderFrame();
EndPaint(hwnd, &paintStruct);
return 0;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
break;
}
return DefWindowProcW(hwnd, message, wParam, lParam);
}
bool Initialize(HINSTANCE hInstance, int nCmdShow) {
m_captureRoot =
ResolveRepoRootPath() / "tests/UI/Editor/integration/shell/panel_frame_basic/captures";
m_autoScreenshot.Initialize(m_captureRoot);
WNDCLASSEXW windowClass = {};
windowClass.cbSize = sizeof(windowClass);
windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.lpfnWndProc = &ScenarioApp::WndProc;
windowClass.hInstance = hInstance;
windowClass.hCursor = LoadCursorW(nullptr, IDC_ARROW);
windowClass.lpszClassName = kWindowClassName;
m_windowClassAtom = RegisterClassExW(&windowClass);
if (m_windowClassAtom == 0) {
return false;
}
m_hwnd = CreateWindowExW(
0,
kWindowClassName,
kWindowTitle,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
1440,
920,
nullptr,
nullptr,
hInstance,
this);
if (m_hwnd == nullptr) {
return false;
}
ShowWindow(m_hwnd, nCmdShow);
UpdateWindow(m_hwnd);
if (!m_renderer.Initialize(m_hwnd)) {
return false;
}
ResetState();
return true;
}
void Shutdown() {
m_autoScreenshot.Shutdown();
m_renderer.Shutdown();
if (m_hwnd != nullptr && IsWindow(m_hwnd)) {
DestroyWindow(m_hwnd);
}
m_hwnd = nullptr;
if (m_windowClassAtom != 0) {
UnregisterClassW(kWindowClassName, GetModuleHandleW(nullptr));
m_windowClassAtom = 0;
}
}
void OnResize(UINT width, UINT height) {
m_renderer.Resize(width, height);
}
void HandleMouseMove(float x, float y) {
m_mousePosition = UIPoint(x, y);
TRACKMOUSEEVENT event = {};
event.cbSize = sizeof(event);
event.dwFlags = TME_LEAVE;
event.hwndTrack = m_hwnd;
TrackMouseEvent(&event);
UpdateHoveredPart();
}
void HandleMouseLeave() {
m_mousePosition = UIPoint(-1000.0f, -1000.0f);
m_hoveredPart = UIEditorPanelFrameHitTarget::None;
}
void HandleClick(float x, float y) {
for (const ButtonState& button : m_buttons) {
if (ContainsPoint(button.rect, x, y)) {
ExecuteAction(button.action);
return;
}
}
const UIEditorPanelFrameHitTarget part =
HitTestUIEditorPanelFrame(m_layout, m_state, UIPoint(x, y));
switch (part) {
case UIEditorPanelFrameHitTarget::Header:
m_state.active = !m_state.active;
m_lastResult = m_state.active ? "Header click -> Active = On" : "Header click -> Active = Off";
break;
case UIEditorPanelFrameHitTarget::Body:
case UIEditorPanelFrameHitTarget::Footer:
m_state.focused = true;
m_lastResult = "Body/Footer click -> Focus = On";
break;
case UIEditorPanelFrameHitTarget::PinButton:
if (m_state.pinnable) {
m_state.pinned = !m_state.pinned;
m_lastResult = m_state.pinned ? "Pin click -> Pinned = On" : "Pin click -> Pinned = Off";
}
break;
case UIEditorPanelFrameHitTarget::CloseButton:
if (m_state.closable) {
++m_closeDispatchCount;
m_lastResult = "Close click -> CloseRequested #" + std::to_string(m_closeDispatchCount);
}
break;
case UIEditorPanelFrameHitTarget::None:
default:
m_state.focused = false;
m_lastResult = "Outside click -> Focus = Off";
break;
}
UpdateHoveredPart();
}
void ExecuteAction(ActionId action) {
switch (action) {
case ActionId::ToggleFooter:
m_state.showFooter = !m_state.showFooter;
m_lastResult = m_state.showFooter ? "Footer = On" : "Footer = Off";
break;
case ActionId::TogglePin:
m_state.pinnable = !m_state.pinnable;
if (!m_state.pinnable) {
m_state.pinned = false;
}
m_lastResult = m_state.pinnable ? "Pin button = On" : "Pin button = Off";
break;
case ActionId::ToggleClose:
m_state.closable = !m_state.closable;
m_lastResult = m_state.closable ? "Close button = On" : "Close button = Off";
break;
case ActionId::Reset:
ResetState();
m_lastResult = "State reset";
break;
}
}
void ResetState() {
m_state = {};
m_state.active = true;
m_state.showFooter = true;
m_state.pinnable = true;
m_state.closable = true;
m_hoveredPart = UIEditorPanelFrameHitTarget::None;
m_lastResult = "Ready";
m_closeDispatchCount = 0;
}
void UpdateHoveredPart() {
m_hoveredPart = HitTestUIEditorPanelFrame(m_layout, m_state, m_mousePosition);
}
void BuildButtons(float left, float top, float width) {
const float buttonHeight = 34.0f;
const float gap = 10.0f;
m_buttons = {
{ ActionId::ToggleFooter, "Footer", UIRect(left, top, width, buttonHeight), m_state.showFooter },
{ ActionId::TogglePin, "Pin Button", UIRect(left, top + (buttonHeight + gap), width, buttonHeight), m_state.pinnable },
{ ActionId::ToggleClose, "Close Button", UIRect(left, top + (buttonHeight + gap) * 2.0f, width, buttonHeight), m_state.closable },
{ ActionId::Reset, "Reset", UIRect(left, top + (buttonHeight + gap) * 3.0f, width, buttonHeight), false }
};
}
void RenderFrame() {
RECT clientRect = {};
GetClientRect(m_hwnd, &clientRect);
const float width = static_cast<float>((std::max)(1L, clientRect.right - clientRect.left));
const float height = static_cast<float>((std::max)(1L, clientRect.bottom - clientRect.top));
const float leftColumnWidth = 340.0f;
const float outerPadding = 20.0f;
const UIRect introRect(outerPadding, outerPadding, leftColumnWidth, 148.0f);
const UIRect controlsRect(outerPadding, 188.0f, leftColumnWidth, 180.0f);
const UIRect stateRect(outerPadding, 388.0f, leftColumnWidth, 220.0f);
const UIRect panelRect(
leftColumnWidth + outerPadding * 2.0f,
outerPadding,
width - leftColumnWidth - outerPadding * 3.0f,
height - outerPadding * 2.0f);
BuildButtons(controlsRect.x + 16.0f, controlsRect.y + 54.0f, controlsRect.width - 32.0f);
UIDrawData drawData = {};
UIDrawList& drawList = drawData.EmplaceDrawList("PanelFrameBasic");
drawList.AddFilledRect(UIRect(0.0f, 0.0f, width, height), kWindowBg);
DrawCard(
drawList,
introRect,
"测试功能PanelFrame 基础壳层",
"重点检查Header / Body / Footer 布局Active / Focus 边框Pin / Close 命中。");
drawList.AddText(
UIPoint(introRect.x + 16.0f, introRect.y + 66.0f),
"操作:移动鼠标观察 hover点 Header 切 Active点 Body/Footer 取 Focus点 Pin/Close 看 Result按 F12 截图。",
kTextMuted,
12.0f);
drawList.AddText(
UIPoint(introRect.x + 16.0f, introRect.y + 90.0f),
"这个场景只验证 Editor 基础层 PanelFrame不包含任何业务面板。",
kTextWeak,
12.0f);
DrawCard(drawList, controlsRect, "开关", "这里只保留基础状态开关,避免试验面板过杂。");
for (const ButtonState& button : m_buttons) {
DrawButton(drawList, button);
}
DrawCard(drawList, stateRect, "状态", "右侧面板的命中结果和状态变化会同步显示在这里。");
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 66.0f),
"Hover: " + DescribePart(m_hoveredPart),
kTextPrimary,
13.0f);
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 92.0f),
std::string("Active: ") + (m_state.active ? "On" : "Off"),
kTextPrimary,
13.0f);
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 118.0f),
std::string("Focused: ") + (m_state.focused ? "On" : "Off"),
kTextPrimary,
13.0f);
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 144.0f),
std::string("Pinned: ") + (m_state.pinned ? "On" : "Off"),
kTextPrimary,
13.0f);
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 170.0f),
"Result: " + m_lastResult,
kTextMuted,
12.0f);
UIEditorPanelFrameState frameState = m_state;
frameState.hovered = m_hoveredPart != UIEditorPanelFrameHitTarget::None;
frameState.pinHovered = m_hoveredPart == UIEditorPanelFrameHitTarget::PinButton;
frameState.closeHovered = m_hoveredPart == UIEditorPanelFrameHitTarget::CloseButton;
m_layout = BuildUIEditorPanelFrameLayout(panelRect, frameState);
AppendUIEditorPanelFrameBackground(drawList, m_layout, frameState);
AppendUIEditorPanelFrameForeground(
drawList,
m_layout,
frameState,
UIEditorPanelFrameText{
"Inspector Placeholder",
"PanelFrame foundation validation",
m_state.showFooter
? "Footer visible | Active=" + std::string(m_state.active ? "On" : "Off")
: ""
});
drawList.AddText(
UIPoint(m_layout.bodyRect.x, m_layout.bodyRect.y),
"Body content placeholder",
kTextPrimary,
15.0f);
drawList.AddText(
UIPoint(m_layout.bodyRect.x, m_layout.bodyRect.y + 28.0f),
"Hover current region: " + DescribePart(m_hoveredPart),
kTextMuted,
12.0f);
drawList.AddText(
UIPoint(m_layout.bodyRect.x, m_layout.bodyRect.y + 50.0f),
"Pin button and Close button use PanelFrame hit rects.",
kTextMuted,
12.0f);
drawList.AddText(
UIPoint(m_layout.bodyRect.x, m_layout.bodyRect.y + 72.0f),
"Close does not destroy the panel here. It only verifies dispatch intent.",
kTextWeak,
12.0f);
const bool framePresented = m_renderer.Render(drawData);
m_autoScreenshot.CaptureIfRequested(
m_renderer,
drawData,
static_cast<unsigned int>(width),
static_cast<unsigned int>(height),
framePresented);
}
HWND m_hwnd = nullptr;
ATOM m_windowClassAtom = 0;
NativeRenderer m_renderer = {};
AutoScreenshotController m_autoScreenshot = {};
std::filesystem::path m_captureRoot = {};
std::vector<ButtonState> m_buttons = {};
UIPoint m_mousePosition = UIPoint(-1000.0f, -1000.0f);
UIEditorPanelFrameState m_state = {};
UIEditorPanelFrameLayout m_layout = {};
UIEditorPanelFrameHitTarget m_hoveredPart = UIEditorPanelFrameHitTarget::None;
std::string m_lastResult = {};
int m_closeDispatchCount = 0;
};
} // namespace
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) {
return ScenarioApp().Run(hInstance, nCmdShow);
}

View File

@@ -0,0 +1,30 @@
add_executable(editor_ui_tab_strip_basic_validation WIN32
main.cpp
)
target_include_directories(editor_ui_tab_strip_basic_validation PRIVATE
${CMAKE_SOURCE_DIR}/new_editor/include
${CMAKE_SOURCE_DIR}/new_editor/app
${CMAKE_SOURCE_DIR}/engine/include
)
target_compile_definitions(editor_ui_tab_strip_basic_validation PRIVATE
UNICODE
_UNICODE
XCENGINE_EDITOR_UI_TESTS_REPO_ROOT="${XCENGINE_EDITOR_UI_TESTS_REPO_ROOT_PATH}"
)
if(MSVC)
target_compile_options(editor_ui_tab_strip_basic_validation PRIVATE /utf-8 /FS)
set_property(TARGET editor_ui_tab_strip_basic_validation PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
target_link_libraries(editor_ui_tab_strip_basic_validation PRIVATE
XCUIEditorLib
XCUIEditorHost
)
set_target_properties(editor_ui_tab_strip_basic_validation PROPERTIES
OUTPUT_NAME "XCUIEditorTabStripBasicValidation"
)

View File

@@ -0,0 +1,740 @@
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <XCEditor/Core/UIEditorPanelRegistry.h>
#include <XCEditor/Core/UIEditorWorkspaceController.h>
#include <XCEditor/Widgets/UIEditorTabStrip.h>
#include "Host/AutoScreenshot.h"
#include "Host/NativeRenderer.h"
#include <XCEngine/UI/DrawData.h>
#include <XCEngine/UI/Widgets/UITabStripModel.h>
#include <windows.h>
#include <windowsx.h>
#include <algorithm>
#include <filesystem>
#include <sstream>
#include <string>
#include <string_view>
#include <vector>
#ifndef XCENGINE_EDITOR_UI_TESTS_REPO_ROOT
#define XCENGINE_EDITOR_UI_TESTS_REPO_ROOT "."
#endif
namespace {
using XCEngine::UI::UIColor;
using XCEngine::UI::UIDrawData;
using XCEngine::UI::UIDrawList;
using XCEngine::UI::UIPoint;
using XCEngine::UI::UIRect;
using XCEngine::UI::Widgets::UITabStripModel;
using XCEngine::UI::Editor::BuildDefaultUIEditorWorkspaceController;
using XCEngine::UI::Editor::BuildUIEditorWorkspacePanel;
using XCEngine::UI::Editor::BuildUIEditorWorkspaceTabStack;
using XCEngine::UI::Editor::FindUIEditorPanelDescriptor;
using XCEngine::UI::Editor::FindUIEditorPanelSessionState;
using XCEngine::UI::Editor::GetUIEditorWorkspaceCommandStatusName;
using XCEngine::UI::Editor::Host::AutoScreenshotController;
using XCEngine::UI::Editor::Host::NativeRenderer;
using XCEngine::UI::Editor::UIEditorPanelDescriptor;
using XCEngine::UI::Editor::UIEditorPanelRegistry;
using XCEngine::UI::Editor::UIEditorWorkspaceCommand;
using XCEngine::UI::Editor::UIEditorWorkspaceCommandKind;
using XCEngine::UI::Editor::UIEditorWorkspaceCommandResult;
using XCEngine::UI::Editor::UIEditorWorkspaceController;
using XCEngine::UI::Editor::UIEditorWorkspaceModel;
using XCEngine::UI::Editor::UIEditorWorkspaceNode;
using XCEngine::UI::Editor::UIEditorWorkspaceNodeKind;
using XCEngine::UI::Editor::Widgets::AppendUIEditorTabStripBackground;
using XCEngine::UI::Editor::Widgets::AppendUIEditorTabStripForeground;
using XCEngine::UI::Editor::Widgets::BuildUIEditorTabStripLayout;
using XCEngine::UI::Editor::Widgets::HitTestUIEditorTabStrip;
using XCEngine::UI::Editor::Widgets::ResolveUIEditorTabStripSelectedIndex;
using XCEngine::UI::Editor::Widgets::UIEditorTabStripHitTarget;
using XCEngine::UI::Editor::Widgets::UIEditorTabStripHitTargetKind;
using XCEngine::UI::Editor::Widgets::UIEditorTabStripInvalidIndex;
using XCEngine::UI::Editor::Widgets::UIEditorTabStripItem;
using XCEngine::UI::Editor::Widgets::UIEditorTabStripLayout;
using XCEngine::UI::Editor::Widgets::UIEditorTabStripState;
constexpr const wchar_t* kWindowClassName = L"XCUIEditorTabStripBasicValidation";
constexpr const wchar_t* kWindowTitle = L"XCUI Editor | TabStrip Basic";
constexpr UIColor kWindowBg(0.15f, 0.15f, 0.15f, 1.0f);
constexpr UIColor kCardBg(0.19f, 0.19f, 0.19f, 1.0f);
constexpr UIColor kCardBorder(0.30f, 0.30f, 0.30f, 1.0f);
constexpr UIColor kTextPrimary(0.94f, 0.94f, 0.94f, 1.0f);
constexpr UIColor kTextMuted(0.73f, 0.73f, 0.73f, 1.0f);
constexpr UIColor kTextWeak(0.58f, 0.58f, 0.58f, 1.0f);
constexpr UIColor kSuccess(0.62f, 0.74f, 0.62f, 1.0f);
constexpr UIColor kWarning(0.78f, 0.70f, 0.46f, 1.0f);
constexpr UIColor kDanger(0.82f, 0.48f, 0.48f, 1.0f);
constexpr UIColor kButtonBg(0.25f, 0.25f, 0.25f, 1.0f);
constexpr UIColor kButtonHoveredBg(0.31f, 0.31f, 0.31f, 1.0f);
std::filesystem::path ResolveRepoRootPath() {
std::string root = XCENGINE_EDITOR_UI_TESTS_REPO_ROOT;
if (root.size() >= 2u && root.front() == '"' && root.back() == '"') {
root = root.substr(1u, root.size() - 2u);
}
return std::filesystem::path(root).lexically_normal();
}
bool ContainsPoint(const UIRect& rect, float x, float y) {
return x >= rect.x &&
x <= rect.x + rect.width &&
y >= rect.y &&
y <= rect.y + rect.height;
}
void DrawCard(
UIDrawList& drawList,
const UIRect& rect,
std::string_view title,
std::string_view subtitle = {}) {
drawList.AddFilledRect(rect, kCardBg, 10.0f);
drawList.AddRectOutline(rect, kCardBorder, 1.0f, 10.0f);
drawList.AddText(UIPoint(rect.x + 16.0f, rect.y + 14.0f), std::string(title), kTextPrimary, 17.0f);
if (!subtitle.empty()) {
drawList.AddText(UIPoint(rect.x + 16.0f, rect.y + 40.0f), std::string(subtitle), kTextMuted, 12.0f);
}
}
void DrawButton(
UIDrawList& drawList,
const UIRect& rect,
std::string_view label,
bool hovered) {
drawList.AddFilledRect(rect, hovered ? kButtonHoveredBg : kButtonBg, 8.0f);
drawList.AddRectOutline(rect, kCardBorder, 1.0f, 8.0f);
drawList.AddText(UIPoint(rect.x + 14.0f, rect.y + 11.0f), std::string(label), kTextPrimary, 13.0f);
}
UIEditorPanelRegistry BuildPanelRegistry() {
UIEditorPanelRegistry registry = {};
registry.panels = {
{ "doc-a", "Document A", {}, true, true, true },
{ "doc-b", "Document B", {}, true, true, true },
{ "doc-c", "Document C", {}, true, true, false }
};
return registry;
}
UIEditorWorkspaceModel BuildWorkspace() {
UIEditorWorkspaceModel workspace = {};
workspace.root = BuildUIEditorWorkspaceTabStack(
"document-tabs",
{
BuildUIEditorWorkspacePanel("doc-a-node", "doc-a", "Document A", true),
BuildUIEditorWorkspacePanel("doc-b-node", "doc-b", "Document B", true),
BuildUIEditorWorkspacePanel("doc-c-node", "doc-c", "Document C", true)
},
0u);
workspace.activePanelId = "doc-a";
return workspace;
}
const UIEditorWorkspaceNode* GetRootTabStack(const UIEditorWorkspaceModel& workspace) {
return workspace.root.kind == UIEditorWorkspaceNodeKind::TabStack ? &workspace.root : nullptr;
}
std::string DescribeHitTarget(
const UIEditorTabStripHitTarget& target,
const std::vector<UIEditorTabStripItem>& items) {
switch (target.kind) {
case UIEditorTabStripHitTargetKind::HeaderBackground:
return "HeaderBackground";
case UIEditorTabStripHitTargetKind::Content:
return "Content";
case UIEditorTabStripHitTargetKind::Tab:
if (target.index < items.size()) {
return "Tab: " + items[target.index].title;
}
return "Tab";
case UIEditorTabStripHitTargetKind::CloseButton:
if (target.index < items.size()) {
return "CloseButton: " + items[target.index].title;
}
return "CloseButton";
case UIEditorTabStripHitTargetKind::None:
default:
return "None";
}
}
std::string JoinTabTitles(const std::vector<UIEditorTabStripItem>& items) {
if (items.empty()) {
return "(none)";
}
std::ostringstream stream;
for (std::size_t index = 0; index < items.size(); ++index) {
if (index > 0u) {
stream << " | ";
}
stream << items[index].title;
if (!items[index].closable) {
stream << " (locked)";
}
}
return stream.str();
}
class ScenarioApp {
public:
int Run(HINSTANCE hInstance, int nCmdShow) {
if (!Initialize(hInstance, nCmdShow)) {
Shutdown();
return 1;
}
MSG message = {};
while (message.message != WM_QUIT) {
if (PeekMessageW(&message, nullptr, 0U, 0U, PM_REMOVE)) {
TranslateMessage(&message);
DispatchMessageW(&message);
continue;
}
RenderFrame();
Sleep(8);
}
Shutdown();
return static_cast<int>(message.wParam);
}
private:
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
if (message == WM_NCCREATE) {
const auto* createStruct = reinterpret_cast<CREATESTRUCTW*>(lParam);
auto* app = reinterpret_cast<ScenarioApp*>(createStruct->lpCreateParams);
SetWindowLongPtrW(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(app));
return TRUE;
}
auto* app = reinterpret_cast<ScenarioApp*>(GetWindowLongPtrW(hwnd, GWLP_USERDATA));
switch (message) {
case WM_SIZE:
if (app != nullptr && wParam != SIZE_MINIMIZED) {
app->OnResize(static_cast<UINT>(LOWORD(lParam)), static_cast<UINT>(HIWORD(lParam)));
}
return 0;
case WM_MOUSEMOVE:
if (app != nullptr) {
app->HandleMouseMove(
static_cast<float>(GET_X_LPARAM(lParam)),
static_cast<float>(GET_Y_LPARAM(lParam)));
return 0;
}
break;
case WM_MOUSELEAVE:
if (app != nullptr) {
app->HandleMouseLeave();
return 0;
}
break;
case WM_LBUTTONUP:
if (app != nullptr) {
app->HandleClick(
static_cast<float>(GET_X_LPARAM(lParam)),
static_cast<float>(GET_Y_LPARAM(lParam)));
return 0;
}
break;
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
if (app != nullptr) {
if (wParam == VK_F12) {
app->m_autoScreenshot.RequestCapture("manual_f12");
} else {
app->HandleKeyDown(static_cast<UINT>(wParam));
}
return 0;
}
break;
case WM_PAINT:
if (app != nullptr) {
PAINTSTRUCT paintStruct = {};
BeginPaint(hwnd, &paintStruct);
app->RenderFrame();
EndPaint(hwnd, &paintStruct);
return 0;
}
break;
case WM_ERASEBKGND:
return 1;
case WM_DESTROY:
if (app != nullptr) {
app->m_hwnd = nullptr;
}
PostQuitMessage(0);
return 0;
default:
break;
}
return DefWindowProcW(hwnd, message, wParam, lParam);
}
bool Initialize(HINSTANCE hInstance, int nCmdShow) {
m_captureRoot =
ResolveRepoRootPath() / "tests/UI/Editor/integration/shell/tab_strip_basic/captures";
m_autoScreenshot.Initialize(m_captureRoot);
WNDCLASSEXW windowClass = {};
windowClass.cbSize = sizeof(windowClass);
windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.lpfnWndProc = &ScenarioApp::WndProc;
windowClass.hInstance = hInstance;
windowClass.hCursor = LoadCursorW(nullptr, IDC_ARROW);
windowClass.lpszClassName = kWindowClassName;
m_windowClassAtom = RegisterClassExW(&windowClass);
if (m_windowClassAtom == 0) {
return false;
}
m_hwnd = CreateWindowExW(
0,
kWindowClassName,
kWindowTitle,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
1440,
920,
nullptr,
nullptr,
hInstance,
this);
if (m_hwnd == nullptr) {
return false;
}
ShowWindow(m_hwnd, nCmdShow);
UpdateWindow(m_hwnd);
if (!m_renderer.Initialize(m_hwnd)) {
return false;
}
ResetScenario();
return true;
}
void Shutdown() {
m_autoScreenshot.Shutdown();
m_renderer.Shutdown();
if (m_hwnd != nullptr && IsWindow(m_hwnd)) {
DestroyWindow(m_hwnd);
}
m_hwnd = nullptr;
if (m_windowClassAtom != 0) {
UnregisterClassW(kWindowClassName, GetModuleHandleW(nullptr));
m_windowClassAtom = 0;
}
}
void ResetScenario() {
m_controller =
BuildDefaultUIEditorWorkspaceController(BuildPanelRegistry(), BuildWorkspace());
m_tabStripState = {};
m_layout = {};
m_tabItems.clear();
m_hoverTarget = {};
m_mousePosition = UIPoint(-1000.0f, -1000.0f);
m_lastResult = "等待操作";
m_navigationModel = {};
}
void OnResize(UINT width, UINT height) {
if (width == 0u || height == 0u) {
return;
}
m_renderer.Resize(width, height);
}
void HandleMouseMove(float x, float y) {
m_mousePosition = UIPoint(x, y);
TRACKMOUSEEVENT event = {};
event.cbSize = sizeof(event);
event.dwFlags = TME_LEAVE;
event.hwndTrack = m_hwnd;
TrackMouseEvent(&event);
m_resetButtonHovered = ContainsPoint(m_resetButtonRect, x, y);
RefreshHoverTarget();
InvalidateRect(m_hwnd, nullptr, FALSE);
}
void HandleMouseLeave() {
m_mousePosition = UIPoint(-1000.0f, -1000.0f);
m_resetButtonHovered = false;
m_hoverTarget = {};
m_tabStripState.hoveredIndex = UIEditorTabStripInvalidIndex;
m_tabStripState.closeHoveredIndex = UIEditorTabStripInvalidIndex;
InvalidateRect(m_hwnd, nullptr, FALSE);
}
void HandleClick(float x, float y) {
if (ContainsPoint(m_resetButtonRect, x, y)) {
ResetScenario();
InvalidateRect(m_hwnd, nullptr, FALSE);
return;
}
const UIEditorTabStripHitTarget hit =
HitTestUIEditorTabStrip(m_layout, m_tabStripState, UIPoint(x, y));
switch (hit.kind) {
case UIEditorTabStripHitTargetKind::CloseButton:
if (hit.index < m_tabItems.size()) {
DispatchCommand(
UIEditorWorkspaceCommandKind::ClosePanel,
m_tabItems[hit.index].tabId,
"Close " + m_tabItems[hit.index].title);
m_tabStripState.focused = true;
}
break;
case UIEditorTabStripHitTargetKind::Tab:
if (hit.index < m_tabItems.size()) {
DispatchCommand(
UIEditorWorkspaceCommandKind::ActivatePanel,
m_tabItems[hit.index].tabId,
"Activate " + m_tabItems[hit.index].title);
m_tabStripState.focused = true;
}
break;
case UIEditorTabStripHitTargetKind::HeaderBackground:
case UIEditorTabStripHitTargetKind::Content:
m_tabStripState.focused = true;
m_lastResult = "TabStrip 获得 focus";
break;
case UIEditorTabStripHitTargetKind::None:
default:
m_tabStripState.focused = false;
m_lastResult = "Focus cleared";
break;
}
RefreshHoverTarget();
InvalidateRect(m_hwnd, nullptr, FALSE);
}
void HandleKeyDown(UINT keyCode) {
if (!m_tabStripState.focused) {
return;
}
RefreshTabItems();
bool handled = true;
bool changed = false;
std::string action = {};
switch (keyCode) {
case VK_LEFT:
action = "Keyboard Left";
changed = m_navigationModel.SelectPrevious();
break;
case VK_RIGHT:
action = "Keyboard Right";
changed = m_navigationModel.SelectNext();
break;
case VK_HOME:
action = "Keyboard Home";
changed = m_navigationModel.SelectFirst();
break;
case VK_END:
action = "Keyboard End";
changed = m_navigationModel.SelectLast();
break;
default:
handled = false;
break;
}
if (!handled) {
return;
}
if (!changed || !m_navigationModel.HasSelection()) {
m_lastResult = action + " -> NoOp";
InvalidateRect(m_hwnd, nullptr, FALSE);
return;
}
const std::size_t selectedIndex = m_navigationModel.GetSelectedIndex();
if (selectedIndex < m_tabItems.size()) {
DispatchCommand(
UIEditorWorkspaceCommandKind::ActivatePanel,
m_tabItems[selectedIndex].tabId,
action + " -> " + m_tabItems[selectedIndex].title);
}
InvalidateRect(m_hwnd, nullptr, FALSE);
}
void DispatchCommand(
UIEditorWorkspaceCommandKind kind,
std::string_view panelId,
std::string label) {
UIEditorWorkspaceCommand command = {};
command.kind = kind;
command.panelId = std::string(panelId);
const UIEditorWorkspaceCommandResult result = m_controller.Dispatch(command);
m_lastResult =
std::move(label) + " -> " +
std::string(GetUIEditorWorkspaceCommandStatusName(result.status)) +
" | " +
result.message;
}
void RefreshTabItems() {
const UIEditorWorkspaceModel& workspace = m_controller.GetWorkspace();
const UIEditorPanelRegistry& registry = m_controller.GetPanelRegistry();
const auto* tabStack = GetRootTabStack(workspace);
m_tabItems.clear();
if (tabStack != nullptr) {
for (const UIEditorWorkspaceNode& child : tabStack->children) {
if (child.kind != UIEditorWorkspaceNodeKind::Panel) {
continue;
}
const auto* sessionState =
FindUIEditorPanelSessionState(m_controller.GetSession(), child.panel.panelId);
if (sessionState == nullptr || !sessionState->open || !sessionState->visible) {
continue;
}
const UIEditorPanelDescriptor* descriptor =
FindUIEditorPanelDescriptor(registry, child.panel.panelId);
UIEditorTabStripItem item = {};
item.tabId = child.panel.panelId;
item.title = child.panel.title;
item.closable = descriptor != nullptr ? descriptor->canClose : true;
m_tabItems.push_back(std::move(item));
}
}
m_tabStripState.selectedIndex =
ResolveUIEditorTabStripSelectedIndex(m_tabItems, workspace.activePanelId);
m_navigationModel.SetItemCount(m_tabItems.size());
if (m_tabStripState.selectedIndex != UIEditorTabStripInvalidIndex) {
m_navigationModel.SetSelectedIndex(m_tabStripState.selectedIndex);
}
}
void RefreshHoverTarget() {
m_hoverTarget = HitTestUIEditorTabStrip(m_layout, m_tabStripState, m_mousePosition);
m_tabStripState.hoveredIndex = UIEditorTabStripInvalidIndex;
m_tabStripState.closeHoveredIndex = UIEditorTabStripInvalidIndex;
if (m_hoverTarget.kind == UIEditorTabStripHitTargetKind::CloseButton &&
m_hoverTarget.index < m_tabItems.size()) {
m_tabStripState.hoveredIndex = m_hoverTarget.index;
m_tabStripState.closeHoveredIndex = m_hoverTarget.index;
return;
}
if (m_hoverTarget.kind == UIEditorTabStripHitTargetKind::Tab &&
m_hoverTarget.index < m_tabItems.size()) {
m_tabStripState.hoveredIndex = m_hoverTarget.index;
}
}
void RenderFrame() {
RECT clientRect = {};
GetClientRect(m_hwnd, &clientRect);
const float width = static_cast<float>((std::max)(1L, clientRect.right - clientRect.left));
const float height = static_cast<float>((std::max)(1L, clientRect.bottom - clientRect.top));
const float outerPadding = 20.0f;
const float leftColumnWidth = 360.0f;
const UIRect introRect(outerPadding, outerPadding, leftColumnWidth, 176.0f);
const UIRect stateRect(outerPadding, 216.0f, leftColumnWidth, height - 236.0f);
const UIRect previewCardRect(
leftColumnWidth + outerPadding * 2.0f,
outerPadding,
width - leftColumnWidth - outerPadding * 3.0f,
height - outerPadding * 2.0f);
const UIRect tabStripRect(
previewCardRect.x + 20.0f,
previewCardRect.y + 20.0f,
previewCardRect.width - 40.0f,
previewCardRect.height - 40.0f);
RefreshTabItems();
m_layout = BuildUIEditorTabStripLayout(tabStripRect, m_tabItems, m_tabStripState);
RefreshHoverTarget();
m_resetButtonRect = UIRect(
stateRect.x + 16.0f,
stateRect.y + 194.0f,
stateRect.width - 32.0f,
38.0f);
UIDrawData drawData = {};
UIDrawList& drawList = drawData.EmplaceDrawList("EditorTabStripBasic");
drawList.AddFilledRect(UIRect(0.0f, 0.0f, width, height), kWindowBg);
DrawCard(
drawList,
introRect,
"测试功能Editor TabStrip 基础层",
"只验证 TabStrip header / hit-test / selection / close / keyboard不包含任何业务面板。");
drawList.AddText(
UIPoint(introRect.x + 16.0f, introRect.y + 68.0f),
"重点检查tab 布局是否整齐selected / hover / focus 是否正确Close 后 active panel 是否回退正确。",
kTextPrimary,
12.0f);
drawList.AddText(
UIPoint(introRect.x + 16.0f, introRect.y + 92.0f),
"操作:点击 tab 切换;点击 X 关闭Document C 没有 X点击内容区后按 Left / Right / Home / EndReset 恢复F12 截图。",
kTextMuted,
12.0f);
drawList.AddText(
UIPoint(introRect.x + 16.0f, introRect.y + 116.0f),
"预期Close 命中优先于 tab键盘导航只在 focused 时生效Document C 始终保留。",
kTextWeak,
12.0f);
DrawCard(
drawList,
stateRect,
"状态回显",
"这里直接回显 hover / focus / active panel / result方便人工检查。");
DrawButton(drawList, m_resetButtonRect, "Reset", m_resetButtonHovered);
const std::size_t selectedIndex =
ResolveUIEditorTabStripSelectedIndex(m_tabItems, m_controller.GetWorkspace().activePanelId);
const std::string selectedIndexText =
selectedIndex == UIEditorTabStripInvalidIndex ? "(none)" : std::to_string(selectedIndex);
const auto validation = m_controller.ValidateState();
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 70.0f),
"Hover: " + DescribeHitTarget(m_hoverTarget, m_tabItems),
kTextPrimary,
13.0f);
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 96.0f),
std::string("Focused: ") + (m_tabStripState.focused ? "On" : "Off"),
kTextPrimary,
13.0f);
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 122.0f),
"Active Panel: " +
(m_controller.GetWorkspace().activePanelId.empty()
? std::string("(none)")
: m_controller.GetWorkspace().activePanelId),
kTextPrimary,
13.0f);
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 148.0f),
"Selected Index: " + selectedIndexText,
kTextPrimary,
13.0f);
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 174.0f),
"Tabs: " + JoinTabTitles(m_tabItems),
kTextMuted,
12.0f);
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 250.0f),
"Result: " + m_lastResult,
kTextMuted,
12.0f);
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 276.0f),
validation.IsValid() ? "Validation: OK" : "Validation: " + validation.message,
validation.IsValid() ? kSuccess : kDanger,
12.0f);
const std::string captureSummary =
m_autoScreenshot.HasPendingCapture()
? "截图排队中..."
: (m_autoScreenshot.GetLastCaptureSummary().empty()
? std::string("F12 -> tests/UI/Editor/integration/shell/tab_strip_basic/captures/")
: m_autoScreenshot.GetLastCaptureSummary());
drawList.AddText(
UIPoint(stateRect.x + 16.0f, stateRect.y + 302.0f),
captureSummary,
kTextWeak,
12.0f);
DrawCard(
drawList,
previewCardRect,
"预览区",
"这里只放一个 TabStrip 和一个 content placeholder避免试验面板过杂。");
AppendUIEditorTabStripBackground(drawList, m_layout, m_tabStripState);
AppendUIEditorTabStripForeground(drawList, m_layout, m_tabItems, m_tabStripState);
drawList.AddText(
UIPoint(m_layout.contentRect.x + 20.0f, m_layout.contentRect.y + 22.0f),
"Content Placeholder",
kTextPrimary,
18.0f);
drawList.AddText(
UIPoint(m_layout.contentRect.x + 20.0f, m_layout.contentRect.y + 52.0f),
"当前 active panel: " +
(m_controller.GetWorkspace().activePanelId.empty()
? std::string("(none)")
: m_controller.GetWorkspace().activePanelId),
kTextMuted,
13.0f);
drawList.AddText(
UIPoint(m_layout.contentRect.x + 20.0f, m_layout.contentRect.y + 76.0f),
"这个区域只用于验证 TabStrip content frame 与 focus不承载业务内容。",
kTextWeak,
12.0f);
drawList.AddText(
UIPoint(m_layout.contentRect.x + 20.0f, m_layout.contentRect.y + 100.0f),
"检查点:关闭 Document B 后,应自动回退到相邻 tabDocument C 无法关闭。",
kTextWeak,
12.0f);
const bool framePresented = m_renderer.Render(drawData);
m_autoScreenshot.CaptureIfRequested(
m_renderer,
drawData,
static_cast<unsigned int>(width),
static_cast<unsigned int>(height),
framePresented);
}
HWND m_hwnd = nullptr;
ATOM m_windowClassAtom = 0;
NativeRenderer m_renderer = {};
AutoScreenshotController m_autoScreenshot = {};
std::filesystem::path m_captureRoot = {};
UIPoint m_mousePosition = UIPoint(-1000.0f, -1000.0f);
UIEditorWorkspaceController m_controller = {};
UIEditorTabStripState m_tabStripState = {};
UIEditorTabStripLayout m_layout = {};
std::vector<UIEditorTabStripItem> m_tabItems = {};
UITabStripModel m_navigationModel = {};
UIEditorTabStripHitTarget m_hoverTarget = {};
UIRect m_resetButtonRect = {};
bool m_resetButtonHovered = false;
std::string m_lastResult = {};
};
} // namespace
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) {
return ScenarioApp().Run(hInstance, nCmdShow);
}