Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP
Nathan Soboeec39dc23ccb
diff --git a/crates/gpui/playground/docs/thoughts.md b/crates/gpui/playground/docs/thoughts.mdnew file mode 100644index 00000000000..147d8bdc81a--- /dev/null+++ b/crates/gpui/playground/docs/thoughts.md@@ -0,0 +1,33 @@+```rs+#[derive(Styled, Interactive)]+pub struct Div {+ declared_style: StyleRefinement,+ interactions: Interactions+}++pub trait Styled {+ fn declared_style(&mut self) -> &mut StyleRefinement;+ fn compute_style(&mut self) -> Style {+ Style::default().refine(self.declared_style())+ }++ // All the tailwind classes, modifying self.declared_style()+}++impl Style {+ pub fn paint_background<V>(layout: Layout, cx: &mut PaintContext<V>);+ pub fn paint_foreground<V>(layout: Layout, cx: &mut PaintContext<V>);+}++pub trait Interactive<V> {+ fn interactions(&mut self) -> &mut Interactions<V>;++ fn on_click(self, )+}++struct Interactions<V> {+ click: SmallVec<[<Rc<dyn Fn(&mut V, &dyn Any, )>; 1]>,+}+++```diff --git a/crates/gpui/playground/src/hoverable.rs b/crates/gpui/playground/src/hoverable.rsindex b09e1079f5d..d703ecbdf8d 100644--- a/crates/gpui/playground/src/hoverable.rs+++ b/crates/gpui/playground/src/hoverable.rs@@ -2,7 +2,7 @@ use std::{cell::Cell, marker::PhantomData, rc::Rc};use gpui::{geometry::{rect::RectF, vector::Vector2F},- scene::MouseMove,+ platform::MouseMovedEvent,EngineLayout, ViewContext,};use refineable::Refineable;@@ -40,6 +40,8 @@ impl<V: 'static, E: Element<V>> Element<V> for Hoverable<V, E> {}fn computed_style(&mut self, cx: &mut ViewContext<V>) -> &StyleRefinement {+ dbg!(self.computed_style.is_some());+self.computed_style.get_or_insert_with(|| {let mut style = self.child.computed_style(cx).clone();if self.hovered.get() {@@ -83,9 +85,10 @@ impl<V: 'static, E: Element<V>> Element<V> for Hoverable<V, E> {order,window_bounds,false,- move |view, event: &MouseMove, cx| {+ move |view, event: &MouseMovedEvent, cx| {let mouse_within_bounds = bounds.contains_point(cx.mouse_position());if mouse_within_bounds != hovered.get() {+ dbg!("hovered", mouse_within_bounds);hovered.set(mouse_within_bounds);cx.repaint();}diff --git a/crates/gpui/src/platform/event.rs b/crates/gpui/src/platform/event.rsindex bb76bb995e1..07d730172ef 100644--- a/crates/gpui/src/platform/event.rs+++ b/crates/gpui/src/platform/event.rs@@ -228,10 +228,9 @@ impl Event {Event::ModifiersChanged { .. } => None,Event::MouseDown(event) => Some(event),Event::MouseUp(event) => Some(event),- _ => None,- // Event::MouseMoved(event) => Some(event),- // Event::MouseExited(event) => Some(event),- // Event::ScrollWheel(event) => Some(event),+ Event::MouseMoved(event) => Some(event),+ Event::MouseExited(event) => Some(event),+ Event::ScrollWheel(event) => Some(event),}}}diff --git a/crates/refineable/derive_refineable/src/derive_refineable.rs b/crates/refineable/derive_refineable/src/derive_refineable.rsindex 939726fc8f5..b5ba4124820 100644--- a/crates/refineable/derive_refineable/src/derive_refineable.rs+++ b/crates/refineable/derive_refineable/src/derive_refineable.rs@@ -147,8 +147,6 @@ pub fn derive_refineable(input: TokenStream) -> TokenStream {}};- println!("{}", gen);-gen.into()}