Build XCEditor menu and status shell widgets
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
add_executable(editor_ui_status_bar_basic_validation WIN32
|
||||
main.cpp
|
||||
)
|
||||
|
||||
target_include_directories(editor_ui_status_bar_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_status_bar_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_status_bar_basic_validation PRIVATE /utf-8 /FS)
|
||||
set_property(TARGET editor_ui_status_bar_basic_validation PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_status_bar_basic_validation PRIVATE
|
||||
XCUIEditorLib
|
||||
XCUIEditorHost
|
||||
)
|
||||
|
||||
set_target_properties(editor_ui_status_bar_basic_validation PROPERTIES
|
||||
OUTPUT_NAME "XCUIEditorStatusBarBasicValidation"
|
||||
)
|
||||
531
tests/UI/Editor/integration/shell/status_bar_basic/main.cpp
Normal file
531
tests/UI/Editor/integration/shell/status_bar_basic/main.cpp
Normal file
@@ -0,0 +1,531 @@
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
|
||||
#include <XCEditor/Widgets/UIEditorStatusBar.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::AppendUIEditorStatusBarBackground;
|
||||
using XCEngine::UI::Editor::Widgets::AppendUIEditorStatusBarForeground;
|
||||
using XCEngine::UI::Editor::Widgets::BuildUIEditorStatusBarLayout;
|
||||
using XCEngine::UI::Editor::Widgets::HitTestUIEditorStatusBar;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorStatusBarHitTarget;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorStatusBarHitTargetKind;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorStatusBarInvalidIndex;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorStatusBarLayout;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorStatusBarSegment;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorStatusBarSlot;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorStatusBarState;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorStatusBarTextTone;
|
||||
|
||||
constexpr const wchar_t* kWindowClassName = L"XCUIEditorStatusBarBasicValidation";
|
||||
constexpr const wchar_t* kWindowTitle = L"XCUI Editor | StatusBar 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.40f, 0.40f, 0.40f, 1.0f);
|
||||
constexpr UIColor kButtonBorder(0.48f, 0.48f, 0.48f, 1.0f);
|
||||
|
||||
enum class ActionId : unsigned char {
|
||||
ToggleAccent = 0,
|
||||
ToggleSeparator,
|
||||
MoveToTrailing,
|
||||
Reset,
|
||||
Capture
|
||||
};
|
||||
|
||||
struct ButtonState {
|
||||
ActionId action = ActionId::ToggleAccent;
|
||||
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 DescribeHitTarget(const UIEditorStatusBarHitTarget& hit) {
|
||||
switch (hit.kind) {
|
||||
case UIEditorStatusBarHitTargetKind::Segment:
|
||||
return "Segment[" + std::to_string(hit.index) + "]";
|
||||
case UIEditorStatusBarHitTargetKind::Separator:
|
||||
return "Separator[" + std::to_string(hit.index) + "]";
|
||||
case UIEditorStatusBarHitTargetKind::Background:
|
||||
return "Background";
|
||||
case UIEditorStatusBarHitTargetKind::None:
|
||||
default:
|
||||
return "None";
|
||||
}
|
||||
}
|
||||
|
||||
std::string DescribeSlot(UIEditorStatusBarSlot slot) {
|
||||
return slot == UIEditorStatusBarSlot::Leading ? "Leading" : "Trailing";
|
||||
}
|
||||
|
||||
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");
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
UpdateWindow(hwnd);
|
||||
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:
|
||||
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/status_bar_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;
|
||||
}
|
||||
|
||||
if (!m_renderer.Initialize(m_hwnd)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ShowWindow(m_hwnd, nCmdShow);
|
||||
|
||||
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);
|
||||
UpdateHover();
|
||||
}
|
||||
|
||||
void HandleMouseLeave() {
|
||||
m_mousePosition = UIPoint(-1000.0f, -1000.0f);
|
||||
m_state.hoveredIndex = UIEditorStatusBarInvalidIndex;
|
||||
m_hoverTarget = {};
|
||||
}
|
||||
|
||||
void HandleClick(float x, float y) {
|
||||
for (const ButtonState& button : m_buttons) {
|
||||
if (ContainsPoint(button.rect, x, y)) {
|
||||
ExecuteAction(button.action);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_hoverTarget = HitTestUIEditorStatusBar(m_layout, UIPoint(x, y));
|
||||
if (m_hoverTarget.kind == UIEditorStatusBarHitTargetKind::Segment) {
|
||||
m_state.activeIndex = m_hoverTarget.index;
|
||||
m_state.focused = true;
|
||||
m_lastResult = "激活 segment: " + m_segments[m_hoverTarget.index].segmentId;
|
||||
} else if (m_hoverTarget.kind == UIEditorStatusBarHitTargetKind::Background) {
|
||||
m_state.activeIndex = UIEditorStatusBarInvalidIndex;
|
||||
m_lastResult = "点击 status bar background";
|
||||
} else {
|
||||
m_lastResult = "命中 " + DescribeHitTarget(m_hoverTarget);
|
||||
}
|
||||
UpdateHover();
|
||||
}
|
||||
|
||||
void ExecuteAction(ActionId action) {
|
||||
switch (action) {
|
||||
case ActionId::ToggleAccent:
|
||||
m_segments[1].tone =
|
||||
m_segments[1].tone == UIEditorStatusBarTextTone::Accent
|
||||
? UIEditorStatusBarTextTone::Primary
|
||||
: UIEditorStatusBarTextTone::Accent;
|
||||
m_lastResult = "切换 Selection 文本强调";
|
||||
break;
|
||||
case ActionId::ToggleSeparator:
|
||||
m_segments[0].showSeparator = !m_segments[0].showSeparator;
|
||||
m_lastResult = m_segments[0].showSeparator ? "开启 Leading separator" : "关闭 Leading separator";
|
||||
break;
|
||||
case ActionId::MoveToTrailing:
|
||||
m_segments[1].slot =
|
||||
m_segments[1].slot == UIEditorStatusBarSlot::Leading
|
||||
? UIEditorStatusBarSlot::Trailing
|
||||
: UIEditorStatusBarSlot::Leading;
|
||||
m_lastResult = "切换 Selection slot -> " + DescribeSlot(m_segments[1].slot);
|
||||
break;
|
||||
case ActionId::Reset:
|
||||
ResetState();
|
||||
m_lastResult = "状态重置";
|
||||
break;
|
||||
case ActionId::Capture:
|
||||
m_autoScreenshot.RequestCapture("manual_button");
|
||||
InvalidateRect(m_hwnd, nullptr, FALSE);
|
||||
UpdateWindow(m_hwnd);
|
||||
m_lastResult = "截图已排队";
|
||||
break;
|
||||
}
|
||||
UpdateHover();
|
||||
}
|
||||
|
||||
void ResetState() {
|
||||
m_segments = {
|
||||
{ "scene", "Scene: Main", UIEditorStatusBarSlot::Leading, UIEditorStatusBarTextTone::Primary, true, true, 96.0f },
|
||||
{ "selection", "Selection: Camera", UIEditorStatusBarSlot::Leading, UIEditorStatusBarTextTone::Accent, true, false, 140.0f },
|
||||
{ "frame", "16.7 ms", UIEditorStatusBarSlot::Trailing, UIEditorStatusBarTextTone::Muted, true, true, 64.0f },
|
||||
{ "gpu", "GPU Ready", UIEditorStatusBarSlot::Trailing, UIEditorStatusBarTextTone::Primary, true, false, 86.0f }
|
||||
};
|
||||
m_state = {};
|
||||
m_state.focused = true;
|
||||
m_state.activeIndex = 1u;
|
||||
m_hoverTarget = {};
|
||||
m_lastResult = "Ready";
|
||||
}
|
||||
|
||||
void UpdateHover() {
|
||||
m_hoverTarget = HitTestUIEditorStatusBar(m_layout, m_mousePosition);
|
||||
m_state.hoveredIndex =
|
||||
m_hoverTarget.kind == UIEditorStatusBarHitTargetKind::Segment
|
||||
? m_hoverTarget.index
|
||||
: UIEditorStatusBarInvalidIndex;
|
||||
}
|
||||
|
||||
void BuildButtons(float left, float top, float width) {
|
||||
const float buttonHeight = 34.0f;
|
||||
const float gap = 10.0f;
|
||||
m_buttons = {
|
||||
{ ActionId::ToggleAccent, "强调文本", UIRect(left, top, width, buttonHeight), m_segments[1].tone == UIEditorStatusBarTextTone::Accent },
|
||||
{ ActionId::ToggleSeparator, "Leading 分隔线", UIRect(left, top + (buttonHeight + gap), width, buttonHeight), m_segments[0].showSeparator },
|
||||
{ ActionId::MoveToTrailing, "切换 Selection Slot", UIRect(left, top + (buttonHeight + gap) * 2.0f, width, buttonHeight), m_segments[1].slot == UIEditorStatusBarSlot::Trailing },
|
||||
{ ActionId::Reset, "Reset", UIRect(left, top + (buttonHeight + gap) * 3.0f, width, buttonHeight), false },
|
||||
{ ActionId::Capture, "截图", UIRect(left, top + (buttonHeight + gap) * 4.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, 156.0f);
|
||||
const UIRect controlsRect(outerPadding, 196.0f, leftColumnWidth, 276.0f);
|
||||
const UIRect stateRect(outerPadding, 492.0f, leftColumnWidth, 244.0f);
|
||||
const UIRect previewRect(
|
||||
leftColumnWidth + outerPadding * 2.0f,
|
||||
outerPadding,
|
||||
width - leftColumnWidth - outerPadding * 3.0f,
|
||||
height - outerPadding * 2.0f);
|
||||
const UIRect viewportRect(
|
||||
previewRect.x,
|
||||
previewRect.y,
|
||||
previewRect.width,
|
||||
previewRect.height - 28.0f);
|
||||
const UIRect statusBarRect(
|
||||
previewRect.x,
|
||||
previewRect.y + previewRect.height - 28.0f,
|
||||
previewRect.width,
|
||||
28.0f);
|
||||
|
||||
BuildButtons(controlsRect.x + 16.0f, controlsRect.y + 54.0f, controlsRect.width - 32.0f);
|
||||
m_layout = BuildUIEditorStatusBarLayout(statusBarRect, m_segments);
|
||||
UpdateHover();
|
||||
|
||||
UIDrawData drawData = {};
|
||||
UIDrawList& drawList = drawData.EmplaceDrawList("StatusBarBasic");
|
||||
drawList.AddFilledRect(UIRect(0.0f, 0.0f, width, height), kWindowBg);
|
||||
|
||||
DrawCard(
|
||||
drawList,
|
||||
introRect,
|
||||
"测试功能:StatusBar 基础壳层",
|
||||
"重点检查:Leading / Trailing slot 对齐,文本强调,separator 开关,hover / active 命中。");
|
||||
drawList.AddText(
|
||||
UIPoint(introRect.x + 16.0f, introRect.y + 66.0f),
|
||||
"操作:hover 观察 segment 高亮;点击 segment 切 active;切换左侧按钮检查 slot / separator / emphasis;按 F12 或点“截图”。",
|
||||
kTextMuted,
|
||||
12.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(introRect.x + 16.0f, introRect.y + 90.0f),
|
||||
"这个场景只验证 Editor 基础层 StatusBar,不混入任何业务面板。",
|
||||
kTextWeak,
|
||||
12.0f);
|
||||
|
||||
DrawCard(drawList, controlsRect, "开关", "只保留和当前 StatusBar contract 直接相关的操作。");
|
||||
for (const ButtonState& button : m_buttons) {
|
||||
DrawButton(drawList, button);
|
||||
}
|
||||
|
||||
DrawCard(drawList, stateRect, "状态", "命中、active、slot 和结果统一回显在这里。");
|
||||
drawList.AddText(
|
||||
UIPoint(stateRect.x + 16.0f, stateRect.y + 66.0f),
|
||||
"Hover: " + DescribeHitTarget(m_hoverTarget),
|
||||
kTextPrimary,
|
||||
13.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(stateRect.x + 16.0f, stateRect.y + 92.0f),
|
||||
"Active: " + (m_state.activeIndex == UIEditorStatusBarInvalidIndex ? std::string("None") : m_segments[m_state.activeIndex].segmentId),
|
||||
kTextPrimary,
|
||||
13.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(stateRect.x + 16.0f, stateRect.y + 118.0f),
|
||||
"Selection Slot: " + DescribeSlot(m_segments[1].slot),
|
||||
kTextPrimary,
|
||||
13.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(stateRect.x + 16.0f, stateRect.y + 144.0f),
|
||||
std::string("Leading Separator: ") + (m_segments[0].showSeparator ? "On" : "Off"),
|
||||
kTextPrimary,
|
||||
13.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(stateRect.x + 16.0f, stateRect.y + 170.0f),
|
||||
"Result: " + m_lastResult,
|
||||
kTextMuted,
|
||||
12.0f);
|
||||
const std::string captureSummary =
|
||||
m_autoScreenshot.HasPendingCapture()
|
||||
? "截图排队中..."
|
||||
: (m_autoScreenshot.GetLastCaptureSummary().empty()
|
||||
? std::string("截图: F12 或按钮 -> status_bar_basic/captures/")
|
||||
: m_autoScreenshot.GetLastCaptureSummary());
|
||||
drawList.AddText(
|
||||
UIPoint(stateRect.x + 16.0f, stateRect.y + 196.0f),
|
||||
captureSummary,
|
||||
kTextWeak,
|
||||
12.0f);
|
||||
|
||||
drawList.AddFilledRect(viewportRect, UIColor(0.17f, 0.17f, 0.17f, 1.0f), 10.0f);
|
||||
drawList.AddRectOutline(viewportRect, kCardBorder, 1.0f, 10.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(viewportRect.x + 18.0f, viewportRect.y + 18.0f),
|
||||
"Preview Host",
|
||||
kTextPrimary,
|
||||
18.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(viewportRect.x + 18.0f, viewportRect.y + 48.0f),
|
||||
"这里只保留一个空白宿主区域,专门看底部 StatusBar 的对齐和交互。",
|
||||
kTextMuted,
|
||||
12.0f);
|
||||
|
||||
AppendUIEditorStatusBarBackground(drawList, m_layout, m_segments, m_state);
|
||||
AppendUIEditorStatusBarForeground(drawList, m_layout, m_segments, m_state);
|
||||
|
||||
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 = {};
|
||||
std::vector<UIEditorStatusBarSegment> m_segments = {};
|
||||
UIPoint m_mousePosition = UIPoint(-1000.0f, -1000.0f);
|
||||
UIEditorStatusBarState m_state = {};
|
||||
UIEditorStatusBarLayout m_layout = {};
|
||||
UIEditorStatusBarHitTarget m_hoverTarget = {};
|
||||
std::string m_lastResult = {};
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) {
|
||||
return ScenarioApp().Run(hInstance, nCmdShow);
|
||||
}
|
||||
Reference in New Issue
Block a user