Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Checkpoint
Nathan Soboe4f8fe941ee8
diff --git a/crates/storybook/src/gpui3/app.rs b/crates/storybook/src/gpui3/app.rsindex 13bd484127d..7506395f7a4 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<T> {pub(crate) entity_type: PhantomData<T>,}+#[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<T: 'static> Handle<T> {fn new(id: EntityId) -> Self {Self {diff --git a/crates/storybook/src/gpui3/elements.rs b/crates/storybook/src/gpui3/elements.rsnew file mode 100644index 00000000000..9bd9727f21b--- /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<S>(PhantomData<S>);++impl<S: 'static> Element for Div<S> {+ type State = S;+ type FrameState = ();++ fn layout(+ &mut self,+ state: &mut Self::State,+ cx: &mut ViewContext<Self::State>,+ ) -> Result<(LayoutId, Self::FrameState)> {+ todo!()+ }++ fn paint(+ &mut self,+ layout: Layout,+ state: &mut Self::State,+ frame_state: &mut Self::FrameState,+ cx: &mut ViewContext<Self::State>,+ ) -> Result<()> {+ todo!()+ }+}++impl<S> ParentElement<S> for Div<S> {+ fn child(self, child: impl IntoAnyElement<S>) -> Self {+ todo!()+ }+}++pub fn div<S>() -> Div<S> {+ todo!()+}diff --git a/crates/storybook/src/gpui3/mod.rs b/crates/storybook/src/gpui3/mod.rsindex 36901265327..3813b200cbe 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<S>(PhantomData<S>);--impl<S: 'static> Element for Div<S> {- type State = S;- type FrameState = ();-- fn layout(- &mut self,- state: &mut Self::State,- cx: &mut ViewContext<Self::State>,- ) -> Result<(LayoutId, Self::FrameState)> {- todo!()- }-- fn paint(- &mut self,- layout: Layout,- state: &mut Self::State,- frame_state: &mut Self::FrameState,- cx: &mut ViewContext<Self::State>,- ) -> Result<()> {- todo!()- }-}--impl<S> ParentElement<S> for Div<S> {- fn child(self, child: impl IntoAnyElement<S>) -> Self {- todo!()- }-}--pub fn div<S>() -> Div<S> {- todo!()-}-pub struct SharedString(ArcCow<'static, str>);impl<T: Into<ArcCow<'static, str>>> From<T> for SharedString {