Implement "gap" property for flexbox algorithm (#248)
1use taffy::prelude::*;
2
3// Creates three 20px x 20px children, evenly spaced 10px apart from each other
4// Thus the container is 80px x 20px.
5
6fn main() -> Result<(), taffy::error::TaffyError> {
7 let mut taffy = Taffy::new();
8
9 let child_style = FlexboxLayout {
10 size: Size { width: Dimension::Points(20.0), height: Dimension::Points(20.0) },
11 ..Default::default()
12 };
13 let child0 = taffy.new_leaf(child_style.clone())?;
14 let child1 = taffy.new_leaf(child_style.clone())?;
15 let child2 = taffy.new_leaf(child_style.clone())?;
16
17 let root = taffy.new_with_children(
18 FlexboxLayout {
19 gap: Size { width: Dimension::Points(10.0), height: Dimension::Undefined },
20 ..Default::default()
21 },
22 &[child0, child1, child2],
23 )?;
24
25 // Compute layout and print result
26 taffy.compute_layout(root, Size::MAX_CONTENT)?;
27 taffy::debug::print_tree(&taffy, root);
28
29 Ok(())
30}