tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Definiciones

⎇ ec371711989b7f4d870d91bea4b66bdd94b45c9e benches/generated/child_min_max_width_flexing.rs Rust · 37 líneas · 1.3 KB Historia Quién tocó qué crudo

Implement CSS Grid (#205) 6fd2c6bcb · 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            flex_grow: 1f32,
8            flex_shrink: 0f32,
9            flex_basis: taffy::style::Dimension::Points(0f32),
10            min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() },
11            ..Default::default()
12        })
13        .unwrap();
14    let node1 = taffy
15        .new_leaf(taffy::style::Style {
16            flex_grow: 1f32,
17            flex_shrink: 0f32,
18            flex_basis: taffy::style::Dimension::Percent(0.5f32),
19            max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() },
20            ..Default::default()
21        })
22        .unwrap();
23    let node = taffy
24        .new_with_children(
25            taffy::style::Style {
26                align_items: Some(taffy::style::AlignItems::Stretch),
27                size: taffy::geometry::Size {
28                    width: taffy::style::Dimension::Points(120f32),
29                    height: taffy::style::Dimension::Points(50f32),
30                },
31                ..Default::default()
32            },
33            &[node0, node1],
34        )
35        .unwrap();
36    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
37}