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:
+2 -2
View File
@@ -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]
+1 -1
View File
@@ -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]
+1 -1
View File
@@ -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]
+2 -2
View File
@@ -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]