gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 492HTML 238TOML 3CSS 11131 Definiciones

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/align_content_stretch_row_with_padding.rs Rust · 62 líneas · 2.5 KB Historia Quién tocó qué crudo

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 { width: taffy::style::Dimension::Points(50f32), height: auto() },
8            ..Default::default()
9        })
10        .unwrap();
11    let node1 = taffy
12        .new_leaf(taffy::style::Style {
13            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
14            padding: taffy::geometry::Rect {
15                left: taffy::style::LengthPercentage::Points(10f32),
16                right: taffy::style::LengthPercentage::Points(10f32),
17                top: taffy::style::LengthPercentage::Points(10f32),
18                bottom: taffy::style::LengthPercentage::Points(10f32),
19            },
20            ..Default::default()
21        })
22        .unwrap();
23    let node2 = taffy
24        .new_leaf(taffy::style::Style {
25            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
26            ..Default::default()
27        })
28        .unwrap();
29    let node3 = taffy
30        .new_leaf(taffy::style::Style {
31            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
32            padding: taffy::geometry::Rect {
33                left: taffy::style::LengthPercentage::Points(10f32),
34                right: taffy::style::LengthPercentage::Points(10f32),
35                top: taffy::style::LengthPercentage::Points(10f32),
36                bottom: taffy::style::LengthPercentage::Points(10f32),
37            },
38            ..Default::default()
39        })
40        .unwrap();
41    let node4 = taffy
42        .new_leaf(taffy::style::Style {
43            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
44            ..Default::default()
45        })
46        .unwrap();
47    let node = taffy
48        .new_with_children(
49            taffy::style::Style {
50                flex_wrap: taffy::style::FlexWrap::Wrap,
51                align_content: Some(taffy::style::AlignContent::Stretch),
52                size: taffy::geometry::Size {
53                    width: taffy::style::Dimension::Points(150f32),
54                    height: taffy::style::Dimension::Points(100f32),
55                },
56                ..Default::default()
57            },
58            &[node0, node1, node2, node3, node4],
59        )
60        .unwrap();
61    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
62}