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

View File

@@ -5,6 +5,8 @@
#include "absl/status/status.h"
#include "app/core/window.h"
#include "app/editor/editor_manager.h"
#include "app/gui/background_renderer.h"
#include "app/gui/theme_manager.h"
#include "imgui/backends/imgui_impl_sdl2.h"
#include "imgui/backends/imgui_impl_sdlrenderer2.h"
#include "imgui/imgui.h"
@@ -54,10 +56,10 @@ absl::Status Controller::OnLoad() {
ImGui::Begin("DockSpaceWindow", nullptr, window_flags);
ImGui::PopStyleVar(3);
// Create DockSpace
// Create DockSpace first
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f),
ImGuiDockNodeFlags_PassthruCentralNode);
gui::DockSpaceRenderer::BeginEnhancedDockSpace(dockspace_id, ImVec2(0.0f, 0.0f),
ImGuiDockNodeFlags_PassthruCentralNode);
editor_manager_.DrawMenuBar(); // Draw the fixed menu bar at the top

View File

@@ -78,6 +78,19 @@ void SaveFile(const std::string &filename, const std::string &contents) {
}
}
std::string GetResourcePath(const std::string &resource_path) {
#ifdef __APPLE__
#if TARGET_OS_IOS == 1
const std::string kBundlePath = GetBundleResourcePath();
return kBundlePath + resource_path;
#else
return GetBundleResourcePath() + "Contents/Resources/" + resource_path;
#endif
#else
return resource_path; // On Linux/Windows, resources are relative to executable
#endif
}
std::string GetConfigDirectory() {
std::string config_directory = ".yaze";
Platform platform;

View File

@@ -45,6 +45,7 @@ std::string GetFileName(const std::string &filename);
std::string LoadFile(const std::string &filename);
std::string LoadConfigFile(const std::string &filename);
std::string GetConfigDirectory();
std::string GetResourcePath(const std::string &resource_path);
void SaveFile(const std::string &filename, const std::string &data);
} // namespace core

View File

@@ -6,7 +6,9 @@
#include "app/core/platform/sdl_deleter.h"
#include "app/gfx/arena.h"
#include "app/gui/style.h"
#include "app/gui/theme_manager.h"
#include "app/test/test_manager.h"
#include "util/log.h"
#include "imgui/backends/imgui_impl_sdl2.h"
#include "imgui/backends/imgui_impl_sdlrenderer2.h"
#include "imgui/imgui.h"
@@ -49,7 +51,16 @@ absl::Status CreateWindow(Window& window, int flags) {
RETURN_IF_ERROR(LoadPackageFonts());
// Apply original YAZE colors as fallback, then try to load theme system
gui::ColorsYaze();
// Try to initialize theme system (will fallback to ColorsYaze if files fail)
auto& theme_manager = gui::ThemeManager::Get();
auto status = theme_manager.LoadTheme("YAZE Classic");
if (!status.ok()) {
// Theme system failed, stick with original ColorsYaze()
util::logf("Theme system failed, using original ColorsYaze(): %s", status.message().data());
}
const int audio_frequency = 48000;
SDL_AudioSpec want, have;