ltk::theme

Module active

Source
Expand description

Process-wide active theme state.

The active document is published once and read by every per-slot accessor in crate::theme. First access triggers a disk load of the default theme; if that fails, an embedded B/W document takes over and the is_fallback_active flag flips on so the draw layer can paint a warning banner.

Functions§

  • The currently loaded theme document. Use this for slot-typed lookups when the per-slot helpers (crate::theme::color, crate::theme::surface(), …) are not expressive enough — e.g. iterating mode.slots.entries.
  • The active variant (light or dark).
  • The id of the active theme.
  • true when the active theme was produced by the embedded B/W fallback because ThemeDocument::find("default") failed at first-access. Flipped back to false the moment a consumer calls set_active_document with any document (even another call to the same fallback — the point is “this state came from an explicit install, not from the missing-theme code path”).
  • Install doc as the active theme. The current mode is preserved (defaulting to ThemeMode::Light if nothing was set yet). Also clears the fallback flag — an explicit install supersedes the embedded B/W document and the warning banner stops painting from the next frame on.
  • Switch the active variant. The document is left untouched — if nothing has been loaded yet, the default theme is loaded first.