OpenTTD Source 20250205-master-gfd85ab1e2c
|
To make nested widgets easier to enter, nested widget parts have been created. More...
Data Structures | |
struct | NWidgetPartDataTip |
Widget part for storing data and tooltip information. More... | |
struct | NWidgetPartWidget |
Widget part for storing basic widget information. More... | |
struct | NWidgetPartPaddings |
Widget part for storing padding. More... | |
struct | NWidgetPartPIP |
Widget part for storing pre/inter/post spaces. More... | |
struct | NWidgetPartTextLines |
Widget part for storing minimal text line data. More... | |
struct | NWidgetPartTextStyle |
Widget part for storing text colour. More... | |
struct | NWidgetPartAlignment |
Widget part for setting text/image alignment within a widget. More... | |
struct | NWidgetPart |
Partial widget specification to allow NWidgets to be written nested. More... | |
Functions | |
std::unique_ptr< NWidgetBase > | MakeNWidgets (std::span< const NWidgetPart > nwid_parts, std::unique_ptr< NWidgetBase > &&container) |
Construct a nested widget tree from an array of parts. | |
std::unique_ptr< NWidgetBase > | MakeWindowNWidgetTree (std::span< const NWidgetPart > nwid_parts, NWidgetStacked **shade_select) |
Make a nested widget tree for a window from a parts array. | |
constexpr NWidgetPart | SetResize (int16_t dx, int16_t dy) |
Widget part function for setting the resize step. | |
constexpr NWidgetPart | SetMinimalSize (int16_t x, int16_t y) |
Widget part function for setting the minimal size. | |
constexpr NWidgetPart | SetMinimalTextLines (uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL) |
Widget part function for setting the minimal text lines. | |
constexpr NWidgetPart | SetTextStyle (TextColour colour, FontSize size=FS_NORMAL) |
Widget part function for setting the text style. | |
constexpr NWidgetPart | SetAlignment (StringAlignment align) |
Widget part function for setting the alignment of text/images. | |
constexpr NWidgetPart | SetFill (uint16_t fill_x, uint16_t fill_y) |
Widget part function for setting filling. | |
constexpr NWidgetPart | EndContainer () |
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL). | |
constexpr NWidgetPart | SetStringTip (StringID string, StringID tip={}) |
Widget part function for setting the string and tooltip. | |
constexpr NWidgetPart | SetSpriteTip (SpriteID sprite, StringID tip={}) |
Widget part function for setting the sprite and tooltip. | |
constexpr NWidgetPart | SetArrowWidgetTypeTip (ArrowWidgetValues widget_type, StringID tip={}) |
Widget part function for setting the arrow widget type and tooltip. | |
constexpr NWidgetPart | SetResizeWidgetTypeTip (ResizeWidgetValues widget_type, StringID tip) |
Widget part function for setting the resize widget type and tooltip. | |
constexpr NWidgetPart | SetMatrixDataTip (uint32_t cols, uint32_t rows, StringID tip={}) |
Widget part function for setting the data and tooltip of WWT_MATRIX widgets. | |
constexpr NWidgetPart | SetToolTip (StringID tip) |
Widget part function for setting tooltip and clearing the widget data. | |
constexpr NWidgetPart | SetPadding (uint8_t top, uint8_t right, uint8_t bottom, uint8_t left) |
Widget part function for setting additional space around a widget. | |
constexpr NWidgetPart | SetPadding (uint8_t horizontal, uint8_t vertical) |
Widget part function for setting additional space around a widget. | |
constexpr NWidgetPart | SetPadding (const RectPadding &padding) |
Widget part function for setting additional space around a widget. | |
constexpr NWidgetPart | SetPadding (uint8_t padding) |
Widget part function for setting a padding. | |
constexpr NWidgetPart | SetPIP (uint8_t pre, uint8_t inter, uint8_t post) |
Widget part function for setting a pre/inter/post spaces. | |
constexpr NWidgetPart | SetPIPRatio (uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post) |
Widget part function for setting a pre/inter/post ratio. | |
constexpr NWidgetPart | SetScrollbar (WidgetID index) |
Attach a scrollbar to a widget. | |
constexpr NWidgetPart | SetAspect (float ratio, AspectFlags flags=AspectFlag::ResizeX) |
Widget part function for setting the aspect ratio. | |
constexpr NWidgetPart | NWidget (WidgetType tp, Colours col, WidgetID idx=-1) |
Widget part function for starting a new 'real' widget. | |
constexpr NWidgetPart | NWidget (WidgetType tp, NWidContainerFlags cont_flags=NC_NONE) |
Widget part function for starting a new horizontal container, vertical container, or spacer widget. | |
constexpr NWidgetPart | NWidgetFunction (NWidgetFunctionType *func_ptr) |
Obtain a nested widget (sub)tree from an external source. | |
To make nested widgets easier to enter, nested widget parts have been created.
They allow the tree to be defined in a flat array of parts.
|
constexpr |
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition at line 1204 of file widget_type.h.
References WPT_ENDCONTAINER.
Referenced by MakePickerClassWidgets(), and MakePickerTypeWidgets().
std::unique_ptr< NWidgetBase > MakeNWidgets | ( | std::span< const NWidgetPart > | nwid_parts, |
std::unique_ptr< NWidgetBase > && | container | ||
) |
Construct a nested widget tree from an array of parts.
nwid_parts | Span of nested widget parts. |
container | Container to add the nested widgets to. In case it is nullptr a vertical container is used. |
Definition at line 3381 of file widget.cpp.
References MakeWidgetTree().
Referenced by MakePickerClassWidgets(), MakePickerTypeWidgets(), MakeWindowNWidgetTree(), and NewGRFDisplay().
std::unique_ptr< NWidgetBase > MakeWindowNWidgetTree | ( | std::span< const NWidgetPart > | nwid_parts, |
NWidgetStacked ** | shade_select | ||
) |
Make a nested widget tree for a window from a parts array.
Besides loading, it inserts a shading selection widget between the title bar and the window body if the first widget in the parts array looks like a title bar (it is a horizontal container with a caption widget) and has a shade box widget.
nwid_parts | Span of nested widget parts. | |
[out] | shade_select | Pointer to the inserted shade selection widget (nullptr if not unserted). |
Definition at line 3400 of file widget.cpp.
References NWidgetContainer::Add(), NWidgetContainer::GetWidgetOfType(), MakeNWidgets(), MakeWidgetTree(), WWT_CAPTION, and WWT_SHADEBOX.
Referenced by Window::CreateNestedTree().
|
constexpr |
Widget part function for starting a new 'real' widget.
tp | Type of the new nested widget. |
col | Colour of the new widget. |
idx | Index of the widget. |
Definition at line 1376 of file widget_type.h.
Referenced by MakePickerClassWidgets(), and MakePickerTypeWidgets().
|
constexpr |
Widget part function for starting a new horizontal container, vertical container, or spacer widget.
tp | Type of the new nested widget, NWID_HORIZONTAL, NWID_VERTICAL, NWID_SPACER, NWID_SELECTION, and NWID_MATRIX. |
cont_flags | Flags for the containers (NWID_HORIZONTAL and NWID_VERTICAL). |
Definition at line 1387 of file widget_type.h.
|
constexpr |
Obtain a nested widget (sub)tree from an external source.
func_ptr | Pointer to function that returns the tree. |
Definition at line 1397 of file widget_type.h.
References WPT_FUNCTION.
|
constexpr |
Widget part function for setting the alignment of text/images.
align | Alignment of text/image within widget. |
Definition at line 1183 of file widget_type.h.
References WPT_ALIGNMENT.
|
constexpr |
Widget part function for setting the arrow widget type and tooltip.
widget_type | Type of the widget to draw. |
tip | Tooltip of the widget. |
Definition at line 1237 of file widget_type.h.
|
constexpr |
Widget part function for setting the aspect ratio.
ratio | Desired aspect ratio, or 0 for none. |
flags | Dimensions which should be resized. |
Definition at line 1362 of file widget_type.h.
References WPT_ASPECT.
|
constexpr |
Widget part function for setting filling.
fill_x | Horizontal filling step from minimal size. |
fill_y | Vertical filling step from minimal size. |
Definition at line 1194 of file widget_type.h.
References WPT_FILL.
Referenced by MakePickerClassWidgets(), and MakePickerTypeWidgets().
|
constexpr |
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
cols | Number of columns. 0 means to use draw columns with width according to the resize step size. |
rows | Number of rows. 0 means to use draw rows with height according to the resize step size. |
tip | Tooltip of the widget. |
Definition at line 1260 of file widget_type.h.
Referenced by MakePickerClassWidgets().
|
constexpr |
Widget part function for setting the minimal size.
x | Horizontal minimal size. |
y | Vertical minimal size. |
Definition at line 1150 of file widget_type.h.
References WPT_MINSIZE.
Referenced by MakePickerClassWidgets().
|
constexpr |
Widget part function for setting the minimal text lines.
lines | Number of text lines. |
spacing | Extra spacing required. |
size | Font size of text. |
Definition at line 1162 of file widget_type.h.
References WPT_MINTEXTLINES.
Referenced by MakePickerTypeWidgets().
|
constexpr |
Widget part function for setting additional space around a widget.
r | The padding around the widget. |
Definition at line 1305 of file widget_type.h.
References WPT_PADDING.
|
constexpr |
Widget part function for setting additional space around a widget.
horizontal | The padding on either side of the widget. |
vertical | The padding above and below the widget. |
Definition at line 1295 of file widget_type.h.
References WPT_PADDING.
|
constexpr |
Widget part function for setting a padding.
padding | The padding to use for all directions. |
Definition at line 1315 of file widget_type.h.
References SetPadding().
|
constexpr |
Widget part function for setting additional space around a widget.
Parameters start above the widget, and are specified in clock-wise direction.
top | The padding above the widget. |
right | The padding right of the widget. |
bottom | The padding below the widget. |
left | The padding left of the widget. |
Definition at line 1284 of file widget_type.h.
References WPT_PADDING.
Referenced by MakePickerClassWidgets(), MakePickerTypeWidgets(), and SetPadding().
|
constexpr |
Widget part function for setting a pre/inter/post spaces.
pre | The amount of space before the first widget. |
inter | The amount of space between widgets. |
post | The amount of space after the last widget. |
Definition at line 1327 of file widget_type.h.
References WPT_PIPSPACE.
Referenced by MakePickerTypeWidgets().
|
constexpr |
Widget part function for setting a pre/inter/post ratio.
pre | The ratio of space before the first widget. |
inter | The ratio of space between widgets. |
post | The ratio of space after the last widget. |
Definition at line 1339 of file widget_type.h.
References WPT_PIPRATIO.
|
constexpr |
Widget part function for setting the resize step.
dx | Horizontal resize step. 0 means no horizontal resizing. |
dy | Vertical resize step. 0 means no vertical resizing. |
Definition at line 1139 of file widget_type.h.
References WPT_RESIZE.
Referenced by MakePickerClassWidgets(), and MakePickerTypeWidgets().
|
constexpr |
Widget part function for setting the resize widget type and tooltip.
widget_type | Type of the widget to draw. |
tip | Tooltip of the widget. |
Definition at line 1248 of file widget_type.h.
References WPT_DATATIP.
|
constexpr |
Attach a scrollbar to a widget.
The scrollbar is controlled when using the mousewheel on the widget. Multiple widgets can refer to the same scrollbar to make the mousewheel work in all of them.
index | Widget index of the scrollbar. |
Definition at line 1351 of file widget_type.h.
References WPT_SCROLLBAR.
Referenced by MakePickerClassWidgets(), and MakePickerTypeWidgets().
|
constexpr |
Widget part function for setting the sprite and tooltip.
data | Sprite of the widget. |
tip | Tooltip of the widget. |
Definition at line 1226 of file widget_type.h.
|
constexpr |
Widget part function for setting the string and tooltip.
string | String of the widget. |
tip | Tooltip of the widget. |
Definition at line 1215 of file widget_type.h.
Referenced by MakePickerClassWidgets(), and MakePickerTypeWidgets().
|
constexpr |
Widget part function for setting the text style.
colour | Colour to draw string within widget. |
size | Font size to draw string within widget. |
Definition at line 1173 of file widget_type.h.
References WPT_TEXTSTYLE.
|
constexpr |
Widget part function for setting tooltip and clearing the widget data.
tip | Tooltip of the widget. |
Definition at line 1270 of file widget_type.h.
References WPT_DATATIP.