mirror of https://github.com/OpenTTD/OpenTTD
(svn r26680) -Codechange: Simplify dropdown height computation. (Juanjo)
parent
da9de1de70
commit
d7736e3797
|
@ -355,16 +355,13 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Total length of list */
|
/* Total length of list */
|
||||||
int list_height = 0;
|
int height = 0;
|
||||||
|
|
||||||
for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) {
|
for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) {
|
||||||
const DropDownListItem *item = *it;
|
const DropDownListItem *item = *it;
|
||||||
list_height += item->Height(width);
|
height += item->Height(width);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Height of window visible */
|
|
||||||
int height = list_height;
|
|
||||||
|
|
||||||
/* Check if the status bar is visible, as we don't want to draw over it */
|
/* Check if the status bar is visible, as we don't want to draw over it */
|
||||||
int screen_bottom = GetMainViewBottom();
|
int screen_bottom = GetMainViewBottom();
|
||||||
bool scroll = false;
|
bool scroll = false;
|
||||||
|
@ -377,7 +374,7 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
|
||||||
} else {
|
} else {
|
||||||
/* ... and lastly if it won't, enable the scroll bar and fit the
|
/* ... and lastly if it won't, enable the scroll bar and fit the
|
||||||
* list in below the widget */
|
* list in below the widget */
|
||||||
int avg_height = list_height / (int)list->Length();
|
int avg_height = height / (int)list->Length();
|
||||||
int rows = (screen_bottom - 4 - top) / avg_height;
|
int rows = (screen_bottom - 4 - top) / avg_height;
|
||||||
height = rows * avg_height;
|
height = rows * avg_height;
|
||||||
scroll = true;
|
scroll = true;
|
||||||
|
|
Loading…
Reference in New Issue