* Show a drop down list. * @param w Parent window for the list. * @param list Prepopulated DropDownList. * @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 minimum width determined by the selected widget and list contents. * @param
| 416 | * @param options Drop Down options for this menu. |
| 417 | */ |
| 418 | void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, DropDownOptions options) |
| 419 | { |
| 420 | /* Handle the beep of the player's click. */ |
| 421 | SndClickBeep(); |
| 422 | |
| 423 | /* Our parent's button widget is used to determine where to place the drop |
| 424 | * down list window. */ |
| 425 | NWidgetCore *nwi = w->GetWidget<NWidgetCore>(button); |
| 426 | Rect wi_rect = nwi->GetCurrentRect(); |
| 427 | Colours wi_colour = nwi->colour; |
| 428 | |
| 429 | if ((nwi->type & WWT_MASK) == NWID_BUTTON_DROPDOWN) { |
| 430 | nwi->disp_flags.Set(NWidgetDisplayFlag::DropdownActive); |
| 431 | } else { |
| 432 | nwi->SetLowered(true); |
| 433 | } |
| 434 | nwi->SetDirty(w); |
| 435 | |
| 436 | if (width != 0) { |
| 437 | if (_current_text_dir == TD_RTL) { |
| 438 | wi_rect.left = wi_rect.right + 1 - ScaleGUITrad(width); |
| 439 | } else { |
| 440 | wi_rect.right = wi_rect.left + ScaleGUITrad(width) - 1; |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | ShowDropDownListAt(w, std::move(list), selected, button, wi_rect, wi_colour, options); |
| 445 | } |
| 446 | |
| 447 | /** |
| 448 | * Show a dropdown menu window near a widget of the parent window. |
no test coverage detected