summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx/qfxrect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/fx/qfxrect.cpp')
-rw-r--r--src/declarative/fx/qfxrect.cpp38
1 files changed, 10 insertions, 28 deletions
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index eb8103c..f35fe3d 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -74,7 +74,7 @@ void QFxPen::setColor(const QColor &c)
void QFxPen::setWidth(int w)
{
- if (_width == w)
+ if (_width == w && _valid)
return;
_width = w;
@@ -425,41 +425,21 @@ void QFxRect::drawRect(QPainter &p)
if (d->smooth)
p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
- int offset = 0;
const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0;
- if (d->radius > 0) {
+ if (d->radius > 0)
generateRoundedRect();
- //### implicit conversion to int
- offset = int(d->radius+1.5+pw);
- } else {
+ else
generateBorderedRect();
- offset = pw+1;
- }
- //basically same code as QFxImage uses to paint sci images
- int w = width()+pw;
- int h = height()+pw;
- int xOffset = offset;
- int xSide = xOffset * 2;
- bool xMiddles=true;
- if (xSide > w) {
- xMiddles=false;
- xOffset = w/2 + 1;
- xSide = xOffset * 2;
- }
- int yOffset = offset;
- int ySide = yOffset * 2;
- bool yMiddles=true;
- if (ySide > h) {
- yMiddles = false;
- yOffset = h/2 + 1;
- ySide = yOffset * 2;
- }
+ int xOffset = (d->rectImage.width()-1)/2;
+ int yOffset = (d->rectImage.height()-1)/2;
+ Q_ASSERT(d->rectImage.width() == 2*xOffset + 1);
+ Q_ASSERT(d->rectImage.height() == 2*yOffset + 1);
QMargins margins(xOffset, yOffset, xOffset, yOffset);
QTileRules rules(Qt::StretchTile, Qt::StretchTile);
- qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, d->rectImage.width()/2 + xOffset*2, d->rectImage.height()/2 + yOffset*2), margins, d->rectImage, d->rectImage.rect(), margins, rules);
+ qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width()+pw, height()+pw), margins, d->rectImage, d->rectImage.rect(), margins, rules);
if (d->smooth) {
p.setRenderHint(QPainter::Antialiasing, oldAA);
@@ -479,6 +459,8 @@ void QFxRect::drawRect(QPainter &p)
\note Generally scaling artifacts are only visible if the item is stationary on
the screen. A common pattern when animating an item is to disable smooth
filtering at the beginning of the animation and reenable it at the conclusion.
+
+ \image rect-smooth.png
*/
QRectF QFxRect::boundingRect() const