looper/backends/ui/imgui/theme.h
Zachary Hall a41c63d059
Some checks failed
Build / build-gentoo (push) Successful in 1m52s
Build / download-system-deps (push) Successful in 5m28s
Build / get-source-code (push) Successful in 16m4s
Build / build-deb (push) Failing after 6m59s
Build / build-appimage (push) Successful in 6m19s
Build / build-android (push) Failing after 3m19s
Build / build-windows (push) Failing after 7m13s
Make subtitle color configurable, and prepare for more configurable colors specific to Looper
2025-01-15 13:52:50 -08:00

76 lines
2.2 KiB
C++

#pragma once
#include "config.h"
#include "imgui/imgui.h"
#include <set>
#include <map>
#include <string>
#include "file_browser.h"
#include <json/json.h>
#include <filesystem>
#include "thirdparty/toml.hpp"
using std::string;
using namespace std::filesystem;
struct ThemeStrings {
string name;
string description;
ThemeStrings();
ThemeStrings(toml::table config);
};
enum LooperCol {
LooperCol_Subtitle,
// LooperCol_Title,
// LooperCol_WindowBorder,
LooperCol_COUNT
};
struct AccentColorizer {
/// @brief Whether or not to change the hue.
bool Hue;
/// @brief Whether or not to change the saturation.
bool Saturation;
/// @brief Whether or not to change the value.
bool Value;
/// @brief Whether or not to multiply the alpha.
bool Alpha;
/// @brief Colorizes a color stored as an ImVec4 according to preferences.
void Colorize(ImVec4 accent, ImVec4 &color);
/// @brief Serialize the settings to json.
/// @returns The serialized TOML, as a toml::table.
toml::table Serialize();
/// @brief Create a default accent colorizer
AccentColorizer();
/// @brief Deserialize the settings from TOML and construct.
/// @param table The TOML to deserialize from.
AccentColorizer(toml::table table);
};
class Theme {
ImGuiStyle style;
static std::string Migrate(string path);
public:
static std::set<path> availableThemes;
static std::map<path, ThemeStrings> themeStrings;
static void updateAvailableThemes();
static path themeDir;
static const char* prefPath;
static const int MinSchemaVersion = 0;
static const int MaxSchemaVersion = 1;
static Theme *cur_theme;
ImVec4 Colors[LooperCol_COUNT];
string file_path;
static ImVec4 GetColor(int color);
const char *GetStyleColorName(int color);
std::map<string, ThemeStrings> strings;
std::map<int, AccentColorizer> AccentColorizers;
ThemeStrings GetStrings();
static bool ShowEditor(bool *open, Theme* &theme, ImGuiID dockid, int window_width, int window_height);
void Apply(ImVec4 accent, float scale);
void Save(string path);
void Save(path path);
Theme();
Theme(bool dark);
Theme(string path);
Theme(path path);
};