gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 709HTML 662Markdown 12TOML 62348 Definiciones

⎇ 0.2.x benches/generated/margin_auto_left.rs Rust · 45 líneas · 1.6 KB Historia Quién tocó qué crudo

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