summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2014-07-16 20:38:36 +0000
committerfrosch <frosch@openttd.org>2014-07-16 20:38:36 +0000
commit925fb7bd37a6a33f885807688487ee052efe2409 (patch)
tree9445068cabb2f11aa641e0973731a0b71d05c80d
parente6641f86d826421bde774c82aabd29d738df2c3f (diff)
downloadopenttd-925fb7bd37a6a33f885807688487ee052efe2409.tar.xz
(svn r26691) -Codechange: Simplify ShowDropDownListAt (Juanjo)
-rw-r--r--src/widgets/dropdown.cpp10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index 0ff6ab577..e83772799 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -344,22 +344,16 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
/* The preferred width equals the calling widget */
uint width = wi_rect.right - wi_rect.left + 1;
+ /* Longest item in the list, if auto_width is enabled */
uint max_item_width = 0;
- if (auto_width) {
- /* Find the longest item in the list */
- for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) {
- const DropDownListItem *item = *it;
- max_item_width = max(max_item_width, item->Width() + 5);
- }
- }
-
/* Total length of list */
int height = 0;
for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) {
const DropDownListItem *item = *it;
height += item->Height(width);
+ if (auto_width) max_item_width = max(max_item_width, item->Width() + 5);
}
/* Check if the status bar is visible, as we don't want to draw over it */