tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Definiciones

⎇ ec371711989b7f4d870d91bea4b66bdd94b45c9e benches/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs Rust · 68 líneas · 2.3 KB Historia Quién tocó qué crudo

Implement CSS Grid (#205) 6fd2c6bcb · Nico Burns ·

1pub fn compute() {
2    #[allow(unused_imports)]
3    use taffy::prelude::*;
4    let mut taffy = taffy::Taffy::new();
5    let node000 = taffy
6        .new_leaf(taffy::style::Style {
7            size: taffy::geometry::Size {
8                width: taffy::style::Dimension::Points(40f32),
9                height: taffy::style::Dimension::Points(40f32),
10            },
11            ..Default::default()
12        })
13        .unwrap();
14    let node00 = taffy
15        .new_with_children(
16            taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() },
17            &[node000],
18        )
19        .unwrap();
20    let node010 = taffy
21        .new_leaf(taffy::style::Style {
22            size: taffy::geometry::Size {
23                width: taffy::style::Dimension::Points(40f32),
24                height: taffy::style::Dimension::Points(40f32),
25            },
26            ..Default::default()
27        })
28        .unwrap();
29    let node01 = taffy
30        .new_with_children(
31            taffy::style::Style {
32                flex_direction: taffy::style::FlexDirection::Column,
33                margin: taffy::geometry::Rect {
34                    left: zero(),
35                    right: taffy::style::LengthPercentageAuto::Points(10f32),
36                    top: zero(),
37                    bottom: zero(),
38                },
39                ..Default::default()
40            },
41            &[node010],
42        )
43        .unwrap();
44    let node0 = taffy
45        .new_with_children(
46            taffy::style::Style {
47                flex_wrap: taffy::style::FlexWrap::Wrap,
48                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(85f32), height: auto() },
49                ..Default::default()
50            },
51            &[node00, node01],
52        )
53        .unwrap();
54    let node = taffy
55        .new_with_children(
56            taffy::style::Style {
57                flex_direction: taffy::style::FlexDirection::Column,
58                size: taffy::geometry::Size {
59                    width: taffy::style::Dimension::Points(500f32),
60                    height: taffy::style::Dimension::Points(500f32),
61                },
62                ..Default::default()
63            },
64            &[node0],
65        )
66        .unwrap();
67    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
68}