gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 701HTML 654Markdown 12TOML 62332 Definiciones

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/absolute_layout_within_border.rs Rust · 106 líneas · 4.4 KB Historia Quién tocó qué crudo

Rename PositionType and Position in accordance to specs (#295) e2cee9d6f · Andreas Weibye ·

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            position: taffy::style::Position::Absolute,
8            size: taffy::geometry::Size {
9                width: taffy::style::Dimension::Points(50f32),
10                height: taffy::style::Dimension::Points(50f32),
11            },
12            inset: taffy::geometry::Rect {
13                left: taffy::style::LengthPercentageAuto::Points(0f32),
14                right: auto(),
15                top: taffy::style::LengthPercentageAuto::Points(0f32),
16                bottom: auto(),
17            },
18            ..Default::default()
19        })
20        .unwrap();
21    let node1 = taffy
22        .new_leaf(taffy::style::Style {
23            position: taffy::style::Position::Absolute,
24            size: taffy::geometry::Size {
25                width: taffy::style::Dimension::Points(50f32),
26                height: taffy::style::Dimension::Points(50f32),
27            },
28            inset: taffy::geometry::Rect {
29                left: auto(),
30                right: taffy::style::LengthPercentageAuto::Points(0f32),
31                top: auto(),
32                bottom: taffy::style::LengthPercentageAuto::Points(0f32),
33            },
34            ..Default::default()
35        })
36        .unwrap();
37    let node2 = taffy
38        .new_leaf(taffy::style::Style {
39            position: taffy::style::Position::Absolute,
40            size: taffy::geometry::Size {
41                width: taffy::style::Dimension::Points(50f32),
42                height: taffy::style::Dimension::Points(50f32),
43            },
44            margin: taffy::geometry::Rect {
45                left: taffy::style::LengthPercentageAuto::Points(10f32),
46                right: taffy::style::LengthPercentageAuto::Points(10f32),
47                top: taffy::style::LengthPercentageAuto::Points(10f32),
48                bottom: taffy::style::LengthPercentageAuto::Points(10f32),
49            },
50            inset: taffy::geometry::Rect {
51                left: taffy::style::LengthPercentageAuto::Points(0f32),
52                right: auto(),
53                top: taffy::style::LengthPercentageAuto::Points(0f32),
54                bottom: auto(),
55            },
56            ..Default::default()
57        })
58        .unwrap();
59    let node3 = taffy
60        .new_leaf(taffy::style::Style {
61            position: taffy::style::Position::Absolute,
62            size: taffy::geometry::Size {
63                width: taffy::style::Dimension::Points(50f32),
64                height: taffy::style::Dimension::Points(50f32),
65            },
66            margin: taffy::geometry::Rect {
67                left: taffy::style::LengthPercentageAuto::Points(10f32),
68                right: taffy::style::LengthPercentageAuto::Points(10f32),
69                top: taffy::style::LengthPercentageAuto::Points(10f32),
70                bottom: taffy::style::LengthPercentageAuto::Points(10f32),
71            },
72            inset: taffy::geometry::Rect {
73                left: auto(),
74                right: taffy::style::LengthPercentageAuto::Points(0f32),
75                top: auto(),
76                bottom: taffy::style::LengthPercentageAuto::Points(0f32),
77            },
78            ..Default::default()
79        })
80        .unwrap();
81    let node = taffy
82        .new_with_children(
83            taffy::style::Style {
84                size: taffy::geometry::Size {
85                    width: taffy::style::Dimension::Points(100f32),
86                    height: taffy::style::Dimension::Points(100f32),
87                },
88                padding: taffy::geometry::Rect {
89                    left: taffy::style::LengthPercentage::Points(10f32),
90                    right: taffy::style::LengthPercentage::Points(10f32),
91                    top: taffy::style::LengthPercentage::Points(10f32),
92                    bottom: taffy::style::LengthPercentage::Points(10f32),
93                },
94                border: taffy::geometry::Rect {
95                    left: taffy::style::LengthPercentage::Points(10f32),
96                    right: taffy::style::LengthPercentage::Points(10f32),
97                    top: taffy::style::LengthPercentage::Points(10f32),
98                    bottom: taffy::style::LengthPercentage::Points(10f32),
99                },
100                ..Default::default()
101            },
102            &[node0, node1, node2, node3],
103        )
104        .unwrap();
105    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
106}