From 116e7baeada1184bb10c64aed3cd20315955c63a Mon Sep 17 00:00:00 2001 From: Pavel Shliak Date: Sun, 8 Dec 2024 01:08:17 +0400 Subject: [PATCH] LibGfx: Remove aligned_within from Rect The CenterRight and TopCenter alignment cases were mistakenly identical due to a copy-paste error, causing the function to behave unexpectedly. Rather than attempting to fix it, remove aligned_within entirely. --- Libraries/LibGfx/Rect.h | 42 ----------------------------------------- 1 file changed, 42 deletions(-) diff --git a/Libraries/LibGfx/Rect.h b/Libraries/LibGfx/Rect.h index 1e51ad7f118..2bd79477fb1 100644 --- a/Libraries/LibGfx/Rect.h +++ b/Libraries/LibGfx/Rect.h @@ -606,48 +606,6 @@ public: return rect; } - [[nodiscard]] Rect aligned_within(Size const& rect_size, Point const& align_at, TextAlignment alignment = TextAlignment::Center) const - { - if (rect_size.is_empty()) - return {}; - if (!size().contains(rect_size)) - return {}; - if (!contains(align_at)) - return {}; - - 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; - case TextAlignment::Center: - rect = { { align_at.x() - rect_size.width() / 2, align_at.y() - rect_size.height() / 2 }, rect_size }; - break; - case TextAlignment::CenterRight: - rect = { { align_at.x() - rect_size.width() / 2, align_at.y() }, rect_size }; - break; - 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 }; - break; - case TextAlignment::BottomRight: - rect = { { align_at.x() - rect_size.width(), align_at.y() - rect_size.width() }, rect_size }; - break; - } - return rect.constrained_to(*this); - } - [[nodiscard]] Point closest_to(Point const& point) const { if (is_empty())