Trait iced::widget::shader::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,
        _shell: &mut Shell<'_, Message>
    ) -> (Status, Option<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, _shell: &mut Shell<'_, Message> ) -> (Status, Option<Message>)

Update the internal State of the Program. This can be used to reflect state changes based on mouse & other events. You can use the Shell to publish messages, request a redraw for the window, etc.

By default, this method does and returns nothing.

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>,

§

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

§

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

source§

fn update( &self, state: &mut <&T as Program<Message>>::State, event: Event, bounds: Rectangle, cursor: Cursor, shell: &mut Shell<'_, Message> ) -> (Status, Option<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§