LibDraw: Add TextAlignment::TopRight

Also tidy up the alignment code to use switch statements.
This commit is contained in:
Andreas Kling 2019-09-06 19:23:36 +02:00
commit a791b86afa
Notes: sideshowbarker 2024-07-19 12:15:08 +09:00
3 changed files with 33 additions and 15 deletions

View file

@ -86,6 +86,10 @@ void Rect::align_within(const Rect& other, TextAlignment alignment)
case TextAlignment::TopLeft:
set_location(other.location());
return;
case TextAlignment::TopRight:
set_x(other.x() + other.width() - width());
set_y(other.y());
return;
case TextAlignment::CenterLeft:
set_x(other.x());
center_vertically_within(other);