WIP

Nathan Sobo created

Change summary

crates/gpui/playground/docs/thoughts.md                      | 33 ++++++
crates/gpui/playground/src/hoverable.rs                      |  7 
crates/gpui/src/platform/event.rs                            |  7 
crates/refineable/derive_refineable/src/derive_refineable.rs |  2 
4 files changed, 41 insertions(+), 8 deletions(-)

Detailed changes

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]>,
+}
+
+
+```

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();
                 }

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),
         }
     }
 }