refactor(theme): Introduce semantic theme layer and clean NERV cruft from gui_2.py

This commit is contained in:
2026-05-12 20:24:47 -04:00
parent b53fc19f99
commit 12465fd04c
4 changed files with 450 additions and 393 deletions
+25
View File
@@ -10,7 +10,11 @@ Scale uses imgui.get_style().font_scale_main.
from imgui_bundle import imgui, hello_imgui
from typing import Any, Optional
from contextlib import nullcontext
from src import imgui_scopes as imscope
import src.theme_nerv
from src.theme_nerv import DATA_GREEN
from src.theme_nerv_fx import CRTFilter, AlertPulsing, StatusFlicker
# ------------------------------------------------------------------ palettes
@@ -239,6 +243,10 @@ _current_scale: float = 1.0
_transparency: float = 1.0
_child_transparency: float = 1.0
_crt_filter = CRTFilter()
_alert_pulsing = AlertPulsing()
_status_flicker = StatusFlicker()
# ------------------------------------------------------------------ public API
def get_current_palette() -> str:
@@ -396,3 +404,20 @@ def get_tweaked_theme() -> hello_imgui.ImGuiTweakedTheme:
# Sync tweaks
tt.tweaks.rounding = 6.0
return tt
def ai_text_color() -> imgui.ImVec4:
"""Returns DATA_GREEN if NERV is active, otherwise standard text color."""
if is_nerv_active():
return imgui.ImVec4(*DATA_GREEN)
return imgui.get_style().color_(imgui.Col_.text)
def ai_text_style():
"""Context manager for AI response text styling."""
return imscope.style_color(imgui.Col_.text, ai_text_color())
def render_post_fx(width: float, height: float, ai_status: str, crt_enabled: bool) -> None:
"""Updates and renders the alert and CRT filters."""
_alert_pulsing.update(ai_status)
_alert_pulsing.render(width, height)
_crt_filter.enabled = crt_enabled
_crt_filter.render(width, height)