tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

⎇ bf3dfaec9e387a7e67408fc78ca869d7eaaa8e1f benches/generated/aspect_ratio_flex_row_fill_max_height.rs Rust · 21 lines · 1.3 KB History Who touched what raw

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 . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ;
6    let node = taffy
7        .new_with_children(
8            taffy::style::Style {
9                display: taffy::style::Display::Flex,
10                align_items: Some(taffy::style::AlignItems::Start),
11                size: taffy::geometry::Size {
12                    width: taffy::style::Dimension::Points(100f32),
13                    height: taffy::style::Dimension::Points(100f32),
14                },
15                ..Default::default()
16            },
17            &[node0],
18        )
19        .unwrap();
20    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
21}