tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Sutichaykuna

⎇ ec371711989b7f4d870d91bea4b66bdd94b45c9e benches/generated/wrapped_row_within_align_items_center.rs Rust · 44 siq'ikuna · 1.5 KB Ñawpa willay Pi imata llamkarqan ch'uya

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 node00 = taffy
6        .new_leaf(taffy::style::Style {
7            size: taffy::geometry::Size {
8                width: taffy::style::Dimension::Points(150f32),
9                height: taffy::style::Dimension::Points(80f32),
10            },
11            ..Default::default()
12        })
13        .unwrap();
14    let node01 = taffy
15        .new_leaf(taffy::style::Style {
16            size: taffy::geometry::Size {
17                width: taffy::style::Dimension::Points(80f32),
18                height: taffy::style::Dimension::Points(80f32),
19            },
20            ..Default::default()
21        })
22        .unwrap();
23    let node0 = taffy
24        .new_with_children(
25            taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() },
26            &[node00, node01],
27        )
28        .unwrap();
29    let node = taffy
30        .new_with_children(
31            taffy::style::Style {
32                flex_direction: taffy::style::FlexDirection::Column,
33                align_items: Some(taffy::style::AlignItems::Center),
34                size: taffy::geometry::Size {
35                    width: taffy::style::Dimension::Points(200f32),
36                    height: taffy::style::Dimension::Points(200f32),
37                },
38                ..Default::default()
39            },
40            &[node0],
41        )
42        .unwrap();
43    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
44}