gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 254C 19JavaScript 81371 Definitions

⎇ 72a1d81325e63c351a9bcbf07427e676cbe938c4 benches/generated/flex_root_ignored.rs Rust · 47 lines · 1.6 KB History Who touched what raw

rename stretch to stretch2 79aa44fa4 · elbaro ·

1pub fn compute() {
2    let mut stretch = stretch2::Stretch::new();
3    let node0 = stretch
4        .new_node(
5            stretch2::style::Style {
6                flex_grow: 1f32,
7                flex_basis: stretch2::style::Dimension::Points(200f32),
8                ..Default::default()
9            },
10            &[],
11        )
12        .unwrap();
13    let node1 = stretch
14        .new_node(
15            stretch2::style::Style {
16                size: stretch2::geometry::Size {
17                    height: stretch2::style::Dimension::Points(100f32),
18                    ..Default::default()
19                },
20                ..Default::default()
21            },
22            &[],
23        )
24        .unwrap();
25    let node = stretch
26        .new_node(
27            stretch2::style::Style {
28                flex_direction: stretch2::style::FlexDirection::Column,
29                size: stretch2::geometry::Size {
30                    width: stretch2::style::Dimension::Points(100f32),
31                    ..Default::default()
32                },
33                min_size: stretch2::geometry::Size {
34                    height: stretch2::style::Dimension::Points(100f32),
35                    ..Default::default()
36                },
37                max_size: stretch2::geometry::Size {
38                    height: stretch2::style::Dimension::Points(500f32),
39                    ..Default::default()
40                },
41                ..Default::default()
42            },
43            &[node0, node1],
44        )
45        .unwrap();
46    stretch.compute_layout(node, stretch2::geometry::Size::undefined()).unwrap();
47}