Expand description
§Widget
A UI element that exists in a window, whether visible or otherwise, that consumes and alternatively generates events.
Every Widget owns a WidgetCore, which stores the state that all Widgets share: the
ID, parent ID, origin, size, color, visibility, and invalidation flag. The
Widget trait provides default implementations for all of the getters and setters against
the WidgetCore, so a new Widget only needs to implement three functions:
use pushrod::paint::{self, Painter};
use pushrod::widget::{Widget, WidgetCore};
pub struct MyWidget {
core: WidgetCore,
}
impl Widget for MyWidget {
fn core(&self) -> &WidgetCore { &self.core }
fn core_mut(&mut self) -> &mut WidgetCore { &mut self.core }
fn paint(&self, p: &mut dyn Painter) {
paint::fill(p, self.get_color());
}
}If the compiler is happy, the Widget is complete: there are no lists of Widget types to
update elsewhere in the library.
Structs§
- Behavior
- What a
Widgetcan do, stored on itsWidgetCore. - Visual
State - How a
Widgetcurrently looks, stored on itsWidgetCore. - Widget
Core - The state that every
Widgetshares.
Constants§
- ROOT_
WIDGET_ ID - The ID of the window’s root
Widget.
Traits§
- Widget
- A drawable, interactive object presented in a window.
Type Aliases§
- Widget
Id - The ID of a
Widget.