diff --git a/theme.cpp b/theme.cpp index d73221f..628ede3 100644 --- a/theme.cpp +++ b/theme.cpp @@ -14,6 +14,18 @@ using namespace std::numbers; const char* Theme::prefPath = NULL; path Theme::themeDir = path(); std::set Theme::availableThemes = std::set(); + +ImVec4 change_accent_color(ImVec4 in, float hue) { + if (in.x == in.y && in.y == in.z) { + return in; + } + ImVec4 hsv = in; + ImVec4 out = in; + ImGui::ColorConvertRGBtoHSV(in.x, in.y, in.z, hsv.x, hsv.y, hsv.z); + hsv.x = hue / 360.0f; + ImGui::ColorConvertHSVtoRGB(hsv.x, hsv.y, hsv.z, out.x, out.y, out.z); + return out; +} bool Theme::ShowEditor(bool* open, Theme* &theme) { static ImGui::FileBrowser importDialog; static ImGui::FileBrowser exportDialog; @@ -146,17 +158,18 @@ bool Theme::ShowEditor(bool* open, Theme* &theme) { if (!filter.PassFilter(name)) continue; ImGui::PushID(i); - ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags | ImGuiColorEditFlags_DisplayHSV); - ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); - ImGui::TextUnformatted(name); bool hueEnabled = theme->HueEnabledColors.contains(i); - if (ImGui::Checkbox("Match accent color hue", &hueEnabled)) { + if (ImGui::Checkbox("Accent", &hueEnabled)) { if (hueEnabled) { theme->HueEnabledColors.insert(i); } else { theme->HueEnabledColors.erase(i); } } + ImGui::SameLine(); + ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags | ImGuiColorEditFlags_DisplayHSV); + ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); + ImGui::TextUnformatted(name); ImGui::PopID(); } ImGui::PopItemWidth(); @@ -269,17 +282,6 @@ bool Theme::ShowEditor(bool* open, Theme* &theme) { } return false; } -ImVec4 change_accent_color(ImVec4 in, float hue) { - if (in.x == in.y && in.y == in.z) { - return in; - } - ImVec4 hsv = in; - ImVec4 out = in; - ImGui::ColorConvertRGBtoHSV(in.x, in.y, in.z, hsv.x, hsv.y, hsv.z); - hsv.x = hue / 360.0f; - ImGui::ColorConvertHSVtoRGB(hsv.x, hsv.y, hsv.z, out.x, out.y, out.z); - return out; -} void Theme::Apply(float hue) { ImGuiStyle& actual_style = ImGui::GetStyle(); actual_style = style; @@ -370,7 +372,10 @@ Theme::Theme(bool dark) : Theme() { } for (int i = 0; i < ImGuiCol_COUNT; i++) { - HueEnabledColors.insert(i); + ImVec4 color = style.Colors[i]; + if (color.x != color.y || color.y != color.z) { + HueEnabledColors.insert(i); + } } style.FrameRounding = 12; style.GrabRounding = 12;