summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorPeter Elliott <pelliott@ualberta.ca>2020-08-21 08:52:39 -0600
committerAndreas Kling <kling@serenityos.org>2020-08-23 01:05:22 +0200
commit28db3cd5efe91ad6dd2821ce160f540c2f3ade9a (patch)
tree2fa89face072d7d065f74c8fe8f7710e28ae21d2 /Libraries
parent23a43d10f3926400631c02a9f6547d0e03c7ee8a (diff)
downloadserenity-28db3cd5efe91ad6dd2821ce160f540c2f3ade9a.zip
LibGfx: Add TextAlignment::BottomRight
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGfx/Painter.cpp4
-rw-r--r--Libraries/LibGfx/Rect.cpp4
-rw-r--r--Libraries/LibGfx/TextAlignment.h2
3 files changed, 10 insertions, 0 deletions
diff --git a/Libraries/LibGfx/Painter.cpp b/Libraries/LibGfx/Painter.cpp
index ab807dafb1..1377fc81ea 100644
--- a/Libraries/LibGfx/Painter.cpp
+++ b/Libraries/LibGfx/Painter.cpp
@@ -888,6 +888,7 @@ void Painter::draw_text_line(const IntRect& a_rect, const Utf8View& text, const
break;
case TextAlignment::TopRight:
case TextAlignment::CenterRight:
+ case TextAlignment::BottomRight:
rect.set_x(rect.right() - font.width(final_text));
break;
case TextAlignment::Center: {
@@ -1037,6 +1038,9 @@ void Painter::draw_text(const IntRect& rect, const StringView& raw_text, const F
case TextAlignment::Center:
bounding_rect.center_within(rect);
break;
+ case TextAlignment::BottomRight:
+ bounding_rect.set_location({ (rect.right() + 1) - bounding_rect.width(), (rect.bottom() + 1) - bounding_rect.height() });
+ break;
default:
ASSERT_NOT_REACHED();
}
diff --git a/Libraries/LibGfx/Rect.cpp b/Libraries/LibGfx/Rect.cpp
index 51ba5f509f..1f0d39d440 100644
--- a/Libraries/LibGfx/Rect.cpp
+++ b/Libraries/LibGfx/Rect.cpp
@@ -134,6 +134,10 @@ void Rect<T>::align_within(const Rect<T>& other, TextAlignment alignment)
set_x(other.x() + other.width() - width());
center_vertically_within(other);
return;
+ case TextAlignment::BottomRight:
+ set_x(other.x() + other.width() - width());
+ set_y(other.y() + other.height() - height());
+ return;
}
}
diff --git a/Libraries/LibGfx/TextAlignment.h b/Libraries/LibGfx/TextAlignment.h
index 4e527711b8..565a5c95dc 100644
--- a/Libraries/LibGfx/TextAlignment.h
+++ b/Libraries/LibGfx/TextAlignment.h
@@ -34,6 +34,7 @@ enum class TextAlignment {
Center,
CenterRight,
TopRight,
+ BottomRight,
};
inline bool is_right_text_alignment(TextAlignment alignment)
@@ -41,6 +42,7 @@ inline bool is_right_text_alignment(TextAlignment alignment)
switch (alignment) {
case TextAlignment::CenterRight:
case TextAlignment::TopRight:
+ case TextAlignment::BottomRight:
return true;
default:
return false;