[][src]Trait iced::widget::Widget

pub trait Widget<Message, Renderer>: Debug {
    fn node(&self, renderer: &Renderer) -> Node;
fn draw(
        &self,
        renderer: &mut Renderer,
        layout: Layout,
        cursor_position: Point
    ) -> MouseCursor;
fn hash_layout(&self, state: &mut Hasher); fn on_event(
        &mut self,
        _event: Event,
        _layout: Layout,
        _cursor_position: Point,
        _messages: &mut Vec<Message>
    ) { ... } }

A component that displays information and allows interaction.

If you want to build your own widgets, you will need to implement this trait.

Required methods

fn node(&self, renderer: &Renderer) -> Node

Returns the Node of the Widget.

This Node is used by the runtime to compute the Layout of the user interface.

fn draw(
    &self,
    renderer: &mut Renderer,
    layout: Layout,
    cursor_position: Point
) -> MouseCursor

Draws the Widget using the associated Renderer.

It must return the MouseCursor state for the Widget.

fn hash_layout(&self, state: &mut Hasher)

Computes the layout hash of the Widget.

The produced hash is used by the runtime to decide if the Layout needs to be recomputed between frames. Therefore, to ensure maximum efficiency, the hash should only be affected by the properties of the Widget that can affect layouting.

For example, the Text widget does not hash its color property, as its value cannot affect the overall Layout of the user interface.

Loading content...

Provided methods

fn on_event(
    &mut self,
    _event: Event,
    _layout: Layout,
    _cursor_position: Point,
    _messages: &mut Vec<Message>
)

Processes a runtime Event.

It receives:

  • an Event describing user interaction
  • the computed Layout of the Widget
  • the current cursor position
  • a mutable Message list, allowing the Widget to produce new messages based on user interaction.

By default, it does nothing.

Loading content...

Implementors

impl<'a, Message, Renderer> Widget<Message, Renderer> for Button<'a, Message> where
    Renderer: Renderer,
    Message: Copy + Debug
[src]

impl<'a, Message, Renderer> Widget<Message, Renderer> for Slider<'a, Message> where
    Renderer: Renderer
[src]

impl<'a, Message, Renderer> Widget<Message, Renderer> for Column<'a, Message, Renderer>[src]

impl<'a, Message, Renderer> Widget<Message, Renderer> for Row<'a, Message, Renderer>[src]

impl<Color, Message, Renderer> Widget<Message, Renderer> for Checkbox<Color, Message> where
    Color: 'static + Copy + Debug,
    Renderer: Renderer + Renderer<Color>, 
[src]

impl<Color, Message, Renderer> Widget<Message, Renderer> for Radio<Color, Message> where
    Color: 'static + Copy + Debug,
    Renderer: Renderer + Renderer<Color>,
    Message: Copy + Debug
[src]

impl<I, Message, Renderer> Widget<Message, Renderer> for Image<I> where
    Renderer: Renderer<I>,
    I: Clone
[src]

impl<Message, Renderer, Color> Widget<Message, Renderer> for Text<Color> where
    Color: Copy + Debug,
    Renderer: Renderer<Color>, 
[src]

Loading content...