Skip to main content

NavView

Struct NavView 

Source
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: Rectangle

Full navigation frame.

§header: Rectangle

Header frame.

§body: Rectangle

Body frame below the header.

§layers: StackLayers<K>

Presentation layers for the body.

Implementations§

Source§

impl<'a> NavView<'a, ()>

Source

pub fn root(frame: Rectangle, title: Localized<'a>) -> Self

Creates a non-navigating root navigation view.

Source§

impl<'a, K> NavView<'a, K>

Source

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.

Source

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?
src/stack_view.rs (line 116)
111    pub fn draw_static_chrome<D>(&self, display: &mut D, theme: &FsTheme, i18n: &I18n<'a>)
112    where
113        D: DrawTarget<Color = Rgb565>,
114    {
115        let touch = ButtonTouchState::new();
116        self.draw_chrome(display, theme, i18n, &touch);
117    }
More examples
Hide additional 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    }
Source

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?
src/containers.rs (line 155)
149    pub fn handle_touch(
150        &mut self,
151        touch: TouchEvent,
152        frame: Rectangle,
153    ) -> ButtonTouchResponse<NavHeaderAction> {
154        self.nav_view(frame)
155            .handle_touch(&mut self.header_touch, touch)
156    }
More examples
Hide additional 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§

Source§

impl<'a, K: Clone> Clone for NavView<'a, K>

Source§

fn clone(&self) -> NavView<'a, K>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, K: Debug> Debug for NavView<'a, K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, K: PartialEq> PartialEq for NavView<'a, K>

Source§

fn eq(&self, other: &NavView<'a, K>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, K: Copy> Copy for NavView<'a, K>

Source§

impl<'a, K: Eq> Eq for NavView<'a, K>

Source§

impl<'a, K> StructuralPartialEq for NavView<'a, K>

Auto Trait Implementations§

§

impl<'a, K> Freeze for NavView<'a, K>
where K: Freeze,

§

impl<'a, K> RefUnwindSafe for NavView<'a, K>
where K: RefUnwindSafe,

§

impl<'a, K> Send for NavView<'a, K>
where K: Send,

§

impl<'a, K> Sync for NavView<'a, K>
where K: Sync,

§

impl<'a, K> Unpin for NavView<'a, K>
where K: Unpin,

§

impl<'a, K> UnsafeUnpin for NavView<'a, K>
where K: UnsafeUnpin,

§

impl<'a, K> UnwindSafe for NavView<'a, K>
where K: UnwindSafe,

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.