Enable dragging from project panel to panes

Rework gpui2 drag API so that receivers need not specify the dragged view type.

co-authored-by: Max <max@zed.dev>
co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Mikayla 2023-12-14 12:03:17 -08:00 committed by Max Brunsfeld
parent c6e44683e6
commit 8791f7cefc
9 changed files with 190 additions and 100 deletions

View file

@ -2552,12 +2552,11 @@ impl CollabPanel {
.group("") .group("")
.flex() .flex()
.w_full() .w_full()
.on_drag({ .on_drag(channel.clone(), move |channel, cx| {
let channel = channel.clone(); cx.build_view(|cx| DraggedChannelView {
move |cx| { channel: channel.clone(),
let channel = channel.clone(); width,
cx.build_view(|cx| DraggedChannelView { channel, width }) })
}
}) })
.drag_over::<DraggedChannelView>(|style| { .drag_over::<DraggedChannelView>(|style| {
style.bg(cx.theme().colors().ghost_element_hover) style.bg(cx.theme().colors().ghost_element_hover)

View file

@ -1139,8 +1139,10 @@ impl AppContext {
self.active_drag.is_some() self.active_drag.is_some()
} }
pub fn active_drag(&self) -> Option<AnyView> { pub fn active_drag<T: 'static>(&self) -> Option<&T> {
self.active_drag.as_ref().map(|drag| drag.view.clone()) self.active_drag
.as_ref()
.and_then(|drag| drag.value.downcast_ref())
} }
} }
@ -1296,6 +1298,7 @@ impl<G: 'static> DerefMut for GlobalLease<G> {
/// within the window or by dragging into the app from the underlying platform. /// within the window or by dragging into the app from the underlying platform.
pub struct AnyDrag { pub struct AnyDrag {
pub view: AnyView, pub view: AnyView,
pub value: Box<dyn Any>,
pub cursor_offset: Point<Pixels>, pub cursor_offset: Point<Pixels>,
} }

View file

@ -15,6 +15,7 @@ use std::{
cell::RefCell, cell::RefCell,
cmp::Ordering, cmp::Ordering,
fmt::Debug, fmt::Debug,
marker::PhantomData,
mem, mem,
rc::Rc, rc::Rc,
time::Duration, time::Duration,
@ -30,9 +31,18 @@ pub struct GroupStyle {
pub style: Box<StyleRefinement>, pub style: Box<StyleRefinement>,
} }
pub struct DragMoveEvent<W: Render> { pub struct DragMoveEvent<T> {
pub event: MouseMoveEvent, pub event: MouseMoveEvent,
pub drag: View<W>, drag: PhantomData<T>,
}
impl<T: 'static> DragMoveEvent<T> {
pub fn drag<'b>(&self, cx: &'b AppContext) -> &'b T {
cx.active_drag
.as_ref()
.and_then(|drag| drag.value.downcast_ref::<T>())
.expect("DragMoveEvent is only valid when the stored active drag is of the same type.")
}
} }
pub trait InteractiveElement: Sized { pub trait InteractiveElement: Sized {
@ -198,24 +208,27 @@ pub trait InteractiveElement: Sized {
self self
} }
fn on_drag_move<W>( fn on_drag_move<T>(
mut self, mut self,
listener: impl Fn(&DragMoveEvent<W>, &mut WindowContext) + 'static, listener: impl Fn(&DragMoveEvent<T>, &mut WindowContext) + 'static,
) -> Self ) -> Self
where where
W: Render, T: Render,
{ {
self.interactivity().mouse_move_listeners.push(Box::new( self.interactivity().mouse_move_listeners.push(Box::new(
move |event, bounds, phase, cx| { move |event, bounds, phase, cx| {
if phase == DispatchPhase::Capture if phase == DispatchPhase::Capture
&& bounds.drag_target_contains(&event.position, cx) && bounds.drag_target_contains(&event.position, cx)
{ {
if let Some(view) = cx.active_drag().and_then(|view| view.downcast::<W>().ok()) if cx
.active_drag
.as_ref()
.is_some_and(|drag| drag.value.type_id() == TypeId::of::<T>())
{ {
(listener)( (listener)(
&DragMoveEvent { &DragMoveEvent {
event: event.clone(), event: event.clone(),
drag: view, drag: PhantomData,
}, },
cx, cx,
); );
@ -363,14 +376,11 @@ pub trait InteractiveElement: Sized {
self self
} }
fn on_drop<W: 'static>( fn on_drop<T: 'static>(mut self, listener: impl Fn(&T, &mut WindowContext) + 'static) -> Self {
mut self,
listener: impl Fn(&View<W>, &mut WindowContext) + 'static,
) -> Self {
self.interactivity().drop_listeners.push(( self.interactivity().drop_listeners.push((
TypeId::of::<W>(), TypeId::of::<T>(),
Box::new(move |dragged_view, cx| { Box::new(move |dragged_value, cx| {
listener(&dragged_view.downcast().unwrap(), cx); listener(dragged_value.downcast_ref().unwrap(), cx);
}), }),
)); ));
self self
@ -437,19 +447,24 @@ pub trait StatefulInteractiveElement: InteractiveElement {
self self
} }
fn on_drag<W>(mut self, constructor: impl Fn(&mut WindowContext) -> View<W> + 'static) -> Self fn on_drag<T, W>(
mut self,
value: T,
constructor: impl Fn(&T, &mut WindowContext) -> View<W> + 'static,
) -> Self
where where
Self: Sized, Self: Sized,
T: 'static,
W: 'static + Render, W: 'static + Render,
{ {
debug_assert!( debug_assert!(
self.interactivity().drag_listener.is_none(), self.interactivity().drag_listener.is_none(),
"calling on_drag more than once on the same element is not supported" "calling on_drag more than once on the same element is not supported"
); );
self.interactivity().drag_listener = Some(Box::new(move |cursor_offset, cx| AnyDrag { self.interactivity().drag_listener = Some((
view: constructor(cx).into(), Box::new(value),
cursor_offset, Box::new(move |value, cx| constructor(value.downcast_ref().unwrap(), cx).into()),
})); ));
self self
} }
@ -513,9 +528,9 @@ pub type ScrollWheelListener =
pub type ClickListener = Box<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>; pub type ClickListener = Box<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>;
pub type DragListener = Box<dyn Fn(Point<Pixels>, &mut WindowContext) -> AnyDrag + 'static>; pub type DragListener = Box<dyn Fn(&dyn Any, &mut WindowContext) -> AnyView + 'static>;
type DropListener = dyn Fn(AnyView, &mut WindowContext) + 'static; type DropListener = Box<dyn Fn(&dyn Any, &mut WindowContext) + 'static>;
pub type TooltipBuilder = Rc<dyn Fn(&mut WindowContext) -> AnyView + 'static>; pub type TooltipBuilder = Rc<dyn Fn(&mut WindowContext) -> AnyView + 'static>;
@ -712,9 +727,9 @@ pub struct Interactivity {
pub key_down_listeners: Vec<KeyDownListener>, pub key_down_listeners: Vec<KeyDownListener>,
pub key_up_listeners: Vec<KeyUpListener>, pub key_up_listeners: Vec<KeyUpListener>,
pub action_listeners: Vec<(TypeId, ActionListener)>, pub action_listeners: Vec<(TypeId, ActionListener)>,
pub drop_listeners: Vec<(TypeId, Box<DropListener>)>, pub drop_listeners: Vec<(TypeId, DropListener)>,
pub click_listeners: Vec<ClickListener>, pub click_listeners: Vec<ClickListener>,
pub drag_listener: Option<DragListener>, pub drag_listener: Option<(Box<dyn Any>, DragListener)>,
pub hover_listener: Option<Box<dyn Fn(&bool, &mut WindowContext)>>, pub hover_listener: Option<Box<dyn Fn(&bool, &mut WindowContext)>>,
pub tooltip_builder: Option<TooltipBuilder>, pub tooltip_builder: Option<TooltipBuilder>,
@ -998,8 +1013,10 @@ impl Interactivity {
if phase == DispatchPhase::Bubble if phase == DispatchPhase::Bubble
&& interactive_bounds.drag_target_contains(&event.position, cx) && interactive_bounds.drag_target_contains(&event.position, cx)
{ {
if let Some(drag_state_type) = if let Some(drag_state_type) = cx
cx.active_drag.as_ref().map(|drag| drag.view.entity_type()) .active_drag
.as_ref()
.map(|drag| drag.value.as_ref().type_id())
{ {
for (drop_state_type, listener) in &drop_listeners { for (drop_state_type, listener) in &drop_listeners {
if *drop_state_type == drag_state_type { if *drop_state_type == drag_state_type {
@ -1008,7 +1025,7 @@ impl Interactivity {
.take() .take()
.expect("checked for type drag state type above"); .expect("checked for type drag state type above");
listener(drag.view.clone(), cx); listener(drag.value.as_ref(), cx);
cx.notify(); cx.notify();
cx.stop_propagation(); cx.stop_propagation();
} }
@ -1022,13 +1039,13 @@ impl Interactivity {
} }
let click_listeners = mem::take(&mut self.click_listeners); let click_listeners = mem::take(&mut self.click_listeners);
let drag_listener = mem::take(&mut self.drag_listener); let mut drag_listener = mem::take(&mut self.drag_listener);
if !click_listeners.is_empty() || drag_listener.is_some() { if !click_listeners.is_empty() || drag_listener.is_some() {
let pending_mouse_down = element_state.pending_mouse_down.clone(); let pending_mouse_down = element_state.pending_mouse_down.clone();
let mouse_down = pending_mouse_down.borrow().clone(); let mouse_down = pending_mouse_down.borrow().clone();
if let Some(mouse_down) = mouse_down { if let Some(mouse_down) = mouse_down {
if let Some(drag_listener) = drag_listener { if drag_listener.is_some() {
let active_state = element_state.clicked_state.clone(); let active_state = element_state.clicked_state.clone();
let interactive_bounds = interactive_bounds.clone(); let interactive_bounds = interactive_bounds.clone();
@ -1041,10 +1058,18 @@ impl Interactivity {
&& interactive_bounds.visibly_contains(&event.position, cx) && interactive_bounds.visibly_contains(&event.position, cx)
&& (event.position - mouse_down.position).magnitude() > DRAG_THRESHOLD && (event.position - mouse_down.position).magnitude() > DRAG_THRESHOLD
{ {
let (drag_value, drag_listener) = drag_listener
.take()
.expect("The notify below should invalidate this callback");
*active_state.borrow_mut() = ElementClickedState::default(); *active_state.borrow_mut() = ElementClickedState::default();
let cursor_offset = event.position - bounds.origin; let cursor_offset = event.position - bounds.origin;
let drag = drag_listener(cursor_offset, cx); let drag = (drag_listener)(drag_value.as_ref(), cx);
cx.active_drag = Some(drag); cx.active_drag = Some(AnyDrag {
view: drag,
value: drag_value,
cursor_offset,
});
cx.notify(); cx.notify();
cx.stop_propagation(); cx.stop_propagation();
} }
@ -1312,7 +1337,7 @@ impl Interactivity {
if let Some(drag) = cx.active_drag.take() { if let Some(drag) = cx.active_drag.take() {
for (state_type, group_drag_style) in &self.group_drag_over_styles { for (state_type, group_drag_style) in &self.group_drag_over_styles {
if let Some(group_bounds) = GroupBounds::get(&group_drag_style.group, cx) { if let Some(group_bounds) = GroupBounds::get(&group_drag_style.group, cx) {
if *state_type == drag.view.entity_type() if *state_type == drag.value.as_ref().type_id()
&& group_bounds.contains(&mouse_position) && group_bounds.contains(&mouse_position)
{ {
style.refine(&group_drag_style.style); style.refine(&group_drag_style.style);
@ -1321,7 +1346,7 @@ impl Interactivity {
} }
for (state_type, drag_over_style) in &self.drag_over_styles { for (state_type, drag_over_style) in &self.drag_over_styles {
if *state_type == drag.view.entity_type() if *state_type == drag.value.as_ref().type_id()
&& bounds && bounds
.intersect(&cx.content_mask().bounds) .intersect(&cx.content_mask().bounds)
.contains(&mouse_position) .contains(&mouse_position)

View file

@ -806,7 +806,7 @@ impl<'a> WindowContext<'a> {
/// a specific need to register a global listener. /// a specific need to register a global listener.
pub fn on_mouse_event<Event: 'static>( pub fn on_mouse_event<Event: 'static>(
&mut self, &mut self,
handler: impl Fn(&Event, DispatchPhase, &mut WindowContext) + 'static, mut handler: impl FnMut(&Event, DispatchPhase, &mut WindowContext) + 'static,
) { ) {
let order = self.window.next_frame.z_index_stack.clone(); let order = self.window.next_frame.z_index_stack.clone();
self.window self.window
@ -1379,6 +1379,7 @@ impl<'a> WindowContext<'a> {
self.window.mouse_position = position; self.window.mouse_position = position;
if self.active_drag.is_none() { if self.active_drag.is_none() {
self.active_drag = Some(AnyDrag { self.active_drag = Some(AnyDrag {
value: Box::new(files.clone()),
view: self.build_view(|_| files).into(), view: self.build_view(|_| files).into(),
cursor_offset: position, cursor_offset: position,
}); });

View file

@ -1377,33 +1377,28 @@ impl ProjectPanel {
}) })
.unwrap_or(theme.status().info); .unwrap_or(theme.status().info);
let file_name = details.filename.clone();
let icon = details.icon.clone();
let depth = details.depth;
div() div()
.id(entry_id.to_proto() as usize) .id(entry_id.to_proto() as usize)
.on_drag({ .on_drag(entry_id, move |entry_id, cx| {
let details = details.clone(); cx.build_view(|_| DraggedProjectEntryView {
move |cx| { details: details.clone(),
let details = details.clone(); width,
cx.build_view(|_| DraggedProjectEntryView { entry_id: *entry_id,
details, })
width,
entry_id,
})
}
}) })
.drag_over::<DraggedProjectEntryView>(|style| { .drag_over::<ProjectEntryId>(|style| style.bg(cx.theme().colors().ghost_element_hover))
style.bg(cx.theme().colors().ghost_element_hover) .on_drop(cx.listener(move |this, dragged_id: &ProjectEntryId, cx| {
}) this.move_entry(*dragged_id, entry_id, kind.is_file(), cx);
.on_drop(cx.listener( }))
move |this, dragged_view: &View<DraggedProjectEntryView>, cx| {
this.move_entry(dragged_view.read(cx).entry_id, entry_id, kind.is_file(), cx);
},
))
.child( .child(
ListItem::new(entry_id.to_proto() as usize) ListItem::new(entry_id.to_proto() as usize)
.indent_level(details.depth) .indent_level(depth)
.indent_step_size(px(settings.indent_size)) .indent_step_size(px(settings.indent_size))
.selected(is_selected) .selected(is_selected)
.child(if let Some(icon) = &details.icon { .child(if let Some(icon) = &icon {
div().child(IconElement::from_path(icon.to_string())) div().child(IconElement::from_path(icon.to_string()))
} else { } else {
div() div()
@ -1414,7 +1409,7 @@ impl ProjectPanel {
} else { } else {
div() div()
.text_color(filename_text_color) .text_color(filename_text_color)
.child(Label::new(details.filename.clone())) .child(Label::new(file_name))
} }
.ml_1(), .ml_1(),
) )

View file

@ -792,7 +792,6 @@ impl Element for TerminalElement {
.on_drop::<ExternalPaths>(move |external_paths, cx| { .on_drop::<ExternalPaths>(move |external_paths, cx| {
cx.focus(&terminal_focus_handle); cx.focus(&terminal_focus_handle);
let mut new_text = external_paths let mut new_text = external_paths
.read(cx)
.paths() .paths()
.iter() .iter()
.map(|path| format!(" {path:?}")) .map(|path| format!(" {path:?}"))

View file

@ -493,7 +493,9 @@ impl Render for Dock {
let handler = div() let handler = div()
.id("resize-handle") .id("resize-handle")
.bg(cx.theme().colors().border) .bg(cx.theme().colors().border)
.on_drag(move |cx| cx.build_view(|_| DraggedDock(position))) .on_drag(DraggedDock(position), |dock, cx| {
cx.build_view(|_| dock.clone())
})
.on_click(cx.listener(|v, e: &ClickEvent, cx| { .on_click(cx.listener(|v, e: &ClickEvent, cx| {
if e.down.button == MouseButton::Left && e.down.click_count == 2 { if e.down.button == MouseButton::Left && e.down.click_count == 2 {
v.resize_active_panel(None, cx) v.resize_active_panel(None, cx)

View file

@ -231,6 +231,7 @@ pub struct NavigationEntry {
pub timestamp: usize, pub timestamp: usize,
} }
#[derive(Clone)]
struct DraggedTab { struct DraggedTab {
pub pane: View<Pane>, pub pane: View<Pane>,
pub ix: usize, pub ix: usize,
@ -1514,24 +1515,25 @@ impl Pane {
.on_click(cx.listener(move |pane: &mut Self, event, cx| { .on_click(cx.listener(move |pane: &mut Self, event, cx| {
pane.activate_item(ix, true, true, cx) pane.activate_item(ix, true, true, cx)
})) }))
.on_drag({ .on_drag(
let pane = cx.view().clone(); DraggedTab {
move |cx| { pane: cx.view().clone(),
cx.build_view(|cx| DraggedTab { detail,
pane: pane.clone(), item_id,
detail, is_active,
item_id, ix,
is_active, },
ix, |tab, cx| cx.build_view(|cx| tab.clone()),
})
}
})
.drag_over::<DraggedTab>(|tab| tab.bg(cx.theme().colors().tab_active_background))
.on_drop(
cx.listener(move |this, dragged_tab: &View<DraggedTab>, cx| {
this.handle_tab_drop(dragged_tab, ix, cx)
}),
) )
.drag_over::<DraggedTab>(|tab| tab.bg(cx.theme().colors().tab_active_background))
.drag_over::<ProjectEntryId>(|tab| tab.bg(gpui::red()))
.on_drop(cx.listener(move |this, dragged_tab: &DraggedTab, cx| {
this.handle_tab_drop(dragged_tab, ix, cx)
}))
.on_drop(cx.listener(move |this, entry_id: &ProjectEntryId, cx| {
dbg!(entry_id);
this.handle_project_entry_drop(entry_id, ix, cx)
}))
.when_some(item.tab_tooltip_text(cx), |tab, text| { .when_some(item.tab_tooltip_text(cx), |tab, text| {
tab.tooltip(move |cx| Tooltip::text(text.clone(), cx)) tab.tooltip(move |cx| Tooltip::text(text.clone(), cx))
}) })
@ -1677,11 +1679,13 @@ impl Pane {
.drag_over::<DraggedTab>(|bar| { .drag_over::<DraggedTab>(|bar| {
bar.bg(cx.theme().colors().tab_active_background) bar.bg(cx.theme().colors().tab_active_background)
}) })
.on_drop( .drag_over::<ProjectEntryId>(|bar| bar.bg(gpui::red()))
cx.listener(move |this, dragged_tab: &View<DraggedTab>, cx| { .on_drop(cx.listener(move |this, dragged_tab: &DraggedTab, cx| {
this.handle_tab_drop(dragged_tab, this.items.len(), cx) this.handle_tab_drop(dragged_tab, this.items.len(), cx)
}), }))
), .on_drop(cx.listener(move |this, entry_id: &ProjectEntryId, cx| {
this.handle_project_entry_drop(entry_id, this.items.len(), cx)
})),
) )
} }
@ -1743,11 +1747,10 @@ impl Pane {
fn handle_tab_drop( fn handle_tab_drop(
&mut self, &mut self,
dragged_tab: &View<DraggedTab>, dragged_tab: &DraggedTab,
ix: usize, ix: usize,
cx: &mut ViewContext<'_, Pane>, cx: &mut ViewContext<'_, Pane>,
) { ) {
let dragged_tab = dragged_tab.read(cx);
let item_id = dragged_tab.item_id; let item_id = dragged_tab.item_id;
let from_pane = dragged_tab.pane.clone(); let from_pane = dragged_tab.pane.clone();
let to_pane = cx.view().clone(); let to_pane = cx.view().clone();
@ -1760,13 +1763,37 @@ impl Pane {
.log_err(); .log_err();
} }
fn handle_project_entry_drop(
&mut self,
project_entry_id: &ProjectEntryId,
ix: usize,
cx: &mut ViewContext<'_, Pane>,
) {
let to_pane = cx.view().downgrade();
let project_entry_id = *project_entry_id;
self.workspace
.update(cx, |workspace, cx| {
cx.defer(move |workspace, cx| {
if let Some(path) = workspace
.project()
.read(cx)
.path_for_entry(project_entry_id, cx)
{
workspace
.open_path(path, Some(to_pane), true, cx)
.detach_and_log_err(cx);
}
});
})
.log_err();
}
fn handle_split_tab_drop( fn handle_split_tab_drop(
&mut self, &mut self,
dragged_tab: &View<DraggedTab>, dragged_tab: &DraggedTab,
split_direction: SplitDirection, split_direction: SplitDirection,
cx: &mut ViewContext<'_, Pane>, cx: &mut ViewContext<'_, Pane>,
) { ) {
let dragged_tab = dragged_tab.read(cx);
let item_id = dragged_tab.item_id; let item_id = dragged_tab.item_id;
let from_pane = dragged_tab.pane.clone(); let from_pane = dragged_tab.pane.clone();
let to_pane = cx.view().clone(); let to_pane = cx.view().clone();
@ -1780,13 +1807,40 @@ impl Pane {
.map(|item| item.boxed_clone()); .map(|item| item.boxed_clone());
if let Some(item) = item { if let Some(item) = item {
if let Some(item) = item.clone_on_split(workspace.database_id(), cx) { if let Some(item) = item.clone_on_split(workspace.database_id(), cx) {
workspace.split_item(split_direction, item, cx); let pane = workspace.split_pane(to_pane, split_direction, cx);
workspace.move_item(from_pane, pane, item_id, 0, cx);
} }
} }
}); });
}) })
.log_err(); .log_err();
} }
fn handle_split_project_entry_drop(
&mut self,
project_entry_id: &ProjectEntryId,
split_direction: SplitDirection,
cx: &mut ViewContext<'_, Pane>,
) {
let project_entry_id = *project_entry_id;
let current_pane = cx.view().clone();
self.workspace
.update(cx, |workspace, cx| {
cx.defer(move |workspace, cx| {
if let Some(path) = workspace
.project()
.read(cx)
.path_for_entry(project_entry_id, cx)
{
let pane = workspace.split_pane(current_pane, split_direction, cx);
workspace
.open_path(path, Some(pane.downgrade()), true, cx)
.detach_and_log_err(cx);
}
});
})
.log_err();
}
} }
impl FocusableView for Pane { impl FocusableView for Pane {
@ -1894,11 +1948,17 @@ impl Render for Pane {
.full() .full()
.z_index(1) .z_index(1)
.drag_over::<DraggedTab>(|style| style.bg(drag_target_color)) .drag_over::<DraggedTab>(|style| style.bg(drag_target_color))
.on_drop(cx.listener( .drag_over::<ProjectEntryId>(|style| style.bg(gpui::red()))
move |this, dragged_tab: &View<DraggedTab>, cx| { .on_drop(cx.listener(move |this, dragged_tab: &DraggedTab, cx| {
this.handle_tab_drop(dragged_tab, this.active_item_index(), cx) this.handle_tab_drop(dragged_tab, this.active_item_index(), cx)
}, }))
)), .on_drop(cx.listener(move |this, entry_id: &ProjectEntryId, cx| {
this.handle_project_entry_drop(
entry_id,
this.active_item_index(),
cx,
)
})),
) )
.children( .children(
[ [
@ -1915,9 +1975,15 @@ impl Render for Pane {
.invisible() .invisible()
.bg(drag_target_color) .bg(drag_target_color)
.drag_over::<DraggedTab>(|style| style.visible()) .drag_over::<DraggedTab>(|style| style.visible())
.drag_over::<ProjectEntryId>(|style| style.visible())
.on_drop(cx.listener(move |this, dragged_tab: &DraggedTab, cx| {
this.handle_split_tab_drop(dragged_tab, direction, cx)
}))
.on_drop(cx.listener( .on_drop(cx.listener(
move |this, dragged_tab: &View<DraggedTab>, cx| { move |this, entry_id: &ProjectEntryId, cx| {
this.handle_split_tab_drop(dragged_tab, direction, cx) this.handle_split_project_entry_drop(
entry_id, direction, cx,
)
}, },
)); ));
match direction { match direction {

View file

@ -3580,7 +3580,7 @@ impl FocusableView for Workspace {
struct WorkspaceBounds(Bounds<Pixels>); struct WorkspaceBounds(Bounds<Pixels>);
#[derive(Render)] #[derive(Clone, Render)]
struct DraggedDock(DockPosition); struct DraggedDock(DockPosition);
impl Render for Workspace { impl Render for Workspace {
@ -3636,7 +3636,7 @@ impl Render for Workspace {
) )
.on_drag_move( .on_drag_move(
cx.listener(|workspace, e: &DragMoveEvent<DraggedDock>, cx| { cx.listener(|workspace, e: &DragMoveEvent<DraggedDock>, cx| {
match e.drag.read(cx).0 { match e.drag(cx).0 {
DockPosition::Left => { DockPosition::Left => {
let size = workspace.bounds.left() + e.event.position.x; let size = workspace.bounds.left() + e.event.position.x;
workspace.left_dock.update(cx, |left_dock, cx| { workspace.left_dock.update(cx, |left_dock, cx| {