pub trait TextMeasure {
// Required methods
fn intrinsic(&mut self, id: TextId) -> Size;
fn wrapped(&mut self, id: TextId, max_w: f32) -> Size;
// Provided methods
fn min_content(&mut self, _id: TextId) -> f32 { ... }
fn edit_intrinsic(&mut self, _key: Key) -> Size { ... }
fn edit_wrapped(&mut self, _key: Key, _max_w: f32) -> Size { ... }
fn baseline(&mut self, _id: TextId) -> f32 { ... }
fn edit_baseline(&mut self, _key: Key) -> f32 { ... }
fn image_size(&mut self, _id: ImageId) -> Size { ... }
fn cells_size(&mut self, _id: CellsId) -> Size { ... }
}Expand description
What the solver asks about text, editors, images and cell grids: the sizes it cannot compute from specs alone. The core implements it over its text system; a test may implement it with fixed numbers.
Required Methods§
Provided Methods§
Sourcefn min_content(&mut self, _id: TextId) -> f32
fn min_content(&mut self, _id: TextId) -> f32
The widest stretch of the text no break falls inside, logical px — CSS’s min-content: the longest word, a whole unwrapped line. Asked only on a frame with a share of the room; 0, the default, is a text that rewraps to any width.
Sourcefn edit_intrinsic(&mut self, _key: Key) -> Size
fn edit_intrinsic(&mut self, _key: Key) -> Size
Unwrapped content size of an editable text node.
Sourcefn edit_wrapped(&mut self, _key: Key, _max_w: f32) -> Size
fn edit_wrapped(&mut self, _key: Key, _max_w: f32) -> Size
Content size of an editable text node wrapped to max_w.
Sourcefn baseline(&mut self, _id: TextId) -> f32
fn baseline(&mut self, _id: TextId) -> f32
The first line’s baseline of a text last wrapped by wrapped,
logical px below its top: what crossAlign: baseline lines up.
Asked only on a frame with a baseline row. NaN = not known, and
the text aligns by its bottom edge.
Sourcefn edit_baseline(&mut self, _key: Key) -> f32
fn edit_baseline(&mut self, _key: Key) -> f32
An editor’s first baseline, below the top of its text (its box’s
padding is added by the caller). NaN = not known.
Sourcefn image_size(&mut self, _id: ImageId) -> Size
fn image_size(&mut self, _id: ImageId) -> Size
Pixel dimensions of a registered image (ZERO when unknown).
Sourcefn cells_size(&mut self, _id: CellsId) -> Size
fn cells_size(&mut self, _id: CellsId) -> Size
The laid-out size of a cell grid (rows × cols cells).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".