gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5364Rust 86Markdown 12TOML 91841 Definitions

update sample to use new api

2472941336f4a3a4b74d7a4330a2fe5c5c5c1428 · by Emil Sjölander · (7 years ago) · parent c9a591338 · browse the tree at this commit

Semantic delta · 1

examples/basic.rs

  • body changed fn main

1 files · +12 −11

diff --git a/examples/basic.rs b/examples/basic.rs
index a06cbef34..3ba1ff4b7 100644
--- a/examples/basic.rs
+++ b/examples/basic.rs
@@ -1,20 +1,21 @@
 use stretch::geometry::Size;
+use stretch::node::Node;
 use stretch::style::*;
 
 fn main() {
-    let node = Node {
-        size: Size { width: Dimension::Points(100.0), height: Dimension::Points(100.0) },
-        justify_content: JustifyContent::Center,
-
-        children: vec![Node {
-            size: Size { width: Dimension::Percent(0.5), height: Dimension::Auto },
+    let node = Node::new(
+        Style {
+            size: Size { width: Dimension::Points(100.0), height: Dimension::Points(100.0) },
+            justify_content: JustifyContent::Center,
             ..Default::default()
-        }],
-
-        ..Default::default()
-    };
+        },
+        vec![&Node::new(
+            Style { size: Size { width: Dimension::Percent(0.5), height: Dimension::Auto }, ..Default::default() },
+            vec![],
+        )],
+    );
 
-    let layout = stretch::compute(&node, Size::undefined()).unwrap();
+    let layout = node.compute_layout(Size::undefined()).unwrap();
 
     println!("{:#?}", layout);
 }