⎇ d8c8bb472833ba92d694a9420e4c5bd8308e32e3
benches/generated/absolute_layout_within_border.rs
Historia
Quién tocó qué
crudo
Strict types for style values (#269)
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 position_type: taffy::style::PositionType::Absolute,
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Points(50f32),
11 height: taffy::style::Dimension::Points(50f32),
12 ..Size::auto()
13 },
14 position: taffy::geometry::Rect {
15 left: taffy::style::LengthPercentageAuto::Points(0f32),
16 top: taffy::style::LengthPercentageAuto::Points(0f32),
17 ..Rect::auto()
18 },
19 ..Default::default()
20 },
21 &[],
22 )
23 .unwrap();
24 let node1 = taffy
25 .new_with_children(
26 taffy::style::Style {
27 position_type: taffy::style::PositionType::Absolute,
28 size: taffy::geometry::Size {
29 width: taffy::style::Dimension::Points(50f32),
30 height: taffy::style::Dimension::Points(50f32),
31 ..Size::auto()
32 },
33 position: taffy::geometry::Rect {
34 right: taffy::style::LengthPercentageAuto::Points(0f32),
35 bottom: taffy::style::LengthPercentageAuto::Points(0f32),
36 ..Rect::auto()
37 },
38 ..Default::default()
39 },
40 &[],
41 )
42 .unwrap();
43 let node2 = taffy
44 .new_with_children(
45 taffy::style::Style {
46 position_type: taffy::style::PositionType::Absolute,
47 size: taffy::geometry::Size {
48 width: taffy::style::Dimension::Points(50f32),
49 height: taffy::style::Dimension::Points(50f32),
50 ..Size::auto()
51 },
52 margin: taffy::geometry::Rect {
53 left: taffy::style::LengthPercentageAuto::Points(10f32),
54 right: taffy::style::LengthPercentageAuto::Points(10f32),
55 top: taffy::style::LengthPercentageAuto::Points(10f32),
56 bottom: taffy::style::LengthPercentageAuto::Points(10f32),
57 ..Rect::zero()
58 },
59 position: taffy::geometry::Rect {
60 left: taffy::style::LengthPercentageAuto::Points(0f32),
61 top: taffy::style::LengthPercentageAuto::Points(0f32),
62 ..Rect::auto()
63 },
64 ..Default::default()
65 },
66 &[],
67 )
68 .unwrap();
69 let node3 = taffy
70 .new_with_children(
71 taffy::style::Style {
72 position_type: taffy::style::PositionType::Absolute,
73 size: taffy::geometry::Size {
74 width: taffy::style::Dimension::Points(50f32),
75 height: taffy::style::Dimension::Points(50f32),
76 ..Size::auto()
77 },
78 margin: taffy::geometry::Rect {
79 left: taffy::style::LengthPercentageAuto::Points(10f32),
80 right: taffy::style::LengthPercentageAuto::Points(10f32),
81 top: taffy::style::LengthPercentageAuto::Points(10f32),
82 bottom: taffy::style::LengthPercentageAuto::Points(10f32),
83 ..Rect::zero()
84 },
85 position: taffy::geometry::Rect {
86 right: taffy::style::LengthPercentageAuto::Points(0f32),
87 bottom: taffy::style::LengthPercentageAuto::Points(0f32),
88 ..Rect::auto()
89 },
90 ..Default::default()
91 },
92 &[],
93 )
94 .unwrap();
95 let node = taffy
96 .new_with_children(
97 taffy::style::Style {
98 size: taffy::geometry::Size {
99 width: taffy::style::Dimension::Points(100f32),
100 height: taffy::style::Dimension::Points(100f32),
101 ..Size::auto()
102 },
103 padding: taffy::geometry::Rect {
104 left: taffy::style::LengthPercentage::Points(10f32),
105 right: taffy::style::LengthPercentage::Points(10f32),
106 top: taffy::style::LengthPercentage::Points(10f32),
107 bottom: taffy::style::LengthPercentage::Points(10f32),
108 ..Rect::zero()
109 },
110 border: taffy::geometry::Rect {
111 left: taffy::style::LengthPercentage::Points(10f32),
112 right: taffy::style::LengthPercentage::Points(10f32),
113 top: taffy::style::LengthPercentage::Points(10f32),
114 bottom: taffy::style::LengthPercentage::Points(10f32),
115 ..Rect::zero()
116 },
117 ..Default::default()
118 },
119 &[node0, node1, node2, node3],
120 )
121 .unwrap();
122 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
123}