1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-07-09 22:04:07 +01:00

Codechange: Simplify setting minimum width for game options dropdown lists. ()

Height isn't necessary as drop down controls already have sufficient height, so we can use GetDropDownListDimension() to get the width.
This commit is contained in:
Peter Nelson 2023-11-20 00:44:06 +00:00 committed by GitHub
parent f58a7ef673
commit c80fa7d752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -445,17 +445,8 @@ struct GameOptionsWindow : Window {
default: { default: {
int selected; int selected;
DropDownList list = this->BuildDropDownList(widget, &selected); size->width = std::max(size->width, GetDropDownListDimension(this->BuildDropDownList(widget, &selected)).width + padding.width);
if (!list.empty()) { break;
/* 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);
}
}
} }
} }
} }