tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Definitions

⎇ 9e53f03adea2b770d68954e404d2fa407dfc7d40 benches/generated/gap_column_gap_flexible.rs Rust · 55 lines · 1.8 KB History Who touched what raw

Implement "gap" property for flexbox algorithm (#248) 9e53f03ad · Nico Burns ·

1pub fn compute() {
2    let mut taffy = taffy::Taffy::new();
3    let node0 = taffy
4        .new_with_children(
5            taffy::style::FlexboxLayout {
6                flex_grow: 1f32,
7                flex_shrink: 1f32,
8                flex_basis: taffy::style::Dimension::Percent(0f32),
9                ..Default::default()
10            },
11            &[],
12        )
13        .unwrap();
14    let node1 = taffy
15        .new_with_children(
16            taffy::style::FlexboxLayout {
17                flex_grow: 1f32,
18                flex_shrink: 1f32,
19                flex_basis: taffy::style::Dimension::Percent(0f32),
20                ..Default::default()
21            },
22            &[],
23        )
24        .unwrap();
25    let node2 = taffy
26        .new_with_children(
27            taffy::style::FlexboxLayout {
28                flex_grow: 1f32,
29                flex_shrink: 1f32,
30                flex_basis: taffy::style::Dimension::Percent(0f32),
31                ..Default::default()
32            },
33            &[],
34        )
35        .unwrap();
36    let node = taffy
37        .new_with_children(
38            taffy::style::FlexboxLayout {
39                gap: taffy::geometry::Size {
40                    width: taffy::style::Dimension::Points(10f32),
41                    height: taffy::style::Dimension::Points(20f32),
42                    ..Default::default()
43                },
44                size: taffy::geometry::Size {
45                    width: taffy::style::Dimension::Points(80f32),
46                    height: taffy::style::Dimension::Points(100f32),
47                    ..Default::default()
48                },
49                ..Default::default()
50            },
51            &[node0, node1, node2],
52        )
53        .unwrap();
54    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
55}