61e443db84edeee79e75cc799f45d80a650895e6
[profile/ivi/qtdeclarative.git] / src / quick / items / qquicksprite.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the Declarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "qquicksprite_p.h"
43 #include <QDebug>
44
45 QT_BEGIN_NAMESPACE
46
47 /*!
48     \qmlclass Sprite QQuickSprite
49     \inqmlmodule QtQuick 2
50     \brief The Sprite element represents a sprite animation
51
52 */
53 /*!
54     \qmlproperty int QtQuick2::Sprite::duration
55
56     Time between frames.
57 */
58 /*!
59     \qmlproperty int QtQuick2::Sprite::durationVariation
60
61     The time between frames can vary by up to this amount.
62
63     Default is 0.
64 */
65
66 /*!
67     \qmlproperty string QtQuick2::Sprite::name
68
69     The name of this sprite, for use in the to property of other sprites.
70 */
71 /*!
72     \qmlproperty QVariantMap QtQuick2::Sprite::to
73
74     A list of other sprites and weighted transitions to them,
75     for example {"a":1, "b":2, "c":0} would specify that one-third should
76     transition to sprite "a" when this sprite is done, and two-thirds should
77     transition to sprite "b" when this sprite is done. As the transitions are
78     chosen randomly, these proportions will not be exact. With "c":0 in the list,
79     no sprites will randomly transition to "c", but it wll be a valid path if a sprite
80     goal is set.
81
82     If no list is specified, or the sum of weights in the list is zero, then the sprite
83     will repeat itself after completing.
84 */
85 /*!
86     \qmlproperty int QtQuick2::Sprite::frames
87
88     Number of frames in this sprite.
89 */
90 /*!
91     \qmlproperty int QtQuick2::Sprite::frameHeight
92
93     Height of a single frame in this sprite.
94 */
95 /*!
96     \qmlproperty int QtQuick2::Sprite::frameWidth
97
98     Width of a single frame in this sprite.
99 */
100 /*!
101     \qmlproperty url QtQuick2::Sprite::source
102
103     The image source for the animation.
104
105     If frameHeight and frameWidth are not specified, it is assumed to be a single long row of square frames.
106     Otherwise, it can be multiple contiguous rows or rectangluar frames, when one row runs out the next will be used.
107 */
108     Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
109     Q_PROPERTY(int durationVariation READ durationVariance WRITE setDurationVariance NOTIFY durationVarianceChanged)
110     Q_PROPERTY(QVariantMap to READ to WRITE setTo NOTIFY toChanged)
111     Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
112     Q_PROPERTY(qreal speedModifiesDuration READ speedModifer WRITE setSpeedModifier NOTIFY speedModifierChanged)
113     Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY framesChanged)
114     Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
115     //If frame height or width is not specified, it is assumed to be a single long row of square frames.
116     //Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used.
117     Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged)
118     Q_PROPERTY(int frameWidth READ frameWidth WRITE setFrameWidth NOTIFY frameWidthChanged)
119
120 QQuickSprite::QQuickSprite(QObject *parent) :
121     QQuickStochasticState(parent)
122     , m_generatedCount(0)
123     , m_framesPerRow(0)
124     , m_frameHeight(0)
125     , m_frameWidth(0)
126     , m_rowY(0)
127 {
128 }
129
130 QT_END_NAMESPACE