Skip to main content

PropertyTrack

Struct PropertyTrack 

Source
pub struct PropertyTrack<T: Lerp> { /* private fields */ }
Expand description

单属性的呈现值轨道。

典型用法(State 内):

ⓘ
struct AnimatedOpacityState {
    track: PropertyTrack<f32>,
    widget: WidgetNode,
}
fn tick(&mut self, now_ms: u64) {
    self.track.tick(now_ms); // 推进锚点,呈现值存在 track 里
}
fn is_animating(&self) -> bool { self.track.is_animating() }
fn apply_to_ro(&mut self, ro: &mut dyn RenderObject) -> StateApply {
    ro.apply_state(self.as_any_mut())
}

Implementations§

Source§

impl<T: Lerp> PropertyTrack<T>

Source

pub fn new(initial: T, duration_ms: u64) -> Self

以 initial 为初始呈现值创建静止轨道。

Source

pub fn with_curve(self, curve: Curve) -> Self

Source

pub fn target(&self) -> T

Source

pub fn presented(&self) -> T

当前呈现值(无副作用查询,不推进)。

Source

pub fn set_presented(&mut self, value: T, now_ms: u64)

live_only 专用:把呈现值就地钉到 value,逻辑 target 保持不变。

is_animating() 在 live 期间为 true,驱动 State 就地写 RO;但 tick 不推进、 不碰 Signal、不 mount/update。终态由 LiveSession 调 settle_live 统一结算。

Source

pub fn settle_live(&mut self, value: T, now_ms: u64)

结束 live 接管,把终值同时写回呈现位与逻辑目标。

Source

pub fn is_animating(&self) -> bool

Source

pub fn is_settled(&self) -> bool

是否已到达目标(呈现值与目标逐分量相等)。

Source

pub fn retarget(&mut self, target: T, now_ms: u64)

从当前呈现值起,在 now_ms 时刻开始向 target 推进。

关键:先按 now_ms 结算当前呈现值,再以此为新锚点 —— 这就是中断/反向 连续的来源:中途改目标不会出现跳变。

Source

pub fn tick(&mut self, now_ms: u64) -> T

推进到 now_ms,返回结算后的呈现值。

必须在 State::tick 里每帧调用一次;只改内部锚点与缓存,不产生副作用。 live 期间呈现值由手势持有,tick 原样返回。

Source

pub fn value_at(&self, now_ms: u64) -> T

无状态查询 now_ms 时刻的呈现值(不推进、不改状态)。

供 hit_test、语义快照等“立即读当前位置“的路径使用,与 paint 同源。

Trait Implementations§

Source§

impl<T: Clone + Lerp> Clone for PropertyTrack<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Lerp> Debug for PropertyTrack<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Lerp> Track<T> for PropertyTrack<T>

Source§

fn presented(&self) -> T

Source§

fn target(&self) -> T

Source§

fn set_presented(&mut self, value: T, now_ms: u64)

live_only 呈现位直写;不产生响应式副作用、不改逻辑目标。
Source§

fn settle_live(&mut self, value: T, now_ms: u64)

结束 live 接管并把终值结算为新的逻辑目标。
Source§

fn tick(&mut self, now_ms: u64) -> T

Source§

fn retarget(&mut self, target: T, now_ms: u64)

Source§

fn is_animating(&self) -> bool

Source§

fn is_settled(&self) -> bool

Auto Trait Implementations§

§

impl<T> Forget for PropertyTrack<T>

§

impl<T> Freeze for PropertyTrack<T>
where T: Freeze,

§

impl<T> Move for PropertyTrack<T>

§

impl<T> RefUnwindSafe for PropertyTrack<T>
where T: RefUnwindSafe,

§

impl<T> Send for PropertyTrack<T>
where T: Send,

§

impl<T> Sync for PropertyTrack<T>
where T: Sync,

§

impl<T> Unpin for PropertyTrack<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for PropertyTrack<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for PropertyTrack<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.