Skip to main content

SkinInsets

Struct SkinInsets 

Source
pub struct SkinInsets {
    pub left: f32,
    pub right: f32,
    pub top: f32,
    pub bottom: f32,
}
Expand description

Re-exported for the same reason as Menu: MenuSkin’s buttons are a ButtonSkin drawn per ButtonState, and its insets are SkinInsets. The fixed corner insets of a nine-slice button skin, in screen pixels.

§Why a Button carries the insets and not the art

A skinned button needs two things: art to draw, and the sizes that art refuses to stretch. Only the second is a layout fact, and the layout is what a Button is: it measures, positions and hit-tests with no picture in the room. The art is a ButtonSkin — three registered images — and ButtonSkin::insets hands back exactly this type, read off the art itself, so the two cannot drift.

§Screen space, so top is the visually-upper edge

Every rectangle in this crate is Y-down with the origin at the framebuffer’s top-left, and these insets follow it: top is the inset at the smaller Y. That agrees with an image’s own rows — its top row is its first — so DrawList::nine_slice pairs top with the image’s top band and nothing flips.

Fields§

§left: f32

Fixed width of the left column, in pixels.

§right: f32

Fixed width of the right column, in pixels.

§top: f32

Fixed height of the top row, in pixels.

§bottom: f32

Fixed height of the bottom row, in pixels.

Implementations§

Source§

impl SkinInsets

Source

pub const NONE: SkinInsets

No fixed bands at all — a skin that stretches everywhere.

Source

pub const fn new(left: f32, right: f32, top: f32, bottom: f32) -> SkinInsets

Insets given per side.

Source

pub const fn uniform(inset: f32) -> SkinInsets

The same inset on all four sides.

Source

pub fn minimum_size(&self) -> Vec2

(left + right, top + bottom) — the smallest box that draws all four corners at their natural size.

The float twin of crcbl_sprite::NineSlice::minimum_size, and the floor under Button::minimum_size before the label is even considered.

Source

pub fn min_corner(&self) -> Vec2

The top-left corner’s size, as an offset from a rect’s min.

Source

pub fn max_corner(&self) -> Vec2

The bottom-right corner’s size, as an offset back from a rect’s max.

Trait Implementations§

Source§

impl Clone for SkinInsets

Source§

fn clone(&self) -> SkinInsets

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 SkinInsets

Source§

impl Debug for SkinInsets

Source§

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

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

impl Default for SkinInsets

Source§

fn default() -> SkinInsets

Returns the “default value” for a type. Read more
Source§

impl PartialEq for SkinInsets

Source§

fn eq(&self, other: &SkinInsets) -> 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 SkinInsets

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> HalThreadSafe for T
where T: Send + Sync,

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.