tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Sutichaykuna

⎇ ec371711989b7f4d870d91bea4b66bdd94b45c9e benches/generated/align_content_stretch_row_with_flex.rs Rust · 56 siq'ikuna · 2.1 KB Ñawpa willay Pi imata llamkarqan ch'uya

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            flex_grow: 1f32,
14            flex_shrink: 1f32,
15            flex_basis: taffy::style::Dimension::Percent(0f32),
16            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
17            ..Default::default()
18        })
19        .unwrap();
20    let node2 = taffy
21        .new_leaf(taffy::style::Style {
22            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
23            ..Default::default()
24        })
25        .unwrap();
26    let node3 = taffy
27        .new_leaf(taffy::style::Style {
28            flex_grow: 1f32,
29            flex_shrink: 1f32,
30            flex_basis: taffy::style::Dimension::Percent(0f32),
31            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
32            ..Default::default()
33        })
34        .unwrap();
35    let node4 = taffy
36        .new_leaf(taffy::style::Style {
37            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
38            ..Default::default()
39        })
40        .unwrap();
41    let node = taffy
42        .new_with_children(
43            taffy::style::Style {
44                flex_wrap: taffy::style::FlexWrap::Wrap,
45                align_content: Some(taffy::style::AlignContent::Stretch),
46                size: taffy::geometry::Size {
47                    width: taffy::style::Dimension::Points(150f32),
48                    height: taffy::style::Dimension::Points(100f32),
49                },
50                ..Default::default()
51            },
52            &[node0, node1, node2, node3, node4],
53        )
54        .unwrap();
55    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
56}