gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1082HTML 1014Markdown 12TOML 83222 Definiciones

⎇ 6b83eacc35555fe93c4a6b5bee2d84e40757390b examples/basic.rs Rust · 24 líneas · 762 B Historia Quién tocó qué crudo

index: fix formatting and warnings 7a9692ba7 · msiglreith ·

1use stretch::geometry::Size;
2use stretch::style::*;
3
4fn main() -> Result<(), stretch::Error> {
5    let mut stretch = stretch::node::Stretch::new();
6    let child = stretch.new_node(
7        Style { size: Size { width: Dimension::Percent(0.5), height: Dimension::Auto }, ..Default::default() },
8        vec![],
9    )?;
10    let node = stretch.new_node(
11        Style {
12            size: Size { width: Dimension::Points(100.0), height: Dimension::Points(100.0) },
13            justify_content: JustifyContent::Center,
14            ..Default::default()
15        },
16        vec![child],
17    )?;
18
19    stretch.compute_layout(node, Size::undefined())?;
20    println!("node: {:#?}", stretch.layout(node)?);
21    println!("child: {:#?}", stretch.layout(child)?);
22
23    Ok(())
24}