tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 583HTML 275Markdown 8TOML 41586 Sutichaykuna

⎇ 0.1.x benches/generated/wrap_nodes_with_content_sizing_margin_cross.rs Rust · 70 siq'ikuna · 2.3 KB Ñawpa willay Pi imata llamkarqan ch'uya

Rename sprawl to taffy (#134) 8936790d6 · Alice Cecile ·

1pub fn compute() {
2    let mut taffy = taffy::Taffy::new();
3    let node000 = taffy
4        .new_node(
5            taffy::style::Style {
6                size: taffy::geometry::Size {
7                    width: taffy::style::Dimension::Points(40f32),
8                    height: taffy::style::Dimension::Points(40f32),
9                    ..Default::default()
10                },
11                ..Default::default()
12            },
13            &[],
14        )
15        .unwrap();
16    let node00 = taffy
17        .new_node(
18            taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() },
19            &[node000],
20        )
21        .unwrap();
22    let node010 = taffy
23        .new_node(
24            taffy::style::Style {
25                size: taffy::geometry::Size {
26                    width: taffy::style::Dimension::Points(40f32),
27                    height: taffy::style::Dimension::Points(40f32),
28                    ..Default::default()
29                },
30                ..Default::default()
31            },
32            &[],
33        )
34        .unwrap();
35    let node01 = taffy
36        .new_node(
37            taffy::style::Style {
38                flex_direction: taffy::style::FlexDirection::Column,
39                margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() },
40                ..Default::default()
41            },
42            &[node010],
43        )
44        .unwrap();
45    let node0 = taffy
46        .new_node(
47            taffy::style::Style {
48                flex_wrap: taffy::style::FlexWrap::Wrap,
49                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(70f32), ..Default::default() },
50                ..Default::default()
51            },
52            &[node00, node01],
53        )
54        .unwrap();
55    let node = taffy
56        .new_node(
57            taffy::style::Style {
58                flex_direction: taffy::style::FlexDirection::Column,
59                size: taffy::geometry::Size {
60                    width: taffy::style::Dimension::Points(500f32),
61                    height: taffy::style::Dimension::Points(500f32),
62                    ..Default::default()
63                },
64                ..Default::default()
65            },
66            &[node0],
67        )
68        .unwrap();
69    taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
70}