diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-06 09:47:03 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-06 09:47:03 +0200 |
commit | 3bbbd1399373755cec95e9685d18ecebec3b9c24 (patch) | |
tree | fe987e205dd7b40f4dab61074a98e143d0ca4e46 /src/ui/root.c | |
parent | 9df0c10c915b504a9f6dcca88608d702e4548bb6 (diff) |
Fixed issues with tall popup menus
A tall popup menu needs to use overflow scrolling, but the size of the display wasn't considered. Now a popup window is fit to the usable bounds of the display.
Diffstat (limited to 'src/ui/root.c')
-rw-r--r-- | src/ui/root.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/ui/root.c b/src/ui/root.c index d847480f..95126654 100644 --- a/src/ui/root.c +++ b/src/ui/root.c | |||
@@ -1529,6 +1529,35 @@ iRect safeRect_Root(const iRoot *d) { | |||
1529 | return rect; | 1529 | return rect; |
1530 | } | 1530 | } |
1531 | 1531 | ||
1532 | iInt2 visibleSize_Root(const iRoot *d) { | 1532 | iRect visibleRect_Root(const iRoot *d) { |
1533 | return addY_I2(size_Root(d), -get_MainWindow()->keyboardHeight); | 1533 | iRect visRect = rect_Root(d); |
1534 | #if defined (iPlatformAppleMobile) | ||
1535 | /* TODO: Check this on device... Maybe DisplayUsableBounds would be good here, too? */ | ||
1536 | float left, top, right, bottom; | ||
1537 | safeAreaInsets_iOS(&left, &top, &right, &bottom); | ||
1538 | visRect.pos.x = (int) left; | ||
1539 | visRect.size.x -= (int) (left + right); | ||
1540 | visRect.pos.y = (int) top; | ||
1541 | visRect.size.y -= (int) (top + bottom); | ||
1542 | #endif | ||
1543 | #if defined (iPlatformDesktop) | ||
1544 | /* Apply the usable bounds of the display. */ | ||
1545 | SDL_Rect usable; { | ||
1546 | const float ratio = d->window->pixelRatio; | ||
1547 | SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(d->window->win), &usable); | ||
1548 | iInt2 winPos; | ||
1549 | SDL_GetWindowPosition(d->window->win, &winPos.x, &winPos.y); | ||
1550 | mulfv_I2(&winPos, ratio); | ||
1551 | usable.x *= ratio; | ||
1552 | usable.y *= ratio; | ||
1553 | usable.w *= ratio; | ||
1554 | usable.h *= ratio; | ||
1555 | /* Make it relative to the window. */ | ||
1556 | usable.x -= winPos.x; | ||
1557 | usable.y -= winPos.y; | ||
1558 | visRect = intersect_Rect(visRect, init_Rect(usable.x, usable.y, usable.w, usable.h)); | ||
1559 | } | ||
1560 | #endif | ||
1561 | adjustEdges_Rect(&visRect, 0, 0, -get_MainWindow()->keyboardHeight, 0); | ||
1562 | return visRect; | ||
1534 | } | 1563 | } |