layout_as_grid

Function layout_as_grid 

Source
pub fn layout_as_grid(
    area: Rect,
    horizontal: Layout,
    vertical: Layout,
) -> GenericLayout<(usize, usize)>
Expand description

Calculates a full grid of rects from the horizontal and vertical components.

use ratatui_core::layout::{Constraint, Layout, Rect};
use rat_widget::layout::layout_as_grid;

let area = Rect::new(0,0,100,100);

let layout = layout_as_grid(area,
            Layout::horizontal([
                Constraint::Length(5),
                Constraint::Fill(1),
                Constraint::Length(5)
            ]),
            Layout::vertical([
                Constraint::Length(1),
                Constraint::Length(3),
                Constraint::Fill(1),
                Constraint::Length(3),
                Constraint::Length(1),
            ])
);

// middle column, second block
let a_1_2 = layout.widget(layout.try_index_of((1,2)).expect("fine"));