tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1118HTML 1044Markdown 12TOML 94787 Definiciones

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

index: fix formatting and warnings ef85ea9e2 · 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}