From c80fa7d7524b7869f6c9ea97dad0e74a826635be Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Mon, 20 Nov 2023 00:44:06 +0000 Subject: [PATCH] Codechange: Simplify setting minimum width for game options dropdown lists. (#11474) Height isn't necessary as drop down controls already have sufficient height, so we can use GetDropDownListDimension() to get the width. --- src/settings_gui.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 231ddc71e2..ebbbb8ba24 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -445,17 +445,8 @@ struct GameOptionsWindow : Window { default: { int selected; - DropDownList list = this->BuildDropDownList(widget, &selected); - if (!list.empty()) { - /* Find the biggest item for the default size. */ - for (const auto &ddli : list) { - Dimension string_dim; - int width = ddli->Width(); - string_dim.width = width + padding.width; - string_dim.height = ddli->Height() + padding.height; - *size = maxdim(*size, string_dim); - } - } + size->width = std::max(size->width, GetDropDownListDimension(this->BuildDropDownList(widget, &selected)).width + padding.width); + break; } } }