pub struct ButtonSkin {
pub idle: NineSliceImage,
pub hovered: NineSliceImage,
pub pressed: NineSliceImage,
}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 art a skinned button draws: one nine-sliced image per ButtonState.
idle hovered pressed
┌──┬────────┬──┐ ┌──┬────────┬──┐ ┌──┬────────┬──┐
│ │ │ │ │ │ │ │ │ │ │ │
├──┤ Play ├──┤ ├──┤ Play ├──┤ ├──┤ Play ├──┤
│ │ │ │ │ │ │ │ │ │ │ │
└──┴────────┴──┘ └──┴────────┴──┘ └──┴────────┴──┘
three pictures — pressing swaps art, it does not tintThree pictures rather than one picture and three tints, because that is what the feature is for. A tint can only darken or lighten uniformly; separate frames let a pressed button have a sunken bevel, a different highlight, or a shadow that moved — none of which is a multiply.
draw emits the frame for a state into a DrawList as
textured quads, so the frame and the label on it are drawn by one pass in
the order they were pushed: frame first, label over it.
Fields§
§idle: NineSliceImageThe frame drawn at rest.
hovered: NineSliceImageThe frame drawn under the cursor or the keyboard’s selection.
pressed: NineSliceImageThe frame drawn while the button holds the press.
Implementations§
Source§impl ButtonSkin
impl ButtonSkin
Sourcepub const fn uniform(frame: NineSliceImage) -> ButtonSkin
pub const fn uniform(frame: NineSliceImage) -> ButtonSkin
One frame for every state — a skin that does not react.
Sourcepub const fn frame(&self, state: ButtonState) -> &NineSliceImage
pub const fn frame(&self, state: ButtonState) -> &NineSliceImage
The frame state draws.
Sourcepub fn insets(&self) -> SkinInsets
pub fn insets(&self) -> SkinInsets
The insets to hand Button::with_skin, in texels.
Read off the idle frame, and off its clamped insets rather than its
declared ones, so the layout agrees with the geometry that will actually
be drawn. Idle specifically, and not “whichever state is current”: a
button whose minimum size changed with the cursor would resize as the
mouse crossed it. insets_agree is there for a
skin whose frames might not.
Sourcepub fn insets_agree(&self) -> bool
pub fn insets_agree(&self) -> bool
Whether all three frames have the same clamped insets.
Sourcepub fn draw(
&self,
dl: &mut DrawList,
state: ButtonState,
min: Vec2,
max: Vec2,
scale: f32,
)
pub fn draw( &self, dl: &mut DrawList, state: ButtonState, min: Vec2, max: Vec2, scale: f32, )
Pushes state’s frame stretched to min..max, at scale screen pixels
per texel of its fixed bands — see DrawList::nine_slice.
Trait Implementations§
Source§impl Clone for ButtonSkin
impl Clone for ButtonSkin
Source§fn clone(&self) -> ButtonSkin
fn clone(&self) -> ButtonSkin
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more