pub trait Measure {
// Required method
fn height_for(&self, width: u16) -> u16;
}Expand description
A widget that can report the height it needs for a given width, before ever being rendered.
Lets a caller size a pane to fit content (e.g. a wrapped Paragraph)
instead of guessing a fixed height up front.
Sizing is pure content math, not drawing.
§Examples
use retroglyph_ui::Measure;
struct FixedHeight(u16);
impl Measure for FixedHeight {
fn height_for(&self, _width: u16) -> u16 {
self.0
}
}
assert_eq!(FixedHeight(3).height_for(80), 3);Required Methods§
Sourcefn height_for(&self, width: u16) -> u16
fn height_for(&self, width: u16) -> u16
The number of rows this widget would need to render at width
columns.