Skip to content

Commit

Permalink
Merge pull request #1124 from iced-rs/fix/pane-grid-mouse-interaction
Browse files Browse the repository at this point in the history
Fix implementation of `Widget::mouse_interaction` for `PaneGrid`
  • Loading branch information
hecrj authored Nov 22, 2021
2 parents e2ec824 + 77aa05a commit 71685a1
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions native/src/widget/pane_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,33 @@ where
return mouse::Interaction::Grab;
}

if let Some((_, axis)) = self.state.picked_split() {
return match axis {
Axis::Horizontal => mouse::Interaction::ResizingHorizontally,
Axis::Vertical => mouse::Interaction::ResizingVertically,
let resize_axis =
self.state.picked_split().map(|(_, axis)| axis).or_else(|| {
self.on_resize.as_ref().and_then(|(leeway, _)| {
let bounds = layout.bounds();

let splits = self
.state
.split_regions(f32::from(self.spacing), bounds.size());

let relative_cursor = Point::new(
cursor_position.x - bounds.x,
cursor_position.y - bounds.y,
);

hovered_split(
splits.iter(),
f32::from(self.spacing + leeway),
relative_cursor,
)
.map(|(_, axis, _)| axis)
})
});

if let Some(resize_axis) = resize_axis {
return match resize_axis {
Axis::Horizontal => mouse::Interaction::ResizingVertically,
Axis::Vertical => mouse::Interaction::ResizingHorizontally,
};
}

Expand Down

0 comments on commit 71685a1

Please sign in to comment.