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

A thin horizontal line separating two pieces of content. More...

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

Inheritance diagram for guillaume::entities::Divider:
Collaboration diagram for guillaume::entities::Divider:

Classes

class  Builder
 Configures Divider widgets and registers them in the scene's entity registry. More...

Public Types

using Variant = components::Divider::Variant
 Which ends of the line are shortened by the inset: FullWidth (none), Inset (leading end) or Middle (both).
Public Types inherited from guillaume::ecs::Entity
using Identifier = std::size_t
 The key under which an entity's components are stored. Systems and components refer to entities by this value.
using Signature = std::bitset<128>
 A set of component types, one bit per type (bit position given by ComponentTypeId, MaxComponentTypes bits).

Public Member Functions

 ~Divider (void) override
 Destructor.
Divider & setVariant (Variant variant)
 Choose which ends of the line are inset. Moves and resizes the line at once.
Divider & setLength (float length)
 Set the total length. Resizes the line at once.
Divider & setThickness (float thickness)
 Set the stroke thickness. Restyles at once.
Divider & setBold (bool bold)
 Switch between the hairline and the bold stroke (Paper bold). Restyles at once.
bool isBold (void) const
 Check whether the divider uses the bold stroke.
Divider & setInset (float inset)
 Set how much an inset end is shortened. Moves and resizes the line at once.
Divider & setColor (const utility::graphic::Color32Bit &color)
 Set the stroke color. Restyles at once.
Variant getVariant (void) const
 Tell which ends of the line are inset.
Public Member Functions inherited from guillaume::ecs::EntityFiller< components::Transform, components::Bound, components::Color, components::Line, components::Divider >
 EntityFiller (ComponentRegistry &componentRegistry)
 Create the entity, its listed components and its components::Hierarchy.
virtual ~EntityFiller (void)=default
 Destroy the entity object; its components stay in the registry (see EntityRegistry::removeEntity).
Public Member Functions inherited from guillaume::ecs::Entity
 Entity (void)
 Create an entity with a fresh identifier, an empty signature, no parent and no component.
virtual ~Entity (void)=default
 Destroy the entity object.
Entity::Identifier getIdentifier (void) const noexcept
 Get the identifier of the entity.
Entity::Signature getSignature (void) const noexcept
 Get the set of component types the entity declares.
void setSignature (const Signature &signature)
 Replace the signature of the entity.
std::int32_t getLayer (void) const noexcept
 Get the depth of the entity in the tree.
Entity & setParent (std::shared_ptr< Entity > parent)
 Attach the entity under another one, or detach it.
std::vector< Identifier > releaseComponents (void)
 Drop the entity's place in the tree and all its components.
std::shared_ptr< Entity > getParent (void) const noexcept
 Get the parent entity.

Static Public Member Functions

template<typename... Arguments>
static std::shared_ptr< Divider > create (Arguments &&...arguments)
 Build a divider without registering it in an entity registry.
Static Public Member Functions inherited from guillaume::ecs::Entity
template<InheritFromComponent... ComponentTypes>
static Signature getSignatureFromTypes (void)
 Build the signature that has exactly the bits of the given component types.

Static Public Attributes

static constexpr float HairlineThickness
 Default stroke thickness, in dp: a hairline (Paper StyleSheet.hairlineWidth on a 2x display).
static constexpr float BoldThickness
 Stroke thickness of a bold divider, in dp (Paper bold).
Static Public Attributes inherited from guillaume::ecs::Entity
static constexpr Identifier InvalidIdentifier
 "No entity": never the identifier of a real entity

Additional Inherited Members

Protected Member Functions inherited from guillaume::ecs::EntityFiller< components::Transform, components::Bound, components::Color, components::Line, components::Divider >
ComponentRegistry & getComponentRegistry (void)
 Get the registry that stores this entity's components.
Protected Member Functions inherited from guillaume::ecs::Entity
void attachHierarchy (ComponentRegistry &componentRegistry)
 Give the entity a components::Hierarchy in a registry and add that component to its signature.
template<InheritFromComponent... ComponentTypes>
void setSignature (void)
 Replace the signature by the one made of the given component types.

Detailed Description

A thin horizontal line separating two pieces of content.

Divider is a leaf widget: it has no children. Its state lives in components::Divider (variant, length, thickness, inset, color, origin pose); systems::Divider turns it into the entity's Transform, Bound, Line and Color each frame, in the Measure phase, and systems::LineRender draws the stroke. The class itself holds no field: its setters write the component and run systems::Divider at once.

The variant chooses which ends are shortened by the inset:

  • FullWidth: spans the whole length.
  • Inset: leaves the inset on the leading end.
  • Middle: leaves the inset on both ends.
