tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 492HTML 238TOML 3CSS 11112 Definitions

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