fixed merge errors

This commit is contained in:
K Simmons 2022-08-11 12:24:48 -07:00
parent 133c194f4a
commit ab9f073443
3 changed files with 74 additions and 110 deletions

View file

@ -284,15 +284,11 @@ impl Presenter {
{ {
events_to_send.push(( events_to_send.push((
clicked_region.clone(), clicked_region.clone(),
<<<<<<< HEAD
MouseRegionEvent::Drag(*prev_drag_position, *e),
=======
MouseRegionEvent::Drag(DragRegionEvent { MouseRegionEvent::Drag(DragRegionEvent {
region: clicked_region.bounds, region: clicked_region.bounds,
prev_drag_position: *prev_drag_position, prev_drag_position: *prev_drag_position,
platform_event: e.clone(), platform_event: e.clone(),
}), }),
>>>>>>> 4bd8a4b0 (wip tab drag and drop)
)); ));
} }
@ -313,7 +309,7 @@ impl Presenter {
_ => {} _ => {}
} }
let (invalidated_views, dispatch_directives, handled) = { let (invalidated_views, handled) = {
let mut event_cx = self.handle_hover_events(&event, cx); let mut event_cx = self.handle_hover_events(&event, cx);
event_cx.process_region_events(events_to_send); event_cx.process_region_events(events_to_send);
@ -321,25 +317,9 @@ impl Presenter {
event_cx.handled = event_cx.dispatch_event(root_view_id, &event); event_cx.handled = event_cx.dispatch_event(root_view_id, &event);
} }
if let Some(callback) = region.handlers.get(&event.handler_key()) { (event_cx.invalidated_views, event_cx.handled)
event_cx.with_current_view(region.view_id, |event_cx| {
callback(event, event_cx);
})
}
(
event_cx.invalidated_views,
event_cx.dispatched_actions,
event_cx.handled,
)
}; };
if !handled {
handled = event_cx.dispatch_event(root_view_id, &event);
}
invalidated_views.extend(event_cx.invalidated_views);
for view_id in invalidated_views { for view_id in invalidated_views {
cx.notify_view(self.window_id, view_id); cx.notify_view(self.window_id, view_id);
} }
@ -400,23 +380,23 @@ impl Presenter {
} }
} }
} else if let Some(region_id) = region.id() { } else if let Some(region_id) = region.id() {
if self.hovered_region_ids.contains(&region_id) { if self.hovered_region_ids.contains(&region_id) {
let region_event = if pressed_button.is_some() { let region_event = if pressed_button.is_some() {
MouseRegionEvent::DragOver(DragOverRegionEvent { MouseRegionEvent::DragOver(DragOverRegionEvent {
region: region.bounds, region: region.bounds,
started: false, started: false,
platform_event: e.clone(), platform_event: e.clone(),
}) })
} else { } else {
MouseRegionEvent::Hover(HoverRegionEvent { MouseRegionEvent::Hover(HoverRegionEvent {
region: region.bounds, region: region.bounds,
started: false, started: false,
platform_event: e.clone(), platform_event: e.clone(),
}) })
}; };
events_to_send.push((region.clone(), region_event)); events_to_send.push((region.clone(), region_event));
self.hovered_region_ids.remove(&region_id); self.hovered_region_ids.remove(&region_id);
} }
} }
} }
} }

View file

