diff --git a/ui/rect.h b/ui/rect.h index 60828802..0f8222a2 100644 --- a/ui/rect.h +++ b/ui/rect.h @@ -87,6 +87,21 @@ namespace pos { return w->y() + w->height(); } +/* + rect::center(mywidget); +*/ +[[nodiscard]] inline QPoint center(const QRect &r) { + return { r.left() + r.width() / 2, r.top() + r.height() / 2 }; +} + +[[nodiscard]] inline QPointF center(const QRectF &r) { + return { r.left() + r.width() / 2, r.top() + r.height() / 2 }; +} + +[[nodiscard]] inline QPoint center(not_null w) { + return { w->x() + w->width() / 2, w->y() + w->height() / 2 }; +} + } // namespace rect /*