tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1114HTML 1040Markdown 12TOML 94698 Definitions

⎇ 0.2.x benches/generated/wrapped_column_max_height_flex.rs Rust · 78 lines · 2.9 KB History Who touched what raw

Rename Rect field start->left end->right (#257) ca514f6c8 · Nico Burns ·

1pub fn compute() {
2    let mut taffy = taffy::Taffy::new();
3    let node0 = taffy
4        .new_with_children(
5            taffy::style::Style {
6                flex_grow: 1f32,
7                flex_shrink: 1f32,
8                flex_basis: taffy::style::Dimension::Percent(0f32),
9                size: taffy::geometry::Size {
10                    width: taffy::style::Dimension::Points(100f32),
11                    height: taffy::style::Dimension::Points(500f32),
12                    ..Default::default()
13                },
14                max_size: taffy::geometry::Size {
15                    height: taffy::style::Dimension::Points(200f32),
16                    ..Default::default()
17                },
18                ..Default::default()
19            },
20            &[],
21        )
22        .unwrap();
23    let node1 = taffy
24        .new_with_children(
25            taffy::style::Style {
26                flex_grow: 1f32,
27                flex_shrink: 1f32,
28                flex_basis: taffy::style::Dimension::Percent(0f32),
29                size: taffy::geometry::Size {
30                    width: taffy::style::Dimension::Points(200f32),
31                    height: taffy::style::Dimension::Points(200f32),
32                    ..Default::default()
33                },
34                margin: taffy::geometry::Rect {
35                    left: taffy::style::Dimension::Points(20f32),
36                    right: taffy::style::Dimension::Points(20f32),
37                    top: taffy::style::Dimension::Points(20f32),
38                    bottom: taffy::style::Dimension::Points(20f32),
39                    ..Default::default()
40                },
41                ..Default::default()
42            },
43            &[],
44        )
45        .unwrap();
46    let node2 = taffy
47        .new_with_children(
48            taffy::style::Style {
49                size: taffy::geometry::Size {
50                    width: taffy::style::Dimension::Points(100f32),
51                    height: taffy::style::Dimension::Points(100f32),
52                    ..Default::default()
53                },
54                ..Default::default()
55            },
56            &[],
57        )
58        .unwrap();
59    let node = taffy
60        .new_with_children(
61            taffy::style::Style {
62                flex_direction: taffy::style::FlexDirection::Column,
63                flex_wrap: taffy::style::FlexWrap::Wrap,
64                align_items: taffy::style::AlignItems::Center,
65                align_content: taffy::style::AlignContent::Center,
66                justify_content: taffy::style::JustifyContent::Center,
67                size: taffy::geometry::Size {
68                    width: taffy::style::Dimension::Points(700f32),
69                    height: taffy::style::Dimension::Points(500f32),
70                    ..Default::default()
71                },
72                ..Default::default()
73            },
74            &[node0, node1, node2],
75        )
76        .unwrap();
77    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
78}