|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
Configures, creates and registers Button widgets. More...
#include <headers/guillaume/entities/button.hpp>


Public Member Functions | |
| Builder (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry) | |
| Construct a builder with the default configuration (see reset()). | |
| std::shared_ptr< Button > | buildEntity (void) override |
| Build a Button, with its icon and label children, from the current configuration, without registering it. | |
| void | reset (void) override |
| Restore the default configuration. | |
| Builder & | withIcon (const std::string &iconGlyphName) |
| Set the icon shown next to the label. | |
| Builder & | withIconStyle (const components::Glyph::Style &iconStyle) |
| Set the glyph style of the icon. | |
| Builder & | withLabel (const std::string &labelContent) |
| Set the label text. | |
| Builder & | withOnClick (std::function< void(void)> onClick) |
| Set the click handler. | |
| Builder & | withToggle (const bool &isToggle) |
| Make the button a toggle: each click flips its selected state. | |
| Builder & | withColorStyle (const Color &colorStyle) |
| Set the color style. | |
| Builder & | withShape (const Shape &shape) |
| Set the corner shape. | |
| Builder & | withSize (const Size &size) |
| Set the size. | |
| Builder & | withMorph (const bool &isMorph) |
| Choose whether a selected toggle button swaps its shape (Round becomes Square and Square becomes Round). | |
| Builder & | withDisabled (const bool &isDisabled) |
| Choose whether the button starts disabled. | |
| Builder & | withTrailingIcon (const bool &isTrailingIcon) |
| Choose the side of the icon. | |
| Builder & | withAccessibilityLabel (const std::string &accessibilityLabel) |
| Set the label read by assistive technology. | |
| std::shared_ptr< Button > | makeButton (std::shared_ptr< Entity > parent, const std::string &labelContent, std::function< void(void)> onClick, Color colorStyle, Shape shape, Size size, bool isMorph) |
| Build a button with a label and no icon, register it under parent and reset the builder. | |
| std::shared_ptr< Button > | makeIconButton (std::shared_ptr< Entity > parent, const std::string &labelContent, const std::string &iconGlyphName, const components::Glyph::Style &iconStyle, std::function< void(void)> onClick, Color colorStyle, Shape shape, Size size, bool isMorph) |
| Build a button with an icon and a label, register it under parent and reset the builder. | |
| Public Member Functions inherited from guillaume::entities::EntityBuilderBase< Button > | |
| EntityBuilderBase (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry) | |
| Construct a builder bound to two registries. | |
| ~EntityBuilderBase (void) override=default | |
| Default destructor. | |
| std::shared_ptr< Button > | registerEntity (std::shared_ptr< ecs::Entity > parent) |
| Build the widget, attach it to its parent, hand it to the entity registry, then reset the builder to its defaults. | |
| Public Member Functions inherited from guillaume::ecs::EntityBuilder | |
| EntityBuilder (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry) | |
| Create a builder working on a pair of registries, normally those of one scene. | |
| virtual | ~EntityBuilder (void)=default |
| Virtual destructor. | |
Additional Inherited Members | |
| Protected Member Functions inherited from guillaume::ecs::EntityBuilder | |
| ComponentRegistry & | getComponentRegistry (void) |
| Get the registry in which the builder creates components. | |
| EntityRegistry & | getEntityRegistry (void) |
| Get the registry in which the builder registers the entities it creates. | |
Configures, creates and registers Button widgets.
Set options with the with... methods then call registerEntity(), or use makeButton() / makeIconButton() to do both in one call.
Definition at line 96 of file button.hpp.
| guillaume::entities::Button::Builder::Builder | ( | ecs::ComponentRegistry & | componentRegistry, |
| ecs::EntityRegistry & | entityRegistry ) |
Construct a builder with the default configuration (see reset()).
| componentRegistry | The registry that stores the components of the buttons to build. |
| entityRegistry | The registry the built buttons are added to (usually the scene's). |
Definition at line 37 of file button.cpp.

|
overridevirtual |
Build a Button, with its icon and label children, from the current configuration, without registering it.
registerEntity() calls it, then sets the parent, registers the button and resets the builder.
Implements guillaume::entities::EntityBuilderBase< Button >.
Definition at line 44 of file button.cpp.

| std::shared_ptr< Button > guillaume::entities::Button::Builder::makeButton | ( | std::shared_ptr< Entity > | parent, |
| const std::string & | labelContent, | ||
| std::function< void(void)> | onClick, | ||
| Color | colorStyle, | ||
| Shape | shape, | ||
| Size | size, | ||
| bool | isMorph ) |
Build a button with a label and no icon, register it under parent and reset the builder.
Options set before the call with the other with... methods (toggle, disabled, ...) also apply.
| parent | The entity the button becomes a child of. |
| labelContent | The text shown in the button. |
| onClick | The function called when the user clicks the button (may be empty). |
| colorStyle | The color style. |
| shape | The corner shape. |
| size | The size. |
| isMorph | True for a toggle button that swaps its shape while selected. |
Definition at line 145 of file button.cpp.

| std::shared_ptr< Button > guillaume::entities::Button::Builder::makeIconButton | ( | std::shared_ptr< Entity > | parent, |
| const std::string & | labelContent, | ||
| const std::string & | iconGlyphName, | ||
| const components::Glyph::Style & | iconStyle, | ||
| std::function< void(void)> | onClick, | ||
| Color | colorStyle, | ||
| Shape | shape, | ||
| Size | size, | ||
| bool | isMorph ) |
Build a button with an icon and a label, register it under parent and reset the builder.
Options set before the call with the other with... methods (toggle, trailing icon, ...) also apply. For a button that shows an icon only, see IconButton.
| parent | The entity the button becomes a child of. |
| labelContent | The text shown in the button. |
| iconGlyphName | The glyph name of the icon. |
| iconStyle | The glyph style of the icon. |
| onClick | The function called when the user clicks the button (may be empty). |
| colorStyle | The color style. |
| shape | The corner shape. |
| size | The size. |
| isMorph | True for a toggle button that swaps its shape while selected. |
Definition at line 159 of file button.cpp.

|
overridevirtual |
Restore the default configuration.
Defaults: no icon, Glyph::Style::Outlined, empty label, no click handler, not a toggle, Color::Text, Shape::Round, Size::Small, no morph, enabled, leading icon, empty accessibility label.
Implements guillaume::ecs::EntityBuilder.
Definition at line 53 of file button.cpp.

| Button::Builder & guillaume::entities::Button::Builder::withAccessibilityLabel | ( | const std::string & | accessibilityLabel | ) |
Set the label read by assistive technology.
| accessibilityLabel | The accessibility label. Default: empty, in which case the label text is used. |
Definition at line 138 of file button.cpp.
| Button::Builder & guillaume::entities::Button::Builder::withColorStyle | ( | const Color & | colorStyle | ) |
Set the color style.
| colorStyle | The color style. Default: Color::Text. |
Definition at line 101 of file button.cpp.
| Button::Builder & guillaume::entities::Button::Builder::withDisabled | ( | const bool & | isDisabled | ) |
Choose whether the button starts disabled.
| isDisabled | True for a button that ignores input. Default: false. |
Definition at line 125 of file button.cpp.

| Button::Builder & guillaume::entities::Button::Builder::withIcon | ( | const std::string & | iconGlyphName | ) |
Set the icon shown next to the label.
| iconGlyphName | The glyph name of the icon (for example "add"). Default: empty, no icon. |
Definition at line 69 of file button.cpp.

| Button::Builder & guillaume::entities::Button::Builder::withIconStyle | ( | const components::Glyph::Style & | iconStyle | ) |
Set the glyph style of the icon.
| iconStyle | The glyph style. Default: Glyph::Style::Outlined. |
Definition at line 75 of file button.cpp.
| Button::Builder & guillaume::entities::Button::Builder::withLabel | ( | const std::string & | labelContent | ) |
Set the label text.
| labelContent | The text shown in the button. Default: empty. It is also the accessibility label when none is set. |
Definition at line 82 of file button.cpp.

| Button::Builder & guillaume::entities::Button::Builder::withMorph | ( | const bool & | isMorph | ) |
Choose whether a selected toggle button swaps its shape (Round becomes Square and Square becomes Round).
| isMorph | True to swap the shape while selected. Default: false. It has no effect on a button that is not a toggle. |
Definition at line 119 of file button.cpp.
| Button::Builder & guillaume::entities::Button::Builder::withOnClick | ( | std::function< void(void)> | onClick | ) |
Set the click handler.
| onClick | The function called when the user clicks the button. Default: empty, nothing is called. |
Definition at line 89 of file button.cpp.
| Button::Builder & guillaume::entities::Button::Builder::withShape | ( | const Shape & | shape | ) |
Set the corner shape.
| shape | The corner shape. Default: Shape::Round. |
Definition at line 107 of file button.cpp.
| Button::Builder & guillaume::entities::Button::Builder::withSize | ( | const Size & | size | ) |
Set the size.
| size | The size. Default: Size::Small. |
Definition at line 113 of file button.cpp.
| Button::Builder & guillaume::entities::Button::Builder::withToggle | ( | const bool & | isToggle | ) |
Make the button a toggle: each click flips its selected state.
| isToggle | True for a toggle button. Default: false. |
Definition at line 95 of file button.cpp.
| Button::Builder & guillaume::entities::Button::Builder::withTrailingIcon | ( | const bool & | isTrailingIcon | ) |
Choose the side of the icon.
| isTrailingIcon | True to place the icon after the label, false to place it before. Default: false. |
Definition at line 132 of file button.cpp.