Skip to main content

Widget

Trait Widget 

Source
pub trait Widget<C, M>
where C: PixelColor, M: Clone,
{
Show 16 methods // Required methods fn measure(&mut self, constraints: Constraints) -> Size; fn arrange(&mut self, rect: Rectangle); fn rect(&self) -> Rectangle; fn handle_touch(&mut self, point: Point, phase: TouchPhase) -> Option<M>; fn draw<'t>( &self, renderer: &mut dyn Renderer<C>, theme: &Theme<'t, C>, ) -> Result<(), RenderError>; // Provided methods fn preferred_size(&self) -> (Length, Length) { ... } fn mark_pressed(&mut self, point: Point) { ... } fn widget_id(&self) -> Option<WidgetId> { ... } fn is_focusable(&self) -> bool { ... } fn collect_focusable(&self, out: &mut Vec<WidgetId>) { ... } fn sync_focus(&mut self, focused: Option<WidgetId>) { ... } fn handle_action(&mut self, action: UiAction) -> Option<M> { ... } fn route_action(&mut self, target: WidgetId, action: UiAction) -> Option<M> { ... } fn navigate_focus( &self, target: WidgetId, action: UiAction, ) -> Option<WidgetId> { ... } fn focus_rect(&self, target: WidgetId) -> Option<Rectangle> { ... } fn focus_at(&self, point: Point) -> Option<WidgetId> { ... }
}
Expand description

Object-safe widget contract.

Required Methods§

Source

fn measure(&mut self, constraints: Constraints) -> Size

Report the size this widget wants within constraints.

Source

fn arrange(&mut self, rect: Rectangle)

Commit the final rectangle, recursively arranging any children.

Source

fn rect(&self) -> Rectangle

The current arranged rectangle.

Source

fn handle_touch(&mut self, point: Point, phase: TouchPhase) -> Option<M>

Dispatch a touch event. Returns a message if consumed.

Source

fn draw<'t>( &self, renderer: &mut dyn Renderer<C>, theme: &Theme<'t, C>, ) -> Result<(), RenderError>

Paint into renderer at rect.

Provided Methods§

Source

fn preferred_size(&self) -> (Length, Length)

Per-axis sizing intent set via .width(...) / .height(...). Containers consult this during layout to allocate fixed slots, query intrinsic sizes, and split residual space among Fill / FillPortion children. Default is Length::Fill on both axes.

Source

fn mark_pressed(&mut self, point: Point)

Set this widget’s pressed flag if point hits. No message emit. Containers forward to children. Default no-op.

Source

fn widget_id(&self) -> Option<WidgetId>

Stable id of this widget, if it participates in focus.

Source

fn is_focusable(&self) -> bool

True if this widget should appear in focus traversal.

Source

fn collect_focusable(&self, out: &mut Vec<WidgetId>)

Append focusable widget ids in traversal order.

Source

fn sync_focus(&mut self, focused: Option<WidgetId>)

Synchronize focused state against the runtime’s currently-focused id.

Source

fn handle_action(&mut self, action: UiAction) -> Option<M>

Handle a semantic action directed at this widget.

Source

fn route_action(&mut self, target: WidgetId, action: UiAction) -> Option<M>

Route a semantic action to the widget with id target.

Source

fn navigate_focus(&self, target: WidgetId, action: UiAction) -> Option<WidgetId>

Request a focus movement relative to target for directional actions.

Source

fn focus_rect(&self, target: WidgetId) -> Option<Rectangle>

Rectangle currently occupied by the focusable target, if any.

Source

fn focus_at(&self, point: Point) -> Option<WidgetId>

Focusable widget id at point, if any.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, C, M> Widget<C, M> for Element<'a, C, M>
where C: PixelColor, M: Clone,

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Column<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Container<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Dropdown<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Grid<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Keyboard<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for List<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for MessageBox<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Roller<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Row<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Scrollable<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Stack<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for TabBar<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Table<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Tileview<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Window<'a, C, M>

Source§

impl<'a, C: PixelColor + 'a, M: Clone> Widget<C, M> for Chart<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Arc<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Button<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Calendar<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Canvas<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Checkbox<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Image<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for ImageButton<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Line<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for ListRow<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Scale<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Slider<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for SpanGroup<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for SpinButton<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Spinner<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Switch<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for TableRow<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for Text<'a, C, M>

Source§

impl<'a, C: PixelColor, M: Clone> Widget<C, M> for TextArea<'a, C, M>

Source§

impl<C: PixelColor, M: Clone> Widget<C, M> for Divider<C, M>

Source§

impl<C: PixelColor, M: Clone> Widget<C, M> for LED<C, M>

Source§

impl<C: PixelColor, M: Clone> Widget<C, M> for Menu<C, M>

Source§

impl<C: PixelColor, M: Clone> Widget<C, M> for ProgressBar<C, M>

Source§

impl<C: PixelColor, M: Clone> Widget<C, M> for Qr<C, M>

Source§

impl<C: PixelColor, M: Clone> Widget<C, M> for RadioButton<C, M>

Source§

impl<C: PixelColor, M: Clone> Widget<C, M> for Space<C, M>

Source§

impl<M: Clone> Widget<Rgb565, M> for WeatherIcon