Add theme management and background rendering features

- Introduced a comprehensive theme management system, allowing users to load, save, and switch between multiple themes.
- Added support for various built-in themes, enhancing the visual customization of the application.
- Implemented a background renderer for improved visual effects in docking windows, including grid backgrounds and subtle animations.
- Enhanced the EditorManager UI with themed elements, providing a more cohesive and engaging user experience.
- Updated CMake configuration to include new theme and background renderer source files, ensuring proper integration into the build system.
This commit is contained in:
scawful
2025-09-26 19:32:19 -04:00
parent dedbe078d3
commit 997092390a
20 changed files with 2093 additions and 26 deletions

179
src/app/gui/theme_manager.h Normal file
View File

@@ -0,0 +1,179 @@
#ifndef YAZE_APP_GUI_THEME_MANAGER_H
#define YAZE_APP_GUI_THEME_MANAGER_H
#include <map>
#include <string>
#include <vector>
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "app/gui/color.h"
#include "imgui/imgui.h"
namespace yaze {
namespace gui {
/**
* @struct EnhancedTheme
* @brief Comprehensive theme structure for YAZE
*/
struct EnhancedTheme {
std::string name;
std::string description;
std::string author;
// Primary colors
Color primary;
Color secondary;
Color accent;
Color background;
Color surface;
Color error;
Color warning;
Color success;
Color info;
// Text colors
Color text_primary;
Color text_secondary;
Color text_disabled;
// Window colors
Color window_bg;
Color child_bg;
Color popup_bg;
Color modal_bg;
// Interactive elements
Color button;
Color button_hovered;
Color button_active;
Color frame_bg;
Color frame_bg_hovered;
Color frame_bg_active;
// Navigation and selection
Color header;
Color header_hovered;
Color header_active;
Color tab;
Color tab_hovered;
Color tab_active;
Color menu_bar_bg;
Color title_bg;
Color title_bg_active;
Color title_bg_collapsed;
// Borders and separators
Color border;
Color border_shadow;
Color separator;
Color separator_hovered;
Color separator_active;
// Scrollbars and controls
Color scrollbar_bg;
Color scrollbar_grab;
Color scrollbar_grab_hovered;
Color scrollbar_grab_active;
// Special elements
Color resize_grip;
Color resize_grip_hovered;
Color resize_grip_active;
Color docking_preview;
Color docking_empty_bg;
// Complete ImGui color support
Color check_mark;
Color slider_grab;
Color slider_grab_active;
Color input_text_cursor;
Color nav_cursor;
Color nav_windowing_highlight;
Color nav_windowing_dim_bg;
Color modal_window_dim_bg;
Color text_selected_bg;
Color drag_drop_target;
Color table_header_bg;
Color table_border_strong;
Color table_border_light;
Color table_row_bg;
Color table_row_bg_alt;
Color text_link;
Color plot_lines;
Color plot_lines_hovered;
Color plot_histogram;
Color plot_histogram_hovered;
// Style parameters
float window_rounding = 0.0f;
float frame_rounding = 5.0f;
float scrollbar_rounding = 5.0f;
float grab_rounding = 3.0f;
float tab_rounding = 0.0f;
float window_border_size = 0.0f;
float frame_border_size = 0.0f;
// Animation and effects
bool enable_animations = true;
float animation_speed = 1.0f;
bool enable_glow_effects = false;
// Helper methods
void ApplyToImGui() const;
};
/**
* @class ThemeManager
* @brief Manages themes, loading, saving, and switching
*/
class ThemeManager {
public:
static ThemeManager& Get();
// Theme management
absl::Status LoadTheme(const std::string& theme_name);
absl::Status SaveTheme(const EnhancedTheme& theme, const std::string& filename);
absl::Status LoadThemeFromFile(const std::string& filepath);
absl::Status SaveThemeToFile(const EnhancedTheme& theme, const std::string& filepath) const;
// Built-in themes
void InitializeBuiltInThemes();
std::vector<std::string> GetAvailableThemes() const;
const EnhancedTheme* GetTheme(const std::string& name) const;
const EnhancedTheme& GetCurrentTheme() const { return current_theme_; }
// Theme application
void ApplyTheme(const std::string& theme_name);
void ApplyTheme(const EnhancedTheme& theme);
void ApplyClassicYazeTheme(); // Apply original ColorsYaze() function
// Theme creation and editing
EnhancedTheme CreateCustomTheme(const std::string& name);
void ShowThemeEditor(bool* p_open);
void ShowThemeSelector(bool* p_open);
void ShowSimpleThemeEditor(bool* p_open);
// Integration with welcome screen
Color GetWelcomeScreenBackground() const;
Color GetWelcomeScreenBorder() const;
Color GetWelcomeScreenAccent() const;
private:
ThemeManager() { InitializeBuiltInThemes(); }
std::map<std::string, EnhancedTheme> themes_;
EnhancedTheme current_theme_;
std::string current_theme_name_ = "YAZE Classic";
void CreateFallbackYazeClassic();
absl::Status ParseThemeFile(const std::string& content, EnhancedTheme& theme);
Color ParseColorFromString(const std::string& color_str) const;
std::string SerializeTheme(const EnhancedTheme& theme) const;
};
} // namespace gui
} // namespace yaze
#endif // YAZE_APP_GUI_THEME_MANAGER_H