Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use `InteractiveBounds` everywhere we change the cursor style
Antonio Scandurra5781cf6604fe
diff --git a/crates/editor2/src/element.rs b/crates/editor2/src/element.rsindex 7fc5244b927..8031bc5db60 100644--- a/crates/editor2/src/element.rs+++ b/crates/editor2/src/element.rs@@ -884,7 +884,11 @@ impl EditorElement {bounds: text_bounds,}),|cx| {- if text_bounds.contains(&cx.mouse_position()) {+ let interactive_text_bounds = InteractiveBounds {+ bounds: text_bounds,+ stacking_order: cx.stacking_order().clone(),+ };+ if interactive_text_bounds.visibly_contains(&cx.mouse_position(), cx) {if self.editor.read(cx)@@ -1361,8 +1365,12 @@ impl EditorElement {));}+ let interactive_track_bounds = InteractiveBounds {+ bounds: track_bounds,+ stacking_order: cx.stacking_order().clone(),+ };let mut mouse_position = cx.mouse_position();- if track_bounds.contains(&mouse_position) {+ if interactive_track_bounds.visibly_contains(&mouse_position, cx) {cx.set_cursor_style(CursorStyle::Arrow);}@@ -1392,7 +1400,7 @@ impl EditorElement {cx.stop_propagation();} else {editor.scroll_manager.set_is_dragging_scrollbar(false, cx);- if track_bounds.contains(&event.position) {+ if interactive_track_bounds.visibly_contains(&event.position, cx) {editor.scroll_manager.show_scrollbar(cx);}}diff --git a/crates/gpui2/src/elements/text.rs b/crates/gpui2/src/elements/text.rsindex 175a79c19a5..7716d815361 100644--- a/crates/gpui2/src/elements/text.rs+++ b/crates/gpui2/src/elements/text.rs@@ -358,14 +358,13 @@ impl Element for InteractiveText {fn paint(&mut self, bounds: Bounds<Pixels>, state: &mut Self::State, cx: &mut WindowContext) {if let Some(click_listener) = self.click_listener.take() {- if let Some(ix) = state- .text_state- .index_for_position(bounds, cx.mouse_position())- {+ let mouse_position = cx.mouse_position();+ if let Some(ix) = state.text_state.index_for_position(bounds, mouse_position) {if self.clickable_ranges.iter().any(|range| range.contains(&ix))+ && cx.was_top_layer(&mouse_position, cx.stacking_order()){cx.set_cursor_style(crate::CursorStyle::PointingHand)}diff --git a/crates/workspace2/src/pane_group.rs b/crates/workspace2/src/pane_group.rsindex 7416b72331b..06bd506e56e 100644--- a/crates/workspace2/src/pane_group.rs+++ b/crates/workspace2/src/pane_group.rs@@ -564,9 +564,9 @@ mod element {use std::{cell::RefCell, iter, rc::Rc, sync::Arc};use gpui::{- px, relative, Along, AnyElement, Axis, Bounds, CursorStyle, Element, IntoElement,- MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point, Size, Style,- WindowContext,+ px, relative, Along, AnyElement, Axis, Bounds, CursorStyle, Element, InteractiveBounds,+ IntoElement, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point,+ Size, Style, WindowContext,};use parking_lot::Mutex;use smallvec::SmallVec;@@ -717,7 +717,11 @@ mod element {};cx.with_z_index(3, |cx| {- if handle_bounds.contains(&cx.mouse_position()) {+ let interactive_handle_bounds = InteractiveBounds {+ bounds: handle_bounds,+ stacking_order: cx.stacking_order().clone(),+ };+ if interactive_handle_bounds.visibly_contains(&cx.mouse_position(), cx) {cx.set_cursor_style(match axis {Axis::Vertical => CursorStyle::ResizeUpDown,Axis::Horizontal => CursorStyle::ResizeLeftRight,