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

Turns the bound of an entity into the rectangle the engine clips drawing to. More...

#include <headers/guillaume/systems/clip.hpp>

Inheritance diagram for guillaume::systems::Clip:
Collaboration diagram for guillaume::systems::Clip:

Public Member Functions

 Clip (utility::Engine &engine)
 Create the system in the Layout phase.
 ~Clip (void) override=default
 Destroy the system. The engine scissor is left as it is.
void prepare (void) override
 Clear the engine scissor. Called once per frame before the entities are visited, so a frame without any enabled clip draws unclipped.
void update (const ecs::Entity::Identifier &entityIdentifier) override
 Resolve the clip rectangle of one entity, store it in its components::Clip and make it the engine scissor.
Public Member Functions inherited from guillaume::ecs::SystemFiller< components::Transform, components::Bound, components::Clip >
 SystemFiller (Phase phase)
 Create the system and set its signature from ComponentTypes.
virtual ~SystemFiller (void)=default
 Virtual destructor.
Public Member Functions inherited from guillaume::ecs::System
 System (Phase phase)
 Create a system that runs in a given phase, with an empty signature.
virtual ~System (void)=default
 Virtual destructor.
Phase getPhase (void) const noexcept
 Get the phase of the frame in which the system runs.
Entity::Signature getSignature (void) const noexcept
 Get the component types an entity must declare to be visited by this system.
void routine (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry, const ecs::EntityTreeTraveler &traveler)
 Run the system once over a scene: prepare(), update() on each matching entity, cleanup().
void bindComponentRegistry (ecs::ComponentRegistry &componentRegistry)
 Bind a component registry so update() can be called directly, without routine().
void unbindComponentRegistry (void)
 Drop the binding made by bindComponentRegistry().
virtual void cleanup (void)
 Called once per pass, after the last update().

Static Public Member Functions

static components::Clip::Rect computeRect (const utility::graphic::PoseF &pose, float width, float height, float margin)
 Compute a clip rectangle from the pose and size of a bound.

Additional Inherited Members

Protected Member Functions inherited from guillaume::ecs::System
template<InheritFromComponent... ComponentTypes>
void setSignature (void)
 Replace the signature by the one made of the given component types.
ecs::EntityRegistry & getEntityRegistry (void)
 Get the entity registry of the scene being processed.
const ecs::EntityRegistry & getEntityRegistry (void) const
 Get the entity registry of the scene being processed, read-only.
ecs::ComponentRegistry & getComponentRegistry (void)
 Get the component registry of the scene being processed.
const ecs::ComponentRegistry & getComponentRegistry (void) const
 Get the component registry of the scene being processed, read-only.
template<InheritFromComponent ComponentType>
bool hasComponent (const ecs::Entity::Identifier &entityIdentifier) const
 Tell whether an entity has a component, in the bound registry.
template<InheritFromComponent ComponentType>
ComponentType & getComponent (const ecs::Entity::Identifier &entityIdentifier)
 Get a component of an entity from the bound registry, to read or modify it.
template<InheritFromComponent ComponentType>
const ComponentType & getComponent (const ecs::Entity::Identifier &entityIdentifier) const
 Get a component of an entity from the bound registry, read-only.
template<InheritFromComponent ComponentType>
bool requireComponent (const ecs::Entity::Identifier &entityIdentifier)
 Tell whether an entity has a component, and log a warning naming the entity and the component when it does not.

Detailed Description

Turns the bound of an entity into the rectangle the engine clips drawing to.

Runs in the Layout phase on entities with Transform, Bound and Clip.

The scissor is cleared once per frame in prepare(), then set by each enabled clip entity. The render systems that run later in the frame draw with whatever scissor is left.

Things to know:

  • The engine has one scissor. With several enabled clip entities the last one visited wins, and it applies to everything drawn, not only to the descendants of that entity.
  • The rectangle is axis-aligned: it is built from the X and Y of the position and ignores the orientation.
  • This system is registered before systems::Layout, which runs in the same phase. It therefore reads the Transform and Bound as the previous frame left them.
See also
components::Clip

Definition at line 65 of file clip.hpp.

Constructor & Destructor Documentation

◆ Clip()

guillaume::systems::Clip::Clip ( utility::Engine & engine)

Create the system in the Layout phase.

Parameters
engineThe engine that receives the scissor rectangle. It must outlive the system.

Definition at line 27 of file clip.cpp.

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

Member Function Documentation

◆ computeRect()

components::Clip::Rect guillaume::systems::Clip::computeRect ( const utility::graphic::PoseF & pose,
float width,
float height,
float margin )
static

Compute a clip rectangle from the pose and size of a bound.

The rectangle starts at the X and Y of the pose and is shrunk by margin on its four sides. The orientation is ignored.

Parameters
posePose of the top-left corner of the bound.
widthWidth of the bound, in dp.
heightHeight of the bound, in dp.
marginInset applied to each side, in dp. A negative value grows the rectangle.
Returns
The rectangle. Its width or height is negative when the margin exceeds half the matching size.

Definition at line 40 of file clip.cpp.

Here is the caller graph for this function:

◆ prepare()

void guillaume::systems::Clip::prepare ( void )
overridevirtual

Clear the engine scissor. Called once per frame before the entities are visited, so a frame without any enabled clip draws unclipped.

Reimplemented from guillaume::ecs::System.

Definition at line 34 of file clip.cpp.

◆ update()

void guillaume::systems::Clip::update ( const ecs::Entity::Identifier & entityIdentifier)
overridevirtual

Resolve the clip rectangle of one entity, store it in its components::Clip and make it the engine scissor.

Parameters
entityIdentifierThe entity to resolve. It is skipped when its clip is disabled, and skipped with a log message when one of the three components is missing.

Implements guillaume::ecs::System.

Definition at line 53 of file clip.cpp.

Here is the call graph for this function:

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