|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
A modal panel shown above the rest of the interface, with an optional icon, a title, a message and a row of text buttons. More...
#include <headers/guillaume/entities/dialog.hpp>


Classes | |
| class | Builder |
| Configures a Dialog, then builds it and registers it in the entity registry given at construction. More... | |
Public Types | |
| using | Variant = components::Dialog::Variant |
| Look of the dialog: Alert, Simple, Confirmation or FullScreen. | |
| using | Action = components::Dialog::Action |
| Public Types inherited from guillaume::entities::SurfaceBase< components::Overlay, components::Elevation, components::Accessibility, components::Dialog > | |
| using | Children |
| Public Types inherited from guillaume::ecs::Entity | |
| using | Identifier = std::size_t |
| The key under which an entity's components are stored. Systems and components refer to entities by this value. | |
| using | Signature = std::bitset<128> |
| A set of component types, one bit per type (bit position given by ComponentTypeId, MaxComponentTypes bits). | |
Public Member Functions | |
| Dialog (ecs::ComponentRegistry ®istry, const SurfaceConfig &config, Variant variant, const std::string &title, const std::string &message, const std::vector< Action > &actions, const std::string &icon, std::function< void(void)> onDismiss={}) | |
| Construct a dialog with pressable actions and an icon. | |
| ~Dialog (void) override=default | |
| Default destructor. | |
| Dialog & | setVariant (Variant variant) |
| Change the dialog variant. | |
| Variant | getVariant (void) const |
| Get the dialog variant. | |
| Dialog & | setTitle (const std::string &title) |
| Change the title text. | |
| Dialog & | setMessage (const std::string &message) |
| Change the message text. | |
| Dialog & | show (void) |
| Show the dialog and, except for the FullScreen variant, its backdrop. | |
| Dialog & | hide (void) |
| Hide the dialog and its backdrop. | |
| bool | isVisible (void) const |
| Check whether the dialog is shown. | |
| Dialog & | open (void) |
| Show the dialog; same as show(). | |
| Dialog & | close (void) |
| Hide the dialog; same as hide(). | |
| bool | isOpen (void) const |
| Check whether the dialog is shown; same as isVisible(). | |
| Dialog & | dismiss (void) |
| Dismiss the dialog as the user would: hide it, then call the dismiss handler. | |
| Dialog & | setOnDismiss (std::function< void(void)> onDismiss) |
| Set the handler called when the dialog is dismissed (Paper onDismiss). | |
| std::size_t | getActionCount (void) const |
| Get the number of action buttons. | |
| ecs::Entity::Identifier | getActionIdentifier (std::size_t index) const |
| Get the identifier of an action button. | |
| ecs::Entity::Identifier | getActionRowIdentifier (void) const |
| Get the identifier of the row that holds the action buttons. | |
| ecs::Entity::Identifier | getBackdropIdentifier (void) const |
| Get the identifier of the backdrop drawn behind the panel. | |
| ecs::Entity::Identifier | getIconIdentifier (void) const |
| Get the identifier of the icon shown above the title. | |
| Public Member Functions inherited from guillaume::entities::SurfaceBase< components::Overlay, components::Elevation, components::Accessibility, components::Dialog > | |
| ~SurfaceBase (void) override=default | |
| Default destructor. | |
| SurfaceBase & | setPose (const utility::graphic::PoseF &pose) |
| Move the surface. | |
| SurfaceBase & | setColor (const utility::graphic::Color32Bit &color) |
| Set the fill color (Color component). | |
| SurfaceBase & | setBorderRadius (float radius) |
| Set the radius of the four corners (Borders component). | |
| SurfaceBase & | setSurfaceConfig (const SurfaceConfig &config) |
| Apply every field of a configuration at once. | |
| SurfaceConfig | getSurfaceConfig (void) const |
| Read the current configuration back from the components. | |
| SurfaceBase & | setChildren (const Children &children) |
| Choose the children this surface arranges, in order. | |
| std::vector< ecs::Entity::Identifier > | getChildren (void) const |
| Get the children this surface arranges. | |
| Public Member Functions inherited from guillaume::ecs::ParentEntityFiller< components::Layout, components::Transform, components::Bound, components::Color, components::Borders, ExtraComponents... > | |
| ParentEntityFiller (ComponentRegistry &componentRegistry) | |
| Create the entity, its listed components and its components::Hierarchy. It owns no child yet. | |
| virtual | ~ParentEntityFiller (void)=default |
| Destroy the entity object and release the children it owns; components stay in the registry (see EntityRegistry::removeEntity). | |
| Public Member Functions inherited from guillaume::ecs::Entity | |
| Entity (void) | |
| Create an entity with a fresh identifier, an empty signature, no parent and no component. | |
| virtual | ~Entity (void)=default |
| Destroy the entity object. | |
| Entity::Identifier | getIdentifier (void) const noexcept |
| Get the identifier of the entity. | |
| Entity::Signature | getSignature (void) const noexcept |
| Get the set of component types the entity declares. | |
| void | setSignature (const Signature &signature) |
| Replace the signature of the entity. | |
| std::int32_t | getLayer (void) const noexcept |
| Get the depth of the entity in the tree. | |
| Entity & | setParent (std::shared_ptr< Entity > parent) |
| Attach the entity under another one, or detach it. | |
| std::vector< Identifier > | releaseComponents (void) |
| Drop the entity's place in the tree and all its components. | |
| std::shared_ptr< Entity > | getParent (void) const noexcept |
| Get the parent entity. | |
| Public Member Functions inherited from guillaume::ecs::EntityRegistry | |
| EntityRegistry (void)=default | |
| Create a registry. | |
| virtual | ~EntityRegistry (void)=default |
| Virtual destructor. | |
| void | addEntity (std::shared_ptr< Entity > entity) |
| Make this registry own an entity, so that it stays alive and systems visit it. | |
| bool | removeEntity (Entity::Identifier identifier) |
| Remove an entity, with its children and all their components. | |
| void | clearEntities (void) |
| Remove every entity owned by this registry, with everything they own and all their components. | |
| const std::vector< std::shared_ptr< Entity > > & | getEntities (void) const |
| Get the entities this registry owns directly. | |
| std::vector< std::shared_ptr< Entity > > | getEntitiesBreadthFirst (void) |
| List every entity of this registry and of the registries nested in it, level by level. | |
| std::vector< std::shared_ptr< Entity > > | getEntitiesBreadthFirst (void) const |
| List every entity of this registry and of the registries nested in it, level by level (const overload). | |
| template<InheritFromEntity EntityType> | |
| std::shared_ptr< EntityType > | getEntity (Entity::Identifier identifier) |
| Find an entity owned directly by this registry, by identifier. | |
| template<InheritFromEntity EntityType> | |
| std::shared_ptr< const EntityType > | getEntity (Entity::Identifier identifier) const |
| Find an entity owned directly by this registry, by identifier (const overload). | |
| std::vector< Entity::Identifier > | getEntityWithSignature (Entity::Signature systemSignature) const |
| List the entities that have every component type of a signature, from the root down. | |
| std::vector< Entity::Identifier > | getEntityWithSignature (Entity::Signature systemSignature, const EntityTreeTraveler &traveler) const |
| List the entities that have every component type of a signature, in the order chosen by a traveler. | |
Static Public Member Functions | |
| template<typename... Arguments> | |
| static std::shared_ptr< Dialog > | create (Arguments &&...arguments) |
| Create a dialog and its children, without registering it in an entity registry. | |
| Static Public Member Functions inherited from guillaume::ecs::Entity | |
| template<InheritFromComponent... ComponentTypes> | |
| static Signature | getSignatureFromTypes (void) |
| Build the signature that has exactly the bits of the given component types. | |
Additional Inherited Members | |
| Static Public Attributes inherited from guillaume::ecs::Entity | |
| static constexpr Identifier | InvalidIdentifier |
| "No entity": never the identifier of a real entity | |
| Protected Member Functions inherited from guillaume::entities::SurfaceBase< components::Overlay, components::Elevation, components::Accessibility, components::Dialog > | |
| SurfaceBase (ecs::ComponentRegistry ®istry, const SurfaceConfig &config) | |
| Create the entity with its components and apply a configuration. | |
| void | applyGeometry (void) |
| Arrange the layout children now with systems::Layout::apply. | |
| Protected Member Functions inherited from guillaume::ecs::ParentEntityFiller< components::Layout, components::Transform, components::Bound, components::Color, components::Borders, ExtraComponents... > | |
| ComponentRegistry & | getComponentRegistry (void) |
| Get the registry that stores this entity's components. | |
| Protected Member Functions inherited from guillaume::ecs::ParentEntity | |
| std::vector< std::shared_ptr< Entity > > & | accessDirectEntities (void) override |
| Give access to the list of entities this entity owns directly. | |
| const std::vector< std::shared_ptr< Entity > > & | accessDirectEntities (void) const override |
| Give read access to the list of entities this entity owns directly. | |
| Protected Member Functions inherited from guillaume::ecs::Entity | |
| void | attachHierarchy (ComponentRegistry &componentRegistry) |
| Give the entity a components::Hierarchy in a registry and add that component to its signature. | |
| template<InheritFromComponent... ComponentTypes> | |
| void | setSignature (void) |
| Replace the signature by the one made of the given component types. | |
A modal panel shown above the rest of the interface, with an optional icon, a title, a message and a row of text buttons.
Its configuration lives in components::Dialog (variant, title, message, actions, icon, identifiers of the children) and its visibility and dismiss handler in components::Overlay. systems::Dialog styles the panel, arranges its children and shows or hides its backdrop each frame, in the Layout phase. The class itself holds no field: its setters write the components and restyle at once.
Dialog::create(registry, config, variant, title, message, actions, icon, onDismiss) builds the same widget without registering it in an entity registry.
Showing and hiding: a dialog is created hidden. show() and hide() switch it; dismiss() hides it and calls the dismiss handler. systems::Overlay dismisses the topmost visible overlay when the user presses Escape. Pressing an action button only calls the action's handler: the dialog stays open until the handler (or other code) hides it.
The variants differ as follows:
Things to know:
Definition at line 109 of file dialog.hpp.
One dialog action: a label and a press handler, shown as a text button in the action row.
Definition at line 119 of file dialog.hpp.
Look of the dialog: Alert, Simple, Confirmation or FullScreen.
Definition at line 115 of file dialog.hpp.
| guillaume::entities::Dialog::Dialog | ( | ecs::ComponentRegistry & | registry, |
| const SurfaceConfig & | config, | ||
| Variant | variant, | ||
| const std::string & | title, | ||
| const std::string & | message, | ||
| const std::vector< Action > & | actions, | ||
| const std::string & | icon, | ||
| std::function< void(void)> | onDismiss = {} ) |
Construct a dialog with pressable actions and an icon.
Writes the components and styles the panel, but builds no child: use create() or the Builder, which also build the children.
| registry | The registry the dialog's components are created in. |
| config | Pose and layout of the panel. systems::Dialog overwrites the layout settings. |
| variant | The dialog variant. |
| title | The title text, in the HeadlineSmall type role. |
| message | The message text, in the BodyMedium type role. |
| actions | The actions, shown as a row of text buttons aligned to the end of the panel. |
| icon | The glyph name of the icon above the title. When empty, a Confirmation dialog shows "info" and the other variants show no icon. |
| onDismiss | Called when the dialog is dismissed; stored in components::Overlay. |
Definition at line 173 of file dialog.cpp.


