MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ShowDropDownList

Function ShowDropDownList

src/dropdown.cpp:418–445  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

416 * @param options Drop Down options for this menu.
417 */
418void 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.

Callers 15

OnClickMethod · 0.85
OnClickMethod · 0.85
ShowDateDropDownMethod · 0.85
PopupMainToolbarMenuFunction · 0.85
ToolbarOptionsClickFunction · 0.85
ToolbarGraphsClickFunction · 0.85
ToolbarLeagueClickFunction · 0.85
ToolbarBuildRailClickFunction · 0.85
ToolbarBuildRoadClickFunction · 0.85
ToolbarBuildTramClickFunction · 0.85
ToolbarBuildWaterClickFunction · 0.85
ToolbarBuildAirClickFunction · 0.85

Calls 7

SndClickBeepFunction · 0.85
ShowDropDownListAtFunction · 0.85
GetCurrentRectMethod · 0.80
SetLoweredMethod · 0.80
ScaleGUITradFunction · 0.70
SetMethod · 0.45
SetDirtyMethod · 0.45

Tested by

no test coverage detected