pub struct MotionTokens { /* private fields */ }Expand description
The application-global motion policy: every duration, stagger beat, and spring response the crate animates with, resolved through one value.
crate::init installs MotionTokens::DEFAULT unless the application
already chose. To customize, build from default() and set
the result — before windows render, so no frame is timed under two
policies:
gpui_ai::init(cx);
gpui_ai::motion::MotionTokens::default()
.with_quick(Duration::from_millis(120))
.set(cx);Components use the quick role for acknowledgments, standard for entrances and compact disclosures, and spring roles for bounded retargets. Named repeating effects keep their individual tempos. The deliberate role is available for application composition without adding motion implicitly.
What the policy cannot do: override reduced motion. cx.reduce_motion()
stays authoritative in every consumer, so customization tunes tempo and
feel, never whether travel happens for someone who asked for stillness.
Implementations§
Source§impl MotionTokens
impl MotionTokens
Sourcepub fn read(cx: &App) -> &Self
pub fn read(cx: &App) -> &Self
The policy the application installed, or the crate’s default where it
installed none. Never panics: a window rendered before init runs is
timed by Self::DEFAULT, the same values init would install.
Sourcepub fn set(self, cx: &mut App)
pub fn set(self, cx: &mut App)
Makes this policy the application’s, for every component at once.
Sourcepub const fn instant(&self) -> Duration
pub const fn instant(&self) -> Duration
Focus, press acknowledgement, pointer capture: zero, because a direct response to input is not eased.
Sourcepub const fn hover_glide(&self) -> Duration
pub const fn hover_glide(&self) -> Duration
One hover highlight gliding between uniform rows, chasing the
pointer on the strong ease-out. Faster than quick
because the highlight follows input rather than acknowledging it;
any reduced preference snaps the highlight instead.
Sourcepub const fn standard(&self) -> Duration
pub const fn standard(&self) -> Duration
Selected indicator, compact disclosure, progress retarget — and the crate’s entrance tempo.
Sourcepub const fn deliberate(&self) -> Duration
pub const fn deliberate(&self) -> Duration
Larger bounded panel or success choreography.
Restricted by contract to modal- and sheet-class surfaces and
explanatory composition: nothing smaller — tooltips, popovers,
dropdowns, toggles, row state — may bind to it, because 380ms on
an element the reader is waiting on reads as lag, not weight.
Popover-class entrances bind to quick.
Sourcepub const fn press_spring(&self) -> SpringRole
pub const fn press_spring(&self) -> SpringRole
Reversible control compression: fast and fully damped.
Sourcepub const fn selection_spring(&self) -> SpringRole
pub const fn selection_spring(&self) -> SpringRole
An active pill or marker gliding between targets.
Sourcepub const fn disclosure_spring(&self) -> SpringRole
pub const fn disclosure_spring(&self) -> SpringRole
Bounded panel geometry; no bounce, so it also suits destructive and error surfaces.
Sourcepub const fn reflow_spring(&self) -> SpringRole
pub const fn reflow_spring(&self) -> SpringRole
Visible row displacement: critically damped, velocity-preserving.
Sourcepub const fn preference(&self) -> MotionPreference
pub const fn preference(&self) -> MotionPreference
The policy’s own motion preference, before the OS signal composes.
Sourcepub fn effective_preference(cx: &App) -> MotionPreference
pub fn effective_preference(cx: &App) -> MotionPreference
The preference actually in effect: the policy’s, floored at
MotionPreference::Crossfade while the OS asks for reduced
motion. Every clock, spring, and loop in the crate resolves
through this.
Sourcepub const fn with_preference(self, preference: MotionPreference) -> Self
pub const fn with_preference(self, preference: MotionPreference) -> Self
Replaces the preference.
Sourcepub const fn with_instant(self, duration: Duration) -> Self
pub const fn with_instant(self, duration: Duration) -> Self
Replaces the instant duration.
Sourcepub const fn with_quick(self, duration: Duration) -> Self
pub const fn with_quick(self, duration: Duration) -> Self
Replaces the quick duration.
Sourcepub const fn with_hover_glide(self, duration: Duration) -> Self
pub const fn with_hover_glide(self, duration: Duration) -> Self
Replaces the hover_glide duration.
Sourcepub const fn with_standard(self, duration: Duration) -> Self
pub const fn with_standard(self, duration: Duration) -> Self
Replaces the standard duration, which is also the
entrance tempo every reveal in the crate settles at.
Sourcepub const fn with_deliberate(self, duration: Duration) -> Self
pub const fn with_deliberate(self, duration: Duration) -> Self
Replaces the deliberate duration.
Sourcepub const fn with_stagger_beat(self, beat: Duration) -> Self
pub const fn with_stagger_beat(self, beat: Duration) -> Self
Replaces the per-item stagger beat. The participation and aggregate caps are policy, not configuration, and stay where they are.
Sourcepub const fn with_press_spring(self, response: Duration, damping: f32) -> Self
pub const fn with_press_spring(self, response: Duration, damping: f32) -> Self
Replaces the press spring’s feel.
Sourcepub const fn with_selection_spring(
self,
response: Duration,
damping: f32,
) -> Self
pub const fn with_selection_spring( self, response: Duration, damping: f32, ) -> Self
Replaces the selection spring’s feel.
Sourcepub const fn with_disclosure_spring(
self,
response: Duration,
damping: f32,
) -> Self
pub const fn with_disclosure_spring( self, response: Duration, damping: f32, ) -> Self
Replaces the disclosure spring’s feel.
Sourcepub const fn with_reflow_spring(self, response: Duration, damping: f32) -> Self
pub const fn with_reflow_spring(self, response: Duration, damping: f32) -> Self
Replaces the reflow spring’s feel.
Sourcepub fn arrival_stagger(&self, index: usize, arriving: usize) -> Duration
pub fn arrival_stagger(&self, index: usize, arriving: usize) -> Duration
The delay item index of arriving newly visible items waits before
its arrival plays — the stagger role.
The cascade decelerates: delays are spread with ease-out spacing, so
later items land closer together and the group resolves quickly
instead of trailing. At most six items take part, the whole cascade
spends at most 220 ms, and items past the participation bound arrive
with the last beat rather than after it — the bounded-choreography
caps, which are policy rather than configuration. The per-item beat
scales with with_stagger_beat.
Provisional like the other unconsumed roles: the motion lab is its
first consumer and its validator, and the shipped reveal_staggered
keeps its documented linear beats regardless.
Trait Implementations§
Source§impl Clone for MotionTokens
impl Clone for MotionTokens
Source§fn clone(&self) -> MotionTokens
fn clone(&self) -> MotionTokens
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MotionTokens
impl Debug for MotionTokens
Source§impl Default for MotionTokens
impl Default for MotionTokens
impl Global for MotionTokens
Source§impl PartialEq for MotionTokens
impl PartialEq for MotionTokens
impl StructuralPartialEq for MotionTokens
Auto Trait Implementations§
impl Freeze for MotionTokens
impl RefUnwindSafe for MotionTokens
impl Send for MotionTokens
impl Sync for MotionTokens
impl Unpin for MotionTokens
impl UnsafeUnpin for MotionTokens
impl UnwindSafe for MotionTokens
Blanket Implementations§
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Span], returning an
Instrumented wrapper.§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> ReadGlobal for Twhere
T: Global,
impl<T> ReadGlobal for Twhere
T: Global,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().§impl<T> UpdateGlobal for Twhere
T: Global,
impl<T> UpdateGlobal for Twhere
T: Global,
§fn update_global<C, F, R>(cx: &mut C, update: F) -> R
fn update_global<C, F, R>(cx: &mut C, update: F) -> R
§fn set_global<C>(cx: &mut C, global: T)where
C: BorrowAppContext,
fn set_global<C>(cx: &mut C, global: T)where
C: BorrowAppContext,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
Subscriber to this type, returning a
[WithDispatch] wrapper.