Divider::Builder builder(getComponentRegistry(), getEntityRegistry());
auto divider = builder.makeDivider(parent, 320.0f,
Divider::Variant::Inset);
divider->setBold(true);
Configures Divider widgets and registers them in the scene's entity registry.
Definition divider.hpp:114

Divider::create(registry, pose, color, length, thickness, inset, variant) builds the same widget without registering it in an entity registry.

Watch out:

  • Lengths, thicknesses and insets are in dp.
  • The Bound, Line thickness and Color of the entity are overwritten every frame from components::Divider: change them with the setters of this class, not by writing those components.
  • The Transform pose is the origin pose shifted by the leading inset. When something else moves the entity (a parent layout for example), the system takes the new position as the drawn start of the line and recomputes the origin from it.
See also
components::Divider, systems::Divider, systems::LineRender

Definition at line 84 of file divider.hpp.

Member Typedef Documentation

◆ Variant

Which ends of the line are shortened by the inset: FullWidth (none), Inset (leading end) or Middle (both).

Definition at line 94 of file divider.hpp.

Constructor & Destructor Documentation

◆ ~Divider()

guillaume::entities::Divider::~Divider ( void )
override

Destructor.

Definition at line 127 of file divider.cpp.

Member Function Documentation

◆ create()

template<typename... Arguments>
std::shared_ptr< Divider > guillaume::entities::Divider::create ( Arguments &&... arguments)
inlinestatic

Build a divider without registering it in an entity registry.

The arguments are forwarded to the private constructor: (registry, pose, color, length, thickness, inset, variant). A divider has no children to build.

Template Parameters
ArgumentsThe constructor argument types.
Parameters
argumentsThe constructor arguments, as listed above.
Returns
The new divider. The caller owns it.

Definition at line 228 of file divider.hpp.

Here is the caller graph for this function:

◆ getVariant()

Divider::Variant guillaume::entities::Divider::getVariant ( void ) const

Tell which ends of the line are inset.

Returns
The variant stored in components::Divider.

Definition at line 193 of file divider.cpp.

◆ isBold()

bool guillaume::entities::Divider::isBold ( void ) const

Check whether the divider uses the bold stroke.

Returns
True when the thickness is at least BoldThickness, whether it was set by setBold() or setThickness().

Definition at line 174 of file divider.cpp.

◆ setBold()

Divider & guillaume::entities::Divider::setBold ( bool bold)

Switch between the hairline and the bold stroke (Paper bold). Restyles at once.

Parameters
boldTrue for BoldThickness (1 dp), false for HairlineThickness (0.5 dp).
Returns
Reference to this divider for chaining.

Definition at line 169 of file divider.cpp.

Here is the call graph for this function:

◆ setColor()

Divider & guillaume::entities::Divider::setColor ( const utility::graphic::Color32Bit & color)

Set the stroke color. Restyles at once.

Parameters
colorThe new color (RGBA).
Returns
Reference to this divider for chaining.

Definition at line 186 of file divider.cpp.

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

◆ setInset()

Divider & guillaume::entities::Divider::setInset ( float inset)

Set how much an inset end is shortened. Moves and resizes the line at once.

Parameters
insetThe new inset, in dp. It has no effect with the FullWidth variant.
Returns
Reference to this divider for chaining.

Definition at line 179 of file divider.cpp.

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

◆ setLength()

Divider & guillaume::entities::Divider::setLength ( float length)

Set the total length. Resizes the line at once.

Parameters
lengthThe new length, insets included, in dp. The drawn line is this length minus the insets of the variant, and never negative.
Returns
Reference to this divider for chaining.

Definition at line 155 of file divider.cpp.

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

◆ setThickness()

Divider & guillaume::entities::Divider::setThickness ( float thickness)

Set the stroke thickness. Restyles at once.

Parameters
thicknessThe new thickness, in dp.
Returns
Reference to this divider for chaining.

Definition at line 162 of file divider.cpp.

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

◆ setVariant()

Divider & guillaume::entities::Divider::setVariant ( Variant variant)

Choose which ends of the line are inset. Moves and resizes the line at once.

Parameters
variantThe new variant.
Returns
Reference to this divider for chaining.

Definition at line 148 of file divider.cpp.

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

Member Data Documentation

◆ BoldThickness

float guillaume::entities::Divider::BoldThickness
staticconstexpr
Initial value:
=
static constexpr float BoldThickness
Thickness of a bold stroke, in dp.
Definition divider.hpp:73

Stroke thickness of a bold divider, in dp (Paper bold).

Definition at line 106 of file divider.hpp.

◆ HairlineThickness

float guillaume::entities::Divider::HairlineThickness
staticconstexpr
Initial value:
=
static constexpr float HairlineThickness
Default stroke thickness, in dp.
Definition divider.hpp:70

Default stroke thickness, in dp: a hairline (Paper StyleSheet.hairlineWidth on a 2x display).

Definition at line 100 of file divider.hpp.


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