feat(new_editor): add project panel and polish dock chrome
This commit is contained in:
@@ -88,20 +88,6 @@ float ResolveTabTextLeft(
|
||||
return availableLeft + (std::max)(0.0f, (availableWidth - labelWidth) * 0.5f);
|
||||
}
|
||||
|
||||
UIColor ResolveStripBorderColor(
|
||||
const UIEditorTabStripState& state,
|
||||
const UIEditorTabStripPalette& palette) {
|
||||
(void)state;
|
||||
return palette.stripBorderColor;
|
||||
}
|
||||
|
||||
float ResolveStripBorderThickness(
|
||||
const UIEditorTabStripState& state,
|
||||
const UIEditorTabStripMetrics& metrics) {
|
||||
(void)state;
|
||||
return metrics.baseBorderThickness;
|
||||
}
|
||||
|
||||
UIColor ResolveTabFillColor(
|
||||
bool selected,
|
||||
bool hovered,
|
||||
@@ -359,11 +345,6 @@ void AppendUIEditorTabStripBackground(
|
||||
if (layout.headerRect.height > 0.0f) {
|
||||
drawList.AddFilledRect(layout.headerRect, palette.headerBackgroundColor, stripRounding);
|
||||
}
|
||||
drawList.AddRectOutline(
|
||||
layout.bounds,
|
||||
ResolveStripBorderColor(state, palette),
|
||||
ResolveStripBorderThickness(state, metrics),
|
||||
stripRounding);
|
||||
|
||||
for (std::size_t index = 0; index < layout.tabHeaderRects.size(); ++index) {
|
||||
const bool selected = layout.selectedIndex == index;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <XCEngine/UI/Widgets/UIFlatHierarchyHelpers.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <numeric>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
@@ -19,16 +20,42 @@ std::vector<std::size_t> BuildItemOffsets(std::size_t count) {
|
||||
return offsets;
|
||||
}
|
||||
|
||||
constexpr float kTreeFontSize = 12.0f;
|
||||
float ResolveTreeViewRowHeight(
|
||||
const UIEditorTreeViewItem& item,
|
||||
const UIEditorTreeViewMetrics& metrics) {
|
||||
return item.desiredHeight > 0.0f ? item.desiredHeight : metrics.rowHeight;
|
||||
}
|
||||
|
||||
::XCEngine::UI::UIPoint ResolveDisclosureGlyphPosition(
|
||||
float ResolveTextTop(const ::XCEngine::UI::UIRect& rect, float fontSize) {
|
||||
const float lineHeight = fontSize * 1.6f;
|
||||
return rect.y + std::floor((rect.height - lineHeight) * 0.5f);
|
||||
}
|
||||
|
||||
void AppendDisclosureArrow(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
float insetY) {
|
||||
return ::XCEngine::UI::UIPoint(rect.x + 2.0f, rect.y + insetY - 1.0f);
|
||||
bool expanded,
|
||||
const ::XCEngine::UI::UIColor& color) {
|
||||
constexpr float kOpticalCenterYOffset = -0.5f;
|
||||
const float centerX = std::floor(rect.x + rect.width * 0.5f) + 0.5f;
|
||||
const float centerY =
|
||||
std::floor(rect.y + rect.height * 0.5f + kOpticalCenterYOffset) + 0.5f;
|
||||
const float halfExtent = (std::max)(2.5f, std::floor((std::min)(rect.width, rect.height) * 0.24f));
|
||||
const float triangleHeight = halfExtent * 1.55f;
|
||||
|
||||
::XCEngine::UI::UIPoint points[3] = {};
|
||||
if (expanded) {
|
||||
points[0] = ::XCEngine::UI::UIPoint(centerX - halfExtent, centerY - triangleHeight * 0.5f);
|
||||
points[1] = ::XCEngine::UI::UIPoint(centerX + halfExtent, centerY - triangleHeight * 0.5f);
|
||||
points[2] = ::XCEngine::UI::UIPoint(centerX, centerY + triangleHeight * 0.5f);
|
||||
} else {
|
||||
points[0] = ::XCEngine::UI::UIPoint(centerX - triangleHeight * 0.5f, centerY - halfExtent);
|
||||
points[1] = ::XCEngine::UI::UIPoint(centerX - triangleHeight * 0.5f, centerY + halfExtent);
|
||||
points[2] = ::XCEngine::UI::UIPoint(centerX + triangleHeight * 0.5f, centerY);
|
||||
}
|
||||
|
||||
drawList.AddFilledTriangle(points[0], points[1], points[2], color);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -267,23 +294,21 @@ void AppendUIEditorTreeViewForeground(
|
||||
for (std::size_t visibleOffset = 0u; visibleOffset < layout.rowRects.size(); ++visibleOffset) {
|
||||
const UIEditorTreeViewItem& item = items[layout.visibleItemIndices[visibleOffset]];
|
||||
if (layout.itemHasChildren[visibleOffset]) {
|
||||
drawList.AddText(
|
||||
ResolveDisclosureGlyphPosition(
|
||||
layout.disclosureRects[visibleOffset],
|
||||
metrics.labelInsetY),
|
||||
layout.itemExpanded[visibleOffset] ? "v" : ">",
|
||||
palette.disclosureColor,
|
||||
12.0f);
|
||||
AppendDisclosureArrow(
|
||||
drawList,
|
||||
layout.disclosureRects[visibleOffset],
|
||||
layout.itemExpanded[visibleOffset],
|
||||
palette.disclosureColor);
|
||||
}
|
||||
|
||||
drawList.PushClipRect(layout.labelRects[visibleOffset]);
|
||||
drawList.AddText(
|
||||
::XCEngine::UI::UIPoint(
|
||||
layout.labelRects[visibleOffset].x,
|
||||
layout.labelRects[visibleOffset].y + metrics.labelInsetY),
|
||||
ResolveTextTop(layout.labelRects[visibleOffset], kTreeFontSize)),
|
||||
item.label,
|
||||
palette.textColor,
|
||||
12.0f);
|
||||
kTreeFontSize);
|
||||
drawList.PopClipRect();
|
||||
}
|
||||
drawList.PopClipRect();
|
||||
|
||||
Reference in New Issue
Block a user