gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Definiciones

⎇ 0.2.x tests/generated/margin_auto_mutiple_children_row.rs Rust · 76 líneas · 3.1 KB Historia Quién tocó qué crudo

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

1#[test]
2fn margin_auto_mutiple_children_row() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_with_children(
6            taffy::style::Style {
7                size: taffy::geometry::Size {
8                    width: taffy::style::Dimension::Points(50f32),
9                    height: taffy::style::Dimension::Points(50f32),
10                    ..Default::default()
11                },
12                margin: taffy::geometry::Rect { right: taffy::style::Dimension::Auto, ..Default::default() },
13                ..Default::default()
14            },
15            &[],
16        )
17        .unwrap();
18    let node1 = taffy
19        .new_with_children(
20            taffy::style::Style {
21                size: taffy::geometry::Size {
22                    width: taffy::style::Dimension::Points(50f32),
23                    height: taffy::style::Dimension::Points(50f32),
24                    ..Default::default()
25                },
26                margin: taffy::geometry::Rect { right: taffy::style::Dimension::Auto, ..Default::default() },
27                ..Default::default()
28            },
29            &[],
30        )
31        .unwrap();
32    let node2 = taffy
33        .new_with_children(
34            taffy::style::Style {
35                size: taffy::geometry::Size {
36                    width: taffy::style::Dimension::Points(50f32),
37                    height: taffy::style::Dimension::Points(50f32),
38                    ..Default::default()
39                },
40                ..Default::default()
41            },
42            &[],
43        )
44        .unwrap();
45    let node = taffy
46        .new_with_children(
47            taffy::style::Style {
48                align_items: taffy::style::AlignItems::Center,
49                size: taffy::geometry::Size {
50                    width: taffy::style::Dimension::Points(200f32),
51                    height: taffy::style::Dimension::Points(200f32),
52                    ..Default::default()
53                },
54                ..Default::default()
55            },
56            &[node0, node1, node2],
57        )
58        .unwrap();
59    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
60    assert_eq!(taffy.layout(node).unwrap().size.width, 200f32);
61    assert_eq!(taffy.layout(node).unwrap().size.height, 200f32);
62    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
63    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
64    assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32);
65    assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32);
66    assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
67    assert_eq!(taffy.layout(node0).unwrap().location.y, 75f32);
68    assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32);
69    assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32);
70    assert_eq!(taffy.layout(node1).unwrap().location.x, 75f32);
71    assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32);
72    assert_eq!(taffy.layout(node2).unwrap().size.width, 50f32);
73    assert_eq!(taffy.layout(node2).unwrap().size.height, 50f32);
74    assert_eq!(taffy.layout(node2).unwrap().location.x, 150f32);
75    assert_eq!(taffy.layout(node2).unwrap().location.y, 75f32);
76}