@ -421,75 +421,60 @@ impl TerminalEl {
let drag_connection = self.terminal; let drag_connection = self.terminal;
cx.scene.push_mouse_region( cx.scene.push_mouse_region(
MouseRegion::new(view_id, None, visible_bounds) MouseRegion::new(view_id, None, visible_bounds)
.on_down( .on_down(MouseButton::Left, move |e, cx| {
MouseButton::Left, if let Some(conn_handle) = mouse_down_connection.upgrade(cx.app) {
move |MouseButtonEvent { position, .. }, cx| { conn_handle.update(cx.app, |terminal, cx| {
if let Some(conn_handle) = mouse_down_connection.upgrade(cx.app) { let (point, side) = TerminalEl::mouse_to_cell_data(
conn_handle.update(cx.app, |terminal, cx| { e.position,
let (point, side) = TerminalEl::mouse_to_cell_data( origin,
position, cur_size,
origin, display_offset,
cur_size, );
display_offset,
);
terminal.mouse_down(point, side); terminal.mouse_down(point, side);
cx.notify(); cx.notify();
}) })
} }
}, })
) .on_click(MouseButton::Left, move |e, cx| {
.on_click( cx.focus_parent_view();
MouseButton::Left, if let Some(conn_handle) = click_connection.upgrade(cx.app) {
move |MouseButtonEvent { conn_handle.update(cx.app, |terminal, cx| {
position, let (point, side) = TerminalEl::mouse_to_cell_data(
click_count, e.position,
.. origin,
}, cur_size,
cx| { display_offset,
cx.focus_parent_view(); );
if let Some(conn_handle) = click_connection.upgrade(cx.app) {
conn_handle.update(cx.app, |terminal, cx| {
let (point, side) = TerminalEl::mouse_to_cell_data(
position,
origin,
cur_size,
display_offset,
);
terminal.click(point, side, click_count); terminal.click(point, side, e.click_count);
cx.notify(); cx.notify();
}); });
} }
}, })
) .on_click(MouseButton::Right, move |e, cx| {
.on_click( cx.dispatch_action(DeployContextMenu {
MouseButton::Right, position: e.position,
move |MouseButtonEvent { position, .. }, cx| { });
cx.dispatch_action(DeployContextMenu { position }); })
}, .on_drag(MouseButton::Left, move |e, cx| {
) if let Some(conn_handle) = drag_connection.upgrade(cx.app) {
.on_drag( conn_handle.update(cx.app, |terminal, cx| {
MouseButton::Left, let (point, side) = TerminalEl::mouse_to_cell_data(
move |_, MouseMovedEvent { position, .. }, cx| { e.position,
if let Some(conn_handle) = drag_connection.upgrade(cx.app) { origin,
conn_handle.update(cx.app, |terminal, cx| { cur_size,
let (point, side) = TerminalEl::mouse_to_cell_data( display_offset,
position, );
origin,
cur_size,
display_offset,
);
terminal.drag(point, side); terminal.drag(point, side);
cx.notify() cx.notify()
}); });
} }
}, }),
),
); );
} }

View file

@ -14,8 +14,8 @@ use gpui::{
impl_actions, impl_internal_actions, impl_actions, impl_internal_actions,
platform::{CursorStyle, NavigationDirection}, platform::{CursorStyle, NavigationDirection},
AnyViewHandle, AnyWeakViewHandle, AppContext, AsyncAppContext, Entity, EventContext, AnyViewHandle, AnyWeakViewHandle, AppContext, AsyncAppContext, Entity, EventContext,
ModelHandle, MouseButton, MouseButtonEvent, MutableAppContext, PromptLevel, Quad, ModelHandle, MouseButton, MutableAppContext, PromptLevel, Quad, RenderContext, Task, View,
RenderContext, Task, View, ViewContext, ViewHandle, WeakViewHandle, ViewContext, ViewHandle, WeakViewHandle,
}; };
use project::{Project, ProjectEntryId, ProjectPath}; use project::{Project, ProjectEntryId, ProjectPath};
use serde::Deserialize; use serde::Deserialize;
@ -1143,12 +1143,11 @@ impl View for Pane {
}, },
) )
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_down( .on_down(MouseButton::Left, |e, cx| {
MouseButton::Left, cx.dispatch_action(DeployNewMenu {
|MouseButtonEvent { position, .. }, cx| { position: e.position,
cx.dispatch_action(DeployNewMenu { position }); });
}, })
)
.boxed(), .boxed(),
MouseEventHandler::new::<SplitIcon, _, _>( MouseEventHandler::new::<SplitIcon, _, _>(
1, 1,