tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Sutichaykuna

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/align_baseline_child_top2.rs Rust · 55 siq'ikuna · 1.9 KB Ñawpa willay Pi imata llamkarqan ch'uya

Import yoga tests (#320) e05b9093d · 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            ..Default::default()
12        })
13        .unwrap();
14    let node10 = taffy
15        .new_leaf(taffy::style::Style {
16            size: taffy::geometry::Size {
17                width: taffy::style::Dimension::Points(50f32),
18                height: taffy::style::Dimension::Points(10f32),
19            },
20            ..Default::default()
21        })
22        .unwrap();
23    let node1 = taffy
24        .new_with_children(
25            taffy::style::Style {
26                size: taffy::geometry::Size {
27                    width: taffy::style::Dimension::Points(50f32),
28                    height: taffy::style::Dimension::Points(20f32),
29                },
30                inset: taffy::geometry::Rect {
31                    left: auto(),
32                    right: auto(),
33                    top: taffy::style::LengthPercentageAuto::Points(5f32),
34                    bottom: auto(),
35                },
36                ..Default::default()
37            },
38            &[node10],
39        )
40        .unwrap();
41    let node = taffy
42        .new_with_children(
43            taffy::style::Style {
44                align_items: Some(taffy::style::AlignItems::Baseline),
45                size: taffy::geometry::Size {
46                    width: taffy::style::Dimension::Points(100f32),
47                    height: taffy::style::Dimension::Points(100f32),
48                },
49                ..Default::default()
50            },
51            &[node0, node1],
52        )
53        .unwrap();
54    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
55}