tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 788HTML 740Markdown 12TOML 62536 Definitions

⎇ 9e53f03adea2b770d68954e404d2fa407dfc7d40 benches/generated/absolute_layout_width_height_start_top_end_bottom.rs Rust · 38 lines · 1.4 KB History Who touched what raw

Layout algorithm decoupling, Sizing Constraints & Perf Improvements (#246) ba4cd3c3b · Nico Burns ·

1pub fn compute() {
2    let mut taffy = taffy::Taffy::new();
3    let node0 = taffy
4        .new_with_children(
5            taffy::style::FlexboxLayout {
6                position_type: taffy::style::PositionType::Absolute,
7                size: taffy::geometry::Size {
8                    width: taffy::style::Dimension::Points(10f32),
9                    height: taffy::style::Dimension::Points(10f32),
10                    ..Default::default()
11                },
12                position: taffy::geometry::Rect {
13                    start: taffy::style::Dimension::Points(10f32),
14                    end: taffy::style::Dimension::Points(10f32),
15                    top: taffy::style::Dimension::Points(10f32),
16                    bottom: taffy::style::Dimension::Points(10f32),
17                    ..Default::default()
18                },
19                ..Default::default()
20            },
21            &[],
22        )
23        .unwrap();
24    let node = taffy
25        .new_with_children(
26            taffy::style::FlexboxLayout {
27                size: taffy::geometry::Size {
28                    width: taffy::style::Dimension::Points(100f32),
29                    height: taffy::style::Dimension::Points(100f32),
30                    ..Default::default()
31                },
32                ..Default::default()
33            },
34            &[node0],
35        )
36        .unwrap();
37    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
38}