tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Sutichaykuna

⎇ ec371711989b7f4d870d91bea4b66bdd94b45c9e benches/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs Rust · 32 siq'ikuna · 1.1 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(taffy::style::Style {
7            position: taffy::style::Position::Absolute,
8            aspect_ratio: Some(3f32),
9            inset: taffy::geometry::Rect {
10                left: auto(),
11                right: auto(),
12                top: taffy::style::LengthPercentageAuto::Percent(0.3f32),
13                bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32),
14            },
15            ..Default::default()
16        })
17        .unwrap();
18    let node = taffy
19        .new_with_children(
20            taffy::style::Style {
21                display: taffy::style::Display::Flex,
22                size: taffy::geometry::Size {
23                    width: taffy::style::Dimension::Points(400f32),
24                    height: taffy::style::Dimension::Points(300f32),
25                },
26                ..Default::default()
27            },
28            &[node0],
29        )
30        .unwrap();
31    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
32}