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

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

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

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

Public Member Functions

 Builder (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder holding the defaults of reset().
std::shared_ptr< View > buildEntity (void) override
 Build a view from the current configuration, without registering it or giving it a parent.
void reset (void) override
 Restore the defaults: default pose, transparent background, corner radius 16 dp, horizontal axis, main axis alignment Start, cross axis alignment Center, spacing 8 dp, padding 16 dp, no fixed width or height, and no entity.
Builder & withPose (const utility::graphic::PoseF &pose)
 Set where the view is.
Builder & withColor (const utility::graphic::Color32Bit &color)
 Set the background color.
Builder & withBorderRadius (float borderRadius)
 Set the corner radius of the background.
Builder & withAxis (Axis axis)
 Choose between a row and a column.
Builder & withMainAxisAlignment (MainAxisAlignment alignment)
 Set how the children are distributed along the axis.
Builder & withCrossAxisAlignment (CrossAxisAlignment alignment)
 Set how each child is aligned across the axis.
Builder & withSpacing (float spacing)
 Set the gap between two consecutive children.
Builder & withPadding (float padding)
 Set the space between the edges of the view and its children.
Builder & withFixedWidth (float width)
 Force the width of the view.
Builder & withFixedHeight (float height)
 Force the height of the view.
Builder & withEntities (const std::vector< std::shared_ptr< ecs::Entity > > &entities)
 Set the entities the view arranges, in layout order.
std::shared_ptr< View > makeDefaultView (std::shared_ptr< Entity > parent, const utility::graphic::PoseF &pose, const std::vector< std::shared_ptr< ecs::Entity > > &entities)
 Build a transparent view, register it under parent and reset the builder.
std::shared_ptr< View > makeColorView (std::shared_ptr< Entity > parent, const utility::graphic::PoseF &pose, const utility::graphic::Color32Bit &color, const std::vector< std::shared_ptr< ecs::Entity > > &entities)
 Build a view with a background color, register it under parent and reset the builder.
Public Member Functions inherited from guillaume::entities::EntityBuilderBase< View >
 EntityBuilderBase (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder bound to two registries.
 ~EntityBuilderBase (void) override=default
 Default destructor.
std::shared_ptr< View > 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 View widgets and registers them in the scene's entity registry.

Definition at line 117 of file view.hpp.

Constructor & Destructor Documentation

◆ Builder()

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

Construct a builder holding the defaults of reset().

Parameters
componentRegistryThe registry the components of the built views are stored in.
entityRegistryThe registry that owns the views built by the make... methods.

Definition at line 35 of file view.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ buildEntity()

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

Build a view from the current configuration, without registering it or giving it a parent.

The entities of withEntities() are parented to the new view and arranged.

Returns
The new view.

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

Definition at line 42 of file view.cpp.

Here is the call graph for this function:

◆ makeColorView()

std::shared_ptr< View > guillaume::entities::View::Builder::makeColorView ( std::shared_ptr< Entity > parent,
const utility::graphic::PoseF & pose,
const utility::graphic::Color32Bit & color,
const std::vector< std::shared_ptr< ecs::Entity > > & entities )

Build a view with a background color, register it under parent and reset the builder.

Parameters
parentThe entity the view is attached to, or nullptr for a root entity.
poseThe pose of the top-left corner of the view.
colorThe background color (RGBA).
entitiesThe entities to arrange, in layout order. They are parented to the view; each must be owned by an entity registry. May be empty.
Returns
The registered view.

Definition at line 148 of file view.cpp.

Here is the call graph for this function:

◆ makeDefaultView()

std::shared_ptr< View > guillaume::entities::View::Builder::makeDefaultView ( std::shared_ptr< Entity > parent,
const utility::graphic::PoseF & pose,
const std::vector< std::shared_ptr< ecs::Entity > > & entities )

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

The background stays transparent unless withColor() was called. The other settings of the with... methods apply.

Parameters
parentThe entity the view is attached to, or nullptr for a root entity.
poseThe pose of the top-left corner of the view.
entitiesThe entities to arrange, in layout order. They are parented to the view; each must be owned by an entity registry. May be empty.
Returns
The registered view.

Definition at line 141 of file view.cpp.

Here is the call graph for this function:

◆ reset()

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

Restore the defaults: default pose, transparent background, corner radius 16 dp, horizontal axis, main axis alignment Start, cross axis alignment Center, spacing 8 dp, padding 16 dp, no fixed width or height, and no entity.

Implements guillaume::ecs::EntityBuilder.

Definition at line 52 of file view.cpp.

Here is the caller graph for this function:

◆ withAxis()

View::Builder & guillaume::entities::View::Builder::withAxis ( Axis axis)

Choose between a row and a column.

Parameters
axisHorizontal to arrange the children left to right, Vertical for top to bottom. Horizontal by default.
Returns
Reference to this builder for chaining.

Definition at line 88 of file view.cpp.

◆ withBorderRadius()

View::Builder & guillaume::entities::View::Builder::withBorderRadius ( float borderRadius)

Set the corner radius of the background.

Parameters
borderRadiusThe radius of the four corners, in dp. 16 by default.
Returns
Reference to this builder for chaining.

Definition at line 82 of file view.cpp.

◆ withColor()

View::Builder & guillaume::entities::View::Builder::withColor ( const utility::graphic::Color32Bit & color)

Set the background color.

Parameters
colorThe color (RGBA). Transparent by default.
Returns
Reference to this builder for chaining.

Definition at line 76 of file view.cpp.

◆ withCrossAxisAlignment()

View::Builder & guillaume::entities::View::Builder::withCrossAxisAlignment ( CrossAxisAlignment alignment)

Set how each child is aligned across the axis.

Parameters
alignmentStart, Center or End. Center by default.
Returns
Reference to this builder for chaining.

Definition at line 102 of file view.cpp.

◆ withEntities()

View::Builder & guillaume::entities::View::Builder::withEntities ( const std::vector< std::shared_ptr< ecs::Entity > > & entities)

Set the entities the view arranges, in layout order.

The builder keeps the pointers only until the view is built. The view does not own them either: each entity must be owned by an entity registry.

Parameters
entitiesThe entities to arrange. Null entries are skipped. Empty by default.
Returns
Reference to this builder for chaining.

Definition at line 134 of file view.cpp.

◆ withFixedHeight()

View::Builder & guillaume::entities::View::Builder::withFixedHeight ( float height)

Force the height of the view.

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

Definition at line 127 of file view.cpp.

◆ withFixedWidth()

View::Builder & guillaume::entities::View::Builder::withFixedWidth ( float width)

Force the width of the view.

Parameters
widthThe width, in dp. By default the width follows the children.
Returns
Reference to this builder for chaining.

Definition at line 120 of file view.cpp.

◆ withMainAxisAlignment()

View::Builder & guillaume::entities::View::Builder::withMainAxisAlignment ( MainAxisAlignment alignment)

Set how the children are distributed along the axis.

Parameters
alignmentStart, Center, End or SpaceBetween. Start by default. It only shows when the view is larger than its content, that is with a fixed size on that axis.
Returns
Reference to this builder for chaining.

Definition at line 95 of file view.cpp.

◆ withPadding()

View::Builder & guillaume::entities::View::Builder::withPadding ( float padding)

Set the space between the edges of the view and its children.

Parameters
paddingThe padding, in dp, the same on the four sides. 16 by default.
Returns
Reference to this builder for chaining.

Definition at line 114 of file view.cpp.

◆ withPose()

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

Set where the view is.

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

Definition at line 69 of file view.cpp.

Here is the caller graph for this function:

◆ withSpacing()

View::Builder & guillaume::entities::View::Builder::withSpacing ( float spacing)

Set the gap between two consecutive children.

Parameters
spacingThe gap, in dp. 8 by default.
Returns
Reference to this builder for chaining.

Definition at line 108 of file view.cpp.


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