102 WWB_PUSHBUTTON = 1 << 7,
146 void ApplyAspectRatio();
163 return {given_width, given_height};
176 template <
class NWID>
179 for (NWidgetBase *nwid_parent = this->
parent; nwid_parent !=
nullptr; nwid_parent = nwid_parent->parent) {
180 if (NWID *nwid =
dynamic_cast<NWID *
>(nwid_parent); nwid !=
nullptr)
return nwid;
190 template <
class NWID>
193 for (
const NWidgetBase *nwid_parent = this->
parent; nwid_parent !=
nullptr; nwid_parent = nwid_parent->parent) {
194 if (
const NWID *nwid =
dynamic_cast<const NWID *
>(nwid_parent); nwid !=
nullptr)
return nwid;
226 inline void SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
251 Rect GetCurrentRect()
const
254 r.left = this->
pos_x;
512class NWidgetContainer :
public NWidgetBase {
517 void Add(std::unique_ptr<NWidgetBase> &&wid);
543 std::vector<std::unique_ptr<NWidgetBase>>
children{};
565class NWidgetStacked :
public NWidgetContainer {
593class NWidgetPIPContainer :
public NWidgetContainer {
621class NWidgetHorizontal :
public NWidgetPIPContainer {
633class NWidgetHorizontalLTR :
public NWidgetHorizontal {
644class NWidgetVertical :
public NWidgetPIPContainer {
662class NWidgetMatrix :
public NWidgetPIPContainer {
688 void GetScrollOffsets(
int &start_x,
int &start_y,
int &base_offs_x,
int &base_offs_y);
715 void Add(std::unique_ptr<NWidgetBase> &&nwid);
716 void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post);
717 void SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_ratio_post);
730 std::unique_ptr<NWidgetPIPContainer>
child{};
758 using size_type = int32_t;
759 static constexpr size_type max_size_type = std::numeric_limits<size_type>::max();
760 static constexpr size_type npos = max_size_type;
821 return this->is_vertical;
842 assert(num < Scrollbar::max_size_type);
856 assert(capacity < Scrollbar::max_size_type);
872 size_type old_pos = this->pos;
873 this->pos =
Clamp(position, 0, std::max(this->count - this->cap, 0));
874 return this->pos != old_pos;
886 if (difference == 0)
return false;
919 template <
typename Tcontainer>
922 assert(
static_cast<size_t>(this->
GetCount()) == container.size());
923 auto first = std::next(std::begin(container), this->
GetPosition());
925 return std::make_pair(first, last);
938 template <
typename Tcontainer>
941 assert(
static_cast<size_t>(this->
GetCount()) == container.size());
943 if (row == Scrollbar::npos)
return std::end(container);
945 return std::next(std::begin(container), row);
963 static void InvalidateDimensionCache();
965 static Dimension GetHorizontalDimension();
1006 if (base >= max_space || step == 0)
return base;
1007 if (step == 1)
return max_space;
1008 uint increment = max_space - base;
1009 increment -= increment % step;
1010 return base + increment;
1144 union NWidgetPartUnion {
1158 constexpr NWidgetPartUnion() :
xy() {}
1163 constexpr NWidgetPartUnion(NWidgetPartPIP
pip) :
pip(
pip) {}
1166 constexpr NWidgetPartUnion(NWidgetPartAlignment
align) :
align(
align) {}
1434 return SetPadding(padding, padding, padding, padding);
1528std::unique_ptr<NWidgetBase>
MakeNWidgets(std::span<const NWidgetPart> nwid_parts, std::unique_ptr<NWidgetBase> &&container);
@ Centre
Align to the centre.
@ Middle
Align to the middle.
Types related to the graphics and/or input devices.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
FontSize
Available font sizes.
@ Normal
Index of the normal font in the font tables.
Colours
One of 16 base colours used for companies and windows/widgets.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
#define Rect
Macro that prevents name conflicts between included headers.
#define Point
Macro that prevents name conflicts between included headers.
constexpr bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
constexpr To ClampTo(From value)
Clamp the given value down to lie within the requested type.
Types related to strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
Horizontal and vertical alignment.
Dimensions (a width and height) of a rectangle in 2D.
Widget part for storing minimal text line data.
uint8_t lines
Number of text lines.
uint8_t spacing
Extra spacing around lines.
FontSize size
Font size of text lines.
Widget part for storing text colour.
TextColour colour
TextColour for DrawString.
FontSize size
Font size of text.
Padding dimensions to apply to each side of a Rect.
Data structure for an opened window.
Types related to windows.
EventState
State of handling an event.
static constexpr WidgetID INVALID_WIDGET
An invalid widget index.
ZoomLevel
All zoom levels we know.