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
10
11namespace yaze {
12
13class Rom;
14
15namespace editor {
16
39class StatusBar {
40 public:
41 StatusBar() = default;
42 ~StatusBar() = default;
43
44 void Initialize(GlobalEditorContext* context);
45
46 // ============================================================================
47 // Configuration
48 // ============================================================================
49
53 void SetEnabled(bool enabled) { enabled_ = enabled; }
54 bool IsEnabled() const { return enabled_; }
55
59 void SetRom(Rom* rom) { rom_ = rom; }
60
66 void SetSessionInfo(size_t session_id, size_t total_sessions);
67
68 // ============================================================================
69 // Context Setters (called by active editor)
70 // ============================================================================
71
78 void SetCursorPosition(int x, int y, const char* label = "Pos");
79
84
91 void SetSelection(int count, int width = 0, int height = 0);
92
96 void ClearSelection();
97
102 void SetZoom(float level);
103
107 void ClearZoom();
108
113 void SetEditorMode(const std::string& mode);
114
118 void ClearEditorMode();
119
125 void SetCustomSegment(const std::string& key, const std::string& value);
126
130 void ClearCustomSegment(const std::string& key);
131
135 void ClearAllContext();
136
137 // ============================================================================
138 // Agent Status
139 // ============================================================================
140
141 void SetAgentInfo(const std::string& provider, const std::string& model,
142 bool active);
143 void ClearAgentInfo();
144 void SetAgentToggleCallback(std::function<void()> callback) {
145 agent_toggle_callback_ = std::move(callback);
146 }
147
148 // ============================================================================
149 // Rendering
150 // ============================================================================
151
158 void Draw();
159
164 float GetHeight() const;
165
166 static constexpr float kStatusBarHeight = 24.0f;
167 static constexpr float kStatusBarTouchHeight = 44.0f;
168
169 private:
170 void HandleStatusUpdate(const StatusUpdateEvent& event);
171
172 void DrawRomSegment();
173 void DrawSessionSegment();
174 void DrawCursorSegment();
176 void DrawZoomSegment();
177 void DrawModeSegment();
178 void DrawAgentSegment();
179 void DrawCustomSegments();
180 void DrawSeparator();
181
183 bool enabled_ = false;
184 Rom* rom_ = nullptr;
185
186 // Session info
187 size_t session_id_ = 0;
188 size_t total_sessions_ = 1;
189
190 // Cursor position
191 bool has_cursor_ = false;
192 int cursor_x_ = 0;
193 int cursor_y_ = 0;
194 std::string cursor_label_ = "Pos";
195
196 // Selection
197 bool has_selection_ = false;
201
202 // Zoom
203 bool has_zoom_ = false;
204 float zoom_level_ = 1.0f;
205
206 // Editor mode
207 bool has_mode_ = false;
208 std::string editor_mode_;
209
210 // Custom segments
211 std::unordered_map<std::string, std::string> custom_segments_;
212
213 // Agent status
214 bool has_agent_ = false;
215 bool agent_active_ = false;
216 std::string agent_provider_;
217 std::string agent_model_;
218 std::function<void()> agent_toggle_callback_;
219};
220
221} // namespace editor
222} // namespace yaze
223
224#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:39
static constexpr float kStatusBarHeight
Definition status_bar.h:166
void HandleStatusUpdate(const StatusUpdateEvent &event)
Definition status_bar.cc:53
bool IsEnabled() const
Definition status_bar.h:54
GlobalEditorContext * context_
Definition status_bar.h:182
float GetHeight() const
Get the height of the status bar.
Definition status_bar.cc:20
void SetSessionInfo(size_t session_id, size_t total_sessions)
Set session information.
Definition status_bar.cc:75
static constexpr float kStatusBarTouchHeight
Definition status_bar.h:167
std::string agent_provider_
Definition status_bar.h:216
void ClearCursorPosition()
Clear cursor position (no cursor in editor)
Definition status_bar.cc:87
std::function< void()> agent_toggle_callback_
Definition status_bar.h:218
void SetSelection(int count, int width=0, int height=0)
Set selection information.
Definition status_bar.cc:91
void ClearZoom()
Clear zoom display.
void SetRom(Rom *rom)
Set the current ROM for dirty status and filename display.
Definition status_bar.h:59
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 SetEnabled(bool enabled)
Enable or disable the status bar.
Definition status_bar.h:53
std::string cursor_label_
Definition status_bar.h:194
std::unordered_map< std::string, std::string > custom_segments_
Definition status_bar.h:211
void ClearSelection()
Clear selection info.
Definition status_bar.cc:98
void ClearEditorMode()
Clear editor mode display.
void Initialize(GlobalEditorContext *context)
Definition status_bar.cc:30
void SetCursorPosition(int x, int y, const char *label="Pos")
Set cursor/mouse position in editor coordinates.
Definition status_bar.cc:80
void SetEditorMode(const std::string &mode)
Set the current editor mode or tool.
void Draw()
Draw the status bar.
void SetAgentToggleCallback(std::function< void()> callback)
Definition status_bar.h:144
void ClearAllContext()
Clear all context (cursor, selection, zoom, mode, custom)
void ClearCustomSegment(const std::string &key)
Remove a custom segment.
void SetAgentInfo(const std::string &provider, const std::string &model, bool active)