gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 227Rust 7TOML 3CSS 1307 Definiciones

⎇ 0.2.x benches/generated/flex_basis_and_main_dimen_set_when_flexing.rs Rust · 43 líneas · 1.5 KB Historia Quién tocó qué crudo

Rename FlexboxLayout back to Style (#251) 49893a7d9 · 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_basis: taffy::style::Dimension::Points(10f32),
8                size: taffy::geometry::Size {
9                    width: taffy::style::Dimension::Points(50f32),
10                    height: taffy::style::Dimension::Points(50f32),
11                    ..Default::default()
12                },
13                ..Default::default()
14            },
15            &[],
16        )
17        .unwrap();
18    let node1 = taffy
19        .new_with_children(
20            taffy::style::Style {
21                flex_grow: 1f32,
22                flex_basis: taffy::style::Dimension::Points(10f32),
23                size: taffy::geometry::Size {
24                    width: taffy::style::Dimension::Points(0f32),
25                    height: taffy::style::Dimension::Points(50f32),
26                    ..Default::default()
27                },
28                ..Default::default()
29            },
30            &[],
31        )
32        .unwrap();
33    let node = taffy
34        .new_with_children(
35            taffy::style::Style {
36                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() },
37                ..Default::default()
38            },
39            &[node0, node1],
40        )
41        .unwrap();
42    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
43}