tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Definitions

⎇ ec371711989b7f4d870d91bea4b66bdd94b45c9e benches/generated/absolute_aspect_ratio_fill_min_width.rs Rust · 27 lines · 969 B 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
6        .new_leaf(taffy::style::Style {
7            position: taffy::style::Position::Absolute,
8            min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) },
9            aspect_ratio: Some(0.5f32),
10            ..Default::default()
11        })
12        .unwrap();
13    let node = taffy
14        .new_with_children(
15            taffy::style::Style {
16                display: taffy::style::Display::Flex,
17                size: taffy::geometry::Size {
18                    width: taffy::style::Dimension::Points(400f32),
19                    height: taffy::style::Dimension::Points(300f32),
20                },
21                ..Default::default()
22            },
23            &[node0],
24        )
25        .unwrap();
26    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
27}