tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Definitions

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/align_content_stretch_row_with_max_height.rs Rust · 51 lines · 2.0 KB History Who touched what raw

Import yoga tests (#320) e05b9093d · Nico Burns ·

1pub fn compute() {
2    #[allow(unused_imports)]
3    use taffy::prelude::*;
4    let mut taffy = taffy::Taffy::new();
5    let node0 = taffy
6        .new_leaf(taffy::style::Style {
7            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
8            ..Default::default()
9        })
10        .unwrap();
11    let node1 = taffy
12        .new_leaf(taffy::style::Style {
13            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
14            max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) },
15            ..Default::default()
16        })
17        .unwrap();
18    let node2 = taffy
19        .new_leaf(taffy::style::Style {
20            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
21            ..Default::default()
22        })
23        .unwrap();
24    let node3 = taffy
25        .new_leaf(taffy::style::Style {
26            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
27            ..Default::default()
28        })
29        .unwrap();
30    let node4 = taffy
31        .new_leaf(taffy::style::Style {
32            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
33            ..Default::default()
34        })
35        .unwrap();
36    let node = taffy
37        .new_with_children(
38            taffy::style::Style {
39                flex_wrap: taffy::style::FlexWrap::Wrap,
40                align_content: Some(taffy::style::AlignContent::Stretch),
41                size: taffy::geometry::Size {
42                    width: taffy::style::Dimension::Points(150f32),
43                    height: taffy::style::Dimension::Points(100f32),
44                },
45                ..Default::default()
46            },
47            &[node0, node1, node2, node3, node4],
48        )
49        .unwrap();
50    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
51}