Skip to main content

UiApp

Struct UiApp 

Source
pub struct UiApp<'a, ViewId, Delegate, const STACK_DEPTH: usize> { /* private fields */ }
Expand description

Compatibility app wrapper retained for pre-UiSystem consumers.

Implementations§

Source§

impl<'a, ViewId, Delegate, const STACK_DEPTH: usize> UiApp<'a, ViewId, Delegate, STACK_DEPTH>
where ViewId: Copy, Delegate: ViewDelegate<'a, ViewId>,

Source

pub fn draw<D>(&self, display: &mut D, bounds: Rectangle)
where D: DrawTarget<Color = Rgb565>,

Draws the full compatibility UI.

Source

pub fn draw_interactive<D>(&self, display: &mut D, bounds: Rectangle)
where D: DrawTarget<Color = Rgb565>,

Draws only interactive chrome and the active view.

Source

pub fn draw_active_view<D>(&self, display: &mut D, bounds: Rectangle)
where D: DrawTarget<Color = Rgb565>,

Draws only the active view body.

Source

pub fn stack_motion(&self, bounds: Rectangle) -> Option<StackMotion>

Returns geometry for a stack transition, if one is active.

Source

pub fn draw_stack_motion_header<D>(&self, display: &mut D, bounds: Rectangle)
where D: DrawTarget<Color = Rgb565>,

Draws only the stack-motion header region.

Source

pub fn draw_stack_motion_base<D>(&self, display: &mut D, bounds: Rectangle)
where D: DrawTarget<Color = Rgb565>,

Draws the base layer for a stack transition.

Source

pub fn draw_stack_motion_overlay<D>(&self, display: &mut D, bounds: Rectangle)
where D: DrawTarget<Color = Rgb565>,

Draws the overlay layer for a stack transition.

Source§

impl<'a, ViewId, Delegate, const STACK_DEPTH: usize> UiApp<'a, ViewId, Delegate, STACK_DEPTH>
where ViewId: Copy, Delegate: ViewDelegate<'a, ViewId>,

Source

pub fn new( root: ViewId, delegate: Delegate, theme: FsTheme, i18n: I18n<'a>, ) -> Self

Creates a compatibility app rooted at root.

Examples found in repository?
examples/root_delegate.rs (lines 54-59)
53fn main() {
54    let _ui = UiApp::<AppView, DemoDelegate, 8>::new(
55        AppView::Home,
56        DemoDelegate::new(),
57        FsTheme::default(),
58        I18n::new("en", "en", &[]),
59    );
60}
Source

pub const fn delegate(&self) -> &Delegate

Returns the delegate.

Source

pub fn delegate_mut(&mut self) -> &mut Delegate

Returns the delegate mutably.

Source

pub const fn theme(&self) -> &FsTheme

Returns the active theme.

Source

pub fn theme_mut(&mut self) -> &mut FsTheme

Returns the active theme mutably.

Source

pub const fn i18n(&self) -> &I18n<'a>

Returns the active localization tables.

Source

pub fn i18n_mut(&mut self) -> &mut I18n<'a>

Returns the active localization tables mutably.

Source

pub fn active_view(&self) -> ViewId

Returns the currently visible view identifier.

Source

pub fn is_animating(&self) -> bool

Returns whether a stack animation is active.

Examples found in repository?
src/app/ui_app.rs (line 101)
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    }
Source

pub fn content_frame(&self, bounds: Rectangle) -> Rectangle

Returns the body frame for the active view.

Examples found in repository?
src/app/ui_app.rs (line 79)
78    pub fn active_view_dirty(&self, bounds: Rectangle) -> Rectangle {
79        self.content_frame(bounds)
80    }
81
82    /// Advances the compatibility app by one tick.
83    pub fn tick(&mut self, dt_ms: u32, bounds: Rectangle) -> AppRedraw {
84        if self.stack.advance(dt_ms) {
85            return AppRedraw::StackMotion;
86        }
87        let body = self.content_frame(bounds);
88        let response = self
89            .delegate
90            .tick(self.stack.top(), dt_ms, body, &self.theme, &self.i18n);
91        self.apply_response(response)
92    }
Source

pub fn active_view_dirty(&self, bounds: Rectangle) -> Rectangle

Returns the dirty region for the active view.

Source

pub fn tick(&mut self, dt_ms: u32, bounds: Rectangle) -> AppRedraw

Advances the compatibility app by one tick.

Source

pub fn handle_touch( &mut self, touch: TouchEvent, bounds: Rectangle, ) -> AppRedraw

Handles one touch event.

Source

pub fn handle_touch_result( &mut self, touch: TouchEvent, bounds: Rectangle, ) -> AppTouchResult

Handles one touch event and returns capture status.

Examples found in repository?
src/app/ui_app.rs (line 96)
95    pub fn handle_touch(&mut self, touch: TouchEvent, bounds: Rectangle) -> AppRedraw {
96        self.handle_touch_result(touch, bounds).redraw
97    }
Source

pub fn clear_touch_state(&mut self)

Clears all compatibility touch state.

Examples found in repository?
src/app/ui_app.rs (line 111)
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    }
144
145    /// Clears all compatibility touch state.
146    pub fn clear_touch_state(&mut self) {
147        self.nav_touch.clear();
148        self.delegate.clear_touch_state();
149    }
150
151    fn apply_response(&mut self, response: ViewResponse<ViewId>) -> AppRedraw {
152        let mut redraw = response.redraw;
153        match response.navigation {
154            Some(AppNavigation::Push(view)) => {
155                self.clear_touch_state();
156                if self.stack.push(view).is_ok() {
157                    redraw = redraw.merge(AppRedraw::StackMotion);
158                }
159            }
160            Some(AppNavigation::Pop) => {
161                self.clear_touch_state();
162                if self.stack.pop().is_ok() {
163                    redraw = redraw.merge(AppRedraw::StackMotion);
164                }
165            }
166            None => {}
167        }
168        redraw
169    }

Auto Trait Implementations§

§

impl<'a, ViewId, Delegate, const STACK_DEPTH: usize> Freeze for UiApp<'a, ViewId, Delegate, STACK_DEPTH>
where Delegate: Freeze, ViewId: Freeze,

§

impl<'a, ViewId, Delegate, const STACK_DEPTH: usize> RefUnwindSafe for UiApp<'a, ViewId, Delegate, STACK_DEPTH>
where Delegate: RefUnwindSafe, ViewId: RefUnwindSafe,

§

impl<'a, ViewId, Delegate, const STACK_DEPTH: usize> Send for UiApp<'a, ViewId, Delegate, STACK_DEPTH>
where Delegate: Send, ViewId: Send,

§

impl<'a, ViewId, Delegate, const STACK_DEPTH: usize> Sync for UiApp<'a, ViewId, Delegate, STACK_DEPTH>
where Delegate: Sync, ViewId: Sync,

§

impl<'a, ViewId, Delegate, const STACK_DEPTH: usize> Unpin for UiApp<'a, ViewId, Delegate, STACK_DEPTH>
where Delegate: Unpin, ViewId: Unpin,

§

impl<'a, ViewId, Delegate, const STACK_DEPTH: usize> UnsafeUnpin for UiApp<'a, ViewId, Delegate, STACK_DEPTH>
where Delegate: UnsafeUnpin, ViewId: UnsafeUnpin,

§

impl<'a, ViewId, Delegate, const STACK_DEPTH: usize> UnwindSafe for UiApp<'a, ViewId, Delegate, STACK_DEPTH>
where Delegate: UnwindSafe, ViewId: 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> 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.