2023-07-09 18:56:12 -07:00
|
|
|
#pragma once
|
2023-07-20 14:45:35 -07:00
|
|
|
#include "config.h"
|
2024-03-23 18:41:26 -07:00
|
|
|
#include "imgui/imgui.h"
|
2023-07-09 18:56:12 -07:00
|
|
|
#include <set>
|
2023-07-24 23:13:47 -07:00
|
|
|
#include <map>
|
2023-07-09 18:56:12 -07:00
|
|
|
#include <string>
|
2023-07-17 12:21:38 -07:00
|
|
|
#include "file_browser.h"
|
2023-07-24 23:13:47 -07:00
|
|
|
#include <json/json.h>
|
2023-07-09 18:56:12 -07:00
|
|
|
#include <filesystem>
|
2023-12-22 14:13:48 -08:00
|
|
|
#include "thirdparty/toml.hpp"
|
2023-07-09 18:56:12 -07:00
|
|
|
using std::string;
|
|
|
|
using namespace std::filesystem;
|
|
|
|
|
2023-07-24 23:13:47 -07:00
|
|
|
struct ThemeStrings {
|
|
|
|
string name;
|
|
|
|
string description;
|
|
|
|
ThemeStrings();
|
2023-12-22 14:13:48 -08:00
|
|
|
ThemeStrings(toml::table config);
|
2023-07-24 23:13:47 -07:00
|
|
|
};
|
|
|
|
|
2023-10-16 10:44:25 -07:00
|
|
|
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.
|
2023-12-22 14:13:48 -08:00
|
|
|
/// @returns The serialized TOML, as a toml::table.
|
|
|
|
toml::table Serialize();
|
2023-10-16 10:44:25 -07:00
|
|
|
/// @brief Create a default accent colorizer
|
|
|
|
AccentColorizer();
|
2023-12-22 14:13:48 -08:00
|
|
|
/// @brief Deserialize the settings from TOML and construct.
|
|
|
|
/// @param table The TOML to deserialize from.
|
|
|
|
AccentColorizer(toml::table table);
|
2023-10-16 10:44:25 -07:00
|
|
|
};
|
|
|
|
|
2023-07-09 18:56:12 -07:00
|
|
|
class Theme {
|
|
|
|
ImGuiStyle style;
|
|
|
|
|
2023-12-22 14:13:48 -08:00
|
|
|
static std::string Migrate(string path);
|
2023-07-09 18:56:12 -07:00
|
|
|
public:
|
2023-07-10 19:27:55 -07:00
|
|
|
static std::set<path> availableThemes;
|
2023-07-25 07:56:56 -07:00
|
|
|
static std::map<path, ThemeStrings> themeStrings;
|
2023-07-10 19:27:55 -07:00
|
|
|
static void updateAvailableThemes();
|
|
|
|
static path themeDir;
|
2023-07-09 18:56:12 -07:00
|
|
|
static const char* prefPath;
|
2023-07-24 23:13:47 -07:00
|
|
|
static const int MinSchemaVersion = 0;
|
|
|
|
static const int MaxSchemaVersion = 1;
|
2023-07-09 18:56:12 -07:00
|
|
|
string file_path;
|
2023-07-24 23:13:47 -07:00
|
|
|
std::map<string, ThemeStrings> strings;
|
2023-10-16 10:44:25 -07:00
|
|
|
std::map<int, AccentColorizer> AccentColorizers;
|
2023-07-25 07:56:56 -07:00
|
|
|
ThemeStrings GetStrings();
|
2023-07-17 15:45:43 -07:00
|
|
|
static bool ShowEditor(bool *open, Theme* &theme, ImGuiID dockid, int window_width, int window_height);
|
2023-10-16 10:44:25 -07:00
|
|
|
void Apply(ImVec4 accent);
|
2023-07-09 18:56:12 -07:00
|
|
|
void Save(string path);
|
2023-07-16 19:59:23 -07:00
|
|
|
void Save(path path);
|
2023-07-09 18:56:12 -07:00
|
|
|
Theme();
|
|
|
|
Theme(bool dark);
|
|
|
|
Theme(string path);
|
2023-07-16 19:59:23 -07:00
|
|
|
Theme(path path);
|
2023-07-09 18:56:12 -07:00
|
|
|
};
|