Fix some drag and drop issues including the mouse cursor not being locked to pointer, tooltips being incorrect when a dragged tab is used, and some subscription leaks from panes

This commit is contained in:
K Simmons 2022-08-26 15:43:15 -07:00
parent 579c84b5e4
commit 3cc07c1099
7 changed files with 139 additions and 97 deletions

View file

@ -172,7 +172,7 @@ pub enum Event {
Focused,
ActivateItem { local: bool },
Remove,
RemoveItem,
RemoveItem { item_id: usize },
Split(SplitDirection),
ChangeItemTitle,
}
@ -453,7 +453,7 @@ impl Pane {
item
}
pub fn add_item(
pub(crate) fn add_item(
workspace: &mut Workspace,
pane: &ViewHandle<Pane>,
item: Box<dyn ItemHandle>,
@ -475,6 +475,8 @@ impl Pane {
)
};
item.added_to_pane(workspace, pane.clone(), cx);
// Does the item already exist?
if let Some(existing_item_index) = pane.read(cx).items.iter().position(|existing_item| {
let existing_item_entry_ids = existing_item.project_entry_ids(cx);
@ -516,8 +518,6 @@ impl Pane {
pane.activate_item(insertion_index, activate_pane, focus_item, cx);
});
} else {
// If the item doesn't already exist, add it and activate it
item.added_to_pane(workspace, pane.clone(), cx);
pane.update(cx, |pane, cx| {
cx.reparent(&item);
pane.items.insert(insertion_index, item);
@ -762,7 +762,7 @@ impl Pane {
}
let item = self.items.remove(item_ix);
cx.emit(Event::RemoveItem);
cx.emit(Event::RemoveItem { item_id: item.id() });
if self.items.is_empty() {
item.deactivated(cx);
self.update_toolbar(cx);
@ -1069,7 +1069,7 @@ impl Pane {
let detail = detail.clone();
move |dragged_item, cx: &mut RenderContext<Workspace>| {
let tab_style = &theme.workspace.tab_bar.dragged_tab;
Pane::render_tab(
Self::render_tab(
&dragged_item.item,
dragged_item.pane.clone(),
detail,