From 3ab679725526bd095cc1a160705312b16c408b92 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Tue, 17 Jan 2023 11:12:10 -0800 Subject: New method to determine if overlay contains cursor This is needed for "container" overlay's such as `Group` which should only consider it's childrens layouts and not it's own when determining if the cursor is captured by the overlay. --- native/src/user_interface.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'native/src/user_interface.rs') diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs index 29cc3472..8659caa3 100644 --- a/native/src/user_interface.rs +++ b/native/src/user_interface.rs @@ -261,7 +261,11 @@ where } } - let base_cursor = if layout.bounds().contains(cursor_position) { + let base_cursor = if manual_overlay + .as_ref() + .unwrap() + .contains_cursor(Layout::new(&layout), cursor_position) + { // TODO: Type-safe cursor availability Point::new(-1.0, -1.0) } else { @@ -504,7 +508,10 @@ where ); }); - if overlay_bounds.contains(cursor_position) { + if overlay.contains_cursor( + Layout::new(layout), + cursor_position, + ) { overlay_interaction } else { base_interaction -- cgit From be860508a9deed1f4583e045790eb9ddd74d07d5 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Tue, 17 Jan 2023 17:20:53 -0800 Subject: Rename method to is_over --- native/src/user_interface.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'native/src/user_interface.rs') diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs index 8659caa3..0def730c 100644 --- a/native/src/user_interface.rs +++ b/native/src/user_interface.rs @@ -264,7 +264,7 @@ where let base_cursor = if manual_overlay .as_ref() .unwrap() - .contains_cursor(Layout::new(&layout), cursor_position) + .is_over(Layout::new(&layout), cursor_position) { // TODO: Type-safe cursor availability Point::new(-1.0, -1.0) @@ -508,10 +508,8 @@ where ); }); - if overlay.contains_cursor( - Layout::new(layout), - cursor_position, - ) { + if overlay.is_over(Layout::new(layout), cursor_position) + { overlay_interaction } else { base_interaction -- cgit From a50cc32d09ddff1d061701074908c28d5c5509ba Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 30 Jan 2023 05:01:28 +0100 Subject: Fix layout translation in `overlay::Group` This bug produced improper positioning of overlays of elements inside a `Scrollable`. --- native/src/user_interface.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'native/src/user_interface.rs') diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs index 0def730c..80dece21 100644 --- a/native/src/user_interface.rs +++ b/native/src/user_interface.rs @@ -6,7 +6,9 @@ use crate::mouse; use crate::renderer; use crate::widget; use crate::window; -use crate::{Clipboard, Element, Layout, Point, Rectangle, Shell, Size}; +use crate::{ + Clipboard, Element, Layout, Point, Rectangle, Shell, Size, Vector, +}; /// A set of interactive graphical elements with a specific [`Layout`]. /// @@ -203,7 +205,7 @@ where let bounds = self.bounds; let mut overlay = manual_overlay.as_mut().unwrap(); - let mut layout = overlay.layout(renderer, bounds); + let mut layout = overlay.layout(renderer, bounds, Vector::ZERO); let mut event_statuses = Vec::new(); for event in events.iter().cloned() { @@ -252,7 +254,7 @@ where overlay = manual_overlay.as_mut().unwrap(); shell.revalidate_layout(|| { - layout = overlay.layout(renderer, bounds); + layout = overlay.layout(renderer, bounds, Vector::ZERO); }); } @@ -434,10 +436,9 @@ where .as_widget_mut() .overlay(&mut self.state, Layout::new(&self.base), renderer) { - let overlay_layout = self - .overlay - .take() - .unwrap_or_else(|| overlay.layout(renderer, self.bounds)); + let overlay_layout = self.overlay.take().unwrap_or_else(|| { + overlay.layout(renderer, self.bounds, Vector::ZERO) + }); let new_cursor_position = if overlay_layout.bounds().contains(cursor_position) { @@ -538,7 +539,8 @@ where renderer, ) { if self.overlay.is_none() { - self.overlay = Some(overlay.layout(renderer, self.bounds)); + self.overlay = + Some(overlay.layout(renderer, self.bounds, Vector::ZERO)); } overlay.operate( -- cgit