gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 227Rust 7TOML 3CSS 1307 Definitions

⎇ 6652882a96948b4d8ee433a176d428cf3c3916bf benches/generated/measure_remeasure_child_after_growing.rs Rust · 37 lines · 1.3 KB History Who touched what raw

Convert measure tests to gentests (#292) 6652882a9 · Nico Burns ·

1pub fn compute() {
2    #[allow(unused_imports)]
3    use taffy::prelude::*;
4    let mut taffy = taffy::Taffy::new();
5    let node0 = taffy
6        .new_leaf(taffy::style::Style {
7            size: taffy::geometry::Size {
8                width: taffy::style::Dimension::Points(50f32),
9                height: taffy::style::Dimension::Points(50f32),
10            },
11            ..Default::default()
12        })
13        .unwrap();
14    let node1 = taffy
15        .new_leaf_with_measure(
16            taffy::style::Style { ..Default::default() },
17            taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| {
18                const TEXT: &str = "HH";
19                super::measure_standard_text(known_dimensions, available_space, TEXT)
20            }),
21        )
22        .unwrap();
23    let node = taffy
24        .new_with_children(
25            taffy::style::Style {
26                align_items: Some(taffy::style::AlignItems::Start),
27                size: taffy::geometry::Size {
28                    width: taffy::style::Dimension::Points(100f32),
29                    height: taffy::style::Dimension::Auto,
30                },
31                ..Default::default()
32            },
33            &[node0, node1],
34        )
35        .unwrap();
36    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
37}