gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1116HTML 1041Markdown 12TOML 94780 Definiciones

⎇ 0.2.x tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs Rust · 95 líneas · 4.0 KB Historia Quién tocó qué crudo

Rename Rect field start->left end->right (#257) ca514f6c8 · Nico Burns ·

1#[test]
2fn wrap_nodes_with_content_sizing_overflowing_margin() {
3    let mut taffy = taffy::Taffy::new();
4    let node000 = taffy
5        .new_with_children(
6            taffy::style::Style {
7                size: taffy::geometry::Size {
8                    width: taffy::style::Dimension::Points(40f32),
9                    height: taffy::style::Dimension::Points(40f32),
10                    ..Default::default()
11                },
12                ..Default::default()
13            },
14            &[],
15        )
16        .unwrap();
17    let node00 = taffy
18        .new_with_children(
19            taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() },
20            &[node000],
21        )
22        .unwrap();
23    let node010 = taffy
24        .new_with_children(
25            taffy::style::Style {
26                size: taffy::geometry::Size {
27                    width: taffy::style::Dimension::Points(40f32),
28                    height: taffy::style::Dimension::Points(40f32),
29                    ..Default::default()
30                },
31                ..Default::default()
32            },
33            &[],
34        )
35        .unwrap();
36    let node01 = taffy
37        .new_with_children(
38            taffy::style::Style {
39                flex_direction: taffy::style::FlexDirection::Column,
40                margin: taffy::geometry::Rect { right: taffy::style::Dimension::Points(10f32), ..Default::default() },
41                ..Default::default()
42            },
43            &[node010],
44        )
45        .unwrap();
46    let node0 = taffy
47        .new_with_children(
48            taffy::style::Style {
49                flex_wrap: taffy::style::FlexWrap::Wrap,
50                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(85f32), ..Default::default() },
51                ..Default::default()
52            },
53            &[node00, node01],
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                    ..Default::default()
64                },
65                ..Default::default()
66            },
67            &[node0],
68        )
69        .unwrap();
70    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
71    assert_eq!(taffy.layout(node).unwrap().size.width, 500f32);
72    assert_eq!(taffy.layout(node).unwrap().size.height, 500f32);
73    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
74    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
75    assert_eq!(taffy.layout(node0).unwrap().size.width, 85f32);
76    assert_eq!(taffy.layout(node0).unwrap().size.height, 80f32);
77    assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
78    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
79    assert_eq!(taffy.layout(node00).unwrap().size.width, 40f32);
80    assert_eq!(taffy.layout(node00).unwrap().size.height, 40f32);
81    assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32);
82    assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32);
83    assert_eq!(taffy.layout(node000).unwrap().size.width, 40f32);
84    assert_eq!(taffy.layout(node000).unwrap().size.height, 40f32);
85    assert_eq!(taffy.layout(node000).unwrap().location.x, 0f32);
86    assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32);
87    assert_eq!(taffy.layout(node01).unwrap().size.width, 40f32);
88    assert_eq!(taffy.layout(node01).unwrap().size.height, 40f32);
89    assert_eq!(taffy.layout(node01).unwrap().location.x, 0f32);
90    assert_eq!(taffy.layout(node01).unwrap().location.y, 40f32);
91    assert_eq!(taffy.layout(node010).unwrap().size.width, 40f32);
92    assert_eq!(taffy.layout(node010).unwrap().size.height, 40f32);
93    assert_eq!(taffy.layout(node010).unwrap().location.x, 0f32);
94    assert_eq!(taffy.layout(node010).unwrap().location.y, 0f32);
95}