yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
widget_definition.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_LAYOUT_DESIGNER_WIDGET_DEFINITION_H_
2#define YAZE_APP_EDITOR_LAYOUT_DESIGNER_WIDGET_DEFINITION_H_
3
4#include <functional>
5#include <memory>
6#include <string>
7#include <vector>
8
9#include "imgui/imgui.h"
10
11namespace yaze {
12namespace editor {
13namespace layout_designer {
14
19enum class WidgetType {
20 // Basic Widgets
21 Text,
24 Button,
35
36 // Layout Widgets
39 Spacing,
40 Dummy, // Invisible spacing
41 NewLine,
42 Indent,
44
45 // Container Widgets
52 TabBar,
53 TabItem,
54
55 // Table Widgets
61
62 // Custom Widgets
63 Canvas, // Custom drawing area
64 Image,
68
69 // Menu Widgets
71 EndMenu,
73
74 // Combo/Dropdown
78 ListBox,
79};
80
86 std::string name;
87 enum class Type {
88 String,
89 Int,
90 Float,
91 Bool,
92 Color,
93 Vec2,
94 Flags
96
97 // Value storage (union-like)
98 std::string string_value;
99 int int_value = 0;
100 float float_value = 0.0f;
101 bool bool_value = false;
102 ImVec4 color_value = ImVec4(1, 1, 1, 1);
103 ImVec2 vec2_value = ImVec2(0, 0);
104 int flags_value = 0;
105};
106
112 std::string id; // Unique widget ID
113 WidgetType type; // Widget type
114 std::string label; // Display label
115 ImVec2 position = ImVec2(0, 0); // Position in panel (for absolute positioning)
116 ImVec2 size = ImVec2(-1, 0); // Size (-1 = auto-width)
117
118 // Properties specific to widget type
119 std::vector<WidgetProperty> properties;
120
121 // Hierarchy
122 std::vector<std::unique_ptr<WidgetDefinition>> children;
123
124 // Code generation hints
125 std::string callback_name; // For buttons, menu items, etc.
126 std::string tooltip; // Hover tooltip
127 bool same_line = false; // Should this widget be on same line as previous?
128
129 // Visual hints for designer
130 bool selected = false;
131 ImVec4 border_color = ImVec4(0.5f, 0.5f, 0.5f, 1.0f);
132
133 // Helper methods
134 void AddProperty(const std::string& name, WidgetProperty::Type type);
135 WidgetProperty* GetProperty(const std::string& name);
136 void AddChild(std::unique_ptr<WidgetDefinition> child);
137
138 // Validation
139 bool IsContainer() const;
140 bool CanHaveChildren() const;
141 bool RequiresEnd() const; // Needs End*() call
142};
143
149 std::string panel_id; // e.g., "dungeon.room_selector"
150 std::string panel_name; // Human-readable name
151 ImVec2 design_size = ImVec2(400, 600); // Design canvas size
152
153 // Widget tree (root level widgets)
154 std::vector<std::unique_ptr<WidgetDefinition>> widgets;
155
156 // Metadata
157 std::string author;
158 std::string version = "1.0.0";
159 int64_t created_timestamp = 0;
161
162 // Helper methods
163 void AddWidget(std::unique_ptr<WidgetDefinition> widget);
164 WidgetDefinition* FindWidget(const std::string& id);
165 std::vector<WidgetDefinition*> GetAllWidgets();
166 bool Validate(std::string* error_message = nullptr) const;
167 void Touch(); // Update modified timestamp
168};
169
173const char* GetWidgetTypeName(WidgetType type);
174
178const char* GetWidgetTypeIcon(WidgetType type);
179
184
188bool RequiresEndCall(WidgetType type);
189
193std::vector<WidgetProperty> GetDefaultProperties(WidgetType type);
194
195} // namespace layout_designer
196} // namespace editor
197} // namespace yaze
198
199#endif // YAZE_APP_EDITOR_LAYOUT_DESIGNER_WIDGET_DEFINITION_H_
200
std::vector< WidgetProperty > GetDefaultProperties(WidgetType type)
Get default properties for a widget type.
WidgetType
Types of ImGui widgets available in the designer.
const char * GetWidgetTypeName(WidgetType type)
Get human-readable name for widget type.
bool IsContainerWidget(WidgetType type)
Check if widget type is a container.
bool RequiresEndCall(WidgetType type)
Check if widget type requires an End*() call.
const char * GetWidgetTypeIcon(WidgetType type)
Get icon for widget type.
Complete design definition for a panel's internal layout.
void AddWidget(std::unique_ptr< WidgetDefinition > widget)
std::vector< std::unique_ptr< WidgetDefinition > > widgets
bool Validate(std::string *error_message=nullptr) const
std::vector< WidgetDefinition * > GetAllWidgets()
WidgetDefinition * FindWidget(const std::string &id)
Defines a widget instance in a panel layout.
void AddProperty(const std::string &name, WidgetProperty::Type type)
WidgetProperty * GetProperty(const std::string &name)
void AddChild(std::unique_ptr< WidgetDefinition > child)
std::vector< std::unique_ptr< WidgetDefinition > > children
Represents a configurable property of a widget.
enum yaze::editor::layout_designer::WidgetProperty::Type type