use gpui::{platform::MouseMovedEvent, EventContext}; use smallvec::SmallVec; use std::rc::Rc; pub trait Interactive { fn interaction_handlers(&mut self) -> &mut InteractionHandlers; fn on_mouse_move(mut self, handler: H) -> Self where H: 'static + Fn(&mut V, &MouseMovedEvent, bool, &mut EventContext), Self: Sized, { self.interaction_handlers() .mouse_moved .push(Rc::new(move |view, event, hit_test, cx| { handler(view, event, hit_test, cx); cx.bubble })); self } } pub struct InteractionHandlers { mouse_moved: SmallVec<[Rc) -> bool>; 2]>, } impl Default for InteractionHandlers { fn default() -> Self { Self { mouse_moved: Default::default(), } } }