Removed EventHandler from workspace in favor of mouse event handler

This commit is contained in:
K Simmons 2022-08-22 16:49:14 -07:00
parent 0f43ef9331
commit e44536344a
4 changed files with 13 additions and 10 deletions

View file

@ -44,6 +44,11 @@ impl MouseEventHandler {
self self
} }
pub fn capture_all(mut self) -> Self {
self.handlers = HandlerSet::capture_all();
self
}
pub fn on_move( pub fn on_move(
mut self, mut self,
handler: impl Fn(MoveRegionEvent, &mut EventContext) + 'static, handler: impl Fn(MoveRegionEvent, &mut EventContext) + 'static,

View file

@ -79,7 +79,6 @@ impl Presenter {
self.rendered_views.remove(view_id); self.rendered_views.remove(view_id);
} }
for view_id in &invalidation.updated { for view_id in &invalidation.updated {
dbg!(view_id);
self.rendered_views.insert( self.rendered_views.insert(
*view_id, *view_id,
cx.render_view(RenderParams { cx.render_view(RenderParams {
@ -152,7 +151,6 @@ impl Presenter {
if cx.window_is_active(self.window_id) { if cx.window_is_active(self.window_id) {
if let Some(event) = self.last_mouse_moved_event.clone() { if let Some(event) = self.last_mouse_moved_event.clone() {
println!("Redispatching mouse moved");
self.dispatch_event(event, true, cx); self.dispatch_event(event, true, cx);
} }
} }

View file

@ -46,7 +46,7 @@ impl MouseRegion {
view_id, view_id,
discriminant, discriminant,
bounds, bounds,
handlers: HandlerSet::handle_all(), handlers: HandlerSet::capture_all(),
} }
} }
@ -129,7 +129,7 @@ pub struct HandlerSet {
} }
impl HandlerSet { impl HandlerSet {
pub fn handle_all() -> Self { pub fn capture_all() -> Self {
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
let mut set: HashMap< let mut set: HashMap<
(Discriminant<MouseRegionEvent>, Option<MouseButton>), (Discriminant<MouseRegionEvent>, Option<MouseButton>),

View file

@ -2071,11 +2071,11 @@ impl Workspace {
} }
} }
fn render_disconnected_overlay(&self, cx: &AppContext) -> Option<ElementBox> { fn render_disconnected_overlay(&self, cx: &mut RenderContext<Workspace>) -> Option<ElementBox> {
if self.project.read(cx).is_read_only() { if self.project.read(cx).is_read_only() {
let theme = &cx.global::<Settings>().theme;
Some( Some(
EventHandler::new( MouseEventHandler::new::<Workspace, _, _>(0, cx, |_, cx| {
let theme = &cx.global::<Settings>().theme;
Label::new( Label::new(
"Your connection to the remote project has been lost.".to_string(), "Your connection to the remote project has been lost.".to_string(),
theme.workspace.disconnected_overlay.text.clone(), theme.workspace.disconnected_overlay.text.clone(),
@ -2083,9 +2083,9 @@ impl Workspace {
.aligned() .aligned()
.contained() .contained()
.with_style(theme.workspace.disconnected_overlay.container) .with_style(theme.workspace.disconnected_overlay.container)
.boxed(), .boxed()
) })
.capture_all::<Self>(0) .capture_all()
.boxed(), .boxed(),
) )
} else { } else {