1use takia::prelude::*;
2
3fn main() -> Result<(), takia::TakiaError> {
4 let mut takia: TakiaTree<()> = TakiaTree::new();
5
6 let child = takia.new_leaf(Style {
7 size: Size { width: Dimension::from_percent(0.5), height: Dimension::AUTO },
8 ..Default::default()
9 })?;
10
11 let node = takia.new_with_children(
12 Style {
13 size: Size { width: Dimension::from_length(100.0), height: Dimension::from_length(100.0) },
14 justify_content: JustifyContent::CENTER,
15 ..Default::default()
16 },
17 &[child],
18 )?;
19
20 println!("Compute layout with 100x100 viewport:");
21 takia.compute_layout(
22 node,
23 Size { height: AvailableSpace::Definite(100.0), width: AvailableSpace::Definite(100.0) },
24 )?;
25 println!("node: {:#?}", takia.layout(node)?);
26 println!("child: {:#?}", takia.layout(child)?);
27
28 println!("Compute layout with undefined (infinite) viewport:");
29 takia.compute_layout(node, Size::MAX_CONTENT)?;
30 println!("node: {:#?}", takia.layout(node)?);
31 println!("child: {:#?}", takia.layout(child)?);
32
33 Ok(())
34}