diff --git a/crates/gpui3/src/element.rs b/crates/gpui3/src/element.rs index afb50fabec2fe80b07dee30880c8ae604691a156..e5ba1815a5c347879d58a5e6e9e59508f6b69545 100644 --- a/crates/gpui3/src/element.rs +++ b/crates/gpui3/src/element.rs @@ -1,3 +1,5 @@ +use smallvec::SmallVec; + use super::{Handle, Layout, LayoutId, Pixels, Point, Result, ViewContext, WindowContext}; use std::{any::Any, cell::RefCell, marker::PhantomData, rc::Rc}; @@ -21,7 +23,15 @@ pub trait Element: 'static { } pub trait ParentElement { - fn child(self, child: impl IntoAnyElement) -> Self; + fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]>; + + fn child(mut self, child: impl IntoAnyElement) -> Self + where + Self: Sized, + { + self.children_mut().push(child.into_any()); + self + } } trait ElementObject { diff --git a/crates/gpui3/src/elements.rs b/crates/gpui3/src/elements.rs index 3847db24cc5fcdbaf135ec517f0415dec8da138a..c2cecaf6c66a9c622b727708a79c82d9cc852496 100644 --- a/crates/gpui3/src/elements.rs +++ b/crates/gpui3/src/elements.rs @@ -2,7 +2,6 @@ pub mod div; pub mod editor; use super::*; -use std::marker::PhantomData; pub use div::div; pub use editor::field; diff --git a/crates/gpui3/src/elements/div.rs b/crates/gpui3/src/elements/div.rs index bc0c23fc5ad0e3b1485cdf04ad18bbd33c4c1e43..77e323204b8d35a3862df29bc2f29a739d31ae2b 100644 --- a/crates/gpui3/src/elements/div.rs +++ b/crates/gpui3/src/elements/div.rs @@ -1,38 +1,295 @@ -use super::{ - Element, IntoAnyElement, Layout, LayoutId, ParentElement, PhantomData, Result, ViewContext, +use crate::{ + AnyElement, Bounds, Element, Layout, LayoutId, Overflow, ParentElement, Pixels, Point, + Refineable, RefinementCascade, Result, Style, Styled, ViewContext, }; +use smallvec::SmallVec; +use std::{cell::Cell, rc::Rc}; +use util::ResultExt; -pub struct Div(PhantomData); +pub struct Div { + styles: RefinementCascade