Skip to content

GPU Layout: Complete theme integration #110

@Pluglug

Description

@Pluglug

Overview

Fully integrate with Blender's UI theme system for consistent appearance.

Current State

GPULayoutStyle.from_blender_theme() extracts some colors:

  • Background color
  • Text color
  • Outline color

Missing Integration

Button States

Blender themes define multiple button states:

theme = context.preferences.themes[0].user_interface
widget = theme.wcol_tool  # or wcol_regular, wcol_radio, etc.

# Available colors:
widget.inner           # Normal background
widget.inner_sel       # Selected/pressed background
widget.text            # Normal text
widget.text_sel        # Selected text
widget.outline         # Border
widget.item            # Icon tint

State Machine Colors

State 0: UP       → widget.inner
State 1: DOWN     → widget.inner_sel
State 2: HOVER    → tint(widget.inner, 0.2)
State 3: PRESSED  → widget.inner_sel
State 4: DISABLED → desaturate(widget.inner)

Widget Style Types

# Different widget appearances
theme.user_interface.wcol_regular   # Standard buttons
theme.user_interface.wcol_tool      # Tool buttons
theme.user_interface.wcol_radio     # Radio buttons
theme.user_interface.wcol_text      # Text input
theme.user_interface.wcol_option    # Checkboxes
theme.user_interface.wcol_toggle    # Toggle buttons
theme.user_interface.wcol_num       # Number inputs
theme.user_interface.wcol_numslider # Sliders
theme.user_interface.wcol_box       # Box containers
theme.user_interface.wcol_menu      # Menu items
theme.user_interface.wcol_pie_menu  # Pie menu items
theme.user_interface.wcol_tooltip   # Tooltips

Implementation

@dataclass
class WidgetColors:
    inner: tuple[float, float, float, float]
    inner_sel: tuple[float, float, float, float]
    text: tuple[float, float, float, float]
    text_sel: tuple[float, float, float, float]
    outline: tuple[float, float, float, float]
    
    @classmethod
    def from_theme(cls, widget_style: str = 'wcol_tool'):
        theme = bpy.context.preferences.themes[0].user_interface
        wcol = getattr(theme, widget_style)
        return cls(
            inner=tuple(wcol.inner),
            inner_sel=tuple(wcol.inner_sel),
            text=tuple(wcol.text),
            text_sel=tuple(wcol.text_sel),
            outline=tuple(wcol.outline),
        )

Acceptance Criteria

  • All button states use theme colors
  • Support different widget style types
  • Hover/press colors derived from theme
  • Disabled state appearance
  • Works with custom Blender themes

Parent Issue

Part of #104 (GPU Layout System tracking)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestui/uxUser interface and experience

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions