gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Definitions

⎇ d8c8bb472833ba92d694a9420e4c5bd8308e32e3 benches/generated/padding_flex_child.rs Rust · 36 lines · 1.3 KB History Who touched what raw

Strict types for style values (#269) 0d8c198a9 · 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_with_children(
7            taffy::style::Style {
8                flex_grow: 1f32,
9                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() },
10                ..Default::default()
11            },
12            &[],
13        )
14        .unwrap();
15    let node = taffy
16        .new_with_children(
17            taffy::style::Style {
18                size: taffy::geometry::Size {
19                    width: taffy::style::Dimension::Points(100f32),
20                    height: taffy::style::Dimension::Points(100f32),
21                    ..Size::auto()
22                },
23                padding: taffy::geometry::Rect {
24                    left: taffy::style::LengthPercentage::Points(10f32),
25                    right: taffy::style::LengthPercentage::Points(10f32),
26                    top: taffy::style::LengthPercentage::Points(10f32),
27                    bottom: taffy::style::LengthPercentage::Points(10f32),
28                    ..Rect::zero()
29                },
30                ..Default::default()
31            },
32            &[node0],
33        )
34        .unwrap();
35    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
36}