gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5544Rust 87Markdown 12TOML 91924 Definiciones

⎇ rayon tests/rounding.rs Rust · 29 líneas · 1.0 KB Historia Quién tocó qué crudo

Rename Taffy struct to TaffyTree (#580) 17235ffa2 · Nico Burns ·

1use taffy::prelude::*;
2
3#[test]
4fn rounding_doesnt_leave_gaps() {
5    // First create an instance of TaffyTree
6    let mut taffy: TaffyTree<()> = TaffyTree::new();
7
8    let w_square = Size { width: length(100.3), height: length(100.3) };
9    let child_a = taffy.new_leaf(Style { size: w_square, ..Default::default() }).unwrap();
10    let child_b = taffy.new_leaf(Style { size: w_square, ..Default::default() }).unwrap();
11
12    let root_node = taffy
13        .new_with_children(
14            Style {
15                size: Size { width: length(963.3333), height: length(1000.) },
16                justify_content: Some(JustifyContent::Center),
17                ..Default::default()
18            },
19            &[child_a, child_b],
20        )
21        .unwrap();
22
23    taffy.compute_layout(root_node, Size::MAX_CONTENT).unwrap();
24    taffy.print_tree(root_node);
25
26    let layout_a = taffy.layout(child_a).unwrap();
27    let layout_b = taffy.layout(child_b).unwrap();
28    assert_eq!(layout_a.location.x + layout_a.size.width, layout_b.location.x);
29}