pub struct UiTheme { /* private fields */ }Expand description
Validated metrics/palette with checked atomic edits. Fixed value storage; create/copy/reset per consumer, with no retained history or heap allocation.
Implementations§
Source§impl UiTheme
impl UiTheme
Sourcepub fn preset(mode: ThemeMode) -> UiTheme
pub fn preset(mode: ThemeMode) -> UiTheme
Explicit authored presets: label 16/body 18/heading 24, inset 16/gap 12/ compact gap 8/control height 44/stroke 2 in BOTH modes. Normal text roles require 4.5:1, high-contrast text roles 7:1; Focus/Border require 3:1 and 4.5:1 respectively on Canvas and Surface independently. These thresholds are token policy, not whole-renderer conformance/physical readability.
Sourcepub fn try_new(
mode: ThemeMode,
types: TypeScale,
spacing: Spacing,
palette: Palette,
) -> Result<UiTheme, ThemeError>
pub fn try_new( mode: ThemeMode, types: TypeScale, spacing: Spacing, palette: Palette, ) -> Result<UiTheme, ThemeError>
Validate a complete authored choice; see Palette’s executable example.
pub fn mode(self) -> ThemeMode
pub fn types(self) -> TypeScale
pub fn spacing(self) -> Spacing
pub fn palette(self) -> Palette
pub fn color(self, role: ColorRole) -> Color
Sourcepub fn role_contrast(
self,
a: ColorRole,
b: ColorRole,
) -> Result<f64, ThemeError>
pub fn role_contrast( self, a: ColorRole, b: ColorRole, ) -> Result<f64, ThemeError>
Inspect any actual token pair, including pairs outside required roles. This measures, rather than makes the pair pass policy.
Sourcepub fn set_colors(
&mut self,
edits: &[(ColorRole, Color)],
) -> Result<(), ThemeError>
pub fn set_colors( &mut self, edits: &[(ColorRole, Color)], ) -> Result<(), ThemeError>
Override at most COLOR_ROLE_COUNT distinct roles. Related background/
foreground edits may be adopted together. Duplicate/capacity/color/pair
failure leaves self intact; empty edits succeed unchanged. See module recipe.
Sourcepub fn set_metrics(
&mut self,
types: TypeScale,
spacing: Spacing,
) -> Result<(), ThemeError>
pub fn set_metrics( &mut self, types: TypeScale, spacing: Spacing, ) -> Result<(), ThemeError>
Adopt type/spacing together before layout/paint/hit rebuild. Invalid metrics leave both unchanged. No fitting/scaling occurs here.
pub fn text(self, role: TextRole) -> TextTokens
Sourcepub fn state(self, state: ThemeState) -> StateTokens
pub fn state(self, state: ThemeState) -> StateTokens
State foregrounds plus non-color guidance for cards/meters/inspectors. Focus color is for non-text outlines; accompanying labels stay in Text. Nothing automatically draws cues or changes authoritative game state.