| Dialog & guillaume::entities::Dialog::close | ( | void | ) |
Hide the dialog; same as hide().
Definition at line 258 of file dialog.cpp.

|
inlinestatic |
Create a dialog and its children, without registering it in an entity registry.
The arguments are forwarded to a constructor: (registry, config, variant, title, message, actions, icon, onDismiss) with a vector of Action, or (registry, config, variant, title, message, labels) with a vector of labels. The children are built here, by build(), because a child needs its parent to be owned by a shared pointer.
| Arguments | The constructor argument types. |
| arguments | The constructor arguments, as listed above. |
Definition at line 283 of file dialog.hpp.


| Dialog & guillaume::entities::Dialog::dismiss | ( | void | ) |
Dismiss the dialog as the user would: hide it, then call the dismiss handler.
Does nothing while the dialog is hidden.
Definition at line 268 of file dialog.cpp.

| std::size_t guillaume::entities::Dialog::getActionCount | ( | void | ) | const |
Get the number of action buttons.
Definition at line 282 of file dialog.cpp.

| ecs::Entity::Identifier guillaume::entities::Dialog::getActionIdentifier | ( | std::size_t | index | ) | const |
Get the identifier of an action button.
| index | Index of the button in the action row, from 0. |
index is out of range. Definition at line 290 of file dialog.cpp.

