Change: Make vehicle list dropdown buttons resize to fit strings. (#10286)
This commit is contained in:
15
src/gfx.cpp
15
src/gfx.cpp
@@ -922,6 +922,21 @@ Dimension GetStringBoundingBox(StringID strid, FontSize start_fontsize)
|
||||
return GetStringBoundingBox(buffer, start_fontsize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get maximum width of a list of strings.
|
||||
* @param list List of strings, terminated with INVALID_STRING_ID.
|
||||
* @param fontsize Font size to use.
|
||||
* @return Width of longest string within the list.
|
||||
*/
|
||||
uint GetStringListWidth(const StringID *list, FontSize fontsize)
|
||||
{
|
||||
uint width = 0;
|
||||
for (const StringID *str = list; *str != INVALID_STRING_ID; str++) {
|
||||
width = std::max(width, GetStringBoundingBox(*str, fontsize).width);
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the leading corner of a character in a single-line string relative
|
||||
* to the start of the string.
|
||||
|
Reference in New Issue
Block a user