Avatar
avatar · Elements
A person, as a small round picture — or as their initials when there is none.
Import
cpp
#include "gbui/widgets/avatar.hpp"Example
cpp
NodeId avatar(Ui& ui, std::string_view name, const AvatarOptions& options = {});A person's picture, or their initials. name is what it is announced as and where the initials and the colour come from, so it is a parameter rather than an option: an avatar without one is a decoration, and this component would have nothing to draw.
API
AvatarOptions
| Option | Type | Default | What it does |
|---|---|---|---|
size | float | 28.0f | |
picture optional | std::optional<Bitmap> | The picture. Nothing draws the initials instead. Borrowed for the frame like every other bitmap here — read when the frame is painted, never copied. See image. | |
square | bool | false | Square instead of round. A round avatar is a person and a square one is a thing — an organisation, a repository, a bot. Worth the option because the shape is the only signal a reader gets, and getting it backwards makes a list of teams look like a list of people. |
initials | std::string_view | Overrides the initials, which are otherwise taken from the name. For the cases the derivation gets wrong and only the caller can know: a handle with no spaces in it, a name written family-first, an emoji. | |
decorative | bool | false | Announced instead of the name, when the name is already beside it. A row that reads out "Ada Lovelace, Ada Lovelace" has said it twice. |