mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
add Rect::shrink(Distance) even though it arguably should be handled by Rect::expand()
This commit is contained in:
parent
f3d349bc9a
commit
857719f2e1
2 changed files with 19 additions and 0 deletions
|
|
@ -94,6 +94,7 @@ struct LIBCANVAS_API Rect
|
||||||
Rect extend (Rect const &) const;
|
Rect extend (Rect const &) const;
|
||||||
Rect translate (Duple) const;
|
Rect translate (Duple) const;
|
||||||
Rect expand (Distance) const;
|
Rect expand (Distance) const;
|
||||||
|
Rect shrink (Distance) const;
|
||||||
bool contains (Duple) const;
|
bool contains (Duple) const;
|
||||||
Rect fix () const;
|
Rect fix () const;
|
||||||
bool empty() const { return (x0 == x1 && y0 == y1); }
|
bool empty() const { return (x0 == x1 && y0 == y1); }
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,24 @@ Rect::expand (Distance amount) const
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect
|
||||||
|
Rect::shrink (Distance amount) const
|
||||||
|
{
|
||||||
|
/* This isn't the equivalent of expand (-distance) because
|
||||||
|
of the peculiarities of safe_add() with negative values.
|
||||||
|
Maybe.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Rect r;
|
||||||
|
|
||||||
|
r.x0 = safe_add (x0, amount);
|
||||||
|
r.y0 = safe_add (y0, amount);
|
||||||
|
r.x1 = x1 - amount;
|
||||||
|
r.y1 = y1 - amount;
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Rect::contains (Duple point) const
|
Rect::contains (Duple point) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue