tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 583HTML 275Markdown 8TOML 41586 Sutichaykuna

⎇ b0c7d824daea2c453850812d532c277f8ac37736 benches/generated/absolute_layout_width_height_start_top_end_bottom.rs Rust · 34 siq'ikuna · 1.3 KB Ñawpa willay Pi imata llamkarqan ch'uya

Rename PositionType and Position in accordance to specs (#295) e2cee9d6f · Andreas Weibye ·

1pub fn compute() {
2    #[allow(unused_imports)]
3    use taffy::prelude::*;
4    let mut taffy = taffy::Taffy::new();
5    let node0 = taffy
6        .new_leaf(taffy::style::Style {
7            position: taffy::style::Position::Absolute,
8            size: taffy::geometry::Size {
9                width: taffy::style::Dimension::Points(10f32),
10                height: taffy::style::Dimension::Points(10f32),
11            },
12            inset: taffy::geometry::Rect {
13                left: taffy::style::LengthPercentageAuto::Points(10f32),
14                right: taffy::style::LengthPercentageAuto::Points(10f32),
15                top: taffy::style::LengthPercentageAuto::Points(10f32),
16                bottom: taffy::style::LengthPercentageAuto::Points(10f32),
17            },
18            ..Default::default()
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                },
28                ..Default::default()
29            },
30            &[node0],
31        )
32        .unwrap();
33    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
34}