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

Asks that drawing be cut to the entity's rectangle, and holds the rectangle that results. More...

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

Inheritance diagram for guillaume::components::Clip:
Collaboration diagram for guillaume::components::Clip:

Classes

struct  Rect
 The clip rectangle, in the same coordinates as the position of a components::Transform. More...

Public Member Functions

 Clip (void)=default
 Default constructor for the Clip component.
 ~Clip (void)=default
 Default destructor for the Clip component.
float getMargin (void) const
 Get the inset between the bound and the clip rectangle.
Clip & setMargin (float margin)
 Set the inset between the bound and the clip rectangle.
bool isEnabled (void) const
 Check whether systems::Clip processes this entity.
Clip & setEnabled (bool enabled)
 Turn clipping on or off without removing the component.
const Rect & getRect (void) const
 Get the rectangle computed by systems::Clip.
Clip & setRect (const Rect &rect)
 Store the computed rectangle. Called by systems::Clip; a value set by hand is replaced on the next frame.
Public Member Functions inherited from guillaume::ecs::Component
bool hasChanged (void) const
 Tell whether a value of the component changed since the flags were last reset (the end of the previous frame).
void setHasChanged (bool hasChanged)
 Raise or lower the changed flag.
 Component (void)=default
 Create a component that is not marked as changed.
virtual ~Component (void)=default
 Virtual destructor, so components can be destroyed through the base class.

Detailed Description

Asks that drawing be cut to the entity's rectangle, and holds the rectangle that results.

The application or a widget sets the margin and the enabled flag. systems::Clip (Layout phase) reads them with the entity's Transform and Bound, computes the rectangle (the bound shrunk by the margin on every side), stores it with setRect() and gives it to the engine as the scissor rectangle.

registry.addComponent<components::Clip>(id).setMargin(8.0f);
Asks that drawing be cut to the entity's rectangle, and holds the rectangle that results.
Definition clip.hpp:53
Clip & setMargin(float margin)
Set the inset between the bound and the clip rectangle.
Definition clip.cpp:32
Note
The rectangle is overwritten every frame while the clip is enabled; while it is disabled the system skips the entity and the rectangle keeps its last value.
The rectangle is built from the X and Y of the position only: the orientation of the entity is ignored.
See also
systems::Clip

Definition at line 52 of file clip.hpp.

Member Function Documentation

◆ getMargin()

float guillaume::components::Clip::getMargin ( void ) const

Get the inset between the bound and the clip rectangle.

Returns
The margin, in dp, removed on every side (0 by default).

Definition at line 27 of file clip.cpp.

◆ getRect()

const Clip::Rect & guillaume::components::Clip::getRect ( void ) const

Get the rectangle computed by systems::Clip.

Returns
The rectangle of the last frame the clip was enabled; a rectangle of zeros before the system ran once.

Definition at line 57 of file clip.cpp.

◆ isEnabled()

bool guillaume::components::Clip::isEnabled ( void ) const

Check whether systems::Clip processes this entity.

Returns
True when clipping is enabled (the default).

Definition at line 42 of file clip.cpp.

◆ setEnabled()

Clip & guillaume::components::Clip::setEnabled ( bool enabled)

Turn clipping on or off without removing the component.

Marks the component changed only when the value differs.

Parameters
enabledFalse to make systems::Clip skip this entity.
Returns
This component, for chaining.

Definition at line 47 of file clip.cpp.

Here is the call graph for this function:

◆ setMargin()

Clip & guillaume::components::Clip::setMargin ( float margin)

Set the inset between the bound and the clip rectangle.

Marks the component changed only when the value differs.

Parameters
marginThe margin, in dp, removed on every side. A negative value makes the rectangle larger than the bound.
Returns
This component, for chaining.

Definition at line 32 of file clip.cpp.

Here is the call graph for this function:

◆ setRect()

Clip & guillaume::components::Clip::setRect ( const Rect & rect)

Store the computed rectangle. Called by systems::Clip; a value set by hand is replaced on the next frame.

Marks the component changed only when the rectangle differs.

Parameters
rectThe clip rectangle, in dp.
Returns
This component, for chaining.

Definition at line 62 of file clip.cpp.

Here is the call graph for this function:

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