feat(ui): Implement Subtle Rounding professional theme

This commit is contained in:
2026-03-08 21:55:35 -04:00
parent c6dd055da8
commit 59e14533f6
2 changed files with 59 additions and 3 deletions

View File

@@ -204,18 +204,39 @@ def get_current_scale() -> float:
def apply(palette_name: str) -> None: 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. 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. In practice we call it once when the user picks a palette, and imgui retains the style.
""" """
global _current_palette global _current_palette
_current_palette = palette_name _current_palette = palette_name
colours = _PALETTES.get(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: if not colours:
# Reset to imgui dark defaults # Reset to imgui dark defaults
imgui.style_colors_dark() imgui.style_colors_dark()
return return
style = imgui.get_style()
# Start from dark defaults so unlisted keys have sensible values # Start from dark defaults so unlisted keys have sensible values
imgui.style_colors_dark() imgui.style_colors_dark()
for col_enum, rgba in colours.items(): for col_enum, rgba in colours.items():

35
tests/test_theme.py Normal file
View File

@@ -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