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

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

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

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

Public Member Functions

 Builder (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder holding the defaults of reset().
std::shared_ptr< Card > buildEntity (void) override
 Build an empty card from the current configuration, without registering it or giving it a parent.
void reset (void) override
 Restore the defaults: default pose, the Elevated variant, no press handler, enabled, the Medium shape radius of the active theme, a fixed width of 240 dp, no fixed height, and a vertical layout with 16 dp of padding and 8 dp between sections.
Builder & withPose (const utility::graphic::PoseF &pose)
 Set where the card is.
Builder & withVariant (Variant variant)
 Choose the look of the card.
Builder & withWidth (float width)
 Set the width of the card.
Builder & withHeight (float height)
 Force the height of the card.
Builder & withBorderRadius (float radius)
 Set the corner radius.
Builder & withOnPress (std::function< void(void)> onPress)
 Make the built card pressable.
Builder & withDisabled (bool disabled)
 Build the card disabled or enabled.
std::shared_ptr< Card > makeCard (std::shared_ptr< ecs::Entity > parent, Variant variant)
 Build an empty card, register it under parent and reset the builder.
Public Member Functions inherited from guillaume::entities::EntityBuilderBase< Card >
 EntityBuilderBase (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder bound to two registries.
 ~EntityBuilderBase (void) override=default
 Default destructor.
std::shared_ptr< Card > 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 Card widgets and registers them in the scene's entity registry.

Definition at line 127 of file card.hpp.

Constructor & Destructor Documentation

◆ Builder()

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

Construct a builder holding the defaults of reset().

Parameters
componentRegistryThe registry the components of the built cards are stored in.
entityRegistryThe registry that owns the cards built by makeCard.

Definition at line 70 of file card.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ buildEntity()

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

Build an empty card from the current configuration, without registering it or giving it a parent.

Returns
The new card.

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

Definition at line 77 of file card.cpp.

Here is the call graph for this function:

◆ makeCard()

std::shared_ptr< Card > guillaume::entities::Card::Builder::makeCard ( std::shared_ptr< ecs::Entity > parent,
Variant variant )

Build an empty card, register it under parent and reset the builder.

The pose, size, radius, press handler and disabled state set with the with... methods apply. Compose the content on the returned card with setCover(), setTitle(), setContent() and addAction().

Parameters
parentThe entity the card is attached to, or nullptr for a root entity.
variantThe look: Elevated, Filled or Outlined.
Returns
The registered card.

Definition at line 146 of file card.cpp.

Here is the call graph for this function:

◆ reset()

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

Restore the defaults: default pose, the Elevated variant, no press handler, enabled, the Medium shape radius of the active theme, a fixed width of 240 dp, no fixed height, and a vertical layout with 16 dp of padding and 8 dp between sections.

Implements guillaume::ecs::EntityBuilder.

Definition at line 88 of file card.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ withBorderRadius()

Card::Builder & guillaume::entities::Card::Builder::withBorderRadius ( float radius)

Set the corner radius.

Parameters
radiusThe radius of the four corners, in dp. By default the Medium shape radius the active theme had when the builder was last reset.
Returns
Reference to this builder for chaining.

Definition at line 127 of file card.cpp.

◆ withDisabled()

Card::Builder & guillaume::entities::Card::Builder::withDisabled ( bool disabled)

Build the card disabled or enabled.

Parameters
disabledTrue for a card that ignores presses. False by default.
Returns
Reference to this builder for chaining.

Definition at line 139 of file card.cpp.

◆ withHeight()

Card::Builder & guillaume::entities::Card::Builder::withHeight ( float height)

Force the height of the card.

Parameters
heightThe fixed height, in dp. By default the height follows the sections.
Returns
Reference to this builder for chaining.

Definition at line 120 of file card.cpp.

◆ withOnPress()

Card::Builder & guillaume::entities::Card::Builder::withOnPress ( std::function< void(void)> onPress)

Make the built card pressable.

Parameters
onPressThe function called when the user presses the card. An empty function, the default, builds a passive card.
Returns
Reference to this builder for chaining.

Definition at line 133 of file card.cpp.

◆ withPose()

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

Set where the card is.

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

Definition at line 101 of file card.cpp.

◆ withVariant()

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

Choose the look of the card.

Parameters
variantElevated, Filled or Outlined. Elevated by default.
Returns
Reference to this builder for chaining.

Definition at line 107 of file card.cpp.

Here is the caller graph for this function:

◆ withWidth()

Card::Builder & guillaume::entities::Card::Builder::withWidth ( float width)

Set the width of the card.

Parameters
widthThe fixed width, in dp. 240 by default. The sections are sized from it.
Returns
Reference to this builder for chaining.

Definition at line 113 of file card.cpp.


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