Widget

Trait Widget 

Source
pub trait Widget {
    // Required methods
    fn bounds(&self) -> Rect;
    fn draw(&self, renderer: &mut dyn Renderer);
    fn handle_event(&mut self, event: &Event) -> bool;
}
Expand description

Base trait implemented by all widgets.

A widget is expected to provide its bounds, draw itself using a Renderer, and optionally handle input Events.

Required Methods§

Source

fn bounds(&self) -> Rect

Return the area this widget occupies relative to its parent.

Source

fn draw(&self, renderer: &mut dyn Renderer)

Render the widget using the provided Renderer.

Source

fn handle_event(&mut self, event: &Event) -> bool

Handle an event and return true if it was consumed.

The default implementation for most widgets will simply ignore the event and return false.

Implementors§