110 WWB_PUSHBUTTON = 1 << 7,
125enum class AspectFlags : uint8_t {
128 ResizeXY = ResizeX | ResizeY,
149 void ApplyAspectRatio();
150 virtual void AdjustPaddingForZoom();
164 template <
class NWID>
168 if (NWID *nwid =
dynamic_cast<NWID *
>(nwid_parent); nwid !=
nullptr)
return nwid;
178 template <
class NWID>
181 for (
const NWidgetBase *nwid_parent = this->
parent; nwid_parent !=
nullptr; nwid_parent = nwid_parent->
parent) {
182 if (
const NWID *nwid =
dynamic_cast<const NWID *
>(nwid_parent); nwid !=
nullptr)
return nwid;
187 virtual bool IsHighlighted()
const {
return false; }
188 virtual TextColour GetHighlightColour()
const {
return TC_INVALID; }
189 virtual void SetHighlighted([[maybe_unused]]
TextColour highlight_colour) {}
198 inline void SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
204 this->AdjustPaddingForZoom();
214 this->AdjustPaddingForZoom();
223 Rect GetCurrentRect()
const
226 r.left = this->
pos_x;
308 void AdjustPaddingForZoom()
override;
314 void SetAspect(
float ratio, AspectFlags flags = AspectFlags::ResizeX);
315 void SetAspect(
int x_ratio,
int y_ratio, AspectFlags flags = AspectFlags::ResizeX);
380 inline void SetLowered(
bool lowered);
381 inline bool IsLowered()
const;
382 inline void SetDisabled(
bool disabled);
383 inline bool IsDisabled()
const;
385 void FillWidgetLookup(
WidgetLookup &widget_lookup)
override;
387 bool IsHighlighted()
const override;
388 TextColour GetHighlightColour()
const override;
389 void SetHighlighted(
TextColour highlight_colour)
override;
464 void AdjustPaddingForZoom()
override;
465 void Add(std::unique_ptr<NWidgetBase> &&wid);
477 std::vector<std::unique_ptr<NWidgetBase>>
children;
534 void AdjustPaddingForZoom()
override;
535 void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post);
536 void SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_rato_post);
625 void GetScrollOffsets(
int &start_x,
int &start_y,
int &base_offs_x,
int &base_offs_y);
653 void Add(std::unique_ptr<NWidgetBase> &&nwid);
654 void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post);
655 void SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_ratio_post);
657 void AdjustPaddingForZoom()
override;
668 std::unique_ptr<NWidgetPIPContainer>
child;
696 using size_type = int32_t;
697 static constexpr size_type max_size_type = std::numeric_limits<size_type>::max();
698 static constexpr size_type npos = max_size_type;
772 this->stepsize = ClampTo<size_type>(
stepsize);
782 assert(num < Scrollbar::max_size_type);
784 this->count = ClampTo<size_type>(num);
796 assert(capacity < Scrollbar::max_size_type);
798 this->cap = ClampTo<size_type>(capacity);
812 size_type old_pos = this->
pos;
813 this->pos =
Clamp(position, 0, std::max(this->count - this->cap, 0));
814 return this->pos != old_pos;
826 if (difference == 0)
return false;
829 case SS_BIG: difference *= this->
cap;
break;
859 template <
typename Tcontainer>
862 assert(
static_cast<size_t>(this->
GetCount()) == container.size());
863 auto first = std::next(std::begin(container), this->
GetPosition());
865 return std::make_pair(first, last);
878 template <
typename Tcontainer>
881 assert(
static_cast<size_t>(this->
GetCount()) == container.size());
883 if (row == Scrollbar::npos)
return std::end(container);
885 return std::next(std::begin(container), row);
903 static void InvalidateDimensionCache();
905 static Dimension GetHorizontalDimension();
946 if (base >= max_space || step == 0)
return base;
947 if (step == 1)
return max_space;
948 uint increment = max_space - base;
949 increment -= increment % step;
950 return base + increment;
1261 return SetPadding(padding, padding, padding, padding);
1347std::unique_ptr<NWidgetBase>
MakeNWidgets(std::span<const NWidgetPart> nwid_parts, std::unique_ptr<NWidgetBase> &&container);
Helper types related to the allocation of memory.
Functions related to bit mathematics.
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
#define CLRBITS(x, y)
Clears several bits in a variable.
#define SETBITS(x, y)
Sets several bits in a variable.
Base class that provides memory initialization on dynamically created objects.
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
Types related to the graphics and/or input devices.
StringAlignment
How to align the to-be drawn text.
FontSize
Available font sizes.
@ FS_NORMAL
Index of the normal font in the font tables.
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.
Coordinates of a point in 2D.
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.
ZoomLevel
All zoom levels we know.