tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Sutichaykuna

⎇ ec371711989b7f4d870d91bea4b66bdd94b45c9e benches/generated/display_none_with_margin.rs Rust · 35 siq'ikuna · 1.4 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 node0 = taffy
6        .new_leaf(taffy::style::Style {
7            display: taffy::style::Display::None,
8            size: taffy::geometry::Size {
9                width: taffy::style::Dimension::Points(20f32),
10                height: taffy::style::Dimension::Points(20f32),
11            },
12            margin: taffy::geometry::Rect {
13                left: taffy::style::LengthPercentageAuto::Points(10f32),
14                right: taffy::style::LengthPercentageAuto::Points(10f32),
15                top: taffy::style::LengthPercentageAuto::Points(10f32),
16                bottom: taffy::style::LengthPercentageAuto::Points(10f32),
17            },
18            ..Default::default()
19        })
20        .unwrap();
21    let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap();
22    let node = taffy
23        .new_with_children(
24            taffy::style::Style {
25                size: taffy::geometry::Size {
26                    width: taffy::style::Dimension::Points(100f32),
27                    height: taffy::style::Dimension::Points(100f32),
28                },
29                ..Default::default()
30            },
31            &[node0, node1],
32        )
33        .unwrap();
34    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
35}