Skip to main content

Animation

Struct Animation 

Source
pub struct Animation { /* private fields */ }
Expand description

Fluent builder for an LVGL animation.

Configure the animation step-by-step, then call Animation::start — LVGL copies the state into its internal animation list, so the builder can be dropped immediately after.

§Callback constraints

In no_std Rust we’re stuck with extern "C" fn pointers for exec_cb / ready_cb — no closures. Use the animate_x, animate_y, animate_width, animate_opa helpers for the common cases where you just want to tween a single property.

Implementations§

Source§

impl Animation

Source

pub fn new() -> Self

Create a fresh animation with default values (duration 0, no exec cb).

Source

pub fn target(self, var: *mut c_void) -> Self

Set the target variable (typically obj.raw() as *mut c_void).

Source

pub fn values(self, from: i32, to: i32) -> Self

Set start and end values.

Source

pub fn duration(self, ms: u32) -> Self

Set duration in milliseconds.

Source

pub fn delay(self, ms: u32) -> Self

Set the delay before the animation starts.

Source

pub fn path(self, cb: lv_anim_path_cb_t) -> Self

Set the easing path callback. Use e.g. path_ease_out.

Source

pub fn repeat_count(self, count: u32) -> Self

Set the repeat count; use ANIM_REPEAT_INFINITE for endless.

Source

pub fn repeat_delay(self, ms: u32) -> Self

Set the delay between repeats.

Source

pub fn playback_duration(self, ms: u32) -> Self

Set the duration of the reverse (playback) phase.

Source

pub fn playback_delay(self, ms: u32) -> Self

Set the delay before the playback phase.

Source

pub fn exec_cb(self, cb: lv_anim_exec_xcb_t) -> Self

Set the exec callback invoked every frame with (var, value).

Source

pub fn completed_cb(self, cb: lv_anim_completed_cb_t) -> Self

Set the callback invoked when the animation completes (lv_anim_set_completed_cb).

Source

pub fn start(self)

Start the animation. LVGL copies internal state, so the builder can be dropped immediately after.

Source

pub fn stop(var: *mut c_void, exec_cb: lv_anim_exec_xcb_t) -> bool

Stop any animations matching (var, exec_cb).

Source§

impl Animation

Source

pub fn duration_for_speed(speed: u32) -> u32

Configure the animation duration based on a movement speed (LVGL’s lv_anim_speed). Returns the precomputed duration value.

Source

pub fn tick_fn<W: Widget>(self, obj: W, on_tick: fn(Obj, i32)) -> Self

Set both the animation target and a safe tick callback.

on_tick(obj, v) is invoked every frame with the target widget (as Obj) and the interpolated value. Uses LVGL’s custom exec callback so the fn pointer is smuggled through user_data.

Trait Implementations§

Source§

impl Default for Animation

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.