gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Definiciones

⎇ d8c8bb472833ba92d694a9420e4c5bd8308e32e3 benches/generated/display_none_with_margin.rs Rust · 41 líneas · 1.6 KB Historia Quién tocó qué crudo

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                display: taffy::style::Display::None,
9                size: taffy::geometry::Size {
10                    width: taffy::style::Dimension::Points(20f32),
11                    height: taffy::style::Dimension::Points(20f32),
12                    ..Size::auto()
13                },
14                margin: taffy::geometry::Rect {
15                    left: taffy::style::LengthPercentageAuto::Points(10f32),
16                    right: taffy::style::LengthPercentageAuto::Points(10f32),
17                    top: taffy::style::LengthPercentageAuto::Points(10f32),
18                    bottom: taffy::style::LengthPercentageAuto::Points(10f32),
19                    ..Rect::zero()
20                },
21                ..Default::default()
22            },
23            &[],
24        )
25        .unwrap();
26    let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap();
27    let node = taffy
28        .new_with_children(
29            taffy::style::Style {
30                size: taffy::geometry::Size {
31                    width: taffy::style::Dimension::Points(100f32),
32                    height: taffy::style::Dimension::Points(100f32),
33                    ..Size::auto()
34                },
35                ..Default::default()
36            },
37            &[node0, node1],
38        )
39        .unwrap();
40    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
41}