diff --git a/crates/storybook/src/gpui3/app.rs b/crates/storybook/src/gpui3/app.rs index 13bd484127db2183260a0463e1a13cb1cbad1950..7506395f7a40c441d4f309dd97fa1ab0d34fe4b6 100644 --- a/crates/storybook/src/gpui3/app.rs +++ b/crates/storybook/src/gpui3/app.rs @@ -3,7 +3,7 @@ use std::{any::Any, collections::HashMap, marker::PhantomData}; use super::{ window::{Window, WindowHandle, WindowId}, - Context, EntityId, LayoutId, Reference, View, WindowContext, + Context, LayoutId, Reference, View, WindowContext, }; pub struct AppContext { @@ -135,6 +135,17 @@ pub struct Handle { pub(crate) entity_type: PhantomData, } +#[derive(Clone, Copy, Eq, PartialEq, Hash)] +pub struct EntityId(usize); + +impl EntityId { + pub fn new(entity_count: &mut usize) -> EntityId { + let id = *entity_count; + *entity_count += 1; + Self(id) + } +} + impl Handle { fn new(id: EntityId) -> Self { Self { diff --git a/crates/storybook/src/gpui3/elements.rs b/crates/storybook/src/gpui3/elements.rs new file mode 100644 index 0000000000000000000000000000000000000000..9bd9727f21b8af9340c9aad745a2de0ac2b8069b --- /dev/null +++ b/crates/storybook/src/gpui3/elements.rs @@ -0,0 +1,40 @@ +use std::marker::PhantomData; + +use anyhow::Result; + +use super::{Element, IntoAnyElement, Layout, LayoutId, ParentElement, 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/mod.rs b/crates/storybook/src/gpui3/mod.rs index 369012653279226eaf2f3dbdbbd1a8257ccdb42f..3813b200cbe6345119ed4b69f70b6be6742dd9f9 100644 --- a/crates/storybook/src/gpui3/mod.rs +++ b/crates/storybook/src/gpui3/mod.rs @@ -1,5 +1,6 @@ mod app; mod element; +mod elements; mod geometry; mod style; mod taffy; @@ -12,22 +13,12 @@ use std::marker::PhantomData; pub use app::*; pub use element::*; +pub use elements::*; pub use geometry::*; pub use style::*; use taffy::TaffyLayoutEngine; pub use window::*; -#[derive(Clone, Copy, Eq, PartialEq, Hash)] -pub struct EntityId(usize); - -impl EntityId { - fn new(entity_count: &mut usize) -> EntityId { - let id = *entity_count; - *entity_count += 1; - Self(id) - } -} - pub trait Context { type EntityContext<'a, 'w, T: 'static>; @@ -43,41 +34,6 @@ pub trait Context { ) -> R; } -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!() -} - pub struct SharedString(ArcCow<'static, str>); impl>> From for SharedString {