From 925fb7bd37a6a33f885807688487ee052efe2409 Mon Sep 17 00:00:00 2001 From: frosch Date: Wed, 16 Jul 2014 20:38:36 +0000 Subject: [PATCH] (svn r26691) -Codechange: Simplify ShowDropDownListAt (Juanjo) --- src/widgets/dropdown.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 0ff6ab5772..e83772799b 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 */