Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add col/row resize cursor styles (#11406)
Soroush Mirzaeida6a6ec36b2a
diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rsindex 6c234c3c34f..cc4f23cff28 100644--- a/crates/gpui/src/platform.rs+++ b/crates/gpui/src/platform.rs@@ -733,7 +733,7 @@ pub enum CursorStyle {ResizeRight,/// A resize cursor to the left and right- /// corresponds to the CSS cursor value `col-resize`+ /// corresponds to the CSS cursor value `ew-resize`ResizeLeftRight,/// A resize up cursor@@ -745,9 +745,17 @@ pub enum CursorStyle {ResizeDown,/// A resize cursor directing up and down- /// corresponds to the CSS cursor value `row-resize`+ /// corresponds to the CSS cursor value `ns-resize`ResizeUpDown,+ /// A cursor indicating that the item/column can be resized horizontally.+ /// corresponds to the CSS curosr value `col-resize`+ ResizeColumn,++ /// A cursor indicating that the item/row can be resized vertically.+ /// corresponds to the CSS curosr value `row-resize`+ ResizeRow,+/// A cursor indicating that something will disappear if moved here/// Does not correspond to a CSS cursor valueDisappearingItem,diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rsindex c1f6df1593b..1b5e739928b 100644--- a/crates/gpui/src/platform/linux/platform.rs+++ b/crates/gpui/src/platform/linux/platform.rs@@ -507,6 +507,8 @@ impl CursorStyle {CursorStyle::ResizeUp => Shape::NResize,CursorStyle::ResizeDown => Shape::SResize,CursorStyle::ResizeUpDown => Shape::NsResize,+ CursorStyle::ResizeColumn => Shape::ColResize,+ CursorStyle::ResizeRow => Shape::RowResize,CursorStyle::DisappearingItem => Shape::Grabbing, // todo(linux) - couldn't find equivalent icon in linuxCursorStyle::IBeamCursorForVerticalLayout => Shape::VerticalText,CursorStyle::OperationNotAllowed => Shape::NotAllowed,@@ -533,6 +535,8 @@ impl CursorStyle {CursorStyle::ResizeUp => "n-resize",CursorStyle::ResizeDown => "s-resize",CursorStyle::ResizeUpDown => "ns-resize",+ CursorStyle::ResizeColumn => "col-resize",+ CursorStyle::ResizeRow => "row-resize",CursorStyle::DisappearingItem => "grabbing", // todo(linux) - couldn't find equivalent icon in linuxCursorStyle::IBeamCursorForVerticalLayout => "vertical-text",CursorStyle::OperationNotAllowed => "not-allowed",diff --git a/crates/gpui/src/platform/mac/platform.rs b/crates/gpui/src/platform/mac/platform.rsindex 32d49cccbd8..b5b220d942a 100644--- a/crates/gpui/src/platform/mac/platform.rs+++ b/crates/gpui/src/platform/mac/platform.rs@@ -781,9 +781,11 @@ impl Platform for MacPlatform {CursorStyle::ResizeLeft => msg_send![class!(NSCursor), resizeLeftCursor],CursorStyle::ResizeRight => msg_send![class!(NSCursor), resizeRightCursor],CursorStyle::ResizeLeftRight => msg_send![class!(NSCursor), resizeLeftRightCursor],+ CursorStyle::ResizeColumn => msg_send![class!(NSCursor), resizeLeftRightCursor],CursorStyle::ResizeUp => msg_send![class!(NSCursor), resizeUpCursor],CursorStyle::ResizeDown => msg_send![class!(NSCursor), resizeDownCursor],CursorStyle::ResizeUpDown => msg_send![class!(NSCursor), resizeUpDownCursor],+ CursorStyle::ResizeRow => msg_send![class!(NSCursor), resizeUpDownCursor],CursorStyle::DisappearingItem => {msg_send![class!(NSCursor), disappearingItemCursor]}diff --git a/crates/gpui/src/styled.rs b/crates/gpui/src/styled.rsindex 9705f4dd13e..c5ddd1f8f84 100644--- a/crates/gpui/src/styled.rs+++ b/crates/gpui/src/styled.rs@@ -176,17 +176,31 @@ pub trait Styled: Sized {self}+ /// Sets cursor style when hovering over an element to `ew-resize`.+ /// [Docs](https://tailwindcss.com/docs/cursor)+ fn cursor_ew_resize(mut self) -> Self {+ self.style().mouse_cursor = Some(CursorStyle::ResizeLeftRight);+ self+ }++ /// Sets cursor style when hovering over an element to `ns-resize`.+ /// [Docs](https://tailwindcss.com/docs/cursor)+ fn cursor_ns_resize(mut self) -> Self {+ self.style().mouse_cursor = Some(CursorStyle::ResizeUpDown);+ self+ }+/// Sets cursor style when hovering over an element to `col-resize`./// [Docs](https://tailwindcss.com/docs/cursor)fn cursor_col_resize(mut self) -> Self {- self.style().mouse_cursor = Some(CursorStyle::ResizeLeftRight);+ self.style().mouse_cursor = Some(CursorStyle::ResizeColumn);self}/// Sets cursor style when hovering over an element to `row-resize`./// [Docs](https://tailwindcss.com/docs/cursor)fn cursor_row_resize(mut self) -> Self {- self.style().mouse_cursor = Some(CursorStyle::ResizeUpDown);+ self.style().mouse_cursor = Some(CursorStyle::ResizeRow);self}diff --git a/crates/workspace/src/pane_group.rs b/crates/workspace/src/pane_group.rsindex 1c9e1ef9f06..1a057bc20aa 100644--- a/crates/workspace/src/pane_group.rs+++ b/crates/workspace/src/pane_group.rs@@ -914,8 +914,8 @@ mod element {for (ix, child) in &mut layout.children.iter_mut().enumerate() {if let Some(handle) = child.handle.as_mut() {let cursor_style = match self.axis {- Axis::Vertical => CursorStyle::ResizeUpDown,- Axis::Horizontal => CursorStyle::ResizeLeftRight,+ Axis::Vertical => CursorStyle::ResizeRow,+ Axis::Horizontal => CursorStyle::ResizeColumn,};cx.set_cursor_style(cursor_style, &handle.hitbox);cx.paint_quad(gpui::fill(