Refactor new_editor window architecture and routing

This commit is contained in:
2026-04-23 14:11:33 +08:00
parent 5c0a878aa0
commit af5690395d
121 changed files with 1647 additions and 1592 deletions

View File

@@ -651,6 +651,44 @@ float D3D12UiTextSystem::MeasureTextWidth(
return std::ceil(width * dpiScale) / dpiScale;
}
float D3D12UiTextSystem::MeasureTextAdvance(
const ::XCEngine::UI::Editor::UIEditorTextMeasureRequest& request) const {
if (!m_dwriteFactory || request.text.empty()) {
return 0.0f;
}
const std::wstring text = Utf8ToWide(request.text);
if (text.empty()) {
return 0.0f;
}
const float dpiScale = ClampDpiScale(m_dpiScale);
const float resolvedFontSize = ResolveDisplayFontSize(request.fontSize);
IDWriteTextFormat* textFormat = GetTextFormat(resolvedFontSize);
if (textFormat == nullptr) {
return 0.0f;
}
Microsoft::WRL::ComPtr<IDWriteTextLayout> textLayout = {};
const HRESULT hr = m_dwriteFactory->CreateTextLayout(
text.c_str(),
static_cast<UINT32>(text.size()),
textFormat,
4096.0f,
resolvedFontSize * 2.0f,
textLayout.ReleaseAndGetAddressOf());
if (FAILED(hr) || textLayout == nullptr) {
return 0.0f;
}
DWRITE_TEXT_METRICS textMetrics = {};
if (FAILED(textLayout->GetMetrics(&textMetrics))) {
return 0.0f;
}
return std::ceil(textMetrics.widthIncludingTrailingWhitespace * dpiScale) / dpiScale;
}
bool D3D12UiTextSystem::RasterizeTextMask(
std::string_view text,
float fontSize,