Skip to content

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

Nothing is downloaded until you press it.

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

OptionTypeDefaultWhat it does
sizefloat28.0f
picture optionalstd::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.
squareboolfalseSquare 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.
initialsstd::string_viewOverrides 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.
decorativeboolfalseAnnounced instead of the name, when the name is already beside it. A row that reads out "Ada Lovelace, Ada Lovelace" has said it twice.

Released under the LGPL-3.0-or-later licence.