tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Sutichaykuna

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/align_items_center_justify_content_center.rs Rust · 70 siq'ikuna · 2.7 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 node000 = taffy
6        .new_leaf_with_measure(
7            taffy::style::Style {
8                size: taffy::geometry::Size {
9                    width: taffy::style::Dimension::Points(10f32),
10                    height: taffy::style::Dimension::Points(10f32),
11                },
12                ..Default::default()
13            },
14            taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| {
15                const TEXT: &str = "\n      ";
16                super::measure_standard_text(
17                    known_dimensions,
18                    available_space,
19                    TEXT,
20                    super::WritingMode::Horizontal,
21                    None,
22                )
23            }),
24        )
25        .unwrap();
26    let node00 = taffy
27        .new_with_children(
28            taffy::style::Style {
29                flex_direction: taffy::style::FlexDirection::Column,
30                align_items: Some(taffy::style::AlignItems::Center),
31                justify_content: Some(taffy::style::JustifyContent::Center),
32                size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) },
33                margin: taffy::geometry::Rect {
34                    left: taffy::style::LengthPercentageAuto::Points(10f32),
35                    right: taffy::style::LengthPercentageAuto::Points(10f32),
36                    top: zero(),
37                    bottom: zero(),
38                },
39                ..Default::default()
40            },
41            &[node000],
42        )
43        .unwrap();
44    let node0 = taffy
45        .new_with_children(
46            taffy::style::Style {
47                flex_direction: taffy::style::FlexDirection::Column,
48                align_items: Some(taffy::style::AlignItems::Center),
49                justify_content: Some(taffy::style::JustifyContent::Center),
50                size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) },
51                ..Default::default()
52            },
53            &[node00],
54        )
55        .unwrap();
56    let node = taffy
57        .new_with_children(
58            taffy::style::Style {
59                flex_direction: taffy::style::FlexDirection::Column,
60                size: taffy::geometry::Size {
61                    width: taffy::style::Dimension::Points(500f32),
62                    height: taffy::style::Dimension::Points(500f32),
63                },
64                ..Default::default()
65            },
66            &[node0],
67        )
68        .unwrap();
69    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
70}