Changeset - r28157:89602bab64ed
[Not reviewed]
master
0 1 0
Peter Nelson - 10 months ago 2023-11-20 00:44:06
peter1138@openttd.org
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.
1 file changed with 2 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/settings_gui.cpp
Show inline comments
 
@@ -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;
 
			}
 
		}
 
	}
0 comments (0 inline, 0 general)