From 18b0385d7344f69a4ede63c01e6b234db4898d8b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 17 Jul 2023 16:48:31 -0600 Subject: [PATCH] WIP --- crates/gpui/playground/src/elements.rs | 12 +++++++++++- crates/gpui/playground/src/playground.rs | 3 +++ crates/gpui_macros/src/gpui_macros.rs | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/gpui/playground/src/elements.rs b/crates/gpui/playground/src/elements.rs index 24bc0f84b8..7ddef347ea 100644 --- a/crates/gpui/playground/src/elements.rs +++ b/crates/gpui/playground/src/elements.rs @@ -78,6 +78,16 @@ impl Node { self } + pub fn row(mut self) -> Self { + self.style.axis = Axis3d::X; + self + } + + pub fn stack(mut self) -> Self { + self.style.axis = Axis3d::Z; + self + } + fn layout_2d_children( &mut self, axis: Axis2d, @@ -216,7 +226,7 @@ impl Node { // Advance along the primary axis by the size of this child match axis { Axis2d::X => child_origin.set_x(child_origin.x() + child.size().x()), - Axis2d::Y => child_origin.set_y(child_origin.x() + child.size().y()), + Axis2d::Y => child_origin.set_y(child_origin.y() + child.size().y()), } } } diff --git a/crates/gpui/playground/src/playground.rs b/crates/gpui/playground/src/playground.rs index 6ab5b409ab..c2ec55281c 100644 --- a/crates/gpui/playground/src/playground.rs +++ b/crates/gpui/playground/src/playground.rs @@ -33,9 +33,12 @@ impl View for PlaygroundView { .width(100.) .height(100.) .fill(Color::red()) + .row() .children([ Node::new().width(20.).height(20.).fill(Color::green()), Node::new().width(20.).height(20.).fill(Color::blue()), + Node::new().width(30.).height(30.).fill(Color::yellow()), + Node::new().width(50.).height(50.).fill(Color::yellow()), ]) .into_any() diff --git a/crates/gpui_macros/src/gpui_macros.rs b/crates/gpui_macros/src/gpui_macros.rs index dbf57b83e5..62a4fd04f1 100644 --- a/crates/gpui_macros/src/gpui_macros.rs +++ b/crates/gpui_macros/src/gpui_macros.rs @@ -332,7 +332,7 @@ pub fn element_derive(input: TokenStream) -> TokenStream { _: &(), view: &V, cx: &gpui::ViewContext, - ) -> serde_json::Value { + ) -> gpui::json::Value { element.debug(view, cx) } }