| ecs::Entity::Identifier guillaume::entities::Dialog::getActionRowIdentifier | ( | void | ) | const |
Get the identifier of the row that holds the action buttons.
Definition at line 301 of file dialog.cpp.

| ecs::Entity::Identifier guillaume::entities::Dialog::getBackdropIdentifier | ( | void | ) | const |
Get the identifier of the backdrop drawn behind the panel.
Definition at line 308 of file dialog.cpp.

| ecs::Entity::Identifier guillaume::entities::Dialog::getIconIdentifier | ( | void | ) | const |
Get the identifier of the icon shown above the title.
Definition at line 315 of file dialog.cpp.

| Dialog::Variant guillaume::entities::Dialog::getVariant | ( | void | ) | const |
Get the dialog variant.
Definition at line 207 of file dialog.cpp.


| Dialog & guillaume::entities::Dialog::hide | ( | void | ) |
Hide the dialog and its backdrop.
Sets components::Overlay hidden and restyles at once. Does not itself call the dismiss handler; use dismiss() for that.
Definition at line 240 of file dialog.cpp.


| bool guillaume::entities::Dialog::isOpen | ( | void | ) | const |
Check whether the dialog is shown; same as isVisible().
Definition at line 263 of file dialog.cpp.

| bool guillaume::entities::Dialog::isVisible | ( | void | ) | const |
Check whether the dialog is shown.
Definition at line 246 of file dialog.cpp.


