|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
Configuration of a chip: a compact pill with a label and optional leading, check and close icons. More...
#include <headers/guillaume/components/chip.hpp>


Public Types | |
| enum class | Variant { Assist , Filter , Input , Suggestion } |
| Kind of chip. More... | |
| enum class | Mode { Flat , Outlined } |
| Container style: Flat is filled with the secondary container color; Outlined is transparent with an outline until selected, where it is filled too. More... | |
| using | Handler = std::function<void(void)> |
| Callback run when the chip, or its close icon, is activated. | |
Public Member Functions | |
| Chip (void)=default | |
| Create the configuration of a flat Assist chip with no label. | |
| ~Chip (void)=default | |
| Default destructor. | |
| Variant | getVariant (void) const noexcept |
| Get the kind of chip. | |
| Chip & | setVariant (Variant variant) |
| Choose the kind of chip. | |
| Mode | getMode (void) const noexcept |
| Get the container style. | |
| Chip & | setMode (Mode mode) |
| Choose the container style. | |
| const std::string & | getLabel (void) const noexcept |
| Get the label text. | |
| Chip & | setLabel (const std::string &label) |
| Set the label text. | |
| const std::string & | getIconGlyph (void) const noexcept |
| Get the name of the leading icon glyph. | |
| Chip & | setIconGlyph (const std::string &iconGlyph) |
| Set the name of the leading icon glyph. | |
| ecs::Entity::Identifier | getLeadingIcon (void) const noexcept |
| Get the child entity that draws the leading icon. | |
| Chip & | setLeadingIcon (ecs::Entity::Identifier identifier) |
| Record which child entity draws the leading icon. | |
| ecs::Entity::Identifier | getTrailingIcon (void) const noexcept |
| Get the child entity that draws the trailing close icon. | |
| Chip & | setTrailingIcon (ecs::Entity::Identifier identifier) |
| Record which child entity draws the trailing close icon. | |
| ecs::Entity::Identifier | getLabelEntity (void) const noexcept |
| Get the child entity that draws the label. | |
| Chip & | setLabelEntity (ecs::Entity::Identifier identifier) |
| Record which child entity draws the label. | |
| ecs::Entity::Identifier | getCheckIcon (void) const noexcept |
| Get the child entity that draws the selected check. | |
| Chip & | setCheckIcon (ecs::Entity::Identifier identifier) |
| Record which child entity draws the selected check. | |
| bool | isCompact (void) const noexcept |
| Check whether the chip uses the compact padding. | |
| Chip & | setCompact (bool compact) |
| Choose between the regular and the compact padding. | |
| bool | isElevated (void) const noexcept |
| Check whether the chip casts a shadow. | |
| Chip & | setElevated (bool elevated) |
| Choose whether the chip casts a shadow. | |
| bool | isShowSelectedOverlay (void) const noexcept |
| Check whether a selected chip is darkened by a state layer. | |
| Chip & | setShowSelectedOverlay (bool show) |
| Choose whether a selected chip is darkened by a state layer. | |
| bool | isShowSelectedCheck (void) const noexcept |
| Check whether a selected chip shows its check. | |
| Chip & | setShowSelectedCheck (bool show) |
| Choose whether a selected chip shows its check. | |
| const Handler & | getOnPress (void) const noexcept |
| Get the callback run when the chip is pressed. | |
| Chip & | setOnPress (Handler handler) |
| Set the callback run when the chip is pressed. | |
| const Handler & | getOnClose (void) const noexcept |
| Get the callback run when the close icon is pressed. | |
| Chip & | setOnClose (Handler handler) |
| Set the callback run when the close icon is pressed. | |
| 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 const char * | DefaultAssistGlyph = "event" |
| Glyph of the leading icon of an Assist chip without one. | |
| static constexpr const char * | CheckGlyph = "check" |
| Glyph of the selected check. | |
| static constexpr const char * | CloseGlyph = "close" |
| Glyph of the trailing close icon. | |
| static constexpr float | IconSize = 18.0f |
| Font size of the icons, in dp. | |
| static constexpr float | Padding = 12.0f |
| Padding around the content, in dp. | |
| static constexpr float | CompactPadding = 8.0f |
| Padding around the content of a compact chip, in dp. | |
Configuration of a chip: a compact pill with a label and optional leading, check and close icons.
It holds the variant, the mode, the label, the icon glyph, the look options, the callbacks and the identifiers of the chip's children. Two pieces of state live in other components of the same entity: whether the chip is selected (components::Selectable) and whether it is enabled (components::StyleState).
Role in the frame:
To select or disable a chip from code call systems::Chip::setSelected() or systems::Chip::setDisabled(). Every setter here except setOnPress() and setOnClose() compares before writing and marks the component changed only when the value differs.
| using guillaume::components::Chip::Handler = std::function<void(void)> |
|
strong |
|
strong |
|
noexcept |
Get the child entity that draws the selected check.
|
noexcept |
Get the name of the leading icon glyph.
Definition at line 71 of file chip.cpp.

|
noexcept |
|
noexcept |
Get the child entity that draws the label.
|
noexcept |
Get the child entity that draws the leading icon.
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Get the child entity that draws the trailing close icon.
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
| Chip & guillaume::components::Chip::setCheckIcon | ( | ecs::Entity::Identifier | identifier | ) |
Record which child entity draws the selected check.
| identifier | The check child, or ecs::Entity::InvalidIdentifier for none. |
Definition at line 132 of file chip.cpp.

| Chip & guillaume::components::Chip::setCompact | ( | bool | compact | ) |
| Chip & guillaume::components::Chip::setElevated | ( | bool | elevated | ) |
| Chip & guillaume::components::Chip::setIconGlyph | ( | const std::string & | iconGlyph | ) |
| Chip & guillaume::components::Chip::setLabel | ( | const std::string & | label | ) |
Set the label text.
The system copies it to the label child's Text and to the chip's Accessibility label.
| label | The label text. |
Definition at line 62 of file chip.cpp.

| Chip & guillaume::components::Chip::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 118 of file chip.cpp.

| Chip & guillaume::components::Chip::setLeadingIcon | ( | ecs::Entity::Identifier | identifier | ) |
Record which child entity draws the leading icon.
| identifier | The leading icon child, or ecs::Entity::InvalidIdentifier for none. |
Definition at line 90 of file chip.cpp.

Set the callback run when the close icon is pressed.
A chip of any variant with a close callback needs a close icon (systems::Chip::needsCloseIcon()). The chip is not removed for you: do it in the callback. Does not mark the component changed.
| handler | The callback, or an empty one to remove it. |
Definition at line 213 of file chip.cpp.

Set the callback run when the chip is pressed.
It runs on every press of an enabled chip, after a Filter chip toggled its selection. Does not mark the component changed.
| handler | The callback, or an empty one to remove it. |
Definition at line 202 of file chip.cpp.

| Chip & guillaume::components::Chip::setShowSelectedCheck | ( | bool | show | ) |
| Chip & guillaume::components::Chip::setShowSelectedOverlay | ( | bool | show | ) |
| Chip & guillaume::components::Chip::setTrailingIcon | ( | ecs::Entity::Identifier | identifier | ) |
Record which child entity draws the trailing close icon.
systems::Chip::installCloseIcon() then makes that child run the close callback when pressed.
| identifier | The close icon child, or ecs::Entity::InvalidIdentifier for none. |
Definition at line 104 of file chip.cpp.

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