Change: Make all dropdown lists extend width if necessary.
This removes the auto_width parameter from ShowDropDown(At).
This commit is contained in:
@@ -351,12 +351,10 @@ struct DropdownWindow : Window {
|
||||
* @param button The widget which is passed to Window::OnDropdownSelect and OnDropdownClose.
|
||||
* Unless you override those functions, this should be then widget index of the dropdown button.
|
||||
* @param wi_rect Coord of the parent drop down button, used to position the dropdown menu.
|
||||
* @param auto_width The width is determined by the widest item in the list,
|
||||
* in this case only one of \a left or \a right is used (depending on text direction).
|
||||
* @param instant_close Set to true if releasing mouse button should close the
|
||||
* list regardless of where the cursor is.
|
||||
*/
|
||||
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close)
|
||||
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool instant_close)
|
||||
{
|
||||
CloseWindowById(WC_DROPDOWN_MENU, 0);
|
||||
|
||||
@@ -366,7 +364,7 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button
|
||||
/* The preferred width equals the calling widget */
|
||||
uint width = wi_rect.Width();
|
||||
|
||||
/* Longest item in the list, if auto_width is enabled */
|
||||
/* Longest item in the list */
|
||||
uint max_item_width = 0;
|
||||
|
||||
/* Total height of list */
|
||||
@@ -374,10 +372,10 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button
|
||||
|
||||
for (const auto &item : list) {
|
||||
height += item->Height(width);
|
||||
if (auto_width) max_item_width = std::max(max_item_width, item->Width());
|
||||
max_item_width = std::max(max_item_width, item->Width());
|
||||
}
|
||||
|
||||
if (auto_width) max_item_width += WidgetDimensions::scaled.fullbevel.Horizontal();
|
||||
max_item_width += WidgetDimensions::scaled.fullbevel.Horizontal();
|
||||
|
||||
/* Scrollbar needed? */
|
||||
bool scroll = false;
|
||||
@@ -421,7 +419,7 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button
|
||||
}
|
||||
}
|
||||
|
||||
if (auto_width) width = std::max(width, max_item_width);
|
||||
width = std::max(width, max_item_width);
|
||||
|
||||
Point dw_pos = { w->left + (_current_text_dir == TD_RTL ? wi_rect.right + 1 - (int)width : wi_rect.left), top};
|
||||
Dimension dw_size = {width, height};
|
||||
@@ -440,12 +438,11 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button
|
||||
* @param selected The initially selected list item.
|
||||
* @param button The widget within the parent window that is used to determine
|
||||
* the list's location.
|
||||
* @param width Override the width determined by the selected widget.
|
||||
* @param auto_width Maximum width is determined by the widest item in the list.
|
||||
* @param width Override the minimum width determined by the selected widget and list contents.
|
||||
* @param instant_close Set to true if releasing mouse button should close the
|
||||
* list regardless of where the cursor is.
|
||||
*/
|
||||
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
|
||||
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool instant_close)
|
||||
{
|
||||
/* Our parent's button widget is used to determine where to place the drop
|
||||
* down list window. */
|
||||
@@ -468,7 +465,7 @@ void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button,
|
||||
}
|
||||
}
|
||||
|
||||
ShowDropDownListAt(w, std::move(list), selected, button, wi_rect, wi_colour, auto_width, instant_close);
|
||||
ShowDropDownListAt(w, std::move(list), selected, button, wi_rect, wi_colour, instant_close);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -480,7 +477,7 @@ void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button,
|
||||
* @param button Button widget number of the parent window \a w that wants the dropdown menu.
|
||||
* @param disabled_mask Bitmask for disabled items (items with their bit set are displayed, but not selectable in the dropdown list).
|
||||
* @param hidden_mask Bitmask for hidden items (items with their bit set are not copied to the dropdown list).
|
||||
* @param width Width of the dropdown menu. If \c 0, use the width of parent widget \a button.
|
||||
* @param width Minimum width of the dropdown menu.
|
||||
*/
|
||||
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
|
||||
{
|
||||
|
Reference in New Issue
Block a user