mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:08:12 +00:00
LibGfx: Add missing TextAlignment::BottomLeft
This commit is contained in:
parent
8cbdcffd05
commit
9dd3203cc6
6 changed files with 19 additions and 5 deletions
|
@ -78,6 +78,7 @@ constexpr static CellTypeDialog::VerticalAlignment vertical_alignment_from(Gfx::
|
|||
case Gfx::TextAlignment::TopLeft:
|
||||
return CellTypeDialog::VerticalAlignment::Top;
|
||||
|
||||
case Gfx::TextAlignment::BottomLeft:
|
||||
case Gfx::TextAlignment::BottomRight:
|
||||
return CellTypeDialog::VerticalAlignment::Bottom;
|
||||
}
|
||||
|
@ -91,13 +92,14 @@ constexpr static CellTypeDialog::HorizontalAlignment horizontal_alignment_from(G
|
|||
case Gfx::TextAlignment::Center:
|
||||
return CellTypeDialog::HorizontalAlignment::Center;
|
||||
|
||||
case Gfx::TextAlignment::CenterRight:
|
||||
case Gfx::TextAlignment::TopRight:
|
||||
case Gfx::TextAlignment::CenterRight:
|
||||
case Gfx::TextAlignment::BottomRight:
|
||||
return CellTypeDialog::HorizontalAlignment::Right;
|
||||
|
||||
case Gfx::TextAlignment::TopLeft:
|
||||
case Gfx::TextAlignment::CenterLeft:
|
||||
case Gfx::TextAlignment::BottomLeft:
|
||||
return CellTypeDialog::HorizontalAlignment::Left;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,6 +141,8 @@ void Canvas::draw()
|
|||
painter.draw_text({ 520, 260, 240, 80 }, "CenterRight", Gfx::TextAlignment::CenterRight, Color::White);
|
||||
painter.draw_text({ 520, 260, 240, 80 }, "TopLeft", Gfx::TextAlignment::TopLeft, Color::White);
|
||||
painter.draw_text({ 520, 260, 240, 80 }, "TopRight", Gfx::TextAlignment::TopRight, Color::White);
|
||||
painter.draw_text({ 520, 260, 240, 80 }, "BottomLeft", Gfx::TextAlignment::BottomLeft, Color::White);
|
||||
painter.draw_text({ 520, 260, 240, 80 }, "BottomRight", Gfx::TextAlignment::BottomRight, Color::White);
|
||||
|
||||
painter.draw_rect({ 520, 360, 240, 30 }, Color::DarkGray);
|
||||
painter.draw_text({ 520, 360, 240, 30 }, "Emojis! 🙂😂🐞🦄", Gfx::TextAlignment::Center, Color::White);
|
||||
|
|
|
@ -353,11 +353,12 @@ T* Object::find_descendant_of_type_named(String const& name) requires IsBaseOf<O
|
|||
#define REGISTER_TEXT_ALIGNMENT_PROPERTY(property_name, getter, setter) \
|
||||
REGISTER_ENUM_PROPERTY( \
|
||||
property_name, getter, setter, Gfx::TextAlignment, \
|
||||
{ Gfx::TextAlignment::TopLeft, "TopLeft" }, \
|
||||
{ Gfx::TextAlignment::CenterLeft, "CenterLeft" }, \
|
||||
{ Gfx::TextAlignment::Center, "Center" }, \
|
||||
{ Gfx::TextAlignment::CenterLeft, "CenterLeft" }, \
|
||||
{ Gfx::TextAlignment::CenterRight, "CenterRight" }, \
|
||||
{ Gfx::TextAlignment::TopLeft, "TopLeft" }, \
|
||||
{ Gfx::TextAlignment::TopRight, "TopRight" }, \
|
||||
{ Gfx::TextAlignment::BottomLeft, "BottomLeft" }, \
|
||||
{ Gfx::TextAlignment::BottomRight, "BottomRight" })
|
||||
|
||||
#define REGISTER_FONT_WEIGHT_PROPERTY(property_name, getter, setter) \
|
||||
|
|
|
@ -1229,6 +1229,7 @@ void draw_text_line(const IntRect& a_rect, const TextType& text, const Font& fon
|
|||
switch (alignment) {
|
||||
case TextAlignment::TopLeft:
|
||||
case TextAlignment::CenterLeft:
|
||||
case TextAlignment::BottomLeft:
|
||||
break;
|
||||
case TextAlignment::TopRight:
|
||||
case TextAlignment::CenterRight:
|
||||
|
@ -1501,6 +1502,9 @@ void do_draw_text(const IntRect& rect, const TextType& text, const Font& font, T
|
|||
case TextAlignment::Center:
|
||||
bounding_rect.center_within(rect);
|
||||
break;
|
||||
case TextAlignment::BottomLeft:
|
||||
bounding_rect.set_location({ rect.x(), (rect.bottom() + 1) - bounding_rect.height() });
|
||||
break;
|
||||
case TextAlignment::BottomRight:
|
||||
bounding_rect.set_location({ (rect.right() + 1) - bounding_rect.width(), (rect.bottom() + 1) - bounding_rect.height() });
|
||||
break;
|
||||
|
|
|
@ -114,6 +114,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::BottomLeft:
|
||||
set_x(other.x());
|
||||
set_y(other.y() + other.height() - height());
|
||||
return;
|
||||
case TextAlignment::BottomRight:
|
||||
set_x(other.x() + other.width() - width());
|
||||
set_y(other.y() + other.height() - height());
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
namespace Gfx {
|
||||
|
||||
#define GFX_ENUMERATE_TEXT_ALIGNMENTS(M) \
|
||||
M(TopLeft) \
|
||||
M(CenterLeft) \
|
||||
M(Center) \
|
||||
M(CenterLeft) \
|
||||
M(CenterRight) \
|
||||
M(TopLeft) \
|
||||
M(TopRight) \
|
||||
M(BottomLeft) \
|
||||
M(BottomRight)
|
||||
|
||||
enum class TextAlignment {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue