summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-11-21 15:06:01 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-11-21 15:06:01 +0700
commit77aa05afd3cdc7034ddedd394c49b47cc20d56ae (patch)
tree23951cd48171ff727cc50973ca888020fcb12d3d /native
parentd165b789df603e3b93cc9f92184afa6aa6aaf64b (diff)
downloadiced-77aa05afd3cdc7034ddedd394c49b47cc20d56ae.tar.gz
iced-77aa05afd3cdc7034ddedd394c49b47cc20d56ae.tar.bz2
iced-77aa05afd3cdc7034ddedd394c49b47cc20d56ae.zip
Fix implementation of `Widget::mouse_interaction` for `PaneGrid`
Diffstat (limited to 'native')
-rw-r--r--native/src/widget/pane_grid.rs31
1 files changed, 27 insertions, 4 deletions
diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs
index 20616ed4..3637822b 100644
--- a/native/src/widget/pane_grid.rs
+++ b/native/src/widget/pane_grid.rs
@@ -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,
};
}