summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-12 15:41:11 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-12 16:32:02 (GMT)
commit0c992f560a0872ccdc4a44cf4d1c7da627cc6807 (patch)
treeabdef86516e0bb594eba7f60b23ed2b51a2c8a33 /src
parent77feedfa3c00dc39df65bd4f567c9d43e8e25b4f (diff)
downloadQt-0c992f560a0872ccdc4a44cf4d1c7da627cc6807.zip
Qt-0c992f560a0872ccdc4a44cf4d1c7da627cc6807.tar.gz
Qt-0c992f560a0872ccdc4a44cf4d1c7da627cc6807.tar.bz2
Ugly round corners when no border is drawn
When specifying round corners with QStyleSheetStyle and no border-width specified, the round corners were not rendered with antialiasing. Furthermore, if border-width was set to 0, part of the border was rendered in discordance with CSS3. The background in now rendered directly instead of drawing a clipped rectangle. The actual border width is checked before rendering. A test has been added at tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui Task-number: 230362 Reviewed-by: olivier
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qcssutil.cpp8
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp13
2 files changed, 14 insertions, 7 deletions
diff --git a/src/gui/painting/qcssutil.cpp b/src/gui/painting/qcssutil.cpp
index ac0ea08..ae8afed 100644
--- a/src/gui/painting/qcssutil.cpp
+++ b/src/gui/painting/qcssutil.cpp
@@ -353,7 +353,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles
qNormalizeRadii(rect, radii, &tlr, &trr, &blr, &brr);
// Drawn in increasing order of precendence
- if (styles[BottomEdge] != BorderStyle_None) {
+ if (styles[BottomEdge] != BorderStyle_None && borders[BottomEdge] > 0) {
qreal dw1 = (blr.width() || paintsOver(styles, colors, BottomEdge, LeftEdge)) ? 0 : borders[LeftEdge];
qreal dw2 = (brr.width() || paintsOver(styles, colors, BottomEdge, RightEdge)) ? 0 : borders[RightEdge];
qreal x1 = br.x() + blr.width();
@@ -365,7 +365,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles
if (blr.width() || brr.width())
qDrawRoundedCorners(p, x1, y1, x2, y2, blr, brr, BottomEdge, styles[BottomEdge], colors[BottomEdge]);
}
- if (styles[RightEdge] != BorderStyle_None) {
+ if (styles[RightEdge] != BorderStyle_None && borders[RightEdge] > 0) {
qreal dw1 = (trr.height() || paintsOver(styles, colors, RightEdge, TopEdge)) ? 0 : borders[TopEdge];
qreal dw2 = (brr.height() || paintsOver(styles, colors, RightEdge, BottomEdge)) ? 0 : borders[BottomEdge];
qreal x1 = br.x() + br.width() - borders[RightEdge];
@@ -377,7 +377,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles
if (trr.height() || brr.height())
qDrawRoundedCorners(p, x1, y1, x2, y2, trr, brr, RightEdge, styles[RightEdge], colors[RightEdge]);
}
- if (styles[LeftEdge] != BorderStyle_None) {
+ if (styles[LeftEdge] != BorderStyle_None && borders[LeftEdge] > 0) {
qreal dw1 = (tlr.height() || paintsOver(styles, colors, LeftEdge, TopEdge)) ? 0 : borders[TopEdge];
qreal dw2 = (blr.height() || paintsOver(styles, colors, LeftEdge, BottomEdge)) ? 0 : borders[BottomEdge];
qreal x1 = br.x();
@@ -389,7 +389,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles
if (tlr.height() || blr.height())
qDrawRoundedCorners(p, x1, y1, x2, y2, tlr, blr, LeftEdge, styles[LeftEdge], colors[LeftEdge]);
}
- if (styles[TopEdge] != BorderStyle_None) {
+ if (styles[TopEdge] != BorderStyle_None && borders[TopEdge] > 0) {
qreal dw1 = (tlr.width() || paintsOver(styles, colors, TopEdge, LeftEdge)) ? 0 : borders[LeftEdge];
qreal dw2 = (trr.width() || paintsOver(styles, colors, TopEdge, RightEdge)) ? 0 : borders[RightEdge];
qreal x1 = br.x() + tlr.width();
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 370290f..8ac811c 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -1298,7 +1298,6 @@ void QRenderRule::unsetClip(QPainter *p)
void QRenderRule::drawBackground(QPainter *p, const QRect& rect, const QPoint& off)
{
- setClip(p, borderRect(rect));
QBrush brush = hasBackground() ? background()->brush : QBrush();
if (brush.style() == Qt::NoBrush)
brush = defaultBackground;
@@ -1306,11 +1305,19 @@ void QRenderRule::drawBackground(QPainter *p, const QRect& rect, const QPoint& o
if (brush.style() != Qt::NoBrush) {
Origin origin = hasBackground() ? background()->clip : Origin_Border;
// ### fix for gradients
- p->fillRect(originRect(rect, origin), brush);
+ const QPainterPath &borderPath = borderClip(originRect(rect, origin));
+ if (!borderPath.isEmpty()) {
+ // Drawn intead of being used as clipping path for better visual quality
+ bool wasAntialiased = p->renderHints() & QPainter::Antialiasing;
+ p->setRenderHint(QPainter::Antialiasing);
+ p->fillPath(borderPath, brush);
+ p->setRenderHint(QPainter::Antialiasing, wasAntialiased);
+ } else {
+ p->fillRect(originRect(rect, origin), brush);
+ }
}
drawBackgroundImage(p, rect, off);
- unsetClip(p);
}
void QRenderRule::drawFrame(QPainter *p, const QRect& rect)