yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
status_bar.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_MENU_STATUS_BAR_H_
2#define YAZE_APP_EDITOR_MENU_STATUS_BAR_H_
3
4#include <functional>
5#include <string>
6#include <unordered_map>
7#include <vector>
8
12
13namespace yaze {
14
15class Rom;
16
17namespace editor {
18
28 std::function<void()> on_click;
29 std::string tooltip;
30};
31
57class StatusBar {
58 public:
59 StatusBar() = default;
60 ~StatusBar() = default;
61
62 void Initialize(GlobalEditorContext* context);
63
64 // ============================================================================
65 // Configuration
66 // ============================================================================
67
71 void SetEnabled(bool enabled) { enabled_ = enabled; }
72 bool IsEnabled() const { return enabled_; }
73
77 void SetRom(Rom* rom) { rom_ = rom; }
78
85 void SetSessionInfo(size_t session_id, size_t total_sessions,
86 const std::string& display_name = {});
87
94 void SetActiveEditor(const std::string& name);
95 void SetActiveEditor(const std::string& name,
96 StatusBarSegmentOptions options);
97 void ClearActiveEditor();
98
104 void SetDirtyScope(const std::string& short_label);
105 void SetDirtyScope(const std::string& short_label,
106 StatusBarSegmentOptions options);
107 void ClearDirtyScope();
108
109 // Test / introspection helpers (display state only).
110 const std::string& active_editor_for_test() const { return active_editor_; }
112 const std::string& dirty_scope_for_test() const { return dirty_scope_; }
114 const std::string& session_display_name_for_test() const {
116 }
117
118 // ============================================================================
119 // Context Setters (called by active editor)
120 // ============================================================================
121
128 void SetCursorPosition(int x, int y, const char* label = "Pos");
129 void SetCursorPosition(int x, int y, const char* label,
131
135 void ClearCursorPosition();
136
143 void SetSelection(int count, int width = 0, int height = 0);
144
148 void ClearSelection();
149
154 void SetZoom(float level);
155 void SetZoom(float level, StatusBarSegmentOptions options);
156
160 void ClearZoom();
161
166 void SetEditorMode(const std::string& mode);
167 void SetEditorMode(const std::string& mode, StatusBarSegmentOptions options);
168
172 void ClearEditorMode();
173
179 void SetCustomSegment(const std::string& key, const std::string& value);
180 void SetCustomSegment(const std::string& key, const std::string& value,
182
186 void ClearCustomSegment(const std::string& key);
187
191 void ClearAllContext();
192
201
202 // ============================================================================
203 // Agent Status
204 // ============================================================================
205
206 void SetAgentInfo(const std::string& provider, const std::string& model,
207 bool active);
208 void ClearAgentInfo();
210 build_status_ = status;
211 }
213 run_status_ = status;
214 }
219 void SetAgentToggleCallback(std::function<void()> callback) {
220 agent_toggle_callback_ = std::move(callback);
221 }
222
223 // ============================================================================
224 // Rendering
225 // ============================================================================
226
233 void Draw();
234
239 float GetHeight() const;
240
241 static constexpr float kStatusBarHeight = 24.0f;
242 static constexpr float kStatusBarTouchHeight = 44.0f;
243
244 private:
245 void HandleStatusUpdate(const StatusUpdateEvent& event);
246
247 void DrawRomSegment();
248 void DrawSessionSegment();
251 void DrawCursorSegment();
253 void DrawZoomSegment();
254 void DrawModeSegment();
255 void DrawAgentSegment();
257 const char* default_icon);
258 void DrawCustomSegments();
259 void DrawSeparator();
260
262 bool enabled_ = false;
263 Rom* rom_ = nullptr;
264
265 // Session info
266 size_t session_id_ = 0;
267 size_t total_sessions_ = 1;
269
270 // Active editor (manager-owned context strip)
271 bool has_active_editor_ = false;
272 std::string active_editor_;
274
275 // Dirty scope summary (manager-owned)
276 bool has_dirty_scope_ = false;
277 std::string dirty_scope_;
279
280 // Cursor position
281 bool has_cursor_ = false;
282 int cursor_x_ = 0;
283 int cursor_y_ = 0;
284 std::string cursor_label_ = "Pos";
286
287 // Selection
288 bool has_selection_ = false;
292
293 // Zoom
294 bool has_zoom_ = false;
295 float zoom_level_ = 1.0f;
297
298 // Editor mode
299 bool has_mode_ = false;
300 std::string editor_mode_;
302
303 // Custom segments — vector preserves insertion order for stable rendering.
305 std::string key;
306 std::string value;
308 };
309 std::vector<CustomSegment> custom_segments_;
310
311 // Agent status
312 bool has_agent_ = false;
313 bool agent_active_ = false;
314 std::string agent_provider_;
315 std::string agent_model_;
316 std::function<void()> agent_toggle_callback_;
317
320};
321
322} // namespace editor
323} // namespace yaze
324
325#endif // YAZE_APP_EDITOR_MENU_STATUS_BAR_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Instance-based runtime context replacing ContentRegistry::Context.
A session-aware status bar displayed at the bottom of the application.
Definition status_bar.h:57
static constexpr float kStatusBarHeight
Definition status_bar.h:241
const std::string & active_editor_for_test() const
Definition status_bar.h:110
void HandleStatusUpdate(const StatusUpdateEvent &event)
StatusBarSegmentOptions dirty_scope_options_
Definition status_bar.h:278
bool IsEnabled() const
Definition status_bar.h:72
GlobalEditorContext * context_
Definition status_bar.h:261
float GetHeight() const
Get the height of the status bar.
Definition status_bar.cc:81
std::string session_display_name_
Definition status_bar.h:268
std::vector< CustomSegment > custom_segments_
Definition status_bar.h:309
void SetBuildStatus(const ProjectWorkflowStatus &status)
Definition status_bar.h:209
StatusBarSegmentOptions cursor_options_
Definition status_bar.h:285
static constexpr float kStatusBarTouchHeight
Definition status_bar.h:242
std::string agent_provider_
Definition status_bar.h:314
StatusBarSegmentOptions active_editor_options_
Definition status_bar.h:273
void SetSessionInfo(size_t session_id, size_t total_sessions, const std::string &display_name={})
Set session information.
void ClearCursorPosition()
Clear cursor position (no cursor in editor)
bool has_dirty_scope_for_test() const
Definition status_bar.h:113
std::string active_editor_
Definition status_bar.h:272
std::function< void()> agent_toggle_callback_
Definition status_bar.h:316
const std::string & session_display_name_for_test() const
Definition status_bar.h:114
void SetSelection(int count, int width=0, int height=0)
Set selection information.
StatusBarSegmentOptions zoom_options_
Definition status_bar.h:296
void ClearZoom()
Clear zoom display.
void SetRunStatus(const ProjectWorkflowStatus &status)
Definition status_bar.h:212
void SetRom(Rom *rom)
Set the current ROM for dirty status and filename display.
Definition status_bar.h:77
StatusBarSegmentOptions mode_options_
Definition status_bar.h:301
void SetActiveEditor(const std::string &name)
Set the active editor category/name for the context strip.
void SetDirtyScope(const std::string &short_label)
Compact dirty-scope chip (ROM / Project / Rooms / …).
void SetCustomSegment(const std::string &key, const std::string &value)
Set a custom segment with key-value pair.
void SetZoom(float level)
Set current zoom level.
void DrawProjectWorkflowSegment(const ProjectWorkflowStatus &status, const char *default_icon)
void SetEnabled(bool enabled)
Enable or disable the status bar.
Definition status_bar.h:71
std::string cursor_label_
Definition status_bar.h:284
void ClearSelection()
Clear selection info.
void ClearEditorMode()
Clear editor mode display.
const std::string & dirty_scope_for_test() const
Definition status_bar.h:112
void Initialize(GlobalEditorContext *context)
Definition status_bar.cc:91
void ClearEditorContributions()
Clear frame-scoped editor contributions.
void SetCursorPosition(int x, int y, const char *label="Pos")
Set cursor/mouse position in editor coordinates.
void SetEditorMode(const std::string &mode)
Set the current editor mode or tool.
ProjectWorkflowStatus build_status_
Definition status_bar.h:318
bool has_active_editor_for_test() const
Definition status_bar.h:111
void Draw()
Draw the status bar.
void SetAgentToggleCallback(std::function< void()> callback)
Definition status_bar.h:219
void ClearAllContext()
Clear all context (cursor, selection, zoom, mode, custom)
void ClearCustomSegment(const std::string &key)
Remove a custom segment.
ProjectWorkflowStatus run_status_
Definition status_bar.h:319
void SetAgentInfo(const std::string &provider, const std::string &model, bool active)
Optional behavior for an interactive status bar segment.
Definition status_bar.h:27
std::function< void()> on_click
Definition status_bar.h:28
StatusBarSegmentOptions options
Definition status_bar.h:307