From 3ed2b3966ccce49baada0164d31a2b6f0b19bde6 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Fri, 5 Jun 2026 01:01:03 -0400 Subject: [PATCH] fix(theme): robust get_color fallback and Solarized Dark table colors --- src/theme_2.py | 31 ++++++++++++++++++++++++------- themes/10x_dark.toml | 4 ++-- themes/monokai.toml | 2 +- themes/nord_dark.toml | 2 +- themes/solarized_dark.toml | 4 ++-- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/theme_2.py b/src/theme_2.py index b5262626..27de46e5 100644 --- a/src/theme_2.py +++ b/src/theme_2.py @@ -147,15 +147,29 @@ def get_table_color(is_alt: bool = False, alpha: float = 1.0) -> imgui.ImVec4: def get_color(name: str, alpha: float = 1.0) -> imgui.ImVec4: """Return a tone-mapped semantic color from the current palette.""" palette_name = _current_palette - if palette_name in _TOML_SEMANTIC_CACHE: - d = _TOML_SEMANTIC_CACHE[palette_name] - if name in d: - rgba = list(d[name]) - rgba[3] = alpha - return imgui.ImVec4(*_tone_map(tuple(rgba), palette_name)) - # Hardcoded fallbacks if not in TOML (matches ThemePalette defaults) + # 1. Check TOML-loaded themes first + if palette_name in _TOML_PALETTES: + theme_file = _TOML_PALETTES[palette_name] + + # A. Check semantic cache (for non-ImGui keys) + if palette_name in _TOML_SEMANTIC_CACHE: + d = _TOML_SEMANTIC_CACHE[palette_name] + if name in d: + rgba = list(d[name]) + rgba[3] = alpha + return imgui.ImVec4(*_tone_map(tuple(rgba), palette_name)) + + # B. Check ThemePalette dataclass fields (for basics like 'text') + if hasattr(theme_file.palette, name): + rgb = getattr(theme_file.palette, name) + if isinstance(rgb, tuple) and len(rgb) == 3: + return imgui.ImVec4(*_tone_map((rgb[0]/255.0, rgb[1]/255.0, rgb[2]/255.0, alpha), palette_name)) + + # 2. Hardcoded fallbacks if not in TOML (matches ThemePalette defaults) fallbacks = { + "text": (200, 200, 200), + "text_disabled": (130, 130, 130), "status_success": (80, 255, 80), "status_warning": (255, 152, 48), "status_error": (255, 72, 64), @@ -171,11 +185,14 @@ def get_color(name: str, alpha: float = 1.0) -> imgui.ImVec4: "diff_removed": (230, 51, 51), "diff_header": (77, 178, 255), "table_header_text": (255, 255, 255), + "table_row_bg": (0, 0, 0), + "table_row_bg_alt": (10, 10, 10), } if name in fallbacks: rgb = fallbacks[name] return imgui.ImVec4(*_tone_map((rgb[0]/255.0, rgb[1]/255.0, rgb[2]/255.0, alpha), palette_name)) + # 3. Last resort return imgui.ImVec4(1, 1, 1, alpha) def get_role_tint(role: str) -> imgui.ImVec4: diff --git a/themes/10x_dark.toml b/themes/10x_dark.toml index 55fc55cb..6d445511 100644 --- a/themes/10x_dark.toml +++ b/themes/10x_dark.toml @@ -68,8 +68,8 @@ table_border_light = [ 50, 47, 42] table_border_strong = [ 70, 65, 55] table_header_bg = [ 55, 50, 38] table_header_text = [255, 255, 255] -table_row_bg = [ 0, 0, 0] -table_row_bg_alt = [ 40, 38, 34] +table_row_bg = [ 34, 32, 28] +table_row_bg_alt = [ 45, 42, 38] text = [200, 200, 200] text_disabled = [130, 130, 120] text_link = [ 60, 100, 150] diff --git a/themes/monokai.toml b/themes/monokai.toml index d4784c89..ca7c7b42 100644 --- a/themes/monokai.toml +++ b/themes/monokai.toml @@ -68,7 +68,7 @@ table_border_light = [ 55, 56, 48] table_border_strong = [ 73, 72, 62] table_header_bg = [ 60, 61, 52] table_header_text = [255, 255, 255] -table_row_bg = [ 0, 0, 0] +table_row_bg = [ 39, 40, 34] table_row_bg_alt = [ 50, 51, 44] text = [248, 248, 242] text_disabled = [117, 113, 94] diff --git a/themes/nord_dark.toml b/themes/nord_dark.toml index 180ccc9f..86f459a3 100644 --- a/themes/nord_dark.toml +++ b/themes/nord_dark.toml @@ -68,7 +68,7 @@ table_border_light = [ 59, 66, 82] table_border_strong = [ 76, 86, 106] table_header_bg = [ 59, 66, 82] table_header_text = [255, 255, 255] -table_row_bg = [ 0, 0, 0] +table_row_bg = [ 36, 41, 49] table_row_bg_alt = [ 46, 52, 64] text = [216, 222, 233] text_disabled = [116, 128, 150] diff --git a/themes/solarized_dark.toml b/themes/solarized_dark.toml index 842ec103..4d02ed13 100644 --- a/themes/solarized_dark.toml +++ b/themes/solarized_dark.toml @@ -68,8 +68,8 @@ table_border_light = [ 40, 40, 40] table_border_strong = [ 60, 60, 60] table_header_bg = [ 7, 54, 66] table_header_text = [255, 255, 255] -table_row_bg = [ 0, 0, 0] -table_row_bg_alt = [ 10, 10, 10] +table_row_bg = [ 0, 43, 54] +table_row_bg_alt = [ 7, 54, 66] text = [147, 161, 161] text_disabled = [ 88, 110, 117] text_link = [ 60, 100, 150]