new_editor: fix adaptive tab width semantics

This commit is contained in:
2026-04-22 01:12:46 +08:00
parent ed90911a5c
commit 9760bcb00e
17 changed files with 205 additions and 64 deletions

View File

@@ -112,13 +112,18 @@ bool IsToolWindow(const EditorWindow& window) {
return ::XCEngine::UI::UISize(640.0f, 360.0f);
}
float ResolveDetachedTabWidth(std::string_view text) {
float ResolveDetachedTabWidth(
std::string_view text,
const UIEditorTextMeasurer* textMeasurer) {
const Widgets::UIEditorTabStripMetrics& metrics = ResolveUIEditorTabStripMetrics();
Widgets::UIEditorTabStripItem item = {};
item.title = std::string(text);
const float desiredLabelWidth =
Widgets::ResolveUIEditorTabStripDesiredHeaderLabelWidth(item, metrics);
return MeasureUITabStripHeaderWidth(desiredLabelWidth, metrics.layoutMetrics);
const float measuredLabelWidth =
Widgets::ResolveUIEditorTabStripMeasuredLabelWidth(
item,
metrics,
textMeasurer);
return MeasureUITabStripHeaderWidth(measuredLabelWidth, metrics.layoutMetrics);
}
bool HasSingleVisibleRootTab(const UIEditorWorkspaceController& controller) {
@@ -710,7 +715,9 @@ Host::BorderlessWindowChromeLayout EditorWindowChromeController::ResolveChromeLa
float clientWidthDips) const {
float leadingOccupiedRight = 0.0f;
if (ShouldUseDetachedTitleBarTabStrip(window)) {
leadingOccupiedRight = ResolveDetachedTabWidth(ResolveDetachedTitleTabText(window));
leadingOccupiedRight = ResolveDetachedTabWidth(
ResolveDetachedTitleTabText(window),
&window.m_runtime->GetTextMeasurer());
}
return Host::BuildBorderlessWindowChromeLayout(