|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
State of a badge: a small dot or pill, usually holding a count, drawn over another widget. More...
#include <headers/guillaume/components/badge.hpp>


Public Types | |
| enum class | Variant { Dot , Small , Large } |
| Kind of badge; it sets the height and whether a label is shown. More... | |
Public Member Functions | |
| Badge (void)=default | |
| Create the state of a visible Large badge with no label. | |
| ~Badge (void)=default | |
| Default destructor. | |
| Variant | getVariant (void) const noexcept |
| Get the kind of badge. | |
| Badge & | setVariant (Variant variant) |
| Choose the kind of badge. | |
| const std::string & | getLabel (void) const noexcept |
| Get the label text. | |
| Badge & | setLabel (const std::string &label) |
| Set the label text. | |
| ecs::Entity::Identifier | getLabelEntity (void) const noexcept |
| Get the child entity that draws the label. | |
| Badge & | setLabelEntity (ecs::Entity::Identifier identifier) |
| Record which child entity draws the label. | |
| const std::optional< float > & | getSize (void) const noexcept |
| Get the height that replaces the one of the variant. | |
| Badge & | setSize (std::optional< float > size) |
| Replace the height of the variant. | |
| const std::optional< utility::graphic::Color32Bit > & | getContainerColor (void) const noexcept |
| Get the color that replaces the themed container color. | |
| Badge & | setContainerColor (std::optional< utility::graphic::Color32Bit > color) |
| Replace the themed container (background) color. | |
| const std::optional< utility::graphic::Color32Bit > & | getContentColor (void) const noexcept |
| Get the color that replaces the themed label color. | |
| Badge & | setContentColor (std::optional< utility::graphic::Color32Bit > color) |
| Replace the themed label color. | |
| bool | isVisible (void) const noexcept |
| Check whether the badge is shown or fading in. | |
| Badge & | setVisible (bool visible) |
| Store the visibility the fade heads to. | |
| float | getOpacity (void) const noexcept |
| Get the opacity the badge is drawn with. | |
| Badge & | setOpacity (float opacity) |
| Set the opacity the badge is drawn with. | |
| float | getFadeFrom (void) const noexcept |
| Get the opacity the running fade started from. | |
| Badge & | setFadeFrom (float opacity) |
| Record the opacity a fade starts from. | |
| Public Member Functions inherited from guillaume::ecs::Component | |
| bool | hasChanged (void) const |
| Tell whether a value of the component changed since the flags were last reset (the end of the previous frame). | |
| void | setHasChanged (bool hasChanged) |
| Raise or lower the changed flag. | |
| Component (void)=default | |
| Create a component that is not marked as changed. | |
| virtual | ~Component (void)=default |
| Virtual destructor, so components can be destroyed through the base class. | |
Static Public Attributes | |
| static constexpr float | DotSize = 6.0f |
| Height of the Dot variant, in dp. | |
| static constexpr float | SmallSize = 16.0f |
| Height of the Small variant, in dp. | |
| static constexpr float | LargeSize = 20.0f |
| Height of the Large variant, in dp. | |
| static constexpr float | HorizontalPadding = 3.0f |
| Space on each side of the label, in dp. | |
| static constexpr float | LabelScale = 0.5f |
| Label font size as a fraction of the badge height. | |
State of a badge: a small dot or pill, usually holding a count, drawn over another widget.
It holds the variant, the label, the size and color overrides, the identifier of the label child, and the state of the fade that shows or hides the badge.
Role in the frame:
Watch out:
Every setter compares before writing and marks the component changed only when the value differs.
|
strong |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Get the child entity that draws the label.
|
noexcept |
|
noexcept |
Get the height that replaces the one of the variant.
|
noexcept |
|
noexcept |
| Badge & guillaume::components::Badge::setContainerColor | ( | std::optional< utility::graphic::Color32Bit > | color | ) |
| Badge & guillaume::components::Badge::setContentColor | ( | std::optional< utility::graphic::Color32Bit > | color | ) |
| Badge & guillaume::components::Badge::setFadeFrom | ( | float | opacity | ) |
Record the opacity a fade starts from.
Written by systems::Badge::setVisible(), so a fade interrupted half-way reverses from where it was.
| opacity | The starting opacity, 0 to 1. |
Definition at line 150 of file badge.cpp.


| Badge & guillaume::components::Badge::setLabel | ( | const std::string & | label | ) |
Set the label text.
The system copies it to the label child. A label wider than the badge height stretches the badge into a pill. The Dot variant shows no label.
| label | The label text. |
Definition at line 48 of file badge.cpp.

| Badge & guillaume::components::Badge::setLabelEntity | ( | ecs::Entity::Identifier | identifier | ) |
Record which child entity draws the label.
| identifier | The label child, or ecs::Entity::InvalidIdentifier for none. |
Definition at line 62 of file badge.cpp.

| Badge & guillaume::components::Badge::setOpacity | ( | float | opacity | ) |
Set the opacity the badge is drawn with.
Written by systems::Badge on each sample of the fade. The system multiplies the alpha of the container and label colors by it. The value is stored as given, without clamping.
| opacity | The opacity, 0 (hidden) to 1 (fully shown). |
Definition at line 136 of file badge.cpp.

| Badge & guillaume::components::Badge::setSize | ( | std::optional< float > | size | ) |
| Badge & guillaume::components::Badge::setVisible | ( | bool | visible | ) |
Store the visibility the fade heads to.
It starts no fade and leaves the opacity untouched; use systems::Badge::setVisible() to show or hide the badge.
| visible | True when the badge should end up shown. |
Definition at line 122 of file badge.cpp.


|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |