tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 788HTML 740Markdown 12TOML 62536 Definitions

⎇ 9e53f03adea2b770d68954e404d2fa407dfc7d40 benches/generated/justify_content_row_min_width_and_margin.rs Rust · 28 lines · 1.0 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                size: taffy::geometry::Size {
7                    width: taffy::style::Dimension::Points(20f32),
8                    height: taffy::style::Dimension::Points(20f32),
9                    ..Default::default()
10                },
11                margin: taffy::geometry::Rect { start: taffy::style::Dimension::Points(10f32), ..Default::default() },
12                ..Default::default()
13            },
14            &[],
15        )
16        .unwrap();
17    let node = taffy
18        .new_with_children(
19            taffy::style::FlexboxLayout {
20                justify_content: taffy::style::JustifyContent::Center,
21                min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() },
22                ..Default::default()
23            },
24            &[node0],
25        )
26        .unwrap();
27    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
28}