yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
theme_manager.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GUI_THEME_MANAGER_H
2#define YAZE_APP_GUI_THEME_MANAGER_H
3
4#include <map>
5#include <string>
6#include <vector>
7
8#include "absl/status/status.h"
9#include "absl/status/statusor.h"
10#include "app/gui/core/color.h"
11#include "imgui/imgui.h"
12
13namespace yaze {
14namespace gui {
15
20struct Theme {
21 std::string name;
22 std::string description;
23 std::string author;
24
25 // Primary colors
35
36 // Text colors
40
41 // Window colors
46
47 // Interactive elements
54
55 // Navigation and selection
66
67 // Borders and separators
73
74 // Scrollbars and controls
79
80 // Special elements
86
87 // Complete ImGui color support
109
110 // Additional ImGui colors for complete coverage
117
118 // Enhanced theme system - semantic colors
119 Color text_highlight; // For selected text, highlighted items
120 Color link_hover; // For hover state of links
121 Color code_background; // For code blocks, monospace text backgrounds
122 Color success_light; // Lighter variant of success color
123 Color warning_light; // Lighter variant of warning color
124 Color error_light; // Lighter variant of error color
125 Color info_light; // Lighter variant of info color
126
127 // UI state colors
128 Color active_selection; // For active/selected UI elements
129 Color hover_highlight; // General hover state
130 Color focus_border; // For focused input elements
131 Color disabled_overlay; // Semi-transparent overlay for disabled elements
132
133 // Editor-specific colors
134 Color editor_background; // Main editor canvas background
135 Color editor_grid; // Grid lines in editors
136 Color editor_cursor; // Cursor/selection in editors
137 Color editor_selection; // Selected area in editors
138
144
145 // Nested struct for dungeon editor colors
174
175 // Nested struct for chat/agent colors
194
195 // Style parameters
196 float window_rounding = 0.0f;
197 float frame_rounding = 5.0f;
198 float scrollbar_rounding = 5.0f;
199 float grab_rounding = 3.0f;
200 float tab_rounding = 0.0f;
201 float window_border_size = 0.0f;
202 float frame_border_size = 0.0f;
203
204 // Animation and effects
205 bool enable_animations = true;
206 float animation_speed = 1.0f;
208
209 // Theme-aware sizing system (relative to font size)
210 // compact_factor: 0.8 = very compact, 1.0 = normal, 1.2 = spacious
211 float compact_factor = 1.0f;
212
213 // Semantic sizing multipliers (applied on top of compact_factor)
214 float widget_height_multiplier = 1.0f; // Standard widget height
215 float spacing_multiplier = 1.0f; // Padding/margins between elements
216 float toolbar_height_multiplier = 0.8f; // Compact toolbars
217 float panel_padding_multiplier = 1.0f; // Panel interior padding
218 float input_width_multiplier = 1.0f; // Standard input field width
219 float button_padding_multiplier = 1.0f; // Button interior padding
220 float table_row_height_multiplier = 1.0f; // Table row height
221 float canvas_toolbar_multiplier = 0.75f; // Canvas overlay toolbars
222
223 // Helper methods
224 void ApplyToImGui() const;
225};
226
232 public:
233 static ThemeManager& Get();
234
235 // Theme management
236 absl::Status LoadTheme(const std::string& theme_name);
237 absl::Status SaveTheme(const Theme& theme,
238 const std::string& filename);
239 absl::Status LoadThemeFromFile(const std::string& filepath);
240 absl::Status SaveThemeToFile(const Theme& theme,
241 const std::string& filepath) const;
242
243 // Dynamic theme discovery - replaces hardcoded theme lists with automatic
244 // discovery This works across development builds, macOS app bundles, and
245 // other deployment scenarios
246 std::vector<std::string> DiscoverAvailableThemeFiles() const;
247 absl::Status LoadAllAvailableThemes();
248 absl::Status RefreshAvailableThemes(); // Public method to refresh at runtime
249
250 // Built-in themes
252 std::vector<std::string> GetAvailableThemes() const;
253 const Theme* GetTheme(const std::string& name) const;
254 const Theme& GetCurrentTheme() const { return current_theme_; }
255 const std::string& GetCurrentThemeName() const { return current_theme_name_; }
256
257 // Theme application
258 void ApplyTheme(const std::string& theme_name);
259 void ApplyTheme(const Theme& theme);
260 void ApplyClassicYazeTheme(); // Apply original ColorsYaze() function
261
262 // Theme creation and editing
263 Theme CreateCustomTheme(const std::string& name);
264 void ShowThemeEditor(bool* p_open);
265 void ShowThemeSelector(bool* p_open);
266 void ShowSimpleThemeEditor(bool* p_open);
267
268 // Integration with welcome screen
272
273 // Export current theme as JSON string for Web/WASM sync
274 std::string ExportCurrentThemeJson() const;
275
276 // Convenient theme color access interface
277 Color GetThemeColor(const std::string& color_name) const;
278 ImVec4 GetThemeColorVec4(const std::string& color_name) const;
279
280 // Material Design color accessors
299
300 private:
302
303 std::map<std::string, Theme> themes_;
305 std::string current_theme_name_ = "Classic YAZE";
306
308 absl::Status ParseThemeFile(const std::string& content, Theme& theme);
309 Color ParseColorFromString(const std::string& color_str) const;
310 std::string SerializeTheme(const Theme& theme) const;
311
312 // Helper methods for path resolution
313 std::vector<std::string> GetThemeSearchPaths() const;
314 std::string GetThemesDirectory() const;
315 std::string GetCurrentThemeFilePath() const;
316};
317
318// Global convenience functions for easy theme color access
319// Material Design color accessors - global convenience functions
320inline Color GetThemeColor(const std::string& color_name) {
321 return ThemeManager::Get().GetThemeColor(color_name);
322}
323
324inline ImVec4 GetThemeColorVec4(const std::string& color_name) {
325 return ThemeManager::Get().GetThemeColorVec4(color_name);
326}
327
328// Material Design color accessors
330 return ThemeManager::Get().GetPrimary();
331}
340}
342 return ThemeManager::Get().GetSurface();
343}
358}
364}
366 return ThemeManager::Get().GetOutline();
367}
374inline Color GetShadow() {
375 return ThemeManager::Get().GetShadow();
376}
377
378// ImVec4 versions for direct ImGui usage
379inline ImVec4 GetPrimaryVec4() {
381}
382inline ImVec4 GetPrimaryHoverVec4() {
384}
385inline ImVec4 GetPrimaryActiveVec4() {
387}
388inline ImVec4 GetSurfaceVec4() {
390}
403inline ImVec4 GetOnSurfaceVec4() {
405}
409inline ImVec4 GetOnPrimaryVec4() {
411}
412inline ImVec4 GetOutlineVec4() {
414}
415inline ImVec4 GetTextSecondaryVec4() {
417}
418inline ImVec4 GetTextDisabledVec4() {
420}
421inline ImVec4 GetShadowVec4() {
423}
424} // namespace gui
425
426} // namespace yaze
427
428#endif // YAZE_APP_GUI_THEME_MANAGER_H
Manages themes, loading, saving, and switching.
Color GetSurfaceContainerHigh() const
Color ParseColorFromString(const std::string &color_str) const
Color GetSurfaceVariant() const
Color GetTextSecondary() const
void ShowThemeEditor(bool *p_open)
Color GetWelcomeScreenBackground() const
ImVec4 GetThemeColorVec4(const std::string &color_name) const
absl::Status SaveTheme(const Theme &theme, const std::string &filename)
std::string GetCurrentThemeFilePath() const
std::map< std::string, Theme > themes_
absl::Status LoadTheme(const std::string &theme_name)
const Theme & GetCurrentTheme() const
Color GetPrimaryHover() const
absl::Status LoadThemeFromFile(const std::string &filepath)
void ApplyTheme(const std::string &theme_name)
std::string GetThemesDirectory() const
std::string current_theme_name_
Color GetWelcomeScreenAccent() const
std::vector< std::string > DiscoverAvailableThemeFiles() const
Theme CreateCustomTheme(const std::string &name)
absl::Status LoadAllAvailableThemes()
Color GetSurfaceContainer() const
Color GetOnSurfaceVariant() const
absl::Status SaveThemeToFile(const Theme &theme, const std::string &filepath) const
std::vector< std::string > GetThemeSearchPaths() const
absl::Status ParseThemeFile(const std::string &content, Theme &theme)
static ThemeManager & Get()
Color GetThemeColor(const std::string &color_name) const
const std::string & GetCurrentThemeName() const
void ShowThemeSelector(bool *p_open)
const Theme * GetTheme(const std::string &name) const
std::string SerializeTheme(const Theme &theme) const
absl::Status RefreshAvailableThemes()
Color GetTextDisabled() const
std::string ExportCurrentThemeJson() const
Color GetSurfaceContainerHighest() const
Color GetWelcomeScreenBorder() const
void ShowSimpleThemeEditor(bool *p_open)
Color GetPrimaryActive() const
std::vector< std::string > GetAvailableThemes() const
ImVec4 ConvertColorToImVec4(const Color &color)
Definition color.h:23
ImVec4 GetSurfaceContainerHighestVec4()
Color GetPrimaryHover()
Color GetOnPrimary()
ImVec4 GetThemeColorVec4(const std::string &color_name)
Color GetOnSurfaceVariant()
ImVec4 GetOnPrimaryVec4()
Color GetTextDisabled()
ImVec4 GetPrimaryActiveVec4()
Color GetSurfaceContainerHighest()
Color GetOnSurface()
ImVec4 GetPrimaryVec4()
Color GetSecondary()
Color GetSurfaceContainer()
ImVec4 GetSurfaceVariantVec4()
ImVec4 GetSurfaceVec4()
ImVec4 GetTextDisabledVec4()
Color GetTextSecondary()
Color GetOutline()
Color GetShadow()
ImVec4 GetTextSecondaryVec4()
ImVec4 GetShadowVec4()
ImVec4 GetSurfaceContainerHighVec4()
ImVec4 GetPrimaryHoverVec4()
Color GetPrimaryActive()
Color GetPrimary()
Color GetSurface()
ImVec4 GetOutlineVec4()
Color GetThemeColor(const std::string &color_name)
Color GetSurfaceContainerHigh()
ImVec4 GetOnSurfaceVariantVec4()
ImVec4 GetOnSurfaceVec4()
ImVec4 GetSurfaceContainerVec4()
Color GetSurfaceVariant()
Comprehensive theme structure for YAZE.
Color tab_dimmed_selected_overline
std::string description
std::string name
Color scrollbar_grab_hovered
Color scrollbar_grab_active
Color nav_windowing_highlight
float panel_padding_multiplier
float widget_height_multiplier
struct yaze::gui::Theme::DungeonColors dungeon
struct yaze::gui::Theme::ChatColors chat
void ApplyToImGui() const
float button_padding_multiplier
float table_row_height_multiplier
float toolbar_height_multiplier
std::string author
float canvas_toolbar_multiplier