From 4c63c74f920d11cff2ecefabd9e09fb001d076d1 Mon Sep 17 00:00:00 2001 From: Mikayla Date: Thu, 14 Dec 2023 15:23:24 -0800 Subject: [PATCH 1/2] Fix bug in drag move dispatch co-authored-by: conrad --- crates/gpui2/src/elements/div.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rs index 395afdcc88..1019e5f5e6 100644 --- a/crates/gpui2/src/elements/div.rs +++ b/crates/gpui2/src/elements/div.rs @@ -213,7 +213,7 @@ pub trait InteractiveElement: Sized { listener: impl Fn(&DragMoveEvent, &mut WindowContext) + 'static, ) -> Self where - T: Render, + T: 'static, { self.interactivity().mouse_move_listeners.push(Box::new( move |event, bounds, phase, cx| { @@ -223,7 +223,7 @@ pub trait InteractiveElement: Sized { if cx .active_drag .as_ref() - .is_some_and(|drag| drag.value.type_id() == TypeId::of::()) + .is_some_and(|drag| (*drag.value).type_id() == TypeId::of::()) { (listener)( &DragMoveEvent { From 8b4cf383798fd288f2e0c189b0f3af69b50775e3 Mon Sep 17 00:00:00 2001 From: Mikayla Date: Thu, 14 Dec 2023 15:53:06 -0800 Subject: [PATCH 2/2] Fix dock resize handles co-authored-by: conrad --- crates/gpui2/src/elements/canvas.rs | 8 +++--- crates/workspace2/src/dock.rs | 39 ++++++++++++++++++----------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/crates/gpui2/src/elements/canvas.rs b/crates/gpui2/src/elements/canvas.rs index b3afd335d4..6a7d68e831 100644 --- a/crates/gpui2/src/elements/canvas.rs +++ b/crates/gpui2/src/elements/canvas.rs @@ -27,7 +27,7 @@ impl IntoElement for Canvas { } impl Element for Canvas { - type State = (); + type State = Style; fn layout( &mut self, @@ -37,11 +37,11 @@ impl Element for Canvas { let mut style = Style::default(); style.refine(&self.style); let layout_id = cx.request_layout(&style, []); - (layout_id, ()) + (layout_id, style) } - fn paint(self, bounds: Bounds, _: &mut (), cx: &mut WindowContext) { - (self.paint_callback)(&bounds, cx) + fn paint(self, bounds: Bounds, style: &mut Style, cx: &mut WindowContext) { + style.paint(bounds, cx, |cx| (self.paint_callback)(&bounds, cx)); } } diff --git a/crates/workspace2/src/dock.rs b/crates/workspace2/src/dock.rs index 54480f0b68..f76bb82177 100644 --- a/crates/workspace2/src/dock.rs +++ b/crates/workspace2/src/dock.rs @@ -486,12 +486,9 @@ impl Render for Dock { if let Some(entry) = self.visible_entry() { let size = entry.panel.size(cx); - let mut pre_resize_handle = None; - let mut post_resize_handle = None; let position = self.position; - let handler = div() + let mut handle = div() .id("resize-handle") - .bg(cx.theme().colors().border) .on_drag(DraggedDock(position), |dock, cx| { cx.build_view(|_| dock.clone()) }) @@ -506,16 +503,31 @@ impl Render for Dock { match self.position() { DockPosition::Left => { - post_resize_handle = - Some(handler.min_w(HANDLE_SIZE).h_full().cursor_col_resize()) + handle = handle + .absolute() + .right(px(0.)) + .top(px(0.)) + .h_full() + .w(HANDLE_SIZE) + .cursor_col_resize(); } DockPosition::Bottom => { - pre_resize_handle = - Some(handler.w_full().min_h(HANDLE_SIZE).cursor_row_resize()) + handle = handle + .absolute() + .top(px(0.)) + .left(px(0.)) + .w_full() + .h(HANDLE_SIZE) + .cursor_row_resize(); } DockPosition::Right => { - pre_resize_handle = - Some(handler.min_w(HANDLE_SIZE).h_full().cursor_col_resize()) + handle = handle + .absolute() + .top(px(0.)) + .left(px(0.)) + .w_full() + .h(HANDLE_SIZE) + .cursor_col_resize(); } } @@ -531,16 +543,15 @@ impl Render for Dock { DockPosition::Right => this.border_l(), DockPosition::Bottom => this.border_t(), }) - .children(pre_resize_handle) .child( div() .map(|this| match self.position().axis() { - Axis::Horizontal => this.min_w(px(size) - HANDLE_SIZE).h_full(), - Axis::Vertical => this.min_h(px(size) - HANDLE_SIZE).w_full(), + Axis::Horizontal => this.min_w(px(size)).h_full(), + Axis::Vertical => this.min_h(px(size)).w_full(), }) .child(entry.panel.to_any()), ) - .children(post_resize_handle) + .child(handle) } else { div() }