use crate::{EMPTY_LINE_CONTEXT, LayoutBox, LayoutChild, LineContext, Style};
type LayoutCache = (u32, (LayoutBox, LineContext));
#[derive(Debug)]
pub struct LayoutNode {
pub style: Style,
pub children: Vec<LayoutChild>,
pub layout_box: LayoutBox,
pub(crate) layout_box_cache: LayoutCache,
}
impl LayoutNode {
pub fn new(style: Style) -> Self {
Self {
style,
layout_box: LayoutBox::default(),
children: Vec::new(),
layout_box_cache: (0, (LayoutBox::default(), EMPTY_LINE_CONTEXT)),
}
}
pub fn with_children<I, T>(style: Style, children: I) -> Self
where
I: IntoIterator<Item = T>,
T: Into<LayoutChild>,
{
let children = children.into_iter().map(Into::into).collect();
Self {
style,
layout_box: LayoutBox::default(),
children,
layout_box_cache: (0, (LayoutBox::default(), EMPTY_LINE_CONTEXT)),
}
}
}