tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 238Markdown 7TOML 31234 Definitions

⎇ ebd376fbebd0ba73c79aa00d1835918680ef82a0 benches/generated/align_content_flex_start_with_flex.rs Rust · 63 lines · 2.4 KB History Who touched what raw

Reinstate FlexStart and FlexEnd alignment variants (#336) 78fd9cc09 · 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::Percent(0f32),
10            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), 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(0f32),
19            size: taffy::geometry::Size {
20                width: taffy::style::Dimension::Points(50f32),
21                height: taffy::style::Dimension::Points(10f32),
22            },
23            ..Default::default()
24        })
25        .unwrap();
26    let node2 = taffy
27        .new_leaf(taffy::style::Style {
28            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
29            ..Default::default()
30        })
31        .unwrap();
32    let node3 = taffy
33        .new_leaf(taffy::style::Style {
34            flex_grow: 1f32,
35            flex_shrink: 1f32,
36            flex_basis: taffy::style::Dimension::Percent(0f32),
37            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
38            ..Default::default()
39        })
40        .unwrap();
41    let node4 = taffy
42        .new_leaf(taffy::style::Style {
43            size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
44            ..Default::default()
45        })
46        .unwrap();
47    let node = taffy
48        .new_with_children(
49            taffy::style::Style {
50                flex_direction: taffy::style::FlexDirection::Column,
51                flex_wrap: taffy::style::FlexWrap::Wrap,
52                align_content: Some(taffy::style::AlignContent::FlexStart),
53                size: taffy::geometry::Size {
54                    width: taffy::style::Dimension::Points(100f32),
55                    height: taffy::style::Dimension::Points(120f32),
56                },
57                ..Default::default()
58            },
59            &[node0, node1, node2, node3, node4],
60        )
61        .unwrap();
62    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
63}