Private
Public Access
0
0

fix(theme): robust get_color fallback and Solarized Dark table colors

This commit is contained in:
2026-06-05 01:01:03 -04:00
parent 98acc12811
commit 3ed2b3966c
5 changed files with 30 additions and 13 deletions
+24 -7
View File
@@ -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: