BMenu: fix menu navigation area
Change-Id: If9326ebc99978627d9dfb1eaff67912f0114f292 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2071 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
+19
-29
@@ -1911,39 +1911,29 @@ BMenu::_UpdateStateOpenSelect(BMenuItem* item, BPoint position,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect menuBounds = ConvertToScreen(Bounds());
|
bool isLeft = ConvertFromScreen(navAreaRectAbove).left == 0;
|
||||||
|
BPoint p1, p2;
|
||||||
BRect submenuBounds;
|
|
||||||
if (fSelected->Submenu()->LockLooper()) {
|
|
||||||
fSelected->Submenu()->ConvertToScreen(
|
|
||||||
fSelected->Submenu()->Bounds());
|
|
||||||
fSelected->Submenu()->UnlockLooper();
|
|
||||||
}
|
|
||||||
|
|
||||||
float xOffset;
|
|
||||||
|
|
||||||
// navAreaRectAbove and navAreaRectBelow have the same X
|
|
||||||
// position and width, so it doesn't matter which one we use to
|
|
||||||
// calculate the X offset
|
|
||||||
if (menuBounds.left < submenuBounds.left)
|
|
||||||
xOffset = position.x - navAreaRectAbove.left;
|
|
||||||
else
|
|
||||||
xOffset = navAreaRectAbove.right - position.x;
|
|
||||||
|
|
||||||
bool inNavArea;
|
|
||||||
|
|
||||||
if (inNavAreaRectAbove) {
|
if (inNavAreaRectAbove) {
|
||||||
float yOffset = navAreaRectAbove.bottom - position.y;
|
if (!isLeft) {
|
||||||
float ratio = navAreaRectAbove.Width() / navAreaRectAbove.Height();
|
p1 = navAreaRectAbove.LeftBottom();
|
||||||
|
p2 = navAreaRectAbove.RightTop();
|
||||||
inNavArea = yOffset <= xOffset / ratio;
|
} else {
|
||||||
|
p2 = navAreaRectAbove.RightBottom();
|
||||||
|
p1 = navAreaRectAbove.LeftTop();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
float yOffset = navAreaRectBelow.bottom - position.y;
|
if (!isLeft) {
|
||||||
float ratio = navAreaRectBelow.Width() / navAreaRectBelow.Height();
|
p2 = navAreaRectBelow.LeftTop();
|
||||||
|
p1 = navAreaRectBelow.RightBottom();
|
||||||
inNavArea = yOffset >= (navAreaRectBelow.Height() - xOffset
|
} else {
|
||||||
/ ratio);
|
p1 = navAreaRectBelow.RightTop();
|
||||||
|
p2 = navAreaRectBelow.LeftBottom();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
bool inNavArea =
|
||||||
|
(p1.y - p2.y) * position.x + (p2.x - p1.x) * position.y
|
||||||
|
+ (p1.x - p2.x) * p1.y + (p2.y - p1.y) * p1.x >= 0;
|
||||||
|
|
||||||
bigtime_t systime = system_time();
|
bigtime_t systime = system_time();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user