Trait ori_core::View

source ·
pub trait View: SendSync + 'static {
    type State: SendSync + 'static;

    // Required method
    fn build(&self) -> Self::State;

    // Provided methods
    fn style(&self) -> Style { ... }
    fn event(
        &self,
        state: &mut Self::State,
        cx: &mut EventContext<'_>,
        event: &Event
    ) { ... }
    fn layout(
        &self,
        state: &mut Self::State,
        cx: &mut LayoutContext<'_>,
        bc: BoxConstraints
    ) -> Vec2 { ... }
    fn draw(&self, state: &mut Self::State, cx: &mut DrawContext<'_>) { ... }
}
Expand description

A View is a component that can be rendered to the screen.

Required Associated Types§

source

type State: SendSync + 'static

The state of the view.

Required Methods§

source

fn build(&self) -> Self::State

Builds the state of the view.

Provided Methods§

source

fn style(&self) -> Style

Returns the style of the view.

source

fn event( &self, state: &mut Self::State, cx: &mut EventContext<'_>, event: &Event )

Handles an event.

source

fn layout( &self, state: &mut Self::State, cx: &mut LayoutContext<'_>, bc: BoxConstraints ) -> Vec2

Handle layout and returns the size of the view.

This method should return a size that fits the BoxConstraints.

The default implementation returns the minimum size.

source

fn draw(&self, state: &mut Self::State, cx: &mut DrawContext<'_>)

Draws the view.

Implementations on Foreign Types§

source§

impl View for ()

§

type State = ()

source§

fn build(&self) -> Self::State

source§

fn event( &self, _state: &mut Self::State, _cx: &mut EventContext<'_>, _event: &Event )

source§

fn layout( &self, _state: &mut Self::State, _cx: &mut LayoutContext<'_>, bc: BoxConstraints ) -> Vec2

source§

fn draw(&self, _state: &mut Self::State, _cx: &mut DrawContext<'_>)

Implementors§

source§

impl View for Button

§

type State = <Div as View>::State

source§

impl View for Checkbox

§

type State = ()

source§

impl View for Comment

§

type State = ()

source§

impl View for Div

§

type State = ()

source§

impl View for Image

source§

impl View for Knob

source§

impl View for Scroll

source§

impl View for Text

§

type State = f32

source§

impl View for TextInput

source§

impl<T: View> View for Styled<T>

§

type State = <T as View>::State

source§

impl<V: View + SendSync> View for SharedSignal<V>

When a view is wrapped in a signal, the view will be redrawn when the signal changes.

§

type State = (Callback<'static, ()>, <V as View>::State)