pub trait Widget:
Debug
+ Send
+ Sync {
// Required methods
fn id(&self) -> WidgetId;
fn rect(&self) -> Rect;
fn set_rect(&mut self, rect: Rect);
fn draw(&self, dl: &mut DrawList, theme: &Theme);
fn handle_input(
&mut self,
input: &UiInput,
events: &mut Vec<UiEvent>,
theme: &Theme,
dt: f32,
);
// Provided methods
fn is_visible(&self) -> bool { ... }
fn preferred_size(&self) -> (SizeConstraint, SizeConstraint) { ... }
fn update(&mut self, _dt: f32) { ... }
}Expand description
A UI widget that can draw itself and handle input.
Required Methods§
fn id(&self) -> WidgetId
fn rect(&self) -> Rect
fn set_rect(&mut self, rect: Rect)
fn draw(&self, dl: &mut DrawList, theme: &Theme)
fn handle_input( &mut self, input: &UiInput, events: &mut Vec<UiEvent>, theme: &Theme, dt: f32, )
Provided Methods§
fn is_visible(&self) -> bool
fn preferred_size(&self) -> (SizeConstraint, SizeConstraint)
fn update(&mut self, _dt: f32)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".