gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5544Rust 88Markdown 11TOML 91926 Definiciones

⎇ 9e53f03adea2b770d68954e404d2fa407dfc7d40 tests/generated/gap_column_gap_justify_space_evenly.rs Rust · 63 líneas · 2.7 KB Historia Quién tocó qué crudo

Implement "gap" property for flexbox algorithm (#248) 9e53f03ad · Nico Burns ·

1#[test]
2fn gap_column_gap_justify_space_evenly() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_with_children(
6            taffy::style::FlexboxLayout {
7                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
8                ..Default::default()
9            },
10            &[],
11        )
12        .unwrap();
13    let node1 = taffy
14        .new_with_children(
15            taffy::style::FlexboxLayout {
16                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
17                ..Default::default()
18            },
19            &[],
20        )
21        .unwrap();
22    let node2 = taffy
23        .new_with_children(
24            taffy::style::FlexboxLayout {
25                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
26                ..Default::default()
27            },
28            &[],
29        )
30        .unwrap();
31    let node = taffy
32        .new_with_children(
33            taffy::style::FlexboxLayout {
34                justify_content: taffy::style::JustifyContent::SpaceEvenly,
35                gap: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() },
36                size: taffy::geometry::Size {
37                    width: taffy::style::Dimension::Points(100f32),
38                    height: taffy::style::Dimension::Points(100f32),
39                    ..Default::default()
40                },
41                ..Default::default()
42            },
43            &[node0, node1, node2],
44        )
45        .unwrap();
46    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
47    assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
48    assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
49    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
50    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
51    assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32);
52    assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32);
53    assert_eq!(taffy.layout(node0).unwrap().location.x, 5f32);
54    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
55    assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32);
56    assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32);
57    assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32);
58    assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32);
59    assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32);
60    assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32);
61    assert_eq!(taffy.layout(node2).unwrap().location.x, 75f32);
62    assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32);
63}