From: Alan Alpert Date: Tue, 1 May 2012 07:25:38 +0000 (+1000) Subject: End the deprecation period of SpriteImage X-Git-Tag: 071012131707~409 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f36e1bc949e63fb53f37662ff2e21cad0183ad1;p=profile%2Fivi%2Fqtdeclarative.git End the deprecation period of SpriteImage Also remove the stale files left around. Change-Id: I2f275f23ebfb65045cc683ccd542cbc451b767fb Reviewed-by: Martin Jones --- diff --git a/doc/src/qtquick2/whatsnew.qdoc b/doc/src/qtquick2/whatsnew.qdoc index 1997a42..0fe3bab 100644 --- a/doc/src/qtquick2/whatsnew.qdoc +++ b/doc/src/qtquick2/whatsnew.qdoc @@ -91,8 +91,8 @@ The \l{QtQuick.Particles 2}{QtQuick.Particles} module contains elements that can \section2 Element API/Behavior Changes -New \l SpriteImage element renders animated sprites and can transition between animations. -It uses the \l Sprite element to represent each animation. +New \l SpriteSequence element renders animated sprites and can transition between animations. +It uses the \l Sprite element to represent each animation. For single sprites, there is also \l AnimatedSprite. MouseArea now propagates clicked, doubleClicked and pressAndHold differently to pressed. These will now be propagated to the highest-stacking-order enabled MouseArea which has a handler for them. diff --git a/src/quick/doc/src/whatsnew.qdoc b/src/quick/doc/src/whatsnew.qdoc index 1997a42..56cb341 100644 --- a/src/quick/doc/src/whatsnew.qdoc +++ b/src/quick/doc/src/whatsnew.qdoc @@ -91,8 +91,8 @@ The \l{QtQuick.Particles 2}{QtQuick.Particles} module contains elements that can \section2 Element API/Behavior Changes -New \l SpriteImage element renders animated sprites and can transition between animations. -It uses the \l Sprite element to represent each animation. +New \l SpriteSequence element renders animated sprites and can transition between animations. +It uses the \l Sprite element to represent each animation. For drawing single sprite animations, there is also the \l AnimatedSprite element. MouseArea now propagates clicked, doubleClicked and pressAndHold differently to pressed. These will now be propagated to the highest-stacking-order enabled MouseArea which has a handler for them. diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h index fb00136..6632f6d 100644 --- a/src/quick/items/qquickanimatedsprite_p.h +++ b/src/quick/items/qquickanimatedsprite_p.h @@ -61,7 +61,7 @@ class Q_AUTOTEST_EXPORT QQuickAnimatedSprite : public QQuickItem Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged) Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged) //###try to share similar spriteEngines for less overhead? - //These properties come out of QQuickSprite, since a SimpleSpriteImage is a renderer for a single sprite + //These properties come out of QQuickSprite, since an AnimatedSprite is a renderer for a single sprite Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) Q_PROPERTY(bool reverse READ reverse WRITE setReverse NOTIFY reverseChanged) Q_PROPERTY(bool frameSync READ frameSync WRITE setFrameSync NOTIFY frameSyncChanged) diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index 421a4cd..3348122 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -205,7 +205,6 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) qmlRegisterType("QtQuick", 2, 0, "Sprite"); qmlRegisterType("QtQuick", 2, 0, "AnimatedSprite"); qmlRegisterType("QtQuick", 2, 0, "SpriteSequence"); - qmlRegisterType("QtQuick", 2, 0, "SpriteImage");//Deprecation in progress qmlRegisterType(uri, major, minor,"ParentChange"); qmlRegisterType(uri, major, minor,"AnchorChanges"); diff --git a/src/quick/items/qquickspriteimage.cpp b/src/quick/items/qquickspriteimage.cpp deleted file mode 100644 index fca6fbc..0000000 --- a/src/quick/items/qquickspriteimage.cpp +++ /dev/null @@ -1,481 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickspriteimage_p.h" -#include "qquicksprite_p.h" -#include "qquickspriteengine_p.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -static const char vertexShaderCode[] = - "attribute highp vec2 vTex;\n" - "uniform highp vec3 animData;// w,h(premultiplied of anim), interpolation progress\n" - "uniform highp vec4 animPos;//x,y, x,y (two frames for interpolation)\n" - "uniform highp vec2 size;//w,h of element\n" - "\n" - "uniform highp mat4 qt_Matrix;\n" - "\n" - "varying highp vec4 fTexS;\n" - "varying lowp float progress;\n" - "\n" - "\n" - "void main() {\n" - " progress = animData.z;\n" - " //Calculate frame location in texture\n" - " fTexS.xy = animPos.xy + vTex.xy * animData.xy;\n" - " //Next frame is also passed, for interpolation\n" - " fTexS.zw = animPos.zw + vTex.xy * animData.xy;\n" - "\n" - " gl_Position = qt_Matrix * vec4(size.x * vTex.x, size.y * vTex.y, 0, 1);\n" - "}\n"; - -static const char fragmentShaderCode[] = - "uniform sampler2D texture;\n" - "uniform lowp float qt_Opacity;\n" - "\n" - "varying highp vec4 fTexS;\n" - "varying lowp float progress;\n" - "\n" - "void main() {\n" - " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), progress) * qt_Opacity;\n" - "}\n"; - -class QQuickSpriteImageMaterial : public QSGMaterial -{ -public: - QQuickSpriteImageMaterial(); - ~QQuickSpriteImageMaterial(); - virtual QSGMaterialType *type() const { static QSGMaterialType type; return &type; } - virtual QSGMaterialShader *createShader() const; - virtual int compare(const QSGMaterial *other) const - { - return this - static_cast(other); - } - - QSGTexture *texture; - - float animT; - float animX1; - float animY1; - float animX2; - float animY2; - float animW; - float animH; - float elementWidth; - float elementHeight; -}; - -QQuickSpriteImageMaterial::QQuickSpriteImageMaterial() - : animT(0.0f) - , animX1(0.0f) - , animY1(0.0f) - , animX2(0.0f) - , animY2(0.0f) - , animW(1.0f) - , animH(1.0f) - , elementWidth(1.0f) - , elementHeight(1.0f) -{ - setFlag(Blending, true); -} - -QQuickSpriteImageMaterial::~QQuickSpriteImageMaterial() -{ - delete texture; -} - -class SpriteImageMaterialData : public QSGMaterialShader -{ -public: - SpriteImageMaterialData(const char * /* vertexFile */ = 0, const char * /* fragmentFile */ = 0) - { - } - - void deactivate() { - QSGMaterialShader::deactivate(); - - for (int i=0; i<8; ++i) { - program()->setAttributeArray(i, GL_FLOAT, chunkOfBytes, 1, 0); - } - } - - virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) - { - QQuickSpriteImageMaterial *m = static_cast(newEffect); - m->texture->bind(); - - program()->setUniformValue(m_opacity_id, state.opacity()); - program()->setUniformValue(m_animData_id, m->animW, m->animH, m->animT); - program()->setUniformValue(m_animPos_id, m->animX1, m->animY1, m->animX2, m->animY2); - program()->setUniformValue(m_size_id, m->elementWidth, m->elementHeight); - - if (state.isMatrixDirty()) - program()->setUniformValue(m_matrix_id, state.combinedMatrix()); - } - - virtual void initialize() { - m_matrix_id = program()->uniformLocation("qt_Matrix"); - m_opacity_id = program()->uniformLocation("qt_Opacity"); - m_animData_id = program()->uniformLocation("animData"); - m_animPos_id = program()->uniformLocation("animPos"); - m_size_id = program()->uniformLocation("size"); - } - - virtual const char *vertexShader() const { return vertexShaderCode; } - virtual const char *fragmentShader() const { return fragmentShaderCode; } - - virtual char const *const *attributeNames() const { - static const char *attr[] = { - "vTex", - 0 - }; - return attr; - } - - int m_matrix_id; - int m_opacity_id; - int m_animData_id; - int m_animPos_id; - int m_size_id; - - static float chunkOfBytes[1024]; -}; - -float SpriteImageMaterialData::chunkOfBytes[1024]; - -QSGMaterialShader *QQuickSpriteImageMaterial::createShader() const -{ - return new SpriteImageMaterialData; -} - -struct SpriteVertex { - float tx; - float ty; -}; - -struct SpriteVertices { - SpriteVertex v1; - SpriteVertex v2; - SpriteVertex v3; - SpriteVertex v4; -}; - -/*! - \qmlclass SpriteImage QQuickSpriteImage - \inqmlmodule QtQuick 2 - \inherits Item - \brief The SpriteImage element draws a sprite animation - -*/ -/*! - \qmlproperty bool QtQuick2::SpriteImage::running - - Whether the sprite is animating or not. - - Default is true -*/ -/*! - \qmlproperty bool QtQuick2::SpriteImage::interpolate - - If true, interpolation will occur between sprite frames to make the - animation appear smoother. - - Default is true. -*/ -/*! - \qmlproperty string QtQuick2::SpriteImage::goalSprite - - The name of the Sprite which is currently animating. -*/ -/*! - \qmlproperty string QtQuick2::SpriteImage::goalSprite - - The name of the Sprite which the animation should move to. - - Sprite states have defined durations and transitions between them, setting goalState - will cause it to disregard any path weightings (including 0) and head down the path - which will reach the goalState quickest (fewest animations). It will pass through - intermediate states on that path, and animate them for their duration. - - If it is possible to return to the goalState from the starting point of the goalState - it will continue to do so until goalState is set to "" or an unreachable state. -*/ -/*! \qmlmethod void QtQuick2::SpriteImage::jumpTo(string sprite) - - This function causes the sprite to jump to the specified state immediately, intermediate - states are not played. -*/ -/*! - \qmlproperty list QtQuick2::SpriteImage::sprites - - The sprite or sprites to draw. Sprites will be scaled to the size of this element. -*/ - -//TODO: Implicitly size element to size of first sprite? or currentSprite? -QQuickSpriteImage::QQuickSpriteImage(QQuickItem *parent) : - QQuickItem(parent) - , m_node(0) - , m_material(0) - , m_spriteEngine(0) - , m_curFrame(0) - , m_pleaseReset(false) - , m_running(true) - , m_interpolate(true) - , m_curStateIdx(0) -{ - setFlag(ItemHasContents); - connect(this, SIGNAL(runningChanged(bool)), - this, SLOT(update())); -} - -void QQuickSpriteImage::jumpTo(const QString &sprite) -{ - if (!m_spriteEngine) - return; - m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite), 0, true); -} - -void QQuickSpriteImage::setGoalSprite(const QString &sprite) -{ - if (m_goalState != sprite){ - m_goalState = sprite; - emit goalSpriteChanged(sprite); - m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite)); - } -} - -QQmlListProperty QQuickSpriteImage::sprites() -{ - return QQmlListProperty(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear); -} - -void QQuickSpriteImage::createEngine() -{ - //TODO: delay until component complete - if (m_spriteEngine) - delete m_spriteEngine; - if (m_sprites.count()) - m_spriteEngine = new QQuickSpriteEngine(m_sprites, this); - else - m_spriteEngine = 0; - reset(); -} - -static QSGGeometry::Attribute SpriteImage_Attributes[] = { - QSGGeometry::Attribute::create(0, 2, GL_FLOAT), // tex -}; - -static QSGGeometry::AttributeSet SpriteImage_AttributeSet = -{ - 1, // Attribute Count - 2 * sizeof(float), - SpriteImage_Attributes -}; - -QSGGeometryNode* QQuickSpriteImage::buildNode() -{ - if (!m_spriteEngine) { - qmlInfo(this) << "No sprite engine..."; - return 0; - } else if (m_spriteEngine->status() == QQuickPixmap::Null) { - m_spriteEngine->startAssemblingImage(); - update();//Schedule another update, where we will check again - return 0; - } else if (m_spriteEngine->status() == QQuickPixmap::Loading) { - update();//Schedule another update, where we will check again - return 0; - } - - m_material = new QQuickSpriteImageMaterial(); - - QImage image = m_spriteEngine->assembledImage(); - if (image.isNull()) - return 0; - m_sheetSize = QSizeF(image.size()); - m_material->texture = canvas()->createTextureFromImage(image); - m_material->texture->setFiltering(QSGTexture::Linear); - m_spriteEngine->start(0); - m_material->animT = 0; - m_material->animX1 = m_spriteEngine->spriteX() / m_sheetSize.width(); - m_material->animY1 = m_spriteEngine->spriteY() / m_sheetSize.height(); - m_material->animX2 = m_material->animX1; - m_material->animY2 = m_material->animY1; - m_material->animW = m_spriteEngine->spriteWidth() / m_sheetSize.width(); - m_material->animH = m_spriteEngine->spriteHeight() / m_sheetSize.height(); - m_material->elementWidth = width(); - m_material->elementHeight = height(); - m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name(); - emit currentSpriteChanged(m_curState); - - int vCount = 4; - int iCount = 6; - QSGGeometry *g = new QSGGeometry(SpriteImage_AttributeSet, vCount, iCount); - g->setDrawingMode(GL_TRIANGLES); - - SpriteVertices *p = (SpriteVertices *) g->vertexData(); - - p->v1.tx = 0; - p->v1.ty = 0; - - p->v2.tx = 1.0; - p->v2.ty = 0; - - p->v3.tx = 0; - p->v3.ty = 1.0; - - p->v4.tx = 1.0; - p->v4.ty = 1.0; - - quint16 *indices = g->indexDataAsUShort(); - indices[0] = 0; - indices[1] = 1; - indices[2] = 2; - indices[3] = 1; - indices[4] = 3; - indices[5] = 2; - - - m_timestamp.start(); - m_node = new QSGGeometryNode(); - m_node->setGeometry(g); - m_node->setMaterial(m_material); - m_node->setFlag(QSGGeometryNode::OwnsMaterial); - return m_node; -} - -void QQuickSpriteImage::reset() -{ - m_pleaseReset = true; -} - -QSGNode *QQuickSpriteImage::updatePaintNode(QSGNode *, UpdatePaintNodeData *) -{ - if (m_pleaseReset) { - delete m_node; - - m_node = 0; - m_material = 0; - m_pleaseReset = false; - } - - prepareNextFrame(); - - if (m_running) { - update(); - if (m_node) - m_node->markDirty(QSGNode::DirtyMaterial); - } - - return m_node; -} - -void QQuickSpriteImage::prepareNextFrame() -{ - if (m_node == 0) - m_node = buildNode(); - if (m_node == 0) //error creating node - return; - - uint timeInt = m_timestamp.elapsed(); - qreal time = timeInt / 1000.; - m_material->elementHeight = height(); - m_material->elementWidth = width(); - - //Advance State - m_spriteEngine->updateSprites(timeInt); - if (m_curStateIdx != m_spriteEngine->curState()) { - m_curStateIdx = m_spriteEngine->curState(); - m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name(); - emit currentSpriteChanged(m_curState); - m_curFrame= -1; - } - - //Advance Sprite - qreal animT = m_spriteEngine->spriteStart()/1000.0; - qreal frameCount = m_spriteEngine->spriteFrames(); - qreal frameDuration = m_spriteEngine->spriteDuration()/frameCount; - double frameAt; - qreal progress; - if (frameDuration > 0) { - qreal frame = (time - animT)/(frameDuration / 1000.0); - frame = qBound(qreal(0.0), frame, frameCount - qreal(1.0));//Stop at count-1 frames until we have between anim interpolation - progress = modf(frame,&frameAt); - } else { - m_curFrame++; - if (m_curFrame >= frameCount){ - m_curFrame = 0; - m_spriteEngine->advance(); - } - frameAt = m_curFrame; - progress = 0; - } - if (m_spriteEngine->sprite()->reverse()) - frameAt = (m_spriteEngine->spriteFrames() - 1) - frameAt; - qreal y = m_spriteEngine->spriteY() / m_sheetSize.height(); - qreal w = m_spriteEngine->spriteWidth() / m_sheetSize.width(); - qreal h = m_spriteEngine->spriteHeight() / m_sheetSize.height(); - qreal x1 = m_spriteEngine->spriteX() / m_sheetSize.width(); - x1 += frameAt * w; - qreal x2 = x1; - if (frameAt < (frameCount-1)) - x2 += w; - - m_material->animX1 = x1; - m_material->animY1 = y; - m_material->animX2 = x2; - m_material->animY2 = y; - m_material->animW = w; - m_material->animH = h; - m_material->animT = m_interpolate ? progress : 0.0; -} - -QT_END_NAMESPACE diff --git a/src/quick/items/qquickspriteimage_p.h b/src/quick/items/qquickspriteimage_p.h deleted file mode 100644 index 1574afc..0000000 --- a/src/quick/items/qquickspriteimage_p.h +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKSPRITEIMAGE_P_H -#define QQUICKSPRITEIMAGE_P_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QSGContext; -class QQuickSprite; -class QQuickSpriteEngine; -class QSGGeometryNode; -class QQuickSpriteImageMaterial; -class Q_AUTOTEST_EXPORT QQuickSpriteImage : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged) - Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged) - Q_PROPERTY(QString goalSprite READ goalSprite WRITE setGoalSprite NOTIFY goalSpriteChanged) - Q_PROPERTY(QString currentSprite READ currentSprite NOTIFY currentSpriteChanged) - //###try to share similar spriteEngines for less overhead? - Q_PROPERTY(QQmlListProperty sprites READ sprites) - Q_CLASSINFO("DefaultProperty", "sprites") - -public: - explicit QQuickSpriteImage(QQuickItem *parent = 0); - - QQmlListProperty sprites(); - - bool running() const - { - return m_running; - } - - bool interpolate() const - { - return m_interpolate; - } - - QString goalSprite() const - { - return m_goalState; - } - - QString currentSprite() const - { - return m_curState; - } - -signals: - - void runningChanged(bool arg); - void interpolateChanged(bool arg); - void goalSpriteChanged(QString arg); - void currentSpriteChanged(QString arg); - -public slots: - - void jumpTo(const QString &sprite); - void setGoalSprite(const QString &sprite); - - void setRunning(bool arg) - { - if (m_running != arg) { - m_running = arg; - emit runningChanged(arg); - } - } - - void setInterpolate(bool arg) - { - if (m_interpolate != arg) { - m_interpolate = arg; - emit interpolateChanged(arg); - } - } - -private slots: - void createEngine(); -protected: - void reset(); - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); -private: - void prepareNextFrame(); - QSGGeometryNode* buildNode(); - QSGGeometryNode *m_node; - QQuickSpriteImageMaterial *m_material; - QList m_sprites; - QQuickSpriteEngine* m_spriteEngine; - QTime m_timestamp; - int m_curFrame; - bool m_pleaseReset; - bool m_running; - bool m_interpolate; - QString m_goalState; - QString m_curState; - int m_curStateIdx; - QSizeF m_sheetSize; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QQUICKSPRITEIMAGE_P_H diff --git a/tests/auto/quick/qquickspriteimage/data/advance.qml b/tests/auto/quick/qquickspriteimage/data/advance.qml deleted file mode 100644 index 46a49ca..0000000 --- a/tests/auto/quick/qquickspriteimage/data/advance.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - color: "black" - width: 320 - height: 320 - - SpriteImage { - objectName: "sprite" - sprites: [Sprite { - name: "firstState" - source: "squarefacesprite.png" - frames: 3 - frameSync: true - to: {"secondState":1} - }, Sprite { - name: "secondState" - source: "squarefacesprite.png" - frames: 6 - frameSync: true - } ] - width: 160 - height: 160 - } -} diff --git a/tests/auto/quick/qquickspriteimage/data/basic.qml b/tests/auto/quick/qquickspriteimage/data/basic.qml deleted file mode 100644 index 2f2b1c9..0000000 --- a/tests/auto/quick/qquickspriteimage/data/basic.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - color: "black" - width: 320 - height: 320 - - SpriteImage { - objectName: "sprite" - sprites: Sprite { - name: "happy" - source: "squarefacesprite.png" - frames: 6 - frameDuration: 120 - } - width: 160 - height: 160 - } -} diff --git a/tests/auto/quick/qquickspriteimage/data/squarefacesprite.png b/tests/auto/quick/qquickspriteimage/data/squarefacesprite.png deleted file mode 100644 index f9a5d5f..0000000 Binary files a/tests/auto/quick/qquickspriteimage/data/squarefacesprite.png and /dev/null differ diff --git a/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro b/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro deleted file mode 100644 index 02d45b9..0000000 --- a/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro +++ /dev/null @@ -1,13 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickspriteimage -SOURCES += tst_qquickspriteimage.cpp - -include (../../shared/util.pri) - -macx:CONFIG -= app_bundle - -TESTDATA = data/* - -CONFIG += parallel_test - -QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp b/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp deleted file mode 100644 index 7aff773..0000000 --- a/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include "../../shared/util.h" -#include -#include - -class tst_qquickspriteimage : public QQmlDataTest -{ - Q_OBJECT -public: - tst_qquickspriteimage(){} - -private slots: - void test_properties(); - void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine -}; - -void tst_qquickspriteimage::test_properties() -{ - QQuickView *canvas = new QQuickView(0); - - canvas->setSource(testFileUrl("basic.qml")); - canvas->show(); - QTest::qWaitForWindowShown(canvas); - - QVERIFY(canvas->rootObject()); - QQuickSpriteImage* sprite = canvas->rootObject()->findChild("sprite"); - QVERIFY(sprite); - - QVERIFY(sprite->running()); - QVERIFY(sprite->interpolate()); - - sprite->setRunning(false); - QVERIFY(!sprite->running()); - sprite->setInterpolate(false); - QVERIFY(!sprite->interpolate()); - - delete canvas; -} - -void tst_qquickspriteimage::test_framerateAdvance() -{ - QQuickView *canvas = new QQuickView(0); - - canvas->setSource(testFileUrl("advance.qml")); - canvas->show(); - QTest::qWaitForWindowShown(canvas); - - QVERIFY(canvas->rootObject()); - QQuickSpriteImage* sprite = canvas->rootObject()->findChild("sprite"); - QVERIFY(sprite); - - QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState")); - delete canvas; -} - -QTEST_MAIN(tst_qquickspriteimage) - -#include "tst_qquickspriteimage.moc" diff --git a/tests/testapplications/elements/content/GridViewElement.qml b/tests/testapplications/elements/content/GridViewElement.qml index 0e0eaba..a276b61 100644 --- a/tests/testapplications/elements/content/GridViewElement.qml +++ b/tests/testapplications/elements/content/GridViewElement.qml @@ -123,6 +123,6 @@ Rectangle { ListElement { label: "Shape"; help: "The Shape element allows you to specify an area for affectors and emitter." } ListElement { label: "TrailEmitter"; help: "The TrailEmitter element allows you to emit logical particles from other logical particles." } ListElement { label: "Direction"; help: "The Direction elements allow you to specify a vector space." } - ListElement { label: "SpriteImage"; help: "The SpriteImage element plays stochastic sprite animations." } + ListElement { label: "SpriteSequence"; help: "The SpriteSequence element plays stochastic sprite animations." } } } diff --git a/tests/testapplications/elements/content/SpriteImageElement.qml b/tests/testapplications/elements/content/SpriteSequenceElement.qml similarity index 91% rename from tests/testapplications/elements/content/SpriteImageElement.qml rename to tests/testapplications/elements/content/SpriteSequenceElement.qml index 1270aef..8b0a93b 100644 --- a/tests/testapplications/elements/content/SpriteImageElement.qml +++ b/tests/testapplications/elements/content/SpriteSequenceElement.qml @@ -45,61 +45,61 @@ Item { id: spriteimageelementtest anchors.fill: parent property string testtext: "" - SpriteImage { + SpriteSequence { id: spriteimage sprites: [Sprite { name: "happy" source: "pics/squarefacesprite2.png" frames: 6 - duration: 120 + frameDuration: 120 to: {"silly": 1, "sad":0} }, Sprite { name: "silly" source: "pics/squarefacesprite.png" frames: 6 - duration: 120 + frameDuration: 120 to: {"happy": 1, "sad": 0} }, Sprite { name: "sad" source: "pics/squarefacesprite3.png" frames: 6 - duration: 120 + frameDuration: 120 to: {"evil": 0.5, "sad": 1, "cyclops" : 0} }, Sprite { name: "cyclops" source: "pics/squarefacesprite4.png" frames: 6 - duration: 120 + frameDuration: 120 to: {"love": 0.1, "boggled": 0.1, "cyclops" : 0.1} }, Sprite { name: "evil" source: "pics/squarefacesprite5.png" frames: 6 - duration: 120 + frameDuration: 120 to: {"sad": 1.0, "cyclops" : 0} }, Sprite { name: "love" source: "pics/squarefacesprite6.png" frames: 6 - duration: 120 + frameDuration: 120 to: {"love": 0.1, "boggled": 0.1, "cyclops" : 0.1} }, Sprite { name: "boggled" source: "pics/squarefacesprite7.png" frames: 6 - duration: 120 + frameDuration: 120 to: {"love": 0.1, "boggled": 0.1, "cyclops" : 0.1, "dying":0} }, Sprite { name: "dying" source: "pics/squarefacespriteX.png" frames: 4 - duration: 120 + frameDuration: 120 to: {"dead":1.0} }, Sprite { name: "dead" source: "pics/squarefacespriteXX.png" frames: 1 - duration: 10000 + frameDuration: 10000 }] width: 300 @@ -118,7 +118,7 @@ Item { State { name: "start"; when: statenum == 1 StateChangeScript { script: spriteimage.jumpTo("happy"); } PropertyChanges { target: spriteimageelementtest - testtext: "This is a SpriteImage element. It should be animating currently."+ + testtext: "This is a SpriteSequence element. It should be animating currently."+ "It should alternate between winking and sticking out its tongue." } }, State { name: "stochastic2"; when: statenum == 2 @@ -136,7 +136,7 @@ Item { "When it does, it should first animate to and play through the 'big eyes' animation (if it is not currently playing that animation) before it enters the dying animation."} }, State { name: "dead"; when: statenum == 4 - PropertyChanges { target: spriteimage; goalState: "dead" } + PropertyChanges { target: spriteimage; goalSprite: "dead" } PropertyChanges { target: spriteimageelementtest testtext: "After a brief dying animation, the image should now be static.\n"+ "Advance to restart the test." }