Struct Toasts

Source
pub struct Toasts { /* private fields */ }
Expand description

Main notifications collector.

§Usage

You need to create Toasts once and call .show(ctx) in every frame.

use egui_notify::Toasts;

let mut t = Toasts::default();
t.info("Hello, World!").duration(Some(Duration::from_secs(5))).closable(true);
// More app code
t.show(ctx);

Implementations§

Source§

impl Toasts

Source

pub const fn new() -> Self

Creates new Toasts instance.

Source

pub fn add(&mut self, toast: Toast) -> &mut Toast

Adds new toast to the collection. By default adds toast at the end of the list, can be changed with self.reverse.

Source

pub fn dismiss_oldest_toast(&mut self)

Dismisses the oldest toast

Source

pub fn dismiss_latest_toast(&mut self)

Dismisses the most recent toast

Source

pub fn dismiss_all_toasts(&mut self)

Dismisses all toasts

Source

pub fn len(&self) -> usize

Returns the number of toast items.

Source

pub fn is_empty(&self) -> bool

Returns true if there are no toast items.

Source

pub fn success(&mut self, caption: impl Into<WidgetText>) -> &mut Toast

Shortcut for adding a toast with info success.

Source

pub fn info(&mut self, caption: impl Into<WidgetText>) -> &mut Toast

Shortcut for adding a toast with info level.

Source

pub fn warning(&mut self, caption: impl Into<WidgetText>) -> &mut Toast

Shortcut for adding a toast with warning level.

Source

pub fn error(&mut self, caption: impl Into<WidgetText>) -> &mut Toast

Shortcut for adding a toast with error level.

Source

pub fn basic(&mut self, caption: impl Into<WidgetText>) -> &mut Toast

Shortcut for adding a toast with no level.

Source

pub fn custom( &mut self, caption: impl Into<WidgetText>, level_string: String, level_color: Color32, ) -> &mut Toast

Shortcut for adding a toast with custom level.

Source

pub const fn reverse(self, reverse: bool) -> Self

Should toasts be added in reverse order?

Source

pub const fn with_anchor(self, anchor: Anchor) -> Self

Where toasts should appear.

Source

pub const fn with_spacing(self, spacing: f32) -> Self

Sets spacing between adjacent toasts.

Source

pub const fn with_margin(self, margin: Vec2) -> Self

Margin or distance from screen to toasts’ bounding boxes

Source

pub const fn with_shadow(self, shadow: Shadow) -> Self

Enables the use of a shadow for toasts.

Source

pub const fn with_padding(self, padding: Vec2) -> Self

Padding or distance from toasts’ bounding boxes to inner contents.

Source

pub fn with_default_font(self, font: FontId) -> Self

Changes the default font used for all toasts.

Source§

impl Toasts

Source

pub fn show(&mut self, ctx: &Context)

Displays toast queue

Trait Implementations§

Source§

impl Default for Toasts

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Toasts

§

impl RefUnwindSafe for Toasts

§

impl Send for Toasts

§

impl Sync for Toasts

§

impl Unpin for Toasts

§

impl UnwindSafe for Toasts

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.