diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 0c7de53e89..5a568f3050 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -5,6 +5,7 @@ - Feature: [#22414] Finance graphs can be resized. - Change: [#21659] Increase the Hybrid Roller Coaster’s maximum lift speed to 17 km/h (11 mph). - Change: [#22466] The Clear Scenery tool now uses a bulldozer cursor instead of a generic crosshair. +- Change: [#22491] Scrollbars are now hidden if the scrollable widget is not actually overflowing. - Fix: [#21908] Errors showing up when placing/moving track design previews. - Fix: [#22307] Hover tooltips in financial charts are not invalidated properly. - Fix: [#22395, #22396] Misaligned tick marks in financial and guest count graphs (original bug). diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index 3f124a0dff..9940dbf97e 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -682,23 +682,31 @@ namespace OpenRCT2::Ui bottomRight.x--; bottomRight.y--; + auto scrollSize = w.OnScrollGetSize(widgetIndex); + bool hScrollNeeded = scrollSize.width > widget.width() && (scroll.flags & HSCROLLBAR_VISIBLE); + bool vScrollNeeded = scrollSize.height > widget.height() && (scroll.flags & VSCROLLBAR_VISIBLE); + // Horizontal scrollbar - if (scroll.flags & HSCROLLBAR_VISIBLE) + if (hScrollNeeded) + { WidgetHScrollbarDraw( dpi, scroll, topLeft.x, bottomRight.y - kScrollBarWidth, ((scroll.flags & VSCROLLBAR_VISIBLE) ? bottomRight.x - (kScrollBarWidth + 1) : bottomRight.x), bottomRight.y, colour); + } // Vertical scrollbar - if (scroll.flags & VSCROLLBAR_VISIBLE) + if (vScrollNeeded) + { WidgetVScrollbarDraw( dpi, scroll, bottomRight.x - kScrollBarWidth, topLeft.y, bottomRight.x, ((scroll.flags & HSCROLLBAR_VISIBLE) ? bottomRight.y - (kScrollBarWidth + 1) : bottomRight.y), colour); + } // Contents - if (scroll.flags & HSCROLLBAR_VISIBLE) + if (hScrollNeeded) bottomRight.y -= (kScrollBarWidth + 1); - if (scroll.flags & VSCROLLBAR_VISIBLE) + if (vScrollNeeded) bottomRight.x -= (kScrollBarWidth + 1); bottomRight.y++;