Trait gui::Renderable

source ·
pub trait Renderable: 'static + Debug {
    // Required methods
    fn type_id(&self) -> TypeId;
    fn render(&self, cap: &dyn Cap, renderer: &dyn Renderer, bbox: BBox) -> BBox;

    // Provided method
    fn render_done(&self, cap: &dyn Cap, renderer: &dyn Renderer, bbox: BBox) { ... }
}
Expand description

A trait representing a renderable object.

Required Methods§

source

fn type_id(&self) -> TypeId

Get the TypeId of self.

source

fn render(&self, cap: &dyn Cap, renderer: &dyn Renderer, bbox: BBox) -> BBox

Render the renderable object.

This method should just forward the call to the given Renderer, supplying a trait object of the actual widget. The renderer is advised to honor the given BBox and is free to inquire additional state using the supplied Cap.

This method is invoked before all the widget’s children are rendered (“pre-order”).

Provided Methods§

source

fn render_done(&self, cap: &dyn Cap, renderer: &dyn Renderer, bbox: BBox)

A method invoked once rendering of this widget and all its children concluded (“post-order”).

By default, this method does nothing, but it can be useful for rendering an overlay or for certain renderer related state adjustments.

Implementations§

source§

impl dyn Renderable

source

pub fn is<T>(&self) -> bool
where T: Renderable,

Check if the widget is of type T.

source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: Renderable,

Downcast the widget reference to type T.

source

pub fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: Renderable,

Downcast the widget reference to type T.

Implementors§