pub struct Alert { /* private fields */ }Expand description
An inline banner: Info, Success, Warning or Error, with a message.
Not interactive, not focusable, not a tab stop. It sits in the layout, in the place the thing it is about would be.
Alert::new(Role::Success, "Lagret").with_icon('✓');
Alert::new(Role::Error, "Kunne ikke lagre: disken er full");§This is a banner, not a dialog
Worth being explicit, because the word covers both. A dialog — something
that takes over, dims what is behind it and demands an answer — is
Ui::push_scene, which already exists and already
dims and captures input. This is the strip of colour that reports something
happened.
Neither one opens a window. Denise is a single Surface:
on denise-drm there is no window system to open one in, and denise-win32,
denise-macos and denise-activex are embedded — the host owns the window
and Denise owns one rectangle inside it, so a control that spawned a
top-level window would escape its host’s modality and outlive the dialog that
owns it.
An application that wants a native message box on a desktop build should call the platform for one. It knows which build it is; the toolkit would have to guess. That is the same conclusion the backend choice reached.
§Sizing
preferred_height reports what the message needs
once wrapped to a width — the query convention every sizable widget here
uses, called by the application and never by the tree.
Implementations§
Source§impl Alert
impl Alert
Sourcepub fn new(role: Role, text: impl Into<String>) -> Self
pub fn new(role: Role, text: impl Into<String>) -> Self
A banner in role carrying text.
text may contain \n, and is wrapped to the width it is given.
Sourcepub fn with_icon(self, icon: char) -> Self
pub fn with_icon(self, icon: char) -> Self
Puts a character in front of the message.
A char, not an icon set. There is no icon story in this toolkit and
inventing one inside a banner would be the wrong place to start; whether
✓ or ⚠ actually draws depends on the font in use, and the built-in
bitmap font has Latin and æøå and nothing else. ! and i always work.
Sourcepub fn with_style(self, style: TextStyle) -> Self
pub fn with_style(self, style: TextStyle) -> Self
Sets the message’s font and size.
Sourcepub fn update(&mut self, text: &str) -> bool
pub fn update(&mut self, text: &str) -> bool
Replaces the message, reporting whether it actually changed.
Sourcepub fn preferred_height(&self, engine: &mut TextEngine, width: i32) -> i32
pub fn preferred_height(&self, engine: &mut TextEngine, width: i32) -> i32
Height this banner needs for its message wrapped to width.
Trait Implementations§
Source§impl Describe for Alert
impl Describe for Alert
Source§const DOC: &'static str = "A coloured banner saying something happened, in the place it happened."
const DOC: &'static str = "A coloured banner saying something happened, in the place it happened."
Source§const ICON: &'static Icon
const ICON: &'static Icon
Source§const PROPERTIES: &'static [Property]
const PROPERTIES: &'static [Property]
Source§impl<M: 'static> Widget<M> for Alert
impl<M: 'static> Widget<M> for Alert
Source§fn describe(&self) -> Option<&dyn DynDescribe>
fn describe(&self) -> Option<&dyn DynDescribe>
Source§fn describe_mut(&mut self) -> Option<&mut dyn DynDescribe>
fn describe_mut(&mut self) -> Option<&mut dyn DynDescribe>
describe.Source§fn measure(&self, ctx: &mut MeasureCtx<'_>, offered: Offer) -> Measured
fn measure(&self, ctx: &mut MeasureCtx<'_>, offered: Offer) -> Measured
Source§fn paint(&self, ctx: &mut PaintCtx<'_>, canvas: &mut Pen<'_>)
fn paint(&self, ctx: &mut PaintCtx<'_>, canvas: &mut Pen<'_>)
canvas, which is already clipped to this widget’s bounds
intersected with the damage region being repainted. Read moreSource§fn on_event(&mut self, event: &Event<'_>, ctx: &mut EventCtx<'_, M>) -> Handled
fn on_event(&mut self, event: &Event<'_>, ctx: &mut EventCtx<'_, M>) -> Handled
Source§fn accepts_pointer(&self) -> bool
fn accepts_pointer(&self) -> bool
true if the pointer can hit this widget. Read moreSource§fn preserves_focus(&self) -> bool
fn preserves_focus(&self) -> bool
true if a press on this widget should leave focus exactly where
it is. Read moreSource§fn animate(&mut self, now_ms: u64) -> Animation
fn animate(&mut self, now_ms: u64) -> Animation
EventCtx::request_animation — and stops being called
the moment it answers Wake::Never. Read moreAuto Trait Implementations§
impl Freeze for Alert
impl RefUnwindSafe for Alert
impl Send for Alert
impl Sync for Alert
impl Unpin for Alert
impl UnsafeUnpin for Alert
impl UnwindSafe for Alert
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DynDescribe for Twhere
T: Describe,
impl<T> DynDescribe for Twhere
T: Describe,
Source§fn kind(&self) -> &'static str
fn kind(&self) -> &'static str
Describe::KIND.Source§fn properties(&self) -> &'static [Property]
fn properties(&self) -> &'static [Property]
Describe::PROPERTIES.Source§fn get_property(&self, name: &str) -> Option<Value>
fn get_property(&self, name: &str) -> Option<Value>
Describe::get.Source§fn set_property(
&mut self,
name: &str,
value: Value,
) -> Result<(), PropertyError>
fn set_property( &mut self, name: &str, value: Value, ) -> Result<(), PropertyError>
Describe::set.