gpui: Keep drag cursor style when dragging (#24797)

Release Notes:

- Improve to keep drag cursor style on dragging resize handles.

---

### Before


https://github.com/user-attachments/assets/d4100d01-ac02-42b8-b923-9f2b4633c458

### After


https://github.com/user-attachments/assets/b5a450cd-c6de-4b39-a79c-2d73fcbad209

With example:

```
cargo run -p gpui --example drag_drop
```


https://github.com/user-attachments/assets/4cba1966-1578-40ce-a435-64ec11bcace5
This commit is contained in:
Jason Lee
2025-04-10 23:54:12 +00:00
committed by GitHub
parent a2a3d1a4bd
commit fd256d159d
4 changed files with 153 additions and 5 deletions
+8 -1
View File
@@ -1615,7 +1615,11 @@ impl Interactivity {
global_id, hitbox, &style, window, cx,
);
if !cx.has_active_drag() {
if let Some(drag) = cx.active_drag.as_ref() {
if let Some(mouse_cursor) = drag.cursor_style {
window.set_cursor_style(mouse_cursor, None);
}
} else {
if let Some(mouse_cursor) = style.mouse_cursor {
window.set_cursor_style(mouse_cursor, Some(hitbox));
}
@@ -1838,6 +1842,7 @@ impl Interactivity {
}
});
}
let drag_cursor_style = self.base_style.as_ref().mouse_cursor;
let mut drag_listener = mem::take(&mut self.drag_listener);
let drop_listeners = mem::take(&mut self.drop_listeners);
@@ -1929,6 +1934,7 @@ impl Interactivity {
view: drag,
value: drag_value,
cursor_offset,
cursor_style: drag_cursor_style,
});
pending_mouse_down.take();
window.refresh();
@@ -2269,6 +2275,7 @@ impl Interactivity {
}
}
style.mouse_cursor = drag.cursor_style;
cx.active_drag = Some(drag);
}
}