Expand description
The motion clock: where spinners, travelling bars, shimmer and the
busy delay take their time from, instead of input.time directly.
now: the clock’s time, in seconds: the interface’s time, or a clock the application or a test gives (set_clock,freeze). A given clock moves only when told: a test freezes motion, steps it, and gets the same frames on every run;phase: where a looping animation is (0 to 1), static under reduced motion (motion.durationis 0) so spinners and bars give still frames;animate: asks for the next frame of an animation shown: never at once (a frame later, at most 60 a second; four a second while the window is not focused), never under reduced motion or a given clock;wake_atasks for the frame where something changes;Busy: the delayed busy indicator: nothing beforemotion.spinner.delay(300 ms), then shown at leastmotion.spinner.min(500 ms), counted from when the work started (a job’s or a command’s start, not when the widget was first drawn).
use egui_pop_core::motion::{self, Busy};
use egui_pop_model::clock::ManualClock;
let ctx = egui::Context::default();
let clock = ManualClock::new(0.0);
motion::set_clock(&ctx, Some(clock.shared()));
let id = egui::Id::new("export");
clock.set(0.29);
assert!(!Busy::new(id, 0.0).visible(&ctx, true), "not before 300 ms");
clock.set(0.31);
assert!(Busy::new(id, 0.0).visible(&ctx, true));
// The work ends at once: the indicator stays 500 ms.
clock.set(0.4);
assert!(Busy::new(id, 0.0).visible(&ctx, false));
clock.set(0.82);
assert!(!Busy::new(id, 0.0).visible(&ctx, false));Structs§
- Busy
- A delayed busy indicator for work that started at
since(motion clock seconds): shown after the delay, kept for the minimum once shown. Its state is kept per id.
Constants§
- BACKGROUND_
FRAME - Frames while the window is not focused.
- FRAME
- Frames of an animation, at most this often (seconds).
Functions§
- animate
- Asks for the next frame of an animation on screen: a frame later (never at once, so a headless harness settles), four a second while the window is not focused; nothing under reduced motion or a given clock.
- controlled
- Whether a clock was given (motion moves only when told).
- freeze
- Stops the motion clock at
atseconds; returns the clock, to step it by hand. - now
- Now, by the motion clock, in seconds.
- phase
- Where a looping animation of
periodseconds is, from 0 to 1;stillunder reduced motion. - reduced
- Whether motion is reduced (
motion.durationis 0): animations give still frames. - set_
clock - Gives the motion clock a clock of its own (the application’s, a
test’s), or gives it back the interface’s time (
None). - wake_at
- Asks for a frame when the motion clock reaches
at(seconds): the moment a delayed indicator shows, or work ends. Nothing under a given clock: it moves only when told, and whoever moves it asks for the frame.