#include "Composition/EditorShellRuntimeSupport.h" #include #include namespace XCEngine::UI::Editor::App::RuntimeSupport { using ::XCEngine::UI::UIColor; using ::XCEngine::UI::UIDrawList; UIEditorShellComposeModel BuildShellComposeModelFromFrame( const UIEditorShellInteractionFrame& frame) { UIEditorShellComposeModel model = {}; model.menuBarItems = frame.request.menuBarItems; model.toolbarButtons = frame.model.toolbarButtons; model.statusSegments = frame.model.statusSegments; model.workspacePresentations = frame.model.workspacePresentations; return model; } void AppendShellPopups( UIDrawList& drawList, const UIEditorShellInteractionFrame& frame, const UIEditorShellInteractionPalette& palette, const UIEditorShellInteractionMetrics& metrics) { const std::size_t popupCount = (std::min)(frame.request.popupRequests.size(), frame.popupFrames.size()); for (std::size_t index = 0; index < popupCount; ++index) { const UIEditorShellInteractionPopupRequest& popupRequest = frame.request.popupRequests[index]; const UIEditorShellInteractionPopupFrame& popupFrame = frame.popupFrames[index]; Widgets::AppendUIEditorMenuPopupBackground( drawList, popupRequest.layout, popupRequest.widgetItems, popupFrame.popupState, palette.popupPalette, metrics.popupMetrics); Widgets::AppendUIEditorMenuPopupForeground( drawList, popupRequest.layout, popupRequest.widgetItems, popupFrame.popupState, palette.popupPalette, metrics.popupMetrics); } } UIEditorShellComposeFrame BuildShellComposeFrameWithoutDockPreview( const UIEditorShellComposeFrame& frame) { UIEditorShellComposeFrame copy = frame; copy.workspaceFrame.dockHostLayout.dropPreview = {}; return copy; } UIRect ResolveDockPreviewOverlayRect(const UIEditorShellComposeFrame& frame) { const auto& dropPreview = frame.workspaceFrame.dockHostLayout.dropPreview; UIRect previewRect = dropPreview.previewRect; if (dropPreview.placement != UIEditorWorkspaceDockPlacement::Center) { return previewRect; } for (const Widgets::UIEditorDockHostTabStackLayout& tabStack : frame.workspaceFrame.dockHostLayout.tabStacks) { if (tabStack.nodeId == dropPreview.targetNodeId) { return tabStack.bounds; } } return previewRect; } void AppendDockPreviewOverlay( UIDrawList& drawList, const UIEditorShellComposeFrame& frame) { const auto& dropPreview = frame.workspaceFrame.dockHostLayout.dropPreview; if (!dropPreview.visible) { return; } const UIRect previewRect = ResolveDockPreviewOverlayRect(frame); if (previewRect.width <= 0.0f || previewRect.height <= 0.0f) { return; } static const UIColor kDropPreviewFillColor(0.56f, 0.56f, 0.56f, 0.06f); static const UIColor kDropPreviewBorderColor(0.68f, 0.68f, 0.68f, 0.26f); drawList.AddFilledRect(previewRect, kDropPreviewFillColor); drawList.AddRectOutline(previewRect, kDropPreviewBorderColor, 1.0f); } } // namespace XCEngine::UI::Editor::App::RuntimeSupport namespace XCEngine::UI::Editor::App { using ::XCEngine::UI::UIDrawList; using namespace RuntimeSupport; void EditorShellRuntime::RenderRequestedViewports( const ::XCEngine::Rendering::RenderContext& renderContext) { m_viewportHostService.RenderRequestedViewports(renderContext); } void EditorShellRuntime::Append(UIDrawList& drawList) const { const auto& metrics = ResolveUIEditorShellInteractionMetrics(); const auto& palette = ResolveUIEditorShellInteractionPalette(); const UIEditorShellComposeModel shellComposeModel = BuildShellComposeModelFromFrame(m_shellFrame); const UIEditorShellComposeFrame shellComposeFrame = BuildShellComposeFrameWithoutDockPreview(m_shellFrame.shellFrame); AppendUIEditorShellCompose( drawList, shellComposeFrame, shellComposeModel, m_shellInteractionState.composeState, palette.shellPalette, metrics.shellMetrics); m_consolePanel.Append(drawList); m_hierarchyPanel.Append(drawList); m_inspectorPanel.Append(drawList); m_projectPanel.Append(drawList); AppendDockPreviewOverlay(drawList, m_shellFrame.shellFrame); AppendShellPopups(drawList, m_shellFrame, palette, metrics); } } // namespace XCEngine::UI::Editor::App