mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Merge pull request #8789 from Robyt3/Client-UI-Convenience
Add `CUIRect::TopLeft` and `Size` convenience functions
This commit is contained in:
commit
0013615da1
|
@ -136,7 +136,24 @@ public:
|
||||||
void Draw(ColorRGBA Color, int Corners, float Rounding) const;
|
void Draw(ColorRGBA Color, int Corners, float Rounding) const;
|
||||||
void Draw4(ColorRGBA ColorTopLeft, ColorRGBA ColorTopRight, ColorRGBA ColorBottomLeft, ColorRGBA ColorBottomRight, int Corners, float Rounding) const;
|
void Draw4(ColorRGBA ColorTopLeft, ColorRGBA ColorTopRight, ColorRGBA ColorBottomLeft, ColorRGBA ColorBottomRight, int Corners, float Rounding) const;
|
||||||
|
|
||||||
vec2 Center() const { return vec2(x + w / 2.0f, y + h / 2.0f); }
|
/**
|
||||||
|
* Returns the top-left position of *this* CUIRect as a vec2.
|
||||||
|
*
|
||||||
|
* @return Top-left position as vec2.
|
||||||
|
*/
|
||||||
|
vec2 TopLeft() const { return vec2(x, y); }
|
||||||
|
/**
|
||||||
|
* Returns the size of *this* CUIRect as a vec2.
|
||||||
|
*
|
||||||
|
* @return Size as vec2.
|
||||||
|
*/
|
||||||
|
vec2 Size() const { return vec2(w, h); }
|
||||||
|
/**
|
||||||
|
* Returns the center position of *this* CUIRect as a vec2.
|
||||||
|
*
|
||||||
|
* @return Center position as vec2.
|
||||||
|
*/
|
||||||
|
vec2 Center() const { return TopLeft() + Size() / 2.0f; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue