Skip to content

Label

Generated from engine/render/label.h at 0f4f503. The text under each declaration is the header's own comment, word for word. About the reference says how these pages are made.

Browse the render module

Audience: game code.

#include "engine/render/label.h" · namespace labrador

class Label : public GameObject, public Text

A string a scene can hold, which is what Text on its own is not.

Text is the drawing half - a wide string, a font handle, a measurement and a draw(). What it does not have is the three things engine/core/game_object.h asks for: something to step, an extent to cull against, and the GameObject base that lets a container hold it next to a sprite.

It is a separate class rather than a base added to Text, and that is not a style choice: engine/ui pairs a GameObject-derived UiWidget with the drawable (UiText is UiWidget plus Text), so a GameObject base on Text would give UiText two of them. This is the same pairing Visual already is for sprites - GameObject plus TextureObject - and for the same reason.

IT HAS NO HIDDEN FLAG, AND SCENE TEXT THAT HIDES IS A UiText. A string a scene holds that must stop drawing while keeping its words, its box and its colour is a UiText (engine/ui/widget.h), whose set_hidden skips the draw and leaves bounds() alone. For a label whose box may go empty, set_text(L"") is the supported way to hide it; it re-measures on every call, so a caller that would do it every frame gates it on a change, as LineSweeper's play state does. Naming UiText here is a pointer and not a dependency: engine/render does not include engine/ui.

Label() = default;
Label(const std::wstring& text,
const std::string& font_name,
const Vector2F& position,
RenderResources* render_resources,
const Colour& colour = Colour::white,
float scale = 1.0f,
float rotation = 0.0f,
const Vector2F& origin = Vector2F::zero,
float layer_depth = 0.0f);

The parameters, what is borrowed and what throws are Text's constructor's (engine/render/text.h).

void update(float dt) override;

Nothing to step. A label that animates is a label something else moves, which is what set_position is for.

void draw(DrawList& draw_list) const override;

One declaration overriding two virtuals, because GameObject::draw and TextObject::draw have the same signature in unrelated bases - without it, this class is abstract and the call is ambiguous.

RectangleF bounds() const override;

The drawn box: TextObject::text_bounds, which scales and turns the stored measurement at the current scale and rotation. The measurement is taken when the string or the font changes and not here: this is the culling path, and measuring walks the string. A scale or rotation change takes no measurement and needs none.

Named in the public declarations above: Colour, DrawList, GameObject, RectangleF, RenderResources, Text, Vector2F.

The files that include this header directly. A file can also reach it through another header.

Documentation for Labrador v0.3.0. Built from Labrador 0f4f503 of 2026-11-03.

All documentation versions