Skip to main content

Widget

Trait Widget 

Source
pub trait Widget:
    Brick
    + Send
    + Sync {
Show 13 methods // Required methods fn type_id(&self) -> TypeId; fn measure(&self, constraints: Constraints) -> Size; fn layout(&mut self, bounds: Rect) -> LayoutResult; fn paint(&self, canvas: &mut dyn Canvas); fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>; fn children(&self) -> &[Box<dyn Widget>]; fn children_mut(&mut self) -> &mut [Box<dyn Widget>]; // Provided methods fn is_interactive(&self) -> bool { ... } fn is_focusable(&self) -> bool { ... } fn accessible_name(&self) -> Option<&str> { ... } fn accessible_role(&self) -> AccessibleRole { ... } fn test_id(&self) -> Option<&str> { ... } fn bounds(&self) -> Rect { ... }
}
Expand description

Core widget trait that all UI elements implement.

§Brick Architecture (PROBAR-SPEC-009)

Widget REQUIRES the Brick trait, enforcing the “tests define interface” philosophy:

  • Every Widget has assertions that define its contract
  • Every Widget has a performance budget
  • Rendering is blocked if assertions fail (Popperian falsification)

§Lifecycle

  1. verify: Check Brick assertions (mandatory)
  2. measure: Compute intrinsic size given constraints
  3. layout: Position self and children within allocated bounds
  4. paint: Generate draw commands (only if can_render() returns true)

Required Methods§

Source

fn type_id(&self) -> TypeId

Get the type identifier for this widget type.

Source

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

Compute intrinsic size constraints.

Source

fn layout(&mut self, bounds: Rect) -> LayoutResult

Position children within allocated bounds.

Source

fn paint(&self, canvas: &mut dyn Canvas)

Generate draw commands for rendering.

§Panics

Panics if called when can_render() returns false (Brick verification failed).

Source

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Handle input events.

Source

fn children(&self) -> &[Box<dyn Widget>]

Get child widgets for tree traversal.

Source

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Get mutable child widgets.

Provided Methods§

Source

fn is_interactive(&self) -> bool

Check if this widget is interactive (can receive focus/events).

Source

fn is_focusable(&self) -> bool

Check if this widget can receive keyboard focus.

Source

fn accessible_name(&self) -> Option<&str>

Get the accessible name for screen readers.

Source

fn accessible_role(&self) -> AccessibleRole

Get the accessible role.

Source

fn test_id(&self) -> Option<&str>

Get the test ID for this widget (if any).

Source

fn bounds(&self) -> Rect

Get the current bounds of this widget.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Widget for Button

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Chart

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, _event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Checkbox

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Column

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Container

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for DataCard

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, _event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for DataTable

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, _event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Image

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, _event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for List

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_focusable(&self) -> bool

Source§

fn test_id(&self) -> Option<&str>

Source§

fn bounds(&self) -> Rect

Source§

impl Widget for Menu

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_focusable(&self) -> bool

Source§

fn test_id(&self) -> Option<&str>

Source§

fn bounds(&self) -> Rect

Source§

impl Widget for Modal

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_focusable(&self) -> bool

Source§

fn test_id(&self) -> Option<&str>

Source§

fn bounds(&self) -> Rect

Source§

impl Widget for ModelCard

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, _event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for ProgressBar

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, _event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for RadioGroup

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Row

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Select

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Slider

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Stack

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Tabs

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Text

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, _event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for TextInput

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Toggle

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Source§

impl Widget for Tooltip

Source§

fn type_id(&self) -> TypeId

Source§

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

Source§

fn layout(&mut self, _bounds: Rect) -> LayoutResult

Source§

fn paint(&self, canvas: &mut dyn Canvas)

Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Source§

fn is_interactive(&self) -> bool

Source§

fn is_focusable(&self) -> bool

Source§

fn accessible_name(&self) -> Option<&str>

Source§

fn accessible_role(&self) -> AccessibleRole

Source§

fn test_id(&self) -> Option<&str>

Implementors§