feat: popover top position (#1403)

This commit is contained in:
Ashley Wulber 2026-08-24 20:28:46 -04:00 • committed by GitHub
parent ef490df50b
commit f8f5c7b5a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 22 deletions

View file

@ -24,6 +24,7 @@ pub enum Position {
#[default]
Center,
Bottom,
Top,
Point(Point),
}
@ -260,6 +261,7 @@ where
Position::Point(relative) => {
bounds.position() + Vector::new(relative.x, relative.y)
}
Position::Top => Point::new(bounds.x + bounds.width / 2.0, bounds.y),
};
// Round position to prevent rendering issues
@ -354,6 +356,12 @@ where
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);
}
Position::Top => {
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).clamp(0.0, bounds.height - height);
}
Position::Bottom => {
// Position is set to the center bottom of the widget
let width = node.size().width;