tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 8TOML 3CSS 1317 Definitions

⎇ ebd376fbebd0ba73c79aa00d1835918680ef82a0 benches/generated/grid_basic_implicit_tracks.rs Rust · 27 lines · 955 B History Who touched what raw

Implement CSS Grid (#205) 6fd2c6bcb · Nico Burns ·

1pub fn compute() {
2    #[allow(unused_imports)]
3    use taffy::prelude::*;
4    let mut taffy = taffy::Taffy::new();
5    let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
6    let node1 = taffy
7        .new_leaf(taffy::style::Style {
8            size: taffy::geometry::Size {
9                width: taffy::style::Dimension::Points(35f32),
10                height: taffy::style::Dimension::Points(35f32),
11            },
12            ..Default::default()
13        })
14        .unwrap();
15    let node = taffy
16        .new_with_children(
17            taffy::style::Style {
18                display: taffy::style::Display::Grid,
19                grid_template_rows: vec![points(40f32)],
20                grid_template_columns: vec![points(40f32)],
21                ..Default::default()
22            },
23            &[node0, node1],
24        )
25        .unwrap();
26    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
27}