From ccdd54b1c0a95efbaabd234e8fc7803cabf104bc Mon Sep 17 00:00:00 2001 From: cdozdil Date: Sun, 3 May 2026 20:14:11 +0300 Subject: [PATCH] Accent color now affects background colors (tiny bit) --- OptiScaler/menu/menu_common.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/OptiScaler/menu/menu_common.cpp b/OptiScaler/menu/menu_common.cpp index 44941116..fa770d15 100644 --- a/OptiScaler/menu/menu_common.cpp +++ b/OptiScaler/menu/menu_common.cpp @@ -1411,6 +1411,15 @@ static void ApplyThemeStyle() accent.z *= 0.55f; } + auto Mix = [](const ImVec4& a, const ImVec4& b, float t, float alpha = 1.0f) + { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, alpha); }; + + auto AccentBackground = [&](const ImVec4& base, float strength = 1.0f, float alpha = 1.0f) + { + float t = lightTheme ? (0.025f * strength) : (0.040f * strength); + return Mix(base, accent, t, alpha); + }; + // Background palette switches based on theme const ImVec4 bgDark = lightTheme ? ImVec4(0.80f, 0.82f, 0.86f, 1.00f) : ImVec4(0.09f, 0.10f, 0.13f, 1.00f); const ImVec4 bgMid = lightTheme ? ImVec4(0.89f, 0.91f, 0.95f, 1.00f) : ImVec4(0.11f, 0.13f, 0.16f, 1.00f); @@ -1422,9 +1431,6 @@ static void ApplyThemeStyle() const ImVec4 dimBg = lightTheme ? ImVec4(0.30f, 0.33f, 0.38f, 0.20f) : ImVec4(0.09f, 0.10f, 0.13f, 0.20f); const ImVec4 modalDimBg = lightTheme ? ImVec4(0.22f, 0.24f, 0.28f, 0.55f) : ImVec4(0.04f, 0.04f, 0.07f, 0.55f); - auto Mix = [](const ImVec4& a, const ImVec4& b, float t, float alpha = 1.0f) - { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, alpha); }; - auto AccentSoft = [&](float alpha = 1.0f) { return lightTheme ? Mix(bgLight, accent, 0.24f, alpha) : Mix(bgDark, accent, 0.32f, alpha); }; @@ -1502,18 +1508,19 @@ static void ApplyThemeStyle() c[ImGuiCol_TextLink] = AccentReadable(); // Backgrounds - c[ImGuiCol_WindowBg] = bgDark; - c[ImGuiCol_ChildBg] = bgMid; - c[ImGuiCol_PopupBg] = lightTheme ? bgLight : ImVec4(0.09f, 0.10f, 0.13f, 0.97f); - c[ImGuiCol_MenuBarBg] = bgDark; - c[ImGuiCol_DockingEmptyBg] = bgDark; + c[ImGuiCol_WindowBg] = AccentBackground(bgDark, 1.00f); + c[ImGuiCol_ChildBg] = AccentBackground(bgMid, 1.10f); + c[ImGuiCol_PopupBg] = lightTheme ? AccentBackground(bgLight, 0.90f) + : AccentBackground(ImVec4(0.09f, 0.10f, 0.13f, 0.97f), 0.90f, 0.97f); + c[ImGuiCol_MenuBarBg] = AccentBackground(bgDark, 0.85f); + c[ImGuiCol_DockingEmptyBg] = AccentBackground(bgDark, 0.75f); // Borders c[ImGuiCol_Border] = borderCol; c[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); // Frames - c[ImGuiCol_FrameBg] = bgLight; + c[ImGuiCol_FrameBg] = AccentBackground(bgLight, 0.65f); c[ImGuiCol_FrameBgHovered] = SurfaceHover(); c[ImGuiCol_FrameBgActive] = SurfaceActive(); @@ -1555,11 +1562,11 @@ static void ApplyThemeStyle() c[ImGuiCol_ResizeGripActive] = AccentStrong(0.95f); // Tabs - c[ImGuiCol_Tab] = bgMid; + c[ImGuiCol_Tab] = AccentBackground(bgMid, 0.70f); c[ImGuiCol_TabHovered] = AccentMed(); c[ImGuiCol_TabSelected] = AccentSoft(); c[ImGuiCol_TabSelectedOverline] = AccentStrong(); - c[ImGuiCol_TabDimmed] = bgDark; + c[ImGuiCol_TabDimmed] = AccentBackground(bgDark, 0.60f); c[ImGuiCol_TabDimmedSelected] = AccentSoft(0.75f); c[ImGuiCol_TabDimmedSelectedOverline] = borderCol; @@ -1573,7 +1580,7 @@ static void ApplyThemeStyle() c[ImGuiCol_PlotHistogramHovered] = PlotAccentHovered(); // Tables - c[ImGuiCol_TableHeaderBg] = bgMid; + c[ImGuiCol_TableHeaderBg] = AccentBackground(bgMid, 0.80f); c[ImGuiCol_TableBorderStrong] = borderCol; c[ImGuiCol_TableBorderLight] = lightTheme ? ImVec4(0.68f, 0.72f, 0.80f, 1.00f) : AccentSoft(); c[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);