gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1090HTML 1022Markdown 12TOML 84418 Definitions

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/min_max_percent_different_width_height.rs Rust · 45 lines · 1.6 KB History Who touched what raw

Import yoga tests (#320) e05b9093d · 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_with_measure(
7            taffy::style::Style {
8                min_size: taffy::geometry::Size {
9                    width: taffy::style::Dimension::Percent(0.1f32),
10                    height: taffy::style::Dimension::Percent(0.1f32),
11                },
12                max_size: taffy::geometry::Size {
13                    width: taffy::style::Dimension::Percent(0.1f32),
14                    height: taffy::style::Dimension::Percent(0.1f32),
15                },
16                ..Default::default()
17            },
18            taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| {
19                const TEXT: &str = "\n  ";
20                super::measure_standard_text(
21                    known_dimensions,
22                    available_space,
23                    TEXT,
24                    super::WritingMode::Horizontal,
25                    None,
26                )
27            }),
28        )
29        .unwrap();
30    let node = taffy
31        .new_with_children(
32            taffy::style::Style {
33                flex_direction: taffy::style::FlexDirection::Column,
34                align_items: Some(taffy::style::AlignItems::Start),
35                size: taffy::geometry::Size {
36                    width: taffy::style::Dimension::Points(100f32),
37                    height: taffy::style::Dimension::Points(200f32),
38                },
39                ..Default::default()
40            },
41            &[node0],
42        )
43        .unwrap();
44    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
45}