diff --git a/crates/gpui/playground/ui/src/node.rs b/crates/gpui/playground/ui/src/frame.rs similarity index 98% rename from crates/gpui/playground/ui/src/node.rs rename to crates/gpui/playground/ui/src/frame.rs index 9cea0aa043..cb2d67925f 100644 --- a/crates/gpui/playground/ui/src/node.rs +++ b/crates/gpui/playground/ui/src/frame.rs @@ -24,19 +24,19 @@ use std::{any::Any, borrow::Cow, f32, ops::Range, sync::Arc}; use crate::color::Rgba; -pub struct Node { - style: NodeStyle, +pub struct Frame { + style: FrameStyle, children: Vec>, id: Option>, } -pub fn column() -> Node { - Node::default() +pub fn column() -> Frame { + Frame::default() } -pub fn row() -> Node { - Node { - style: NodeStyle { +pub fn row() -> Frame { + Frame { + style: FrameStyle { axis: Axis3d::X, ..Default::default() }, @@ -44,9 +44,9 @@ pub fn row() -> Node { } } -pub fn stack() -> Node { - Node { - style: NodeStyle { +pub fn stack() -> Frame { + Frame { + style: FrameStyle { axis: Axis3d::Z, ..Default::default() }, @@ -54,7 +54,7 @@ pub fn stack() -> Node { } } -impl Default for Node { +impl Default for Frame { fn default() -> Self { Self { style: Default::default(), @@ -64,8 +64,8 @@ impl Default for Node { } } -impl Element for Node { - type LayoutState = NodeLayout; +impl Element for Frame { + type LayoutState = FrameLayout; type PaintState = (); fn layout( @@ -88,7 +88,7 @@ impl Element for Node { scene: &mut SceneBuilder, bounds: RectF, visible_bounds: RectF, - layout: &mut NodeLayout, + layout: &mut FrameLayout, view: &mut V, cx: &mut PaintContext, ) -> Self::PaintState { @@ -205,7 +205,7 @@ impl Element for Node { cx: &ViewContext, ) -> Value { json!({ - "type": "Node", + "type": "Frame", "bounds": bounds.to_json(), // TODO! // "children": self.content.iter().map(|child| child.debug(view, cx)).collect::>() @@ -217,7 +217,7 @@ impl Element for Node { } } -impl Node { +impl Frame { pub fn id(mut self, id: impl Into>) -> Self { self.id = Some(id.into()); self @@ -321,10 +321,10 @@ impl Node { rem_pixels: f32, view: &mut V, cx: &mut LayoutContext, - ) -> NodeLayout { + ) -> FrameLayout { let cross_axis = primary_axis.rotate(); let total_flex = self.style.flex(); - let mut layout = NodeLayout { + let mut layout = FrameLayout { size: Default::default(), padding: self.style.padding.fixed_pixels(rem_pixels), margins: self.style.margins.fixed_pixels(rem_pixels), @@ -372,7 +372,7 @@ impl Node { for child in &mut self.children { if let Some(child_flex) = child - .metadata::() + .metadata::() .map(|style| style.flex().get(primary_axis)) { if child_flex > 0. { @@ -391,7 +391,7 @@ impl Node { // Distribute the remaining length among the flexible children. for child in &mut self.children { if let Some(child_flex) = child - .metadata::() + .metadata::() .map(|style| style.flex().get(primary_axis)) { if child_flex > 0. { @@ -564,7 +564,7 @@ struct Interactive