aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@digia.com>2012-10-16 17:55:46 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-22 18:23:12 +0200
commit29bfe1db8a5b4480317701ae508f0c920c925525 (patch)
tree041fc8d5f27a9a765382a2f5e552cc0143e292ef /src/quick/scenegraph/qsgdefaultrectanglenode.cpp
parent3aaadc5226e8914a562daa1d3d123da929d1affd (diff)
Make Rectangle border be inner instead of centered on the outline.
This avoids awkward situations such as when clipping to a parent item of the same size and makes it easier to reason about the bounding rectangle of the item. Task-number: QTBUG-21341 Change-Id: If015cfbc5792429f4a407fc0547ea71eca779eda Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultrectanglenode.cpp')
-rw-r--r--src/quick/scenegraph/qsgdefaultrectanglenode.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
index dab855064e..4d5094d526 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
@@ -342,9 +342,12 @@ void QSGDefaultRectangleNode::update()
void QSGDefaultRectangleNode::updateGeometry()
{
- float penWidth = m_aligned ? float(qRound(m_pen_width)) : float(m_pen_width);
float width = float(m_rect.width());
float height = float(m_rect.height());
+ float penWidth = qMin(qMin(width, height) * 0.5f, float(m_pen_width));
+
+ if (m_aligned)
+ penWidth = qRound(penWidth);
QSGGeometry *g = geometry();
g->setDrawingMode(GL_TRIANGLE_STRIP);
@@ -377,14 +380,9 @@ void QSGDefaultRectangleNode::updateGeometry()
float radius = qMin(qMin(width, height) * 0.5f, float(m_radius));
QRectF innerRect = m_rect;
innerRect.adjust(radius, radius, -radius, -radius);
- if (m_aligned && (int(penWidth) & 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));
- }
- float innerRadius = radius - penWidth * 0.5f;
- float outerRadius = radius + penWidth * 0.5f;
+ float innerRadius = radius - penWidth * 1.0f;
+ float outerRadius = radius;
float delta = qMin(width, height) * 0.5f;
// Number of segments per corner, approximately one per 3 pixels.
@@ -630,16 +628,8 @@ void QSGDefaultRectangleNode::updateGeometry()
QRectF innerRect = m_rect;
QRectF outerRect = m_rect;
- if (penWidth) {
- if (m_aligned && (int(penWidth) & 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));
- outerRect = innerRect;
- }
- innerRect.adjust(0.5f * penWidth, 0.5f * penWidth, -0.5f * penWidth, -0.5f * penWidth);
- outerRect.adjust(-0.5f * penWidth, -0.5f * penWidth, 0.5f * penWidth, 0.5f * penWidth);
- }
+ if (penWidth)
+ innerRect.adjust(1.0f * penWidth, 1.0f * penWidth, -1.0f * penWidth, -1.0f * penWidth);
float delta = qMin(width, height) * 0.5f;
int innerVertexCount = 4 + gradientIntersections * 2;