1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:27:35 +00:00

SpaceAnalyzer: Reduce thickness of black borders between cells.

-Adds take_from_{left,right,top,bottom} to Rect.
This commit is contained in:
Mart G 2021-03-02 14:29:22 +01:00 committed by Andreas Kling
parent ee7c8fbd7b
commit de9f458ff5
3 changed files with 101 additions and 53 deletions

View file

@ -196,6 +196,50 @@ public:
return rect;
}
Rect<T> take_from_right(T w)
{
if (w > width())
w = width();
Rect<T> rect = *this;
set_width(width() - w);
rect.set_x(x() + width());
rect.set_width(w);
return rect;
}
Rect<T> take_from_left(T w)
{
if (w > width())
w = width();
Rect<T> rect = *this;
set_x(x() + w);
set_width(width() - w);
rect.set_width(w);
return rect;
}
Rect<T> take_from_top(T h)
{
if (h > height())
h = height();
Rect<T> rect = *this;
set_y(y() + h);
set_height(height() - h);
rect.set_height(h);
return rect;
}
Rect<T> take_from_bottom(T h)
{
if (h > height())
h = height();
Rect<T> rect = *this;
set_height(height() - h);
rect.set_y(y() + height());
rect.set_height(h);
return rect;
}
bool contains_vertically(T y) const
{
return y >= top() && y <= bottom();