aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items/qsgrectangle.cpp
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-08-15 12:55:26 +0200
committerQt by Nokia <qt-info@nokia.com>2011-08-16 08:16:14 +0200
commitec68295138b3cd4ee45cb28ef604212c4e9a9f50 (patch)
treef1774e9f9dcf03c732a57a0525375afe94525021 /src/declarative/items/qsgrectangle.cpp
parentc5b56564667194b179ebfcc87608d38e9969fade (diff)
Fixed clip on QML2 rectangles to include the borders.
This is related to commit 31ebb4bfb0df83805c5d86b6773f11ba1145c7cd. Task-number: QTBUG-20547 Change-Id: I6a5b6c56d440c7fa7f5546472305f62227b64c29 Reviewed-on: http://codereview.qt.nokia.com/2952 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/declarative/items/qsgrectangle.cpp')
-rw-r--r--src/declarative/items/qsgrectangle.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/declarative/items/qsgrectangle.cpp b/src/declarative/items/qsgrectangle.cpp
index b1c26a5a2c..25f0eda5d5 100644
--- a/src/declarative/items/qsgrectangle.cpp
+++ b/src/declarative/items/qsgrectangle.cpp
@@ -330,8 +330,22 @@ QSGRectangle::QSGRectangle(QSGItem *parent)
void QSGRectangle::doUpdate()
{
Q_D(QSGRectangle);
- const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
- d->setPaintMargin((pw+1)/2);
+ qreal penMargin = 0;
+ qreal penOffset = 0;
+ if (d->pen && d->pen->isValid()) {
+ if (d->pen->aligned()) {
+ const int pw = qRound(d->pen->width());
+ penMargin = qreal(0.5) * pw;
+ penOffset = (pw & 1) * qreal(0.5);
+ } else {
+ penMargin = qreal(0.5) * d->pen->width();
+ }
+ }
+ if (penMargin != d->penMargin || penOffset != d->penOffset) {
+ d->penMargin = penMargin;
+ d->penOffset = penOffset;
+ d->dirty(QSGItemPrivate::Size); // update clip
+ }
update();
}
@@ -534,7 +548,8 @@ QSGNode *QSGRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *da
QRectF QSGRectangle::boundingRect() const
{
Q_D(const QSGRectangle);
- return QRectF(-d->paintmargin, -d->paintmargin, width()+d->paintmargin*2, height()+d->paintmargin*2);
+ return QRectF(d->penOffset - d->penMargin, d->penOffset - d->penMargin,
+ d->width + 2 * d->penMargin, d->height + 2 * d->penMargin);
}
QT_END_NAMESPACE