Skip to content

Commit

Permalink
Fix more visual glitches while dragging tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Adanos020 committed Apr 3, 2024
1 parent 9cf801d commit d7176d6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
21 changes: 13 additions & 8 deletions src/widgets/dock_area/show/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,15 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
.transform_layer_shapes(layer_id, TSTransform::new(delta, 1.0));

tabs_ui.memory_mut(|mem| {
let drag_data_mut =
mem.data.get_temp_mut_or(self.id.with("drag_data"), None);
*drag_data_mut = Some(DragData {
src: TreeComponent::Tab(surface_index, node_index, tab_index),
rect: self.dock_state[surface_index][node_index].rect().unwrap(),
});
mem.data.insert_temp(
self.id.with("drag_data"),
Some(DragData {
src: TreeComponent::Tab(surface_index, node_index, tab_index),
rect: self.dock_state[surface_index][node_index]
.rect()
.unwrap(),
}),
);
});
}
}
Expand Down Expand Up @@ -848,8 +851,10 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
};

ui.memory_mut(|mem| {
let hover_data_mut = mem.data.get_temp_mut_or(self.id.with("hover_data"), None);
*hover_data_mut = Some(HoverData { rect, dst, tab });
mem.data.insert_temp(
self.id.with("hover_data"),
Some(HoverData { rect, dst, tab }),
);
});
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/widgets/dock_area/show/main_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
let response = ui.allocate_rect(rect, Sense::hover());
if response.contains_pointer() {
ui.memory_mut(|mem| {
let hover_data_mut = mem.data.get_temp_mut_or(self.id.with("hover_data"), None);
*hover_data_mut = Some(HoverData {
rect,
dst: TreeComponent::Surface(surf_index),
tab: None,
});
mem.data.insert_temp(
self.id.with("hover_data"),
Some(HoverData {
rect,
dst: TreeComponent::Surface(surf_index),
tab: None,
}),
);
});
}
return;
Expand Down
5 changes: 4 additions & 1 deletion src/widgets/dock_area/show/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,13 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
};
self.dock_state.move_tab(source, destination);
}
state.reset_drag();
}
}

if ui.input(|i| i.pointer.primary_released()) {
state.reset_drag();
}

let style = self.style.as_ref().unwrap();
let fade_surface =
self.hovered_window_surface(&mut state, style.overlay.feel.fade_hold_time, ui.ctx());
Expand Down

0 comments on commit d7176d6

Please sign in to comment.