tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Definitions

⎇ 0.1.x benches/generated/percent_absolute_position.rs Rust · 54 lines · 1.8 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 node00 = taffy
4        .new_node(
5            taffy::style::Style {
6                size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Default::default() },
7                ..Default::default()
8            },
9            &[],
10        )
11        .unwrap();
12    let node01 = taffy
13        .new_node(
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 node0 = taffy
22        .new_node(
23            taffy::style::Style {
24                position_type: taffy::style::PositionType::Absolute,
25                size: taffy::geometry::Size {
26                    width: taffy::style::Dimension::Percent(1f32),
27                    height: taffy::style::Dimension::Points(50f32),
28                    ..Default::default()
29                },
30                position: taffy::geometry::Rect {
31                    start: taffy::style::Dimension::Percent(0.5f32),
32                    ..Default::default()
33                },
34                ..Default::default()
35            },
36            &[node00, node01],
37        )
38        .unwrap();
39    let node = taffy
40        .new_node(
41            taffy::style::Style {
42                flex_direction: taffy::style::FlexDirection::Column,
43                size: taffy::geometry::Size {
44                    width: taffy::style::Dimension::Points(60f32),
45                    height: taffy::style::Dimension::Points(50f32),
46                    ..Default::default()
47                },
48                ..Default::default()
49            },
50            &[node0],
51        )
52        .unwrap();
53    taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
54}