tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1116HTML 1041Markdown 12TOML 94780 Definitions

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