Refactor editor workspace panel runtime boundary
This commit is contained in:
145
editor/app/Features/EditorWorkspacePanelRegistry.h
Normal file
145
editor/app/Features/EditorWorkspacePanelRegistry.h
Normal file
@@ -0,0 +1,145 @@
|
||||
#pragma once
|
||||
|
||||
#include "Commands/EditorEditCommandRoute.h"
|
||||
#include "State/EditorSession.h"
|
||||
|
||||
#include <XCEditor/Foundation/UIEditorTextMeasurement.h>
|
||||
#include <XCEditor/Panels/UIEditorHostedPanelDispatch.h>
|
||||
#include <XCEditor/Shell/UIEditorShellInteraction.h>
|
||||
#include <XCEditor/Workspace/UIEditorWorkspaceController.h>
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI {
|
||||
|
||||
struct UIInputEvent;
|
||||
|
||||
} // namespace XCEngine::UI
|
||||
|
||||
namespace XCEngine::UI::Editor::Rendering::Host {
|
||||
|
||||
class UiTextureHost;
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Rendering::Host
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class BuiltInIcons;
|
||||
class EditorContext;
|
||||
class ViewportHostService;
|
||||
|
||||
enum class EditorWorkspacePanelCursorKind : std::uint8_t {
|
||||
Arrow = 0,
|
||||
ResizeEW
|
||||
};
|
||||
|
||||
enum class EditorWorkspacePanelUpdatePhase : std::uint8_t {
|
||||
Main = 0,
|
||||
AfterCommandFocusSync
|
||||
};
|
||||
|
||||
struct EditorWorkspacePanelFrameEvent {
|
||||
std::string status = {};
|
||||
std::string traceChannel = {};
|
||||
std::string message = {};
|
||||
};
|
||||
|
||||
struct EditorWorkspacePanelInitializationContext {
|
||||
const std::filesystem::path& repoRoot;
|
||||
Rendering::Host::UiTextureHost& textureHost;
|
||||
UIEditorTextMeasurer& textMeasurer;
|
||||
BuiltInIcons& builtInIcons;
|
||||
ViewportHostService& viewportHostService;
|
||||
};
|
||||
|
||||
struct EditorWorkspacePanelShutdownContext {
|
||||
Rendering::Host::UiTextureHost& textureHost;
|
||||
ViewportHostService& viewportHostService;
|
||||
};
|
||||
|
||||
struct EditorWorkspacePanelUpdateContext {
|
||||
EditorContext& context;
|
||||
UIEditorShellInteractionFrame& shellFrame;
|
||||
UIEditorShellInteractionState& shellInteractionState;
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& hostedContentEvents;
|
||||
};
|
||||
|
||||
class EditorWorkspacePanel {
|
||||
public:
|
||||
virtual ~EditorWorkspacePanel() = default;
|
||||
|
||||
virtual std::string_view GetPanelId() const = 0;
|
||||
virtual std::string_view GetDrawListId() const = 0;
|
||||
virtual EditorActionRoute GetActionRoute() const = 0;
|
||||
|
||||
virtual void Initialize(const EditorWorkspacePanelInitializationContext&) {}
|
||||
virtual void Shutdown(const EditorWorkspacePanelShutdownContext&) {}
|
||||
virtual void ResetInteractionState() {}
|
||||
virtual void PrepareForShellDefinition(
|
||||
EditorContext& context,
|
||||
UIEditorWorkspaceController& workspaceController) {
|
||||
(void)context;
|
||||
(void)workspaceController;
|
||||
}
|
||||
virtual EditorWorkspacePanelUpdatePhase GetUpdatePhase() const {
|
||||
return EditorWorkspacePanelUpdatePhase::Main;
|
||||
}
|
||||
virtual int GetUpdatePriority() const {
|
||||
return 0;
|
||||
}
|
||||
virtual void Update(const EditorWorkspacePanelUpdateContext& context) = 0;
|
||||
virtual void Append(::XCEngine::UI::UIDrawList& drawList) const = 0;
|
||||
virtual bool HasActivePointerCapture() const {
|
||||
return false;
|
||||
}
|
||||
virtual EditorWorkspacePanelCursorKind GetCursorKind() const {
|
||||
return EditorWorkspacePanelCursorKind::Arrow;
|
||||
}
|
||||
virtual EditorEditCommandRoute* GetEditCommandRoute() {
|
||||
return nullptr;
|
||||
}
|
||||
virtual std::vector<EditorWorkspacePanelFrameEvent> CollectFrameEvents() const {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
class EditorWorkspacePanelRuntimeSet final {
|
||||
public:
|
||||
EditorWorkspacePanelRuntimeSet() = default;
|
||||
EditorWorkspacePanelRuntimeSet(const EditorWorkspacePanelRuntimeSet&) = delete;
|
||||
EditorWorkspacePanelRuntimeSet& operator=(const EditorWorkspacePanelRuntimeSet&) = delete;
|
||||
EditorWorkspacePanelRuntimeSet(EditorWorkspacePanelRuntimeSet&&) noexcept = default;
|
||||
EditorWorkspacePanelRuntimeSet& operator=(EditorWorkspacePanelRuntimeSet&&) noexcept = default;
|
||||
|
||||
void AddPanel(std::unique_ptr<EditorWorkspacePanel> panel);
|
||||
void Initialize(const EditorWorkspacePanelInitializationContext& context);
|
||||
void Shutdown(const EditorWorkspacePanelShutdownContext& context);
|
||||
void ResetInteractionState();
|
||||
void PrepareForShellDefinition(
|
||||
EditorContext& context,
|
||||
UIEditorWorkspaceController& workspaceController);
|
||||
void Update(const EditorWorkspacePanelUpdateContext& context);
|
||||
void AppendDrawPackets(::XCEngine::UI::UIDrawData& drawData) const;
|
||||
|
||||
bool HasActivePointerCapture() const;
|
||||
EditorWorkspacePanelCursorKind GetHostedContentCursorKind() const;
|
||||
EditorEditCommandRoute* FindCommandRoute(EditorActionRoute route);
|
||||
std::vector<EditorWorkspacePanelFrameEvent> CollectFrameEvents() const;
|
||||
|
||||
private:
|
||||
std::vector<EditorWorkspacePanel*> BuildUpdateOrder(
|
||||
EditorWorkspacePanelUpdatePhase phase) const;
|
||||
|
||||
std::vector<std::unique_ptr<EditorWorkspacePanel>> m_panels = {};
|
||||
};
|
||||
|
||||
EditorWorkspacePanelRuntimeSet CreateEditorWorkspacePanelRuntimeSet();
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
Reference in New Issue
Block a user