pub struct Badge { /* private fields */ }Expand description
A standalone or anchored Material badge. For anchored badges, include the badge’s information in the host’s accessible name.
Implementations§
Source§impl Badge
impl Badge
Sourcepub fn standalone() -> Self
pub fn standalone() -> Self
A small badge that participates in the surrounding layout.
Sourcepub fn standalone_label(text: impl Into<SharedString>) -> Self
pub fn standalone_label(text: impl Into<SharedString>) -> Self
A standalone text badge that participates in the surrounding layout.
Sourcepub fn standalone_count(count: usize, maximum: usize) -> Self
pub fn standalone_count(count: usize, maximum: usize) -> Self
A standalone capped numeric badge that participates in the surrounding layout.
Sourcepub fn dot(host: impl IntoElement) -> Self
pub fn dot(host: impl IntoElement) -> Self
Anchors a small badge to the host’s upper trailing edge.
Sourcepub fn label(host: impl IntoElement, text: impl Into<SharedString>) -> Self
pub fn label(host: impl IntoElement, text: impl Into<SharedString>) -> Self
Anchors a text badge to the host’s upper trailing edge.
Sourcepub fn count(host: impl IntoElement, count: usize, maximum: usize) -> Self
pub fn count(host: impl IntoElement, count: usize, maximum: usize) -> Self
Anchors a capped numeric badge to the host’s upper trailing edge, displaying "{maximum}+" when count > maximum.
Sourcepub fn content(
self,
id: impl Into<ElementId>,
content: impl IntoElement,
) -> Self
pub fn content( self, id: impl Into<ElementId>, content: impl IntoElement, ) -> Self
Uses large badge styling with caller-supplied visual content.
Use a stable ID within the parent and keep the content noninteractive. The badge or its host supplies the accessible name.
Sourcepub fn tone(self, tone: SemanticTone) -> Self
pub fn tone(self, tone: SemanticTone) -> Self
Applies a Material 3 semantic tone shortcut.
SemanticTone::Default and SemanticTone::Danger use Error/OnError.
Explicit Self::color_role, Self::container_color, and
Self::content_color overrides take precedence.
Sourcepub fn color_role(self, container: ColorRole, content: ColorRole) -> Self
pub fn color_role(self, container: ColorRole, content: ColorRole) -> Self
Resolves container and content pigments from the window theme’s semantic color roles.
Takes precedence over Self::tone, and is overridden by explicit
Self::container_color and Self::content_color values.
Sourcepub fn container_color(self, color: impl Into<Hsla>) -> Self
pub fn container_color(self, color: impl Into<Hsla>) -> Self
Sets the background color, overriding Self::color_role and Self::tone.
Sourcepub fn content_color(self, color: impl Into<Hsla>) -> Self
pub fn content_color(self, color: impl Into<Hsla>) -> Self
Sets the inherited content color, overriding Self::color_role and Self::tone.
Sourcepub fn visible(self, visible: bool) -> Self
pub fn visible(self, visible: bool) -> Self
Controls whether the badge mark is rendered. When false, anchored badges render only
their host and standalone badges render empty. Defaults to true.
Sourcepub fn offset(self, offset: Point<Pixels>) -> Self
pub fn offset(self, offset: Point<Pixels>) -> Self
Shifts an anchored badge from its default upper-trailing anchor (x follows logical
direction; y shifts downward).
Sourcepub fn accessible_label(
self,
id: impl Into<ElementId>,
label: impl Into<SharedString>,
) -> Self
pub fn accessible_label( self, id: impl Into<ElementId>, label: impl Into<SharedString>, ) -> Self
Names a badge for assistive technology without adding a focus stop. Anchored badges normally use their host’s accessible name instead.
Trait Implementations§
Source§impl IntoElement for Badge
impl IntoElement for Badge
Source§type Element = ViewElement<Badge>
type Element = ViewElement<Badge>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for Badge
impl RenderOnce for Badge
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for Badge
impl !Send for Badge
impl !Sync for Badge
impl !UnwindSafe for Badge
impl Forget for Badge
impl Freeze for Badgewhere
*mut dyn ElementObject: Freeze,
*const RcInner<Cell<bool>> is !null: Freeze,
PhantomData<RcInner<Cell<bool>>>: Freeze,
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
NonZero<u32>: Freeze,
*const ArcInner<Path> is !null: Freeze,
PhantomData<ArcInner<Path>>: Freeze,
*const str is !null: Freeze,
PhantomData<&'static str>: Freeze,
*const ArcInner<ElementId> is !null: Freeze,
PhantomData<ArcInner<ElementId>>: Freeze,
impl Move for Badge
impl Unpin for Badge
impl UnsafeUnpin for Badgewhere
*mut dyn ElementObject: UnsafeUnpin,
*const RcInner<Cell<bool>> is !null: UnsafeUnpin,
PhantomData<RcInner<Cell<bool>>>: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
*const ArcInner<Path> is !null: UnsafeUnpin,
PhantomData<ArcInner<Path>>: UnsafeUnpin,
*const str is !null: UnsafeUnpin,
PhantomData<&'static str>: UnsafeUnpin,
*const ArcInner<ElementId> is !null: UnsafeUnpin,
PhantomData<ArcInner<ElementId>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(
self,
text: impl Into<SharedString>,
) -> ObservedText<Self::Element>
fn test_alt_text( self, text: impl Into<SharedString>, ) -> ObservedText<Self::Element>
Self::test_text for an image’s alternative text, which
stands in for what the element draws.