Skip to main content

Widget

Trait Widget 

Source
pub trait Widget<Msg>: 'static {
    // Required methods
    fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size;
    fn paint(&self, cx: &mut PaintCx<'_>, area: Rect);

    // Provided methods
    fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect) { ... }
    fn event(&self, _cx: &mut EventCx<'_, Msg>, _event: &Event) -> bool { ... }
    fn focusable(&self) -> bool { ... }
    fn children(&self) -> &[Node<Msg>] { ... }
    fn children_mut(&mut self) -> &mut [Node<Msg>] { ... }
}
Expand description

Something that can be laid out, painted and interacted with.

Widgets are plain values created in view every frame. Anything that must survive between frames and is not application data (a cursor position, a scroll offset) is kept in runtime memory through PaintCx::memory and EventCx::memory.

Required Methods§

Source

fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size

The size the widget wants when it may use up to available.

Source

fn paint(&self, cx: &mut PaintCx<'_>, area: Rect)

Draws the widget into area.

Provided Methods§

Source

fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)

Draws the widget’s overlay after the whole view was painted, when it asked for one with PaintCx::request_overlay. anchor is the area the widget was painted in.

Source

fn event(&self, _cx: &mut EventCx<'_, Msg>, _event: &Event) -> bool

Handles input. Returns true when the event was used; unused key and scroll events bubble to the parent widget.

Source

fn focusable(&self) -> bool

Whether the widget can take keyboard focus.

Source

fn children(&self) -> &[Node<Msg>]

Child nodes, for widgets that contain other widgets.

Source

fn children_mut(&mut self) -> &mut [Node<Msg>]

Mutable child nodes, used to assign ids.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<Msg: 'static> Widget<Msg> for Accordion<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Axis

Source§

impl<Msg: 'static> Widget<Msg> for Badge

Source§

impl<Msg: 'static> Widget<Msg> for BarChart<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for BigText

Source§

impl<Msg: 'static> Widget<Msg> for Breadcrumb<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Checkbox<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for DatePicker<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Divider

Source§

impl<Msg: 'static> Widget<Msg> for DurationInput<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Field<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Form<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Gauge

Source§

impl<Msg: 'static> Widget<Msg> for Ghost

Source§

impl<Msg: 'static> Widget<Msg> for GlyphSample

Source§

impl<Msg: 'static> Widget<Msg> for Heatmap<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for KeyHints

Source§

impl<Msg: 'static> Widget<Msg> for Legend

Source§

impl<Msg: 'static> Widget<Msg> for List<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for LogView<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Markdown

Source§

impl<Msg: 'static> Widget<Msg> for Menu<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for NumberInput<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for PageTransition<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for ProgressBar

Source§

impl<Msg: 'static> Widget<Msg> for RadioGroup<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for ScrollView<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Segmented<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Select<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for ShimmerText

Source§

impl<Msg: 'static> Widget<Msg> for Skeleton

Source§

impl<Msg: 'static> Widget<Msg> for Slider<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Sparkline<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Spinner

Source§

impl<Msg: 'static> Widget<Msg> for Steps<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Switch<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for TabRail<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Table<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Tabs<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Text

Source§

impl<Msg: 'static> Widget<Msg> for TextArea<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for TextInput<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for TimeInput<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Timeline<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Tooltip<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Tree<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for WidgetDock<Msg>

Source§

impl<Msg: 'static> Widget<Msg> for Window<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for Button<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for CardGrid<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for CodeView<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for CommandPalette<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for ContextMenu<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for CopyValue<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for EmptyState<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for HelpLayer<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for HoldToConfirm<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for IconButton<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for Modal<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for Panel<Msg>

Source§

impl<Msg: Clone + 'static> Widget<Msg> for SettingsList<Msg>