Skip to main content

CursorImage

Struct CursorImage 

Source
pub struct CursorImage {
    pub width: i32,
    pub height: i32,
    pub hotspot: Point,
    pub mask: &'static [u8],
}
Expand description

A cursor bitmap: three levels, drawn in two theme colours.

mask is one ASCII byte per pixel in row-major order, which keeps the shape readable in the source instead of being a wall of hex:

Both colours come from the theme, so the pointer inverts with it and stays visible on a light panel and a dark one without a second asset.

Fields§

§width: i32

Width in pixels.

§height: i32

Height in pixels.

§hotspot: Point

The pixel that sits on the pointer position.

§mask: &'static [u8]

width * height ASCII bytes.

Implementations§

Source§

impl CursorImage

Source

pub const fn is_well_formed(&self) -> bool

Returns true if mask matches the declared geometry.

Source

pub fn rasterise(&self, theme: &Theme, out: &mut [u32]) -> usize

Writes the sprite into out as 0xAARRGGBB words, for a hardware cursor plane.

Returns the number of words written, which is width * height. The two colours are the theme’s, exactly as the software composite uses them, so a panel that switches to the plane does not also change appearance — transparent pixels come out as a fully zero word rather than as black, because a cursor plane composites during scanout and an opaque pad would draw a rectangle around the pointer.

Re-run this when the theme changes: the sprite is resolved to concrete colours here, so the plane holds pixels rather than roles.

Source

pub fn bounds_at(&self, at: Point) -> Rect

Bounds the sprite would occupy with its hotspot at at.

Trait Implementations§

Source§

impl Clone for CursorImage

Source§

fn clone(&self) -> CursorImage

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 Copy for CursorImage

Source§

impl Debug for CursorImage

Source§

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

Formats the value using the given formatter. 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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Borrows as dyn Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Mutably borrows as dyn Any.
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.