tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 788HTML 740Markdown 12TOML 62536 Definiciones

⎇ 0.2.x tests/generated/justify_content_row_min_width_and_margin.rs Rust · 37 líneas · 1.6 KB Historia Quién tocó qué crudo

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

1#[test]
2fn justify_content_row_min_width_and_margin() {
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(20f32),
9                    height: taffy::style::Dimension::Points(20f32),
10                    ..Default::default()
11                },
12                margin: taffy::geometry::Rect { left: taffy::style::Dimension::Points(10f32), ..Default::default() },
13                ..Default::default()
14            },
15            &[],
16        )
17        .unwrap();
18    let node = taffy
19        .new_with_children(
20            taffy::style::Style {
21                justify_content: taffy::style::JustifyContent::Center,
22                min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() },
23                ..Default::default()
24            },
25            &[node0],
26        )
27        .unwrap();
28    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
29    assert_eq!(taffy.layout(node).unwrap().size.width, 50f32);
30    assert_eq!(taffy.layout(node).unwrap().size.height, 20f32);
31    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
32    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
33    assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32);
34    assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32);
35    assert_eq!(taffy.layout(node0).unwrap().location.x, 20f32);
36    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
37}