|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
State of a card: a surface grouping an optional cover image, title, text and row of action buttons. More...
#include <headers/guillaume/components/card.hpp>


Classes | |
| struct | Action |
| One button of the actions row: its label and what it does. More... | |
Public Types | |
| enum class | Variant { Elevated , Filled , Outlined } |
| Look of the card surface. More... | |
| using | Handler = std::function<void(void)> |
| Callback run when the card is pressed. | |
| using | Identifiers = std::vector<ecs::Entity::Identifier> |
| List of child entity identifiers. | |
Public Member Functions | |
| Card (void)=default | |
| Create the state of an empty, elevated card that cannot be pressed. | |
| ~Card (void)=default | |
| Default destructor. | |
| Variant | getVariant (void) const noexcept |
| Get the look of the card surface. | |
| Card & | setVariant (Variant variant) |
| Choose the look of the card surface. | |
| bool | isInteractive (void) const noexcept |
| Check whether the card reacts to hover and press. | |
| Card & | setInteractive (bool interactive) |
| Record that the card reacts to hover and press. | |
| bool | isPressed (void) const noexcept |
| Check whether the press motion is heading to the raised state. | |
| Card & | setPressed (bool pressed) |
| Record the pressed state the press motion heads to. | |
| float | getPressProgress (void) const noexcept |
| Get how far the card is raised by a press. | |
| Card & | setPressProgress (float pressProgress) |
| Set how far the card is raised by a press. | |
| float | getPressFrom (void) const noexcept |
| Get the press progress at which the running motion began. | |
| Card & | setPressFrom (float pressFrom) |
| Record the press progress at which a motion begins. | |
| const std::string & | getCoverPath (void) const noexcept |
| Get the path of the cover texture. | |
| Card & | setCoverPath (const std::string &coverPath) |
| Set the path of the cover texture. | |
| const std::string & | getTitle (void) const noexcept |
| Get the title text. | |
| Card & | setTitle (const std::string &title) |
| Set the title text. | |
| const std::string & | getSubtitle (void) const noexcept |
| Get the subtitle text. | |
| Card & | setSubtitle (const std::string &subtitle) |
| Set the subtitle text. | |
| const std::string & | getContentText (void) const noexcept |
| Get the content text. | |
| Card & | setContentText (const std::string &contentText) |
| Set the content text. | |
| ecs::Entity::Identifier | getCover (void) const noexcept |
| Get the child entity that draws the cover image. | |
| Card & | setCover (ecs::Entity::Identifier identifier) |
| Record which child entity draws the cover image. | |
| ecs::Entity::Identifier | getTitleSection (void) const noexcept |
| Get the child entity that contains the title and the subtitle. | |
| Card & | setTitleSection (ecs::Entity::Identifier identifier) |
| Record which child entity contains the title and the subtitle. | |
| ecs::Entity::Identifier | getTitleText (void) const noexcept |
| Get the entity that draws the title text. | |
| Card & | setTitleText (ecs::Entity::Identifier identifier) |
| Record which entity draws the title text. | |
| ecs::Entity::Identifier | getSubtitleText (void) const noexcept |
| Get the entity that draws the subtitle text. | |
| Card & | setSubtitleText (ecs::Entity::Identifier identifier) |
| Record which entity draws the subtitle text. | |
| ecs::Entity::Identifier | getContentEntity (void) const noexcept |
| Get the child entity that draws the content text. | |
| Card & | setContentEntity (ecs::Entity::Identifier identifier) |
| Record which child entity draws the content text. | |
| ecs::Entity::Identifier | getActionsSection (void) const noexcept |
| Get the child entity that contains the action buttons. | |
| Card & | setActionsSection (ecs::Entity::Identifier identifier) |
| Record which child entity contains the action buttons. | |
| const std::vector< Action > & | getActions (void) const noexcept |
| Get the actions the card was asked to show. | |
| Card & | addAction (Action action) |
| Append an action to the actions row. | |
| const Identifiers & | getActionButtons (void) const noexcept |
| Get the entities of the action buttons. | |
| Card & | setActionButtons (const Identifiers &identifiers) |
| Record which entities are the action buttons. | |
| const Handler & | getOnPress (void) const noexcept |
| Get the callback run when the card is pressed. | |
| Card & | setOnPress (Handler handler) |
| Store the callback run when the card 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 float | CoverHeight = 195.0f |
| Height of the cover image, in dp. | |
| static constexpr float | TitleMinHeight = 72.0f |
| Minimum height of the title section, in dp. | |
State of a card: a surface grouping an optional cover image, title, text and row of action buttons.
It holds the variant, the content (cover path, title, subtitle, text, actions), the identifiers of the children that draw that content, the press callback and the progress of the press motion. Whether the card is enabled lives in the components::StyleState of the same entity.
Role in the frame:
Watch out:
Unless a member says otherwise, a setter compares before writing and marks the component changed only when the value differs.
| using guillaume::components::Card::Handler = std::function<void(void)> |
| using guillaume::components::Card::Identifiers = std::vector<ecs::Entity::Identifier> |
|
strong |
Append an action to the actions row.
Always marks the component changed. The widget class creates the button of each action from this list.
| action | The label and the click handler of the new button. |
Definition at line 244 of file card.cpp.

