Add a display server and graphical user interface #38

Merged
apio merged 103 commits from display-server into main 2023-09-20 18:49:21 +00:00
2 changed files with 16 additions and 0 deletions
Showing only changes of commit 2b3e9b778a - Show all commits

View File

@ -29,6 +29,14 @@ namespace ui
*/
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 Return a copy of this rectangle with no negative values (normalized to 0).
*

View File

@ -17,6 +17,14 @@ namespace ui
return point;
}
Point Rect::relative(Point point)
{
point = normalize(point);
point.x -= pos.x;
point.y -= pos.y;
return point;
}
Rect Rect::absolute()
{
return Rect { ui::Point { pos.x < 0 ? 0 : pos.x, pos.y < 0 ? 0 : pos.y }, width, height };