feat(xcui): advance core and editor validation flow
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::NewEditor {
|
||||
|
||||
enum class UIEditorPanelPresentationKind : std::uint8_t {
|
||||
Placeholder = 0
|
||||
};
|
||||
|
||||
struct UIEditorPanelDescriptor {
|
||||
std::string panelId = {};
|
||||
std::string defaultTitle = {};
|
||||
UIEditorPanelPresentationKind presentationKind = UIEditorPanelPresentationKind::Placeholder;
|
||||
bool placeholder = true;
|
||||
bool canHide = true;
|
||||
bool canClose = true;
|
||||
};
|
||||
|
||||
struct UIEditorPanelRegistry {
|
||||
std::vector<UIEditorPanelDescriptor> panels = {};
|
||||
};
|
||||
|
||||
enum class UIEditorPanelRegistryValidationCode : std::uint8_t {
|
||||
None = 0,
|
||||
EmptyPanelId,
|
||||
EmptyDefaultTitle,
|
||||
DuplicatePanelId
|
||||
};
|
||||
|
||||
struct UIEditorPanelRegistryValidationResult {
|
||||
UIEditorPanelRegistryValidationCode code = UIEditorPanelRegistryValidationCode::None;
|
||||
std::string message = {};
|
||||
|
||||
[[nodiscard]] bool IsValid() const {
|
||||
return code == UIEditorPanelRegistryValidationCode::None;
|
||||
}
|
||||
};
|
||||
|
||||
UIEditorPanelRegistry BuildDefaultEditorShellPanelRegistry();
|
||||
|
||||
const UIEditorPanelDescriptor* FindUIEditorPanelDescriptor(
|
||||
const UIEditorPanelRegistry& registry,
|
||||
std::string_view panelId);
|
||||
|
||||
UIEditorPanelRegistryValidationResult ValidateUIEditorPanelRegistry(
|
||||
const UIEditorPanelRegistry& registry);
|
||||
|
||||
} // namespace XCEngine::NewEditor
|
||||
@@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCNewEditor/Editor/UIEditorWorkspaceSession.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::NewEditor {
|
||||
|
||||
enum class UIEditorWorkspaceCommandKind : std::uint8_t {
|
||||
OpenPanel = 0,
|
||||
ClosePanel,
|
||||
ShowPanel,
|
||||
HidePanel,
|
||||
ActivatePanel,
|
||||
ResetWorkspace
|
||||
};
|
||||
|
||||
enum class UIEditorWorkspaceCommandStatus : std::uint8_t {
|
||||
Changed = 0,
|
||||
NoOp,
|
||||
Rejected
|
||||
};
|
||||
|
||||
struct UIEditorWorkspaceCommand {
|
||||
UIEditorWorkspaceCommandKind kind = UIEditorWorkspaceCommandKind::ActivatePanel;
|
||||
std::string panelId = {};
|
||||
};
|
||||
|
||||
struct UIEditorWorkspaceCommandResult {
|
||||
UIEditorWorkspaceCommandKind kind = UIEditorWorkspaceCommandKind::ActivatePanel;
|
||||
UIEditorWorkspaceCommandStatus status = UIEditorWorkspaceCommandStatus::Rejected;
|
||||
std::string panelId = {};
|
||||
std::string message = {};
|
||||
std::string activePanelId = {};
|
||||
std::vector<std::string> visiblePanelIds = {};
|
||||
};
|
||||
|
||||
enum class UIEditorWorkspaceControllerValidationCode : std::uint8_t {
|
||||
None = 0,
|
||||
InvalidPanelRegistry,
|
||||
InvalidWorkspace,
|
||||
InvalidWorkspaceSession
|
||||
};
|
||||
|
||||
struct UIEditorWorkspaceControllerValidationResult {
|
||||
UIEditorWorkspaceControllerValidationCode code =
|
||||
UIEditorWorkspaceControllerValidationCode::None;
|
||||
std::string message = {};
|
||||
|
||||
[[nodiscard]] bool IsValid() const {
|
||||
return code == UIEditorWorkspaceControllerValidationCode::None;
|
||||
}
|
||||
};
|
||||
|
||||
std::string_view GetUIEditorWorkspaceCommandKindName(UIEditorWorkspaceCommandKind kind);
|
||||
std::string_view GetUIEditorWorkspaceCommandStatusName(UIEditorWorkspaceCommandStatus status);
|
||||
|
||||
class UIEditorWorkspaceController {
|
||||
public:
|
||||
UIEditorWorkspaceController() = default;
|
||||
UIEditorWorkspaceController(
|
||||
UIEditorPanelRegistry panelRegistry,
|
||||
UIEditorWorkspaceModel workspace,
|
||||
UIEditorWorkspaceSession session);
|
||||
|
||||
const UIEditorPanelRegistry& GetPanelRegistry() const {
|
||||
return m_panelRegistry;
|
||||
}
|
||||
|
||||
const UIEditorWorkspaceModel& GetWorkspace() const {
|
||||
return m_workspace;
|
||||
}
|
||||
|
||||
const UIEditorWorkspaceSession& GetSession() const {
|
||||
return m_session;
|
||||
}
|
||||
|
||||
UIEditorWorkspaceControllerValidationResult ValidateState() const;
|
||||
UIEditorWorkspaceCommandResult Dispatch(const UIEditorWorkspaceCommand& command);
|
||||
|
||||
private:
|
||||
UIEditorWorkspaceCommandResult BuildResult(
|
||||
const UIEditorWorkspaceCommand& command,
|
||||
UIEditorWorkspaceCommandStatus status,
|
||||
std::string message) const;
|
||||
|
||||
UIEditorWorkspaceCommandResult FinalizeMutation(
|
||||
const UIEditorWorkspaceCommand& command,
|
||||
bool changed,
|
||||
std::string changedMessage,
|
||||
std::string unexpectedFailureMessage,
|
||||
const UIEditorWorkspaceModel& previousWorkspace,
|
||||
const UIEditorWorkspaceSession& previousSession);
|
||||
|
||||
const UIEditorPanelDescriptor* FindPanelDescriptor(std::string_view panelId) const;
|
||||
|
||||
UIEditorPanelRegistry m_panelRegistry = {};
|
||||
UIEditorWorkspaceModel m_baselineWorkspace = {};
|
||||
UIEditorWorkspaceSession m_baselineSession = {};
|
||||
UIEditorWorkspaceModel m_workspace = {};
|
||||
UIEditorWorkspaceSession m_session = {};
|
||||
};
|
||||
|
||||
UIEditorWorkspaceController BuildDefaultUIEditorWorkspaceController(
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace);
|
||||
|
||||
} // namespace XCEngine::NewEditor
|
||||
@@ -70,6 +70,8 @@ struct UIEditorWorkspaceVisiblePanel {
|
||||
bool placeholder = false;
|
||||
};
|
||||
|
||||
UIEditorWorkspaceModel BuildDefaultEditorShellWorkspaceModel();
|
||||
|
||||
UIEditorWorkspaceNode BuildUIEditorWorkspacePanel(
|
||||
std::string nodeId,
|
||||
std::string panelId,
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCNewEditor/Editor/UIEditorPanelRegistry.h>
|
||||
#include <XCNewEditor/Editor/UIEditorWorkspaceModel.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::NewEditor {
|
||||
|
||||
struct UIEditorPanelSessionState {
|
||||
std::string panelId = {};
|
||||
bool open = true;
|
||||
bool visible = true;
|
||||
};
|
||||
|
||||
struct UIEditorWorkspaceSession {
|
||||
std::vector<UIEditorPanelSessionState> panelStates = {};
|
||||
};
|
||||
|
||||
enum class UIEditorWorkspaceSessionValidationCode : std::uint8_t {
|
||||
None = 0,
|
||||
MissingPanelState,
|
||||
UnknownPanelId,
|
||||
DuplicatePanelId,
|
||||
ClosedPanelVisible,
|
||||
NonHideablePanelHidden,
|
||||
NonCloseablePanelClosed,
|
||||
InvalidActivePanelId
|
||||
};
|
||||
|
||||
struct UIEditorWorkspaceSessionValidationResult {
|
||||
UIEditorWorkspaceSessionValidationCode code = UIEditorWorkspaceSessionValidationCode::None;
|
||||
std::string message = {};
|
||||
|
||||
[[nodiscard]] bool IsValid() const {
|
||||
return code == UIEditorWorkspaceSessionValidationCode::None;
|
||||
}
|
||||
};
|
||||
|
||||
UIEditorWorkspaceSession BuildDefaultUIEditorWorkspaceSession(
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace);
|
||||
|
||||
const UIEditorPanelSessionState* FindUIEditorPanelSessionState(
|
||||
const UIEditorWorkspaceSession& session,
|
||||
std::string_view panelId);
|
||||
|
||||
UIEditorWorkspaceSessionValidationResult ValidateUIEditorWorkspaceSession(
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session);
|
||||
|
||||
std::vector<UIEditorWorkspaceVisiblePanel> CollectUIEditorWorkspaceVisiblePanels(
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session);
|
||||
|
||||
const UIEditorWorkspacePanelState* FindUIEditorWorkspaceActivePanel(
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session);
|
||||
|
||||
bool TryOpenUIEditorWorkspacePanel(
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
UIEditorWorkspaceModel& workspace,
|
||||
UIEditorWorkspaceSession& session,
|
||||
std::string_view panelId);
|
||||
|
||||
bool TryCloseUIEditorWorkspacePanel(
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
UIEditorWorkspaceModel& workspace,
|
||||
UIEditorWorkspaceSession& session,
|
||||
std::string_view panelId);
|
||||
|
||||
bool TryShowUIEditorWorkspacePanel(
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
UIEditorWorkspaceModel& workspace,
|
||||
UIEditorWorkspaceSession& session,
|
||||
std::string_view panelId);
|
||||
|
||||
bool TryHideUIEditorWorkspacePanel(
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
UIEditorWorkspaceModel& workspace,
|
||||
UIEditorWorkspaceSession& session,
|
||||
std::string_view panelId);
|
||||
|
||||
bool TryActivateUIEditorWorkspacePanel(
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
UIEditorWorkspaceModel& workspace,
|
||||
UIEditorWorkspaceSession& session,
|
||||
std::string_view panelId);
|
||||
|
||||
} // namespace XCEngine::NewEditor
|
||||
Reference in New Issue
Block a user