tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1085HTML 1017Markdown 12TOML 84234 Definiciones

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/grid_auto_fill_with_empty_auto_track.rs Rust · 24 líneas · 1.1 KB Historia Quién tocó qué crudo

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.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
7    let node = taffy
8        .new_with_children(
9            taffy::style::Style {
10                display: taffy::style::Display::Grid,
11                justify_content: Some(taffy::style::JustifyContent::SpaceEvenly),
12                grid_template_rows: vec![points(40f32), points(40f32), points(40f32)],
13                grid_template_columns: vec![repeat(GridTrackRepetition::AutoFill, vec![points(40f32)])],
14                size: taffy::geometry::Size {
15                    width: taffy::style::Dimension::Points(120f32),
16                    height: taffy::style::Dimension::Points(120f32),
17                },
18                ..Default::default()
19            },
20            &[node0, node1],
21        )
22        .unwrap();
23    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
24}