gpui: Add API for read and write active drag cursor style (#32028)
Prep for https://github.com/zed-industries/zed/pull/32040 Currently, there’s no way to modify the cursor style of the active drag state after dragging begins. However, there are scenarios where we might want to change the cursor style, such as pressing a modifier key while dragging. This PR introduces an API to update and read the current active drag state cursor. Release Notes: - N/A
This commit is contained in:
parent
55120c4231
commit
10df7b5eb9
1 changed files with 20 additions and 0 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue