pub struct FadeTrack { /* private fields */ }Expand description
Injected-clock fade tracker keyed by a small u64 id — the per-element
hover / selection progress the immediate-mode form facets were missing. Each
key holds a factor in [0,1] that eases toward 1 while the key is “lit” this
frame (hovered / selected) and toward 0 once it isn’t; keys that settle back
at 0 are dropped, so the map only ever holds the handful of elements that are
currently mid-fade.
The per-frame protocol is three calls: begin (mark all keys
un-lit), lit for each element that should glow this frame, then
advance with your own dt once the frame is laid out. Read
the eased value with factor when you paint each element.
Determinism (FC-7): no egui state, no wall-clock — the factors live in the
caller’s component struct and advance by the dt you own (pass
ui.input(|i| i.stable_dt)), so snapshots reproduce. duration <= 0 snaps
instantly (honours Motion::duration == 0, the reduced-motion / Device setting).
Implementations§
Source§impl FadeTrack
impl FadeTrack
Sourcepub fn lit(&mut self, key: u64)
pub fn lit(&mut self, key: u64)
Mark key lit this frame (hovered / selected). Creates it at factor 0
(so it fades in) if it wasn’t tracked yet.
Sourcepub fn factor(&self, key: u64) -> f32
pub fn factor(&self, key: u64) -> f32
The current eased factor ∈[0,1] for key (0 if untracked) — multiply
your highlight alpha by this when painting the element.
Sourcepub fn active(&self) -> usize
pub fn active(&self) -> usize
How many keys are currently tracked (lit or still fading out) — a
host-readable “is motion live right now” signal for state_json proofs.
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
Whether any tracked key is mid-fade (factor strictly between fully-off and fully-on) — i.e. a cross-fade is visibly animating this frame.
Sourcepub fn advance(&mut self, dt: f32, duration: f32) -> bool
pub fn advance(&mut self, dt: f32, duration: f32) -> bool
Advance every key toward its target (lit → 1, else → 0) over duration
seconds, dropping keys that have faded fully back to 0. Returns whether any
key is still mid-fade (the caller requests a repaint while so). duration <= 0
snaps. Deterministic given the same factors + dt.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FadeTrack
impl RefUnwindSafe for FadeTrack
impl Send for FadeTrack
impl Sync for FadeTrack
impl Unpin for FadeTrack
impl UnsafeUnpin for FadeTrack
impl UnwindSafe for FadeTrack
Blanket Implementations§
impl<T> Allocation 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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