new_editor: unify shared UI text measurement semantics

This commit is contained in:
2026-04-22 01:50:00 +08:00
parent 26e75e093e
commit 0ec0eff90c
16 changed files with 284 additions and 86 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include <XCEditor/Foundation/UIEditorTextMeasurement.h>
#include <XCEditor/Viewport/UIEditorViewportInputBridge.h>
#include <XCEditor/Viewport/UIEditorViewportSlot.h>
@@ -42,6 +43,11 @@ struct UIEditorViewportShellFrame {
::XCEngine::UI::UISize requestedViewportSize = {};
};
UIEditorViewportShellModel ResolveUIEditorViewportShellMeasuredModel(
const UIEditorViewportShellModel& model,
const Widgets::UIEditorViewportSlotMetrics& metrics = {},
const UIEditorTextMeasurer* textMeasurer = nullptr);
UIEditorViewportShellRequest ResolveUIEditorViewportShellRequest(
const ::XCEngine::UI::UIRect& bounds,
const UIEditorViewportShellSpec& spec,

View File

@@ -53,7 +53,8 @@ struct UIEditorViewportSlotToolItem {
UIEditorViewportSlotToolSlot slot = UIEditorViewportSlotToolSlot::Trailing;
bool enabled = true;
bool selected = false;
float desiredWidth = 0.0f;
// Pure measured tool-label width. Tool button padding is applied only in layout.
float measuredLabelWidth = 0.0f;
};
struct UIEditorViewportSlotState {
@@ -75,13 +76,18 @@ struct UIEditorViewportSlotMetrics {
float toolPaddingX = 8.0f;
float toolGap = 4.0f;
float toolCornerRounding = 2.0f;
float toolLabelFontSize = 11.0f;
float toolLabelInsetY = 3.0f;
float titleGap = 6.0f;
float titleFontSize = 13.0f;
float titleInsetY = 5.0f;
float subtitleFontSize = 10.0f;
float subtitleInsetY = 14.0f;
float estimatedGlyphWidth = 6.5f;
float surfaceInset = 0.0f;
float surfaceBorderThickness = 1.0f;
float focusedSurfaceBorderThickness = 1.0f;
UIEditorStatusBarMetrics statusBarMetrics = {};
};
struct UIEditorViewportSlotPalette {
@@ -157,6 +163,11 @@ struct UIEditorViewportSlotForegroundAppendOptions {
bool includeSurfaceTexture = true;
};
float ResolveUIEditorViewportSlotMeasuredToolLabelWidth(
const UIEditorViewportSlotToolItem& item,
const UIEditorViewportSlotMetrics& metrics = {},
const UIEditorTextMeasurer* textMeasurer = nullptr);
float ResolveUIEditorViewportSlotDesiredToolWidth(
const UIEditorViewportSlotToolItem& item,
const UIEditorViewportSlotMetrics& metrics = {});