102 WWB_PUSHBUTTON = 1 << 7,
118enum class AspectFlag : uint8_t {
142 void ApplyAspectRatio();
143 virtual void AdjustPaddingForZoom();
157 template <
class NWID>
161 if (NWID *nwid =
dynamic_cast<NWID *
>(nwid_parent); nwid !=
nullptr)
return nwid;
171 template <
class NWID>
174 for (
const NWidgetBase *nwid_parent = this->
parent; nwid_parent !=
nullptr; nwid_parent = nwid_parent->
parent) {
175 if (
const NWID *nwid =
dynamic_cast<const NWID *
>(nwid_parent); nwid !=
nullptr)
return nwid;
181 virtual bool IsHighlighted()
const {
return false; }
182 virtual TextColour GetHighlightColour()
const {
return TC_INVALID; }
183 virtual void SetHighlighted([[maybe_unused]]
TextColour highlight_colour) {}
192 inline void SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
198 this->AdjustPaddingForZoom();
208 this->AdjustPaddingForZoom();
217 Rect GetCurrentRect()
const
220 r.left = this->
pos_x;
304 void AdjustPaddingForZoom()
override;
363 Colours alternate_colour = INVALID_COLOUR;
478 void AdjustPaddingForZoom()
override;
479 void Add(std::unique_ptr<NWidgetBase> &&wid);
502 std::vector<std::unique_ptr<NWidgetBase>>
children{};
554 void AdjustPaddingForZoom()
override;
643 void GetScrollOffsets(
int &start_x,
int &start_y,
int &base_offs_x,
int &base_offs_y);
670 void Add(std::unique_ptr<NWidgetBase> &&nwid);
671 void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post);
672 void SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_ratio_post);
674 void AdjustPaddingForZoom()
override;
685 std::unique_ptr<NWidgetPIPContainer>
child{};
713 using size_type = int32_t;
714 static constexpr size_type max_size_type = std::numeric_limits<size_type>::max();
715 static constexpr size_type npos = max_size_type;
787 this->stepsize = ClampTo<size_type>(
stepsize);
797 assert(num < Scrollbar::max_size_type);
799 this->count = ClampTo<size_type>(num);
811 assert(capacity < Scrollbar::max_size_type);
813 this->cap = ClampTo<size_type>(capacity);
827 size_type old_pos = this->
pos;
828 this->pos =
Clamp(position, 0, std::max(this->count - this->cap, 0));
829 return this->pos != old_pos;
841 if (difference == 0)
return false;
844 case SS_BIG: difference *= this->
cap;
break;
874 template <
typename Tcontainer>
877 assert(
static_cast<size_t>(this->
GetCount()) == container.size());
878 auto first = std::next(std::begin(container), this->
GetPosition());
880 return std::make_pair(first, last);
893 template <
typename Tcontainer>
896 assert(
static_cast<size_t>(this->
GetCount()) == container.size());
898 if (row == Scrollbar::npos)
return std::end(container);
900 return std::next(std::begin(container), row);
918 static void InvalidateDimensionCache();
920 static Dimension GetHorizontalDimension();
961 if (base >= max_space || step == 0)
return base;
962 if (step == 1)
return max_space;
963 uint increment = max_space - base;
964 increment -= increment % step;
965 return base + increment;
1368 return SetPadding(padding, padding, padding, padding);
1454std::unique_ptr<NWidgetBase>
MakeNWidgets(std::span<const NWidgetPart> nwid_parts, std::unique_ptr<NWidgetBase> &&container);
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Timpl & Reset()
Reset all bits.
constexpr Timpl & Set()
Set all bits.
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.
@ FS_NORMAL
Index of the normal font in the font tables.
StringAlignment
How to align the to-be drawn text.
@ SA_CENTER
Center both horizontally and vertically.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
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.
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
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.
Specification of a rectangle with absolute coordinates of all edges.
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.