From ec339b1dfae32dfa9bf193ba66841a65fa9711a3 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 27 Nov 2020 17:44:14 +0000 Subject: [PATCH] Tracerestrict: Make condition type dropdown variable width --- src/tracerestrict_gui.cpp | 2 +- src/widgets/dropdown.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index 260e24b17e..c345c2cc21 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -1585,7 +1585,7 @@ public: if (type != TRIT_NULL) { uint32 hide_mask = 0; const TraceRestrictDropDownListSet *set = GetTypeDropDownListSet(type, &hide_mask); - this->ShowDropDownListWithValue(set, type, false, widget, 0, hide_mask, 0); + this->ShowDropDownListWithValue(set, type, false, widget, 0, hide_mask, UINT_MAX); } break; } diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 1f26a398db..c9565fa4c7 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -510,7 +510,7 @@ void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, * @param button Button widget number of the parent window \a w that wants the dropdown menu. * @param disabled_mask Bitmask for disabled items (items with their bit set are displayed, but not selectable in the dropdown list). * @param hidden_mask Bitmask for hidden items (items with their bit set are not copied to the dropdown list). - * @param width Width of the dropdown menu. If \c 0, use the width of parent widget \a button. + * @param width Width of the dropdown menu. If \c 0, use the width of parent widget \a button. If \c UINT_MAX, use the width of parent widget \a button, and use auto_width. */ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width, DropDownSyncFocus sync_parent_focus) { @@ -522,7 +522,13 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt } } - if (!list.empty()) ShowDropDownList(w, std::move(list), selected, button, width, false, false, sync_parent_focus); + bool auto_width = false; + if (width == UINT_MAX) { + width = 0; + auto_width = true; + } + + if (!list.empty()) ShowDropDownList(w, std::move(list), selected, button, width, auto_width, false, sync_parent_focus); } /**