tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1077HTML 1008Markdown 12TOML 83209 Definitions

⎇ 859cc921b3adb8e3b184e6fc0cf0c40b6c5a625b benches/generated/grid_placement_auto_negative.rs Rust · 35 lines · 1.4 KB History Who touched what raw

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            grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto },
8            grid_column: taffy::geometry::Line { start: line(-5i16), end: taffy::style::GridPlacement::Auto },
9            ..Default::default()
10        })
11        .unwrap();
12    let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
13    let node2 = taffy
14        .new_leaf(taffy::style::Style {
15            grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto },
16            ..Default::default()
17        })
18        .unwrap();
19    let node = taffy
20        .new_with_children(
21            taffy::style::Style {
22                display: taffy::style::Display::Grid,
23                grid_template_rows: vec![points(40f32), points(40f32)],
24                grid_template_columns: vec![points(40f32), points(40f32)],
25                size: taffy::geometry::Size {
26                    width: taffy::style::Dimension::Points(120f32),
27                    height: taffy::style::Dimension::Points(120f32),
28                },
29                ..Default::default()
30            },
31            &[node0, node1, node2],
32        )
33        .unwrap();
34    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
35}