tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 583HTML 275Markdown 8TOML 41586 Definiciones

⎇ 9e53f03adea2b770d68954e404d2fa407dfc7d40 benches/generated/margin_auto_left_and_right.rs Rust · 48 líneas · 1.6 KB Historia Quién tocó qué crudo

Layout algorithm decoupling, Sizing Constraints & Perf Improvements (#246) ba4cd3c3b · 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 {
7                    width: taffy::style::Dimension::Points(50f32),
8                    height: taffy::style::Dimension::Points(50f32),
9                    ..Default::default()
10                },
11                margin: taffy::geometry::Rect {
12                    start: taffy::style::Dimension::Auto,
13                    end: 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::FlexboxLayout {
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::FlexboxLayout {
37                size: taffy::geometry::Size {
38                    width: taffy::style::Dimension::Points(200f32),
39                    height: taffy::style::Dimension::Points(200f32),
40                    ..Default::default()
41                },
42                ..Default::default()
43            },
44            &[node0, node1],
45        )
46        .unwrap();
47    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
48}