ltk::theme

Module accessors

Source
Expand description

Slot-typed shorthand accessors against the active theme document.

Widgets speak in terms of slot ids. The plumbing for “which document is active” and “which mode” is captured here so widget code stays free of that plumbing.

Functions§

  • Resolve a colour slot in the active mode. None when the slot is missing, empty, or not a Slot::Color (use paint() if a gradient should also be acceptable).
  • Like color but returns fallback when the slot is missing. The typical pattern for widgets that must always paint something.
  • Resolve a paint slot (solid or gradient) in the active mode. A plain Slot::Color is promoted to Paint::Solid. None for missing or non-paintable slots (e.g. a text-style).
  • The eight canonical palette slots of the active mode projected as a Palette struct. This is a one-call shortcut equivalent to Palette::from_slots(&active_document().mode(active_mode()).slots), covering the common case where a widget needs text_primary / surface / accent / etc. without picking specific slot ids.
  • Resolve a surface slot together with its outer shadow stack.
  • Resolve an elevation (outer-shadow stack) slot in the active mode. The returned Vec is a freshly cloned copy so call sites can hold it across frames without borrowing the global state.
  • Resolve a surface slot in the active mode. A colour or paint slot promotes to a surface with that fill and no decorations; a full surface slot returns unchanged.
  • Resolve a typography slot in the active mode. Cloned so the result can outlive the global-state borrow.
  • The active mode’s window-controls payload, derived from slots if the document did not declare an explicit block.