diff --git a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp index bf59ca5ff0..8e9cdd0c3d 100644 --- a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp +++ b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp @@ -74,10 +74,12 @@ constexpr static CellTypeDialog::VerticalAlignment vertical_alignment_from(Gfx:: case Gfx::TextAlignment::Center: return CellTypeDialog::VerticalAlignment::Center; + case Gfx::TextAlignment::TopCenter: case Gfx::TextAlignment::TopRight: case Gfx::TextAlignment::TopLeft: return CellTypeDialog::VerticalAlignment::Top; + case Gfx::TextAlignment::BottomCenter: case Gfx::TextAlignment::BottomLeft: case Gfx::TextAlignment::BottomRight: return CellTypeDialog::VerticalAlignment::Bottom; @@ -89,7 +91,9 @@ constexpr static CellTypeDialog::VerticalAlignment vertical_alignment_from(Gfx:: constexpr static CellTypeDialog::HorizontalAlignment horizontal_alignment_from(Gfx::TextAlignment alignment) { switch (alignment) { + case Gfx::TextAlignment::BottomCenter: case Gfx::TextAlignment::Center: + case Gfx::TextAlignment::TopCenter: return CellTypeDialog::HorizontalAlignment::Center; case Gfx::TextAlignment::TopRight: diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h index 6bcb75b675..3ab4c8fbf9 100644 --- a/Userland/Libraries/LibCore/Object.h +++ b/Userland/Libraries/LibCore/Object.h @@ -376,8 +376,10 @@ T* Object::find_descendant_of_type_named(String const& name) requires IsBaseOf Rect::aligned_within(Size const& rect_size, Point const& align_ Rect rect; switch (alignment) { + case TextAlignment::TopCenter: + rect = { { align_at.x() - rect_size.width() / 2, align_at.y() }, rect_size }; + break; case TextAlignment::TopLeft: rect = { align_at, rect_size }; break; + case TextAlignment::TopRight: + rect = { { align_at.x() - rect_size.width(), align_at.y() }, rect_size }; + break; case TextAlignment::CenterLeft: rect = { { align_at.x(), align_at.y() - rect_size.height() / 2 }, rect_size }; break; @@ -144,8 +150,8 @@ Rect Rect::aligned_within(Size const& rect_size, Point const& align_ case TextAlignment::CenterRight: rect = { { align_at.x() - rect_size.width() / 2, align_at.y() }, rect_size }; break; - case TextAlignment::TopRight: - rect = { { align_at.x() - rect_size.width(), align_at.y() }, rect_size }; + case TextAlignment::BottomCenter: + rect = { { align_at.x() - rect_size.width() / 2, align_at.y() - rect_size.width() }, rect_size }; break; case TextAlignment::BottomLeft: rect = { { align_at.x(), align_at.y() - rect_size.width() }, rect_size }; @@ -270,6 +276,9 @@ void Rect::align_within(Rect const& other, TextAlignment alignment) case TextAlignment::Center: center_within(other); return; + case TextAlignment::TopCenter: + set_x(other.x() + other.width() / 2); + return; case TextAlignment::TopLeft: set_location(other.location()); return; @@ -285,6 +294,10 @@ void Rect::align_within(Rect const& other, TextAlignment alignment) set_x(other.x() + other.width() - width()); center_vertically_within(other); return; + case TextAlignment::BottomCenter: + set_x(other.x() + other.width() / 2); + set_y(other.y() + other.height() - height()); + return; case TextAlignment::BottomLeft: set_x(other.x()); set_y(other.y() + other.height() - height()); diff --git a/Userland/Libraries/LibGfx/TextAlignment.h b/Userland/Libraries/LibGfx/TextAlignment.h index b3c9e84171..9c0f7a38d2 100644 --- a/Userland/Libraries/LibGfx/TextAlignment.h +++ b/Userland/Libraries/LibGfx/TextAlignment.h @@ -15,8 +15,10 @@ namespace Gfx { M(Center) \ M(CenterLeft) \ M(CenterRight) \ + M(TopCenter) \ M(TopLeft) \ M(TopRight) \ + M(BottomCenter) \ M(BottomLeft) \ M(BottomRight)