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 <string>
5#include <unordered_map>
6
9
10namespace yaze {
11
12class Rom;
13
14namespace editor {
15
38class StatusBar {
39 public:
40 StatusBar() = default;
41 ~StatusBar() = default;
42
43 void Initialize(GlobalEditorContext* context);
44
45 // ============================================================================
46 // Configuration
47 // ============================================================================
48
52 void SetEnabled(bool enabled) { enabled_ = enabled; }
53 bool IsEnabled() const { return enabled_; }
54
58 void SetRom(Rom* rom) { rom_ = rom; }
59
65 void SetSessionInfo(size_t session_id, size_t total_sessions);
66
67 // ============================================================================
68 // Context Setters (called by active editor)
69 // ============================================================================
70
77 void SetCursorPosition(int x, int y, const char* label = "Pos");
78
83
90 void SetSelection(int count, int width = 0, int height = 0);
91
95 void ClearSelection();
96
101 void SetZoom(float level);
102
106 void ClearZoom();
107
112 void SetEditorMode(const std::string& mode);
113
117 void ClearEditorMode();
118
124 void SetCustomSegment(const std::string& key, const std::string& value);
125
129 void ClearCustomSegment(const std::string& key);
130
134 void ClearAllContext();
135
136 // ============================================================================
137 // Rendering
138 // ============================================================================
139
146 void Draw();
147
152 float GetHeight() const { return enabled_ ? kStatusBarHeight : 0.0f; }
153
154 static constexpr float kStatusBarHeight = 24.0f;
155
156 private:
157 void HandleStatusUpdate(const StatusUpdateEvent& event);
158
159 void DrawRomSegment();
160 void DrawSessionSegment();
161 void DrawCursorSegment();
163 void DrawZoomSegment();
164 void DrawModeSegment();
165 void DrawCustomSegments();
166 void DrawSeparator();
167
169 bool enabled_ = false;
170 Rom* rom_ = nullptr;
171
172 // Session info
173 size_t session_id_ = 0;
174 size_t total_sessions_ = 1;
175
176 // Cursor position
177 bool has_cursor_ = false;
178 int cursor_x_ = 0;
179 int cursor_y_ = 0;
180 std::string cursor_label_ = "Pos";
181
182 // Selection
183 bool has_selection_ = false;
187
188 // Zoom
189 bool has_zoom_ = false;
190 float zoom_level_ = 1.0f;
191
192 // Editor mode
193 bool has_mode_ = false;
194 std::string editor_mode_;
195
196 // Custom segments
197 std::unordered_map<std::string, std::string> custom_segments_;
198};
199
200} // namespace editor
201} // namespace yaze
202
203#endif // YAZE_APP_EDITOR_MENU_STATUS_BAR_H_
204
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:24
A session-aware status bar displayed at the bottom of the application.
Definition status_bar.h:38
static constexpr float kStatusBarHeight
Definition status_bar.h:154
void HandleStatusUpdate(const StatusUpdateEvent &event)
Definition status_bar.cc:21
bool IsEnabled() const
Definition status_bar.h:53
GlobalEditorContext * context_
Definition status_bar.h:168
float GetHeight() const
Get the height of the status bar.
Definition status_bar.h:152
void SetSessionInfo(size_t session_id, size_t total_sessions)
Set session information.
Definition status_bar.cc:43
void ClearCursorPosition()
Clear cursor position (no cursor in editor)
Definition status_bar.cc:55
void SetSelection(int count, int width=0, int height=0)
Set selection information.
Definition status_bar.cc:59
void ClearZoom()
Clear zoom display.
Definition status_bar.cc:75
void SetRom(Rom *rom)
Set the current ROM for dirty status and filename display.
Definition status_bar.h:58
void SetCustomSegment(const std::string &key, const std::string &value)
Set a custom segment with key-value pair.
Definition status_bar.cc:89
void SetZoom(float level)
Set current zoom level.
Definition status_bar.cc:70
void SetEnabled(bool enabled)
Enable or disable the status bar.
Definition status_bar.h:52
std::string cursor_label_
Definition status_bar.h:180
std::unordered_map< std::string, std::string > custom_segments_
Definition status_bar.h:197
void ClearSelection()
Clear selection info.
Definition status_bar.cc:66
void ClearEditorMode()
Clear editor mode display.
Definition status_bar.cc:84
void Initialize(GlobalEditorContext *context)
Definition status_bar.cc:13
void SetCursorPosition(int x, int y, const char *label="Pos")
Set cursor/mouse position in editor coordinates.
Definition status_bar.cc:48
void SetEditorMode(const std::string &mode)
Set the current editor mode or tool.
Definition status_bar.cc:79
void Draw()
Draw the status bar.
void ClearAllContext()
Clear all context (cursor, selection, zoom, mode, custom)
Definition status_bar.cc:98
void ClearCustomSegment(const std::string &key)
Remove a custom segment.
Definition status_bar.cc:94