tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1077HTML 1008Markdown 12TOML 83209 Definitions

⎇ 859cc921b3adb8e3b184e6fc0cf0c40b6c5a625b benches/generated/grid_align_items_sized_end.rs Rust · 44 lines · 1.9 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(1i16), end: taffy::style::GridPlacement::Auto },
9            size: taffy::geometry::Size {
10                width: taffy::style::Dimension::Points(20f32),
11                height: taffy::style::Dimension::Points(20f32),
12            },
13            ..Default::default()
14        })
15        .unwrap();
16    let node1 = taffy
17        .new_leaf(taffy::style::Style {
18            grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto },
19            grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto },
20            size: taffy::geometry::Size {
21                width: taffy::style::Dimension::Points(60f32),
22                height: taffy::style::Dimension::Points(60f32),
23            },
24            ..Default::default()
25        })
26        .unwrap();
27    let node = taffy
28        .new_with_children(
29            taffy::style::Style {
30                display: taffy::style::Display::Grid,
31                align_items: Some(taffy::style::AlignItems::End),
32                grid_template_rows: vec![points(40f32), points(40f32), points(40f32)],
33                grid_template_columns: vec![points(40f32), points(40f32), points(40f32)],
34                size: taffy::geometry::Size {
35                    width: taffy::style::Dimension::Points(120f32),
36                    height: taffy::style::Dimension::Points(120f32),
37                },
38                ..Default::default()
39            },
40            &[node0, node1],
41        )
42        .unwrap();
43    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
44}