gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1076HTML 1008Markdown 12TOML 83208 Definiciones

⎇ d8c8bb472833ba92d694a9420e4c5bd8308e32e3 benches/generated/absolute_layout_start_top_end_bottom.rs Rust · 35 líneas · 1.3 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                position_type: taffy::style::PositionType::Absolute,
9                position: taffy::geometry::Rect {
10                    left: taffy::style::LengthPercentageAuto::Points(10f32),
11                    right: taffy::style::LengthPercentageAuto::Points(10f32),
12                    top: taffy::style::LengthPercentageAuto::Points(10f32),
13                    bottom: taffy::style::LengthPercentageAuto::Points(10f32),
14                    ..Rect::auto()
15                },
16                ..Default::default()
17            },
18            &[],
19        )
20        .unwrap();
21    let node = taffy
22        .new_with_children(
23            taffy::style::Style {
24                size: taffy::geometry::Size {
25                    width: taffy::style::Dimension::Points(100f32),
26                    height: taffy::style::Dimension::Points(100f32),
27                    ..Size::auto()
28                },
29                ..Default::default()
30            },
31            &[node0],
32        )
33        .unwrap();
34    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
35}