pub struct AlertView<'a, const N: usize> {
pub spec: AlertSpec<'a, N>,
/* private fields */
}Expand description
Drawable alert widget for one AlertSpec.
Fields§
§spec: AlertSpec<'a, N>Immutable alert specification.
Implementations§
Source§impl<'a, const N: usize> AlertView<'a, N>
impl<'a, const N: usize> AlertView<'a, N>
Sourcepub const fn new(spec: AlertSpec<'a, N>) -> Self
pub const fn new(spec: AlertSpec<'a, N>) -> Self
Creates an alert view for a specification.
Examples found in repository?
examples/alerts.rs (line 21)
11fn main() {
12 let bounds = Rectangle::new(Point::zero(), Size::new(320, 240));
13 let theme = support::theme();
14 let i18n = support::i18n();
15 let mut canvas = support::NullCanvas::new(bounds.size);
16
17 let spec = AlertSpec::confirm(
18 Localized::new("alert.title", "Delete item?"),
19 Localized::new("alert.message", "This action cannot be undone."),
20 );
21 let mut alert = AlertView::new(spec);
22 let panel = alert.panel(bounds, &theme, &i18n);
23 alert.draw(&mut canvas, panel, &theme, &i18n);
24 let _ = alert.handle_touch(TouchEvent::new(panel.center(), TouchPhase::Start, 1), panel);
25
26 let mut host = AlertHost::<u8, 2>::new();
27 let _ = host.present(7, spec);
28 let _ = host.layer(bounds, &theme, &i18n);
29 host.draw(&mut canvas, bounds, &theme, &i18n);
30 let _ = host.handle_touch(
31 TouchEvent::new(Point::new(160, 160), TouchPhase::End, 2),
32 bounds,
33 &theme,
34 &i18n,
35 );
36
37 let mut modal = ModalHost::new();
38 modal.show(3_u8);
39 let _ = modal.current(bounds, &theme);
40 let _ = Rgb565::BLACK;
41}Sourcepub fn clear_touch_state(&mut self)
pub fn clear_touch_state(&mut self)
Clears transient button state.
Sourcepub fn panel(
&self,
bounds: Rectangle,
theme: &FsTheme,
i18n: &I18n<'a>,
) -> Rectangle
pub fn panel( &self, bounds: Rectangle, theme: &FsTheme, i18n: &I18n<'a>, ) -> Rectangle
Returns the preferred panel rectangle for the alert.
Examples found in repository?
examples/alerts.rs (line 22)
11fn main() {
12 let bounds = Rectangle::new(Point::zero(), Size::new(320, 240));
13 let theme = support::theme();
14 let i18n = support::i18n();
15 let mut canvas = support::NullCanvas::new(bounds.size);
16
17 let spec = AlertSpec::confirm(
18 Localized::new("alert.title", "Delete item?"),
19 Localized::new("alert.message", "This action cannot be undone."),
20 );
21 let mut alert = AlertView::new(spec);
22 let panel = alert.panel(bounds, &theme, &i18n);
23 alert.draw(&mut canvas, panel, &theme, &i18n);
24 let _ = alert.handle_touch(TouchEvent::new(panel.center(), TouchPhase::Start, 1), panel);
25
26 let mut host = AlertHost::<u8, 2>::new();
27 let _ = host.present(7, spec);
28 let _ = host.layer(bounds, &theme, &i18n);
29 host.draw(&mut canvas, bounds, &theme, &i18n);
30 let _ = host.handle_touch(
31 TouchEvent::new(Point::new(160, 160), TouchPhase::End, 2),
32 bounds,
33 &theme,
34 &i18n,
35 );
36
37 let mut modal = ModalHost::new();
38 modal.show(3_u8);
39 let _ = modal.current(bounds, &theme);
40 let _ = Rgb565::BLACK;
41}Sourcepub fn handle_touch(
&mut self,
touch: TouchEvent,
panel: Rectangle,
) -> ButtonTouchResponse<u8>
pub fn handle_touch( &mut self, touch: TouchEvent, panel: Rectangle, ) -> ButtonTouchResponse<u8>
Routes one touch event to the alert buttons.
Examples found in repository?
examples/alerts.rs (line 24)
11fn main() {
12 let bounds = Rectangle::new(Point::zero(), Size::new(320, 240));
13 let theme = support::theme();
14 let i18n = support::i18n();
15 let mut canvas = support::NullCanvas::new(bounds.size);
16
17 let spec = AlertSpec::confirm(
18 Localized::new("alert.title", "Delete item?"),
19 Localized::new("alert.message", "This action cannot be undone."),
20 );
21 let mut alert = AlertView::new(spec);
22 let panel = alert.panel(bounds, &theme, &i18n);
23 alert.draw(&mut canvas, panel, &theme, &i18n);
24 let _ = alert.handle_touch(TouchEvent::new(panel.center(), TouchPhase::Start, 1), panel);
25
26 let mut host = AlertHost::<u8, 2>::new();
27 let _ = host.present(7, spec);
28 let _ = host.layer(bounds, &theme, &i18n);
29 host.draw(&mut canvas, bounds, &theme, &i18n);
30 let _ = host.handle_touch(
31 TouchEvent::new(Point::new(160, 160), TouchPhase::End, 2),
32 bounds,
33 &theme,
34 &i18n,
35 );
36
37 let mut modal = ModalHost::new();
38 modal.show(3_u8);
39 let _ = modal.current(bounds, &theme);
40 let _ = Rgb565::BLACK;
41}Sourcepub fn draw<D>(
&self,
display: &mut D,
panel: Rectangle,
theme: &FsTheme,
i18n: &I18n<'a>,
)where
D: DrawTarget<Color = Rgb565>,
pub fn draw<D>(
&self,
display: &mut D,
panel: Rectangle,
theme: &FsTheme,
i18n: &I18n<'a>,
)where
D: DrawTarget<Color = Rgb565>,
Draws the alert.
Examples found in repository?
examples/alerts.rs (line 23)
11fn main() {
12 let bounds = Rectangle::new(Point::zero(), Size::new(320, 240));
13 let theme = support::theme();
14 let i18n = support::i18n();
15 let mut canvas = support::NullCanvas::new(bounds.size);
16
17 let spec = AlertSpec::confirm(
18 Localized::new("alert.title", "Delete item?"),
19 Localized::new("alert.message", "This action cannot be undone."),
20 );
21 let mut alert = AlertView::new(spec);
22 let panel = alert.panel(bounds, &theme, &i18n);
23 alert.draw(&mut canvas, panel, &theme, &i18n);
24 let _ = alert.handle_touch(TouchEvent::new(panel.center(), TouchPhase::Start, 1), panel);
25
26 let mut host = AlertHost::<u8, 2>::new();
27 let _ = host.present(7, spec);
28 let _ = host.layer(bounds, &theme, &i18n);
29 host.draw(&mut canvas, bounds, &theme, &i18n);
30 let _ = host.handle_touch(
31 TouchEvent::new(Point::new(160, 160), TouchPhase::End, 2),
32 bounds,
33 &theme,
34 &i18n,
35 );
36
37 let mut modal = ModalHost::new();
38 modal.show(3_u8);
39 let _ = modal.current(bounds, &theme);
40 let _ = Rgb565::BLACK;
41}Sourcepub fn draw_state<D>(
&self,
display: &mut D,
panel: Rectangle,
theme: &FsTheme,
i18n: &I18n<'a>,
)where
D: DrawTarget<Color = Rgb565>,
pub fn draw_state<D>(
&self,
display: &mut D,
panel: Rectangle,
theme: &FsTheme,
i18n: &I18n<'a>,
)where
D: DrawTarget<Color = Rgb565>,
Draws the alert using the current touch state.
Trait Implementations§
impl<'a, const N: usize> Copy for AlertView<'a, N>
impl<'a, const N: usize> Eq for AlertView<'a, N>
impl<'a, const N: usize> StructuralPartialEq for AlertView<'a, N>
Auto Trait Implementations§
impl<'a, const N: usize> Freeze for AlertView<'a, N>
impl<'a, const N: usize> RefUnwindSafe for AlertView<'a, N>
impl<'a, const N: usize> Send for AlertView<'a, N>
impl<'a, const N: usize> Sync for AlertView<'a, N>
impl<'a, const N: usize> Unpin for AlertView<'a, N>
impl<'a, const N: usize> UnsafeUnpin for AlertView<'a, N>
impl<'a, const N: usize> UnwindSafe for AlertView<'a, N>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.