OpenTTD Source 20250312-master-gcdcc6b491d
|
Definitions about widgets. More...
#include "core/bitmath_func.hpp"
#include "core/math_func.hpp"
#include "strings_type.h"
#include "gfx_type.h"
#include "window_type.h"
Go to the source code of this file.
Data Structures | |
class | NWidgetBase |
Baseclass for nested widgets. More... | |
class | NWidgetResizeBase |
Base class for a resizable nested widget. More... | |
struct | WidgetData |
Container with the data associated to a single widget. More... | |
class | NWidgetCore |
Base class for a 'real' widget. More... | |
class | NWidgetContainer |
Baseclass for container widgets. More... | |
class | NWidgetStacked |
Stacked widgets, widgets all occupying the same space in the window. More... | |
class | NWidgetPIPContainer |
Container with pre/inter/post child space. More... | |
class | NWidgetHorizontal |
Horizontal container. More... | |
class | NWidgetHorizontalLTR |
Horizontal container that doesn't change the direction of the widgets for RTL languages. More... | |
class | NWidgetVertical |
Vertical container. More... | |
class | NWidgetMatrix |
Matrix container with implicitly equal sized (virtual) sub-widgets. More... | |
class | NWidgetSpacer |
Spacer widget. More... | |
class | NWidgetBackground |
Nested widget with a child. More... | |
class | NWidgetViewport |
Nested widget to display a viewport in a window. More... | |
class | Scrollbar |
Scrollbar data structure. More... | |
class | NWidgetScrollbar |
Nested widget to display and control a scrollbar in a window. More... | |
class | NWidgetLeaf |
Leaf widget. More... | |
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 | NWidgetPartAspect |
struct | NWidgetPart |
Partial widget specification to allow NWidgets to be written nested. More... | |
union | NWidgetPart::NWidgetPartUnion |
Typedefs | |
using | AspectFlags = EnumBitSet< AspectFlag, uint8_t > |
using | WidgetLookup = std::map< WidgetID, class NWidgetBase * > |
Lookup between widget IDs and NWidget objects. | |
using | NWidgetDisplayFlags = EnumBitSet< NWidgetDisplayFlag, uint16_t > |
using | NWidContainerFlags = EnumBitSet< NWidContainerFlag, uint8_t > |
typedef std::unique_ptr< NWidgetBase > | NWidgetFunctionType() |
Pointer to function returning a nested widget. | |
Functions | |
uint | ComputeMaxSize (uint base, uint max_space, uint step) |
Return the biggest possible size of a nested widget. | |
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={}) |
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. | |
bool | IsContainerWidgetType (WidgetType tp) |
Test if WidgetType is a container widget. | |
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. | |
std::unique_ptr< NWidgetBase > | MakeCompanyButtonRows (WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip, bool resizable=true) |
Make a number of rows with button-like graphics, for enabling/disabling each company. | |
void | SetupWidgetDimensions () |
Set up pre-scaled versions of Widget Dimensions. | |
Definitions about widgets.
Definition in file widget_type.h.
using AspectFlags = EnumBitSet<AspectFlag, uint8_t> |
Definition at line 119 of file widget_type.h.
using NWidContainerFlags = EnumBitSet<NWidContainerFlag, uint8_t> |
Definition at line 531 of file widget_type.h.
using NWidgetDisplayFlags = EnumBitSet<NWidgetDisplayFlag, uint16_t> |
Definition at line 347 of file widget_type.h.
typedef std::unique_ptr< NWidgetBase > NWidgetFunctionType() |
Pointer to function returning a nested widget.
Definition at line 1073 of file widget_type.h.
using WidgetLookup = std::map<WidgetID, class NWidgetBase *> |
Lookup between widget IDs and NWidget objects.
Definition at line 126 of file widget_type.h.
enum ArrowWidgetValues : uint8_t |
Values for an arrow widget.
Definition at line 20 of file widget_type.h.
|
strong |
Definition at line 115 of file widget_type.h.
enum NWidContainerFlag : uint8_t |
Nested widget container flags,.
Enumerator | |
---|---|
EqualSize | Containers should keep all their (resizing) children equally large. |
BigFirst | Allocate space to biggest resize first. |
Definition at line 527 of file widget_type.h.
enum NWidgetDisplayFlag : uint8_t |
Nested widget flags that affect display and interaction with 'real' widgets.
Enumerator | |
---|---|
Lowered | Widget is lowered (pressed down) bit. |
Disabled | Widget is disabled (greyed out) bit. |
NoTransparency | Viewport is never transparent. |
ShadeGrey | Shade viewport to grey-scale. |
ShadeDimmed | Display dimmed colours in the viewport. |
DropdownActive | Dropdown menu of the button dropdown widget is active.
|
ScrollbarUp | Up-button is lowered bit. |
ScrollbarDown | Down-button is lowered bit. |
Highlight | Highlight of widget is on. |
DropdownClosed | Dropdown menu of the dropdown widget has closed. |
Definition at line 326 of file widget_type.h.
enum ResizeWidgetValues : uint8_t |
WidgetData values for a resize box widget.
Enumerator | |
---|---|
RWV_SHOW_BEVEL | Bevel of resize box is shown. |
RWV_HIDE_BEVEL | Bevel of resize box is hidden. |
Definition at line 28 of file widget_type.h.
enum SizingType : uint8_t |
Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition()
Enumerator | |
---|---|
ST_SMALLEST | Initialize nested widget tree to smallest size. Also updates current_x and current_y. |
ST_RESIZE | Resize the nested widget tree. |
Definition at line 110 of file widget_type.h.
enum StackedZeroSizePlanes : int |
Display planes with zero size for NWidgetStacked.
Definition at line 489 of file widget_type.h.
enum WidgetType : uint8_t |
Window widget types, nested widget types, and nested widget part types.
Enumerator | |
---|---|
WWT_EMPTY | Empty widget, place holder to reserve space in widget tree. |
WWT_PANEL | Simple depressed panel. |
WWT_INSET | Pressed (inset) panel, most commonly used as combo box text area. |
WWT_IMGBTN | (Toggle) Button with image |
WWT_IMGBTN_2 | (Toggle) Button with diff image when clicked |
WWT_ARROWBTN | (Toggle) Button with an arrow |
WWT_TEXTBTN | (Toggle) Button with text |
WWT_TEXTBTN_2 | (Toggle) Button with diff text when clicked |
WWT_LABEL | Centered label. |
WWT_TEXT | Pure simple text. |
WWT_MATRIX | Grid of rows and columns.
|
WWT_FRAME | Frame. |
WWT_CAPTION | Window caption (window title between closebox and stickybox) |
WWT_DEBUGBOX | NewGRF debug box (at top-right of a window, between WWT_CAPTION and WWT_SHADEBOX) |
WWT_SHADEBOX | Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX) |
WWT_DEFSIZEBOX | Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX) |
WWT_STICKYBOX | Sticky box (at top-right of a window, after WWT_DEFSIZEBOX) |
WWT_RESIZEBOX | Resize box (normally at bottom-right of a window) |
WWT_CLOSEBOX | Close box (at top-left of a window) |
WWT_DROPDOWN | Drop down list. |
WWT_EDITBOX | a textbox for typing |
WWT_LAST | Last Item. use WIDGETS_END to fill up padding!! |
NWID_HORIZONTAL | Horizontal container. |
NWID_HORIZONTAL_LTR | Horizontal container that doesn't change the order of the widgets for RTL languages. |
NWID_VERTICAL | Vertical container. |
NWID_MATRIX | Matrix container. |
NWID_SPACER | Invisible widget that takes some space. |
NWID_SELECTION | Stacked widgets, only one visible at a time (eg in a panel with tabs). |
NWID_LAYER | Layered widgets, all visible together. |
NWID_VIEWPORT | Nested widget containing a viewport. |
NWID_BUTTON_DROPDOWN | Button with a drop-down. |
NWID_HSCROLLBAR | Horizontal scrollbar. |
NWID_VSCROLLBAR | Vertical scrollbar. |
NWID_CUSTOM | General Custom widget. |
WPT_ATTRIBUTE_BEGIN | Begin marker for attribute NWidgetPart types. |
WPT_RESIZE | Widget part for specifying resizing. |
WPT_MINSIZE | Widget part for specifying minimal size. |
WPT_MINTEXTLINES | Widget part for specifying minimal number of lines of text. |
WPT_FILL | Widget part for specifying fill. |
WPT_DATATIP | Widget part for specifying data and tooltip. |
WPT_PADDING | Widget part for specifying a padding. |
WPT_PIPSPACE | Widget part for specifying pre/inter/post space for containers. |
WPT_PIPRATIO | Widget part for specifying pre/inter/post ratio for containers. |
WPT_TEXTSTYLE | Widget part for specifying text colour. |
WPT_ALIGNMENT | Widget part for specifying text/image alignment. |
WPT_SCROLLBAR | Widget part for attaching a scrollbar. |
WPT_ASPECT | Widget part for specifying aspect ratio. |
WPT_ATTRIBUTE_END | End marker for attribute NWidgetPart types. |
WPT_FUNCTION | Widget part for calling a user function. |
WPT_ENDCONTAINER | Widget part to denote end of a container. |
WWT_PUSHBTN | Normal push-button (no toggle button) with custom drawing. |
WWT_PUSHTXTBTN | Normal push-button (no toggle button) with text caption. |
WWT_PUSHIMGBTN | Normal push-button (no toggle button) with image caption. |
WWT_PUSHARROWBTN | Normal push-button (no toggle button) with arrow caption. |
Definition at line 36 of file widget_type.h.
|
inline |
Return the biggest possible size of a nested widget.
base | Base size of the widget. |
max_space | Available space for the widget. |
step | Stepsize of the widget. |
Definition at line 946 of file widget_type.h.
Referenced by NWidgetNewGRFDisplay::AssignSizePosition(), NWidgetLayer::AssignSizePosition(), NWidgetStacked::AssignSizePosition(), NWidgetHorizontal::AssignSizePosition(), NWidgetVertical::AssignSizePosition(), and NWidgetNewGRFDisplay::SetupSmallestSize().
bool IsContainerWidgetType | ( | WidgetType | tp | ) |
Test if WidgetType is a container widget.
tp | WidgetType to test. |
Definition at line 3302 of file widget.cpp.
References NWID_HORIZONTAL, NWID_HORIZONTAL_LTR, NWID_LAYER, NWID_MATRIX, NWID_SELECTION, NWID_VERTICAL, WWT_FRAME, WWT_INSET, and WWT_PANEL.
Referenced by IsNWidgetTreeClosed(), MakeNWidget(), and MakeWidgetTree().
std::unique_ptr< NWidgetBase > MakeCompanyButtonRows | ( | WidgetID | widget_first, |
WidgetID | widget_last, | ||
Colours | button_colour, | ||
int | max_length, | ||
StringID | button_tooltip, | ||
bool | resizable | ||
) |
Make a number of rows with button-like graphics, for enabling/disabling each company.
widget_first | The first widget index to use. |
widget_last | The last widget index to use. |
colour | The colour in which to draw the button. |
max_length | Maximal number of company buttons in one row. |
button_tooltip | The tooltip-string of every button. |
resizable | Whether the rows are resizable. |
Definition at line 3420 of file widget.cpp.
References GetSpriteSize(), RectPadding::Horizontal(), WidgetDimensions::matrix, WidgetDimensions::unscaled, RectPadding::Vertical(), WWT_PANEL, and ZOOM_LVL_NORMAL.
Referenced by MakeCompanyButtonRowsGraphGUI(), MakeCompanyButtonRowsLinkGraphGUI(), and MakeCompanyButtonRowsScriptDebug().
void SetupWidgetDimensions | ( | ) |
Set up pre-scaled versions of Widget Dimensions.
Definition at line 79 of file widget.cpp.
References _settings_client, WidgetDimensions::bevel, WidgetDimensions::captiontext, WidgetDimensions::closebox, WidgetDimensions::debugbox, WidgetDimensions::defsizebox, WidgetDimensions::dropdownlist, WidgetDimensions::dropdowntext, WidgetDimensions::framerect, WidgetDimensions::frametext, WidgetDimensions::fullbevel, ClientSettings::gui, WidgetDimensions::hscrollbar, WidgetDimensions::hsep_indent, WidgetDimensions::hsep_normal, WidgetDimensions::hsep_wide, WidgetDimensions::imgbtn, WidgetDimensions::inset, WidgetDimensions::matrix, WidgetDimensions::modalpopup, WidgetDimensions::resizebox, GUISettings::scale_bevels, WidgetDimensions::scaled, ScaleGUITrad(), WidgetDimensions::shadebox, WidgetDimensions::stickybox, WidgetDimensions::unscaled, WidgetDimensions::vscrollbar, WidgetDimensions::vsep_normal, and WidgetDimensions::vsep_wide.
Referenced by AdjustGUIZoom(), InitWindowSystem(), GameOptionsWindow::OnClick(), and ReInitAllWindows().