gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 227Rust 7TOML 3CSS 1307 Definitions

⎇ 9e53f03adea2b770d68954e404d2fa407dfc7d40 benches/generated/gap_column_gap_mixed_flexible.rs Rust · 47 lines · 1.6 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                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
7                ..Default::default()
8            },
9            &[],
10        )
11        .unwrap();
12    let node1 = taffy
13        .new_with_children(
14            taffy::style::FlexboxLayout {
15                flex_grow: 1f32,
16                flex_shrink: 1f32,
17                flex_basis: taffy::style::Dimension::Percent(0f32),
18                ..Default::default()
19            },
20            &[],
21        )
22        .unwrap();
23    let node2 = taffy
24        .new_with_children(
25            taffy::style::FlexboxLayout {
26                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
27                ..Default::default()
28            },
29            &[],
30        )
31        .unwrap();
32    let node = taffy
33        .new_with_children(
34            taffy::style::FlexboxLayout {
35                gap: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() },
36                size: taffy::geometry::Size {
37                    width: taffy::style::Dimension::Points(80f32),
38                    height: taffy::style::Dimension::Points(100f32),
39                    ..Default::default()
40                },
41                ..Default::default()
42            },
43            &[node0, node1, node2],
44        )
45        .unwrap();
46    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
47}