gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 230Rust 8TOML 3CSS 1315 Definiciones

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/align_baseline_child_padding.rs Rust · 62 líneas · 2.4 KB Historia Quién tocó qué crudo

Fix flexbox baseline alignment (#325) b91874d4e · 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            size: taffy::geometry::Size {
8                width: taffy::style::Dimension::Points(50f32),
9                height: taffy::style::Dimension::Points(50f32),
10            },
11            ..Default::default()
12        })
13        .unwrap();
14    let node10 = taffy
15        .new_leaf(taffy::style::Style {
16            size: taffy::geometry::Size {
17                width: taffy::style::Dimension::Points(50f32),
18                height: taffy::style::Dimension::Points(10f32),
19            },
20            ..Default::default()
21        })
22        .unwrap();
23    let node1 = taffy
24        .new_with_children(
25            taffy::style::Style {
26                flex_direction: taffy::style::FlexDirection::Column,
27                size: taffy::geometry::Size {
28                    width: taffy::style::Dimension::Points(50f32),
29                    height: taffy::style::Dimension::Points(20f32),
30                },
31                padding: taffy::geometry::Rect {
32                    left: taffy::style::LengthPercentage::Points(5f32),
33                    right: taffy::style::LengthPercentage::Points(5f32),
34                    top: taffy::style::LengthPercentage::Points(5f32),
35                    bottom: taffy::style::LengthPercentage::Points(5f32),
36                },
37                ..Default::default()
38            },
39            &[node10],
40        )
41        .unwrap();
42    let node = taffy
43        .new_with_children(
44            taffy::style::Style {
45                align_items: Some(taffy::style::AlignItems::Baseline),
46                size: taffy::geometry::Size {
47                    width: taffy::style::Dimension::Points(100f32),
48                    height: taffy::style::Dimension::Points(100f32),
49                },
50                padding: taffy::geometry::Rect {
51                    left: taffy::style::LengthPercentage::Points(5f32),
52                    right: taffy::style::LengthPercentage::Points(5f32),
53                    top: taffy::style::LengthPercentage::Points(5f32),
54                    bottom: taffy::style::LengthPercentage::Points(5f32),
55                },
56                ..Default::default()
57            },
58            &[node0, node1],
59        )
60        .unwrap();
61    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
62}