#pragma once #include 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 Transform an absolute position to a position relative to this rectangle. * * @param pos The original absolute position. * @return Point The position relative to this rectangle. */ Point relative(Point pos); /** * @brief Transform a position relative to this rectangle to an absolute position. * * @param pos The original relative position. * @return Point The absolute position. */ Point absolute(Point pos); /** * @brief Transform another rectangle relative to this one to an absolute rectangle. * * @param rect The original relative rectangle. * @return Point The absolute rectangle. */ Rect absolute(Rect rect); /** * @brief Return a copy of this rectangle with no negative values (normalized to 0). * * @return Rect The new rectangle. */ Rect normalized(); }; }