refactor editor ui host and shell asset layout

This commit is contained in:
2026-04-10 01:59:15 +08:00
parent b5ba985831
commit 899442c64d
54 changed files with 150 additions and 153 deletions

View File

@@ -0,0 +1,62 @@
#pragma once
#include <XCEditor/Foundation/UIEditorShortcutManager.h>
#include <XCEditor/Shell/UIEditorMenuModel.h>
#include <XCEditor/Shell/UIEditorPanelRegistry.h>
#include <XCEditor/Shell/UIEditorShellInteraction.h>
#include <XCEditor/Shell/UIEditorWorkspaceModel.h>
#include <XCEditor/Shell/UIEditorWorkspaceSession.h>
#include <cstdint>
#include <filesystem>
#include <string>
#include <vector>
namespace XCEngine::UI::Editor {
struct EditorShellShortcutAsset {
UIEditorCommandRegistry commandRegistry = {};
std::vector<UIShortcutBinding> bindings = {};
};
struct EditorShellAsset {
std::string screenId = "editor.shell";
std::filesystem::path documentPath = {};
std::filesystem::path captureRootPath = {};
UIEditorPanelRegistry panelRegistry = {};
UIEditorWorkspaceModel workspace = {};
UIEditorWorkspaceSession workspaceSession = {};
UIEditorShellInteractionDefinition shellDefinition = {};
EditorShellShortcutAsset shortcutAsset = {};
};
enum class EditorShellAssetValidationCode : std::uint8_t {
None = 0,
InvalidPanelRegistry,
InvalidWorkspace,
InvalidWorkspaceSession,
InvalidShellMenuModel,
InvalidShortcutConfiguration,
MissingPanelDescriptor,
PanelTitleMismatch,
PanelPlaceholderMismatch,
DuplicateShellPresentationPanelId,
MissingShellPresentationPanelDescriptor,
MissingRequiredShellPresentation,
ShellPresentationKindMismatch
};
struct EditorShellAssetValidationResult {
EditorShellAssetValidationCode code = EditorShellAssetValidationCode::None;
std::string message = {};
[[nodiscard]] bool IsValid() const {
return code == EditorShellAssetValidationCode::None;
}
};
EditorShellAsset BuildDefaultEditorShellAsset(const std::filesystem::path& repoRoot);
UIEditorShortcutManager BuildEditorShellShortcutManager(const EditorShellAsset& asset);
EditorShellAssetValidationResult ValidateEditorShellAsset(const EditorShellAsset& asset);
} // namespace XCEngine::UI::Editor

View File

@@ -0,0 +1,45 @@
#pragma once
#include <XCEditor/Foundation/UIEditorShortcutManager.h>
#include <XCEditor/Shell/UIEditorShellAsset.h>
#include <XCEditor/Shell/UIEditorShellInteraction.h>
#include <XCEditor/Shell/UIEditorWorkspaceController.h>
#include <XCEngine/UI/Runtime/UIScreenTypes.h>
namespace XCEngine::UI::Editor {
struct StructuredEditorShellBinding {
::XCEngine::UI::Runtime::UIScreenAsset screenAsset = {};
UIEditorWorkspaceController workspaceController = {};
UIEditorShellInteractionDefinition shellDefinition = {};
UIEditorShortcutManager shortcutManager = {};
EditorShellAssetValidationResult assetValidation = {};
[[nodiscard]] bool IsValid() const {
return assetValidation.IsValid();
}
};
inline StructuredEditorShellBinding BuildStructuredEditorShellBinding(
const EditorShellAsset& asset) {
StructuredEditorShellBinding binding = {};
binding.screenAsset.screenId = asset.screenId;
binding.screenAsset.documentPath = asset.documentPath.string();
binding.workspaceController =
UIEditorWorkspaceController(asset.panelRegistry, asset.workspace, asset.workspaceSession);
binding.shellDefinition = asset.shellDefinition;
binding.shortcutManager = BuildEditorShellShortcutManager(asset);
binding.assetValidation = ValidateEditorShellAsset(asset);
return binding;
}
inline UIEditorShellInteractionServices BuildStructuredEditorShellServices(
const StructuredEditorShellBinding& binding) {
UIEditorShellInteractionServices services = {};
services.commandDispatcher = &binding.shortcutManager.GetCommandDispatcher();
services.shortcutManager = &binding.shortcutManager;
return services;
}
} // namespace XCEngine::UI::Editor