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: StyleVisual style for the widget background (Part::MAIN).
Implementations§
Source§impl AnimImage
impl AnimImage
Sourcepub fn new(bounds: Rect, frames: FrameSource) -> Self
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.
Sourcepub fn set_ticks_per_frame(&mut self, n: u32)
pub fn set_ticks_per_frame(&mut self, n: u32)
Set the number of ticks between frame advances. 0 is clamped to 1.
Sourcepub fn ticks_per_frame(&self) -> u32
pub fn ticks_per_frame(&self) -> u32
Number of ticks between frame advances (always ≥ 1).
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Number of frames in the animation (may be zero for an empty source).
Sourcepub fn current_frame_index(&self) -> usize
pub fn current_frame_index(&self) -> usize
Index of the currently displayed frame.
Sourcepub fn set_current_frame(&mut self, index: usize)
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).
Sourcepub fn set_play_state(&mut self, state: AnimPlayState)
pub fn set_play_state(&mut self, state: AnimPlayState)
Set the play state directly.
Sourcepub fn play_state(&self) -> AnimPlayState
pub fn play_state(&self) -> AnimPlayState
Current play state.
Sourcepub fn is_playing(&self) -> bool
pub fn is_playing(&self) -> bool
Return true when the animation is currently running.
Sourcepub fn set_loop_mode(&mut self, mode: AnimImageLoopMode)
pub fn set_loop_mode(&mut self, mode: AnimImageLoopMode)
Set the loop mode.
Sourcepub fn loop_mode(&self) -> AnimImageLoopMode
pub fn loop_mode(&self) -> AnimImageLoopMode
Current loop mode.
Sourcepub fn set_reverse(&mut self, reverse: bool)
pub fn set_reverse(&mut self, reverse: bool)
When true, the initial playback direction is reversed (frame index
decrements toward 0 rather than incrementing).
Sourcepub fn on_complete<F: FnMut() + 'static>(self, handler: F) -> Self
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
impl Widget for AnimImage
Source§fn draw(&self, renderer: &mut dyn Renderer)
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
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)
fn set_bounds(&mut self, bounds: Rect)
Adopt a layout-computed bounds rect.
Source§fn clear_region(&mut self) -> Option<Rect>
fn clear_region(&mut self) -> Option<Rect>
None. Read more