aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickanimatedsprite.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-02-27 08:43:10 +0100
committerLiang Qi <liang.qi@qt.io>2018-02-27 08:43:10 +0100
commitbb7a5d0cb6e62fa411e8b66759bf6b798c3f68d9 (patch)
tree06c325dc386afd26281ba0ebdbf4fd3f56f892b0 /src/quick/items/qquickanimatedsprite.cpp
parent41edb3bd9f373a865d5698ac8c18bf341071eae9 (diff)
parente41d067227eb6225b05df88ab724708588fa5304 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts: src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4internalclass.cpp src/qml/parser/qqmljslexer.cpp src/qml/qml/v8/qv8engine.cpp src/qml/util/qqmladaptormodel_p.h src/quick/items/qquickanimatedsprite.cpp tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp Change-Id: I16702b7a0da29c2a332afee47728d6a6ebf4fb3f
Diffstat (limited to 'src/quick/items/qquickanimatedsprite.cpp')
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp
index 58eb81fbbd..5234ee65cb 100644
--- a/src/quick/items/qquickanimatedsprite.cpp
+++ b/src/quick/items/qquickanimatedsprite.cpp
@@ -105,7 +105,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlproperty int QtQuick::AnimatedSprite::frameDuration
- Duration of each frame of the animation. Values equal to or below 0 are invalid.
+ Duration of each frame of the animation in milliseconds. Values equal to or below 0 are invalid.
If frameRate is valid then it will be used to calculate the duration of the frames.
If not, and frameDuration is valid, then frameDuration will be used.
@@ -220,7 +220,6 @@ QT_BEGIN_NAMESPACE
\l loops property is set to \c AnimatedSprite.Infinite.
*/
-//TODO: Implicitly size element to size of sprite
QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) :
QQuickItem(*(new QQuickAnimatedSpritePrivate), parent)
{
@@ -526,6 +525,7 @@ void QQuickAnimatedSprite::setFrameHeight(int arg)
if (d->m_sprite->m_frameHeight != arg) {
d->m_sprite->setFrameHeight(arg);
Q_EMIT frameHeightChanged(arg);
+ setImplicitHeight(frameHeight());
reloadImage();
}
}
@@ -537,6 +537,7 @@ void QQuickAnimatedSprite::setFrameWidth(int arg)
if (d->m_sprite->m_frameWidth != arg) {
d->m_sprite->setFrameWidth(arg);
Q_EMIT frameWidthChanged(arg);
+ setImplicitWidth(frameWidth());
reloadImage();
}
}
@@ -651,6 +652,17 @@ QSGSpriteNode* QQuickAnimatedSprite::initNode()
if (image.isNull())
return nullptr;
+ // If frameWidth or frameHeight are not explicitly set, frameWidth
+ // will be set to the width of the image divided by the number of frames,
+ // and frameHeight will be set to the height of the image.
+ // In this case, QQuickAnimatedSprite currently won't emit frameWidth/HeightChanged
+ // at all, so we have to do this here, as it's the only place where assembledImage()
+ // is called (which calculates the "implicit" frameWidth/Height.
+ // In addition, currently the "implicit" frameWidth/Height are only calculated once,
+ // even after changing to a different source.
+ setImplicitWidth(frameWidth());
+ setImplicitHeight(frameHeight());
+
QSGSpriteNode *node = d->sceneGraphContext()->createSpriteNode();
d->m_sheetSize = QSize(image.size());