gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1068HTML 999Markdown 12TOML 83188 Definiciones

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/grid_absolute_layout_within_border_static.rs Rust · 91 líneas · 4.0 KB Historia Quién tocó qué crudo

Fixes for aspect ratio and min/max sizes (#317) 610c92f31 · Nico Burns ·

1pub fn compute() {
2    #[allow(unused_imports)]
3    use taffy::prelude::*;
4    let mut taffy = taffy::Taffy::new();
5    let node0 = taffy
6        .new_leaf(taffy::style::Style {
7            position: taffy::style::Position::Absolute,
8            align_self: Some(taffy::style::AlignSelf::Start),
9            justify_self: Some(taffy::style::JustifySelf::Start),
10            size: taffy::geometry::Size {
11                width: taffy::style::Dimension::Points(50f32),
12                height: taffy::style::Dimension::Points(50f32),
13            },
14            ..Default::default()
15        })
16        .unwrap();
17    let node1 = taffy
18        .new_leaf(taffy::style::Style {
19            position: taffy::style::Position::Absolute,
20            align_self: Some(taffy::style::AlignSelf::End),
21            justify_self: Some(taffy::style::JustifySelf::End),
22            size: taffy::geometry::Size {
23                width: taffy::style::Dimension::Points(50f32),
24                height: taffy::style::Dimension::Points(50f32),
25            },
26            ..Default::default()
27        })
28        .unwrap();
29    let node2 = taffy
30        .new_leaf(taffy::style::Style {
31            position: taffy::style::Position::Absolute,
32            align_self: Some(taffy::style::AlignSelf::Start),
33            justify_self: Some(taffy::style::JustifySelf::Start),
34            size: taffy::geometry::Size {
35                width: taffy::style::Dimension::Points(50f32),
36                height: taffy::style::Dimension::Points(50f32),
37            },
38            margin: taffy::geometry::Rect {
39                left: taffy::style::LengthPercentageAuto::Points(10f32),
40                right: taffy::style::LengthPercentageAuto::Points(10f32),
41                top: taffy::style::LengthPercentageAuto::Points(10f32),
42                bottom: taffy::style::LengthPercentageAuto::Points(10f32),
43            },
44            ..Default::default()
45        })
46        .unwrap();
47    let node3 = taffy
48        .new_leaf(taffy::style::Style {
49            position: taffy::style::Position::Absolute,
50            align_self: Some(taffy::style::AlignSelf::End),
51            justify_self: Some(taffy::style::JustifySelf::End),
52            size: taffy::geometry::Size {
53                width: taffy::style::Dimension::Points(50f32),
54                height: taffy::style::Dimension::Points(50f32),
55            },
56            margin: taffy::geometry::Rect {
57                left: taffy::style::LengthPercentageAuto::Points(10f32),
58                right: taffy::style::LengthPercentageAuto::Points(10f32),
59                top: taffy::style::LengthPercentageAuto::Points(10f32),
60                bottom: taffy::style::LengthPercentageAuto::Points(10f32),
61            },
62            ..Default::default()
63        })
64        .unwrap();
65    let node = taffy
66        .new_with_children(
67            taffy::style::Style {
68                display: taffy::style::Display::Grid,
69                size: taffy::geometry::Size {
70                    width: taffy::style::Dimension::Points(100f32),
71                    height: taffy::style::Dimension::Points(100f32),
72                },
73                padding: taffy::geometry::Rect {
74                    left: taffy::style::LengthPercentage::Points(10f32),
75                    right: taffy::style::LengthPercentage::Points(10f32),
76                    top: taffy::style::LengthPercentage::Points(10f32),
77                    bottom: taffy::style::LengthPercentage::Points(10f32),
78                },
79                border: taffy::geometry::Rect {
80                    left: taffy::style::LengthPercentage::Points(10f32),
81                    right: taffy::style::LengthPercentage::Points(10f32),
82                    top: taffy::style::LengthPercentage::Points(10f32),
83                    bottom: taffy::style::LengthPercentage::Points(10f32),
84                },
85                ..Default::default()
86            },
87            &[node0, node1, node2, node3],
88        )
89        .unwrap();
90    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
91}