pub trait ViewDelegate<'a, ViewId> {
// Required methods
fn title(&self, view: ViewId) -> Localized<'a>;
fn draw_view<D>(
&self,
view: ViewId,
display: &mut D,
frame: Rectangle,
theme: &FsTheme,
i18n: &I18n<'a>,
)
where D: DrawTarget<Color = Rgb565>;
fn handle_view_touch(
&mut self,
view: ViewId,
touch: TouchEvent,
frame: Rectangle,
theme: &FsTheme,
i18n: &I18n<'a>,
) -> ViewResponse<ViewId>;
// Provided methods
fn draw_layer<D>(
&self,
view: ViewId,
display: &mut D,
frame: Rectangle,
animated: bool,
theme: &FsTheme,
i18n: &I18n<'a>,
)
where D: DrawTarget<Color = Rgb565> { ... }
fn tick(
&mut self,
_view: ViewId,
_dt_ms: u32,
_frame: Rectangle,
_theme: &FsTheme,
_i18n: &I18n<'a>,
) -> ViewResponse<ViewId> { ... }
fn clear_touch_state(&mut self) { ... }
}Expand description
Compatibility delegate API retained for older UiApp consumers.
Required Methods§
Sourcefn draw_view<D>(
&self,
view: ViewId,
display: &mut D,
frame: Rectangle,
theme: &FsTheme,
i18n: &I18n<'a>,
)where
D: DrawTarget<Color = Rgb565>,
fn draw_view<D>(
&self,
view: ViewId,
display: &mut D,
frame: Rectangle,
theme: &FsTheme,
i18n: &I18n<'a>,
)where
D: DrawTarget<Color = Rgb565>,
Draws one view.
Sourcefn handle_view_touch(
&mut self,
view: ViewId,
touch: TouchEvent,
frame: Rectangle,
theme: &FsTheme,
i18n: &I18n<'a>,
) -> ViewResponse<ViewId>
fn handle_view_touch( &mut self, view: ViewId, touch: TouchEvent, frame: Rectangle, theme: &FsTheme, i18n: &I18n<'a>, ) -> ViewResponse<ViewId>
Handles a touch event for view.
Provided Methods§
Sourcefn draw_layer<D>(
&self,
view: ViewId,
display: &mut D,
frame: Rectangle,
animated: bool,
theme: &FsTheme,
i18n: &I18n<'a>,
)where
D: DrawTarget<Color = Rgb565>,
fn draw_layer<D>(
&self,
view: ViewId,
display: &mut D,
frame: Rectangle,
animated: bool,
theme: &FsTheme,
i18n: &I18n<'a>,
)where
D: DrawTarget<Color = Rgb565>,
Draws one view layer during animation.
Examples found in repository?
src/app/render.rs (lines 98-105)
93 pub(super) fn draw_layer<D>(&self, display: &mut D, layer: Layer<ViewId>)
94 where
95 D: DrawTarget<Color = Rgb565>,
96 {
97 if layer.offset == Point::zero() {
98 self.delegate.draw_layer(
99 layer.key,
100 display,
101 layer.frame,
102 false,
103 &self.theme,
104 &self.i18n,
105 );
106 return;
107 }
108
109 let mut translated = display.translated(layer.offset);
110 let mut clipped = translated.clipped(&layer.frame);
111 self.delegate.draw_layer(
112 layer.key,
113 &mut clipped,
114 layer.frame,
115 true,
116 &self.theme,
117 &self.i18n,
118 );
119 }Sourcefn tick(
&mut self,
_view: ViewId,
_dt_ms: u32,
_frame: Rectangle,
_theme: &FsTheme,
_i18n: &I18n<'a>,
) -> ViewResponse<ViewId>
fn tick( &mut self, _view: ViewId, _dt_ms: u32, _frame: Rectangle, _theme: &FsTheme, _i18n: &I18n<'a>, ) -> ViewResponse<ViewId>
Advances per-view time-based state.
Sourcefn clear_touch_state(&mut self)
fn clear_touch_state(&mut self)
Clears any delegate-owned touch state.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.