Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

gpui: Add API for read and write active drag cursor style (#32028)

Smit Barmase10df7b5eb904
diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs
index dc9fa0ced34..e6d5fb9e48e 100644
--- a/crates/gpui/src/app.rs
+++ b/crates/gpui/src/app.rs
@@ -1559,6 +1559,11 @@ impl App {
self.active_drag.is_some()
}
+ /// Gets the cursor style of the currently active drag operation.
+ pub fn active_drag_cursor_style(&self) -> Option<CursorStyle> {
+ self.active_drag.as_ref().and_then(|drag| drag.cursor_style)
+ }
+
/// Stops active drag and clears any related effects.
pub fn stop_active_drag(&mut self, window: &mut Window) -> bool {
if self.active_drag.is_some() {
@@ -1570,6 +1575,21 @@ impl App {
}
}
+ /// Sets the cursor style for the currently active drag operation.
+ pub fn set_active_drag_cursor_style(
+ &mut self,
+ cursor_style: CursorStyle,
+ window: &mut Window,
+ ) -> bool {
+ if let Some(ref mut drag) = self.active_drag {
+ drag.cursor_style = Some(cursor_style);
+ window.refresh();
+ true
+ } else {
+ false
+ }
+ }
+
/// Set the prompt renderer for GPUI. This will replace the default or platform specific
/// prompts with this custom implementation.
pub fn set_prompt_builder(