tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Definitions

⎇ ec371711989b7f4d870d91bea4b66bdd94b45c9e benches/generated/margin_auto_left_and_right_column.rs Rust · 43 lines · 1.5 KB History Who touched what raw

Implement CSS Grid (#205) 6fd2c6bcb · Nico Burns ·

1pub fn compute() {
2    #[allow(unused_imports)]
3    use taffy::prelude::*;
4    let mut taffy = taffy::Taffy::new();
5    let node0 = taffy
6        .new_leaf(taffy::style::Style {
7            size: taffy::geometry::Size {
8                width: taffy::style::Dimension::Points(50f32),
9                height: taffy::style::Dimension::Points(50f32),
10            },
11            margin: taffy::geometry::Rect {
12                left: taffy::style::LengthPercentageAuto::Auto,
13                right: taffy::style::LengthPercentageAuto::Auto,
14                top: zero(),
15                bottom: zero(),
16            },
17            ..Default::default()
18        })
19        .unwrap();
20    let node1 = taffy
21        .new_leaf(taffy::style::Style {
22            size: taffy::geometry::Size {
23                width: taffy::style::Dimension::Points(50f32),
24                height: taffy::style::Dimension::Points(50f32),
25            },
26            ..Default::default()
27        })
28        .unwrap();
29    let node = taffy
30        .new_with_children(
31            taffy::style::Style {
32                align_items: Some(taffy::style::AlignItems::Center),
33                size: taffy::geometry::Size {
34                    width: taffy::style::Dimension::Points(200f32),
35                    height: taffy::style::Dimension::Points(200f32),
36                },
37                ..Default::default()
38            },
39            &[node0, node1],
40        )
41        .unwrap();
42    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
43}