// DragonX Wallet - ImGui Edition // Copyright 2024-2026 The Hush Developers // Released under the GPLv3 #pragma once #include "material/color_theme.h" #include "theme.h" #include namespace dragonx { namespace ui { /** * @brief Color utility and theme derivation helpers * * Provides color parsing, luminance calculation, default color computation, * and acrylic theme derivation from Material Design color themes. * * Theme loading is handled by the UISchema overlay system (ui.toml + * dark.toml / light.toml). This class retains the utility methods * that UISchema and other subsystems depend on. */ class ThemeLoader { public: /** * @brief Parse any supported color string to ImU32 * * Supports all formats: * - "0xRRGGBB" / "0xRRGGBBAA" (hex) * - "#RRGGBB" / "#RRGGBBAA" (web hex) * - "rgba(r,g,b,a)" (CSS-style, a is 0.0-1.0) * - "transparent" (fully transparent) */ static bool parseColorString(const std::string& str, ImU32& outColor); /** * @brief Parse hex color string to ImU32 * * Supports formats: * - "0xRRGGBB" (6 hex digits, alpha = 255) * - "0xRRGGBBAA" (8 hex digits, includes alpha) * - "#RRGGBB" / "#RRGGBBAA" (web format) */ static bool parseHexColor(const std::string& hexStr, ImU32& outColor); /** * @brief Convert ImU32 color to hex string */ static std::string colorToHexString(ImU32 color, bool includeAlpha = false); /** * @brief Calculate relative luminance of a color (0.0 - 1.0) */ static float getLuminance(ImU32 color); /** * @brief Compute default colors for missing fields */ static void computeDefaults(material::ColorTheme& theme, bool isDark); /** * @brief Auto-generate AcrylicTheme from a ColorTheme */ static AcrylicTheme deriveAcrylicTheme(const material::ColorTheme& theme); }; } // namespace ui } // namespace dragonx