From 59e14533f655bd7b0df94618e0d3de053b284ca9 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 8 Mar 2026 21:55:35 -0400 Subject: [PATCH] feat(ui): Implement Subtle Rounding professional theme --- src/theme_2.py | 27 ++++++++++++++++++++++++--- tests/test_theme.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 tests/test_theme.py diff --git a/src/theme_2.py b/src/theme_2.py index cc42a35..f2ef0eb 100644 --- a/src/theme_2.py +++ b/src/theme_2.py @@ -204,18 +204,39 @@ def get_current_scale() -> float: def apply(palette_name: str) -> None: """ - Apply a named palette by setting all ImGui style colors. + Apply a named palette by setting all ImGui style colors and applying global professional styling. Call this once per frame if you want dynamic switching, or once at startup. In practice we call it once when the user picks a palette, and imgui retains the style. """ global _current_palette _current_palette = palette_name colours = _PALETTES.get(palette_name, {}) + style = imgui.get_style() + + # Subtle Rounding Professional Theme + style.window_rounding = 6.0 + style.child_rounding = 4.0 + style.frame_rounding = 4.0 + style.popup_rounding = 4.0 + style.scrollbar_rounding = 12.0 + style.grab_rounding = 4.0 + style.tab_rounding = 4.0 + style.window_border_size = 1.0 + style.frame_border_size = 1.0 + style.popup_border_size = 1.0 + + # Spacing & Padding + style.window_padding = imgui.ImVec2(8.0, 8.0) + style.frame_padding = imgui.ImVec2(8.0, 4.0) + style.item_spacing = imgui.ImVec2(8.0, 4.0) + style.item_inner_spacing = imgui.ImVec2(4.0, 4.0) + style.scrollbar_size = 14.0 + if not colours: - # Reset to imgui dark defaults + # Reset to imgui dark defaults imgui.style_colors_dark() return - style = imgui.get_style() + # Start from dark defaults so unlisted keys have sensible values imgui.style_colors_dark() for col_enum, rgba in colours.items(): diff --git a/tests/test_theme.py b/tests/test_theme.py new file mode 100644 index 0000000..b2aca12 --- /dev/null +++ b/tests/test_theme.py @@ -0,0 +1,35 @@ +import pytest +from unittest.mock import MagicMock +from src import theme_2 as theme + +def test_theme_apply_sets_rounding_and_padding(monkeypatch): + # Mock imgui + mock_style = MagicMock() + mock_imgui = MagicMock() + mock_imgui.get_style.return_value = mock_style + mock_imgui.ImVec2.side_effect = lambda x, y: (x, y) + monkeypatch.setattr(theme, "imgui", mock_imgui) + + # Call apply with the default palette + theme.apply("ImGui Dark") + + # Verify subtle rounding styles + assert mock_style.window_rounding == 6.0 + assert mock_style.child_rounding == 4.0 + assert mock_style.frame_rounding == 4.0 + assert mock_style.popup_rounding == 4.0 + assert mock_style.scrollbar_rounding == 12.0 + assert mock_style.grab_rounding == 4.0 + assert mock_style.tab_rounding == 4.0 + + # Verify borders + assert mock_style.window_border_size == 1.0 + assert mock_style.frame_border_size == 1.0 + assert mock_style.popup_border_size == 1.0 + + # Verify padding/spacing + assert mock_style.window_padding == (8.0, 8.0) + assert mock_style.frame_padding == (8.0, 4.0) + assert mock_style.item_spacing == (8.0, 4.0) + assert mock_style.item_inner_spacing == (4.0, 4.0) + assert mock_style.scrollbar_size == 14.0