Struct ButtonFace
pub struct ButtonFace<'a> { /* private fields */ }Expand description
An immediate-mode button: the Button look for a canvas host that owns
its own hit-testing. Built fluently:
ButtonFace::new(rect, "Save").role(ButtonRole::Primary).hovered(hit).
Size the rect from the face itself, so rect and glyphs agree at every
scale: ButtonFace::height for the height,
ButtonFace::intrinsic_width for the width, and hit-test with
ButtonFace::hit_rect (never smaller than the minimum pointer target).
Implementations§
§impl<'a> ButtonFace<'a>
impl<'a> ButtonFace<'a>
pub fn new(rect: Rect, label: &'a str) -> ButtonFace<'a>
pub fn icon_only(rect: Rect, icon: Icon, name: &'a str) -> ButtonFace<'a>
pub fn icon_only(rect: Rect, icon: Icon, name: &'a str) -> ButtonFace<'a>
An icon-only face; name is its accessible name.
pub fn role(self, role: ButtonRole) -> ButtonFace<'a>
pub fn role(self, role: ButtonRole) -> ButtonFace<'a>
What the button does; the role decides its whole look.
pub fn tone(self, tone: Tone) -> ButtonFace<'a>
pub fn tone(self, tone: Tone) -> ButtonFace<'a>
What the face says means something (Tone::Neutral is no tone): the
icon and the label take the tone’s colour.
pub fn icon(self, icon: Icon) -> ButtonFace<'a>
pub fn control_size(self, size: ControlSize) -> ButtonFace<'a>
pub fn control_size(self, size: ControlSize) -> ButtonFace<'a>
The face’s height and label role.
pub fn shortcut_hint(self, shortcut: Shortcut) -> ButtonFace<'a>
pub fn shortcut_hint(self, shortcut: Shortcut) -> ButtonFace<'a>
A trailing keyboard shortcut in the platform’s keycap legends.
pub fn detail(self, detail: &'a str) -> ButtonFace<'a>
pub fn detail(self, detail: &'a str) -> ButtonFace<'a>
A fact told at the face’s trailing edge, in the secondary ink: the label then leads.
pub fn toggled(self, on: bool) -> ButtonFace<'a>
pub fn toggled(self, on: bool) -> ButtonFace<'a>
A toggle that is on: the face stands on the selection lift.
pub fn hovered(self, v: bool) -> ButtonFace<'a>
pub fn pressed(self, v: bool) -> ButtonFace<'a>
pub fn focused(self, v: bool) -> ButtonFace<'a>
pub fn disabled(self, v: bool) -> ButtonFace<'a>
pub fn accessible_name(self, name: &'a str) -> ButtonFace<'a>
pub fn accessible_name(self, name: &'a str) -> ButtonFace<'a>
For callers that expose their own accessibility node for the region.
pub fn spoken_name(&self) -> &str
pub fn spoken_name(&self) -> &str
The visible label, or the explicit accessible_name when it’s empty.
pub fn colors(
&self,
theme: &Theme,
) -> (AlphaColor<Srgb>, Option<AlphaColor<Srgb>>, AlphaColor<Srgb>)
pub fn colors( &self, theme: &Theme, ) -> (AlphaColor<Srgb>, Option<AlphaColor<Srgb>>, AlphaColor<Srgb>)
The resolved palette without painting: (fill, edge, ink).
pub fn height(size: ControlSize, theme: &Theme) -> f64
pub fn height(size: ControlSize, theme: &Theme) -> f64
The height of a face of size in theme.
pub fn intrinsic_width(&self, text: &mut TextRenderer, theme: &Theme) -> f64
pub fn intrinsic_width(&self, text: &mut TextRenderer, theme: &Theme) -> f64
The narrowest rect width that shows this face’s icon, label and shortcut without eliding.
pub fn icon_rect(&self, text: &mut TextRenderer, theme: &Theme) -> Option<Rect>
pub fn icon_rect(&self, text: &mut TextRenderer, theme: &Theme) -> Option<Rect>
Where this face draws its icon: on a labelled face it leads the label, the two centred together. A host that paints its own mark in the icon’s place (a colour swatch over the choice it names) puts it exactly here, so the two never stand side by side. Ignores a shortcut hint.
Auto Trait Implementations§
impl<'a> Freeze for ButtonFace<'a>
impl<'a> RefUnwindSafe for ButtonFace<'a>
impl<'a> Send for ButtonFace<'a>
impl<'a> Sync for ButtonFace<'a>
impl<'a> Unpin for ButtonFace<'a>
impl<'a> UnsafeUnpin for ButtonFace<'a>
impl<'a> UnwindSafe for ButtonFace<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more