The unit of position is CGFloat

This commit is contained in:
Cheng Zhao 2016-05-23 21:53:50 +09:00
parent fca91db133
commit b866b34ac8

View file

@ -51,15 +51,15 @@ void MenuMac::PopupAt(Window* window, int x, int y, int positioning_item) {
// If no preferred item is specified, try to show all of the menu items.
if (!positioning_item) {
int windowBottom = CGRectGetMinY([view window].frame);
int distaceFromBottom = windowBottom + position.y - [menu size].height;
CGFloat windowBottom = CGRectGetMinY([view window].frame);
CGFloat distaceFromBottom = windowBottom + position.y - [menu size].height;
if (distaceFromBottom < 0)
position.y = position.y - distaceFromBottom;
}
// Place the menu left of cursor if it is overflowing off right of screen.
int windowLeft = CGRectGetMinX([view window].frame);
int rightmostPoint = windowLeft + position.x + [menu size].width;
CGFloat windowLeft = CGRectGetMinX([view window].frame);
CGFloat rightmostPoint = windowLeft + position.x + [menu size].width;
if (rightmostPoint > [[NSScreen mainScreen] visibleFrame].size.width)
position.x = position.x - [menu size].width;