tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Sutichaykuna

⎇ ec371711989b7f4d870d91bea4b66bdd94b45c9e benches/generated/grid_absolute_row_start.rs Rust · 36 siq'ikuna · 1.6 KB Ñawpa willay Pi imata llamkarqan ch'uya

Grid/refactor coordinate handling (#301) 859cc921b · 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_leaf(taffy::style::Style {
7            position: taffy::style::Position::Absolute,
8            grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto },
9            inset: taffy::geometry::Rect {
10                left: taffy::style::LengthPercentageAuto::Points(4f32),
11                right: taffy::style::LengthPercentageAuto::Points(3f32),
12                top: taffy::style::LengthPercentageAuto::Points(1f32),
13                bottom: taffy::style::LengthPercentageAuto::Points(2f32),
14            },
15            ..Default::default()
16        })
17        .unwrap();
18    let node = taffy
19        .new_with_children(
20            taffy::style::Style {
21                display: taffy::style::Display::Grid,
22                grid_template_rows: vec![points(40f32), points(40f32), points(40f32)],
23                grid_template_columns: vec![points(40f32), points(40f32), points(40f32)],
24                padding: taffy::geometry::Rect {
25                    left: taffy::style::LengthPercentage::Points(40f32),
26                    right: taffy::style::LengthPercentage::Points(20f32),
27                    top: taffy::style::LengthPercentage::Points(10f32),
28                    bottom: taffy::style::LengthPercentage::Points(30f32),
29                },
30                ..Default::default()
31            },
32            &[node0],
33        )
34        .unwrap();
35    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
36}