40 lines
944 B
C++
40 lines
944 B
C++
#pragma once
|
|
#include <ui/Point.h>
|
|
|
|
namespace ui
|
|
{
|
|
/**
|
|
* @brief A simple rectangle.
|
|
*/
|
|
struct Rect
|
|
{
|
|
Point pos;
|
|
int width;
|
|
int height;
|
|
|
|
/**
|
|
* @brief Check if a point is contained in this rectangle.
|
|
*
|
|
* @param point The point to check.
|
|
* @return true The point is contained inside the rectangle.
|
|
* @return false The point is not contained inside the rectangle.
|
|
*/
|
|
bool contains(Point point);
|
|
|
|
/**
|
|
* @brief Normalize a point to fit inside this rectangle.
|
|
*
|
|
* @param point The original point.
|
|
* @return Point The normalized point.
|
|
*/
|
|
Point normalize(Point point);
|
|
|
|
/**
|
|
* @brief Return a copy of this rectangle with no negative values (normalized to 0).
|
|
*
|
|
* @return Rect The new rectangle.
|
|
*/
|
|
Rect absolute();
|
|
};
|
|
}
|