Skip to main content

IconData

Struct IconData 

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

Which icon — one of the bundled set, or a path of the caller’s own.

It is Copy and cheap to pass around; the path behind it is built only when IconData::path or IconData::placed is called.

An icon also says whether it carries a direction. An arrow, an indent, a reply and a chevron all point somewhere, and where they point is relative to the reading order: in a right-to-left order, back is to the right. A tick, a star and a magnifying glass point nowhere and must not be touched. Which is which is not a judgement a widget can make, so it is a property of the icon — IconData::matches_text_direction — and 76 of the bundled 2 233 carry it.

Implementations§

Source§

impl IconData

Source

pub const fn custom(draw: fn() -> Path) -> Self

An icon of the caller’s own, drawn by draw on the same 24 × 24 grid, y downwards, and filled by the non-zero rule.

A function pointer and not a Path, so that an icon stays a const — a caller’s icon is declared exactly where a bundled one would be, and costs nothing until it is painted.

Source

pub const fn mirrored(self) -> Self

The same icon, declared to carry a direction: IconData::placed mirrors it when the reading order is right-to-left.

const, so a caller’s directional icon is still a constant:

const BACK: IconData = IconData::custom(arrow).mirrored();
assert!(BACK.matches_text_direction());
Source

pub const fn matches_text_direction(self) -> bool

Whether this icon is turned round for a right-to-left reading order.

Source

pub fn path(self) -> Path

The icon’s outline on the 24 × 24 grid, ready to be scaled and filled.

The raw artwork, in the direction it was drawn. IconData::placed is what a widget wants: it is this, sized, positioned, and turned round where it should be.

Source

pub fn style(self) -> Option<IconStyle>

How this icon is drawn, or None for a caller’s own — which is drawn however its function draws it.

Source

pub fn placed(self, side: f32, x: f32, y: f32, direction: TextDirection) -> Path

The icon’s outline scaled to side and placed at (x, y) — the top-left of the square it occupies — and mirrored within that square when it carries a direction and direction is right-to-left.

Every widget that paints an icon goes through here. That is the point: the rule about which icons turn round is stated once, in the icon, and applied once, here, rather than remembered at each of the sixteen places that fill an icon’s path.

Source

pub fn is_bundled(self) -> bool

Whether this icon comes from the bundled set rather than from a caller.

Trait Implementations§

Source§

impl Clone for IconData

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

Source§

impl Debug for IconData

Source§

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

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

impl Eq for IconData

Source§

impl From<IconData> for DestinationIcon

Source§

fn from(icon: IconData) -> Self

Converts to this type from the input type.
Source§

impl Hash for IconData

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for IconData

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 IconData

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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T> MaybeSend for T
where T: Send,

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.