euv_ui/hook/transition/struct.rs
1use super::*;
2
3/// Configuration for a `TransitionState`.
4///
5/// Both fields are reactive (the underlying state holds a
6/// `Signal<TransitionConfig>`), so consumers can adjust
7/// the durations at runtime via `change_config` and any
8/// pending timers driven by the old config will continue
9/// using the old values until they next read the config
10/// signal.
11#[derive(Clone, Copy, Data, Debug, Eq, PartialEq)]
12pub struct TransitionConfig {
13 /// The duration of the enter animation, in
14 /// milliseconds.
15 #[get(type(copy))]
16 pub enter_ms: u32,
17 /// The duration of the exit animation, in
18 /// milliseconds.
19 #[get(type(copy))]
20 pub exit_ms: u32,
21}
22
23/// The aggregate transition state.
24///
25/// Constructed once per animated element via
26/// `App::use_transition(...)`. Cheap to `Clone` (each
27/// internal signal is `Copy`-by-pointer). Drives the
28/// state machine forward via `tick(elapsed_ms)` and
29/// exposes the current phase / progress as reactive
30/// signals so the consuming component's render closure
31/// re-runs whenever either changes.
32#[derive(Clone, Data, New)]
33pub struct TransitionState {
34 /// The current lifecycle phase.
35 ///
36 /// Public because `ui/tests/transition/fn.rs` and
37 /// `ui/tests/hook_traits/fn.rs` read it through
38 /// `get_phase()`.
39 pub phase: Signal<TransitionPhase>,
40 /// The current progress, in `[0.0, 1.0]`. Pinned to
41 /// `1.0` for `Entered`, `0.0` for `Exited`, and
42 /// intermediate for `Entering` / `Exiting`.
43 ///
44 /// Public because `ui/tests/transition/fn.rs` reads it
45 /// through `get_progress()`.
46 pub progress: Signal<f64>,
47 /// The duration config (see `TransitionConfig`).
48 ///
49 /// Public because `ui/tests/transition/fn.rs` reads it
50 /// through `get_config()`.
51 pub config: Signal<TransitionConfig>,
52}