ui: add typed editor field foundations
This commit is contained in:
@@ -12,9 +12,6 @@ using ::XCEngine::UI::UIPoint;
|
||||
using ::XCEngine::UI::UIRect;
|
||||
using ::XCEngine::UI::Editor::UIEditorMenuItemKind;
|
||||
|
||||
constexpr float kPopupFontSize = 13.0f;
|
||||
constexpr float kGlyphFontSize = 12.0f;
|
||||
|
||||
float ClampNonNegative(float value) {
|
||||
return (std::max)(value, 0.0f);
|
||||
}
|
||||
@@ -39,11 +36,11 @@ bool IsInteractiveItem(const UIEditorMenuPopupItem& item) {
|
||||
}
|
||||
|
||||
float ResolveRowTextTop(const UIRect& rect, const UIEditorMenuPopupMetrics& metrics) {
|
||||
return rect.y + (std::max)(0.0f, (rect.height - kPopupFontSize) * 0.5f) + metrics.labelInsetY;
|
||||
return rect.y + (std::max)(0.0f, (rect.height - metrics.labelFontSize) * 0.5f) + metrics.labelInsetY;
|
||||
}
|
||||
|
||||
float ResolveGlyphTop(const UIRect& rect) {
|
||||
return rect.y + (std::max)(0.0f, (rect.height - kGlyphFontSize) * 0.5f) - 0.5f;
|
||||
float ResolveGlyphTop(const UIRect& rect, const UIEditorMenuPopupMetrics& metrics) {
|
||||
return rect.y + (std::max)(0.0f, (rect.height - metrics.glyphFontSize) * 0.5f) - 0.5f;
|
||||
}
|
||||
|
||||
bool IsHighlighted(const UIEditorMenuPopupState& state, std::size_t index) {
|
||||
@@ -209,10 +206,10 @@ void AppendUIEditorMenuPopupForeground(
|
||||
const float checkLeft = rect.x + 6.0f;
|
||||
if (item.checked) {
|
||||
drawList.AddText(
|
||||
UIPoint(checkLeft, ResolveGlyphTop(rect)),
|
||||
UIPoint(checkLeft, ResolveGlyphTop(rect, metrics)),
|
||||
"*",
|
||||
palette.glyphColor,
|
||||
kGlyphFontSize);
|
||||
metrics.glyphFontSize);
|
||||
}
|
||||
|
||||
const float labelLeft =
|
||||
@@ -241,7 +238,7 @@ void AppendUIEditorMenuPopupForeground(
|
||||
UIPoint(labelLeft, ResolveRowTextTop(rect, metrics)),
|
||||
item.label,
|
||||
mainColor,
|
||||
kPopupFontSize);
|
||||
metrics.labelFontSize);
|
||||
drawList.PopClipRect();
|
||||
|
||||
if (!item.shortcutText.empty()) {
|
||||
@@ -258,17 +255,17 @@ void AppendUIEditorMenuPopupForeground(
|
||||
UIPoint(shortcutLeft, ResolveRowTextTop(rect, metrics)),
|
||||
item.shortcutText,
|
||||
secondaryColor,
|
||||
kPopupFontSize);
|
||||
metrics.labelFontSize);
|
||||
}
|
||||
|
||||
if (item.hasSubmenu) {
|
||||
drawList.AddText(
|
||||
UIPoint(
|
||||
rect.x + rect.width - ClampNonNegative(metrics.shortcutInsetRight),
|
||||
ResolveGlyphTop(rect)),
|
||||
ResolveGlyphTop(rect, metrics)),
|
||||
">",
|
||||
palette.glyphColor,
|
||||
kGlyphFontSize);
|
||||
metrics.glyphFontSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user