mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
GButton: Align the button text according to text_alignment().
Added a Rect::align_within(other_rect, alignment) helper that seemed useful.
This commit is contained in:
parent
75b0e5cce5
commit
cca510162e
Notes:
sideshowbarker
2024-07-19 13:57:19 +09:00
Author: https://github.com/awesomekling
Commit: cca510162e
3 changed files with 27 additions and 4 deletions
|
@ -76,3 +76,23 @@ Vector<Rect> Rect::shatter(const Rect& hammer) const
|
|||
|
||||
return pieces;
|
||||
}
|
||||
|
||||
void Rect::align_within(const Rect& other, TextAlignment alignment)
|
||||
{
|
||||
switch (alignment) {
|
||||
case TextAlignment::Center:
|
||||
center_within(other);
|
||||
return;
|
||||
case TextAlignment::TopLeft:
|
||||
set_location(other.location());
|
||||
return;
|
||||
case TextAlignment::CenterLeft:
|
||||
set_x(other.x());
|
||||
center_vertically_within(other);
|
||||
return;
|
||||
case TextAlignment::CenterRight:
|
||||
set_x(other.x() + other.width() - width());
|
||||
center_vertically_within(other);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue