summaryrefslogtreecommitdiffstats
path: root/src/gui
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/gui
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/gui')
-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)
2.5.1&id=5890a6a8a68eb5658b7002501ec30e2e30eba144'>__phello__.foo.py64logstatsplain -rw-r--r--_strptime.py19666logstatsplain -rw-r--r--_threading_local.py6946logstatsplain -rw-r--r--aifc.py33417logstatsplain -rw-r--r--anydbm.py2620logstatsplain -rw-r--r--asynchat.py10764logstatsplain -rw-r--r--asyncore.py16744logstatsplain -rw-r--r--atexit.py1631logstatsplain -rw-r--r--audiodev.py7477logstatsplain -rwxr-xr-xbase64.py11296logstatsplain -rw-r--r--bdb.py20143logstatsplain -rw-r--r--binhex.py15023logstatsplain -rw-r--r--bisect.py2365logstatsplain d---------bsddb293logstatsplain -rwxr-xr-xcProfile.py6259logstatsplain -rw-r--r--calendar.py22987logstatsplain -rwxr-xr-xcgi.py35004logstatsplain -rw-r--r--cgitb.py12089logstatsplain -rw-r--r--chunk.py5372logstatsplain -rw-r--r--cmd.py14962logstatsplain -rw-r--r--code.py9968logstatsplain -rw-r--r--codecs.py33297logstatsplain -rw-r--r--codeop.py5999logstatsplain -rw-r--r--colorsys.py3449logstatsplain -rw-r--r--commands.py2279logstatsplain -rw-r--r--compileall.py5283logstatsplain d---------compiler415logstatsplain -rw-r--r--contextlib.py4105logstatsplain -rw-r--r--cookielib.py64171logstatsplain -rw-r--r--copy.py10943logstatsplain -rw-r--r--copy_reg.py6729logstatsplain -rw-r--r--csv.py15108logstatsplain d---------ctypes217logstatsplain d---------curses225logstatsplain -rw-r--r--dbhash.py404logstatsplain -rw-r--r--decimal.py107367logstatsplain -rw-r--r--difflib.py80826logstatsplain -rw-r--r--dircache.py1006logstatsplain -rw-r--r--dis.py6484logstatsplain d---------distutils1173logstatsplain -rw-r--r--doctest.py98258logstatsplain -rw-r--r--dumbdbm.py8402logstatsplain -rw-r--r--dummy_thread.py4571logstatsplain -rw-r--r--dummy_threading.py2900logstatsplain d---------email607logstatsplain d---------encodings4479logstatsplain -rw-r--r--filecmp.py9471logstatsplain -rw-r--r--fileinput.py14132logstatsplain -rw-r--r--fnmatch.py3019logstatsplain -rw-r--r--formatter.py14954logstatsplain -rw-r--r--fpformat.py4579logstatsplain -rw-r--r--ftplib.py27433logstatsplain -rw-r--r--functools.py2155logstatsplain -rw-r--r--getopt.py7316logstatsplain -rw-r--r--getpass.py3362logstatsplain -rw-r--r--gettext.py19890logstatsplain -rw-r--r--glob.py2010logstatsplain -rw-r--r--gopherlib.py5709logstatsplain -rw-r--r--gzip.py16942logstatsplain -rw-r--r--hashlib.py4834logstatsplain -rw-r--r--heapq.py14339logstatsplain -rw-r--r--hmac.py3580logstatsplain d---------hotshot146logstatsplain -rw-r--r--htmlentitydefs.py18054logstatsplain -rw-r--r--htmllib.py12740logstatsplain -rw-r--r--httplib.py47079logstatsplain d---------idlelib3039logstatsplain -rw-r--r--ihooks.py17335logstatsplain -rw-r--r--imaplib.py46561logstatsplain -rw-r--r--imghdr.py3538logstatsplain -rw-r--r--imputil.py25675logstatsplain -rw-r--r--inspect.py35722logstatsplain -rwxr-xr-xkeyword.py2043logstatsplain d---------lib-tk682logstatsplain -rw-r--r--linecache.py4070logstatsplain -rw-r--r--locale.py73052logstatsplain d---------logging115logstatsplain -rw-r--r--macpath.py7601logstatsplain -rw-r--r--macurl2path.py3275logstatsplain -rwxr-xr-xmailbox.py74281logstatsplain -rw-r--r--mailcap.py7427logstatsplain -rw-r--r--markupbase.py14350logstatsplain -rw-r--r--md5.py241logstatsplain -rw-r--r--mhlib.py33270logstatsplain -rw-r--r--mimetools.py6841logstatsplain -rw-r--r--mimetypes.py18690logstatsplain -rwxr-xr-xmimify.py14885logstatsplain -rw-r--r--modulefinder.py21151logstatsplain d---------msilib150logstatsplain -rw-r--r--multifile.py4677logstatsplain -rw-r--r--mutex.py1749logstatsplain -rw-r--r--netrc.py4111logstatsplain -rw-r--r--new.py541logstatsplain -rw-r--r--nntplib.py21196logstatsplain -rw-r--r--ntpath.py16576logstatsplain -rw-r--r--nturl2path.py2239logstatsplain -rw-r--r--opcode.py5210logstatsplain -rw-r--r--optparse.py60250logstatsplain -rw-r--r--os.py24479logstatsplain -rw-r--r--os2emxpath.py12660logstatsplain -rw-r--r--pdb.doc7483logstatsplain -rwxr-xr-xpdb.py41622logstatsplain -rw-r--r--pickle.py44792logstatsplain -rw-r--r--pickletools.py73421logstatsplain -rw-r--r--pipes.py9984logstatsplain -rw-r--r--pkgutil.py18491logstatsplain d---------plat-aix366logstatsplain d---------plat-aix466logstatsplain d---------plat-atheos102logstatsplain d---------plat-beos566logstatsplain d---------plat-darwin66logstatsplain d---------plat-freebsd266logstatsplain d---------plat-freebsd366logstatsplain d---------plat-freebsd466logstatsplain d---------plat-freebsd566logstatsplain d---------plat-freebsd666logstatsplain d---------plat-freebsd766logstatsplain d---------plat-generic33logstatsplain d---------plat-irix5916logstatsplain d---------plat-irix6879logstatsplain d---------plat-linux2174logstatsplain d---------plat-mac1295logstatsplain d---------plat-netbsd166logstatsplain d---------plat-next333logstatsplain d---------plat-os2emx211logstatsplain d---------plat-riscos126logstatsplain d---------plat-sunos5253logstatsplain d---------plat-unixware7104logstatsplain -rwxr-xr-xplatform.py40326logstatsplain -rw-r--r--popen2.py9588logstatsplain -rw-r--r--poplib.py12446logstatsplain -rw-r--r--posixfile.py7843logstatsplain -rw-r--r--posixpath.py13775logstatsplain -rw-r--r--pprint.py10878logstatsplain -rwxr-xr-xprofile.py23513logstatsplain -rw-r--r--pstats.py25934logstatsplain -rw-r--r--pty.py4832logstatsplain -rw-r--r--py_compile.py5518logstatsplain -rw-r--r--pyclbr.py13279logstatsplain -rwxr-xr-xpydoc.py89732logstatsplain -rwxr-xr-xquopri.py6969logstatsplain -rw-r--r--random.py30483logstatsplain -rw-r--r--re.py12232logstatsplain -rw-r--r--repr.py3976logstatsplain -rw-r--r--rexec.py20033logstatsplain -rw-r--r--rfc822.py33030logstatsplain -rw-r--r--rlcompleter.py5309logstatsplain -rw-r--r--robotparser.py9954logstatsplain -rwxr-xr-xrunpy.py3577logstatsplain -rw-r--r--sched.py4539logstatsplain -rw-r--r--sets.py19624logstatsplain -rw-r--r--sgmllib.py17772logstatsplain -rw-r--r--sha.py265logstatsplain -rw-r--r--shelve.py7565logstatsplain -rw-r--r--shlex.py11124logstatsplain -rw-r--r--shutil.py5960logstatsplain d---------site-packages34logstatsplain -rw-r--r--site.py14404logstatsplain -rwxr-xr-xsmtpd.py18016logstatsplain -rwxr-xr-xsmtplib.py26761logstatsplain -rw-r--r--sndhdr.py5971logstatsplain -rw-r--r--socket.py13185logstatsplain d---------sqlite3107logstatsplain -rw-r--r--sre.py294logstatsplain -rw-r--r--sre_compile.py16500logstatsplain -rw-r--r--sre_constants.py7137logstatsplain -rw-r--r--sre_parse.py26883logstatsplain -rw-r--r--stat.py1667logstatsplain -rw-r--r--statvfs.py779logstatsplain -rw-r--r--string.py16675logstatsplain -rw-r--r--stringold.py12333logstatsplain -rw-r--r--stringprep.py13522logstatsplain -rw-r--r--struct.py2970logstatsplain -rw-r--r--subprocess.py42405logstatsplain -rw-r--r--sunau.py16515logstatsplain -rw-r--r--sunaudio.py1236logstatsplain -rwxr-xr-xsymbol.py2031logstatsplain -rw-r--r--symtable.py7710logstatsplain -rwxr-xr-xtabnanny.py11336logstatsplain -rw-r--r--tarfile.py72758logstatsplain -rw-r--r--telnetlib.py22089logstatsplain -rw-r--r--tempfile.py14371logstatsplain d---------test16762logstatsplain