gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 492HTML 238TOML 3CSS 11131 Definiciones

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

Fix percent sized tracks (#314) 06a168cb1 · 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 { width: taffy::style::Dimension::Percent(0.5f32), height: auto() },
8            padding: taffy::geometry::Rect {
9                left: taffy::style::LengthPercentage::Percent(0.03f32),
10                right: taffy::style::LengthPercentage::Percent(0.03f32),
11                top: taffy::style::LengthPercentage::Percent(0.03f32),
12                bottom: taffy::style::LengthPercentage::Percent(0.03f32),
13            },
14            ..Default::default()
15        })
16        .unwrap();
17    let node = taffy
18        .new_with_children(
19            taffy::style::Style {
20                display: taffy::style::Display::Grid,
21                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() },
22                ..Default::default()
23            },
24            &[node0],
25        )
26        .unwrap();
27    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
28}