libui: Add Rect::contains(Rect)
This commit is contained in:
parent
35d2bd6931
commit
c0ada40e2c
@ -21,6 +21,15 @@ namespace ui
|
||||
*/
|
||||
bool contains(Point point);
|
||||
|
||||
/**
|
||||
* @brief Check if another rectangle is contained in this one.
|
||||
*
|
||||
* @param point The rectangle to check.
|
||||
* @return true The other rectangle is contained inside this one.
|
||||
* @return false The other rectangle is not contained inside this one.
|
||||
*/
|
||||
bool contains(Rect rect);
|
||||
|
||||
/**
|
||||
* @brief Normalize a point to fit inside this rectangle.
|
||||
*
|
||||
|
@ -8,6 +8,15 @@ namespace ui
|
||||
(point.y <= (pos.y + height));
|
||||
}
|
||||
|
||||
bool Rect::contains(Rect rect)
|
||||
{
|
||||
if (!contains(rect.pos)) return false;
|
||||
Point rel = relative(rect.pos);
|
||||
if ((rel.x + rect.width) > width) return false;
|
||||
if ((rel.y + rect.height) > height) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Point Rect::normalize(Point point)
|
||||
{
|
||||
if (point.x < pos.x) point.x = pos.x;
|
||||
|
Loading…
Reference in New Issue
Block a user