tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 709HTML 662Markdown 12TOML 62348 Definitions

⎇ 0.2.x benches/generated/wrap_reverse_row_align_content_flex_start.rs Rust · 80 lines · 2.7 KB History Who touched what raw

Rename FlexboxLayout back to Style (#251) 49893a7d9 · Nico Burns ·

1pub fn compute() {
2    let mut taffy = taffy::Taffy::new();
3    let node0 = taffy
4        .new_with_children(
5            taffy::style::Style {
6                size: taffy::geometry::Size {
7                    width: taffy::style::Dimension::Points(30f32),
8                    height: taffy::style::Dimension::Points(10f32),
9                    ..Default::default()
10                },
11                ..Default::default()
12            },
13            &[],
14        )
15        .unwrap();
16    let node1 = taffy
17        .new_with_children(
18            taffy::style::Style {
19                size: taffy::geometry::Size {
20                    width: taffy::style::Dimension::Points(30f32),
21                    height: taffy::style::Dimension::Points(20f32),
22                    ..Default::default()
23                },
24                ..Default::default()
25            },
26            &[],
27        )
28        .unwrap();
29    let node2 = taffy
30        .new_with_children(
31            taffy::style::Style {
32                size: taffy::geometry::Size {
33                    width: taffy::style::Dimension::Points(30f32),
34                    height: taffy::style::Dimension::Points(30f32),
35                    ..Default::default()
36                },
37                ..Default::default()
38            },
39            &[],
40        )
41        .unwrap();
42    let node3 = taffy
43        .new_with_children(
44            taffy::style::Style {
45                size: taffy::geometry::Size {
46                    width: taffy::style::Dimension::Points(30f32),
47                    height: taffy::style::Dimension::Points(40f32),
48                    ..Default::default()
49                },
50                ..Default::default()
51            },
52            &[],
53        )
54        .unwrap();
55    let node4 = taffy
56        .new_with_children(
57            taffy::style::Style {
58                size: taffy::geometry::Size {
59                    width: taffy::style::Dimension::Points(30f32),
60                    height: taffy::style::Dimension::Points(50f32),
61                    ..Default::default()
62                },
63                ..Default::default()
64            },
65            &[],
66        )
67        .unwrap();
68    let node = taffy
69        .new_with_children(
70            taffy::style::Style {
71                flex_wrap: taffy::style::FlexWrap::WrapReverse,
72                align_content: taffy::style::AlignContent::FlexStart,
73                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() },
74                ..Default::default()
75            },
76            &[node0, node1, node2, node3, node4],
77        )
78        .unwrap();
79    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
80}