summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2014-07-08 20:07:50 +0000
committerfrosch <frosch@openttd.org>2014-07-08 20:07:50 +0000
commitd7736e3797f80fcaa0c96bc562672ee6bfaad304 (patch)
tree5f0a23906c9344837305ab95a41a3dd7ca99b204 /src
parentda9de1de70a83c4f1737f70542214ef39c5df6b7 (diff)
downloadopenttd-d7736e3797f80fcaa0c96bc562672ee6bfaad304.tar.xz
(svn r26680) -Codechange: Simplify dropdown height computation. (Juanjo)
Diffstat (limited to 'src')
-rw-r--r--src/widgets/dropdown.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index 1f32b778e..0ff6ab577 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -355,16 +355,13 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
}
/* Total length of list */
- int list_height = 0;
+ int height = 0;
for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++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 */
int screen_bottom = GetMainViewBottom();
bool scroll = false;
@@ -377,7 +374,7 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
} else {
/* ... and lastly if it won't, enable the scroll bar and fit the
* 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;
height = rows * avg_height;
scroll = true;