feat(config): Implement parsing for shader and window frame configurations

This commit is contained in:
2026-03-13 12:41:24 -04:00
parent 830bd7b1fb
commit d69434e85f
2 changed files with 42 additions and 0 deletions

View File

@@ -268,6 +268,12 @@ _current_palette: str = "DPG Default"
_current_font_path: str = ""
_current_font_size: float = 14.0
_current_scale: float = 1.0
_shader_config: dict[str, Any] = {
"crt": False,
"bloom": False,
"bg": "none",
"custom_window_frame": False,
}
# ------------------------------------------------------------------ public API
@@ -286,6 +292,14 @@ def get_current_font_size() -> float:
def get_current_scale() -> float:
return _current_scale
def get_shader_config(key: str) -> Any:
"""Get a specific shader configuration value."""
return _shader_config.get(key)
def get_window_frame_config() -> bool:
"""Get the window frame configuration."""
return _shader_config.get("custom_window_frame", False)
def get_palette_colours(name: str) -> dict[str, Any]:
"""Return a copy of the colour dict for the named palette."""
return dict(_PALETTES.get(name, {}))
@@ -388,4 +402,9 @@ def load_from_config(config: dict[str, Any]) -> None:
if font_path:
apply_font(font_path, font_size)
set_scale(scale)
global _shader_config
_shader_config["crt"] = t.get("shader_crt", False)
_shader_config["bloom"] = t.get("shader_bloom", False)
_shader_config["bg"] = t.get("shader_bg", "none")
_shader_config["custom_window_frame"] = t.get("custom_window_frame", False)

View File

@@ -0,0 +1,23 @@
import pytest
from unittest.mock import patch
from src import theme
def test_shader_config_parsing():
config = {
"theme": {
"shader_crt": True,
"shader_bloom": False,
"shader_bg": "noise",
"custom_window_frame": True
}
}
with patch("src.theme.apply"), \
patch("src.theme.apply_font"), \
patch("src.theme.set_scale"):
theme.load_from_config(config)
assert theme.get_shader_config("crt") is True
assert theme.get_shader_config("bloom") is False
assert theme.get_shader_config("bg") == "noise"
assert theme.get_window_frame_config() is True