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

Configures Switch widgets and registers them in the scene's entity registry. More...

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

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

Public Member Functions

 Builder (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder holding the defaults of reset().
std::shared_ptr< Switch > buildEntity (void) override
 Build a switch and its children from the current configuration, without registering it or giving it a parent.
void reset (void) override
 Restore the defaults: default pose, the Enabled variant, off, no icon, no label, and a 52 x 32 dp track with fully rounded ends.
Builder & withPose (const utility::graphic::PoseF &pose)
 Set where the switch is.
Builder & withVariant (Variant variant)
 Choose whether the switch reacts to input.
Builder & withChecked (bool checked)
 Choose whether the switch starts on.
Builder & withIcon (const std::string &iconGlyph)
 Draw an icon on the thumb.
Builder & withLabel (const std::string &label)
 Set the text shown to the right of the track.
std::shared_ptr< Switch > makeSwitch (std::shared_ptr< ecs::Entity > parent, Variant variant, bool checked, const std::string &iconGlyph, const std::string &label)
 Build a switch and its children, register it under parent and reset the builder.
Public Member Functions inherited from guillaume::entities::EntityBuilderBase< Switch >
 EntityBuilderBase (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder bound to two registries.
 ~EntityBuilderBase (void) override=default
 Default destructor.
std::shared_ptr< Switch > 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 Switch widgets and registers them in the scene's entity registry.

Definition at line 108 of file switch.hpp.

Constructor & Destructor Documentation

◆ Builder()

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

Construct a builder holding the defaults of reset().

Parameters
componentRegistryThe registry the components of the built switches are stored in.
entityRegistryThe registry that owns the switches built by makeSwitch.

Definition at line 92 of file switch.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ buildEntity()

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

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

Returns
The new switch.

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

Definition at line 99 of file switch.cpp.

Here is the call graph for this function:

◆ makeSwitch()

std::shared_ptr< Switch > guillaume::entities::Switch::Builder::makeSwitch ( std::shared_ptr< ecs::Entity > parent,
Variant variant,
bool checked,
const std::string & iconGlyph,
const std::string & label )

Build a switch and its children, register it under parent and reset the builder.

Parameters
parentThe entity the switch is attached to, or nullptr for a root entity.
variantEnabled, Disabled or WithIcon.
checkedTrue to start on, false to start off.
iconGlyphThe Material Symbols name of the thumb icon, or an empty string for no icon.
labelThe text shown to the right of the track, or an empty string for no label.
Returns
The registered switch.

Definition at line 157 of file switch.cpp.

Here is the call graph for this function:

◆ reset()

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

Restore the defaults: default pose, the Enabled variant, off, no icon, no label, and a 52 x 32 dp track with fully rounded ends.

Implements guillaume::ecs::EntityBuilder.

Definition at line 106 of file switch.cpp.

Here is the caller graph for this function:

◆ withChecked()

Switch::Builder & guillaume::entities::Switch::Builder::withChecked ( bool checked)

Choose whether the switch starts on.

Parameters
checkedTrue for on, false for off. Off by default.
Returns
Reference to this builder for chaining.

Definition at line 139 of file switch.cpp.

◆ withIcon()

Switch::Builder & guillaume::entities::Switch::Builder::withIcon ( const std::string & iconGlyph)

Draw an icon on the thumb.

Parameters
iconGlyphThe Material Symbols name of the icon, such as "check". Empty by default, which builds no icon.
Returns
Reference to this builder for chaining.

Definition at line 145 of file switch.cpp.

◆ withLabel()

Switch::Builder & guillaume::entities::Switch::Builder::withLabel ( const std::string & label)

Set the text shown to the right of the track.

Parameters
labelThe label. It is also the accessibility label. Empty by default, which builds no label child.
Returns
Reference to this builder for chaining.

Definition at line 151 of file switch.cpp.

◆ withPose()

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

Set where the switch is.

Parameters
poseThe pose of the top-left corner of the track. A default-constructed pose by default.
Returns
Reference to this builder for chaining.

Definition at line 127 of file switch.cpp.

◆ withVariant()

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

Choose whether the switch reacts to input.

Parameters
variantEnabled, Disabled or WithIcon. Enabled by default.
Returns
Reference to this builder for chaining.

Definition at line 133 of file switch.cpp.

Here is the caller graph for this function:

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