Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP
Nathan Sobofea987b459b8
diff --git a/crates/gpui/playground/src/adapter.rs b/crates/gpui/playground/src/adapter.rsindex e9f279346f7..b66a176231d 100644--- a/crates/gpui/playground/src/adapter.rs+++ b/crates/gpui/playground/src/adapter.rs@@ -14,19 +14,16 @@ impl<V: 'static> gpui::Element<V> for Adapter<V> {&mut self,constraint: gpui::SizeConstraint,view: &mut V,- legacy_cx: &mut gpui::LayoutContext<V>,+ cx: &mut LayoutContext<V>,) -> (gpui::geometry::vector::Vector2F, Self::LayoutState) {- legacy_cx.push_layout_engine(LayoutEngine::new());- let node = self- .0- .layout(view, &mut LayoutContext { legacy_cx })- .log_err();+ cx.push_layout_engine(LayoutEngine::new());+ let node = self.0.layout(view, cx).log_err();if let Some(node) = node {- let layout_engine = legacy_cx.layout_engine().unwrap();+ let layout_engine = cx.layout_engine().unwrap();layout_engine.compute_layout(node, constraint.max).log_err();}- let layout_engine = legacy_cx.pop_layout_engine();+ let layout_engine = cx.pop_layout_engine();debug_assert!(layout_engine.is_some());(constraint.max, layout_engine)}diff --git a/crates/gpui/playground/src/element.rs b/crates/gpui/playground/src/element.rsindex b81df22a4bd..26fef21a217 100644--- a/crates/gpui/playground/src/element.rs+++ b/crates/gpui/playground/src/element.rs@@ -1,24 +1,19 @@-use std::{any::Any, rc::Rc};-use crate::{adapter::Adapter,style::{Display, ElementStyle, Fill, Overflow, Position},};use anyhow::Result;use derive_more::{Deref, DerefMut};+pub use gpui::LayoutContext;use gpui::{geometry::{DefinedLength, Length},scene::MouseClick,- EngineLayout, LayoutContext as LegacyLayoutContext, PaintContext as LegacyPaintContext,+ EngineLayout, PaintContext as LegacyPaintContext,};use playground_macros::tailwind_lengths;+use std::{any::Any, rc::Rc};pub use taffy::tree::NodeId;-#[derive(Deref, DerefMut)]-pub struct LayoutContext<'a, 'b, 'c, 'd, V> {- pub(crate) legacy_cx: &'d mut LegacyLayoutContext<'a, 'b, 'c, V>,-}-#[derive(Deref, DerefMut)]pub struct PaintContext<'a, 'b, 'c, 'd, V> {#[deref]@@ -355,12 +350,9 @@ impl<V: 'static, E: Element<V>> ElementObject<V> for E {self.paint(layout, view, cx)}-- // fn clone_object(&self) -> Box<dyn ElementObject<V>> {- // Box::new(Clone::clone(self))- // }}+/// A dynamically typed element.pub struct AnyElement<V> {element: Box<dyn ElementObject<V>>,layout: Option<(NodeId, Box<dyn Any>)>,diff --git a/crates/gpui/playground/src/playground.rs b/crates/gpui/playground/src/playground.rsindex 2c68f6caf6d..7b98ac3026e 100644--- a/crates/gpui/playground/src/playground.rs+++ b/crates/gpui/playground/src/playground.rs@@ -18,6 +18,7 @@ mod components;mod element;mod frame;mod style;+mod text;mod themes;mod view;diff --git a/crates/gpui/playground/src/text.rs b/crates/gpui/playground/src/text.rsnew file mode 100644index 00000000000..561d5506a6f--- /dev/null+++ b/crates/gpui/playground/src/text.rs@@ -0,0 +1,36 @@+use std::borrow::Cow;++use crate::element::Element;++impl<V, S> Element<V> for S+where+ V: 'static,+ S: 'static + Into<Cow<'static, str>>,+{+ type Layout = Cow<'static, str>;++ fn style_mut(&mut self) -> &mut crate::style::ElementStyle {+ todo!()+ }++ fn handlers_mut(&mut self) -> &mut crate::element::ElementHandlers<V> {+ todo!()+ }++ fn layout(+ &mut self,+ view: &mut V,+ cx: &mut crate::element::LayoutContext<V>,+ ) -> anyhow::Result<(taffy::tree::NodeId, Self::Layout)> {+ todo!()+ }++ fn paint<'a>(+ &mut self,+ layout: crate::element::Layout<Self::Layout>,+ view: &mut V,+ cx: &mut crate::element::PaintContext<V>,+ ) -> anyhow::Result<()> {+ todo!()+ }+}