Prepare for release of new sprawl crate (#53)
1use sprawl::prelude::*;
2
3fn main() -> Result<(), Error> {
4 let mut stretch = Stretch::new();
5
6 // left
7 let child_t1 = stretch.new_node(
8 Style { size: Size { width: Dimension::Points(5.0), height: Dimension::Points(5.0) }, ..Default::default() },
9 &[],
10 )?;
11
12 let div1 = stretch.new_node(
13 Style {
14 size: Size { width: Dimension::Percent(0.5), height: Dimension::Percent(1.0) },
15 // justify_content: JustifyContent::Center,
16 ..Default::default()
17 },
18 &[child_t1],
19 )?;
20
21 // right
22 let child_t2 = stretch.new_node(
23 Style { size: Size { width: Dimension::Points(5.0), height: Dimension::Points(5.0) }, ..Default::default() },
24 &[],
25 )?;
26
27 let div2 = stretch.new_node(
28 Style {
29 size: Size { width: Dimension::Percent(0.5), height: Dimension::Percent(1.0) },
30 // justify_content: JustifyContent::Center,
31 ..Default::default()
32 },
33 &[child_t2],
34 )?;
35
36 let container = stretch.new_node(
37 Style { size: Size { width: Dimension::Percent(1.0), height: Dimension::Percent(1.0) }, ..Default::default() },
38 &[div1, div2],
39 )?;
40
41 stretch.compute_layout(container, Size { height: Number::Defined(100.0), width: Number::Defined(100.0) })?;
42
43 println!("node: {:#?}", stretch.layout(container)?);
44
45 println!("div1: {:#?}", stretch.layout(div1)?);
46 println!("div2: {:#?}", stretch.layout(div2)?);
47
48 println!("child1: {:#?}", stretch.layout(child_t1)?);
49 println!("child2: {:#?}", stretch.layout(child_t2)?);
50
51 Ok(())
52}