Skip to main content

split_h

Function split_h 

Source
pub fn split_h(area: Rect, constraints: &[Constraint]) -> Vec<Rect> 
Expand description

Split area into columns left-to-right.

Returns one Rect per constraint; empty panes (zero width) are still returned so indices line up with constraints.

Never panics, for the same reason as split_v: a degenerate area resolves every constraint to a zero-width pane instead of under/overflowing, and an empty constraints slice returns an empty Vec.

§Examples

use retroglyph_core::grid::Rect;
use retroglyph_ui::{Constraint, split_h};

let area = Rect::new(0, 0, 100, 5);
let panes = split_h(area, &[Constraint::Percent(30), Constraint::Fill(1)]);
assert_eq!(panes.iter().map(Rect::width).collect::<Vec<_>>(), vec![30, 70]);