From a0340aac268bf61529025c02bff10fb4c21dc6fc Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 26 Feb 2024 15:12:46 -0700 Subject: [PATCH] Center popovers without positions --- src/widget/popover.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/widget/popover.rs b/src/widget/popover.rs index 609b495c..dcd0954c 100644 --- a/src/widget/popover.rs +++ b/src/widget/popover.rs @@ -174,9 +174,9 @@ where false, ), None => { - // Set position to center of bottom edge + // Set position to center ( - Point::new(bounds.x + bounds.width / 2.0, bounds.y + bounds.height), + Point::new(bounds.x + bounds.width / 2.0, bounds.y + bounds.height / 2.0), true, ) } @@ -232,7 +232,9 @@ where if self.centered { // Position is set to the center bottom of the lower widget let width = node.size().width; + let height = node.size().height; position.x = (position.x - width / 2.0).clamp(0.0, bounds.width - width); + position.y = (position.y - height / 2.0).clamp(0.0, bounds.height - height); } else { // Position is using context menu logic let size = node.size();