Skip to main content

UiView

Trait UiView 

Source
pub trait UiView<'text, ViewId, Message, const N: usize> {
    // Required methods
    fn configure(
        &mut self,
        registration: &mut ViewRegistration<'text, ViewId, N>,
    );
    fn handle_touch(
        &mut self,
        touch: TouchEvent,
        registration: &ViewRegistration<'text, ViewId, N>,
        env: &ViewEnvironment<'_, 'text>,
    ) -> ViewEvent<Message>;
    fn draw<D>(
        &self,
        display: &mut D,
        registration: &ViewRegistration<'text, ViewId, N>,
        env: &ViewEnvironment<'_, 'text>,
    )
       where D: UiCanvas;

    // Provided method
    fn update(
        &mut self,
        _dt_ms: u32,
        _registration: &ViewRegistration<'text, ViewId, N>,
        _env: &ViewEnvironment<'_, 'text>,
    ) -> ViewEvent<Message> { ... }
}
Expand description

Root contract implemented by application-defined views.

Required Methods§

Source

fn configure(&mut self, registration: &mut ViewRegistration<'text, ViewId, N>)

Declares the view frame, title, and child hierarchy.

Source

fn handle_touch( &mut self, touch: TouchEvent, registration: &ViewRegistration<'text, ViewId, N>, env: &ViewEnvironment<'_, 'text>, ) -> ViewEvent<Message>

Handles a touch event routed to the view tree.

Source

fn draw<D>( &self, display: &mut D, registration: &ViewRegistration<'text, ViewId, N>, env: &ViewEnvironment<'_, 'text>, )
where D: UiCanvas,

Draws the current view state.

Provided Methods§

Source

fn update( &mut self, _dt_ms: u32, _registration: &ViewRegistration<'text, ViewId, N>, _env: &ViewEnvironment<'_, 'text>, ) -> ViewEvent<Message>

Advances internal state and returns any redraw or message output.

Examples found in repository?
src/system.rs (line 123)
118    pub fn update(&mut self, dt_ms: u32) -> ViewEvent<Message> {
119        let env = ViewEnvironment {
120            theme: &self.theme,
121            i18n: &self.i18n,
122        };
123        self.root.update(dt_ms, &self.registration, &env)
124    }

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.

Implementors§