diff --git a/crates/storybook/src/gpui3/element.rs b/crates/storybook/src/gpui3/element.rs index ea54e1a9c3aae8ca228ed9a04f68e5ad952031cc..afb50fabec2fe80b07dee30880c8ae604691a156 100644 --- a/crates/storybook/src/gpui3/element.rs +++ b/crates/storybook/src/gpui3/element.rs @@ -1,5 +1,4 @@ -use super::{Handle, Layout, LayoutId, Pixels, Point, ViewContext, WindowContext}; -use anyhow::Result; +use super::{Handle, Layout, LayoutId, Pixels, Point, Result, ViewContext, WindowContext}; use std::{any::Any, cell::RefCell, marker::PhantomData, rc::Rc}; pub trait Element: 'static { diff --git a/crates/storybook/src/gpui3/elements.rs b/crates/storybook/src/gpui3/elements.rs index 9bd9727f21b8af9340c9aad745a2de0ac2b8069b..3847db24cc5fcdbaf135ec517f0415dec8da138a 100644 --- a/crates/storybook/src/gpui3/elements.rs +++ b/crates/storybook/src/gpui3/elements.rs @@ -1,40 +1,8 @@ -use std::marker::PhantomData; - -use anyhow::Result; - -use super::{Element, IntoAnyElement, Layout, LayoutId, ParentElement, ViewContext}; - -pub struct Div(PhantomData); +pub mod div; +pub mod editor; -impl Element for Div { - type State = S; - type FrameState = (); - - fn layout( - &mut self, - state: &mut Self::State, - cx: &mut ViewContext, - ) -> Result<(LayoutId, Self::FrameState)> { - todo!() - } - - fn paint( - &mut self, - layout: Layout, - state: &mut Self::State, - frame_state: &mut Self::FrameState, - cx: &mut ViewContext, - ) -> Result<()> { - todo!() - } -} - -impl ParentElement for Div { - fn child(self, child: impl IntoAnyElement) -> Self { - todo!() - } -} +use super::*; +use std::marker::PhantomData; -pub fn div() -> Div { - todo!() -} +pub use div::div; +pub use editor::field; diff --git a/crates/storybook/src/gpui3/elements/div.rs b/crates/storybook/src/gpui3/elements/div.rs new file mode 100644 index 0000000000000000000000000000000000000000..7d3f70042b09ac01b567dc410e673ca660c5fb7e --- /dev/null +++ b/crates/storybook/src/gpui3/elements/div.rs @@ -0,0 +1,38 @@ +use super::{ + Element, IntoAnyElement, Layout, LayoutId, ParentElement, PhantomData, Result, ViewContext, +}; + +pub struct Div(PhantomData); + +impl Element for Div { + type State = S; + type FrameState = (); + + fn layout( + &mut self, + state: &mut Self::State, + cx: &mut ViewContext, + ) -> Result<(LayoutId, Self::FrameState)> { + todo!() + } + + fn paint( + &mut self, + layout: Layout, + state: &mut Self::State, + frame_state: &mut Self::FrameState, + cx: &mut ViewContext, + ) -> Result<()> { + todo!() + } +} + +impl ParentElement for Div { + fn child(self, child: impl IntoAnyElement) -> Self { + todo!() + } +} + +pub fn div() -> Div { + todo!() +} diff --git a/crates/storybook/src/gpui3/elements/editor.rs b/crates/storybook/src/gpui3/elements/editor.rs new file mode 100644 index 0000000000000000000000000000000000000000..77f27d3d1fcdd06dfe4240468f0223124753f5d8 --- /dev/null +++ b/crates/storybook/src/gpui3/elements/editor.rs @@ -0,0 +1,61 @@ +use super::{Element, Handle, Layout, LayoutId, Result, SharedString, ViewContext}; +use std::marker::PhantomData; + +pub fn field(editor: Handle) -> EditorElement { + EditorElement { + editor, + field: true, + placeholder_text: None, + parent_state: PhantomData, + } +} + +pub struct EditorElement { + editor: Handle, + field: bool, + placeholder_text: Option, + parent_state: PhantomData, +} + +impl EditorElement { + pub fn field(mut self) -> Self { + self.field = true; + self + } + + pub fn placeholder_text(mut self, text: impl Into) -> Self { + self.placeholder_text = Some(text.into()); + self + } +} + +impl Element for EditorElement { + type State = S; + type FrameState = (); + + fn layout( + &mut self, + _: &mut Self::State, + cx: &mut ViewContext, + ) -> Result<(LayoutId, Self::FrameState)> { + self.editor.update(cx, |editor, cx| todo!()) + } + + fn paint( + &mut self, + layout: Layout, + state: &mut Self::State, + frame_state: &mut Self::FrameState, + cx: &mut ViewContext, + ) -> Result<()> { + self.editor.update(cx, |editor, cx| todo!()) + } +} + +pub struct Editor {} + +impl Editor { + pub fn new(_: &mut ViewContext) -> Self { + Editor {} + } +} diff --git a/crates/storybook/src/gpui3/mod.rs b/crates/storybook/src/gpui3/mod.rs index 3813b200cbe6345119ed4b69f70b6be6742dd9f9..cbe23ca355484c7ce3120992e394573cf79d9bb5 100644 --- a/crates/storybook/src/gpui3/mod.rs +++ b/crates/storybook/src/gpui3/mod.rs @@ -9,7 +9,6 @@ mod window; use anyhow::Result; pub use gpui2::ArcCow; use gpui2::Reference; -use std::marker::PhantomData; pub use app::*; pub use element::*; @@ -19,6 +18,8 @@ pub use style::*; use taffy::TaffyLayoutEngine; pub use window::*; +use self::editor::Editor; + pub trait Context { type EntityContext<'a, 'w, T: 'static>; @@ -56,7 +57,7 @@ fn workspace(cx: &mut WindowContext) -> View { } struct CollabPanel { - filter_editor: Handle, + filter_editor: Handle, } fn collab_panel(cx: &mut WindowContext) -> View { @@ -76,65 +77,6 @@ impl CollabPanel { } } -fn field(editor: Handle) -> EditorElement { - EditorElement { - editor, - field: true, - placeholder_text: None, - parent_state: PhantomData, - } -} - -struct EditorElement { - editor: Handle, - field: bool, - placeholder_text: Option, - parent_state: PhantomData, -} - -impl EditorElement { - pub fn field(mut self) -> Self { - self.field = true; - self - } - - pub fn placeholder_text(mut self, text: impl Into) -> Self { - self.placeholder_text = Some(text.into()); - self - } -} - -impl Element for EditorElement { - type State = S; - type FrameState = (); - - fn layout( - &mut self, - _: &mut Self::State, - cx: &mut ViewContext, - ) -> Result<(LayoutId, Self::FrameState)> { - self.editor.update(cx, |editor, cx| todo!()) - } - - fn paint( - &mut self, - layout: Layout, - state: &mut Self::State, - frame_state: &mut Self::FrameState, - cx: &mut ViewContext, - ) -> Result<()> { - self.editor.update(cx, |editor, cx| todo!()) - } -} - -struct Editor {} - -impl Editor { - pub fn new(_: &mut ViewContext) -> Self { - Editor {} - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/storybook/src/gpui3/taffy.rs b/crates/storybook/src/gpui3/taffy.rs index 7405b0161ab25a2a38815af4b6492176d89804f8..9fe8adefe7997193cad8f21610d0bd6cedb1e193 100644 --- a/crates/storybook/src/gpui3/taffy.rs +++ b/crates/storybook/src/gpui3/taffy.rs @@ -1,8 +1,7 @@ use super::{ AbsoluteLength, Bounds, DefiniteLength, Edges, Layout, LayoutEngine, LayoutId, Length, Pixels, - Point, Size, Style, + Point, Result, Size, Style, }; -use anyhow::Result; use gpui2::taffy::{self, Taffy}; use std::fmt::Debug;