[−][src]Trait gui::Renderer
An abstraction for objects used for rendering widgets.
Required methods
fn renderable_area(&self) -> BBox
Retrieve the bounding box of the renderable area (typically the
screen).
Note that the units to be used are not specified. That is, the
result could be in pixels, characters (in case of a terminal), or
just arbitrary numbers (if virtual coordinates are being used), as
long as this Renderer
knows how to interpret them.
fn render(&self, object: &dyn Renderable, bbox: BBox, cap: &dyn Cap) -> BBox
Render an object.
Objects are represented as Renderable
and need to be cast into
the actual widget type to render by the Renderer
itself, should
that be necessary. A simplified implementation could look as
follows:
fn render(&self, widget: &dyn Renderable, bbox: BBox, cap: &dyn Cap) -> BBox { if let Some(widget1) = widget.downcast_ref::<ConcreteWidget1>() { self.render_concrete_widget1(widget1, bbox) } else if let Some(widget2) = widget.downcast_ref::<ConcreteWidget1>() { self.render_concrete_widget2(widget2, bbox) } else { panic!("Renderable {:?} is unknown to the renderer", widget) } }
Provided methods
fn pre_render(&self)
Perform some pre-render step.
fn post_render(&self)
Perform some post-render step.