tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81412 Definitions

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/grid_absolute_container_top_bottom_margin.rs Rust · 43 lines · 2.1 KB History Who touched what raw

Rename PositionType and Position in accordance to specs (#295) e2cee9d6f · Andreas Weibye ·

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            inset: taffy::geometry::Rect {
9                left: auto(),
10                right: auto(),
11                top: taffy::style::LengthPercentageAuto::Points(2f32),
12                bottom: taffy::style::LengthPercentageAuto::Points(5f32),
13            },
14            ..Default::default()
15        })
16        .unwrap();
17    let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
18    let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
19    let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
20    let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
21    let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
22    let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
23    let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
24    let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
25    let node = taffy
26        .new_with_children(
27            taffy::style::Style {
28                display: taffy::style::Display::Grid,
29                grid_template_rows: vec![points(40f32), points(40f32), points(40f32)],
30                grid_template_columns: vec![points(40f32), points(40f32), points(40f32)],
31                padding: taffy::geometry::Rect {
32                    left: taffy::style::LengthPercentage::Points(40f32),
33                    right: taffy::style::LengthPercentage::Points(20f32),
34                    top: taffy::style::LengthPercentage::Points(10f32),
35                    bottom: taffy::style::LengthPercentage::Points(30f32),
36                },
37                ..Default::default()
38            },
39            &[node0, node1, node2, node3, node4, node5, node6, node7, node8],
40        )
41        .unwrap();
42    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
43}