iced::widget::shader

Trait Program

Source
pub trait Program<Message> {
    type State: Default + 'static;
    type Primitive: Primitive + 'static;

    // Required method
    fn draw(
        &self,
        state: &Self::State,
        cursor: Cursor,
        bounds: Rectangle,
    ) -> Self::Primitive;

    // Provided methods
    fn update(
        &self,
        _state: &mut Self::State,
        _event: Event,
        _bounds: Rectangle,
        _cursor: Cursor,
    ) -> Option<Action<Message>> { ... }
    fn mouse_interaction(
        &self,
        _state: &Self::State,
        _bounds: Rectangle,
        _cursor: Cursor,
    ) -> Interaction { ... }
}
Available on crate feature wgpu only.
Expand description

The state and logic of a Shader widget.

A Program can mutate the internal state of a Shader widget and produce messages for an application.

Required Associated Types§

Source

type State: Default + 'static

The internal state of the Program.

Source

type Primitive: Primitive + 'static

The type of primitive this Program can draw.

Required Methods§

Source

fn draw( &self, state: &Self::State, cursor: Cursor, bounds: Rectangle, ) -> Self::Primitive

Draws the Primitive.

Provided Methods§

Source

fn update( &self, _state: &mut Self::State, _event: Event, _bounds: Rectangle, _cursor: Cursor, ) -> Option<Action<Message>>

Update the internal State of the Program. This can be used to reflect state changes based on mouse & other events. You can return an Action to publish a message, request a redraw, or capture the event.

By default, this method returns None.

Source

fn mouse_interaction( &self, _state: &Self::State, _bounds: Rectangle, _cursor: Cursor, ) -> Interaction

Returns the current mouse interaction of the Program.

The interaction returned will be in effect even if the cursor position is out of bounds of the Shader’s program.

Implementations on Foreign Types§

Source§

impl<Message, T> Program<Message> for &T
where T: Program<Message>,

Source§

type State = <T as Program<Message>>::State

Source§

type Primitive = <T as Program<Message>>::Primitive

Source§

fn update( &self, state: &mut <&T as Program<Message>>::State, event: Event, bounds: Rectangle, cursor: Cursor, ) -> Option<Action<Message>>

Source§

fn draw( &self, state: &<&T as Program<Message>>::State, cursor: Cursor, bounds: Rectangle, ) -> <&T as Program<Message>>::Primitive

Source§

fn mouse_interaction( &self, state: &<&T as Program<Message>>::State, bounds: Rectangle, cursor: Cursor, ) -> Interaction

Implementors§