Skip to main content

AnimImage

Struct AnimImage 

Source
pub struct AnimImage {
    pub style: Style,
    /* private fields */
}
Expand description

Tick-driven animated image widget.

See the module-level documentation for the full design contract.

Fields§

§style: Style

Visual style for the widget background (Part::MAIN).

Implementations§

Source§

impl AnimImage

Source

pub fn new(bounds: Rect, frames: FrameSource) -> Self

Create an animated image at bounds from the provided frames.

Default: Running, Loop, 3 ticks/frame, forward direction.

Source

pub fn set_ticks_per_frame(&mut self, n: u32)

Set the number of ticks between frame advances. 0 is clamped to 1.

Source

pub fn ticks_per_frame(&self) -> u32

Number of ticks between frame advances (always ≥ 1).

Source

pub fn frame_count(&self) -> usize

Number of frames in the animation (may be zero for an empty source).

Source

pub fn current_frame_index(&self) -> usize

Index of the currently displayed frame.

Source

pub fn set_current_frame(&mut self, index: usize)

Force-set the displayed frame index. Out-of-bounds values are clamped to frame_count().saturating_sub(1).

Source

pub fn play(&mut self)

Start playback (equivalent to LVGL lv_animimg_start).

Source

pub fn pause(&mut self)

Pause playback (equivalent to LVGL lv_animimg_stop).

Source

pub fn set_play_state(&mut self, state: AnimPlayState)

Set the play state directly.

Source

pub fn play_state(&self) -> AnimPlayState

Current play state.

Source

pub fn is_playing(&self) -> bool

Return true when the animation is currently running.

Source

pub fn set_loop_mode(&mut self, mode: AnimImageLoopMode)

Set the loop mode.

Source

pub fn loop_mode(&self) -> AnimImageLoopMode

Current loop mode.

Source

pub fn set_reverse(&mut self, reverse: bool)

When true, the initial playback direction is reversed (frame index decrements toward 0 rather than incrementing).

Source

pub fn on_complete<F: FnMut() + 'static>(self, handler: F) -> Self

Register a callback fired when AnimImageLoopMode::Once reaches the last frame. Replaces any previously registered callback.

Trait Implementations§

Source§

impl Widget for AnimImage

Source§

fn draw(&self, renderer: &mut dyn Renderer)

Draw the current animation frame.

Part::MAIN — widget background. Part::INDICATOR — current frame via Renderer::blit_image.

Source§

fn handle_event(&mut self, event: &Event) -> bool

Handle events. Returns true when Event::Tick is consumed (matching the Spinner pattern: Tick is always consumed when Running).

Source§

fn set_bounds(&mut self, bounds: Rect)

Adopt a layout-computed bounds rect.

Source§

fn bounds(&self) -> Rect

Return the area this widget occupies relative to its parent.
Source§

fn clear_region(&mut self) -> Option<Rect>

Return a region (in draw/landscape coordinates) that should be restored from the pristine background copy, or None. Read more
Source§

fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>

Expose this widget’s font slot for cascade-driven font resolution (FONT-05 §5.B). 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.