Expand description
Env: the host facts a frame driver pushes into the core, which a
view reads back with ui.env().
The core never touches a window. The driver (a runner, an FFI host)
reports what it knows: the refresh rate and whether the window has
focus (Env), the window’s own facts (WindowEnv), and the user’s
OS settings (SystemEnv: appearance, accent, reduced motion, locale,
assistive technology). A view reads them and decides; the core acts on
none of them except to derive the Theme from
the appearance and accent.
Every fact under SystemEnv can be unknown, and unknown is the
default. A driver that cannot ask the OS says so rather than guessing,
and a headless Core reports unknown for all
of them.
use kui_core::{Core, Env, MotionPref, Size};
let mut core = Core::new();
let ui = core.frame(Size::new(100.0, 100.0), 1.0);
let env: Env = ui.env();
assert_eq!(env.system.motion, MotionPref::Unknown); // headless: nobody said
assert!(env.frame_budget_ms() > 0.0);
ui.finish();Structs§
- Audio
Env - What the driver’s audio output is doing, for views to read. A fact, not a verb: nothing here lets a view close the device, which stays the driver’s decision (it closes an idle one itself, after a while).
- Env
- What the host knows about the display/window. Defaults are safe for headless drivers (tests, benches) that never set anything.
- Locale
- A language tag as the host reports it —
"en","en-US","zh-Hans-CN". Carried inline rather than as aStringsoEnvstaysCopy: a view readsui.env()every frame, and a tag that allocated would allocate on every one of them. - System
Env - The user’s OS settings, as the host reports them. Not window facts and
not display facts: things the person chose once, in a settings app, that
a view is expected to honour. The core acts on two of them in one way:
appearanceandaccentderive the theme, so the stock widgets and a<text>with no colour follow the OS — and nothing else moves. Reduced motion does not shorten an animation and a dark appearance repaints none of the app’s own colours: the view decides, because only it knows which of its colours is the background and which of its animations carries meaning.
Enums§
- Appearance
- The OS light/dark setting.
Unknownis a real answer — a host with no way to ask says it, and a view that has one palette per appearance picks its own default for it rather than being handed a guess. - Assistive
- Whether assistive technology is listening: the difference between an
alert that blinks and one that announces.
Listeningis “an accessibility client has asked this window for its tree”, which is the one signal the platform adapters give and the moment the runner starts deriving trees.Noneis “the bridge is up and nobody has asked”;Unknownis “there is no bridge” — a headless core, a driver built without theaccesskitfeature, a C host that never called the setter. - Audio
Device - The output device’s state.
Closedis the default and what a headless driver reports;Openingis the ~90 ms the open takes on its own thread;Failedis a device that refused to open, after which commands are dropped. - Motion
Pref - The OS reduce-motion setting:
Reducedis “the user asked for less animation”,Fullis “the user did not”,Unknownis “nobody asked the OS”. Spelled as what the user wants rather than as areduce_motionboolean because the third reading has no place in a boolean, and a missing answer is not the same as a “no”.