Fix: Off-by-one in GetAlignedPosition().

This commit is contained in:
Peter Nelson 2022-10-01 22:47:57 +01:00 committed by PeterN
parent 47f4fc6a70
commit 68423c40c5
1 changed files with 2 additions and 2 deletions

View File

@ -39,13 +39,13 @@ static inline Point GetAlignedPosition(const Rect &r, const Dimension &d, String
switch (align & SA_HOR_MASK) {
case SA_LEFT: p.x = r.left; break;
case SA_HOR_CENTER: p.x = CenterBounds(r.left, r.right, d.width); break;
case SA_RIGHT: p.x = r.right - d.width; break;
case SA_RIGHT: p.x = r.right + 1 - d.width; break;
default: NOT_REACHED();
}
switch (align & SA_VERT_MASK) {
case SA_TOP: p.y = r.top; break;
case SA_VERT_CENTER: p.y = CenterBounds(r.top, r.bottom, d.height); break;
case SA_BOTTOM: p.y = r.bottom - d.height; break;
case SA_BOTTOM: p.y = r.bottom + 1 - d.height; break;
default: NOT_REACHED();
}
return p;