| Dialog & guillaume::entities::Dialog::open | ( | void | ) |
Show the dialog; same as show().
Definition at line 253 of file dialog.cpp.

| Dialog & guillaume::entities::Dialog::setMessage | ( | const std::string & | message | ) |
Change the message text.
Builds the message child when the dialog had none and message is not empty, then restyles at once. An empty message leaves an existing message child in place, with no text.
| message | The new message text. |
Definition at line 224 of file dialog.cpp.


| Dialog & guillaume::entities::Dialog::setOnDismiss | ( | std::function< void(void)> | onDismiss | ) |
Set the handler called when the dialog is dismissed (Paper onDismiss).
The handler is stored in components::Overlay. It is called by dismiss() and by systems::Overlay when it dismisses the dialog, for example on Escape.
| onDismiss | The handler; an empty one removes it. |
Definition at line 274 of file dialog.cpp.

| Dialog & guillaume::entities::Dialog::setTitle | ( | const std::string & | title | ) |
Change the title text.
Builds the title child when the dialog had none and title is not empty, then restyles at once. An empty title leaves an existing title child in place, with no text.
| title | The new title text. |
Definition at line 214 of file dialog.cpp.


Change the dialog variant.
Builds the default "info" icon when the new variant is Confirmation and the dialog has no icon yet, then restyles at once.
| variant | The new variant. |
Definition at line 196 of file dialog.cpp.


| Dialog & guillaume::entities::Dialog::show | ( | void | ) |
Show the dialog and, except for the FullScreen variant, its backdrop.
Sets components::Overlay visible and restyles at once.
Definition at line 234 of file dialog.cpp.

