Refactor XCUI editor module layout
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Foundation/UIEditorCommandRegistry.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
enum class UIEditorCommandEvaluationCode : std::uint8_t {
|
||||
None = 0,
|
||||
InvalidCommandRegistry,
|
||||
UnknownCommandId,
|
||||
MissingActivePanel
|
||||
};
|
||||
|
||||
struct UIEditorCommandEvaluationResult {
|
||||
UIEditorCommandEvaluationCode code = UIEditorCommandEvaluationCode::None;
|
||||
bool executable = false;
|
||||
std::string commandId = {};
|
||||
std::string displayName = {};
|
||||
UIEditorWorkspaceCommand workspaceCommand = {};
|
||||
UIEditorWorkspaceCommandResult previewResult = {};
|
||||
std::string message = {};
|
||||
|
||||
[[nodiscard]] bool IsExecutable() const {
|
||||
return executable;
|
||||
}
|
||||
};
|
||||
|
||||
enum class UIEditorCommandDispatchStatus : std::uint8_t {
|
||||
Dispatched = 0,
|
||||
Rejected
|
||||
};
|
||||
|
||||
struct UIEditorCommandDispatchResult {
|
||||
UIEditorCommandDispatchStatus status = UIEditorCommandDispatchStatus::Rejected;
|
||||
bool commandExecuted = false;
|
||||
std::string commandId = {};
|
||||
std::string displayName = {};
|
||||
UIEditorWorkspaceCommand workspaceCommand = {};
|
||||
UIEditorWorkspaceCommandResult commandResult = {};
|
||||
std::string message = {};
|
||||
};
|
||||
|
||||
std::string_view GetUIEditorCommandDispatchStatusName(
|
||||
UIEditorCommandDispatchStatus status);
|
||||
|
||||
class UIEditorCommandDispatcher {
|
||||
public:
|
||||
UIEditorCommandDispatcher() = default;
|
||||
explicit UIEditorCommandDispatcher(UIEditorCommandRegistry commandRegistry);
|
||||
|
||||
const UIEditorCommandRegistry& GetCommandRegistry() const {
|
||||
return m_commandRegistry;
|
||||
}
|
||||
|
||||
UIEditorCommandRegistryValidationResult ValidateConfiguration() const;
|
||||
|
||||
UIEditorCommandEvaluationResult Evaluate(
|
||||
std::string_view commandId,
|
||||
const UIEditorWorkspaceController& controller) const;
|
||||
|
||||
UIEditorCommandDispatchResult Dispatch(
|
||||
std::string_view commandId,
|
||||
UIEditorWorkspaceController& controller) const;
|
||||
|
||||
private:
|
||||
UIEditorCommandRegistry m_commandRegistry = {};
|
||||
};
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
Reference in New Issue
Block a user