gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 684HTML 640Markdown 12TOML 62286 Definiciones

⎇ 9e53f03adea2b770d68954e404d2fa407dfc7d40 benches/generated/gap_row_gap_row_wrap_child_margins.rs Rust · 61 líneas · 2.3 KB Historia Quién tocó qué crudo

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(60f32), ..Default::default() },
7                margin: taffy::geometry::Rect {
8                    top: taffy::style::Dimension::Points(2f32),
9                    bottom: taffy::style::Dimension::Points(2f32),
10                    ..Default::default()
11                },
12                ..Default::default()
13            },
14            &[],
15        )
16        .unwrap();
17    let node1 = taffy
18        .new_with_children(
19            taffy::style::FlexboxLayout {
20                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() },
21                margin: taffy::geometry::Rect {
22                    top: taffy::style::Dimension::Points(10f32),
23                    bottom: taffy::style::Dimension::Points(10f32),
24                    ..Default::default()
25                },
26                ..Default::default()
27            },
28            &[],
29        )
30        .unwrap();
31    let node2 = taffy
32        .new_with_children(
33            taffy::style::FlexboxLayout {
34                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() },
35                margin: taffy::geometry::Rect {
36                    top: taffy::style::Dimension::Points(15f32),
37                    bottom: taffy::style::Dimension::Points(15f32),
38                    ..Default::default()
39                },
40                ..Default::default()
41            },
42            &[],
43        )
44        .unwrap();
45    let node = taffy
46        .new_with_children(
47            taffy::style::FlexboxLayout {
48                flex_wrap: taffy::style::FlexWrap::Wrap,
49                gap: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() },
50                size: taffy::geometry::Size {
51                    width: taffy::style::Dimension::Points(100f32),
52                    height: taffy::style::Dimension::Points(200f32),
53                    ..Default::default()
54                },
55                ..Default::default()
56            },
57            &[node0, node1, node2],
58        )
59        .unwrap();
60    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
61}