diff --git a/Userland/Libraries/LibGfx/Rect.h b/Userland/Libraries/LibGfx/Rect.h index 9398976c84..878fd2392e 100644 --- a/Userland/Libraries/LibGfx/Rect.h +++ b/Userland/Libraries/LibGfx/Rect.h @@ -641,6 +641,14 @@ public: center_vertically_within(other); } + [[nodiscard]] Rect centered_within(Rect const& other) const + { + Rect rect { *this }; + rect.center_horizontally_within(other); + rect.center_vertically_within(other); + return rect; + } + void center_horizontally_within(Rect const& other) { set_x(other.center().x() - width() / 2);