Function hud_slots

Source
pub fn hud_slots(
    parent: Rect,
    count: usize,
    min_width: f32,
    height: f32,
    gap: f32,
) -> Result<impl ExactSizeIterator, UiError>
Expand description

Reflow equal-width HUD cells left-to-right, then top-to-bottom, without allocation. Each row fits as many min_width cells as possible (at least one), distributing spare width equally. Rows keep height; a narrow viewport shrinks the one column. The last row keeps the same column widths, even when not full. Cells clip to parent, so overflow rows become empty, non-interactive rectangles. This never scales text: combine with fit_label for long labels.

count may be zero and must not exceed 4096. Width/height must be finite and positive; gap must be finite and nonnegative.

use ferravex_play::ui::{hud_slots, Rect};
let area = Rect { min: [12., 12.], size: [300., 104.] };
let mut cells = hud_slots(area, 3, 140., 44., 8.)?;
assert_eq!(cells.next().unwrap().size, [146., 44.]);
assert_eq!(cells.nth(1).unwrap().min, [12., 64.]); // Third item wraps.