new_editor: unify shared UI text measurement semantics
This commit is contained in:
@@ -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 = {});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Foundation/UIEditorTextMeasurement.h>
|
||||
#include <XCEditor/Menu/UIEditorMenuModel.h>
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
@@ -23,8 +24,9 @@ struct UIEditorMenuPopupItem {
|
||||
bool enabled = true;
|
||||
bool checked = false;
|
||||
bool hasSubmenu = false;
|
||||
float desiredLabelWidth = 0.0f;
|
||||
float desiredShortcutWidth = 0.0f;
|
||||
// Pure measured text widths. Row/popup sizing is derived from them locally.
|
||||
float measuredLabelWidth = 0.0f;
|
||||
float measuredShortcutWidth = 0.0f;
|
||||
};
|
||||
|
||||
struct UIEditorMenuPopupState {
|
||||
@@ -91,6 +93,16 @@ struct UIEditorMenuPopupHitTarget {
|
||||
std::size_t index = UIEditorMenuPopupInvalidIndex;
|
||||
};
|
||||
|
||||
float ResolveUIEditorMenuPopupMeasuredLabelWidth(
|
||||
const UIEditorMenuPopupItem& item,
|
||||
const UIEditorMenuPopupMetrics& metrics = {},
|
||||
const UIEditorTextMeasurer* textMeasurer = nullptr);
|
||||
|
||||
float ResolveUIEditorMenuPopupMeasuredShortcutWidth(
|
||||
const UIEditorMenuPopupItem& item,
|
||||
const UIEditorMenuPopupMetrics& metrics = {},
|
||||
const UIEditorTextMeasurer* textMeasurer = nullptr);
|
||||
|
||||
float ResolveUIEditorMenuPopupDesiredWidth(
|
||||
const std::vector<UIEditorMenuPopupItem>& items,
|
||||
const UIEditorMenuPopupMetrics& metrics = {});
|
||||
|
||||
Reference in New Issue
Block a user