11 V_CONSTEXPR VRect(int left, int top, int width, int height);
12 V_CONSTEXPR inline bool isEmpty() const;
13 V_CONSTEXPR inline bool isNull() const;
15 V_CONSTEXPR inline int left() const;
16 V_CONSTEXPR inline int top() const;
17 V_CONSTEXPR inline int right() const;
18 V_CONSTEXPR inline int bottom() const;
19 V_CONSTEXPR inline int width() const;
20 V_CONSTEXPR inline int height() const;
21 V_CONSTEXPR inline int x() const;
22 V_CONSTEXPR inline int y() const;
23 inline void setLeft(int l) { x1 = l; }
24 inline void setTop(int t) { y1 = t; }
25 inline void setRight(int r) { x2 = r; }
26 inline void setBottom(int b) { y2 = b; }
27 inline void setWidth(int w) { x2 = x1 + w; }
28 inline void setHeight(int h) { y2 = y1 + h; }
29 inline VRect translated(int dx, int dy) const;
30 inline void translate(int dx, int dy);
31 inline bool contains(const VRect &r, bool proper = false) const;
32 inline bool intersects(const VRect &r);
33 friend V_CONSTEXPR inline bool operator==(const VRect &,
34 const VRect &) noexcept;
35 friend V_CONSTEXPR inline bool operator!=(const VRect &,
36 const VRect &) noexcept;
37 friend VDebug & operator<<(VDebug &os, const VRect &o);
46 inline bool VRect::intersects(const VRect &r)
48 return (right() > r.left() && left() < r.right() && bottom() > r.top() &&
52 inline VDebug &operator<<(VDebug &os, const VRect &o)
54 os << "{R " << o.x() << "," << o.y() << "," << o.width() << ","
58 V_CONSTEXPR inline bool operator==(const VRect &r1, const VRect &r2) noexcept
60 return r1.x1 == r2.x1 && r1.x2 == r2.x2 && r1.y1 == r2.y1 && r1.y2 == r2.y2;
63 V_CONSTEXPR inline bool operator!=(const VRect &r1, const VRect &r2) noexcept
65 return r1.x1 != r2.x1 || r1.x2 != r2.x2 || r1.y1 != r2.y1 || r1.y2 != r2.y2;
68 V_CONSTEXPR inline bool VRect::isEmpty() const
70 return x1 > x2 || y1 > y2;
73 V_CONSTEXPR inline bool VRect::isNull() const
75 return (((x2 - x1) == 0) || ((y2 - y1) == 0));
78 V_CONSTEXPR inline int VRect::x() const
83 V_CONSTEXPR inline int VRect::y() const
88 V_CONSTEXPR inline int VRect::left() const
93 V_CONSTEXPR inline int VRect::top() const
98 V_CONSTEXPR inline int VRect::right() const
103 V_CONSTEXPR inline int VRect::bottom() const
107 V_CONSTEXPR inline int VRect::width() const
111 V_CONSTEXPR inline int VRect::height() const
116 inline VRect VRect::translated(int dx, int dy) const
118 return {x1 + dx, y1 + dy, x2 - x1, y2 - y1};
121 inline void VRect::translate(int dx, int dy)
128 inline bool VRect::contains(const VRect &r, bool proper) const
131 if ((x1 <= r.x1) && (x2 >= r.x2) && (y1 <= r.y1) && (y2 >= r.y2))
135 if ((x1 < r.x1) && (x2 > r.x2) && (y1 < r.y1) && (y2 > r.y2))
140 V_CONSTEXPR inline VRect::VRect(int left, int top, int width, int height)
141 : x1(left), y1(top), x2(width + left), y2(height + top)
148 VRectF(float left, float top, float width, float height)
156 V_CONSTEXPR inline bool isEmpty() const;
157 V_CONSTEXPR inline bool isNull() const;
158 V_CONSTEXPR inline float left() const;
159 V_CONSTEXPR inline float top() const;
160 V_CONSTEXPR inline float right() const;
161 V_CONSTEXPR inline float bottom() const;
162 V_CONSTEXPR inline float width() const;
163 V_CONSTEXPR inline float height() const;
164 V_CONSTEXPR inline float x() const;
165 V_CONSTEXPR inline float y() const;
166 V_CONSTEXPR inline VPointF center() const
168 return {x1 + (x2 - x1) / 2.f, y1 + (y2 - y1) / 2.f};
170 inline void setLeft(float l) { x1 = l; }
171 inline void setTop(float t) { y1 = t; }
172 inline void setRight(float r) { x2 = r; }
173 inline void setBottom(float b) { y2 = b; }
174 inline void setWidth(float w) { x2 = x1 + w; }
175 inline void setHeight(float h) { y2 = y1 + h; }
176 inline void translate(float dx, float dy)
191 V_CONSTEXPR inline bool VRectF::isEmpty() const
193 return x1 > x2 || y1 > y2;
196 V_CONSTEXPR inline bool VRectF::isNull() const
198 return (((x2 - x1) == 0) || ((y2 - y1) == 0));
201 V_CONSTEXPR inline float VRectF::x() const
206 V_CONSTEXPR inline float VRectF::y() const
211 V_CONSTEXPR inline float VRectF::left() const
216 V_CONSTEXPR inline float VRectF::top() const
221 V_CONSTEXPR inline float VRectF::right() const
226 V_CONSTEXPR inline float VRectF::bottom() const
230 V_CONSTEXPR inline float VRectF::width() const
234 V_CONSTEXPR inline float VRectF::height() const