Widgets
Generated from engine/ui/widget.h at aceb130. The text under each declaration is the header's own comment, word for word. About the reference says how these pages are made.
Audience: game code.
#include "engine/ui/widget.h" · namespace labrador
class UiObject
Section titled “class UiObject”A named, hideable thing in a user interface.
Geometry stays in the game's authored space. The game owns layout (T1) and maps the menu to screen space through DrawList::set_camera in engine/render/renderer.h; widgets do not recursively rescale themselves.
UiObject · name
Section titled “UiObject · name”explicit UiObject(const std::string& name, bool hidden = false);const std::string& name() const;set_hidden · hidden
Section titled “set_hidden · hidden”void set_hidden(bool hidden);bool hidden() const;update · draw · bounds
Section titled “update · draw · bounds”void update(float dt) override = 0;set_colour
Section titled “set_colour”No-op for an object without colour. Containers can forward colour to all their children without testing each child's type.
class UiWidget
Section titled “class UiWidget”A colourable UiObject accepted by FocusGroup in engine/ui/focus.h.
UiWidget · ~UiWidget
Section titled “UiWidget · ~UiWidget”explicit UiWidget(const std::string& name, bool hidden = false);~UiWidget() override = default;update · draw · bounds
Section titled “update · draw · bounds”void update(float dt) override = 0;set_colour
Section titled “set_colour”Widgets implement colouring rather than inheriting UiObject's no-op.
class UiContainer
Section titled “class UiContainer”A compound widget that updates, draws and colours its children in insertion order. It can be focused as one row and derived from to own its parts (docs/design/PHILOSOPHY.md, UI).
Child pointers are borrowed and must remain alive while operations can reach them. A derived class can own child members and add them from its constructor body; container destruction drops pointers without reading children, so those members may be destroyed before the base container.
UiContainer
Section titled “UiContainer”explicit UiContainer(const std::string& name);add_child
Section titled “add_child”Stores the child's name and borrows the pointer. Throws std::invalid_argument for a null child.
remove_child · child_count
Section titled “remove_child · child_count”void remove_child(const std::string& name);size_t child_count() const;Remove the first matching child, without destroying it. No-op if absent.
children
Section titled “children”The children's names and pointers in insertion order; the pointers remain borrowed. The reference is invalidated by add_child and remove_child.
update · draw
Section titled “update · draw”void update(float dt) override;Hidden children still update; hiding a container suppresses its draw.
bounds · cull_bounds
Section titled “bounds · cull_bounds”RectangleF cull_bounds(float units_per_pixel) const override;Union of child bounds, skipping width or height <= 0. Returns RectangleF::zero when no child contributes.
set_colour
Section titled “set_colour”Forwarded to every child, including hidden ones, in insertion order. Nested containers forward it; children without colour ignore it.
class UiTexture
Section titled “class UiTexture”Leaf widgets are open to derivation (docs/design/PHILOSOPHY.md, UI) and safe to delete through UiWidget*. An overriding draw() must check hidden() itself: it replaces the leaf's check rather than running after it.
UiTexture
Section titled “UiTexture”UiTexture(const std::string& name, const std::string& sheet_name, const std::string& frame_name, bool hidden = false, float rotation = 0.0f, float layer_depth = 0.0f);update · draw · bounds · cull_bounds
Section titled “update · draw · bounds · cull_bounds”void update(float dt) override;RectangleF cull_bounds(float units_per_pixel) const override;set_sprite_frame · set_colour · set_position · set_position_at_center · set_width · set_height · set_size
Section titled “set_sprite_frame · set_colour · set_position · set_position_at_center · set_width · set_height · set_size”void set_sprite_frame(const std::string& frame_name);void set_position_at_center(const Vector2F& position);void set_width(float width);void set_height(float height);void set_size(const Vector2F& size);rectangle
Section titled “rectangle”class UiText
Section titled “class UiText”UiText
Section titled “UiText”UiText(const std::string& name, const std::wstring& text, const std::string& font_name, bool hidden = false, float scale = 1.0f, float rotation = 0.0f, float layer_depth = 0.0f);update · draw · bounds · set_colour
Section titled “update · draw · bounds · set_colour”void update(float dt) override;Related types
Section titled “Related types”Named in the public declarations above: Colour, DrawList, GameObject, RectangleF, RenderResources, SpriteFlip, Text, TextureObject, Vector2F.
In the samples and tests
Section titled “In the samples and tests”The files that include this header directly. A file can also reach it through another header.
samples/components/binding_row.h,gallery_state.h,nine_slice.h,option_row.h,slider.h,text_field.h,widget_draw_null_tests.cppsamples/linesweeper/states/pause_state.hsamples/local_multiplayer/join_state.htests/linesweeper/touch_pause_tests.cpptests/scene/cull_tests.cpptests/ui/stub_widget.h,text_widget_tests.cpp,widget_tests.cpp
Explained in
Section titled “Explained in”Development documentation (unreleased). Built from Labrador aceb130 of 2026-11-20.