summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 */