gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 227Rust 7TOML 3CSS 1307 Definitions

⎇ 0.2.x benches/generated/align_baseline.rs Rust · 44 lines · 1.5 KB History Who touched what raw

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