gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 493HTML 247TOML 5CSS 11151 Definiciones

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/absolute_aspect_ratio_fill_width.rs Rust · 33 líneas · 1.2 KB Historia Quién tocó qué crudo

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            size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) },
9            aspect_ratio: Some(3f32),
10            inset: taffy::geometry::Rect {
11                left: taffy::style::LengthPercentageAuto::Percent(0.05f32),
12                right: auto(),
13                top: taffy::style::LengthPercentageAuto::Percent(0.05f32),
14                bottom: auto(),
15            },
16            ..Default::default()
17        })
18        .unwrap();
19    let node = taffy
20        .new_with_children(
21            taffy::style::Style {
22                display: taffy::style::Display::Flex,
23                size: taffy::geometry::Size {
24                    width: taffy::style::Dimension::Points(400f32),
25                    height: taffy::style::Dimension::Points(300f32),
26                },
27                ..Default::default()
28            },
29            &[node0],
30        )
31        .unwrap();
32    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
33}