diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-04-28 23:28:38 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-04-28 23:28:38 (GMT) |
commit | e65477020b0b70c105606bab3d6c43fbde027117 (patch) | |
tree | 6fe429ea1c9ff77018a090631c4b00d0464fd31a /src/declarative/fx/qfximage.cpp | |
parent | 427c35771a83cce39f5f48c188c180d35ef6ecc9 (diff) | |
parent | 1cb0906f04ed49de26575252740b8bb5190e3025 (diff) | |
download | Qt-e65477020b0b70c105606bab3d6c43fbde027117.zip Qt-e65477020b0b70c105606bab3d6c43fbde027117.tar.gz Qt-e65477020b0b70c105606bab3d6c43fbde027117.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/fx/qfximage.cpp')
-rw-r--r-- | src/declarative/fx/qfximage.cpp | 91 |
1 files changed, 45 insertions, 46 deletions
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 2d0dbc7..a34cd12 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -124,7 +124,7 @@ QFxImage::QFxImage(QFxImagePrivate &dd, QFxItem *parent) QFxImage::~QFxImage() { Q_D(const QFxImage); - if(d->reply) + if (d->reply) d->reply->deleteLater(); } @@ -183,7 +183,8 @@ void QFxImage::setPixmap(const QPixmap &pix) Each scale grid property (left, right, top, and bottom) specifies an offset from the respective side. For example, \c scaleGrid.bottom="10" sets the bottom scale grid line 10 pixels up from the bottom of the image. - A scale grid can also be specified using a \l {Imagexmlpropertysrc}{.sci file}. + A scale grid can also be specified using a + \l {Image::src}{.sci file}. */ QFxScaleGrid *QFxImage::scaleGrid() { @@ -250,7 +251,7 @@ bool QFxImage::isOpaque() const void QFxImage::setOpaque(bool o) { Q_D(QFxImage); - if(o == d->_opaque) + if (o == d->_opaque) return; d->_opaque = o; d->_pix.setOpaque(o); @@ -299,7 +300,7 @@ bool QFxImage::smoothTransform() const void QFxImage::setSmoothTransform(bool s) { Q_D(QFxImage); - if(d->_smooth == s) + if (d->_smooth == s) return; d->_smooth = s; update(); @@ -317,10 +318,10 @@ void QFxImage::dump(int depth) void QFxImage::paintContents(QPainter &p) { Q_D(QFxImage); - if(d->_pix.isNull()) + if (d->_pix.isNull()) return; - if(d->_smooth) { + if (d->_smooth) { p.save(); p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->_smooth); } @@ -347,7 +348,7 @@ void QFxImage::paintContents(QPainter &p) p.restore(); } else if (!d->_scaleGrid || d->_scaleGrid->isNull()) { - if(width() != pix.width() || height() != pix.height()) { + if (width() != pix.width() || height() != pix.height()) { QTransform scale; scale.scale(width() / qreal(pix.width()), height() / qreal(pix.height())); @@ -367,45 +368,45 @@ void QFxImage::paintContents(QPainter &p) const int ySide = sgt + sgb; // Upper left - if(sgt && sgl) + if (sgt && sgl) p.drawImage(QRect(0, 0, sgl, sgt), pix, QRect(0, 0, sgl, sgt)); // Upper middle - if(pix.width() - xSide && sgt) + if (pix.width() - xSide && sgt) p.drawImage(QRect(sgl, 0, width() - xSide, sgt), pix, QRect(sgl, 0, pix.width() - xSide, sgt)); // Upper right - if(sgt && pix.width() - sgr) + if (sgt && pix.width() - sgr) p.drawImage(QPoint(width()-sgr, 0), pix, QRect(pix.width()-sgr, 0, sgr, sgt)); // Middle left - if(sgl && pix.height() - ySide) + if (sgl && pix.height() - ySide) p.drawImage(QRect(0, sgt, sgl, height() - ySide), pix, QRect(0, sgt, sgl, pix.height() - ySide)); // Middle - if(pix.width() - xSide && pix.height() - ySide) + if (pix.width() - xSide && pix.height() - ySide) p.drawImage(QRect(sgl, sgt, width() - xSide, height() - ySide), pix, QRect(sgl, sgt, pix.width() - xSide, pix.height() - ySide)); // Middle right - if(sgr && pix.height() - ySide) + if (sgr && pix.height() - ySide) p.drawImage(QRect(width()-sgr, sgt, sgr, height() - ySide), pix, QRect(pix.width()-sgr, sgt, sgr, pix.height() - ySide)); // Lower left - if(sgl && sgr) + if (sgl && sgr) p.drawImage(QPoint(0, height() - sgb), pix, QRect(0, pix.height() - sgb, sgl, sgb)); // Lower Middle - if(pix.width() - xSide && sgb) + if (pix.width() - xSide && sgb) p.drawImage(QRect(sgl, height() - sgb, width() - xSide, sgb), pix, QRect(sgl, pix.height() - sgb, pix.width() - xSide, sgb)); // Lower Right - if(sgr && sgb) + if (sgr && sgb) p.drawImage(QPoint(width()-sgr, height() - sgb), pix, QRect(pix.width()-sgr, pix.height() - sgb, sgr, sgb)); } - if(d->_smooth) { + if (d->_smooth) { p.restore(); } } @@ -415,10 +416,10 @@ uint QFxImage::glSimpleItemData(float *vertices, float *texVertices, { Q_D(QFxImage); - if(d->_pix.isNull() || (d->_scaleGrid && !d->_scaleGrid->isNull())) + if (d->_pix.isNull() || (d->_scaleGrid && !d->_scaleGrid->isNull())) return 0; - if(count < 8) + if (count < 8) return 8; d->checkDirty(); @@ -433,7 +434,7 @@ uint QFxImage::glSimpleItemData(float *vertices, float *texVertices, *texture = &d->_tex; - if(d->_tiled) { + if (d->_tiled) { float tileWidth = widthV / d->_pix.width(); float tileHeight = heightV / d->_pix.height(); texVertices[0] = 0; texVertices[1] = 0; @@ -452,7 +453,7 @@ uint QFxImage::glSimpleItemData(float *vertices, float *texVertices, void QFxImagePrivate::checkDirty() { - if(_texDirty && !_pix.isNull()) { + if (_texDirty && !_pix.isNull()) { _tex.setImage(_pix); _tex.setHorizontalWrap(GLTexture::Repeat); _tex.setVerticalWrap(GLTexture::Repeat); @@ -464,18 +465,18 @@ void QFxImagePrivate::checkDirty() void QFxImage::paintGLContents(GLPainter &p) { Q_D(QFxImage); - if(d->_pix.isNull()) + if (d->_pix.isNull()) return; QGLShaderProgram *shader = p.useTextureShader(); bool restoreBlend = false; - if(isOpaque() && p.activeOpacity == 1) { + if (isOpaque() && p.activeOpacity == 1) { glDisable(GL_BLEND); restoreBlend = true; } - if(d->_tiled || (!d->_scaleGrid || d->_scaleGrid->isNull())) { + if (d->_tiled || (!d->_scaleGrid || d->_scaleGrid->isNull())) { GLfloat vertices[8]; GLfloat texVertices[8]; @@ -497,7 +498,7 @@ void QFxImage::paintGLContents(GLPainter &p) float imgWidth = d->_pix.width(); float imgHeight = d->_pix.height(); - if(!imgWidth || !imgHeight) { + if (!imgWidth || !imgHeight) { if (restoreBlend) glEnable(GL_BLEND); return; @@ -520,19 +521,19 @@ void QFxImage::paintGLContents(GLPainter &p) const int sgt = d->_scaleGrid->top(); const int sgb = d->_scaleGrid->bottom(); - if(sgl) { + if (sgl) { texleft = float(sgl) / imgWidth; imgleft = sgl; } - if(sgr) { + if (sgr) { texright = 1. - float(sgr) / imgWidth; imgright = widthV - sgr; } - if(sgt) { + if (sgt) { textop = 1. - float(sgb) / imgHeight; imgtop = sgt; } - if(sgb) { + if (sgb) { texbottom = float(sgt) / imgHeight; imgbottom = heightV - sgb; } @@ -609,20 +610,20 @@ void QFxImage::paintGLContents(GLPainter &p) void QFxImage::paintGLContents(GLPainter &p) { Q_D(QFxImage); - if(d->_pix.isNull()) + if (d->_pix.isNull()) return; glMatrixMode(GL_MODELVIEW); glLoadMatrixf(p.activeTransform.data()); bool restoreBlend = false; - if(isOpaque() && p.activeOpacity == 1) { + if (isOpaque() && p.activeOpacity == 1) { glDisable(GL_BLEND); restoreBlend = true; } glEnable(GL_TEXTURE_2D); - if(p.activeOpacity == 1.) { + if (p.activeOpacity == 1.) { GLint i = GL_REPLACE; glTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &i); } else { @@ -631,7 +632,7 @@ void QFxImage::paintGLContents(GLPainter &p) glColor4f(1, 1, 1, p.activeOpacity); } - if(d->_tiled || !d->_scaleGrid || d->_scaleGrid->isNull()) { + if (d->_tiled || !d->_scaleGrid || d->_scaleGrid->isNull()) { GLfloat vertices[8]; GLfloat texVertices[8]; @@ -659,7 +660,7 @@ void QFxImage::paintGLContents(GLPainter &p) float imgWidth = d->_pix.width(); float imgHeight = d->_pix.height(); - if(!imgWidth || !imgHeight) { + if (!imgWidth || !imgHeight) { if (restoreBlend) glEnable(GL_BLEND); return; @@ -682,19 +683,19 @@ void QFxImage::paintGLContents(GLPainter &p) const int sgt = d->_scaleGrid->top(); const int sgb = d->_scaleGrid->bottom(); - if(sgl) { + if (sgl) { texleft = float(sgl) / imgWidth; imgleft = sgl; } - if(sgr) { + if (sgr) { texright = 1. - float(sgr) / imgWidth; imgright = widthV - sgr; } - if(sgt) { + if (sgt) { textop = 1. - float(sgb) / imgHeight; imgtop = sgt; } - if(sgb) { + if (sgb) { texbottom = float(sgt) / imgHeight; imgbottom = heightV - sgb; } @@ -792,11 +793,9 @@ QFxImage::Status QFxImage::status() const Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. - \target Imagexmlpropertysrc - It can also handle .sci files, which are a Qml-specific format. A .sci file uses a simple text-based format that specifies \list - \i the grid lines describing a \l {ImagexmlpropertiesscaleGrid}{scale grid}. + \i the grid lines describing a \l {Image::scaleGrid.left}{scale grid}. \i an image file. \endlist @@ -828,10 +827,10 @@ QString QFxImage::source() const void QFxImage::setSource(const QString &url) { Q_D(QFxImage); - if(url == d->source) + if (url == d->source) return; - if(d->reply) { + if (d->reply) { d->reply->deleteLater(); d->reply = 0; } @@ -845,7 +844,7 @@ void QFxImage::setSource(const QString &url) d->url = qmlContext(this)->resolvedUrl(url); d->sciurl = QUrl(); - if(url.isEmpty()) { + if (url.isEmpty()) { setPixmap(QPixmap()); d->status = Idle; } else { @@ -899,7 +898,7 @@ void QFxImage::requestFinished() void QFxImage::sciRequestFinished() { Q_D(QFxImage); - if(d->reply->error() != QNetworkReply::NoError) { + if (d->reply->error() != QNetworkReply::NoError) { d->status = Error; d->reply->deleteLater(); d->reply = 0; @@ -916,7 +915,7 @@ void QFxImage::sciRequestFinished() void QFxImage::setGridScaledImage(const QFxGridScaledImage& sci) { Q_D(QFxImage); - if(!sci.isValid()) { + if (!sci.isValid()) { d->status = Error; emit statusChanged(d->status); } else { |