MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DrawLabel

Function DrawLabel

src/widget.cpp:410–417  ·  view source on GitHub ↗

* Draw the label-part of a widget. * @param r Rectangle of the label background. * @param colour Colour of the text. * @param str Text to draw. * @param align Alignment of the text. * @param fs Font size of the text. */

Source from the content-addressed store, hash-verified

408 * @param fs Font size of the text.
409 */
410static inline void DrawLabel(const Rect &r, TextColour colour, std::string_view str, StringAlignment align, FontSize fs)
411{
412 if (str.empty()) return;
413
414 Dimension d = GetStringBoundingBox(str, fs);
415 Point p = GetAlignedPosition(r, d, align);
416 DrawString(r.left, r.right, p.y, str, colour, align, false, fs);
417}
418
419/**
420 * Draw text.

Callers 1

DrawMethod · 0.85

Calls 4

GetStringBoundingBoxFunction · 0.85
GetAlignedPositionFunction · 0.85
DrawStringFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected