Skip to main content

Cursor

Struct Cursor 

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

A loaded cursor, immutable once built.

Implementations§

Source§

impl Cursor

Source

pub fn load( resolved: &ThemeResolution, requested_size: u32, ) -> Result<Self, CursorError>

Load from a resolved theme entry at the nearest available size.

Cursor files are multi-resolution packs, so this picks the nominal size closest to requested_size and takes every frame filed under it. A requested_size of zero means the default nominal size.

§Errors
Source

pub fn load_named( theme: &Theme, cursor_name: &str, preferred_theme: &str, requested_size: u32, ) -> Result<Self, CursorError>

Resolve a name against theme and load it.

§Errors

As Theme::resolve and Cursor::load.

Source

pub fn from_bytes( bytes: &[u8], requested_size: u32, ) -> Result<Self, CursorError>

Load from the bytes of a cursor file.

The seam the fuzz target drives, so it exercises the same bounds the real loader does.

§Errors

As Cursor::load, less the I/O.

Source

pub fn from_argb( pixels: &[u32], width: u32, height: u32, xhot: u32, yhot: u32, ) -> Result<Self, CursorError>

Build a static cursor from caller-supplied pixels.

The in-process fallback for when no cursor theme is installed. Pixels are premultiplied 0xAARRGGBB, row-major, and are copied.

§Errors

CursorError::InvalidImage for a zero or oversize dimension, or a pixel count that does not match the dimensions. A caller bug, surfaced here rather than as a surprise at render time.

Source

pub fn from_frames(frames: Vec<Frame>) -> Result<Self, CursorError>

Build a cursor from frames the caller already has.

The many-frame form of Cursor::from_argb, for a caller generating cursors rather than loading them – a compositor drawing its own spinner, or a test. Frames play in the order given.

§Errors
Source

pub fn first(&self) -> &Frame

The first frame, which is what a static cursor shows.

Source

pub fn frames(&self) -> &[Frame]

Every frame, in play order.

Source

pub const fn cycle(&self) -> Duration

How long one full loop takes. Zero for a static cursor.

Source

pub fn is_animated(&self) -> bool

Whether this cursor actually animates.

More than one frame is not enough: some themes ship multi-frame packs with a zero delay on every frame, which would otherwise loop instantly and flicker.

Source

pub fn frame_at(&self, elapsed: Duration) -> &Frame

The frame showing at elapsed since the cursor started displaying.

Deterministic and total: a static cursor, or one whose frames all declare no delay, always answers with the first frame.

Source

pub fn frame_index_at(&self, elapsed: Duration) -> usize

Which frame is showing at elapsed.

The index rather than the frame, so a caller redrawing into a buffer can tell that nothing has changed and skip the work. A cursor ticking at 60 Hz through 100 ms frames redraws on one tick in six.

Trait Implementations§

Source§

impl Clone for Cursor

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 Debug for Cursor

Source§

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

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

impl Eq for Cursor

Source§

impl PartialEq for Cursor

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Cursor

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> 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.