guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::entities::Snackbar::Builder Class Reference

Configures a Snackbar, then builds it and registers it in the entity registry given at construction. More...

#include <headers/guillaume/entities/snackbar.hpp>

Inheritance diagram for guillaume::entities::Snackbar::Builder:
Collaboration diagram for guillaume::entities::Snackbar::Builder:

Public Member Functions

 Builder (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Create a builder set to the defaults of reset().
std::shared_ptr< Snackbar > buildEntity (void) override
 Build a snackbar and its children from the current configuration, without registering it or setting its parent.
void reset (void) override
 Restore the defaults: SingleLine variant, no message, no action label, shown, DurationMedium (7 seconds), no handler, a default pose and a 344 dp wide bar.
Builder & withPose (const utility::graphic::PoseF &pose)
 Set the pose the snackbar is created with.
Builder & withVariant (Variant variant)
 Set the snackbar variant.
Builder & withMessage (const std::string &message)
 Set the message.
Builder & withAction (const std::string &action)
 Set the label of the action.
Builder & withVisible (bool visible)
 Choose whether the snackbar is shown once built.
Builder & withDuration (float seconds)
 Set how long the snackbar stays shown (Paper duration).
Builder & withOnDismiss (std::function< void(void)> onDismiss)
 Set the handler called when the snackbar dismisses itself (see Snackbar::setOnDismiss()).
Builder & withOnAction (std::function< void(void)> onAction)
 Set the handler called when the action is pressed (Paper action.onPress).
std::shared_ptr< Snackbar > makeSnackbar (std::shared_ptr< ecs::Entity > parent, Variant variant, const std::string &message, const std::string &action="")
 Build a snackbar, register it under parent and reset the builder.
Public Member Functions inherited from guillaume::entities::EntityBuilderBase< Snackbar >
 EntityBuilderBase (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder bound to two registries.
 ~EntityBuilderBase (void) override=default
 Default destructor.
std::shared_ptr< Snackbar > 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.

Detailed Description

Configures a Snackbar, then builds it and registers it in the entity registry given at construction.

Definition at line 131 of file snackbar.hpp.

Constructor & Destructor Documentation

◆ Builder()

guillaume::entities::Snackbar::Builder::Builder ( ecs::ComponentRegistry & componentRegistry,
ecs::EntityRegistry & entityRegistry )

Create a builder set to the defaults of reset().

Parameters
componentRegistryThe registry the snackbar's components are created in.
entityRegistryThe registry the built snackbars are added to.

Definition at line 37 of file snackbar.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ buildEntity()

std::shared_ptr< Snackbar > guillaume::entities::Snackbar::Builder::buildEntity ( void )
overridevirtual

Build a snackbar and its children from the current configuration, without registering it or setting its parent.

Returns
The new snackbar.
Exceptions
std::invalid_argumentIf the duration given to withDuration() is negative.

Implements guillaume::entities::EntityBuilderBase< Snackbar >.

Definition at line 44 of file snackbar.cpp.

Here is the call graph for this function:

◆ makeSnackbar()

std::shared_ptr< Snackbar > guillaume::entities::Snackbar::Builder::makeSnackbar ( std::shared_ptr< ecs::Entity > parent,
Variant variant,
const std::string & message,
const std::string & action = "" )

Build a snackbar, register it under parent and reset the builder.

The arguments replace the variant, message and action label set before; the other settings are kept.

Parameters
parentThe entity the snackbar is attached to.
variantThe snackbar variant.
messageThe message text.
actionThe action label, used by the WithAction variant only.
Returns
The registered snackbar.
Exceptions
std::invalid_argumentIf the duration given to withDuration() is negative.

Definition at line 128 of file snackbar.cpp.

Here is the call graph for this function:

◆ reset()

void guillaume::entities::Snackbar::Builder::reset ( void )
overridevirtual

Restore the defaults: SingleLine variant, no message, no action label, shown, DurationMedium (7 seconds), no handler, a default pose and a 344 dp wide bar.

Implements guillaume::ecs::EntityBuilder.

Definition at line 55 of file snackbar.cpp.

Here is the caller graph for this function:

◆ withAction()

Snackbar::Builder & guillaume::entities::Snackbar::Builder::withAction ( const std::string & action)

Set the label of the action.

Parameters
actionThe label. Used by the WithAction variant only; an empty label builds no action. Default: empty.
Returns
This builder, for chaining.

Definition at line 96 of file snackbar.cpp.

◆ withDuration()

Snackbar::Builder & guillaume::entities::Snackbar::Builder::withDuration ( float seconds)

Set how long the snackbar stays shown (Paper duration).

Parameters
secondsThe display time, in seconds; 0 never dismisses. Default: DurationMedium. A negative value makes the build throw.
Returns
This builder, for chaining.

Definition at line 108 of file snackbar.cpp.

◆ withMessage()

Snackbar::Builder & guillaume::entities::Snackbar::Builder::withMessage ( const std::string & message)

Set the message.

Parameters
messageThe message text. Default: empty, which builds no message child.
Returns
This builder, for chaining.

Definition at line 90 of file snackbar.cpp.

◆ withOnAction()

Snackbar::Builder & guillaume::entities::Snackbar::Builder::withOnAction ( std::function< void(void)> onAction)

Set the handler called when the action is pressed (Paper action.onPress).

Parameters
onActionThe handler. Default: none.
Returns
This builder, for chaining.

Definition at line 122 of file snackbar.cpp.

◆ withOnDismiss()

Snackbar::Builder & guillaume::entities::Snackbar::Builder::withOnDismiss ( std::function< void(void)> onDismiss)

Set the handler called when the snackbar dismisses itself (see Snackbar::setOnDismiss()).

Parameters
onDismissThe handler. Default: none.
Returns
This builder, for chaining.

Definition at line 115 of file snackbar.cpp.

◆ withPose()

Snackbar::Builder & guillaume::entities::Snackbar::Builder::withPose ( const utility::graphic::PoseF & pose)

Set the pose the snackbar is created with.

Parameters
poseThe position and orientation of the bar. Default: a default-constructed pose.
Returns
This builder, for chaining.

Definition at line 77 of file snackbar.cpp.

◆ withVariant()

Snackbar::Builder & guillaume::entities::Snackbar::Builder::withVariant ( Variant variant)

Set the snackbar variant.

Parameters
variantThe variant. Default: Variant::SingleLine.
Returns
This builder, for chaining.

Definition at line 83 of file snackbar.cpp.

Here is the caller graph for this function:

◆ withVisible()

Snackbar::Builder & guillaume::entities::Snackbar::Builder::withVisible ( bool visible)

Choose whether the snackbar is shown once built.

Parameters
visibleTrue to show it at once, false to build it hidden. Default: true.
Returns
This builder, for chaining.

Definition at line 102 of file snackbar.cpp.


The documentation for this class was generated from the following files: