#include "Composition/EditorShellDrawComposer.h" #include "Features/Console/ConsolePanel.h" #include "Features/Hierarchy/HierarchyPanel.h" #include "Features/Inspector/InspectorPanel.h" #include "Features/Project/ProjectPanel.h" #include "Features/Scene/SceneViewportFeature.h" #include "Rendering/Assets/BuiltInIcons.h" #include #include #include #include namespace XCEngine::UI::Editor::App { namespace { using ::XCEngine::UI::UIDrawData; 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); } } template void AppendDrawPacket( UIDrawData& drawData, std::string debugName, AppendFn&& appendFn) { UIDrawList drawList(std::move(debugName)); appendFn(drawList); if (!drawList.Empty()) { drawData.AddDrawList(std::move(drawList)); } } } // namespace void EditorShellDrawComposer::Append( const EditorShellDrawComposerContext& context, UIDrawData& drawData) const { const auto& metrics = ResolveUIEditorShellInteractionMetrics(); const auto& palette = ResolveUIEditorShellInteractionPalette(); const UIEditorShellComposeModel shellComposeModel = BuildShellComposeModelFromFrame(context.shellFrame); AppendDrawPacket( drawData, "XCEditorShell.Compose.Base", [&](UIDrawList& drawList) { AppendUIEditorShellComposeBase( drawList, context.shellFrame.shellFrame, shellComposeModel, context.shellInteractionState.composeState, palette.shellPalette, metrics.shellMetrics, &context.builtInIcons); }); AppendDrawPacket( drawData, "XCEditorShell.Compose.Workspace", [&](UIDrawList& drawList) { AppendUIEditorWorkspaceCompose( drawList, context.shellFrame.workspaceInteractionFrame.composeFrame, palette.shellPalette.dockHostPalette, metrics.shellMetrics.dockHostMetrics, palette.shellPalette.viewportPalette, metrics.shellMetrics.viewportMetrics, UIEditorWorkspaceComposeAppendOptions{ true, false }); }); AppendDrawPacket( drawData, "XCEditorShell.Compose.ViewportTextures", [&](UIDrawList& drawList) { AppendUIEditorWorkspaceComposeViewportTextures( drawList, context.shellFrame.workspaceInteractionFrame.composeFrame, palette.shellPalette.viewportPalette); }); AppendDrawPacket( drawData, "XCEditorShell.Compose.StatusBar", [&](UIDrawList& drawList) { AppendUIEditorShellComposeStatusBar( drawList, context.shellFrame.shellFrame, shellComposeModel, context.shellInteractionState.composeState, palette.shellPalette, metrics.shellMetrics); }); AppendDrawPacket( drawData, "XCEditorPanel.Console", [&](UIDrawList& drawList) { context.consolePanel.Append(drawList); }); AppendDrawPacket( drawData, "XCEditorPanel.Hierarchy", [&](UIDrawList& drawList) { context.hierarchyPanel.Append(drawList); }); AppendDrawPacket( drawData, "XCEditorPanel.Inspector", [&](UIDrawList& drawList) { context.inspectorPanel.Append(drawList); }); AppendDrawPacket( drawData, "XCEditorPanel.Project", [&](UIDrawList& drawList) { context.projectPanel.Append(drawList); }); AppendDrawPacket( drawData, "XCEditorPanel.SceneOverlay", [&](UIDrawList& drawList) { context.sceneViewportFeature.Append(drawList); }); AppendDrawPacket( drawData, "XCEditorShell.Compose.Overlay", [&](UIDrawList& drawList) { AppendUIEditorShellComposeOverlay( drawList, context.shellFrame.workspaceInteractionFrame.composeFrame, palette.shellPalette, metrics.shellMetrics); }); AppendDrawPacket( drawData, "XCEditorShell.Popups", [&](UIDrawList& drawList) { AppendShellPopups(drawList, context.shellFrame, palette, metrics); }); } } // namespace XCEngine::UI::Editor::App