gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 684HTML 640Markdown 12TOML 62286 Definiciones

⎇ 9e53f03adea2b770d68954e404d2fa407dfc7d40 benches/generated/gap_column_row_gap_wrapping.rs Rust · 136 líneas · 4.6 KB Historia Quién tocó qué crudo

Implement "gap" property for flexbox algorithm (#248) 9e53f03ad · Nico Burns ·

1pub fn compute() {
2    let mut taffy = taffy::Taffy::new();
3    let node0 = taffy
4        .new_with_children(
5            taffy::style::FlexboxLayout {
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::FlexboxLayout {
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::FlexboxLayout {
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::FlexboxLayout {
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::FlexboxLayout {
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::FlexboxLayout {
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 node6 = taffy
82        .new_with_children(
83            taffy::style::FlexboxLayout {
84                size: taffy::geometry::Size {
85                    width: taffy::style::Dimension::Points(20f32),
86                    height: taffy::style::Dimension::Points(20f32),
87                    ..Default::default()
88                },
89                ..Default::default()
90            },
91            &[],
92        )
93        .unwrap();
94    let node7 = taffy
95        .new_with_children(
96            taffy::style::FlexboxLayout {
97                size: taffy::geometry::Size {
98                    width: taffy::style::Dimension::Points(20f32),
99                    height: taffy::style::Dimension::Points(20f32),
100                    ..Default::default()
101                },
102                ..Default::default()
103            },
104            &[],
105        )
106        .unwrap();
107    let node8 = taffy
108        .new_with_children(
109            taffy::style::FlexboxLayout {
110                size: taffy::geometry::Size {
111                    width: taffy::style::Dimension::Points(20f32),
112                    height: taffy::style::Dimension::Points(20f32),
113                    ..Default::default()
114                },
115                ..Default::default()
116            },
117            &[],
118        )
119        .unwrap();
120    let node = taffy
121        .new_with_children(
122            taffy::style::FlexboxLayout {
123                flex_wrap: taffy::style::FlexWrap::Wrap,
124                gap: taffy::geometry::Size {
125                    width: taffy::style::Dimension::Points(10f32),
126                    height: taffy::style::Dimension::Points(20f32),
127                    ..Default::default()
128                },
129                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Default::default() },
130                ..Default::default()
131            },
132            &[node0, node1, node2, node3, node4, node5, node6, node7, node8],
133        )
134        .unwrap();
135    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
136}