guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
clip.hpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#pragma once
24
25#include "guillaume/ecs/component.hpp"
26
28{
29
52 class Clip: public ecs::Component
53 {
54 public:
59 struct Rect {
60 float x { 0.0f };
61 float y { 0.0f };
62 float width { 0.0f };
63 float height { 0.0f };
64
70 bool operator==(const Rect &other) const
71 {
72 return x == other.x && y == other.y && width == other.width
73 && height == other.height;
74 }
75 };
76
77 private:
78 float _margin { 0.0f };
79 bool _enabled { true };
80 Rect _rect {};
81
82 public:
86 Clip(void) = default;
87
91 ~Clip(void) = default;
92
97 float getMargin(void) const;
98
108 Clip &setMargin(float margin);
109
114 bool isEnabled(void) const;
115
124 Clip &setEnabled(bool enabled);
125
131 const Rect &getRect(void) const;
132
142 Clip &setRect(const Rect &rect);
143 };
144
145} // namespace guillaume::components
Clip & setEnabled(bool enabled)
Turn clipping on or off without removing the component.
Definition clip.cpp:47
float getMargin(void) const
Get the inset between the bound and the clip rectangle.
Definition clip.cpp:27
const Rect & getRect(void) const
Get the rectangle computed by systems::Clip.
Definition clip.cpp:57
bool isEnabled(void) const
Check whether systems::Clip processes this entity.
Definition clip.cpp:42
~Clip(void)=default
Default destructor for the Clip component.
Clip & setMargin(float margin)
Set the inset between the bound and the clip rectangle.
Definition clip.cpp:32
Clip & setRect(const Rect &rect)
Store the computed rectangle. Called by systems::Clip; a value set by hand is replaced on the next fr...
Definition clip.cpp:62
Clip(void)=default
Default constructor for the Clip component.
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
Definition component.hpp:72
State. Every class here is plain data attached to an entity.
The clip rectangle, in the same coordinates as the position of a components::Transform.
Definition clip.hpp:59
bool operator==(const Rect &other) const
Compare the origin and the size of two rectangles.
Definition clip.hpp:70
float height
Height, in dp.
Definition clip.hpp:63
float width
Width, in dp.
Definition clip.hpp:62
float y
Top edge, in dp.
Definition clip.hpp:61
float x
Left edge, in dp.
Definition clip.hpp:60