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

Configures, creates and registers SegmentedButton widgets. More...

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

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

Public Member Functions

 Builder (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder with the default configuration (see reset()).
std::shared_ptr< SegmentedButton > buildEntity (void) override
 Build a SegmentedButton, with one button per segment, from the current configuration, without registering it.
void reset (void) override
 Restore the default configuration.
Builder & withLabels (const std::vector< std::string > &labels)
 Describe the segments by their labels only.
Builder & withSelectionMode (const SelectionMode &selectionMode)
 Set the selection mode.
Builder & withOnChange (std::function< void(std::size_t)> onChange)
 Set the change handler.
Builder & withSegments (const std::vector< Segment > &segments)
 Describe the segments one by one (label, icon, disabled, accessibility label).
std::shared_ptr< SegmentedButton > makeSegmentedButton (std::shared_ptr< Entity > parent, const std::vector< std::string > &labels, SelectionMode selectionMode, std::function< void(std::size_t)> onChange)
 Build a segmented button from labels, register it under parent and reset the builder.
Public Member Functions inherited from guillaume::entities::EntityBuilderBase< SegmentedButton >
 EntityBuilderBase (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder bound to two registries.
 ~EntityBuilderBase (void) override=default
 Default destructor.
std::shared_ptr< SegmentedButton > 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, creates and registers SegmentedButton widgets.

Describe the segments with withLabels() or withSegments(), then call registerEntity(), or use makeSegmentedButton() to do both in one call.

Definition at line 114 of file segmented_button.hpp.

Constructor & Destructor Documentation

◆ Builder()

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

Construct a builder with the default configuration (see reset()).

Parameters
componentRegistryThe registry that stores the components of the segmented buttons to build.
entityRegistryThe registry the built segmented buttons are added to (usually the scene's).

Definition at line 55 of file segmented_button.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ buildEntity()

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

Build a SegmentedButton, with one button per segment, from the current configuration, without registering it.

The segments come from withSegments() when it was given a non-empty list, from withLabels() otherwise. registerEntity() calls this function, then sets the parent, registers the segmented button and resets the builder.

Returns
The new segmented button.

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

Definition at line 62 of file segmented_button.cpp.

Here is the call graph for this function:

◆ makeSegmentedButton()

std::shared_ptr< SegmentedButton > guillaume::entities::SegmentedButton::Builder::makeSegmentedButton ( std::shared_ptr< Entity > parent,
const std::vector< std::string > & labels,
SelectionMode selectionMode,
std::function< void(std::size_t)> onChange )

Build a segmented button from labels, register it under parent and reset the builder.

Segments given earlier to withSegments() still take the place of labels.

Parameters
parentThe entity the segmented button becomes a child of.
labelsOne label per segment, in display order.
selectionModeSingle or Multi selection.
onChangeThe function called with the index of the segment the user pressed (may be empty).
Returns
The new segmented button, with no segment selected, registered in the entity registry.

Definition at line 111 of file segmented_button.cpp.

Here is the call graph for this function:

◆ reset()

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

Restore the default configuration.

Defaults: no label, no segment configuration, SelectionMode::Single, no change handler.

Implements guillaume::ecs::EntityBuilder.

Definition at line 74 of file segmented_button.cpp.

Here is the caller graph for this function:

◆ withLabels()

SegmentedButton::Builder & guillaume::entities::SegmentedButton::Builder::withLabels ( const std::vector< std::string > & labels)

Describe the segments by their labels only.

Parameters
labelsOne label per segment, in display order. Each segment has no icon and is enabled. Default: empty. Ignored when withSegments() was given a non-empty list.
Returns
Reference to the builder for chaining.

Definition at line 82 of file segmented_button.cpp.

Here is the caller graph for this function:

◆ withOnChange()

SegmentedButton::Builder & guillaume::entities::SegmentedButton::Builder::withOnChange ( std::function< void(std::size_t)> onChange)

Set the change handler.

Parameters
onChangeThe function called with the index of the segment the user pressed, after the selection was updated. Default: empty, nothing is called.
Returns
Reference to the builder for chaining.

Definition at line 103 of file segmented_button.cpp.

◆ withSegments()

SegmentedButton::Builder & guillaume::entities::SegmentedButton::Builder::withSegments ( const std::vector< Segment > & segments)

Describe the segments one by one (label, icon, disabled, accessibility label).

Parameters
segmentsOne configuration per segment, in display order. When not empty, it is used in place of the labels given to withLabels(). Default: empty.
Returns
Reference to the builder for chaining.

Definition at line 96 of file segmented_button.cpp.

◆ withSelectionMode()

SegmentedButton::Builder & guillaume::entities::SegmentedButton::Builder::withSelectionMode ( const SelectionMode & selectionMode)

Set the selection mode.

Parameters
selectionModeSelectionMode::Single to keep at most one segment selected, SelectionMode::Multi to let each segment toggle on its own. Default: SelectionMode::Single.
Returns
Reference to the builder for chaining.

Definition at line 89 of file segmented_button.cpp.


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