Refactor XCUI editor module layout
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
|
||||
#include <XCEditor/Widgets/UIEditorStatusBar.h>
|
||||
#include <XCEditor/Shell/UIEditorStatusBar.h>
|
||||
#include "Host/AutoScreenshot.h"
|
||||
#include "Host/NativeRenderer.h"
|
||||
|
||||
@@ -313,10 +313,10 @@ private:
|
||||
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;
|
||||
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";
|
||||
m_lastResult = "命中 status bar background";
|
||||
} else {
|
||||
m_lastResult = "命中 " + DescribeHitTarget(m_hoverTarget);
|
||||
}
|
||||
@@ -330,22 +330,22 @@ private:
|
||||
m_segments[1].tone == UIEditorStatusBarTextTone::Accent
|
||||
? UIEditorStatusBarTextTone::Primary
|
||||
: UIEditorStatusBarTextTone::Accent;
|
||||
m_lastResult = "切换 Selection 文本强调";
|
||||
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";
|
||||
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);
|
||||
m_lastResult = "Selection slot -> " + DescribeSlot(m_segments[1].slot);
|
||||
break;
|
||||
case ActionId::Reset:
|
||||
ResetState();
|
||||
m_lastResult = "状态重置";
|
||||
m_lastResult = "状态已重置";
|
||||
break;
|
||||
case ActionId::Capture:
|
||||
m_autoScreenshot.RequestCapture("manual_button");
|
||||
@@ -368,7 +368,7 @@ private:
|
||||
m_state.focused = true;
|
||||
m_state.activeIndex = 1u;
|
||||
m_hoverTarget = {};
|
||||
m_lastResult = "Ready";
|
||||
m_lastResult = "就绪";
|
||||
}
|
||||
|
||||
void UpdateHover() {
|
||||
@@ -383,11 +383,11 @@ private:
|
||||
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::ToggleAccent, "切换强调", UIRect(left, top, width, buttonHeight), m_segments[1].tone == UIEditorStatusBarTextTone::Accent },
|
||||
{ ActionId::ToggleSeparator, "Leading separator", 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 }
|
||||
{ ActionId::Reset, "重置", UIRect(left, top + (buttonHeight + gap) * 3.0f, width, buttonHeight), false },
|
||||
{ ActionId::Capture, "截图(F12)", UIRect(left, top + (buttonHeight + gap) * 4.0f, width, buttonHeight), false }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -429,25 +429,30 @@ private:
|
||||
DrawCard(
|
||||
drawList,
|
||||
introRect,
|
||||
"测试功能:StatusBar 基础壳层",
|
||||
"重点检查:Leading / Trailing slot 对齐,文本强调,separator 开关,hover / active 命中。");
|
||||
"这个测试验证什么功能?",
|
||||
"验证 StatusBar 的 leading/trailing 布局、separator、强调文本,以及 hover/active 命中。");
|
||||
drawList.AddText(
|
||||
UIPoint(introRect.x + 16.0f, introRect.y + 66.0f),
|
||||
"操作:hover 观察 segment 高亮;点击 segment 切 active;切换左侧按钮检查 slot / separator / emphasis;按 F12 或点“截图”。",
|
||||
"1. hover 不同 segment / separator,检查命中是否正确。",
|
||||
kTextMuted,
|
||||
12.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(introRect.x + 16.0f, introRect.y + 90.0f),
|
||||
"这个场景只验证 Editor 基础层 StatusBar,不混入任何业务面板。",
|
||||
"2. 点击 segment,检查 active 是否切到对应项。",
|
||||
kTextMuted,
|
||||
12.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(introRect.x + 16.0f, introRect.y + 114.0f),
|
||||
"3. 切换强调、separator 和 Selection slot,检查布局是否稳定。",
|
||||
kTextWeak,
|
||||
12.0f);
|
||||
|
||||
DrawCard(drawList, controlsRect, "开关", "只保留和当前 StatusBar contract 直接相关的操作。");
|
||||
DrawCard(drawList, controlsRect, "操作", "只保留与 StatusBar contract 直接相关的开关。");
|
||||
for (const ButtonState& button : m_buttons) {
|
||||
DrawButton(drawList, button);
|
||||
}
|
||||
|
||||
DrawCard(drawList, stateRect, "状态", "命中、active、slot 和结果统一回显在这里。");
|
||||
DrawCard(drawList, stateRect, "状态摘要", "重点看 hover、active、Selection slot、separator 和结果。");
|
||||
drawList.AddText(
|
||||
UIPoint(stateRect.x + 16.0f, stateRect.y + 66.0f),
|
||||
"Hover: " + DescribeHitTarget(m_hoverTarget),
|
||||
@@ -489,12 +494,12 @@ private:
|
||||
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 的对齐和交互。",
|
||||
"这里只放一个宿主区域,用来观察底部 StatusBar 的布局和状态变化。",
|
||||
kTextMuted,
|
||||
12.0f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user