tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Sutichaykuna

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs Rust · 38 siq'ikuna · 1.3 KB Ñawpa willay Pi imata llamkarqan ch'uya

Fixes for aspect ratio and min/max sizes (#317) 610c92f31 · 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                max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) },
9                aspect_ratio: Some(2f32),
10                ..Default::default()
11            },
12            taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| {
13                const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH";
14                super::measure_standard_text(
15                    known_dimensions,
16                    available_space,
17                    TEXT,
18                    super::WritingMode::Horizontal,
19                    Some(2f32),
20                )
21            }),
22        )
23        .unwrap();
24    let node = taffy
25        .new_with_children(
26            taffy::style::Style {
27                display: taffy::style::Display::Flex,
28                size: taffy::geometry::Size {
29                    width: taffy::style::Dimension::Points(100f32),
30                    height: taffy::style::Dimension::Points(100f32),
31                },
32                ..Default::default()
33            },
34            &[node0],
35        )
36        .unwrap();
37    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
38}