gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5364Rust 86Markdown 12TOML 91822 Definitions

⎇ d8c8bb472833ba92d694a9420e4c5bd8308e32e3 benches/generated/justify_content_row_max_width_and_margin.rs Rust · 34 lines · 1.2 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                size: taffy::geometry::Size {
9                    width: taffy::style::Dimension::Points(20f32),
10                    height: taffy::style::Dimension::Points(20f32),
11                    ..Size::auto()
12                },
13                margin: taffy::geometry::Rect {
14                    left: taffy::style::LengthPercentageAuto::Points(100f32),
15                    ..Rect::zero()
16                },
17                ..Default::default()
18            },
19            &[],
20        )
21        .unwrap();
22    let node = taffy
23        .new_with_children(
24            taffy::style::Style {
25                justify_content: taffy::style::JustifyContent::Center,
26                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() },
27                max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Size::auto() },
28                ..Default::default()
29            },
30            &[node0],
31        )
32        .unwrap();
33    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
34}