10#ifndef DROPDOWN_TYPE_H
11#define DROPDOWN_TYPE_H
23class DropDownListItem {
42 virtual uint
Height()
const {
return 0; }
48 virtual uint
Width()
const {
return 0; }
56 virtual int OnClick([[maybe_unused]]
const Rect &r, [[maybe_unused]]
const Point &pt)
const
69 virtual void Draw(
const Rect &full, [[maybe_unused]]
const Rect &r, [[maybe_unused]]
bool sel, [[maybe_unused]]
int click_result, Colours bg_colour)
const
81 if (this->shaded)
return (sel ? TC_SILVER : TC_GREY) |
TC_NO_SHADE;
82 return sel ? TC_WHITE : TC_BLACK;
89typedef std::vector<std::unique_ptr<const DropDownListItem>>
DropDownList;
104void ReplaceDropDownList(
Window *parent,
DropDownList &&list, std::optional<int> selected_result = std::nullopt);
Base list item class from which others are derived.
virtual int OnClick(const Rect &r, const Point &pt) const
Callback when this item is clicked.
bool masked
Masked and unselectable item.
TextColour GetColour(bool sel) const
Get the colour of the text.
virtual bool Selectable() const
Can this dropdown item be selected?
int result
Result value to return to window on selection.
virtual uint Width() const
The width of this item.
bool shaded
Shaded item, affects text colour.
virtual void Draw(const Rect &full, const Rect &r, bool sel, int click_result, Colours bg_colour) const
Callback for drawing this item.
virtual uint Height() const
The height of this item.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
DropDownOption
Configuration options for the created DropDownLists.
@ InstantClose
Set if releasing mouse button should close the list regardless of where the cursor is.
@ Persist
Set if this dropdown should stay open after an option is selected.
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, DropDownOptions options={})
Show a drop down list.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width=0, DropDownOptions options={})
Show a drop down list.
Dimension GetDropDownListDimension(const DropDownList &list)
Determine width and height required to fully display a DropDownList.
Type (helpers) for enums.
void GfxFillRect(int left, int top, int right, int bottom, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Functions related to the gfx engine.
Types related to the graphics and/or input devices.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
@ TC_NO_SHADE
Do not add shading to this text colour.
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
#define Rect
Macro that prevents name conflicts between included headers.
#define Point
Macro that prevents name conflicts between included headers.
PixelColour GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
Functions related to palettes.
Dimensions (a width and height) of a rectangle in 2D.
Data structure for an opened window.
Functions, definitions and such used only by the GUI.
Types related to windows.