mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 19:07:34 +00:00
LibGfx: Add TextAlignment::BottomRight
This commit is contained in:
parent
23a43d10f3
commit
28db3cd5ef
3 changed files with 10 additions and 0 deletions
|
@ -888,6 +888,7 @@ void Painter::draw_text_line(const IntRect& a_rect, const Utf8View& text, const
|
||||||
break;
|
break;
|
||||||
case TextAlignment::TopRight:
|
case TextAlignment::TopRight:
|
||||||
case TextAlignment::CenterRight:
|
case TextAlignment::CenterRight:
|
||||||
|
case TextAlignment::BottomRight:
|
||||||
rect.set_x(rect.right() - font.width(final_text));
|
rect.set_x(rect.right() - font.width(final_text));
|
||||||
break;
|
break;
|
||||||
case TextAlignment::Center: {
|
case TextAlignment::Center: {
|
||||||
|
@ -1037,6 +1038,9 @@ void Painter::draw_text(const IntRect& rect, const StringView& raw_text, const F
|
||||||
case TextAlignment::Center:
|
case TextAlignment::Center:
|
||||||
bounding_rect.center_within(rect);
|
bounding_rect.center_within(rect);
|
||||||
break;
|
break;
|
||||||
|
case TextAlignment::BottomRight:
|
||||||
|
bounding_rect.set_location({ (rect.right() + 1) - bounding_rect.width(), (rect.bottom() + 1) - bounding_rect.height() });
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,10 @@ void Rect<T>::align_within(const Rect<T>& other, TextAlignment alignment)
|
||||||
set_x(other.x() + other.width() - width());
|
set_x(other.x() + other.width() - width());
|
||||||
center_vertically_within(other);
|
center_vertically_within(other);
|
||||||
return;
|
return;
|
||||||
|
case TextAlignment::BottomRight:
|
||||||
|
set_x(other.x() + other.width() - width());
|
||||||
|
set_y(other.y() + other.height() - height());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ enum class TextAlignment {
|
||||||
Center,
|
Center,
|
||||||
CenterRight,
|
CenterRight,
|
||||||
TopRight,
|
TopRight,
|
||||||
|
BottomRight,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool is_right_text_alignment(TextAlignment alignment)
|
inline bool is_right_text_alignment(TextAlignment alignment)
|
||||||
|
@ -41,6 +42,7 @@ inline bool is_right_text_alignment(TextAlignment alignment)
|
||||||
switch (alignment) {
|
switch (alignment) {
|
||||||
case TextAlignment::CenterRight:
|
case TextAlignment::CenterRight:
|
||||||
case TextAlignment::TopRight:
|
case TextAlignment::TopRight:
|
||||||
|
case TextAlignment::BottomRight:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue