From cbf739cf55b9043f0fff4dcc1cd5c96e327b606c Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Wed, 7 Aug 2024 14:08:11 +0200 Subject: [PATCH] Map window: don't add padding for invisible scrollbars --- src/openrct2-ui/windows/Map.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 4792778432..c7cfea0a5f 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1405,8 +1405,12 @@ static Widget window_map_widgets[] = { { // The initial mini map size should be able to show a reasonably sized map auto initSize = std::clamp(getTechnicalMapSize(), 100, 254) * 2; - width = initSize + kReservedHSpace + SCROLLBAR_SIZE; - height = initSize + kReservedTopSpace + GetReservedBottomSpace() + SCROLLBAR_SIZE; + width = initSize + kReservedHSpace; + height = initSize + kReservedTopSpace + GetReservedBottomSpace(); + + auto scrollbarSize = getTechnicalMapSize() > 254 ? SCROLLBAR_SIZE : 2; + width += scrollbarSize; + height += scrollbarSize; auto maxWindowHeight = ContextGetHeight() - 68; width = std::min(width, ContextGetWidth()); @@ -1415,9 +1419,13 @@ static Widget window_map_widgets[] = { void ResetMaxWindowDimensions() { - max_width = std::clamp(getMiniMapWidth() + kReservedHSpace + SCROLLBAR_SIZE, WW, ContextGetWidth()); + max_width = std::clamp(getMiniMapWidth() + kReservedHSpace, WW, ContextGetWidth()); max_height = std::clamp( - getMiniMapWidth() + kReservedTopSpace + GetReservedBottomSpace() + SCROLLBAR_SIZE, WH, ContextGetHeight() - 68); + getMiniMapWidth() + kReservedTopSpace + GetReservedBottomSpace(), WH, ContextGetHeight() - 68); + + auto scrollbarSize = getMiniMapWidth() + kReservedHSpace > ContextGetWidth() ? SCROLLBAR_SIZE : 2; + max_width += scrollbarSize; + max_height += scrollbarSize; } void ResizeMiniMap()