tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1085HTML 1017Markdown 12TOML 84234 Definiciones

⎇ ec371711989b7f4d870d91bea4b66bdd94b45c9e benches/generated/grid_min_content_flex_row.rs Rust · 68 líneas · 2.3 KB Historia Quién tocó qué crudo

Fixes for aspect ratio and min/max sizes (#317) 610c92f31 · Nico Burns ·

1pub fn compute() {
2    #[allow(unused_imports)]
3    use taffy::prelude::*;
4    let mut taffy = taffy::Taffy::new();
5    let node00 = taffy
6        .new_leaf_with_measure(
7            taffy::style::Style { ..Default::default() },
8            taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| {
9                const TEXT: &str = "HH\u{200b}HH";
10                super::measure_standard_text(
11                    known_dimensions,
12                    available_space,
13                    TEXT,
14                    super::WritingMode::Horizontal,
15                    None,
16                )
17            }),
18        )
19        .unwrap();
20    let node01 = taffy
21        .new_leaf_with_measure(
22            taffy::style::Style { ..Default::default() },
23            taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| {
24                const TEXT: &str = "HH\u{200b}HH";
25                super::measure_standard_text(
26                    known_dimensions,
27                    available_space,
28                    TEXT,
29                    super::WritingMode::Horizontal,
30                    None,
31                )
32            }),
33        )
34        .unwrap();
35    let node02 = taffy
36        .new_leaf_with_measure(
37            taffy::style::Style { ..Default::default() },
38            taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| {
39                const TEXT: &str = "HH\u{200b}HH";
40                super::measure_standard_text(
41                    known_dimensions,
42                    available_space,
43                    TEXT,
44                    super::WritingMode::Horizontal,
45                    None,
46                )
47            }),
48        )
49        .unwrap();
50    let node0 = taffy
51        .new_with_children(
52            taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() },
53            &[node00, node01, node02],
54        )
55        .unwrap();
56    let node = taffy
57        .new_with_children(
58            taffy::style::Style {
59                display: taffy::style::Display::Grid,
60                grid_template_rows: vec![points(40f32)],
61                grid_template_columns: vec![min_content()],
62                ..Default::default()
63            },
64            &[node0],
65        )
66        .unwrap();
67    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
68}