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>,
impl<'a, ViewId, Delegate, const STACK_DEPTH: usize> UiApp<'a, ViewId, Delegate, STACK_DEPTH>where
ViewId: Copy,
Delegate: ViewDelegate<'a, ViewId>,
Sourcepub fn draw<D>(&self, display: &mut D, bounds: Rectangle)where
D: DrawTarget<Color = Rgb565>,
pub fn draw<D>(&self, display: &mut D, bounds: Rectangle)where
D: DrawTarget<Color = Rgb565>,
Draws the full compatibility UI.
Sourcepub fn draw_interactive<D>(&self, display: &mut D, bounds: Rectangle)where
D: DrawTarget<Color = Rgb565>,
pub fn draw_interactive<D>(&self, display: &mut D, bounds: Rectangle)where
D: DrawTarget<Color = Rgb565>,
Draws only interactive chrome and the active view.
Sourcepub fn draw_active_view<D>(&self, display: &mut D, bounds: Rectangle)where
D: DrawTarget<Color = Rgb565>,
pub fn draw_active_view<D>(&self, display: &mut D, bounds: Rectangle)where
D: DrawTarget<Color = Rgb565>,
Draws only the active view body.
Sourcepub fn stack_motion(&self, bounds: Rectangle) -> Option<StackMotion>
pub fn stack_motion(&self, bounds: Rectangle) -> Option<StackMotion>
Returns geometry for a stack transition, if one is active.
Sourcepub fn draw_stack_motion_header<D>(&self, display: &mut D, bounds: Rectangle)where
D: DrawTarget<Color = Rgb565>,
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.
Sourcepub fn draw_stack_motion_base<D>(&self, display: &mut D, bounds: Rectangle)where
D: DrawTarget<Color = Rgb565>,
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.
Sourcepub fn draw_stack_motion_overlay<D>(&self, display: &mut D, bounds: Rectangle)where
D: DrawTarget<Color = Rgb565>,
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>,
impl<'a, ViewId, Delegate, const STACK_DEPTH: usize> UiApp<'a, ViewId, Delegate, STACK_DEPTH>where
ViewId: Copy,
Delegate: ViewDelegate<'a, ViewId>,
Sourcepub fn new(
root: ViewId,
delegate: Delegate,
theme: FsTheme,
i18n: I18n<'a>,
) -> Self
pub fn new( root: ViewId, delegate: Delegate, theme: FsTheme, i18n: I18n<'a>, ) -> Self
Creates a compatibility app rooted at root.
Sourcepub fn delegate_mut(&mut self) -> &mut Delegate
pub fn delegate_mut(&mut self) -> &mut Delegate
Returns the delegate mutably.
Sourcepub fn active_view(&self) -> ViewId
pub fn active_view(&self) -> ViewId
Returns the currently visible view identifier.
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
Returns whether a stack animation is active.
Examples found in repository?
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 }Sourcepub fn content_frame(&self, bounds: Rectangle) -> Rectangle
pub fn content_frame(&self, bounds: Rectangle) -> Rectangle
Returns the body frame for the active view.
Examples found in repository?
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 }Sourcepub fn active_view_dirty(&self, bounds: Rectangle) -> Rectangle
pub fn active_view_dirty(&self, bounds: Rectangle) -> Rectangle
Returns the dirty region for the active view.
Sourcepub fn tick(&mut self, dt_ms: u32, bounds: Rectangle) -> AppRedraw
pub fn tick(&mut self, dt_ms: u32, bounds: Rectangle) -> AppRedraw
Advances the compatibility app by one tick.
Sourcepub fn handle_touch(
&mut self,
touch: TouchEvent,
bounds: Rectangle,
) -> AppRedraw
pub fn handle_touch( &mut self, touch: TouchEvent, bounds: Rectangle, ) -> AppRedraw
Handles one touch event.
Sourcepub fn handle_touch_result(
&mut self,
touch: TouchEvent,
bounds: Rectangle,
) -> AppTouchResult
pub fn handle_touch_result( &mut self, touch: TouchEvent, bounds: Rectangle, ) -> AppTouchResult
Handles one touch event and returns capture status.
Sourcepub fn clear_touch_state(&mut self)
pub fn clear_touch_state(&mut self)
Clears all compatibility touch state.
Examples found in repository?
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 }