summaryrefslogtreecommitdiffstats
path: root/src/tuice/layout/build_layout.rs
blob: 0002b0fc04deb9c8a3bb09a47a4c462b8724dfd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use tui::{backend::Backend, layout::Rect};

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

pub fn build_layout_tree<Message, B: Backend>(
    rect: Rect, root: &Element<'_, Message, B>,
) -> LayoutNode {
    let mut root_layout_node = LayoutNode::from_rect(rect);
    let bounds = Bounds {
        min_width: 0,
        min_height: 0,
        max_width: rect.width,
        max_height: rect.height,
    };

    let _ = root.layout(bounds, &mut root_layout_node);

    root_layout_node
}