gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 708HTML 661Markdown 12TOML 62346 Sutichaykuna

⎇ 0.2.x benches/generated/margin_auto_left_and_right_column.rs Rust · 49 siq'ikuna · 1.7 KB Ñawpa willay Pi imata llamkarqan ch'uya

Rename Rect field start->left end->right (#257) ca514f6c8 · 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                margin: taffy::geometry::Rect {
12                    left: taffy::style::Dimension::Auto,
13                    right: taffy::style::Dimension::Auto,
14                    ..Default::default()
15                },
16                ..Default::default()
17            },
18            &[],
19        )
20        .unwrap();
21    let node1 = taffy
22        .new_with_children(
23            taffy::style::Style {
24                size: taffy::geometry::Size {
25                    width: taffy::style::Dimension::Points(50f32),
26                    height: taffy::style::Dimension::Points(50f32),
27                    ..Default::default()
28                },
29                ..Default::default()
30            },
31            &[],
32        )
33        .unwrap();
34    let node = taffy
35        .new_with_children(
36            taffy::style::Style {
37                align_items: taffy::style::AlignItems::Center,
38                size: taffy::geometry::Size {
39                    width: taffy::style::Dimension::Points(200f32),
40                    height: taffy::style::Dimension::Points(200f32),
41                    ..Default::default()
42                },
43                ..Default::default()
44            },
45            &[node0, node1],
46        )
47        .unwrap();
48    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
49}