Refine editor tree alignment and project panel events

This commit is contained in:
2026-04-11 22:31:14 +08:00
parent 8848cfd958
commit 0ff02150c0
6 changed files with 219 additions and 35 deletions

View File

@@ -27,9 +27,12 @@ float ResolveTreeViewRowHeight(
return item.desiredHeight > 0.0f ? item.desiredHeight : metrics.rowHeight;
}
float ResolveTextTop(const ::XCEngine::UI::UIRect& rect, float fontSize) {
float ResolveTextTop(
const ::XCEngine::UI::UIRect& rect,
float fontSize,
float insetY) {
const float lineHeight = fontSize * 1.6f;
return rect.y + std::floor((rect.height - lineHeight) * 0.5f);
return rect.y + std::floor((rect.height - lineHeight) * 0.5f) + insetY;
}
void AppendDisclosureArrow(
@@ -217,7 +220,7 @@ UIEditorTreeViewLayout BuildUIEditorTreeViewLayout(
const float contentStartX = disclosureRect.x + metrics.disclosureExtent + metrics.disclosureLabelGap;
const ::XCEngine::UI::UIRect iconRect(
hasLeadingIcon ? contentStartX : 0.0f,
rowRect.y + (rowRect.height - iconExtent) * 0.5f,
rowRect.y + (rowRect.height - iconExtent) * 0.5f + metrics.iconInsetY,
hasLeadingIcon ? iconExtent : 0.0f,
hasLeadingIcon ? iconExtent : 0.0f);
const float labelStartX =
@@ -322,7 +325,7 @@ void AppendUIEditorTreeViewForeground(
drawList.AddText(
::XCEngine::UI::UIPoint(
layout.labelRects[visibleOffset].x,
ResolveTextTop(layout.labelRects[visibleOffset], kTreeFontSize)),
ResolveTextTop(layout.labelRects[visibleOffset], kTreeFontSize, metrics.labelInsetY)),
item.label,
palette.textColor,
kTreeFontSize);