Add event based drag API to GPUI, continue binding mouse handlers to terminal

This commit is contained in:
Mikayla 2023-12-05 12:07:17 -08:00
parent 8d57d6ca6f
commit ab140ee4c2
No known key found for this signature in database
9 changed files with 295 additions and 224 deletions

View file

@ -1159,12 +1159,15 @@ impl<'a> WindowContext<'a> {
});
if let Some(active_drag) = self.app.active_drag.take() {
self.with_z_index(1, |cx| {
let offset = cx.mouse_position() - active_drag.cursor_offset;
let available_space = size(AvailableSpace::MinContent, AvailableSpace::MinContent);
active_drag.view.draw(offset, available_space, cx);
cx.active_drag = Some(active_drag);
});
if let Some(active_drag) = active_drag.any_drag() {
self.with_z_index(1, |cx| {
let offset = cx.mouse_position() - active_drag.cursor_offset;
let available_space =
size(AvailableSpace::MinContent, AvailableSpace::MinContent);
active_drag.view.draw(offset, available_space, cx);
});
}
self.active_drag = Some(active_drag);
} else if let Some(active_tooltip) = self.app.active_tooltip.take() {
self.with_z_index(1, |cx| {
let available_space = size(AvailableSpace::MinContent, AvailableSpace::MinContent);
@ -1240,10 +1243,10 @@ impl<'a> WindowContext<'a> {
FileDropEvent::Entered { position, files } => {
self.window.mouse_position = position;
if self.active_drag.is_none() {
self.active_drag = Some(AnyDrag {
self.active_drag = Some(crate::AnyDragState::AnyDrag(AnyDrag {
view: self.build_view(|_| files).into(),
cursor_offset: position,
});
}));
}
InputEvent::MouseDown(MouseDownEvent {
position,