feat(xcui): add tab strip and workspace compose foundations
This commit is contained in:
108
new_editor/include/XCNewEditor/Editor/UIEditorWorkspaceModel.h
Normal file
108
new_editor/include/XCNewEditor/Editor/UIEditorWorkspaceModel.h
Normal file
@@ -0,0 +1,108 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::NewEditor {
|
||||
|
||||
enum class UIEditorWorkspaceNodeKind : std::uint8_t {
|
||||
Panel = 0,
|
||||
TabStack,
|
||||
Split
|
||||
};
|
||||
|
||||
enum class UIEditorWorkspaceSplitAxis : std::uint8_t {
|
||||
Horizontal = 0,
|
||||
Vertical
|
||||
};
|
||||
|
||||
struct UIEditorWorkspacePanelState {
|
||||
std::string panelId = {};
|
||||
std::string title = {};
|
||||
bool placeholder = false;
|
||||
};
|
||||
|
||||
struct UIEditorWorkspaceNode {
|
||||
UIEditorWorkspaceNodeKind kind = UIEditorWorkspaceNodeKind::Panel;
|
||||
std::string nodeId = {};
|
||||
UIEditorWorkspaceSplitAxis splitAxis = UIEditorWorkspaceSplitAxis::Horizontal;
|
||||
float splitRatio = 0.5f;
|
||||
std::size_t selectedTabIndex = 0u;
|
||||
UIEditorWorkspacePanelState panel = {};
|
||||
std::vector<UIEditorWorkspaceNode> children = {};
|
||||
};
|
||||
|
||||
struct UIEditorWorkspaceModel {
|
||||
UIEditorWorkspaceNode root = {};
|
||||
std::string activePanelId = {};
|
||||
};
|
||||
|
||||
enum class UIEditorWorkspaceValidationCode : std::uint8_t {
|
||||
None = 0,
|
||||
EmptyNodeId,
|
||||
InvalidSplitChildCount,
|
||||
InvalidSplitRatio,
|
||||
EmptyTabStack,
|
||||
InvalidSelectedTabIndex,
|
||||
NonPanelTabChild,
|
||||
EmptyPanelId,
|
||||
EmptyPanelTitle,
|
||||
DuplicatePanelId,
|
||||
InvalidActivePanelId
|
||||
};
|
||||
|
||||
struct UIEditorWorkspaceValidationResult {
|
||||
UIEditorWorkspaceValidationCode code = UIEditorWorkspaceValidationCode::None;
|
||||
std::string message = {};
|
||||
|
||||
[[nodiscard]] bool IsValid() const {
|
||||
return code == UIEditorWorkspaceValidationCode::None;
|
||||
}
|
||||
};
|
||||
|
||||
struct UIEditorWorkspaceVisiblePanel {
|
||||
std::string panelId = {};
|
||||
std::string title = {};
|
||||
bool active = false;
|
||||
bool placeholder = false;
|
||||
};
|
||||
|
||||
UIEditorWorkspaceNode BuildUIEditorWorkspacePanel(
|
||||
std::string nodeId,
|
||||
std::string panelId,
|
||||
std::string title,
|
||||
bool placeholder = false);
|
||||
|
||||
UIEditorWorkspaceNode BuildUIEditorWorkspaceTabStack(
|
||||
std::string nodeId,
|
||||
std::vector<UIEditorWorkspaceNode> panels,
|
||||
std::size_t selectedTabIndex = 0u);
|
||||
|
||||
UIEditorWorkspaceNode BuildUIEditorWorkspaceSplit(
|
||||
std::string nodeId,
|
||||
UIEditorWorkspaceSplitAxis axis,
|
||||
float splitRatio,
|
||||
UIEditorWorkspaceNode primary,
|
||||
UIEditorWorkspaceNode secondary);
|
||||
|
||||
UIEditorWorkspaceValidationResult ValidateUIEditorWorkspace(
|
||||
const UIEditorWorkspaceModel& workspace);
|
||||
|
||||
std::vector<UIEditorWorkspaceVisiblePanel> CollectUIEditorWorkspaceVisiblePanels(
|
||||
const UIEditorWorkspaceModel& workspace);
|
||||
|
||||
bool ContainsUIEditorWorkspacePanel(
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
std::string_view panelId);
|
||||
|
||||
const UIEditorWorkspacePanelState* FindUIEditorWorkspaceActivePanel(
|
||||
const UIEditorWorkspaceModel& workspace);
|
||||
|
||||
bool TryActivateUIEditorWorkspacePanel(
|
||||
UIEditorWorkspaceModel& workspace,
|
||||
std::string_view panelId);
|
||||
|
||||
} // namespace XCEngine::NewEditor
|
||||
Reference in New Issue
Block a user