Refactor XCUI editor module layout
This commit is contained in:
116
new_editor/include/XCEditor/Shell/UIEditorMenuModel.h
Normal file
116
new_editor/include/XCEditor/Shell/UIEditorMenuModel.h
Normal file
@@ -0,0 +1,116 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Foundation/UIEditorCommandDispatcher.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
class UIEditorShortcutManager;
|
||||
|
||||
enum class UIEditorMenuItemKind : std::uint8_t {
|
||||
Command = 0,
|
||||
Separator,
|
||||
Submenu
|
||||
};
|
||||
|
||||
enum class UIEditorMenuCheckedStateSource : std::uint8_t {
|
||||
None = 0,
|
||||
PanelOpen,
|
||||
PanelVisible,
|
||||
PanelActive
|
||||
};
|
||||
|
||||
struct UIEditorMenuCheckedStateBinding {
|
||||
UIEditorMenuCheckedStateSource source = UIEditorMenuCheckedStateSource::None;
|
||||
std::string panelId = {};
|
||||
};
|
||||
|
||||
struct UIEditorMenuItemDescriptor {
|
||||
UIEditorMenuItemKind kind = UIEditorMenuItemKind::Command;
|
||||
std::string itemId = {};
|
||||
std::string label = {};
|
||||
std::string commandId = {};
|
||||
UIEditorMenuCheckedStateBinding checkedState = {};
|
||||
std::vector<UIEditorMenuItemDescriptor> children = {};
|
||||
};
|
||||
|
||||
struct UIEditorMenuDescriptor {
|
||||
std::string menuId = {};
|
||||
std::string label = {};
|
||||
std::vector<UIEditorMenuItemDescriptor> items = {};
|
||||
};
|
||||
|
||||
struct UIEditorMenuModel {
|
||||
std::vector<UIEditorMenuDescriptor> menus = {};
|
||||
};
|
||||
|
||||
enum class UIEditorMenuModelValidationCode : std::uint8_t {
|
||||
None = 0,
|
||||
InvalidCommandRegistry,
|
||||
EmptyMenuId,
|
||||
EmptyMenuLabel,
|
||||
DuplicateMenuId,
|
||||
EmptyCommandId,
|
||||
UnknownCommandId,
|
||||
MissingItemLabel,
|
||||
CommandItemHasChildren,
|
||||
SubmenuMissingLabel,
|
||||
SubmenuEmptyChildren,
|
||||
SubmenuHasCommandId,
|
||||
SeparatorHasCommandId,
|
||||
SeparatorHasChildren,
|
||||
UnexpectedCheckedState,
|
||||
MissingCheckedStatePanelId
|
||||
};
|
||||
|
||||
struct UIEditorMenuModelValidationResult {
|
||||
UIEditorMenuModelValidationCode code = UIEditorMenuModelValidationCode::None;
|
||||
std::string message = {};
|
||||
|
||||
[[nodiscard]] bool IsValid() const {
|
||||
return code == UIEditorMenuModelValidationCode::None;
|
||||
}
|
||||
};
|
||||
|
||||
struct UIEditorResolvedMenuItem {
|
||||
UIEditorMenuItemKind kind = UIEditorMenuItemKind::Command;
|
||||
std::string itemId = {};
|
||||
std::string label = {};
|
||||
std::string commandId = {};
|
||||
std::string commandDisplayName = {};
|
||||
std::string shortcutText = {};
|
||||
bool enabled = true;
|
||||
bool checked = false;
|
||||
UIEditorWorkspaceCommandStatus previewStatus =
|
||||
UIEditorWorkspaceCommandStatus::Rejected;
|
||||
std::string message = {};
|
||||
std::vector<UIEditorResolvedMenuItem> children = {};
|
||||
};
|
||||
|
||||
struct UIEditorResolvedMenuDescriptor {
|
||||
std::string menuId = {};
|
||||
std::string label = {};
|
||||
std::vector<UIEditorResolvedMenuItem> items = {};
|
||||
};
|
||||
|
||||
struct UIEditorResolvedMenuModel {
|
||||
std::vector<UIEditorResolvedMenuDescriptor> menus = {};
|
||||
};
|
||||
|
||||
std::string_view GetUIEditorMenuItemKindName(UIEditorMenuItemKind kind);
|
||||
|
||||
UIEditorMenuModelValidationResult ValidateUIEditorMenuModel(
|
||||
const UIEditorMenuModel& model,
|
||||
const UIEditorCommandRegistry& commandRegistry);
|
||||
|
||||
UIEditorResolvedMenuModel BuildUIEditorResolvedMenuModel(
|
||||
const UIEditorMenuModel& model,
|
||||
const UIEditorCommandDispatcher& commandDispatcher,
|
||||
const UIEditorWorkspaceController& controller,
|
||||
const UIEditorShortcutManager* shortcutManager = nullptr);
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
Reference in New Issue
Block a user