Skip to content

Commit

Permalink
Rename SpriteImage to SpriteSequence
Browse files Browse the repository at this point in the history
Also rename Sprite::frames->Sprite::frameCount

Change-Id: I2e7a71adc37044fd696ffda2a5da4835725ba3a8
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
  • Loading branch information
Alan Alpert authored and Qt by Nokia committed Feb 28, 2012
1 parent f7dae39 commit 75a0d33
Show file tree
Hide file tree
Showing 24 changed files with 118 additions and 104 deletions.
6 changes: 3 additions & 3 deletions examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml
Expand Up @@ -127,19 +127,19 @@ Item {
id: spinState
name: "spinning"
source: "pics/meteor.png"
frames: 35
frameCount: 35
frameDuration: 40
to: {"death":0, "spinning":1}
},Sprite {
name: "death"
source: "pics/meteor_explo.png"
frames: 22
frameCount: 22
frameDuration: 40
to: {"null":1}
}, Sprite {
name: "null"
source: "pics/nullRock.png"
frames: 1
frameCount: 1
frameDuration: 1000
}
]
Expand Down
2 changes: 1 addition & 1 deletion examples/particles/affectors/age.qml
Expand Up @@ -54,7 +54,7 @@ Rectangle {
sprites: Sprite {
name: "snow"
source: "../images/snowflake.png"
frames: 51
frameCount: 51
frameDuration: 40
frameDurationVariation: 8
}
Expand Down
2 changes: 1 addition & 1 deletion examples/particles/affectors/attractor.qml
Expand Up @@ -108,7 +108,7 @@ Rectangle {
id: spinState
name: "spinning"
source: "../images/meteor.png"
frames: 35
frameCount: 35
frameDuration: 60
}
}
Expand Down
10 changes: 5 additions & 5 deletions examples/particles/affectors/customaffector.qml
Expand Up @@ -135,31 +135,31 @@ Item {
system: sys
sprites: [Sprite {
source: "../images/realLeaf1.png"
frames: 1
frameCount: 1
frameDuration: 1
to: {"a":1, "b":1, "c":1, "d":1}
}, Sprite {
name: "a"
source: "../images/realLeaf1.png"
frames: 1
frameCount: 1
frameDuration: 10000
},
Sprite {
name: "b"
source: "../images/realLeaf2.png"
frames: 1
frameCount: 1
frameDuration: 10000
},
Sprite {
name: "c"
source: "../images/realLeaf3.png"
frames: 1
frameCount: 1
frameDuration: 10000
},
Sprite {
name: "d"
source: "../images/realLeaf4.png"
frames: 1
frameCount: 1
frameDuration: 10000
}
]
Expand Down
10 changes: 5 additions & 5 deletions examples/particles/affectors/friction.qml
Expand Up @@ -65,31 +65,31 @@ Item {
system: sys
sprites: [Sprite {
source: "../images/realLeaf1.png"
frames: 1
frameCount: 1
frameDuration: 1
to: {"a":1, "b":1, "c":1, "d":1}
}, Sprite {
name: "a"
source: "../images/realLeaf1.png"
frames: 1
frameCount: 1
frameDuration: 10000
},
Sprite {
name: "b"
source: "../images/realLeaf2.png"
frames: 1
frameCount: 1
frameDuration: 10000
},
Sprite {
name: "c"
source: "../images/realLeaf3.png"
frames: 1
frameCount: 1
frameDuration: 10000
},
Sprite {
name: "d"
source: "../images/realLeaf4.png"
frames: 1
frameCount: 1
frameDuration: 10000
}
]
Expand Down
6 changes: 3 additions & 3 deletions examples/particles/affectors/spritegoal.qml
Expand Up @@ -105,20 +105,20 @@ Item {
id: spinState
name: "spinning"
source: "../images/meteor.png"
frames: 35
frameCount: 35
frameDuration: 40
randomStart: true
to: {"explode":0, "spinning":1}
},Sprite {
name: "explode"
source: "../images/_explo.png"
frames: 22
frameCount: 22
frameDuration: 40
to: {"nullFrame":1}
},Sprite {//Not sure if this is needed, but seemed easiest
name: "nullFrame"
source: "../images/nullRock.png"
frames: 1
frameCount: 1
frameDuration: 1000
}
]
Expand Down
2 changes: 1 addition & 1 deletion examples/particles/affectors/wander.qml
Expand Up @@ -51,7 +51,7 @@ Rectangle {
sprites: Sprite {
name: "snow"
source: "../images/snowflake.png"
frames: 51
frameCount: 51
frameDuration: 40
frameDurationVariation: 8
}
Expand Down
2 changes: 1 addition & 1 deletion examples/particles/imageparticle/allatonce.qml
Expand Up @@ -54,7 +54,7 @@ Rectangle {
Sprite {
name: "bear"
source: "../images/bear_tiles.png"
frames: 13
frameCount: 13
frameDuration: 120
}
]
Expand Down
12 changes: 6 additions & 6 deletions examples/particles/imageparticle/sprites.qml
Expand Up @@ -47,11 +47,11 @@ Rectangle {
height: 800
id: root

SpriteImage {
SpriteSequence {
sprites: Sprite {
name: "bear"
source: "../images/bear_tiles.png"
frames: 13
frameCount: 13
frameDuration: 120
}
width: 250
Expand All @@ -71,25 +71,25 @@ Rectangle {
sprites: [Sprite {
name: "happy"
source: "../images/starfish_1.png"
frames: 1
frameCount: 1
frameDuration: 260
to: {"happy": 1, "silly": 1, "angry": 1}
}, Sprite {
name: "angry"
source: "../images/starfish_0.png"
frames: 1
frameCount: 1
frameDuration: 260
to: {"happy": 1, "silly": 1, "angry": 1}
}, Sprite {
name: "silly"
source: "../images/starfish_2.png"
frames: 1
frameCount: 1
frameDuration: 260
to: {"happy": 1, "silly": 1, "noticedbear": 0}
}, Sprite {
name: "noticedbear"
source: "../images/starfish_3.png"
frames: 1
frameCount: 1
frameDuration: 2600
}]
}
Expand Down
12 changes: 6 additions & 6 deletions examples/qtquick/imageelements/spriteimage.qml
Expand Up @@ -53,7 +53,7 @@ Item {
ScriptAction { script: {image.goalSprite = ""; image.jumpTo("still");} }
PropertyAction { target: image; property: "y"; value: 0 }
}
SpriteImage {
SpriteSequence {
id: image
width: 256
height: 256
Expand All @@ -63,7 +63,7 @@ Item {
Sprite{
name: "still"
source: "content/BearSheet.png"
frames: 1
frameCount: 1
frameWidth: 256
frameHeight: 256
frameDuration: 100
Expand All @@ -72,7 +72,7 @@ Item {
Sprite{
name: "blink"
source: "content/BearSheet.png"
frames: 3
frameCount: 3
frameX: 256
frameY: 1536
frameWidth: 256
Expand All @@ -83,7 +83,7 @@ Item {
Sprite{
name: "floating"
source: "content/BearSheet.png"
frames: 9
frameCount: 9
frameX: 0
frameY: 0
frameWidth: 256
Expand All @@ -94,7 +94,7 @@ Item {
Sprite{
name: "flailing"
source: "content/BearSheet.png"
frames: 8
frameCount: 8
frameX: 0
frameY: 768
frameWidth: 256
Expand All @@ -105,7 +105,7 @@ Item {
Sprite{
name: "falling"
source: "content/BearSheet.png"
frames: 5
frameCount: 5
frameY: 1280
frameWidth: 256
frameHeight: 256
Expand Down
Expand Up @@ -151,7 +151,7 @@ ParticleSystem {
Sprite{
name: "floating"
source: "Bear1.png"
frames: 9
frameCount: 9
frameWidth: 256
frameHeight: 256
frameDuration: 80
Expand All @@ -160,7 +160,7 @@ ParticleSystem {
Sprite{
name: "flailing"
source: "Bear2.png"
frames: 8
frameCount: 8
frameWidth: 256
frameHeight: 256
frameDuration: 80
Expand All @@ -169,7 +169,7 @@ ParticleSystem {
Sprite{
name: "falling"
source: "Bear3.png"
frames: 5
frameCount: 5
frameWidth: 256
frameHeight: 256
frameDuration: 80
Expand Down
4 changes: 2 additions & 2 deletions src/quick/items/items.pri
Expand Up @@ -65,7 +65,7 @@ HEADERS += \
$$PWD/qquickimplicitsizeitem_p_p.h \
$$PWD/qquickspriteengine_p.h \
$$PWD/qquicksprite_p.h \
$$PWD/qquickspriteimage_p.h \
$$PWD/qquickspritesequence_p.h \
$$PWD/qquickanimatedsprite_p.h \
$$PWD/qquickdrag_p.h \
$$PWD/qquickdroparea_p.h \
Expand Down Expand Up @@ -117,7 +117,7 @@ SOURCES += \
$$PWD/qquickimplicitsizeitem.cpp \
$$PWD/qquickspriteengine.cpp \
$$PWD/qquicksprite.cpp \
$$PWD/qquickspriteimage.cpp \
$$PWD/qquickspritesequence.cpp \
$$PWD/qquickanimatedsprite.cpp \
$$PWD/qquickaccessibleattached.cpp \
$$PWD/qquickdrag.cpp \
Expand Down
5 changes: 3 additions & 2 deletions src/quick/items/qquickitemsmodule.cpp
Expand Up @@ -77,7 +77,7 @@
#include <QtQuick/private/qquickcanvasitem_p.h>
#include <QtQuick/private/qquickcontext2d_p.h>
#include "qquicksprite_p.h"
#include "qquickspriteimage_p.h"
#include "qquickspritesequence_p.h"
#include "qquickanimatedsprite_p.h"
#include "qquickdrag_p.h"
#include "qquickdroparea_p.h"
Expand Down Expand Up @@ -202,7 +202,8 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)

qmlRegisterType<QQuickSprite>("QtQuick", 2, 0, "Sprite");
qmlRegisterType<QQuickAnimatedSprite>("QtQuick", 2, 0, "AnimatedSprite");
qmlRegisterType<QQuickSpriteImage>("QtQuick", 2, 0, "SpriteImage");
qmlRegisterType<QQuickSpriteSequence>("QtQuick", 2, 0, "SpriteSequence");
qmlRegisterType<QQuickSpriteSequence>("QtQuick", 2, 0, "SpriteImage");//Deprecation in progress

qmlRegisterType<QQuickParentChange>(uri, major, minor,"ParentChange");
qmlRegisterType<QQuickAnchorChanges>(uri, major, minor,"AnchorChanges");
Expand Down
2 changes: 1 addition & 1 deletion src/quick/items/qquicksprite.cpp
Expand Up @@ -145,7 +145,7 @@ QT_BEGIN_NAMESPACE
will repeat itself after completing.
*/
/*!
\qmlproperty int QtQuick2::Sprite::frames
\qmlproperty int QtQuick2::Sprite::frameCount
Number of frames in this sprite.
*/
Expand Down
21 changes: 17 additions & 4 deletions src/quick/items/qquicksprite_p.h
Expand Up @@ -48,6 +48,7 @@
#include <QDeclarativeListProperty>
#include <QtQuick/private/qdeclarativepixmapcache_p.h>
#include "qquickspriteengine_p.h"
#include <QDebug>

QT_BEGIN_HEADER

Expand All @@ -60,7 +61,8 @@ class QQuickSprite : public QQuickStochasticState
//Renderers have to query this hint when advancing frames
Q_PROPERTY(bool reverse READ reverse WRITE setReverse NOTIFY reverseChanged)
Q_PROPERTY(bool frameSync READ frameSync WRITE setFrameSync NOTIFY frameSyncChanged)
Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY framesChanged)
Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY frameCountChanged)
Q_PROPERTY(int frameCount READ frameCount WRITE setFrameCount NOTIFY frameCountChanged)
//If frame height or width is not specified, it is assumed to be a single long row of square frames.
//Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used.
Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged)
Expand Down Expand Up @@ -101,6 +103,11 @@ class QQuickSprite : public QQuickStochasticState
return m_frames;
}

int frameCount() const
{
return m_frames;
}

int frameX() const
{
return m_frameX;
Expand Down Expand Up @@ -158,7 +165,7 @@ class QQuickSprite : public QQuickStochasticState

void reverseChanged(bool arg);

void framesChanged(int arg);
void frameCountChanged(int arg);

void frameXChanged(int arg);

Expand Down Expand Up @@ -210,10 +217,16 @@ public slots:
}

void setFrames(int arg)
{
qWarning() << "Sprite::frames has been renamed Sprite::frameCount";
setFrameCount(arg);
}

void setFrameCount(int arg)
{
if (m_frames != arg) {
m_frames = arg;
emit framesChanged(arg);
emit frameCountChanged(arg);
}
}

Expand Down Expand Up @@ -278,7 +291,7 @@ private slots:

private:
friend class QQuickImageParticle;
friend class QQuickSpriteImage;
friend class QQuickSpriteSequence;
friend class QQuickAnimatedSprite;
friend class QQuickSpriteEngine;
friend class QQuickStochasticEngine;
Expand Down

0 comments on commit 75a0d33

Please sign in to comment.