tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Definitions

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/gap_row_gap_align_items_stretch.rs Rust · 61 lines · 2.4 KB History Who touched what raw

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 { width: taffy::style::Dimension::Points(20f32), height: auto() },
8            ..Default::default()
9        })
10        .unwrap();
11    let node1 = taffy
12        .new_leaf(taffy::style::Style {
13            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() },
14            ..Default::default()
15        })
16        .unwrap();
17    let node2 = taffy
18        .new_leaf(taffy::style::Style {
19            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() },
20            ..Default::default()
21        })
22        .unwrap();
23    let node3 = taffy
24        .new_leaf(taffy::style::Style {
25            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() },
26            ..Default::default()
27        })
28        .unwrap();
29    let node4 = taffy
30        .new_leaf(taffy::style::Style {
31            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() },
32            ..Default::default()
33        })
34        .unwrap();
35    let node5 = taffy
36        .new_leaf(taffy::style::Style {
37            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() },
38            ..Default::default()
39        })
40        .unwrap();
41    let node = taffy
42        .new_with_children(
43            taffy::style::Style {
44                flex_wrap: taffy::style::FlexWrap::Wrap,
45                align_items: Some(taffy::style::AlignItems::Stretch),
46                align_content: Some(taffy::style::AlignContent::Stretch),
47                gap: taffy::geometry::Size {
48                    width: taffy::style::LengthPercentage::Points(10f32),
49                    height: taffy::style::LengthPercentage::Points(20f32),
50                },
51                size: taffy::geometry::Size {
52                    width: taffy::style::Dimension::Points(100f32),
53                    height: taffy::style::Dimension::Points(200f32),
54                },
55                ..Default::default()
56            },
57            &[node0, node1, node2, node3, node4, node5],
58        )
59        .unwrap();
60    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
61}