Skip to content

Commit

Permalink
Fix: use the correct icon when dragging (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk authored Oct 10, 2022
1 parent 5f5a877 commit 55b01ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
let is_being_dragged =
ui.memory().is_being_dragged(id) && style.tabs_are_draggable;

if is_being_dragged {
ui.output().cursor_icon = CursorIcon::Grabbing;
}

let is_active = *active == tab_index || is_being_dragged;
let label = tab_viewer.title(tab);

Expand All @@ -355,9 +359,7 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
.response;

let sense = Sense::click_and_drag();
let response = ui
.interact(response.rect, id, sense)
.on_hover_cursor(CursorIcon::Grabbing);
let response = ui.interact(response.rect, id, sense);

if let Some(pointer_pos) = ui.ctx().pointer_interact_pos() {
let center = response.rect.center();
Expand Down
6 changes: 4 additions & 2 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ impl Style {
vec2(galley.size().x + offset.x * 2.0, 24.0)
};

let (rect, response) = ui.allocate_at_least(desired_size, Sense::hover());
let response = response.on_hover_cursor(CursorIcon::PointingHand);
let (rect, mut response) = ui.allocate_at_least(desired_size, Sense::hover());
if !ui.memory().is_anything_being_dragged() {
response = response.on_hover_cursor(CursorIcon::Grab);
}

let (x_rect, x_res) = if (active || response.hovered()) && self.show_close_buttons {
let mut pos = rect.right_top();
Expand Down

0 comments on commit 55b01ea

Please sign in to comment.