diff options
Diffstat (limited to 'src/adaptationlayers/default/default_rectanglenode.cpp')
-rw-r--r-- | src/adaptationlayers/default/default_rectanglenode.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/adaptationlayers/default/default_rectanglenode.cpp b/src/adaptationlayers/default/default_rectanglenode.cpp index cb4f85d..70b9647 100644 --- a/src/adaptationlayers/default/default_rectanglenode.cpp +++ b/src/adaptationlayers/default/default_rectanglenode.cpp @@ -289,18 +289,21 @@ void DefaultRectangleNode::updateGeometry() if (m_radius > 0) { // Rounded corners. + + // Radius should never exceeds half of the width or half of the height + qreal radius = qMin(qMin(m_rect.width() / 2, m_rect.height() / 2), m_radius); QRectF innerRect = m_rect; - innerRect.adjust(m_radius, m_radius, -m_radius, -m_radius); + innerRect.adjust(radius, radius, -radius, -radius); if (m_pen_width & 1) { // Pen width is odd, so add the offset as documented. innerRect.moveLeft(innerRect.left() + qreal(0.5)); innerRect.moveTop(innerRect.top() + qreal(0.5)); } - qreal innerRadius = m_radius - m_pen_width * qreal(0.5); - qreal outerRadius = m_radius + m_pen_width * qreal(0.5); + qreal innerRadius = radius - m_pen_width * qreal(0.5); + qreal outerRadius = radius + m_pen_width * qreal(0.5); - int segments = qMin(15, qCeil(outerRadius)); // Number of segments per corner. + int segments = qMin(30, qCeil(outerRadius)); // Number of segments per corner. /* @@ -332,7 +335,7 @@ void DefaultRectangleNode::updateGeometry() QList<ushort> borderIndices; int nextGradientStop = 0; - qreal gradientPos = (m_radius - innerRadius) / (innerRect.height() + 2 * m_radius); + qreal gradientPos = (radius - innerRadius) / (innerRect.height() + 2 * radius); while (nextGradientStop < stops.size() && stops.at(nextGradientStop).first <= gradientPos) ++nextGradientStop; @@ -353,10 +356,10 @@ void DefaultRectangleNode::updateGeometry() qreal lX = innerRect.left() - outerRadius * s; // current outer left x-coordinate. qreal rX = innerRect.right() + outerRadius * s; // current outer right x-coordinate. - gradientPos = ((part ? innerRect.height() : 0) + m_radius - innerRadius * c) / (innerRect.height() + 2 * m_radius); + gradientPos = ((part ? innerRect.height() : 0) + radius - innerRadius * c) / (innerRect.height() + 2 * radius); while (nextGradientStop < stops.size() && stops.at(nextGradientStop).first <= gradientPos) { // Insert vertices at gradient stops. - qreal gy = (innerRect.top() - m_radius) + stops.at(nextGradientStop).first * (innerRect.height() + 2 * m_radius); + qreal gy = (innerRect.top() - radius) + stops.at(nextGradientStop).first * (innerRect.height() + 2 * radius); Q_ASSERT(fillVertexCount >= 2); qreal t = (gy - py) / (y - py); qreal glx = plx * (1 - t) + t * lx; |