Struct Theme
pub struct Theme {Show 19 fields
pub name: String,
pub document: ThemeDocument,
pub tokens: Tokens,
pub border_standard: AlphaColor<Srgb>,
pub border_focus: AlphaColor<Srgb>,
pub text_primary: AlphaColor<Srgb>,
pub text_dim: AlphaColor<Srgb>,
pub text_tertiary: AlphaColor<Srgb>,
pub status_success: AlphaColor<Srgb>,
pub radius_standard: f64,
pub padding_standard: f32,
pub gap_standard: f32,
pub reduce_motion: bool,
pub reduce_transparency: bool,
pub text_scale: f32,
pub ui_scale: f32,
pub caret_width: f64,
pub forced_colors: bool,
pub surface: Option<SurfaceShape>,
}Fields§
§name: String§document: ThemeDocumentThe document this theme was built from, as applied: after the workspace temperature and high contrast.
tokens: Tokens§border_standard: AlphaColor<Srgb>§border_focus: AlphaColor<Srgb>The focus ring: the person’s own colour (crate::tokens::Intents::you).
text_primary: AlphaColor<Srgb>§text_dim: AlphaColor<Srgb>Second tier of the type hierarchy (captions, sub-labels).
text_tertiary: AlphaColor<Srgb>Quietest legible tier (timestamps, hints), below Theme::text_dim.
status_success: AlphaColor<Srgb>§radius_standard: f64The control radius (crate::tokens::Radii::control).
padding_standard: f32§gap_standard: f32§reduce_motion: boolCarried on the theme (not passed through draw) so every widget
reacts without new plumbing. Default false.
reduce_transparency: boolFloating chrome draws its material opaque instead of over the blurred
backdrop (crate::floating_surface::Material). Default false.
text_scale: f321.0 = default. Baked into every Theme::text role by
Theme::with_text_scale; kept here too so a widget can scale a
size it computes itself.
ui_scale: f32The “make everything bigger” knob — spacing, radii, and type scale
together, distinct from Theme::text_scale (type only). Baked in
by Theme::with_ui_scale. Composes with the compositor’s
per-output device scale: physical size = logical × ui_scale ×
device-scale, text additionally × text_scale.
caret_width: f64Width of an insertion caret in logical pixels. The configured theme folds in the accessibility preference once, keeping file I/O out of widget draw paths.
forced_colors: boolHigh contrast or forced colours is the active track. Content surfaces
ask Theme::colors_are_forced instead of comparing Theme::name.
surface: Option<SurfaceShape>The shape of the surface the window is drawn on, in the coordinates
of the scene being drawn, when its host says: rounded at the radius
the compositor draws the window with, square while it is drawn edge
to edge. None when no host said; nothing then keeps out of corners.
Set where the window is drawn, not part of the configured theme.
Implementations§
§impl Theme
impl Theme
pub const ALL: [&'static str; 14]
pub const ALL: [&'static str; 14]
Every theme Tilo ships, by the name Theme::named resolves.
Exists so a check can be run against all of them rather than against whichever two someone remembered.
pub fn refusal(document: &ThemeDocument) -> Option<String>
pub fn refusal(document: &ThemeDocument) -> Option<String>
Why document is not a theme this build can show, as the person or
the theme’s author reads it: the schema, an out-of-band role, or a
surface shader that is not a surface shader. None when it is a
theme.
pub fn from_document(document: &ThemeDocument) -> Option<Theme>
pub fn from_document(document: &ThemeDocument) -> Option<Theme>
The theme a document describes, or None for one this build does not
admit (Self::refusal, which names why). Values outside a role’s
usable band are clamped, and a pairing that misses a contrast floor
is repaired, so every theme that materializes is legible.
pub fn light() -> Theme
pub fn high_contrast() -> Theme
pub fn high_contrast() -> Theme
Black ground under near-white ink, every text pairing at WCAG AAA.
Selected when A11ySettings::high_contrast
is set on a dark theme.
pub fn on_content(&self) -> OnSurface
pub fn on_content(&self) -> OnSurface
Ink tiers on the content surface — the window ground every app paints on.
pub fn region(&self, region: Region) -> AlphaColor<Srgb>
pub fn region(&self, region: Region) -> AlphaColor<Srgb>
The ground of region (HIG §9.2): surfaces.content,
surfaces.sidebar or surfaces.inspector. The framework paints it
(crate::surface::region); a caller reads it to measure against.
pub fn on_ground(&self, ground: AlphaColor<Srgb>) -> Theme
pub fn on_ground(&self, ground: AlphaColor<Srgb>) -> Theme
This theme as seen by a widget standing on ground: a region tier, a
raised well, a document’s paper. surfaces.content becomes ground,
the text tiers are re-measured against it (Self::on_surface) and
the selection lift steps from it, so a widget that paints “ink on
the window ground” or “the selected row” is right on whatever ground
its container handed it. surfaces.raised stays off the ground
(crate::tokens::Colors::raised_on), so a control’s face never
sinks into a lighter panel. When ground has the other polarity
from the palette (the near-black media.letterbox under a light
theme) and the emphasis is inverted, the primary fill is re-derived
too: primary ink on that ground as the fill and the ground as its
label, so a Primary button over media still reads. Every other
token is unchanged.
pub fn in_region(&self, region: Region) -> Theme
pub fn in_region(&self, region: Region) -> Theme
Self::on_ground for one of the window’s regions.
pub fn on_surface(&self, surface: AlphaColor<Srgb>) -> OnSurface
pub fn on_surface(&self, surface: AlphaColor<Srgb>) -> OnSurface
Self::on_content for any surface a widget actually paints on — a
document’s paper, a tinted placeholder box, a chart panel. See
crate::tokens::Colors::on_surface for why the surface is a
parameter.
pub fn on_surface_at(
&self,
surface: AlphaColor<Srgb>,
min_ratio: f64,
) -> OnSurface
pub fn on_surface_at( &self, surface: AlphaColor<Srgb>, min_ratio: f64, ) -> OnSurface
Self::on_surface against a caller-chosen contrast floor.
pub fn window_edge(&self) -> AlphaColor<Srgb>
pub fn window_edge(&self) -> AlphaColor<Srgb>
See crate::tokens::Colors::window_edge for why it’s derived from
the desktop ground rather than a constant.
pub fn with_neutral_hue(self, hue: f32) -> Theme
pub fn with_neutral_hue(self, hue: f32) -> Theme
The same theme in a workspace whose temperature is hue (OKLCH
degrees). Only the neutral material’s hue moves — never its chroma,
so a palette with chroma 0 (the default dark) shows no temperature
at all, and the light palette, pure grey until now, takes its
chroma at this hue. Presence, status, emphasis and the person’s own
colour keep their hues, and every contrast promise holds at every
hue. A workspace’s temperature comes from workspace_hue.
pub fn with_your_colour(self, hue: PresenceHue) -> Theme
pub fn with_your_colour(self, hue: PresenceHue) -> Theme
The person’s own colour becomes their focus ring, text caret and
text-selection tint, painted at this theme’s presence lightness and
chroma. A colour is identity, not theme: the host that knows who sits
here applies it (PresenceHue::chosen_in, PresenceHue::of_identity).
pub fn with_high_contrast(self) -> Theme
pub fn with_high_contrast(self) -> Theme
The same theme on the high-contrast palette of its polarity: shape, density, type and motion stay, the person keeps their colour, and content surfaces are asked to force their colours.
pub fn configured() -> Theme
pub fn configured() -> Theme
Reads the person’s settings ([settings_store::load]), the shared
preference Settings and Theme Studio update through their respective
domain stores. Absent and unrecognised both mean the dark default — a
machine with no preference wants a desktop that starts.
pub fn configured_from(settings: &Map<String, Value>) -> Theme
pub fn configured_from(settings: &Map<String, Value>) -> Theme
Theme::configured from an explicit settings document.
pub fn configured_accessibility() -> AccessibilityLayer
pub fn configured_accessibility() -> AccessibilityLayer
The accessibility comforts the person chose in this process’s
settings document (the installed source, else the settings file), with
what the launcher requested (crate::host::environment()) on top:
high contrast, text size, interface scale and reduced motion. The
layer Theme::configured leaves to its host, which applies it over
that theme on every settings change, so a change in Settings reaches a
running window without a restart.
pub fn configured_comforts() -> ConfiguredComforts
pub fn configured_comforts() -> ConfiguredComforts
Self::configured_accessibility, saying which comforts the
document names at all: a host keeps its own value for one it does not.
pub fn accessibility_in(
document: &Value,
requested: AccessibilityInputs,
) -> AccessibilityLayer
pub fn accessibility_in( document: &Value, requested: AccessibilityInputs, ) -> AccessibilityLayer
Self::configured_accessibility of an explicit settings document
and launch request.
pub fn comforts_in(
document: &Value,
requested: AccessibilityInputs,
) -> ConfiguredComforts
pub fn comforts_in( document: &Value, requested: AccessibilityInputs, ) -> ConfiguredComforts
Self::configured_comforts of an explicit settings document and
launch request. The launcher’s request is a floor for contrast and
motion (it can add them, never take them away) and gives the scales
until the document names its own: the document is the person’s
current choice, the request a copy of it from when the window opened.
A layer this build rejects names nothing.
pub fn from_settings_json(text: &str) -> Option<Theme>
pub fn from_settings_json(text: &str) -> Option<Theme>
The user’s theme in a settings document, if it names one this build admits. Automatic mode resolves against the local time now.
pub fn from_settings_json_at(text: &str, moment: LocalMoment) -> Option<Theme>
pub fn from_settings_json_at(text: &str, moment: LocalMoment) -> Option<Theme>
Self::from_settings_json at an explicit local moment: automatic
mode is the light theme by day and the dark theme by night, on the
schedule night light shares (settings_store::day_schedule).
pub fn automatic_schedule_from(
document: &Map<String, Value>,
) -> Option<Scheduled>
pub fn automatic_schedule_from( document: &Map<String, Value>, ) -> Option<Scheduled>
The day/night schedule an automatic appearance in document follows,
or None when the mode is fixed. Hosts keep it to notice sunrise and
sunset, which change the theme without changing the settings.
pub fn named(name: &str) -> Option<Theme>
pub fn named(name: &str) -> Option<Theme>
A shipped theme by id or name, loosely (Preset::find), so the
same lookup serves a picker, the persisted preference and the
--shots theme override. None for an unknown name.
pub fn motion(&self) -> EffectiveMotion
pub fn motion(&self) -> EffectiveMotion
The motion widgets may play: the motion tokens with reduced motion
applied. Every motion decision reads this, never reduce_motion
alongside raw durations, so the rule lives in one place.
pub fn with_reduce_motion(self, on: bool) -> Theme
pub fn finish(&self, role: SurfaceRole) -> &Finish
pub fn finish(&self, role: SurfaceRole) -> &Finish
The finish role is painted in: the theme’s, made opaque under
reduced transparency (a flat finish stays flat, a theme’s own set
keeps drawing opaque), and the toolkit’s own under forced colours,
whose guarantees are not a theme’s set to keep.
pub fn chrome_material(&self, material: ChromeMaterial) -> Finish
pub fn chrome_material(&self, material: ChromeMaterial) -> Finish
The finish the shell’s chrome — its bar and its dock — is made of, as the person chose
it (crate::tokens::ChromeMaterial): the bar’s own body (the stock themes’ glass),
the theme’s glass (its bar material, else its floating material, so a theme without a
bar material still gives the glass style something to be), or that glass with nothing
showing through and every light off it.
The same rules as Self::finish apply to each: forced colours draw the toolkit’s
own solid, and reduced transparency makes the glass calm.
pub fn painter(&self, role: SurfaceRole) -> &PainterSet
pub fn painter(&self, role: SurfaceRole) -> &PainterSet
The painter set drawing role’s parts: its finish’s.
pub fn with_painter_set(
self,
role: SurfaceRole,
set: PainterSet,
) -> Result<Theme, &'static str>
pub fn with_painter_set( self, role: SurfaceRole, set: PainterSet, ) -> Result<Theme, &'static str>
This theme with set drawing role’s parts, with none of its
parameters stated. Err where the set requires one.
pub fn with_reduce_transparency(self, on: bool) -> Theme
pub fn with_text_scale(self, factor: f32) -> Theme
pub fn with_text_scale(self, factor: f32) -> Theme
1.0 = unchanged. Multiplies the whole type scale and base body
size together, so layout (which measures the same scaled sizes)
grows to fit and nothing clips. Not assumed idempotent — call once
on a fresh theme.
pub fn at_unit_text_scale(&self) -> Theme
pub fn at_unit_text_scale(&self) -> Theme
This theme with the accessibility text scale taken back out: type at
its 1× sizes (glyphs too), everything else unchanged. For content whose size is
the document’s own (a slide’s text, laid out at the slide’s size and
then scaled as a whole), which must not grow a second time with the
reader’s text setting. Theme::with_text_scale multiplies, so it
cannot undo a scale already applied.
pub fn document_zoom(width: f64, page: f64) -> f32
pub fn document_zoom(width: f64, page: f64) -> f32
How much larger a document draws its text in a pane width wide,
whose page (reading column and its gutters) is page wide at this
theme’s size: 1.0 until the pane is DOCUMENT_ROOM pages wide,
then growing with the pane up to MAX_DOCUMENT_ZOOM, in steps of a
sixteenth so resizing a window re-sets the text about once per pixel
of type size rather than every frame.
A page at its laptop size in a window on a large display is a narrow strip of small text in a field of empty space; grown, it keeps its measure and fills the screen the way a page held closer would. A laptop or phone window is never wide enough to grow it.
pub fn with_document_zoom(&self, zoom: f32) -> Theme
pub fn with_document_zoom(&self, zoom: f32) -> Theme
This theme with its type grown by zoom on top of the reader’s own
text scale (Theme::document_zoom); 1.0 is this theme.
pub fn with_ui_scale(self, factor: f32) -> Theme
pub fn with_ui_scale(self, factor: f32) -> Theme
1.0 = unchanged. Multiplies spacing, radii, and type together,
distinct from Theme::with_text_scale which only resizes type.
Not assumed idempotent — call once on a fresh theme.
pub fn with_density(self, density: Density) -> Theme
pub fn with_density(self, density: Density) -> Theme
The same theme at density (crate::tokens::Density): compact
scales the spacing rhythm by 0.75 and shortens rows to 28 / 44 / 52;
control heights and text stay. Set per window or per region (a
sidebar, a table): a data-heavy app lays its content region out with
theme.with_density(Density::Compact).
pub fn text_growth(&self) -> f32
pub fn text_growth(&self) -> f32
crate::tokens::Metrics::text_growth of this
theme’s Theme::text_scale: how much a text-sized extent grows, never
below 1.
pub fn responsive_scale(&self) -> f64
pub fn responsive_scale(&self) -> f64
The one factor the responsive shells multiply an authored,
text-sized breakpoint or pane width by: ui_scale × text_growth().
NavShell grows its metric widths by it, and a painted app’s
SidebarDrawer its authored ones (breakpoint(760.0)), so at 200 %
text a 760 px breakpoint pushes at 1520 px — the window that has the
room a 760 px window has at 1× — without the app multiplying
anything. 1.0 on a stock theme, so 1× geometry is untouched. A width
sized by icons rather than text (a rail) follows Theme::ui_scale
alone.
pub fn with_a11y(
self,
settings: &A11ySettings,
text_scale: f32,
ui_scale: f32,
) -> Theme
pub fn with_a11y( self, settings: &A11ySettings, text_scale: f32, ui_scale: f32, ) -> Theme
UI scale first so it grows the whole system, then text scale layers additional type growth on top. High contrast keeps the theme’s polarity, shape, density and type, and the person’s own colour.
§impl Theme
impl Theme
pub fn in_window(self, appearance: &WindowAppearance) -> Theme
pub fn in_window(self, appearance: &WindowAppearance) -> Theme
This theme as the window appearance describes sees it: the
workspace’s temperature on the neutrals (nothing on a palette with
chroma 0, nothing while there is no temperature) and the person’s
colour as focus ring, caret and selection. Both are applied to the
theme as configured, so a window moving to a neutral workspace loses
the temperature of the one it left.
§impl Theme
impl Theme
pub fn colors_are_forced(&self) -> bool
pub fn colors_are_forced(&self) -> bool
Whether accessibility is forcing colours onto content surfaces.
pub fn content_surface(&self) -> ContentSurface
pub fn content_surface(&self) -> ContentSurface
Ask “am I forced?” and, when yes, paint the page from these tokens.
pub fn resolved_from_settings(text: &str) -> Theme
pub fn resolved_from_settings(text: &str) -> Theme
resolve_theme_layers for a settings document, including file
scales and reduced motion. Theme::configured leaves scales and
reduced motion to the host instead.
§impl Theme
impl Theme
pub fn text(&self, role: TextRole) -> TextStyle
pub fn text(&self, role: TextRole) -> TextStyle
The resolved style of role in this theme: face, size, weight and
leading, with the UI and text scale already applied. Measure and draw
with the same value through crate::text_render::TextRenderer::measure_style
and crate::text_render::TextRenderer::draw_style (or the
crate::paint::PaintCtx role helpers).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Theme
impl !RefUnwindSafe for Theme
impl Send for Theme
impl Sync for Theme
impl Unpin for Theme
impl UnsafeUnpin for Theme
impl !UnwindSafe for Theme
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more