Trait gelatin::Widget[][src]

pub trait Widget: Any {
    fn draw(
        &self,
        target: &mut Frame,
        context: &DrawContext<'_>
    ) -> Result<NextUpdate, WidgetError>;
fn layout(&self, available_space: LogicalRect);
fn handle_event(&self, event: &Event);
fn children(&self, children: &mut Vec<Rc<dyn Widget>>);
fn placement(&self) -> WidgetPlacement;
fn visible(&self) -> bool;
fn set_valid_ref(&self, rendered_valid: RenderValidity); fn before_draw(&self, _window: &Window) -> NextUpdate { ... } }

Required methods

fn draw(
    &self,
    target: &mut Frame,
    context: &DrawContext<'_>
) -> Result<NextUpdate, WidgetError>
[src]

This function is called when the window is being re-rendered.

WARNING: The window may not be modified from this function. See the before_draw function to do that.

The widget is responsible for setting the correct transformation. A widget should get information for finding a proper transformation from its own drawn_bounds field.

On success this furnction may return an instant indicating the time when it would like to be redrawn. Otherwise it can return Ok(None) to indicate that it should only be redrawn when a window event causes a change.

fn layout(&self, available_space: LogicalRect)[src]

fn handle_event(&self, event: &Event)[src]

fn children(&self, children: &mut Vec<Rc<dyn Widget>>)[src]

The implementer is expected to push its children into the provided vector.

fn placement(&self) -> WidgetPlacement[src]

fn visible(&self) -> bool[src]

fn set_valid_ref(&self, rendered_valid: RenderValidity)[src]

Implementer of this trait must store the provided object and call invalidate on it whenever a change happens on them that requires a re-draw.

Containers must call this function for all of their children immediately and pass a clone of the provided object.

Loading content...

Provided methods

fn before_draw(&self, _window: &Window) -> NextUpdate[src]

This function is called before calling the draw function. Widgets may use this function to mutate the window. This is however not allowed in the draw method.

Note that the Window uses inner mutability so all window related functions take a reference to a seemingly immutable window.

Loading content...

Implementors

impl Widget for Button[src]

impl Widget for Label[src]

impl Widget for Slider[src]

impl<Dim: PickDimension + 'static> Widget for LineLayoutContainer<Dim>[src]

Loading content...