Struct egui_notify::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!").set_duration(Some(Duration::from_secs(5))).set_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 success(&mut self, caption: impl Into<String>) -> &mut Toast

Shortcut for adding a toast with info success.

source

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

Shortcut for adding a toast with info level.

source

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

Shortcut for adding a toast with warning level.

source

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

Shortcut for adding a toast with error level.

source

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

Shortcut for adding a toast with no level.

source

pub fn custom( &mut self, caption: impl Into<String>, 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_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>,

§

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>,

§

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.