OpenTTD Source
20240915-master-g3784a3d3d6
|
Go to the documentation of this file.
111 WWB_PUSHBUTTON = 1 << 7,
126 enum class AspectFlags : uint8_t {
129 ResizeXY = ResizeX | ResizeY,
150 void ApplyAspectRatio();
151 virtual void AdjustPaddingForZoom();
165 template <
class NWID>
169 if (NWID *nwid =
dynamic_cast<NWID *
>(nwid_parent); nwid !=
nullptr)
return nwid;
179 template <
class NWID>
182 for (
const NWidgetBase *nwid_parent = this->
parent; nwid_parent !=
nullptr; nwid_parent = nwid_parent->
parent) {
183 if (
const NWID *nwid =
dynamic_cast<const NWID *
>(nwid_parent); nwid !=
nullptr)
return nwid;
188 virtual bool IsHighlighted()
const {
return false; }
189 virtual TextColour GetHighlightColour()
const {
return TC_INVALID; }
190 virtual void SetHighlighted([[maybe_unused]]
TextColour highlight_colour) {}
199 inline void SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
205 this->AdjustPaddingForZoom();
215 this->AdjustPaddingForZoom();
224 Rect GetCurrentRect()
const
227 r.left = this->
pos_x;
309 void AdjustPaddingForZoom()
override;
315 void SetAspect(
float ratio, AspectFlags flags = AspectFlags::ResizeX);
316 void SetAspect(
int x_ratio,
int y_ratio, AspectFlags flags = AspectFlags::ResizeX);
381 inline void SetLowered(
bool lowered);
382 inline bool IsLowered()
const;
383 inline void SetDisabled(
bool disabled);
384 inline bool IsDisabled()
const;
386 void FillWidgetLookup(
WidgetLookup &widget_lookup)
override;
388 bool IsHighlighted()
const override;
389 TextColour GetHighlightColour()
const override;
390 void SetHighlighted(
TextColour highlight_colour)
override;
465 void AdjustPaddingForZoom()
override;
466 void Add(std::unique_ptr<NWidgetBase> &&wid);
478 std::vector<std::unique_ptr<NWidgetBase>>
children;
504 void AdjustPaddingForZoom()
override;
536 void AdjustPaddingForZoom()
override;
537 void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post);
538 void SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_rato_post);
627 void GetScrollOffsets(
int &start_x,
int &start_y,
int &base_offs_x,
int &base_offs_y);
655 void Add(std::unique_ptr<NWidgetBase> &&nwid);
656 void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post);
657 void SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_ratio_post);
659 void AdjustPaddingForZoom()
override;
670 std::unique_ptr<NWidgetPIPContainer>
child;
698 using size_type = int32_t;
699 static constexpr size_type max_size_type = std::numeric_limits<size_type>::max();
700 static constexpr size_type npos = max_size_type;
774 this->stepsize = ClampTo<size_type>(
stepsize);
784 assert(num < Scrollbar::max_size_type);
786 this->count = ClampTo<size_type>(num);
798 assert(capacity < Scrollbar::max_size_type);
800 this->cap = ClampTo<size_type>(capacity);
814 size_type old_pos = this->
pos;
815 this->pos =
Clamp(position, 0, std::max(this->count - this->cap, 0));
816 return this->pos != old_pos;
828 if (difference == 0)
return false;
831 case SS_BIG: difference *= this->
cap;
break;
861 template <
typename Tcontainer>
864 assert(
static_cast<size_t>(this->
GetCount()) == container.size());
865 auto first = std::next(std::begin(container), this->
GetPosition());
867 return std::make_pair(first, last);
880 template <
typename Tcontainer>
883 assert(
static_cast<size_t>(this->
GetCount()) == container.size());
885 if (row == Scrollbar::npos)
return std::end(container);
887 return std::next(std::begin(container), row);
905 static void InvalidateDimensionCache();
907 static Dimension GetHorizontalDimension();
948 if (base >= max_space || step == 0)
return base;
949 if (step == 1)
return max_space;
950 uint increment = max_space - base;
951 increment -= increment % step;
952 return base + increment;
1252 return SetPadding(padding, padding, padding, padding);
1338 std::unique_ptr<NWidgetBase>
MakeNWidgets(std::span<const NWidgetPart> nwid_parts, std::unique_ptr<NWidgetBase> &&container);
Widget part for storing text colour.
Dimensions (a width and height) of a rectangle in 2D.
FontSize size
Font size of text.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
StringAlignment
How to align the to-be drawn text.
#define SETBITS(x, y)
Sets several bits in a variable.
Padding dimensions to apply to each side of a Rect.
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.
@ FS_NORMAL
Index of the normal font in the font tables.
uint8_t lines
Number of text lines.
Base class that provides memory initialization on dynamically created objects.
Widget part for storing minimal text line data.
Coordinates of a point in 2D.
uint8_t spacing
Extra spacing around lines.
EventState
State of handling an event.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
FontSize
Available font sizes.
Data structure for an opened window.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Specification of a rectangle with absolute coordinates of all edges.
FontSize size
Font size of text lines.
#define CLRBITS(x, y)
Clears several bits in a variable.
TextColour colour
TextColour for DrawString.
ZoomLevel
All zoom levels we know.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.