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,7 @@
#pragma once
#include <XCEditor/Foundation/UIEditorTextMeasurement.h>
#include <XCEngine/UI/DrawData.h>
#include <cstddef>
@@ -16,7 +18,8 @@ struct UIEditorMenuBarItem {
std::string menuId = {};
std::string label = {};
bool enabled = true;
float desiredLabelWidth = 0.0f;
// Pure measured label width. Button padding is applied only in layout.
float measuredLabelWidth = 0.0f;
};
struct UIEditorMenuBarState {
@@ -81,6 +84,11 @@ struct UIEditorMenuBarHitTarget {
std::size_t index = UIEditorMenuBarInvalidIndex;
};
float ResolveUIEditorMenuBarMeasuredLabelWidth(
const UIEditorMenuBarItem& item,
const UIEditorMenuBarMetrics& metrics = {},
const UIEditorTextMeasurer* textMeasurer = nullptr);
float ResolveUIEditorMenuBarDesiredButtonWidth(
const UIEditorMenuBarItem& item,
const UIEditorMenuBarMetrics& metrics = {});