pub struct Callout<'a> { /* private fields */ }Expand description
A full-width inline banner in the elegance style.
Callout::new(CalloutTone::Warning)
.title("Unsaved changes.")
.body("You have 3 edits that haven't been written to disk.")
.show(ui, |_| {});Implementations§
Source§impl<'a> Callout<'a>
impl<'a> Callout<'a>
Sourcepub fn new(tone: CalloutTone) -> Self
pub fn new(tone: CalloutTone) -> Self
Create a new callout with the given tone.
Sourcepub fn title(self, text: impl Into<WidgetText>) -> Self
pub fn title(self, text: impl Into<WidgetText>) -> Self
Set the bolded title text rendered inline at the left of the banner.
Sourcepub fn body(self, text: impl Into<WidgetText>) -> Self
pub fn body(self, text: impl Into<WidgetText>) -> Self
Set the muted body text, rendered to the right of the title.
Sourcepub fn icon(self, icon: impl Into<WidgetText>) -> Self
pub fn icon(self, icon: impl Into<WidgetText>) -> Self
Override the icon glyph. Defaults to a tone-dependent symbol.
Sourcepub fn dismissable(self, open: &'a mut bool) -> Self
pub fn dismissable(self, open: &'a mut bool) -> Self
Render a trailing × button that sets *open = false when clicked.
The caller is responsible for gating the .show(...) call on the
same bool so the banner disappears after dismissal.
Sourcepub fn show<R>(
self,
ui: &mut Ui,
add_actions: impl FnOnce(&mut Ui) -> R,
) -> InnerResponse<R>
pub fn show<R>( self, ui: &mut Ui, add_actions: impl FnOnce(&mut Ui) -> R, ) -> InnerResponse<R>
Render the callout and return the closure’s result.
add_actions is invoked with a right-to-left layout so buttons
you add slot into the action area between the body text and the
dismiss button. Inside the closure the first widget added appears
furthest right, so add your primary action first:
Callout::new(CalloutTone::Warning)
.title("Unsaved changes.")
.show(ui, |ui| {
ui.add(Button::new("Save now").accent(Accent::Amber)); // rightmost
ui.add(Button::new("Discard").outline()); // to its left
});Pass |_| {} when no actions are needed.