gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 227Rust 7TOML 3CSS 1307 Definitions

⎇ 0.2.x benches/generated/gap_column_gap_wrap_align_space_between.rs Rust · 102 lines · 3.4 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(20f32),
8                    height: taffy::style::Dimension::Points(20f32),
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(20f32),
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(20f32),
34                    height: taffy::style::Dimension::Points(20f32),
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(20f32),
47                    height: taffy::style::Dimension::Points(20f32),
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(20f32),
60                    height: taffy::style::Dimension::Points(20f32),
61                    ..Default::default()
62                },
63                ..Default::default()
64            },
65            &[],
66        )
67        .unwrap();
68    let node5 = taffy
69        .new_with_children(
70            taffy::style::Style {
71                size: taffy::geometry::Size {
72                    width: taffy::style::Dimension::Points(20f32),
73                    height: taffy::style::Dimension::Points(20f32),
74                    ..Default::default()
75                },
76                ..Default::default()
77            },
78            &[],
79        )
80        .unwrap();
81    let node = taffy
82        .new_with_children(
83            taffy::style::Style {
84                flex_wrap: taffy::style::FlexWrap::Wrap,
85                align_content: taffy::style::AlignContent::SpaceBetween,
86                gap: taffy::geometry::Size {
87                    width: taffy::style::Dimension::Points(10f32),
88                    height: taffy::style::Dimension::Points(20f32),
89                    ..Default::default()
90                },
91                size: taffy::geometry::Size {
92                    width: taffy::style::Dimension::Points(100f32),
93                    height: taffy::style::Dimension::Points(100f32),
94                    ..Default::default()
95                },
96                ..Default::default()
97            },
98            &[node0, node1, node2, node3, node4, node5],
99        )
100        .unwrap();
101    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
102}