core/menu: add QsMenuAnchor for more control of platform menus

This commit is contained in:
outfoxxed 2024-07-25 20:44:26 -07:00
parent 54350277be
commit 6b9b1fcb53
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
10 changed files with 245 additions and 21 deletions

View file

@ -184,9 +184,9 @@ void PopupPositioner::reposition(PopupAnchor* anchor, QWindow* window, bool only
auto effectiveY = calcEffectiveY();
if (adjustment.testFlag(PopupAdjustment::FlipX)) {
bool flip = (anchorGravity.testFlag(Edges::Left) && effectiveX < screenGeometry.left())
|| (anchorGravity.testFlag(Edges::Right)
&& effectiveX + windowGeometry.width() > screenGeometry.right());
const bool flip = (anchorGravity.testFlag(Edges::Left) && effectiveX < screenGeometry.left())
|| (anchorGravity.testFlag(Edges::Right)
&& effectiveX + windowGeometry.width() > screenGeometry.right());
if (flip) {
anchorGravity ^= Edges::Left | Edges::Right;
@ -200,9 +200,9 @@ void PopupPositioner::reposition(PopupAnchor* anchor, QWindow* window, bool only
}
if (adjustment.testFlag(PopupAdjustment::FlipY)) {
bool flip = (anchorGravity.testFlag(Edges::Top) && effectiveY < screenGeometry.top())
|| (anchorGravity.testFlag(Edges::Bottom)
&& effectiveY + windowGeometry.height() > screenGeometry.bottom());
const bool flip = (anchorGravity.testFlag(Edges::Top) && effectiveY < screenGeometry.top())
|| (anchorGravity.testFlag(Edges::Bottom)
&& effectiveY + windowGeometry.height() > screenGeometry.bottom());
if (flip) {
anchorGravity ^= Edges::Top | Edges::Bottom;