pub struct Theme { /* private fields */ }Expand description
A theme with common semantic tokens and canonical component presentations.
A theme carries no application-specific slot. Applications extend it by
implementing TextThemeRole for their own role type and deriving the style
inside TextThemeRole::resolve; see the module documentation for the
conventions that follow from that.
Implementations§
Source§impl Theme
impl Theme
pub fn from_tokens(tokens: SemanticTokens) -> Self
pub fn new(tokens: SemanticTokens, components: ComponentTheme) -> Self
pub fn tokens(&self) -> &SemanticTokens
pub fn components(&self) -> &ComponentTheme
Sourcepub fn list<T>(&self, list: &List<T>) -> Viewwhere
T: Display,
pub fn list<T>(&self, list: &List<T>) -> Viewwhere
T: Display,
Composes a list with this theme’s canonical presentation.
Sourcepub fn tree<T>(&self, tree: &Tree<T>) -> Viewwhere
T: Display,
pub fn tree<T>(&self, tree: &Tree<T>) -> Viewwhere
T: Display,
Composes a tree with this theme’s canonical presentation.
Sourcepub fn table<T>(&self, table: &Table<T>) -> Viewwhere
T: TableRow,
pub fn table<T>(&self, table: &Table<T>) -> Viewwhere
T: TableRow,
Composes a table with this theme’s canonical presentation.
Sourcepub fn scrollbar(&self, scrollbar: &Scrollbar) -> View
pub fn scrollbar(&self, scrollbar: &Scrollbar) -> View
Composes a scrollbar with this theme’s canonical presentation.
Sourcepub fn text_style<R>(&self, role: R) -> TextStylewhere
R: TextThemeRole,
pub fn text_style<R>(&self, role: R) -> TextStylewhere
R: TextThemeRole,
Resolves one role against this theme.
The style is returned by value because application roles derive their
style rather than reading it from a stored table. Consumers that resolve
roles inside a draw loop should resolve once into their own cache and
borrow from it; Theme::components also exposes built-in styles as
borrows.
Sourcepub fn block_style<R>(&self, role: R) -> BlockStylewhere
R: BlockThemeRole,
pub fn block_style<R>(&self, role: R) -> BlockStylewhere
R: BlockThemeRole,
Resolves one geometry-bearing role against this theme.