yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
editor_layout.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GUI_EDITOR_LAYOUT_H
2#define YAZE_APP_GUI_EDITOR_LAYOUT_H
3
4#include <functional>
5#include <string>
6#include <vector>
7
8#include "imgui/imgui.h"
9
10namespace yaze {
11namespace gui {
12
26class Toolset {
27 public:
28 Toolset() = default;
29
30 // Begin the toolbar
31 void Begin();
32
33 // End the toolbar
34 void End();
35
36 // Add mode button group
37 void BeginModeGroup();
38 bool ModeButton(const char* icon, bool selected, const char* tooltip);
39 void EndModeGroup();
40
41 // Add separator
42 void AddSeparator();
43
44 // Add ROM version badge
45 void AddRomBadge(uint8_t version, std::function<void()> on_upgrade = nullptr);
46
47 // Add quick property (inline hex editing)
48 bool AddProperty(const char* icon, const char* label, uint8_t* value,
49 std::function<void()> on_change = nullptr);
50 bool AddProperty(const char* icon, const char* label, uint16_t* value,
51 std::function<void()> on_change = nullptr);
52
53 // Add combo selector
54 bool AddCombo(const char* icon, int* current, const char* const items[], int count);
55
56 // Add toggle button
57 bool AddToggle(const char* icon, bool* state, const char* tooltip);
58
59 // Add action button
60 bool AddAction(const char* icon, const char* tooltip);
61
62 // Add collapsible settings section
63 bool BeginCollapsibleSection(const char* label, bool* p_open);
65
66 // Add v3 settings indicator
67 void AddV3StatusBadge(uint8_t version, std::function<void()> on_settings);
68
69 // Add usage statistics button
70 bool AddUsageStatsButton(const char* tooltip);
71
72 // Get button count for widget registration
73 int GetButtonCount() const { return button_count_; }
74
75 private:
76 bool in_toolbar_ = false;
77 bool in_section_ = false;
79 float current_line_width_ = 0.0f;
81};
82
107 public:
108 enum class Position {
109 Free, // Floating window
110 Right, // Docked to right side
111 Left, // Docked to left side
112 Bottom, // Docked to bottom
113 Floating, // Floating but position saved
114 };
115
116 EditorCard(const char* title, const char* icon = nullptr);
117 EditorCard(const char* title, const char* icon, bool* p_open);
118
119 // Set card properties
120 void SetDefaultSize(float width, float height);
121 void SetPosition(Position pos);
122 void SetMinimizable(bool minimizable) { minimizable_ = minimizable; }
123 void SetClosable(bool closable) { closable_ = closable; }
124 void SetHeadless(bool headless) { headless_ = headless; }
125 void SetDockingAllowed(bool allowed) { docking_allowed_ = allowed; }
126 void SetIconCollapsible(bool collapsible) { icon_collapsible_ = collapsible; }
127
128 // Begin drawing the card
129 bool Begin(bool* p_open = nullptr);
130
131 // End drawing
132 void End();
133
134 // Minimize/maximize
135 void SetMinimized(bool minimized) { minimized_ = minimized; }
136 bool IsMinimized() const { return minimized_; }
137
138 // Focus the card window (bring to front and set focused)
139 void Focus();
140 bool IsFocused() const { return focused_; }
141
142 // Get the window name for ImGui operations
143 const char* GetWindowName() const { return window_name_.c_str(); }
144
145 private:
146 std::string title_;
147 std::string icon_;
148 std::string window_name_; // Full window name with icon
151 bool minimizable_ = true;
152 bool closable_ = true;
153 bool minimized_ = false;
154 bool first_draw_ = true;
155 bool focused_ = false;
156 bool* p_open_ = nullptr;
157
158 // UX enhancements
159 bool headless_ = false; // Minimal chrome, no title bar
160 bool docking_allowed_ = true; // Allow docking
161 bool icon_collapsible_ = false; // Can collapse to floating icon
162 bool collapsed_to_icon_ = false; // Currently collapsed
163 ImVec2 saved_icon_pos_ = ImVec2(10, 100); // Position when collapsed to icon
164
166};
167
180 public:
181 EditorLayout() = default;
182
183 // Begin the editor layout
184 void Begin();
185
186 // End the editor layout
187 void End();
188
189 // Get toolbar reference
191
192 // Begin main canvas area
193 void BeginMainCanvas();
194 void EndMainCanvas();
195
196 // Register a card (for layout management)
197 void RegisterCard(EditorCard* card);
198
199 private:
201 std::vector<EditorCard*> cards_;
202 bool in_layout_ = false;
203};
204
205} // namespace gui
206} // namespace yaze
207
208#endif // YAZE_APP_GUI_EDITOR_LAYOUT_H
209
Draggable, dockable card for editor sub-windows.
bool Begin(bool *p_open=nullptr)
void SetHeadless(bool headless)
void SetDockingAllowed(bool allowed)
void SetIconCollapsible(bool collapsible)
void SetMinimizable(bool minimizable)
void SetMinimized(bool minimized)
void SetDefaultSize(float width, float height)
void SetClosable(bool closable)
const char * GetWindowName() const
void SetPosition(Position pos)
Modern layout manager for editor components.
std::vector< EditorCard * > cards_
void RegisterCard(EditorCard *card)
Ultra-compact toolbar that merges mode buttons with settings.
bool ModeButton(const char *icon, bool selected, const char *tooltip)
bool AddUsageStatsButton(const char *tooltip)
bool BeginCollapsibleSection(const char *label, bool *p_open)
bool AddProperty(const char *icon, const char *label, uint8_t *value, std::function< void()> on_change=nullptr)
bool AddAction(const char *icon, const char *tooltip)
int GetButtonCount() const
bool AddCombo(const char *icon, int *current, const char *const items[], int count)
void AddRomBadge(uint8_t version, std::function< void()> on_upgrade=nullptr)
void AddV3StatusBadge(uint8_t version, std::function< void()> on_settings)
bool AddToggle(const char *icon, bool *state, const char *tooltip)
Main namespace for the application.