Refactor new_editor window architecture and routing
This commit is contained in:
@@ -26,6 +26,16 @@ inline float ResolveUIEditorTextTop(
|
||||
return centeredTop - 1.0f + offsetY;
|
||||
}
|
||||
|
||||
inline float ResolveUIEditorControlTextTop(
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
float fontSize,
|
||||
float offsetY = 0.0f) {
|
||||
const float textHeight = MeasureUIEditorTextLayoutHeight(fontSize);
|
||||
const float centeredTop =
|
||||
rect.y + (std::max)(0.0f, std::floor((rect.height - textHeight) * 0.5f));
|
||||
return centeredTop + offsetY;
|
||||
}
|
||||
|
||||
inline ::XCEngine::UI::UIRect ResolveUIEditorTextClipRect(
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
float fontSize) {
|
||||
@@ -64,7 +74,7 @@ inline float MeasureUIEditorTextWidthToCaret(
|
||||
if (textMeasurer != nullptr &&
|
||||
clampedCaretOffset > 0u &&
|
||||
fontSize > 0.0f) {
|
||||
return textMeasurer->MeasureTextWidth(
|
||||
return textMeasurer->MeasureTextAdvance(
|
||||
::XCEngine::UI::Editor::UIEditorTextMeasureRequest{
|
||||
std::string_view(text.data(), clampedCaretOffset),
|
||||
fontSize
|
||||
@@ -132,7 +142,7 @@ inline void AppendUIEditorTextCaret(
|
||||
caretOffset,
|
||||
fontSize,
|
||||
textMeasurer));
|
||||
const float top = ResolveUIEditorTextTop(rect, fontSize, insetY);
|
||||
const float top = ResolveUIEditorControlTextTop(rect, fontSize, insetY);
|
||||
const float bottom = top + MeasureUIEditorTextLayoutHeight(fontSize);
|
||||
drawList.AddLine(
|
||||
::XCEngine::UI::UIPoint(caretX, top),
|
||||
|
||||
Reference in New Issue
Block a user