summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx/qfxrect.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-07-10 01:17:51 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-07-10 01:17:51 (GMT)
commit9c13caa3c99af01a9b4c3ff6e178e7dadb61741f (patch)
treeb69df0a23c4628359fc3740e09958980eda7478e /src/declarative/fx/qfxrect.cpp
parentbb1bdcab28e4c52dcea37dfaaa435045b1985eeb (diff)
parent883da42f7c75775502c818aa456c8576d8457ff8 (diff)
downloadQt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.zip
Qt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.tar.gz
Qt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui-gv
Conflicts: examples/itemviews/frozencolumn/main.cpp src/declarative/canvas/qsimplecanvas.cpp src/declarative/canvas/qsimplecanvas_p.h src/declarative/canvas/qsimplecanvasitem.h src/declarative/extra/qfxparticles.cpp src/declarative/fx/fx.pri src/declarative/fx/qfxblurfilter.h src/declarative/fx/qfxcontentwrapper.cpp src/declarative/fx/qfxflickable.cpp src/declarative/fx/qfxfocuspanel.h src/declarative/fx/qfxfocusrealm.h src/declarative/fx/qfxhighlightfilter.cpp src/declarative/fx/qfxhighlightfilter.h src/declarative/fx/qfximage.cpp src/declarative/fx/qfxitem.cpp src/declarative/fx/qfxitem.h src/declarative/fx/qfxrect.cpp src/declarative/fx/qfxreflectionfilter.h src/declarative/fx/qfxshadowfilter.cpp src/declarative/fx/qfxshadowfilter.h src/declarative/fx/qfxtext.cpp src/declarative/fx/qfxtext.h src/declarative/fx/qfxtextedit.cpp src/declarative/opengl/glbasicshaders.h src/declarative/test/qfxtestengine.cpp src/declarative/test/qfxtestengine.h src/declarative/test/qfxtestobjects.cpp src/declarative/test/qfxtestobjects.h src/declarative/test/qfxtestview.h src/declarative/util/qfxglobal.h src/declarative/util/qfxview.cpp src/gui/graphicsview/qgraphicsitem_p.h tools/qmlviewer/qmlviewer.cpp
Diffstat (limited to 'src/declarative/fx/qfxrect.cpp')
-rw-r--r--src/declarative/fx/qfxrect.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index a068fd4..2ad8536 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -55,9 +55,9 @@ QML_DEFINE_TYPE(QFxGradient,Gradient)
\brief The QFxPen class provides a pen used for drawing rect borders on a QFxView.
By default, the pen is invalid and nothing is drawn. You must either set a color (then the default
- width is 0) or a width (then the default color is black).
+ width is 1) or a width (then the default color is black).
- A width of 0 indicates a cosmetic pen, a single-pixel line on the border of the item being painted.
+ A width of 1 indicates is a single-pixel line on the border of the item being painted.
Example:
\qml
@@ -68,9 +68,9 @@ QML_DEFINE_TYPE(QFxGradient,Gradient)
/*! \property QFxPen::width
\brief the width of the pen.
- A width of 0 is a single-pixel line on the border of the item being painted.
+ A width of 1 is a single-pixel line on the border of the item being painted.
- If the width is less than 0 the pen is considered invalid and won't be used.
+ If the width is less than 1 the pen is considered invalid and won't be used.
*/
/*!
@@ -103,18 +103,18 @@ void QFxPen::setColor(const QColor &c)
\brief the width of the pen.
\qml
- // rect with green border using hexidecimal notation
Rect { pen.width: 4 }
\endqml
- A width of 0 creates a thin line. For no line, use a negative width or a transparent color.
+ A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color.
- Odd pen widths generally lead to half-pixel painting.
+ To keep the border smooth (rather than blurry), odd pen widths cause the rect to be painted at
+ a half-pixel offset;
*/
void QFxPen::setWidth(int w)
{
_width = w;
- _valid = (_width < 0) ? false : true;
+ _valid = (_width < 1) ? false : true;
emit updated();
}
@@ -472,7 +472,10 @@ void QFxRect::generateRoundedRect()
p.setPen(Qt::NoPen);
}
p.setBrush(d->color);
- p.drawRoundedRect((pw+1)/2, (pw+1)/2, d->rectImage.width()-(pw+1)/2*2, d->rectImage.height()-(pw+1)/2*2, d->radius, d->radius);
+ if (pw%2)
+ p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)), d->radius, d->radius);
+ else
+ p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw), d->radius, d->radius);
}
}
@@ -487,12 +490,16 @@ void QFxRect::generateBorderedRect()
p.setRenderHint(QPainter::Antialiasing);
if (d->pen && d->pen->isValid()) {
QPen pn(QColor(d->pen->color()), d->pen->width());
+ pn.setJoinStyle(Qt::MiterJoin);
p.setPen(pn);
} else {
p.setPen(Qt::NoPen);
}
p.setBrush(d->color);
- p.drawRect(qreal(pw+1)/2, qreal(pw+1)/2, d->rectImage.width()-(pw+1)/2*2, d->rectImage.height()-(pw+1)/2*2);
+ if (pw%2)
+ p.drawRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)));
+ else
+ p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw));
}
}
@@ -512,7 +519,7 @@ void QFxRect::drawRect(QPainter &p)
if (d->gradient && d->gradient->gradient() /*|| p.usingQt() */) {
// XXX This path is still slower than the image path
// Image path won't work for gradients though
- QPainter::RenderHints oldHints = p.renderHints();
+ bool oldAA = p.testRenderHint(QPainter::Antialiasing);
p.setRenderHint(QPainter::Antialiasing);
if (d->pen && d->pen->isValid()) {
QPen pn(QColor(d->pen->color()), d->pen->width());
@@ -525,7 +532,7 @@ void QFxRect::drawRect(QPainter &p)
p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius);
else
p.drawRect(0, 0, width(), height());
- p.setRenderHints(oldHints);
+ p.setRenderHint(QPainter::Antialiasing, oldAA);
} else {
int offset = 0;
const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0;