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: f32Fixed width of the left column, in pixels.
right: f32Fixed width of the right column, in pixels.
top: f32Fixed height of the top row, in pixels.
bottom: f32Fixed height of the bottom row, in pixels.
Implementations§
Source§impl SkinInsets
impl SkinInsets
Sourcepub const NONE: SkinInsets
pub const NONE: SkinInsets
No fixed bands at all — a skin that stretches everywhere.
Sourcepub const fn new(left: f32, right: f32, top: f32, bottom: f32) -> SkinInsets
pub const fn new(left: f32, right: f32, top: f32, bottom: f32) -> SkinInsets
Insets given per side.
Sourcepub const fn uniform(inset: f32) -> SkinInsets
pub const fn uniform(inset: f32) -> SkinInsets
The same inset on all four sides.
Sourcepub fn minimum_size(&self) -> Vec2
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.
Sourcepub fn min_corner(&self) -> Vec2
pub fn min_corner(&self) -> Vec2
The top-left corner’s size, as an offset from a rect’s min.
Sourcepub fn max_corner(&self) -> Vec2
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
impl Clone for SkinInsets
Source§fn clone(&self) -> SkinInsets
fn clone(&self) -> SkinInsets
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more