diff --git a/ui/round_rect.cpp b/ui/round_rect.cpp index 4118110..d539462 100644 --- a/ui/round_rect.cpp +++ b/ui/round_rect.cpp @@ -10,8 +10,59 @@ #include "ui/image/image_prepare.h" #include "ui/ui_utility.h" +#include + namespace Ui { +QPainterPath ComplexRoundedRectPath( + const QRect &rect, + int topLeftRadius, + int topRightRadius, + int bottomLeftRadius, + int bottomRightRadius) { + auto path = QPainterPath(); + path.setFillRule(Qt::WindingFill); + + const auto cornerPartSize = rect.size() / 4 * 3; + const auto cornerPartOffset = QPoint( + rect.width() - cornerPartSize.width(), + rect.height() - cornerPartSize.height()); + + path.addRoundedRect( + rect.x(), + rect.y(), + cornerPartSize.width(), + cornerPartSize.height(), + topLeftRadius, + topLeftRadius); + + path.addRoundedRect( + rect.x() + cornerPartOffset.x(), + rect.y(), + cornerPartSize.width(), + cornerPartSize.height(), + topRightRadius, + topRightRadius); + + path.addRoundedRect( + rect.x(), + rect.y() + cornerPartOffset.y(), + cornerPartSize.width(), + cornerPartSize.height(), + bottomLeftRadius, + bottomLeftRadius); + + path.addRoundedRect( + rect.x() + cornerPartOffset.x(), + rect.y() + cornerPartOffset.y(), + cornerPartSize.width(), + cornerPartSize.height(), + bottomRightRadius, + bottomRightRadius); + + return path.simplified(); +} + void DrawRoundedRect( QPainter &p, const QRect &rect, diff --git a/ui/round_rect.h b/ui/round_rect.h index e2c184b..322fb5f 100644 --- a/ui/round_rect.h +++ b/ui/round_rect.h @@ -14,6 +14,13 @@ class QPainter; namespace Ui { +[[nodiscard]] QPainterPath ComplexRoundedRectPath( + const QRect &rect, + int topLeftRadius, + int topRightRadius, + int bottomLeftRadius, + int bottomRightRadius); + void DrawRoundedRect( QPainter &p, const QRect &rect,