|
noexcept |
|
noexcept |
|
noexcept |
Get the child entity that contains the action buttons.
|
noexcept |
Get the child entity that draws the content text.
|
noexcept |
|
noexcept |
Get the child entity that draws the cover image.
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Get the entity that draws the subtitle text.
|
noexcept |
|
noexcept |
Get the child entity that contains the title and the subtitle.
|
noexcept |
Get the entity that draws the title text.
|
noexcept |
|
noexcept |
Check whether the card reacts to hover and press.
|
noexcept |
| Card & guillaume::components::Card::setActionButtons | ( | const Identifiers & | identifiers | ) |
| Card & guillaume::components::Card::setActionsSection | ( | ecs::Entity::Identifier | identifier | ) |
Record which child entity contains the action buttons.
| identifier | The actions row child, or ecs::Entity::InvalidIdentifier for none. |
Definition at line 230 of file card.cpp.

| Card & guillaume::components::Card::setContentEntity | ( | ecs::Entity::Identifier | identifier | ) |
Record which child entity draws the content text.
| identifier | The content text child, or ecs::Entity::InvalidIdentifier for none. |
Definition at line 216 of file card.cpp.

| Card & guillaume::components::Card::setContentText | ( | const std::string & | contentText | ) |
| Card & guillaume::components::Card::setCover | ( | ecs::Entity::Identifier | identifier | ) |
Record which child entity draws the cover image.
| identifier | The cover child, or ecs::Entity::InvalidIdentifier for none. |
Definition at line 160 of file card.cpp.

| Card & guillaume::components::Card::setCoverPath | ( | const std::string & | coverPath | ) |
| Card & guillaume::components::Card::setInteractive | ( | bool | interactive | ) |
Record that the card reacts to hover and press.
An interactive card blends the hover and press state layers over its container color. Written by systems::Card::setOnPress(); the flag alone does not wire any input.
| interactive | True when the input is wired. |
Definition at line 48 of file card.cpp.

Store the callback run when the card is pressed.
It only stores the callback and does not mark the component changed. Use systems::Card::setOnPress() so the card also starts reacting to input.
| handler | The callback, or an empty one to remove it. |
Definition at line 270 of file card.cpp.


| Card & guillaume::components::Card::setPressed | ( | bool | pressed | ) |
Record the pressed state the press motion heads to.
Written by systems::Card when the input changes; only an Elevated card is ever recorded as pressed.
| pressed | True when the card is held down. |
Definition at line 62 of file card.cpp.

| Card & guillaume::components::Card::setPressFrom | ( | float | pressFrom | ) |
Record the press progress at which a motion begins.
Written by systems::Card when the pressed state flips, so a press released half-way animates back from where it was.
| pressFrom | The starting progress, 0 to 1. |
Definition at line 90 of file card.cpp.

| Card & guillaume::components::Card::setPressProgress | ( | float | pressProgress | ) |
Set how far the card is raised by a press.
Written by systems::Card on each sample of the press animation. An Elevated card blends its surface tone and shadow between elevation levels 1 and 2 by this amount.
| pressProgress | The progress, 0 at rest to 1 fully pressed. |
Definition at line 76 of file card.cpp.

| Card & guillaume::components::Card::setSubtitle | ( | const std::string & | subtitle | ) |
| Card & guillaume::components::Card::setSubtitleText | ( | ecs::Entity::Identifier | identifier | ) |
Record which entity draws the subtitle text.
| identifier | The subtitle text entity, a child of the title section, or ecs::Entity::InvalidIdentifier for none. |
Definition at line 202 of file card.cpp.

| Card & guillaume::components::Card::setTitle | ( | const std::string & | title | ) |
Set the title text.
The system copies it to the title text child and to the Accessibility label of the title section.
| title | The title text. |
Definition at line 118 of file card.cpp.

| Card & guillaume::components::Card::setTitleSection | ( | ecs::Entity::Identifier | identifier | ) |
Record which child entity contains the title and the subtitle.
| identifier | The title section child, or ecs::Entity::InvalidIdentifier for none. |
Definition at line 174 of file card.cpp.

| Card & guillaume::components::Card::setTitleText | ( | ecs::Entity::Identifier | identifier | ) |
Record which entity draws the title text.
| identifier | The title text entity, a child of the title section, or ecs::Entity::InvalidIdentifier for none. |
Definition at line 188 of file card.cpp.

|
staticconstexpr |
|
staticconstexpr |