pub struct NavView<'a, K> {
pub frame: Rectangle,
pub header: Rectangle,
pub body: Rectangle,
pub layers: StackLayers<K>,
/* private fields */
}Expand description
Navigation chrome plus stack body geometry.
Fields§
§frame: RectangleFull navigation frame.
header: RectangleHeader frame.
body: RectangleBody frame below the header.
layers: StackLayers<K>Presentation layers for the body.
Implementations§
Sourcepub fn draw_static_chrome<D>(
&self,
display: &mut D,
theme: &FsTheme,
i18n: &I18n<'a>,
)where
D: DrawTarget<Color = Rgb565>,
pub fn draw_static_chrome<D>(
&self,
display: &mut D,
theme: &FsTheme,
i18n: &I18n<'a>,
)where
D: DrawTarget<Color = Rgb565>,
Draws navigation chrome without preserving touch state.
Sourcepub fn draw_chrome<D>(
&self,
display: &mut D,
theme: &FsTheme,
i18n: &I18n<'a>,
touch: &ButtonTouchState<NavHeaderAction>,
)where
D: DrawTarget<Color = Rgb565>,
pub fn draw_chrome<D>(
&self,
display: &mut D,
theme: &FsTheme,
i18n: &I18n<'a>,
touch: &ButtonTouchState<NavHeaderAction>,
)where
D: DrawTarget<Color = Rgb565>,
Draws navigation chrome using explicit header touch state.
Examples found in repository?
More examples
src/containers.rs (line 171)
159 pub fn draw_chrome<D>(
160 &self,
161 display: &mut D,
162 frame: Rectangle,
163 theme: &FsTheme,
164 i18n: &I18n<'a>,
165 ) where
166 D: embedded_graphics::draw_target::DrawTarget<
167 Color = embedded_graphics::pixelcolor::Rgb565,
168 >,
169 {
170 self.nav_view(frame)
171 .draw_chrome(display, theme, i18n, &self.header_touch);
172 }src/app/render.rs (line 23)
18 pub fn draw<D>(&self, display: &mut D, bounds: Rectangle)
19 where
20 D: DrawTarget<Color = Rgb565>,
21 {
22 let nav = self.nav_view(bounds);
23 nav.draw_chrome(display, &self.theme, &self.i18n, &self.nav_touch);
24 self.draw_layer(display, nav.layers.base);
25 if let Some(overlay) = nav.layers.overlay {
26 self.draw_layer(display, overlay);
27 }
28 }
29
30 /// Draws only interactive chrome and the active view.
31 pub fn draw_interactive<D>(&self, display: &mut D, bounds: Rectangle)
32 where
33 D: DrawTarget<Color = Rgb565>,
34 {
35 let nav = self.nav_view(bounds);
36 nav.draw_chrome(display, &self.theme, &self.i18n, &self.nav_touch);
37 self.delegate
38 .draw_view(self.stack.top(), display, nav.body, &self.theme, &self.i18n);
39 }
40
41 /// Draws only the active view body.
42 pub fn draw_active_view<D>(&self, display: &mut D, bounds: Rectangle)
43 where
44 D: DrawTarget<Color = Rgb565>,
45 {
46 let nav = self.nav_view(bounds);
47 self.delegate
48 .draw_view(self.stack.top(), display, nav.body, &self.theme, &self.i18n);
49 }
50
51 /// Returns geometry for a stack transition, if one is active.
52 pub fn stack_motion(&self, bounds: Rectangle) -> Option<StackMotion> {
53 let nav = self.nav_view(bounds);
54 nav.layers.overlay.map(|overlay| StackMotion {
55 header: nav.header,
56 body: nav.body,
57 overlay: overlay.translated_frame(),
58 })
59 }
60
61 /// Draws only the stack-motion header region.
62 pub fn draw_stack_motion_header<D>(&self, display: &mut D, bounds: Rectangle)
63 where
64 D: DrawTarget<Color = Rgb565>,
65 {
66 self.nav_view(bounds)
67 .draw_chrome(display, &self.theme, &self.i18n, &self.nav_touch);
68 }Sourcepub fn handle_touch(
&self,
touch_state: &mut ButtonTouchState<NavHeaderAction>,
touch: TouchEvent,
) -> ButtonTouchResponse<NavHeaderAction>
pub fn handle_touch( &self, touch_state: &mut ButtonTouchState<NavHeaderAction>, touch: TouchEvent, ) -> ButtonTouchResponse<NavHeaderAction>
Routes one touch event to the navigation header.
Examples found in repository?
More examples
src/app/ui_app.rs (line 109)
100 pub fn handle_touch_result(&mut self, touch: TouchEvent, bounds: Rectangle) -> AppTouchResult {
101 if self.is_animating() {
102 return AppTouchResult {
103 redraw: AppRedraw::None,
104 captured: false,
105 };
106 }
107
108 let nav = self.nav_view(bounds);
109 let chrome = nav.handle_touch(&mut self.nav_touch, touch);
110 if chrome.action == Some(NavHeaderAction::Back) {
111 self.clear_touch_state();
112 return AppTouchResult {
113 redraw: self
114 .stack
115 .pop()
116 .map(|_| AppRedraw::StackMotion)
117 .unwrap_or(AppRedraw::None),
118 captured: true,
119 };
120 }
121 if chrome.captured {
122 return AppTouchResult {
123 redraw: if chrome.redraw {
124 AppRedraw::Interactive
125 } else {
126 AppRedraw::None
127 },
128 captured: true,
129 };
130 }
131
132 let response = self.delegate.handle_view_touch(
133 self.stack.top(),
134 touch,
135 nav.body,
136 &self.theme,
137 &self.i18n,
138 );
139 AppTouchResult {
140 redraw: self.apply_response(response),
141 captured: response.captured || response.navigation.is_some(),
142 }
143 }Trait Implementations§
Auto Trait Implementations§
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.