tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 496HTML 245JavaScript 8CSS 61215 Definiciones

⎇ 0.2.x benches/generated/child_min_max_width_flexing.rs Rust · 41 líneas · 1.4 KB Historia Quién tocó qué crudo

Rename FlexboxLayout back to Style (#251) 49893a7d9 · Nico Burns ·

1pub fn compute() {
2    let mut taffy = taffy::Taffy::new();
3    let node0 = taffy
4        .new_with_children(
5            taffy::style::Style {
6                flex_grow: 1f32,
7                flex_shrink: 0f32,
8                flex_basis: taffy::style::Dimension::Points(0f32),
9                min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() },
10                ..Default::default()
11            },
12            &[],
13        )
14        .unwrap();
15    let node1 = taffy
16        .new_with_children(
17            taffy::style::Style {
18                flex_grow: 1f32,
19                flex_shrink: 0f32,
20                flex_basis: taffy::style::Dimension::Percent(0.5f32),
21                max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
22                ..Default::default()
23            },
24            &[],
25        )
26        .unwrap();
27    let node = taffy
28        .new_with_children(
29            taffy::style::Style {
30                size: taffy::geometry::Size {
31                    width: taffy::style::Dimension::Points(120f32),
32                    height: taffy::style::Dimension::Points(50f32),
33                    ..Default::default()
34                },
35                ..Default::default()
36            },
37            &[node0, node1],
38        )
39        .unwrap();
40    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
41}