fix(new_editor): stabilize inspector add-component layout and project browser scrolling

This commit is contained in:
2026-04-22 23:30:17 +08:00
parent b0d3141eee
commit c10367a42e
3 changed files with 203 additions and 32 deletions

View File

@@ -100,18 +100,29 @@ Widgets::UIEditorPropertyGridLayout TranslatePropertyGridLayoutForScroll(
return translated;
}
float ResolvePropertyGridContentBottom(
const Widgets::UIEditorPropertyGridLayout& gridLayout,
const UIRect& contentBounds) {
float contentBottom = contentBounds.y;
if (!gridLayout.sectionHeaderRects.empty()) {
const UIRect& lastSectionRect = gridLayout.sectionHeaderRects.back();
contentBottom =
(std::max)(contentBottom, lastSectionRect.y + lastSectionRect.height);
}
if (!gridLayout.fieldRowRects.empty()) {
const UIRect& lastFieldRect = gridLayout.fieldRowRects.back();
contentBottom =
(std::max)(contentBottom, lastFieldRect.y + lastFieldRect.height);
}
return contentBottom;
}
float ResolveAddComponentButtonTop(
const Widgets::UIEditorPropertyGridLayout& gridLayout,
const UIRect& contentBounds) {
if (!gridLayout.fieldRowRects.empty()) {
const UIRect& lastFieldRect = gridLayout.fieldRowRects.back();
return lastFieldRect.y + lastFieldRect.height + kAddComponentButtonTopGap;
}
if (!gridLayout.sectionHeaderRects.empty()) {
const UIRect& lastSectionRect = gridLayout.sectionHeaderRects.back();
return lastSectionRect.y + lastSectionRect.height + kAddComponentButtonTopGap;
}
return contentBounds.y;
return ResolvePropertyGridContentBottom(gridLayout, contentBounds) +
kAddComponentButtonTopGap;
}
Widgets::UIEditorScrollViewPalette BuildInspectorScrollPalette() {
@@ -342,13 +353,7 @@ float InspectorPanel::MeasureScrollableContentHeight(
m_presentation.sections,
m_sectionExpansion,
::XCEngine::UI::Editor::GetUIEditorFixedPropertyGridMetrics());
if (!layout.fieldRowRects.empty()) {
const UIRect& lastFieldRect = layout.fieldRowRects.back();
contentBottom = lastFieldRect.y + lastFieldRect.height;
} else if (!layout.sectionHeaderRects.empty()) {
const UIRect& lastSectionRect = layout.sectionHeaderRects.back();
contentBottom = lastSectionRect.y + lastSectionRect.height;
}
contentBottom = ResolvePropertyGridContentBottom(layout, contentBounds);
}
if (ShouldShowAddComponentButton()) {