summaryrefslogtreecommitdiffstats
path: root/src/tuice/layout/build_layout.rs
blob: 6d8c59fbbb8691f3de8548daee4000db5f30c36e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use tui::layout::Rect;

use crate::tuice::{Bounds, Component, LayoutNode};

pub fn build_layout_tree<Message, Backend>(
    area: Rect, root: &Box<dyn Component<Message, Backend>>,
) -> LayoutNode
where
    Backend: tui::backend::Backend,
{
    let mut root_layout_node = LayoutNode::from_area(area);
    let bounds = Bounds {
        min_width: 0,
        min_height: 0,
        max_width: area.width,
        max_height: area.height,
    };

    root.layout(bounds, &mut root_layout_node);

    root_layout_node
}