From c962c7730674bd78db0eb1dc53ba8d10e5ca7d58 Mon Sep 17 00:00:00 2001 From: PeterN Date: Tue, 20 Dec 2022 14:39:23 +0000 Subject: [PATCH] Fix: Incorrect available height for dropdowns due to unsigned promotion. (#10264) Dropdowns which are taller than the main window should automatically have a scrollbar added. This did not work for toolbar dropdown as the location near the top of the window resulted in an unsigned underflow. --- src/widgets/dropdown.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index fd427c2692..b9cc1c8b9b 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -388,12 +388,12 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button bool above = false; /* Available height below (or above, if the dropdown is placed above the widget). */ - uint available_height = std::max(GetMainViewBottom() - top - WidgetDimensions::scaled.fullbevel.Vertical() * 2, 0U); + uint available_height = std::max(GetMainViewBottom() - top - (int)WidgetDimensions::scaled.fullbevel.Vertical() * 2, 0); /* If the dropdown doesn't fully fit below the widget... */ if (height > available_height) { - uint available_height_above = std::max(w->top + wi_rect.top - GetMainViewTop() - WidgetDimensions::scaled.fullbevel.Vertical() * 2, 0U); + uint available_height_above = std::max(w->top + wi_rect.top - GetMainViewTop() - (int)WidgetDimensions::scaled.fullbevel.Vertical() * 2, 0); /* Put the dropdown above if there is more available space. */ if (available_height_above > available_height) {