pub struct Badge { /* private fields */ }Expand description
A notification circle painted in a corner of a widget.
Build one with Badge::new and attach it with
Button::badge. The colour and corner are
the two knobs you will reach for; everything else has a sane default.
Empty text (Badge::dot) renders a plain coloured dot.
Implementations§
Source§impl Badge
impl Badge
Sourcepub fn new(text: impl Into<WidgetText>) -> Self
pub fn new(text: impl Into<WidgetText>) -> Self
Create a badge showing text (e.g. a change count) in the top-right
corner, filled with ThemeColors::error.
Sourcepub fn corner(self, corner: BadgeCorner) -> Self
pub fn corner(self, corner: BadgeCorner) -> Self
Which corner of the widget the badge sits in. Default: top-right.
Sourcepub fn text_color(self, text_color: Color32) -> Self
pub fn text_color(self, text_color: Color32) -> Self
Colour of the badge text. Defaults to
ThemeColors::bg so glyphs stay
readable on chromatic fills.
Sourcepub fn min_diameter(self, min_diameter: f32) -> Self
pub fn min_diameter(self, min_diameter: f32) -> Self
Smallest diameter the circle will take, in points.
The circle grows beyond this when the text needs the room. Default:
16.0. Lower it for Button::small.
Sourcepub fn inset(self, inset: f32) -> Self
pub fn inset(self, inset: f32) -> Self
Distance between the circle and the widget corner, in points.
Negative values let the badge straddle the edge. Default: 2.0.
Sourcepub fn padding(self, padding: f32) -> Self
pub fn padding(self, padding: f32) -> Self
Gap between the text and the circle edge, in points. Default: 3.0.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Badge
impl RefUnwindSafe for Badge
impl Send for Badge
impl Sync for Badge
impl Unpin for Badge
impl UnsafeUnpin for Badge
impl UnwindSafe for Badge
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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