yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
layout_definition.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_LAYOUT_DESIGNER_LAYOUT_DEFINITION_H_
2#define YAZE_APP_EDITOR_LAYOUT_DESIGNER_LAYOUT_DEFINITION_H_
3
4#include <cstdint>
5#include <memory>
6#include <string>
7#include <vector>
8
9#include "imgui/imgui.h"
10#include "app/editor/editor.h"
11
12namespace yaze {
13namespace editor {
14namespace layout_designer {
15
20enum class DockNodeType {
21 Root, // Root dockspace node
22 Split, // Container with horizontal/vertical split
23 Leaf // Leaf node containing panels
24};
25
34 std::string panel_id; // Unique panel identifier (e.g., "dungeon.room_selector")
35 std::string display_name; // Human-readable name
36 std::string icon; // Icon identifier (e.g., "ICON_MD_LIST")
37
38 // Size configuration
39 ImVec2 size = ImVec2(-1, -1); // Size in pixels (-1 = auto)
40 float size_ratio = 0.0f; // Size ratio for dock splits (0.0 to 1.0)
41
42 // Visibility and priority
43 bool visible_by_default = true;
44 int priority = 100;
45
46 // Panel flags
47 bool closable = true;
48 bool minimizable = true;
49 bool pinnable = true;
50 bool headless = false;
51 bool docking_allowed = true;
52 ImGuiWindowFlags flags = ImGuiWindowFlags_None;
53
54 // Runtime state (for preview)
55 ImGuiID dock_id = 0;
56 bool is_floating = false;
57 ImVec2 floating_pos = ImVec2(100, 100);
58 ImVec2 floating_size = ImVec2(400, 300);
59};
60
68struct DockNode {
70 ImGuiID node_id = 0;
71
72 // Split configuration (for type == Split)
73 ImGuiDir split_dir = ImGuiDir_None; // Left, Right, Up, Down
74 float split_ratio = 0.5f; // Split ratio (0.0 to 1.0)
75
76 // Children (for type == Split)
77 std::unique_ptr<DockNode> child_left;
78 std::unique_ptr<DockNode> child_right;
79
80 // Panels (for type == Leaf)
81 std::vector<LayoutPanel> panels;
82
83 // Dock node flags
84 ImGuiDockNodeFlags flags = ImGuiDockNodeFlags_None;
85
86 // Helper methods
87 bool IsSplit() const { return type == DockNodeType::Split; }
88 bool IsLeaf() const { return type == DockNodeType::Leaf || type == DockNodeType::Root; }
89 bool IsRoot() const { return type == DockNodeType::Root; }
90
91 // Add a panel to this leaf node
92 void AddPanel(const LayoutPanel& panel);
93
94 // Split this node in a direction
95 void Split(ImGuiDir direction, float ratio);
96
97 // Find a panel by ID in the tree
98 LayoutPanel* FindPanel(const std::string& panel_id);
99
100 // Count total panels in the tree
101 size_t CountPanels() const;
102
103 // Clone the node and its children
104 std::unique_ptr<DockNode> Clone() const;
105};
106
115 // Identity
116 std::string name;
117 std::string description;
119
120 // Layout structure
121 std::unique_ptr<DockNode> root;
122 ImVec2 canvas_size = ImVec2(1920, 1080);
123
124 // Metadata
125 std::string author;
126 std::string version = "1.0.0";
127 int64_t created_timestamp = 0;
129
130 // Helper methods
131
135 static LayoutDefinition CreateEmpty(const std::string& name);
136
140 std::unique_ptr<LayoutDefinition> Clone() const;
141
145 LayoutPanel* FindPanel(const std::string& panel_id) const;
146
150 std::vector<LayoutPanel*> GetAllPanels() const;
151
156 bool Validate(std::string* error_message = nullptr) const;
157
161 void Touch();
162};
163
164} // namespace layout_designer
165} // namespace editor
166} // namespace yaze
167
168#endif // YAZE_APP_EDITOR_LAYOUT_DESIGNER_LAYOUT_DEFINITION_H_
DockNodeType
Type of dock node in the layout tree.
Represents a dock node in the layout tree.
void AddPanel(const LayoutPanel &panel)
LayoutPanel * FindPanel(const std::string &panel_id)
std::unique_ptr< DockNode > Clone() const
std::unique_ptr< DockNode > child_left
std::unique_ptr< DockNode > child_right
Complete layout definition with metadata.
std::unique_ptr< LayoutDefinition > Clone() const
Clone the layout definition.
std::vector< LayoutPanel * > GetAllPanels() const
Get all panels in the layout.
bool Validate(std::string *error_message=nullptr) const
Validate the layout structure.
static LayoutDefinition CreateEmpty(const std::string &name)
Create a default empty layout.
void Touch()
Update the modified timestamp to current time.
LayoutPanel * FindPanel(const std::string &panel_id) const
Find a panel by ID anywhere in the layout.
Represents a single panel in a layout.