From d69434e85f089bf65a53d3a3bb5c14fa302de395 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Fri, 13 Mar 2026 12:41:24 -0400 Subject: [PATCH] feat(config): Implement parsing for shader and window frame configurations --- src/theme.py | 19 +++++++++++++++++++ tests/test_shader_config.py | 23 +++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/test_shader_config.py diff --git a/src/theme.py b/src/theme.py index 48bec5a..38fd4a3 100644 --- a/src/theme.py +++ b/src/theme.py @@ -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) diff --git a/tests/test_shader_config.py b/tests/test_shader_config.py new file mode 100644 index 0000000..7a10d31 --- /dev/null +++ b/tests/test_shader_config.py @@ -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