gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1076HTML 1008Markdown 12TOML 83208 Sutichaykuna

⎇ d8c8bb472833ba92d694a9420e4c5bd8308e32e3 benches/generated/margin_with_sibling_column.rs Rust · 34 siq'ikuna · 1.2 KB Ñawpa willay Pi imata llamkarqan ch'uya

Strict types for style values (#269) 0d8c198a9 · 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_with_children(
7            taffy::style::Style {
8                flex_grow: 1f32,
9                margin: taffy::geometry::Rect {
10                    bottom: taffy::style::LengthPercentageAuto::Points(10f32),
11                    ..Rect::zero()
12                },
13                ..Default::default()
14            },
15            &[],
16        )
17        .unwrap();
18    let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap();
19    let node = taffy
20        .new_with_children(
21            taffy::style::Style {
22                flex_direction: taffy::style::FlexDirection::Column,
23                size: taffy::geometry::Size {
24                    width: taffy::style::Dimension::Points(100f32),
25                    height: taffy::style::Dimension::Points(100f32),
26                    ..Size::auto()
27                },
28                ..Default::default()
29            },
30            &[node0, node1],
31        )
32        .unwrap();
33    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
34}