Build XCEditor menu and status shell widgets
This commit is contained in:
@@ -4,3 +4,9 @@ add_subdirectory(tab_strip_basic)
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/menu_bar_basic/CMakeLists.txt")
|
||||
add_subdirectory(menu_bar_basic)
|
||||
endif()
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/status_bar_basic/CMakeLists.txt")
|
||||
add_subdirectory(status_bar_basic)
|
||||
endif()
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/context_menu_basic/CMakeLists.txt")
|
||||
add_subdirectory(context_menu_basic)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
add_executable(editor_ui_context_menu_basic_validation WIN32
|
||||
main.cpp
|
||||
)
|
||||
|
||||
target_include_directories(editor_ui_context_menu_basic_validation PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
${CMAKE_SOURCE_DIR}/new_editor/include
|
||||
${CMAKE_SOURCE_DIR}/new_editor/app
|
||||
${CMAKE_SOURCE_DIR}/new_editor/src
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_context_menu_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_context_menu_basic_validation PRIVATE /utf-8 /FS)
|
||||
set_property(TARGET editor_ui_context_menu_basic_validation PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_context_menu_basic_validation PRIVATE
|
||||
XCUIEditorLib
|
||||
XCUIEditorHost
|
||||
)
|
||||
|
||||
set_target_properties(editor_ui_context_menu_basic_validation PROPERTIES
|
||||
OUTPUT_NAME "XCUIEditorContextMenuBasicValidation"
|
||||
)
|
||||
1249
tests/UI/Editor/integration/shell/context_menu_basic/main.cpp
Normal file
1249
tests/UI/Editor/integration/shell/context_menu_basic/main.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,8 @@
|
||||
#include <XCEditor/Core/UIEditorMenuModel.h>
|
||||
#include <XCEditor/Core/UIEditorMenuSession.h>
|
||||
#include <XCEditor/Core/UIEditorShortcutManager.h>
|
||||
#include <XCEditor/Widgets/UIEditorMenuBar.h>
|
||||
#include <XCEditor/Widgets/UIEditorMenuPopup.h>
|
||||
#include "Host/AutoScreenshot.h"
|
||||
#include "Host/NativeRenderer.h"
|
||||
|
||||
@@ -77,6 +79,20 @@ using XCEngine::UI::UIShortcutScope;
|
||||
using XCEngine::UI::Widgets::ResolvePopupPlacementRect;
|
||||
using XCEngine::UI::Widgets::UIPopupOverlayEntry;
|
||||
using XCEngine::UI::Widgets::UIPopupPlacement;
|
||||
using XCEngine::UI::Editor::Widgets::AppendUIEditorMenuBarBackground;
|
||||
using XCEngine::UI::Editor::Widgets::AppendUIEditorMenuBarForeground;
|
||||
using XCEngine::UI::Editor::Widgets::AppendUIEditorMenuPopupBackground;
|
||||
using XCEngine::UI::Editor::Widgets::AppendUIEditorMenuPopupForeground;
|
||||
using XCEngine::UI::Editor::Widgets::BuildUIEditorMenuBarLayout;
|
||||
using XCEngine::UI::Editor::Widgets::BuildUIEditorMenuPopupLayout;
|
||||
using XCEngine::UI::Editor::Widgets::MeasureUIEditorMenuPopupHeight;
|
||||
using XCEngine::UI::Editor::Widgets::ResolveUIEditorMenuPopupDesiredWidth;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorMenuBarItem;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorMenuBarState;
|
||||
using UIEditorMenuPopupWidgetItem = XCEngine::UI::Editor::Widgets::UIEditorMenuPopupItem;
|
||||
using UIEditorMenuPopupWidgetState = XCEngine::UI::Editor::Widgets::UIEditorMenuPopupState;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorMenuBarInvalidIndex;
|
||||
using XCEngine::UI::Editor::Widgets::UIEditorMenuPopupInvalidIndex;
|
||||
using XCEngine::UI::Editor::Host::AutoScreenshotController;
|
||||
using XCEngine::UI::Editor::Host::NativeRenderer;
|
||||
|
||||
@@ -159,8 +175,11 @@ std::string JoinClosedPopupIds(const UIEditorMenuSessionMutationResult& result);
|
||||
const UIEditorResolvedMenuDescriptor* FindResolvedMenu(const UIEditorResolvedMenuModel& model, std::string_view menuId);
|
||||
const UIEditorResolvedMenuItem* FindResolvedMenuItemRecursive(const std::vector<UIEditorResolvedMenuItem>& items, std::string_view itemId);
|
||||
const std::vector<UIEditorResolvedMenuItem>* ResolvePopupItems(const UIEditorResolvedMenuModel& model, const UIEditorMenuPopupState& popupState);
|
||||
std::vector<UIEditorMenuBarItem> BuildMenuBarWidgetItems(const UIEditorResolvedMenuModel& model);
|
||||
std::vector<UIEditorMenuPopupWidgetItem> BuildMenuPopupWidgetItems(const std::vector<UIEditorResolvedMenuItem>& items);
|
||||
std::size_t FindMenuBarWidgetIndex(const std::vector<UIEditorMenuBarItem>& items, std::string_view menuId);
|
||||
std::size_t FindMenuPopupWidgetIndex(const std::vector<UIEditorMenuPopupWidgetItem>& items, std::string_view itemId);
|
||||
std::uint64_t HashText(std::string_view text);
|
||||
float MeasureMenuPopupHeight(const std::vector<UIEditorResolvedMenuItem>& items);
|
||||
|
||||
class ScenarioApp {
|
||||
public:
|
||||
@@ -602,13 +621,61 @@ const std::vector<UIEditorResolvedMenuItem>* ResolvePopupItems(
|
||||
return &item->children;
|
||||
}
|
||||
|
||||
float MeasureMenuPopupHeight(const std::vector<UIEditorResolvedMenuItem>& items) {
|
||||
float contentHeight = 10.0f;
|
||||
std::vector<UIEditorMenuBarItem> BuildMenuBarWidgetItems(
|
||||
const UIEditorResolvedMenuModel& model) {
|
||||
std::vector<UIEditorMenuBarItem> items = {};
|
||||
items.reserve(model.menus.size());
|
||||
for (const UIEditorResolvedMenuDescriptor& menu : model.menus) {
|
||||
UIEditorMenuBarItem item = {};
|
||||
item.menuId = menu.menuId;
|
||||
item.label = menu.label;
|
||||
item.enabled = true;
|
||||
items.push_back(std::move(item));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
std::vector<UIEditorMenuPopupWidgetItem> BuildMenuPopupWidgetItems(
|
||||
const std::vector<UIEditorResolvedMenuItem>& items) {
|
||||
std::vector<UIEditorMenuPopupWidgetItem> popupItems = {};
|
||||
popupItems.reserve(items.size());
|
||||
for (const UIEditorResolvedMenuItem& item : items) {
|
||||
contentHeight += item.kind == UIEditorMenuItemKind::Separator ? 12.0f : 34.0f;
|
||||
UIEditorMenuPopupWidgetItem popupItem = {};
|
||||
popupItem.itemId = item.itemId;
|
||||
popupItem.kind = item.kind;
|
||||
popupItem.label = item.label;
|
||||
popupItem.shortcutText = item.shortcutText;
|
||||
popupItem.enabled = item.enabled;
|
||||
popupItem.checked = item.checked;
|
||||
popupItem.hasSubmenu =
|
||||
item.kind == UIEditorMenuItemKind::Submenu && !item.children.empty();
|
||||
popupItems.push_back(std::move(popupItem));
|
||||
}
|
||||
return popupItems;
|
||||
}
|
||||
|
||||
std::size_t FindMenuBarWidgetIndex(
|
||||
const std::vector<UIEditorMenuBarItem>& items,
|
||||
std::string_view menuId) {
|
||||
for (std::size_t index = 0; index < items.size(); ++index) {
|
||||
if (items[index].menuId == menuId) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
return contentHeight + 8.0f;
|
||||
return UIEditorMenuBarInvalidIndex;
|
||||
}
|
||||
|
||||
std::size_t FindMenuPopupWidgetIndex(
|
||||
const std::vector<UIEditorMenuPopupWidgetItem>& items,
|
||||
std::string_view itemId) {
|
||||
for (std::size_t index = 0; index < items.size(); ++index) {
|
||||
if (items[index].itemId == itemId) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
return UIEditorMenuPopupInvalidIndex;
|
||||
}
|
||||
|
||||
int ScenarioApp::Run(HINSTANCE hInstance, int nCmdShow) {
|
||||
@@ -867,7 +934,8 @@ const MenuPopupLayout* ScenarioApp::HitTestMenuPopup(float x, float y) const {
|
||||
|
||||
const MenuItemLayout* ScenarioApp::HitTestMenuItem(float x, float y) const {
|
||||
for (auto it = m_menuItems.rbegin(); it != m_menuItems.rend(); ++it) {
|
||||
if (ContainsPoint(it->rect, x, y)) {
|
||||
if (it->kind != UIEditorMenuItemKind::Separator &&
|
||||
ContainsPoint(it->rect, x, y)) {
|
||||
return &(*it);
|
||||
}
|
||||
}
|
||||
@@ -1234,31 +1302,25 @@ void ScenarioApp::DrawMenuBar(
|
||||
UIDrawList& drawList,
|
||||
const UIRect& rect,
|
||||
const UIEditorResolvedMenuModel& resolvedModel) {
|
||||
drawList.AddFilledRect(rect, kMenuBarBg, 8.0f);
|
||||
drawList.AddRectOutline(rect, kCardBorder, 1.0f, 8.0f);
|
||||
const auto barItems = BuildMenuBarWidgetItems(resolvedModel);
|
||||
UIEditorMenuBarState barState = {};
|
||||
barState.openIndex = FindMenuBarWidgetIndex(barItems, m_menuSession.GetOpenRootMenuId());
|
||||
barState.hoveredIndex = FindMenuBarWidgetIndex(barItems, m_hoveredMenuId);
|
||||
barState.focused = m_menuSession.HasOpenMenu();
|
||||
|
||||
float buttonX = rect.x + 12.0f;
|
||||
for (const UIEditorResolvedMenuDescriptor& menu : resolvedModel.menus) {
|
||||
const bool open = m_menuSession.IsMenuOpen(menu.menuId);
|
||||
const bool hovered = m_hoveredMenuId == menu.menuId;
|
||||
const float buttonWidth = 104.0f;
|
||||
const UIRect buttonRect(buttonX, rect.y + 6.0f, buttonWidth, rect.height - 12.0f);
|
||||
|
||||
drawList.AddFilledRect(
|
||||
buttonRect,
|
||||
open ? kMenuButtonOpen : (hovered ? kMenuButtonHover : kMenuButtonBg),
|
||||
6.0f);
|
||||
drawList.AddRectOutline(buttonRect, kCardBorder, 1.0f, 6.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(buttonRect.x + 14.0f, buttonRect.y + 10.0f),
|
||||
menu.label,
|
||||
kTextPrimary,
|
||||
14.0f);
|
||||
const auto barLayout = BuildUIEditorMenuBarLayout(rect, barItems);
|
||||
AppendUIEditorMenuBarBackground(drawList, barLayout, barItems, barState);
|
||||
AppendUIEditorMenuBarForeground(drawList, barLayout, barItems, barState);
|
||||
|
||||
for (std::size_t index = 0; index < barItems.size() && index < barLayout.buttonRects.size(); ++index) {
|
||||
m_menuButtons.push_back(
|
||||
{ menu.menuId, menu.label, BuildRootPopupId(menu.menuId), buttonRect, BuildMenuButtonPath(menu.menuId) });
|
||||
|
||||
buttonX += buttonWidth + 10.0f;
|
||||
{
|
||||
barItems[index].menuId,
|
||||
barItems[index].label,
|
||||
BuildRootPopupId(barItems[index].menuId),
|
||||
barLayout.buttonRects[index],
|
||||
BuildMenuButtonPath(barItems[index].menuId)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1269,75 +1331,45 @@ void ScenarioApp::DrawPopup(
|
||||
const std::vector<UIEditorResolvedMenuItem>& items,
|
||||
const UIPopupOverlayEntry& popupEntry,
|
||||
const UIRect& viewportRect) {
|
||||
const auto popupItems = BuildMenuPopupWidgetItems(items);
|
||||
const float popupWidth = (std::max)(
|
||||
kMenuPopupWidth,
|
||||
ResolveUIEditorMenuPopupDesiredWidth(popupItems));
|
||||
const auto placementResult =
|
||||
ResolvePopupPlacementRect(
|
||||
popupEntry.anchorRect,
|
||||
XCEngine::UI::UISize(kMenuPopupWidth, MeasureMenuPopupHeight(items)),
|
||||
XCEngine::UI::UISize(popupWidth, MeasureUIEditorMenuPopupHeight(popupItems)),
|
||||
viewportRect,
|
||||
popupEntry.placement);
|
||||
const UIRect popupRect = placementResult.rect;
|
||||
|
||||
drawList.AddFilledRect(popupRect, kMenuDropBg, 8.0f);
|
||||
drawList.AddRectOutline(popupRect, kCardBorder, 1.0f, 8.0f);
|
||||
UIEditorMenuPopupWidgetState popupState = {};
|
||||
popupState.hoveredIndex = FindMenuPopupWidgetIndex(popupItems, m_hoveredItemId);
|
||||
popupState.focused = true;
|
||||
for (std::size_t index = 0; index < popupItems.size(); ++index) {
|
||||
if (!popupItems[index].hasSubmenu) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_menuSession.IsPopupOpen(BuildSubmenuPopupId(popupItems[index].itemId))) {
|
||||
popupState.submenuOpenIndex = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const auto popupLayout = BuildUIEditorMenuPopupLayout(popupRect, popupItems);
|
||||
AppendUIEditorMenuPopupBackground(drawList, popupLayout, popupItems, popupState);
|
||||
AppendUIEditorMenuPopupForeground(drawList, popupLayout, popupItems, popupState);
|
||||
|
||||
m_menuPopups.push_back(
|
||||
{ std::string(popupId), std::string(menuId), popupEntry.parentPopupId, popupRect, popupEntry.surfacePath });
|
||||
|
||||
float itemY = popupRect.y + 8.0f;
|
||||
for (const UIEditorResolvedMenuItem& item : items) {
|
||||
if (item.kind == UIEditorMenuItemKind::Separator) {
|
||||
drawList.AddFilledRect(
|
||||
UIRect(popupRect.x + 12.0f, itemY + 4.0f, popupRect.width - 24.0f, 1.0f),
|
||||
kMenuDivider);
|
||||
itemY += 12.0f;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (std::size_t index = 0; index < items.size() && index < popupItems.size() && index < popupLayout.itemRects.size(); ++index) {
|
||||
const UIEditorResolvedMenuItem& item = items[index];
|
||||
const bool hasSubmenu =
|
||||
item.kind == UIEditorMenuItemKind::Submenu && !item.children.empty();
|
||||
const std::string childPopupId =
|
||||
hasSubmenu ? BuildSubmenuPopupId(item.itemId) : std::string();
|
||||
const bool submenuOpen =
|
||||
hasSubmenu && m_menuSession.IsPopupOpen(childPopupId);
|
||||
const bool hovered = m_hoveredItemId == item.itemId;
|
||||
|
||||
const UIRect itemRect(popupRect.x + 8.0f, itemY, popupRect.width - 16.0f, 30.0f);
|
||||
if (hovered || submenuOpen) {
|
||||
drawList.AddFilledRect(itemRect, kMenuItemHover, 6.0f);
|
||||
}
|
||||
|
||||
drawList.AddRectOutline(
|
||||
UIRect(itemRect.x + 10.0f, itemRect.y + 8.0f, 10.0f, 10.0f),
|
||||
item.checked ? kAccent : kMenuDivider,
|
||||
item.checked ? 2.0f : 1.0f,
|
||||
3.0f);
|
||||
if (item.checked) {
|
||||
drawList.AddFilledRect(
|
||||
UIRect(itemRect.x + 12.0f, itemRect.y + 10.0f, 6.0f, 6.0f),
|
||||
kAccent,
|
||||
2.0f);
|
||||
}
|
||||
|
||||
drawList.AddText(
|
||||
UIPoint(itemRect.x + 30.0f, itemRect.y + 7.0f),
|
||||
item.label,
|
||||
item.enabled ? kTextPrimary : kTextDisabled,
|
||||
13.0f);
|
||||
if (!item.shortcutText.empty()) {
|
||||
drawList.AddText(
|
||||
UIPoint(itemRect.x + itemRect.width - 92.0f, itemRect.y + 7.0f),
|
||||
item.shortcutText,
|
||||
item.enabled ? kTextMuted : kTextDisabled,
|
||||
12.0f);
|
||||
}
|
||||
if (hasSubmenu) {
|
||||
drawList.AddText(
|
||||
UIPoint(itemRect.x + itemRect.width - 24.0f, itemRect.y + 7.0f),
|
||||
">",
|
||||
kTextMuted,
|
||||
13.0f);
|
||||
}
|
||||
|
||||
m_menuItems.push_back(
|
||||
{
|
||||
std::string(popupId),
|
||||
@@ -1348,13 +1380,12 @@ void ScenarioApp::DrawPopup(
|
||||
item.commandId,
|
||||
item.shortcutText,
|
||||
childPopupId,
|
||||
itemRect,
|
||||
popupLayout.itemRects[index],
|
||||
BuildMenuItemPath(popupId, item.itemId),
|
||||
item.enabled,
|
||||
item.checked,
|
||||
hasSubmenu
|
||||
});
|
||||
itemY += 34.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1410,7 +1441,7 @@ void ScenarioApp::BuildDrawData(UIDrawData& drawData, float width, float height)
|
||||
shellRect.y,
|
||||
width - shellRect.width - margin * 2.0f - 16.0f,
|
||||
height - 312.0f);
|
||||
const UIRect footerRect(margin, height - 100.0f, width - margin * 2.0f, 80.0f);
|
||||
const UIRect footerRect(margin, height - 124.0f, width - margin * 2.0f, 104.0f);
|
||||
|
||||
DrawCard(
|
||||
drawList,
|
||||
@@ -1461,8 +1492,8 @@ void ScenarioApp::BuildDrawData(UIDrawData& drawData, float width, float height)
|
||||
drawList.AddText(UIPoint(stateRect.x + 18.0f, stateRect.y + 482.0f), "menu model validation", kTextMuted, 12.0f);
|
||||
drawList.AddText(UIPoint(stateRect.x + 18.0f, stateRect.y + 502.0f), menuValidation.IsValid() ? "OK" : menuValidation.message, menuValidation.IsValid() ? kSuccess : kDanger, 12.0f);
|
||||
|
||||
drawList.AddText(UIPoint(footerRect.x + 18.0f, footerRect.y + 28.0f), "Last interaction: " + m_lastActionName + " | Result: " + m_lastStatusLabel, m_lastStatusColor, 13.0f);
|
||||
drawList.AddText(UIPoint(footerRect.x + 18.0f, footerRect.y + 48.0f), m_lastMessage, kTextPrimary, 12.0f);
|
||||
drawList.AddText(UIPoint(footerRect.x + 18.0f, footerRect.y + 56.0f), "Last interaction: " + m_lastActionName + " | Result: " + m_lastStatusLabel, m_lastStatusColor, 13.0f);
|
||||
drawList.AddText(UIPoint(footerRect.x + 18.0f, footerRect.y + 74.0f), m_lastMessage, kTextPrimary, 12.0f);
|
||||
|
||||
const std::string captureSummary =
|
||||
m_autoScreenshot.HasPendingCapture()
|
||||
@@ -1470,7 +1501,7 @@ void ScenarioApp::BuildDrawData(UIDrawData& drawData, float width, float height)
|
||||
: (m_autoScreenshot.GetLastCaptureSummary().empty()
|
||||
? std::string("F12 -> tests/UI/Editor/integration/shell/menu_bar_basic/captures/")
|
||||
: m_autoScreenshot.GetLastCaptureSummary());
|
||||
drawList.AddText(UIPoint(footerRect.x + 18.0f, footerRect.y + 66.0f), captureSummary, kTextMuted, 12.0f);
|
||||
drawList.AddText(UIPoint(footerRect.x + 18.0f, footerRect.y + 92.0f), captureSummary, kTextMuted, 12.0f);
|
||||
|
||||
DrawOpenPopups(drawList, resolvedModel, viewportRect);
|
||||
}
|
||||
|
||||
@@ -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