tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Definitions

⎇ 0.1.x benches/generated/flex_grow_to_min.rs Rust · 33 lines · 1.3 KB History Who touched what raw

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

1pub fn compute() {
2    let mut taffy = taffy::Taffy::new();
3    let node0 =
4        taffy.new_node(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[]).unwrap();
5    let node1 = taffy
6        .new_node(
7            taffy::style::Style {
8                size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() },
9                ..Default::default()
10            },
11            &[],
12        )
13        .unwrap();
14    let node = taffy
15        .new_node(
16            taffy::style::Style {
17                flex_direction: taffy::style::FlexDirection::Column,
18                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() },
19                min_size: taffy::geometry::Size {
20                    height: taffy::style::Dimension::Points(100f32),
21                    ..Default::default()
22                },
23                max_size: taffy::geometry::Size {
24                    height: taffy::style::Dimension::Points(500f32),
25                    ..Default::default()
26                },
27                ..Default::default()
28            },
29            &[node0, node1],
30        )
31        .unwrap();
32    taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
33}