tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 238Markdown 7TOML 31442 Definitions

⎇ 0.2.x benches/generated/gap_column_gap_flexible_undefined_parent.rs Rust · 51 lines · 1.6 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                flex_grow: 1f32,
7                flex_shrink: 1f32,
8                flex_basis: taffy::style::Dimension::Percent(0f32),
9                ..Default::default()
10            },
11            &[],
12        )
13        .unwrap();
14    let node1 = taffy
15        .new_with_children(
16            taffy::style::Style {
17                flex_grow: 1f32,
18                flex_shrink: 1f32,
19                flex_basis: taffy::style::Dimension::Percent(0f32),
20                ..Default::default()
21            },
22            &[],
23        )
24        .unwrap();
25    let node2 = taffy
26        .new_with_children(
27            taffy::style::Style {
28                flex_grow: 1f32,
29                flex_shrink: 1f32,
30                flex_basis: taffy::style::Dimension::Percent(0f32),
31                ..Default::default()
32            },
33            &[],
34        )
35        .unwrap();
36    let node = taffy
37        .new_with_children(
38            taffy::style::Style {
39                gap: taffy::geometry::Size {
40                    width: taffy::style::Dimension::Points(10f32),
41                    height: taffy::style::Dimension::Points(20f32),
42                    ..Default::default()
43                },
44                size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() },
45                ..Default::default()
46            },
47            &[node0, node1, node2],
48        )
49        .unwrap();
50    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
51}