tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Definitions

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/aspect_ratio_flex_column_fill_max_height.rs Rust · 22 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                flex_direction: taffy::style::FlexDirection::Column,
11                align_items: Some(taffy::style::AlignItems::Start),
12                size: taffy::geometry::Size {
13                    width: taffy::style::Dimension::Points(100f32),
14                    height: taffy::style::Dimension::Points(100f32),
15                },
16                ..Default::default()
17            },
18            &[node0],
19        )
20        .unwrap();
21    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
22}