Build XCEditor dock host workspace shell compose
This commit is contained in:
@@ -24,6 +24,7 @@ add_library(XCUIEditorLib STATIC
|
||||
src/Core/UIEditorWorkspaceModel.cpp
|
||||
src/Core/UIEditorWorkspaceSession.cpp
|
||||
src/Widgets/UIEditorCollectionPrimitives.cpp
|
||||
src/Widgets/UIEditorDockHost.cpp
|
||||
src/Widgets/UIEditorPanelFrame.cpp
|
||||
src/Widgets/UIEditorTabStrip.cpp
|
||||
)
|
||||
|
||||
@@ -100,6 +100,10 @@ bool ContainsUIEditorWorkspacePanel(
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
std::string_view panelId);
|
||||
|
||||
const UIEditorWorkspaceNode* FindUIEditorWorkspaceNode(
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
std::string_view nodeId);
|
||||
|
||||
bool AreUIEditorWorkspaceNodesEquivalent(
|
||||
const UIEditorWorkspaceNode& lhs,
|
||||
const UIEditorWorkspaceNode& rhs);
|
||||
@@ -115,4 +119,9 @@ bool TryActivateUIEditorWorkspacePanel(
|
||||
UIEditorWorkspaceModel& workspace,
|
||||
std::string_view panelId);
|
||||
|
||||
bool TrySetUIEditorWorkspaceSplitRatio(
|
||||
UIEditorWorkspaceModel& workspace,
|
||||
std::string_view nodeId,
|
||||
float splitRatio);
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
|
||||
158
new_editor/include/XCEditor/Widgets/UIEditorDockHost.h
Normal file
158
new_editor/include/XCEditor/Widgets/UIEditorDockHost.h
Normal file
@@ -0,0 +1,158 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Core/UIEditorPanelRegistry.h>
|
||||
#include <XCEditor/Core/UIEditorWorkspaceModel.h>
|
||||
#include <XCEditor/Core/UIEditorWorkspaceSession.h>
|
||||
#include <XCEditor/Widgets/UIEditorPanelFrame.h>
|
||||
#include <XCEditor/Widgets/UIEditorTabStrip.h>
|
||||
|
||||
#include <XCEngine/UI/Layout/UISplitterLayout.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
enum class UIEditorDockHostHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
SplitterHandle,
|
||||
TabStripBackground,
|
||||
Tab,
|
||||
TabCloseButton,
|
||||
PanelHeader,
|
||||
PanelBody,
|
||||
PanelFooter,
|
||||
PanelCloseButton
|
||||
};
|
||||
|
||||
struct UIEditorDockHostHitTarget {
|
||||
UIEditorDockHostHitTargetKind kind = UIEditorDockHostHitTargetKind::None;
|
||||
std::string nodeId = {};
|
||||
std::string panelId = {};
|
||||
std::size_t index = UIEditorTabStripInvalidIndex;
|
||||
};
|
||||
|
||||
struct UIEditorDockHostState {
|
||||
bool focused = false;
|
||||
UIEditorDockHostHitTarget hoveredTarget = {};
|
||||
std::string activeSplitterNodeId = {};
|
||||
};
|
||||
|
||||
struct UIEditorDockHostMetrics {
|
||||
::XCEngine::UI::Layout::UISplitterMetrics splitterMetrics =
|
||||
::XCEngine::UI::Layout::UISplitterMetrics{ 10.0f, 18.0f };
|
||||
UIEditorTabStripMetrics tabStripMetrics = {};
|
||||
UIEditorPanelFrameMetrics panelFrameMetrics = {};
|
||||
::XCEngine::UI::UISize minimumStandalonePanelBodySize =
|
||||
::XCEngine::UI::UISize(180.0f, 140.0f);
|
||||
::XCEngine::UI::UISize minimumTabContentBodySize =
|
||||
::XCEngine::UI::UISize(260.0f, 180.0f);
|
||||
float splitterHandleRounding = 4.0f;
|
||||
float placeholderLineGap = 22.0f;
|
||||
};
|
||||
|
||||
struct UIEditorDockHostPalette {
|
||||
UIEditorTabStripPalette tabStripPalette = {};
|
||||
UIEditorPanelFramePalette panelFramePalette = {};
|
||||
::XCEngine::UI::UIColor splitterColor =
|
||||
::XCEngine::UI::UIColor(0.26f, 0.26f, 0.26f, 1.0f);
|
||||
::XCEngine::UI::UIColor splitterHoveredColor =
|
||||
::XCEngine::UI::UIColor(0.36f, 0.36f, 0.36f, 1.0f);
|
||||
::XCEngine::UI::UIColor splitterActiveColor =
|
||||
::XCEngine::UI::UIColor(0.86f, 0.86f, 0.86f, 1.0f);
|
||||
::XCEngine::UI::UIColor placeholderTitleColor =
|
||||
::XCEngine::UI::UIColor(0.94f, 0.94f, 0.94f, 1.0f);
|
||||
::XCEngine::UI::UIColor placeholderTextColor =
|
||||
::XCEngine::UI::UIColor(0.72f, 0.72f, 0.72f, 1.0f);
|
||||
::XCEngine::UI::UIColor placeholderMutedColor =
|
||||
::XCEngine::UI::UIColor(0.58f, 0.58f, 0.58f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorDockHostTabItemLayout {
|
||||
std::string panelId = {};
|
||||
std::string title = {};
|
||||
bool closable = true;
|
||||
bool active = false;
|
||||
};
|
||||
|
||||
struct UIEditorDockHostSplitterLayout {
|
||||
std::string nodeId = {};
|
||||
UIEditorWorkspaceSplitAxis axis = UIEditorWorkspaceSplitAxis::Horizontal;
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect handleHitRect = {};
|
||||
::XCEngine::UI::Layout::UISplitterConstraints constraints = {};
|
||||
::XCEngine::UI::Layout::UISplitterMetrics metrics = {};
|
||||
::XCEngine::UI::Layout::UISplitterLayoutResult splitterLayout = {};
|
||||
bool hovered = false;
|
||||
bool active = false;
|
||||
};
|
||||
|
||||
struct UIEditorDockHostPanelLayout {
|
||||
std::string nodeId = {};
|
||||
std::string panelId = {};
|
||||
std::string title = {};
|
||||
bool active = false;
|
||||
UIEditorPanelFrameState frameState = {};
|
||||
UIEditorPanelFrameLayout frameLayout = {};
|
||||
};
|
||||
|
||||
struct UIEditorDockHostTabStackLayout {
|
||||
std::string nodeId = {};
|
||||
std::string selectedPanelId = {};
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
std::vector<UIEditorDockHostTabItemLayout> items = {};
|
||||
UIEditorTabStripState tabStripState = {};
|
||||
UIEditorTabStripLayout tabStripLayout = {};
|
||||
UIEditorPanelFrameState contentFrameState = {};
|
||||
UIEditorPanelFrameLayout contentFrameLayout = {};
|
||||
};
|
||||
|
||||
struct UIEditorDockHostLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
std::vector<UIEditorDockHostSplitterLayout> splitters = {};
|
||||
std::vector<UIEditorDockHostPanelLayout> panels = {};
|
||||
std::vector<UIEditorDockHostTabStackLayout> tabStacks = {};
|
||||
};
|
||||
|
||||
const UIEditorDockHostSplitterLayout* FindUIEditorDockHostSplitterLayout(
|
||||
const UIEditorDockHostLayout& layout,
|
||||
std::string_view nodeId);
|
||||
|
||||
UIEditorDockHostLayout BuildUIEditorDockHostLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostState& state = {},
|
||||
const UIEditorDockHostMetrics& metrics = {});
|
||||
|
||||
UIEditorDockHostHitTarget HitTestUIEditorDockHost(
|
||||
const UIEditorDockHostLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorDockHostBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorDockHostLayout& layout,
|
||||
const UIEditorDockHostPalette& palette = {},
|
||||
const UIEditorDockHostMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorDockHostForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorDockHostLayout& layout,
|
||||
const UIEditorDockHostPalette& palette = {},
|
||||
const UIEditorDockHostMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorDockHost(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostState& state = {},
|
||||
const UIEditorDockHostPalette& palette = {},
|
||||
const UIEditorDockHostMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -50,6 +50,38 @@ const UIEditorWorkspacePanelState* FindPanelRecursive(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const UIEditorWorkspaceNode* FindNodeRecursive(
|
||||
const UIEditorWorkspaceNode& node,
|
||||
std::string_view nodeId) {
|
||||
if (node.nodeId == nodeId) {
|
||||
return &node;
|
||||
}
|
||||
|
||||
for (const UIEditorWorkspaceNode& child : node.children) {
|
||||
if (const UIEditorWorkspaceNode* found = FindNodeRecursive(child, nodeId)) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UIEditorWorkspaceNode* FindMutableNodeRecursive(
|
||||
UIEditorWorkspaceNode& node,
|
||||
std::string_view nodeId) {
|
||||
if (node.nodeId == nodeId) {
|
||||
return &node;
|
||||
}
|
||||
|
||||
for (UIEditorWorkspaceNode& child : node.children) {
|
||||
if (UIEditorWorkspaceNode* found = FindMutableNodeRecursive(child, nodeId)) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool TryActivateRecursive(
|
||||
UIEditorWorkspaceNode& node,
|
||||
std::string_view panelId) {
|
||||
@@ -326,6 +358,12 @@ bool ContainsUIEditorWorkspacePanel(
|
||||
return FindPanelRecursive(workspace.root, panelId) != nullptr;
|
||||
}
|
||||
|
||||
const UIEditorWorkspaceNode* FindUIEditorWorkspaceNode(
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
std::string_view nodeId) {
|
||||
return FindNodeRecursive(workspace.root, nodeId);
|
||||
}
|
||||
|
||||
const UIEditorWorkspacePanelState* FindUIEditorWorkspaceActivePanel(
|
||||
const UIEditorWorkspaceModel& workspace) {
|
||||
if (workspace.activePanelId.empty()) {
|
||||
@@ -354,4 +392,25 @@ bool TryActivateUIEditorWorkspacePanel(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TrySetUIEditorWorkspaceSplitRatio(
|
||||
UIEditorWorkspaceModel& workspace,
|
||||
std::string_view nodeId,
|
||||
float splitRatio) {
|
||||
if (!IsValidSplitRatio(splitRatio)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UIEditorWorkspaceNode* node = FindMutableNodeRecursive(workspace.root, nodeId);
|
||||
if (node == nullptr || node->kind != UIEditorWorkspaceNodeKind::Split) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (std::fabs(node->splitRatio - splitRatio) <= 0.0001f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
node->splitRatio = splitRatio;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
|
||||
830
new_editor/src/Widgets/UIEditorDockHost.cpp
Normal file
830
new_editor/src/Widgets/UIEditorDockHost.cpp
Normal file
@@ -0,0 +1,830 @@
|
||||
#include <XCEditor/Widgets/UIEditorDockHost.h>
|
||||
|
||||
#include <XCEngine/UI/Widgets/UISplitterInteraction.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
namespace {
|
||||
|
||||
using ::XCEngine::UI::UIColor;
|
||||
using ::XCEngine::UI::UIDrawList;
|
||||
using ::XCEngine::UI::UIPoint;
|
||||
using ::XCEngine::UI::UIRect;
|
||||
using ::XCEngine::UI::UISize;
|
||||
using ::XCEngine::UI::Layout::ArrangeUISplitter;
|
||||
using ::XCEngine::UI::Layout::MeasureSplitterDesiredSize;
|
||||
using ::XCEngine::UI::Layout::MeasureUITabStrip;
|
||||
using ::XCEngine::UI::Layout::UITabStripMeasureItem;
|
||||
using ::XCEngine::UI::Layout::UILayoutAxis;
|
||||
using ::XCEngine::UI::Widgets::ExpandUISplitterHandleHitRect;
|
||||
|
||||
struct DockMeasureResult {
|
||||
bool visible = false;
|
||||
UISize minimumSize = {};
|
||||
};
|
||||
|
||||
float ClampNonNegative(float value) {
|
||||
return (std::max)(value, 0.0f);
|
||||
}
|
||||
|
||||
UILayoutAxis ToLayoutAxis(UIEditorWorkspaceSplitAxis axis) {
|
||||
return axis == UIEditorWorkspaceSplitAxis::Horizontal
|
||||
? UILayoutAxis::Horizontal
|
||||
: UILayoutAxis::Vertical;
|
||||
}
|
||||
|
||||
float GetMainExtent(const UISize& size, UIEditorWorkspaceSplitAxis axis) {
|
||||
return axis == UIEditorWorkspaceSplitAxis::Horizontal ? size.width : size.height;
|
||||
}
|
||||
|
||||
bool IsPointInsideRect(
|
||||
const UIRect& rect,
|
||||
const UIPoint& point) {
|
||||
return point.x >= rect.x &&
|
||||
point.x <= rect.x + rect.width &&
|
||||
point.y >= rect.y &&
|
||||
point.y <= rect.y + rect.height;
|
||||
}
|
||||
|
||||
bool IsPanelOpenAndVisible(
|
||||
const UIEditorWorkspaceSession& session,
|
||||
std::string_view panelId) {
|
||||
const UIEditorPanelSessionState* panelState =
|
||||
FindUIEditorPanelSessionState(session, panelId);
|
||||
return panelState != nullptr && panelState->open && panelState->visible;
|
||||
}
|
||||
|
||||
const UIEditorPanelDescriptor* FindPanelDescriptor(
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
std::string_view panelId) {
|
||||
return FindUIEditorPanelDescriptor(panelRegistry, panelId);
|
||||
}
|
||||
|
||||
UIEditorPanelFrameMetrics BuildTabContentFrameMetrics(
|
||||
const UIEditorDockHostMetrics& metrics) {
|
||||
UIEditorPanelFrameMetrics frameMetrics = metrics.panelFrameMetrics;
|
||||
frameMetrics.headerHeight = 0.0f;
|
||||
frameMetrics.footerHeight = 0.0f;
|
||||
frameMetrics.actionButtonExtent = 0.0f;
|
||||
frameMetrics.actionInsetX = 0.0f;
|
||||
frameMetrics.actionGap = 0.0f;
|
||||
return frameMetrics;
|
||||
}
|
||||
|
||||
UISize MeasurePanelMinimumSize(
|
||||
const UIEditorDockHostMetrics& metrics) {
|
||||
const UIEditorPanelFrameMetrics& frameMetrics = metrics.panelFrameMetrics;
|
||||
return UISize(
|
||||
metrics.minimumStandalonePanelBodySize.width +
|
||||
ClampNonNegative(frameMetrics.contentPadding) * 2.0f,
|
||||
ClampNonNegative(frameMetrics.headerHeight) +
|
||||
metrics.minimumStandalonePanelBodySize.height +
|
||||
ClampNonNegative(frameMetrics.contentPadding) * 2.0f);
|
||||
}
|
||||
|
||||
UISize MeasureTabContentMinimumSize(
|
||||
const UIEditorDockHostMetrics& metrics) {
|
||||
const UIEditorPanelFrameMetrics frameMetrics = BuildTabContentFrameMetrics(metrics);
|
||||
return UISize(
|
||||
metrics.minimumTabContentBodySize.width +
|
||||
ClampNonNegative(frameMetrics.contentPadding) * 2.0f,
|
||||
metrics.minimumTabContentBodySize.height +
|
||||
ClampNonNegative(frameMetrics.contentPadding) * 2.0f);
|
||||
}
|
||||
|
||||
DockMeasureResult MeasureNodeRecursive(
|
||||
const UIEditorWorkspaceNode& node,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostMetrics& metrics);
|
||||
|
||||
DockMeasureResult MeasureTabStackNode(
|
||||
const UIEditorWorkspaceNode& node,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostMetrics& metrics) {
|
||||
std::vector<UITabStripMeasureItem> measureItems = {};
|
||||
for (const UIEditorWorkspaceNode& child : node.children) {
|
||||
if (child.kind != UIEditorWorkspaceNodeKind::Panel ||
|
||||
!IsPanelOpenAndVisible(session, child.panel.panelId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UIEditorTabStripItem item = {};
|
||||
item.tabId = child.panel.panelId;
|
||||
item.title = child.panel.title;
|
||||
const UIEditorPanelDescriptor* descriptor =
|
||||
FindPanelDescriptor(panelRegistry, child.panel.panelId);
|
||||
item.closable = descriptor != nullptr ? descriptor->canClose : true;
|
||||
|
||||
UITabStripMeasureItem measureItem = {};
|
||||
measureItem.desiredHeaderLabelWidth =
|
||||
ResolveUIEditorTabStripDesiredHeaderLabelWidth(item, metrics.tabStripMetrics);
|
||||
measureItem.desiredContentSize = MeasureTabContentMinimumSize(metrics);
|
||||
measureItem.minimumContentSize = MeasureTabContentMinimumSize(metrics);
|
||||
measureItems.push_back(std::move(measureItem));
|
||||
}
|
||||
|
||||
if (measureItems.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto measured = MeasureUITabStrip(measureItems, metrics.tabStripMetrics.layoutMetrics);
|
||||
DockMeasureResult result = {};
|
||||
result.visible = true;
|
||||
result.minimumSize = measured.minimumSize;
|
||||
return result;
|
||||
}
|
||||
|
||||
DockMeasureResult MeasureSplitNode(
|
||||
const UIEditorWorkspaceNode& node,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostMetrics& metrics) {
|
||||
const DockMeasureResult primary =
|
||||
MeasureNodeRecursive(node.children[0], panelRegistry, session, metrics);
|
||||
const DockMeasureResult secondary =
|
||||
MeasureNodeRecursive(node.children[1], panelRegistry, session, metrics);
|
||||
|
||||
if (!primary.visible && !secondary.visible) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!primary.visible) {
|
||||
return secondary;
|
||||
}
|
||||
|
||||
if (!secondary.visible) {
|
||||
return primary;
|
||||
}
|
||||
|
||||
DockMeasureResult result = {};
|
||||
result.visible = true;
|
||||
result.minimumSize = MeasureSplitterDesiredSize(
|
||||
ToLayoutAxis(node.splitAxis),
|
||||
primary.minimumSize,
|
||||
secondary.minimumSize,
|
||||
metrics.splitterMetrics.thickness);
|
||||
return result;
|
||||
}
|
||||
|
||||
DockMeasureResult MeasureNodeRecursive(
|
||||
const UIEditorWorkspaceNode& node,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostMetrics& metrics) {
|
||||
switch (node.kind) {
|
||||
case UIEditorWorkspaceNodeKind::Panel: {
|
||||
DockMeasureResult result = {};
|
||||
result.visible = IsPanelOpenAndVisible(session, node.panel.panelId);
|
||||
if (result.visible) {
|
||||
result.minimumSize = MeasurePanelMinimumSize(metrics);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
case UIEditorWorkspaceNodeKind::TabStack:
|
||||
return MeasureTabStackNode(node, panelRegistry, session, metrics);
|
||||
case UIEditorWorkspaceNodeKind::Split:
|
||||
return MeasureSplitNode(node, panelRegistry, session, metrics);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
std::size_t ResolveSelectedVisibleTabIndex(
|
||||
const UIEditorWorkspaceNode& node,
|
||||
const std::vector<std::size_t>& visibleChildIndices) {
|
||||
if (visibleChildIndices.empty()) {
|
||||
return UIEditorTabStripInvalidIndex;
|
||||
}
|
||||
|
||||
for (std::size_t visibleIndex = 0; visibleIndex < visibleChildIndices.size(); ++visibleIndex) {
|
||||
if (visibleChildIndices[visibleIndex] == node.selectedTabIndex) {
|
||||
return visibleIndex;
|
||||
}
|
||||
}
|
||||
|
||||
return 0u;
|
||||
}
|
||||
|
||||
UIEditorTabStripState BuildTabStripState(
|
||||
const UIEditorDockHostState& state,
|
||||
std::string_view nodeId,
|
||||
std::size_t selectedIndex) {
|
||||
UIEditorTabStripState tabState = {};
|
||||
tabState.selectedIndex = selectedIndex;
|
||||
tabState.focused = state.focused;
|
||||
|
||||
if (state.hoveredTarget.nodeId != nodeId) {
|
||||
return tabState;
|
||||
}
|
||||
|
||||
switch (state.hoveredTarget.kind) {
|
||||
case UIEditorDockHostHitTargetKind::Tab:
|
||||
tabState.hoveredIndex = state.hoveredTarget.index;
|
||||
break;
|
||||
case UIEditorDockHostHitTargetKind::TabCloseButton:
|
||||
tabState.hoveredIndex = state.hoveredTarget.index;
|
||||
tabState.closeHoveredIndex = state.hoveredTarget.index;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return tabState;
|
||||
}
|
||||
|
||||
UIEditorPanelFrameState BuildStandalonePanelFrameState(
|
||||
const UIEditorDockHostState& state,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorPanelDescriptor* descriptor,
|
||||
const UIEditorWorkspaceNode& node) {
|
||||
UIEditorPanelFrameState frameState = {};
|
||||
frameState.active = workspace.activePanelId == node.panel.panelId;
|
||||
frameState.focused = state.focused && frameState.active;
|
||||
frameState.closable = descriptor != nullptr ? descriptor->canClose : true;
|
||||
frameState.pinnable = false;
|
||||
frameState.showFooter = true;
|
||||
|
||||
if (state.hoveredTarget.panelId != node.panel.panelId) {
|
||||
return frameState;
|
||||
}
|
||||
|
||||
switch (state.hoveredTarget.kind) {
|
||||
case UIEditorDockHostHitTargetKind::PanelHeader:
|
||||
case UIEditorDockHostHitTargetKind::PanelBody:
|
||||
case UIEditorDockHostHitTargetKind::PanelFooter:
|
||||
case UIEditorDockHostHitTargetKind::PanelCloseButton:
|
||||
frameState.hovered = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
frameState.closeHovered =
|
||||
state.hoveredTarget.kind == UIEditorDockHostHitTargetKind::PanelCloseButton;
|
||||
return frameState;
|
||||
}
|
||||
|
||||
UIEditorPanelFrameState BuildTabContentFrameState(
|
||||
const UIEditorDockHostState& state,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
std::string_view panelId) {
|
||||
UIEditorPanelFrameState frameState = {};
|
||||
frameState.active = workspace.activePanelId == panelId;
|
||||
frameState.focused = state.focused && frameState.active;
|
||||
frameState.closable = false;
|
||||
frameState.pinnable = false;
|
||||
|
||||
if (state.hoveredTarget.panelId != panelId) {
|
||||
return frameState;
|
||||
}
|
||||
|
||||
switch (state.hoveredTarget.kind) {
|
||||
case UIEditorDockHostHitTargetKind::PanelHeader:
|
||||
case UIEditorDockHostHitTargetKind::PanelBody:
|
||||
case UIEditorDockHostHitTargetKind::PanelFooter:
|
||||
frameState.hovered = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return frameState;
|
||||
}
|
||||
|
||||
void LayoutNodeRecursive(
|
||||
const UIEditorWorkspaceNode& node,
|
||||
const UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostState& state,
|
||||
const UIEditorDockHostMetrics& metrics,
|
||||
UIEditorDockHostLayout& layout);
|
||||
|
||||
void LayoutPanelNode(
|
||||
const UIEditorWorkspaceNode& node,
|
||||
const UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorDockHostState& state,
|
||||
const UIEditorDockHostMetrics& metrics,
|
||||
UIEditorDockHostLayout& layout) {
|
||||
const UIEditorPanelDescriptor* descriptor =
|
||||
FindPanelDescriptor(panelRegistry, node.panel.panelId);
|
||||
|
||||
UIEditorDockHostPanelLayout panelLayout = {};
|
||||
panelLayout.nodeId = node.nodeId;
|
||||
panelLayout.panelId = node.panel.panelId;
|
||||
panelLayout.title = node.panel.title;
|
||||
panelLayout.active = workspace.activePanelId == node.panel.panelId;
|
||||
panelLayout.frameState =
|
||||
BuildStandalonePanelFrameState(state, workspace, descriptor, node);
|
||||
panelLayout.frameLayout =
|
||||
BuildUIEditorPanelFrameLayout(bounds, panelLayout.frameState, metrics.panelFrameMetrics);
|
||||
layout.panels.push_back(std::move(panelLayout));
|
||||
}
|
||||
|
||||
void LayoutTabStackNode(
|
||||
const UIEditorWorkspaceNode& node,
|
||||
const UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostState& state,
|
||||
const UIEditorDockHostMetrics& metrics,
|
||||
UIEditorDockHostLayout& layout) {
|
||||
std::vector<std::size_t> visibleChildIndices = {};
|
||||
visibleChildIndices.reserve(node.children.size());
|
||||
|
||||
UIEditorDockHostTabStackLayout tabStackLayout = {};
|
||||
tabStackLayout.nodeId = node.nodeId;
|
||||
tabStackLayout.bounds = bounds;
|
||||
|
||||
std::vector<UIEditorTabStripItem> tabStripItems = {};
|
||||
for (std::size_t childIndex = 0; childIndex < node.children.size(); ++childIndex) {
|
||||
const UIEditorWorkspaceNode& child = node.children[childIndex];
|
||||
if (child.kind != UIEditorWorkspaceNodeKind::Panel ||
|
||||
!IsPanelOpenAndVisible(session, child.panel.panelId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
visibleChildIndices.push_back(childIndex);
|
||||
|
||||
UIEditorDockHostTabItemLayout itemLayout = {};
|
||||
itemLayout.panelId = child.panel.panelId;
|
||||
itemLayout.title = child.panel.title;
|
||||
itemLayout.active = workspace.activePanelId == child.panel.panelId;
|
||||
const UIEditorPanelDescriptor* descriptor =
|
||||
FindPanelDescriptor(panelRegistry, child.panel.panelId);
|
||||
itemLayout.closable = descriptor != nullptr ? descriptor->canClose : true;
|
||||
tabStackLayout.items.push_back(itemLayout);
|
||||
|
||||
UIEditorTabStripItem tabItem = {};
|
||||
tabItem.tabId = itemLayout.panelId;
|
||||
tabItem.title = itemLayout.title;
|
||||
tabItem.closable = itemLayout.closable;
|
||||
tabStripItems.push_back(std::move(tabItem));
|
||||
}
|
||||
|
||||
if (tabStripItems.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::size_t selectedVisibleIndex =
|
||||
ResolveSelectedVisibleTabIndex(node, visibleChildIndices);
|
||||
tabStackLayout.selectedPanelId =
|
||||
tabStackLayout.items[selectedVisibleIndex].panelId;
|
||||
tabStackLayout.tabStripState =
|
||||
BuildTabStripState(state, node.nodeId, selectedVisibleIndex);
|
||||
tabStackLayout.tabStripLayout =
|
||||
BuildUIEditorTabStripLayout(bounds, tabStripItems, tabStackLayout.tabStripState, metrics.tabStripMetrics);
|
||||
tabStackLayout.contentFrameState =
|
||||
BuildTabContentFrameState(state, workspace, tabStackLayout.selectedPanelId);
|
||||
tabStackLayout.contentFrameLayout = BuildUIEditorPanelFrameLayout(
|
||||
tabStackLayout.tabStripLayout.contentRect,
|
||||
tabStackLayout.contentFrameState,
|
||||
BuildTabContentFrameMetrics(metrics));
|
||||
|
||||
layout.tabStacks.push_back(std::move(tabStackLayout));
|
||||
}
|
||||
|
||||
void LayoutSplitNode(
|
||||
const UIEditorWorkspaceNode& node,
|
||||
const UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostState& state,
|
||||
const UIEditorDockHostMetrics& metrics,
|
||||
UIEditorDockHostLayout& layout) {
|
||||
const DockMeasureResult primaryMeasure =
|
||||
MeasureNodeRecursive(node.children[0], panelRegistry, session, metrics);
|
||||
const DockMeasureResult secondaryMeasure =
|
||||
MeasureNodeRecursive(node.children[1], panelRegistry, session, metrics);
|
||||
|
||||
if (!primaryMeasure.visible && !secondaryMeasure.visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!primaryMeasure.visible) {
|
||||
LayoutNodeRecursive(
|
||||
node.children[1],
|
||||
bounds,
|
||||
panelRegistry,
|
||||
workspace,
|
||||
session,
|
||||
state,
|
||||
metrics,
|
||||
layout);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!secondaryMeasure.visible) {
|
||||
LayoutNodeRecursive(
|
||||
node.children[0],
|
||||
bounds,
|
||||
panelRegistry,
|
||||
workspace,
|
||||
session,
|
||||
state,
|
||||
metrics,
|
||||
layout);
|
||||
return;
|
||||
}
|
||||
|
||||
UIEditorDockHostSplitterLayout splitterLayout = {};
|
||||
splitterLayout.nodeId = node.nodeId;
|
||||
splitterLayout.axis = node.splitAxis;
|
||||
splitterLayout.bounds = bounds;
|
||||
splitterLayout.metrics = metrics.splitterMetrics;
|
||||
splitterLayout.constraints.primaryMin =
|
||||
GetMainExtent(primaryMeasure.minimumSize, node.splitAxis);
|
||||
splitterLayout.constraints.secondaryMin =
|
||||
GetMainExtent(secondaryMeasure.minimumSize, node.splitAxis);
|
||||
splitterLayout.splitterLayout = ArrangeUISplitter(
|
||||
bounds,
|
||||
ToLayoutAxis(node.splitAxis),
|
||||
node.splitRatio,
|
||||
splitterLayout.constraints,
|
||||
splitterLayout.metrics);
|
||||
splitterLayout.handleHitRect = ExpandUISplitterHandleHitRect(
|
||||
splitterLayout.splitterLayout.handleRect,
|
||||
ToLayoutAxis(node.splitAxis),
|
||||
(std::max)(0.0f, (splitterLayout.metrics.hitThickness - splitterLayout.metrics.thickness) * 0.5f));
|
||||
splitterLayout.hovered =
|
||||
state.hoveredTarget.kind == UIEditorDockHostHitTargetKind::SplitterHandle &&
|
||||
state.hoveredTarget.nodeId == node.nodeId;
|
||||
splitterLayout.active = state.activeSplitterNodeId == node.nodeId;
|
||||
layout.splitters.push_back(splitterLayout);
|
||||
|
||||
LayoutNodeRecursive(
|
||||
node.children[0],
|
||||
splitterLayout.splitterLayout.primaryRect,
|
||||
panelRegistry,
|
||||
workspace,
|
||||
session,
|
||||
state,
|
||||
metrics,
|
||||
layout);
|
||||
LayoutNodeRecursive(
|
||||
node.children[1],
|
||||
splitterLayout.splitterLayout.secondaryRect,
|
||||
panelRegistry,
|
||||
workspace,
|
||||
session,
|
||||
state,
|
||||
metrics,
|
||||
layout);
|
||||
}
|
||||
|
||||
void LayoutNodeRecursive(
|
||||
const UIEditorWorkspaceNode& node,
|
||||
const UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostState& state,
|
||||
const UIEditorDockHostMetrics& metrics,
|
||||
UIEditorDockHostLayout& layout) {
|
||||
switch (node.kind) {
|
||||
case UIEditorWorkspaceNodeKind::Panel:
|
||||
if (IsPanelOpenAndVisible(session, node.panel.panelId)) {
|
||||
LayoutPanelNode(node, bounds, panelRegistry, workspace, state, metrics, layout);
|
||||
}
|
||||
return;
|
||||
case UIEditorWorkspaceNodeKind::TabStack:
|
||||
LayoutTabStackNode(node, bounds, panelRegistry, workspace, session, state, metrics, layout);
|
||||
return;
|
||||
case UIEditorWorkspaceNodeKind::Split:
|
||||
LayoutSplitNode(node, bounds, panelRegistry, workspace, session, state, metrics, layout);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UIEditorDockHostHitTarget MakePanelHitTarget(
|
||||
UIEditorDockHostHitTargetKind kind,
|
||||
std::string_view nodeId,
|
||||
std::string_view panelId) {
|
||||
UIEditorDockHostHitTarget target = {};
|
||||
target.kind = kind;
|
||||
target.nodeId = std::string(nodeId);
|
||||
target.panelId = std::string(panelId);
|
||||
return target;
|
||||
}
|
||||
|
||||
UIEditorDockHostHitTarget MapPanelFrameHitTarget(
|
||||
UIEditorPanelFrameHitTarget hitTarget,
|
||||
std::string_view nodeId,
|
||||
std::string_view panelId) {
|
||||
switch (hitTarget) {
|
||||
case UIEditorPanelFrameHitTarget::Header:
|
||||
return MakePanelHitTarget(UIEditorDockHostHitTargetKind::PanelHeader, nodeId, panelId);
|
||||
case UIEditorPanelFrameHitTarget::Body:
|
||||
return MakePanelHitTarget(UIEditorDockHostHitTargetKind::PanelBody, nodeId, panelId);
|
||||
case UIEditorPanelFrameHitTarget::Footer:
|
||||
return MakePanelHitTarget(UIEditorDockHostHitTargetKind::PanelFooter, nodeId, panelId);
|
||||
case UIEditorPanelFrameHitTarget::CloseButton:
|
||||
return MakePanelHitTarget(UIEditorDockHostHitTargetKind::PanelCloseButton, nodeId, panelId);
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
UIColor ResolveSplitterColor(const UIEditorDockHostSplitterLayout& splitter, const UIEditorDockHostPalette& palette) {
|
||||
if (splitter.active) {
|
||||
return palette.splitterActiveColor;
|
||||
}
|
||||
|
||||
if (splitter.hovered) {
|
||||
return palette.splitterHoveredColor;
|
||||
}
|
||||
|
||||
return palette.splitterColor;
|
||||
}
|
||||
|
||||
void AppendPlaceholderText(
|
||||
UIDrawList& drawList,
|
||||
const UIRect& bodyRect,
|
||||
std::string title,
|
||||
std::string detailLine,
|
||||
std::string extraLine,
|
||||
const UIEditorDockHostPalette& palette,
|
||||
const UIEditorDockHostMetrics& metrics) {
|
||||
if (bodyRect.width <= 0.0f || bodyRect.height <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
drawList.AddText(
|
||||
UIPoint(bodyRect.x, bodyRect.y),
|
||||
std::move(title),
|
||||
palette.placeholderTitleColor,
|
||||
16.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(bodyRect.x, bodyRect.y + metrics.placeholderLineGap),
|
||||
std::move(detailLine),
|
||||
palette.placeholderTextColor,
|
||||
12.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(bodyRect.x, bodyRect.y + metrics.placeholderLineGap * 2.0f),
|
||||
std::move(extraLine),
|
||||
palette.placeholderMutedColor,
|
||||
12.0f);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const UIEditorDockHostSplitterLayout* FindUIEditorDockHostSplitterLayout(
|
||||
const UIEditorDockHostLayout& layout,
|
||||
std::string_view nodeId) {
|
||||
for (const UIEditorDockHostSplitterLayout& splitter : layout.splitters) {
|
||||
if (splitter.nodeId == nodeId) {
|
||||
return &splitter;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UIEditorDockHostLayout BuildUIEditorDockHostLayout(
|
||||
const UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostState& state,
|
||||
const UIEditorDockHostMetrics& metrics) {
|
||||
UIEditorDockHostLayout layout = {};
|
||||
layout.bounds = UIRect(
|
||||
bounds.x,
|
||||
bounds.y,
|
||||
ClampNonNegative(bounds.width),
|
||||
ClampNonNegative(bounds.height));
|
||||
LayoutNodeRecursive(
|
||||
workspace.root,
|
||||
layout.bounds,
|
||||
panelRegistry,
|
||||
workspace,
|
||||
session,
|
||||
state,
|
||||
metrics,
|
||||
layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
UIEditorDockHostHitTarget HitTestUIEditorDockHost(
|
||||
const UIEditorDockHostLayout& layout,
|
||||
const UIPoint& point) {
|
||||
for (std::size_t index = layout.splitters.size(); index > 0u; --index) {
|
||||
const UIEditorDockHostSplitterLayout& splitter = layout.splitters[index - 1u];
|
||||
if (IsPointInsideRect(splitter.handleHitRect, point)) {
|
||||
UIEditorDockHostHitTarget target = {};
|
||||
target.kind = UIEditorDockHostHitTargetKind::SplitterHandle;
|
||||
target.nodeId = splitter.nodeId;
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
for (std::size_t index = layout.tabStacks.size(); index > 0u; --index) {
|
||||
const UIEditorDockHostTabStackLayout& tabStack = layout.tabStacks[index - 1u];
|
||||
const UIEditorTabStripHitTarget tabHit =
|
||||
HitTestUIEditorTabStrip(tabStack.tabStripLayout, tabStack.tabStripState, point);
|
||||
switch (tabHit.kind) {
|
||||
case UIEditorTabStripHitTargetKind::CloseButton: {
|
||||
UIEditorDockHostHitTarget target = {};
|
||||
target.kind = UIEditorDockHostHitTargetKind::TabCloseButton;
|
||||
target.nodeId = tabStack.nodeId;
|
||||
target.index = tabHit.index;
|
||||
if (tabHit.index < tabStack.items.size()) {
|
||||
target.panelId = tabStack.items[tabHit.index].panelId;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
case UIEditorTabStripHitTargetKind::Tab: {
|
||||
UIEditorDockHostHitTarget target = {};
|
||||
target.kind = UIEditorDockHostHitTargetKind::Tab;
|
||||
target.nodeId = tabStack.nodeId;
|
||||
target.index = tabHit.index;
|
||||
if (tabHit.index < tabStack.items.size()) {
|
||||
target.panelId = tabStack.items[tabHit.index].panelId;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
case UIEditorTabStripHitTargetKind::HeaderBackground: {
|
||||
UIEditorDockHostHitTarget target = {};
|
||||
target.kind = UIEditorDockHostHitTargetKind::TabStripBackground;
|
||||
target.nodeId = tabStack.nodeId;
|
||||
return target;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const UIEditorPanelFrameHitTarget panelHit = HitTestUIEditorPanelFrame(
|
||||
tabStack.contentFrameLayout,
|
||||
tabStack.contentFrameState,
|
||||
point);
|
||||
if (panelHit != UIEditorPanelFrameHitTarget::None) {
|
||||
return MapPanelFrameHitTarget(panelHit, tabStack.nodeId, tabStack.selectedPanelId);
|
||||
}
|
||||
}
|
||||
|
||||
for (std::size_t index = layout.panels.size(); index > 0u; --index) {
|
||||
const UIEditorDockHostPanelLayout& panel = layout.panels[index - 1u];
|
||||
const UIEditorPanelFrameHitTarget hitTarget = HitTestUIEditorPanelFrame(
|
||||
panel.frameLayout,
|
||||
panel.frameState,
|
||||
point);
|
||||
if (hitTarget != UIEditorPanelFrameHitTarget::None) {
|
||||
return MapPanelFrameHitTarget(hitTarget, panel.nodeId, panel.panelId);
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void AppendUIEditorDockHostBackground(
|
||||
UIDrawList& drawList,
|
||||
const UIEditorDockHostLayout& layout,
|
||||
const UIEditorDockHostPalette& palette,
|
||||
const UIEditorDockHostMetrics& metrics) {
|
||||
for (const UIEditorDockHostPanelLayout& panel : layout.panels) {
|
||||
AppendUIEditorPanelFrameBackground(
|
||||
drawList,
|
||||
panel.frameLayout,
|
||||
panel.frameState,
|
||||
palette.panelFramePalette,
|
||||
metrics.panelFrameMetrics);
|
||||
}
|
||||
|
||||
const UIEditorPanelFrameMetrics tabContentFrameMetrics =
|
||||
BuildTabContentFrameMetrics(metrics);
|
||||
for (const UIEditorDockHostTabStackLayout& tabStack : layout.tabStacks) {
|
||||
std::vector<UIEditorTabStripItem> tabItems = {};
|
||||
tabItems.reserve(tabStack.items.size());
|
||||
for (const UIEditorDockHostTabItemLayout& item : tabStack.items) {
|
||||
UIEditorTabStripItem tabItem = {};
|
||||
tabItem.tabId = item.panelId;
|
||||
tabItem.title = item.title;
|
||||
tabItem.closable = item.closable;
|
||||
tabItems.push_back(std::move(tabItem));
|
||||
}
|
||||
|
||||
AppendUIEditorTabStripBackground(
|
||||
drawList,
|
||||
tabStack.tabStripLayout,
|
||||
tabStack.tabStripState,
|
||||
palette.tabStripPalette,
|
||||
metrics.tabStripMetrics);
|
||||
AppendUIEditorPanelFrameBackground(
|
||||
drawList,
|
||||
tabStack.contentFrameLayout,
|
||||
tabStack.contentFrameState,
|
||||
palette.panelFramePalette,
|
||||
tabContentFrameMetrics);
|
||||
}
|
||||
|
||||
for (const UIEditorDockHostSplitterLayout& splitter : layout.splitters) {
|
||||
drawList.AddFilledRect(
|
||||
splitter.splitterLayout.handleRect,
|
||||
ResolveSplitterColor(splitter, palette),
|
||||
metrics.splitterHandleRounding);
|
||||
}
|
||||
}
|
||||
|
||||
void AppendUIEditorDockHostForeground(
|
||||
UIDrawList& drawList,
|
||||
const UIEditorDockHostLayout& layout,
|
||||
const UIEditorDockHostPalette& palette,
|
||||
const UIEditorDockHostMetrics& metrics) {
|
||||
for (const UIEditorDockHostPanelLayout& panel : layout.panels) {
|
||||
const UIEditorPanelFrameText text = {
|
||||
panel.title,
|
||||
panel.panelId,
|
||||
panel.active ? "Active Panel" : "Panel Placeholder"
|
||||
};
|
||||
AppendUIEditorPanelFrameForeground(
|
||||
drawList,
|
||||
panel.frameLayout,
|
||||
panel.frameState,
|
||||
text,
|
||||
palette.panelFramePalette,
|
||||
metrics.panelFrameMetrics);
|
||||
AppendPlaceholderText(
|
||||
drawList,
|
||||
panel.frameLayout.bodyRect,
|
||||
panel.title,
|
||||
"DockHost standalone panel",
|
||||
panel.active ? "当前面板为 active" : "点击 header/body 可切换 active",
|
||||
palette,
|
||||
metrics);
|
||||
}
|
||||
|
||||
const UIEditorPanelFrameMetrics tabContentFrameMetrics =
|
||||
BuildTabContentFrameMetrics(metrics);
|
||||
for (const UIEditorDockHostTabStackLayout& tabStack : layout.tabStacks) {
|
||||
std::vector<UIEditorTabStripItem> tabItems = {};
|
||||
tabItems.reserve(tabStack.items.size());
|
||||
for (const UIEditorDockHostTabItemLayout& item : tabStack.items) {
|
||||
UIEditorTabStripItem tabItem = {};
|
||||
tabItem.tabId = item.panelId;
|
||||
tabItem.title = item.title;
|
||||
tabItem.closable = item.closable;
|
||||
tabItems.push_back(std::move(tabItem));
|
||||
}
|
||||
|
||||
AppendUIEditorTabStripForeground(
|
||||
drawList,
|
||||
tabStack.tabStripLayout,
|
||||
tabItems,
|
||||
tabStack.tabStripState,
|
||||
palette.tabStripPalette,
|
||||
metrics.tabStripMetrics);
|
||||
AppendUIEditorPanelFrameForeground(
|
||||
drawList,
|
||||
tabStack.contentFrameLayout,
|
||||
tabStack.contentFrameState,
|
||||
{},
|
||||
palette.panelFramePalette,
|
||||
tabContentFrameMetrics);
|
||||
|
||||
std::string selectedTitle = "(none)";
|
||||
for (const UIEditorDockHostTabItemLayout& item : tabStack.items) {
|
||||
if (item.panelId == tabStack.selectedPanelId) {
|
||||
selectedTitle = item.title;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AppendPlaceholderText(
|
||||
drawList,
|
||||
tabStack.contentFrameLayout.bodyRect,
|
||||
selectedTitle,
|
||||
"DockHost tab content placeholder",
|
||||
"Selected Panel: " + tabStack.selectedPanelId,
|
||||
palette,
|
||||
metrics);
|
||||
}
|
||||
}
|
||||
|
||||
void AppendUIEditorDockHost(
|
||||
UIDrawList& drawList,
|
||||
const UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostState& state,
|
||||
const UIEditorDockHostPalette& palette,
|
||||
const UIEditorDockHostMetrics& metrics) {
|
||||
const UIEditorDockHostLayout layout =
|
||||
BuildUIEditorDockHostLayout(bounds, panelRegistry, workspace, session, state, metrics);
|
||||
AppendUIEditorDockHostBackground(drawList, layout, palette, metrics);
|
||||
AppendUIEditorDockHostForeground(drawList, layout, palette, metrics);
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
Reference in New Issue
Block a user