Skip to main content

Renderable

Trait Renderable 

Source
pub trait Renderable {
    // Required methods
    fn measure(&self, context: &Context) -> Measurement;
    fn render(&self, context: &Context) -> Vec<Line>;
}
Expand description

Content that knows its own size and can draw itself at a width.

A container asks each child to measure, decides the child’s width, and renders the child at that width. The trait is dyn compatible, so a container can hold Box<dyn Renderable>. A reference to a widget and a Box of one are widgets too, so a container can borrow its children.

The ctl_text crate docs show a complete widget.

Required Methods§

Source

fn measure(&self, context: &Context) -> Measurement

The narrowest and widest this content can usefully be.

Source

fn render(&self, context: &Context) -> Vec<Line>

Lines no wider than context.width(), except a word or cluster that the content’s overflow policy keeps whole.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> Renderable for &T
where T: Renderable + ?Sized,

Source§

fn measure(&self, context: &Context) -> Measurement

Source§

fn render(&self, context: &Context) -> Vec<Line>

Source§

impl<T> Renderable for Box<T>
where T: Renderable + ?Sized,

Source§

fn measure(&self, context: &Context) -> Measurement

Source§

fn render(&self, context: &Context) -> Vec<Line>

Implementors§