gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 684HTML 640Markdown 12TOML 62290 Definiciones

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/wrap_column.rs Rust · 56 líneas · 1.9 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            size: taffy::geometry::Size {
8                width: taffy::style::Dimension::Points(30f32),
9                height: taffy::style::Dimension::Points(31f32),
10            },
11            ..Default::default()
12        })
13        .unwrap();
14    let node1 = taffy
15        .new_leaf(taffy::style::Style {
16            size: taffy::geometry::Size {
17                width: taffy::style::Dimension::Points(30f32),
18                height: taffy::style::Dimension::Points(32f32),
19            },
20            ..Default::default()
21        })
22        .unwrap();
23    let node2 = taffy
24        .new_leaf(taffy::style::Style {
25            size: taffy::geometry::Size {
26                width: taffy::style::Dimension::Points(30f32),
27                height: taffy::style::Dimension::Points(33f32),
28            },
29            ..Default::default()
30        })
31        .unwrap();
32    let node3 = taffy
33        .new_leaf(taffy::style::Style {
34            size: taffy::geometry::Size {
35                width: taffy::style::Dimension::Points(30f32),
36                height: taffy::style::Dimension::Points(34f32),
37            },
38            ..Default::default()
39        })
40        .unwrap();
41    let node = taffy
42        .new_with_children(
43            taffy::style::Style {
44                flex_direction: taffy::style::FlexDirection::Column,
45                flex_wrap: taffy::style::FlexWrap::Wrap,
46                size: taffy::geometry::Size {
47                    width: taffy::style::Dimension::Points(100f32),
48                    height: taffy::style::Dimension::Points(100f32),
49                },
50                ..Default::default()
51            },
52            &[node0, node1, node2, node3],
53        )
54        .unwrap();
55    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
56}