refactor(new_editor): snapshot hosted editor restructuring

This commit is contained in:
2026-04-21 00:57:14 +08:00
parent e123e584c8
commit 9b7b369007
248 changed files with 21152 additions and 14397 deletions

View File

@@ -3,6 +3,7 @@
#include <XCEditor/Widgets/UIEditorTextLayout.h>
#include <algorithm>
#include <cmath>
namespace XCEngine::UI::Editor::Widgets {
@@ -33,12 +34,6 @@ UIEditorEnumFieldPalette ResolvePalette(const UIEditorEnumFieldPalette& palette)
const auto& tokens = GetUIEditorInspectorFieldStyleTokens();
UIEditorEnumFieldPalette resolved = palette;
if (AreUIEditorFieldColorsEqual(palette.rowHoverColor, ::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f))) {
resolved.rowHoverColor = tokens.rowHoverColor;
}
if (AreUIEditorFieldColorsEqual(palette.rowActiveColor, ::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f))) {
resolved.rowActiveColor = tokens.rowActiveColor;
}
if (AreUIEditorFieldColorsEqual(palette.focusedBorderColor, ::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f))) {
resolved.focusedBorderColor = tokens.controlFocusedBorderColor;
}
@@ -86,20 +81,15 @@ void AppendDropdownChevron(
::XCEngine::UI::UIDrawList& drawList,
const ::XCEngine::UI::UIRect& rect,
const ::XCEngine::UI::UIColor& color) {
const float centerX = rect.x + rect.width * 0.5f;
const float centerY = rect.y + rect.height * 0.5f;
const float centerX = std::floor(rect.x + rect.width * 0.5f) + 0.5f;
const float centerY = std::floor(rect.y + rect.height * 0.5f) + 0.5f;
const float halfWidth = ClampNonNegative(rect.width * 0.18f);
const float halfHeight = ClampNonNegative(rect.height * 0.10f);
drawList.AddLine(
const float halfHeight = ClampNonNegative(rect.height * 0.12f);
drawList.AddFilledTriangle(
::XCEngine::UI::UIPoint(centerX - halfWidth, centerY - halfHeight),
::XCEngine::UI::UIPoint(centerX, centerY + halfHeight),
color,
1.0f);
drawList.AddLine(
::XCEngine::UI::UIPoint(centerX, centerY + halfHeight),
::XCEngine::UI::UIPoint(centerX + halfWidth, centerY - halfHeight),
color,
1.0f);
::XCEngine::UI::UIPoint(centerX, centerY + halfHeight),
color);
}
} // namespace
@@ -181,11 +171,29 @@ void AppendUIEditorEnumFieldBackground(
const bool controlHovered =
state.hoveredTarget == UIEditorEnumFieldHitTargetKind::ValueBox ||
state.hoveredTarget == UIEditorEnumFieldHitTargetKind::DropdownArrow;
const ::XCEngine::UI::UIColor controlColor =
const ::XCEngine::UI::UIColor previewColor =
spec.readOnly
? resolvedPalette.readOnlyColor
: (controlHovered || state.popupOpen ? resolvedPalette.valueBoxHoverColor : resolvedPalette.valueBoxColor);
drawList.AddFilledRect(layout.valueRect, controlColor, resolvedMetrics.valueBoxRounding);
const ::XCEngine::UI::UIColor arrowColor =
spec.readOnly
? resolvedPalette.readOnlyColor
: (state.popupOpen || state.hoveredTarget == UIEditorEnumFieldHitTargetKind::DropdownArrow
? resolvedPalette.valueBoxHoverColor
: resolvedPalette.valueBoxColor);
const ::XCEngine::UI::UIRect previewRect(
layout.valueRect.x,
layout.valueRect.y,
ClampNonNegative(layout.arrowRect.x - layout.valueRect.x),
layout.valueRect.height);
drawList.AddFilledRect(
previewRect,
previewColor,
resolvedMetrics.valueBoxRounding);
drawList.AddFilledRect(
layout.arrowRect,
arrowColor,
resolvedMetrics.valueBoxRounding);
drawList.AddRectOutline(
layout.valueRect,
state.popupOpen ? resolvedPalette.focusedBorderColor : resolvedPalette.controlBorderColor,