Guide API
Skip to main content

layout_widths

Function layout_widths 

Source
pub fn layout_widths(cols: &[ColumnSpec], avail: i32) -> Vec<i32>
Expand description

Distribute avail cells over cols: hidden columns get 0; the visible ones keep their preferred width while everything (plus one separator between neighbouring visible columns) fits, else the currently widest shrinkable column loses one cell per pass until it fits or every column sits at its min_width (a fixed one at its width). Shrinking comes first, scrolling second: a layout that still does not fit, even one whose separators alone fill avail, keeps every column at that floor and is wider than avail; the table scrolls it horizontally. Spare cells go to the flex columns by weight (see stretch); without one they stay empty. With no visible column, or no cell at all (avail ≤ 0), every width is 0.