Struct UiTheme

Source
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

Source

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.

Source

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.

Source

pub fn mode(self) -> ThemeMode

Source

pub fn types(self) -> TypeScale

Source

pub fn spacing(self) -> Spacing

Source

pub fn palette(self) -> Palette

Source

pub fn color(self, role: ColorRole) -> Color

Source

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.

Source

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.

Source

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.

Source

pub fn text(self, role: TextRole) -> TextTokens

Source

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.

Trait Implementations§

Source§

impl Clone for UiTheme

Source§

fn clone(&self) -> UiTheme

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UiTheme

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for UiTheme

Source§

fn eq(&self, other: &UiTheme) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for UiTheme

Source§

impl StructuralPartialEq for UiTheme

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.