fix: Undo accent color changes as they produced some weird results

This commit is contained in:
WerWolv
2025-05-11 15:24:24 +02:00
parent d2344418d6
commit 8cd961596e
4 changed files with 9 additions and 29 deletions

View File

@@ -16,22 +16,9 @@ namespace hex {
AutoReset<std::map<std::string, ThemeManager::StyleHandler>> s_styleHandlers;
AutoReset<std::string> s_imageTheme;
AutoReset<std::string> s_currTheme;
AutoReset<std::optional<ImColor>> s_accentColor;
ImColor s_accentBaseColor;
AutoReset<std::optional<float>> s_accentColor;
std::recursive_mutex s_themeMutex;
std::tuple<float, float, float> getHSV(const ImColor &color) {
float h, s, v;
ImGui::ColorConvertRGBtoHSV(color.Value.x, color.Value.y, color.Value.z, h, s, v);
return { h, s, v };
}
ImColor getRGB(float h, float s, float v, float a) {
float r, g, b;
ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b);
return ImColor(r, g, b, a);
}
}
@@ -155,10 +142,6 @@ namespace hex {
}
}
if (theme.contains("base_color")) {
s_accentBaseColor = parseColorString(theme["base_color"].get<std::string>()).value_or(ImColor(1.0F, 1.0F, 1.0F));
}
if (theme.contains("colors") && !s_themeHandlers->empty()) {
for (const auto&[type, content] : theme["colors"].items()) {
if (!s_themeHandlers->contains(type)) {
@@ -187,15 +170,12 @@ namespace hex {
}
if (accentableColor && s_accentColor->has_value()) {
const auto [baseH, baseS, baseV] = getHSV(s_accentBaseColor);
const auto [accentH, accentS, accentV] = getHSV(s_accentColor->value());
auto [colorH, colorS, colorV] = getHSV(color.value());
float h, s, v;
ImGui::ColorConvertRGBtoHSV(color->Value.x, color->Value.y, color->Value.z, h, s, v);
colorH = std::max(colorH - baseH, 0.0F) + accentH;
colorS = std::max(colorS - baseS, 0.0F) + accentS;
colorV = std::max(colorV - baseV, 0.0F) + accentV;
h = s_accentColor->value();
color = getRGB(colorH, colorS, colorV, color->Value.w);
ImGui::ColorConvertHSVtoRGB(h, s, v, color->Value.x, color->Value.y, color->Value.z);
}
(*s_themeHandlers)[type].setFunction((*s_themeHandlers)[type].colorMap.at(key), color.value());
@@ -274,7 +254,10 @@ namespace hex {
}
void ThemeManager::setAccentColor(const ImColor &color) {
s_accentColor = color;
float h, s, v;
ImGui::ColorConvertRGBtoHSV(color.Value.x, color.Value.y, color.Value.z, h, s, v);
s_accentColor = h;
reapplyCurrentTheme();
}

View File

@@ -1,6 +1,5 @@
{
"base": "Classic",
"base_color": "#59669B9E",
"colors": {
"imgui": {
"border": "#7F7F7F7F",

View File

@@ -1,6 +1,5 @@
{
"base": "Dark",
"base_color": "#4296F966",
"colors": {
"imgui": {
"border": "#6D6D7F7F",

View File

@@ -1,6 +1,5 @@
{
"base": "Light",
"base_color": "#4296F966",
"colors": {
"imgui": {
"border": "#0000004C",