feat(xcui): add editor layout persistence validation
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCNewEditor/Editor/UIEditorWorkspaceLayoutPersistence.h>
|
||||
#include <XCNewEditor/Editor/UIEditorWorkspaceSession.h>
|
||||
|
||||
#include <cstdint>
|
||||
@@ -58,6 +59,23 @@ struct UIEditorWorkspaceControllerValidationResult {
|
||||
std::string_view GetUIEditorWorkspaceCommandKindName(UIEditorWorkspaceCommandKind kind);
|
||||
std::string_view GetUIEditorWorkspaceCommandStatusName(UIEditorWorkspaceCommandStatus status);
|
||||
|
||||
enum class UIEditorWorkspaceLayoutOperationStatus : std::uint8_t {
|
||||
Changed = 0,
|
||||
NoOp,
|
||||
Rejected
|
||||
};
|
||||
|
||||
struct UIEditorWorkspaceLayoutOperationResult {
|
||||
UIEditorWorkspaceLayoutOperationStatus status =
|
||||
UIEditorWorkspaceLayoutOperationStatus::Rejected;
|
||||
std::string message = {};
|
||||
std::string activePanelId = {};
|
||||
std::vector<std::string> visiblePanelIds = {};
|
||||
};
|
||||
|
||||
std::string_view GetUIEditorWorkspaceLayoutOperationStatusName(
|
||||
UIEditorWorkspaceLayoutOperationStatus status);
|
||||
|
||||
class UIEditorWorkspaceController {
|
||||
public:
|
||||
UIEditorWorkspaceController() = default;
|
||||
@@ -79,6 +97,11 @@ public:
|
||||
}
|
||||
|
||||
UIEditorWorkspaceControllerValidationResult ValidateState() const;
|
||||
UIEditorWorkspaceLayoutSnapshot CaptureLayoutSnapshot() const;
|
||||
UIEditorWorkspaceLayoutOperationResult RestoreLayoutSnapshot(
|
||||
const UIEditorWorkspaceLayoutSnapshot& snapshot);
|
||||
UIEditorWorkspaceLayoutOperationResult RestoreSerializedLayout(
|
||||
std::string_view serializedLayout);
|
||||
UIEditorWorkspaceCommandResult Dispatch(const UIEditorWorkspaceCommand& command);
|
||||
|
||||
private:
|
||||
@@ -95,6 +118,10 @@ private:
|
||||
const UIEditorWorkspaceModel& previousWorkspace,
|
||||
const UIEditorWorkspaceSession& previousSession);
|
||||
|
||||
UIEditorWorkspaceLayoutOperationResult BuildLayoutOperationResult(
|
||||
UIEditorWorkspaceLayoutOperationStatus status,
|
||||
std::string message) const;
|
||||
|
||||
const UIEditorPanelDescriptor* FindPanelDescriptor(std::string_view panelId) const;
|
||||
|
||||
UIEditorPanelRegistry m_panelRegistry = {};
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCNewEditor/Editor/UIEditorWorkspaceSession.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace XCEngine::NewEditor {
|
||||
|
||||
struct UIEditorWorkspaceLayoutSnapshot {
|
||||
UIEditorWorkspaceModel workspace = {};
|
||||
UIEditorWorkspaceSession session = {};
|
||||
};
|
||||
|
||||
enum class UIEditorWorkspaceLayoutLoadCode : std::uint8_t {
|
||||
None = 0,
|
||||
InvalidPanelRegistry,
|
||||
EmptyInput,
|
||||
InvalidHeader,
|
||||
UnsupportedVersion,
|
||||
MissingActiveRecord,
|
||||
UnexpectedEndOfInput,
|
||||
InvalidNodeRecord,
|
||||
InvalidSessionRecord,
|
||||
InvalidWorkspace,
|
||||
InvalidWorkspaceSession
|
||||
};
|
||||
|
||||
struct UIEditorWorkspaceLayoutLoadResult {
|
||||
UIEditorWorkspaceLayoutLoadCode code = UIEditorWorkspaceLayoutLoadCode::None;
|
||||
std::string message = {};
|
||||
UIEditorWorkspaceLayoutSnapshot snapshot = {};
|
||||
|
||||
[[nodiscard]] bool IsValid() const {
|
||||
return code == UIEditorWorkspaceLayoutLoadCode::None;
|
||||
}
|
||||
};
|
||||
|
||||
UIEditorWorkspaceLayoutSnapshot BuildUIEditorWorkspaceLayoutSnapshot(
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session);
|
||||
|
||||
bool AreUIEditorWorkspaceLayoutSnapshotsEquivalent(
|
||||
const UIEditorWorkspaceLayoutSnapshot& lhs,
|
||||
const UIEditorWorkspaceLayoutSnapshot& rhs);
|
||||
|
||||
std::string SerializeUIEditorWorkspaceLayoutSnapshot(
|
||||
const UIEditorWorkspaceLayoutSnapshot& snapshot);
|
||||
|
||||
UIEditorWorkspaceLayoutLoadResult DeserializeUIEditorWorkspaceLayoutSnapshot(
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
std::string_view serializedLayout);
|
||||
|
||||
} // namespace XCEngine::NewEditor
|
||||
@@ -100,6 +100,14 @@ bool ContainsUIEditorWorkspacePanel(
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
std::string_view panelId);
|
||||
|
||||
bool AreUIEditorWorkspaceNodesEquivalent(
|
||||
const UIEditorWorkspaceNode& lhs,
|
||||
const UIEditorWorkspaceNode& rhs);
|
||||
|
||||
bool AreUIEditorWorkspaceModelsEquivalent(
|
||||
const UIEditorWorkspaceModel& lhs,
|
||||
const UIEditorWorkspaceModel& rhs);
|
||||
|
||||
const UIEditorWorkspacePanelState* FindUIEditorWorkspaceActivePanel(
|
||||
const UIEditorWorkspaceModel& workspace);
|
||||
|
||||
|
||||
@@ -53,6 +53,10 @@ UIEditorWorkspaceSessionValidationResult ValidateUIEditorWorkspaceSession(
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session);
|
||||
|
||||
bool AreUIEditorWorkspaceSessionsEquivalent(
|
||||
const UIEditorWorkspaceSession& lhs,
|
||||
const UIEditorWorkspaceSession& rhs);
|
||||
|
||||
std::vector<UIEditorWorkspaceVisiblePanel> CollectUIEditorWorkspaceVisiblePanels(
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session);
|
||||
|
||||
Reference in New Issue
Block a user