Center popovers without positions

This commit is contained in:
Jeremy Soller 2024-02-26 15:12:46 -07:00
parent c7093b67f6
commit a0340aac26
No known key found for this signature in database
GPG key ID: D02FD439211AF56F

View file

@ -174,9 +174,9 @@ where
false, false,
), ),
None => { 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, true,
) )
} }
@ -232,7 +232,9 @@ where
if self.centered { if self.centered {
// Position is set to the center bottom of the lower widget // Position is set to the center bottom of the lower widget
let width = node.size().width; let width = node.size().width;
let height = node.size().height;
position.x = (position.x - width / 2.0).clamp(0.0, bounds.width - width); 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 { } else {
// Position is using context menu logic // Position is using context menu logic
let size = node.size(); let size = node.size();