ImageAnimator
#include <bb/cascades/ImageAnimator>
A class that can be used to control the animation of an animated image (typically a .gif animation).
Here's how to use the image animator in C++:
ImageView *iv = new ImageView();
iv->setImageSource(QUrl("foo.gif"));
ImageAnimator *ic = new ImageAnimator();
ic->setAnimatedImage(iv->image()); // attach image
ic->setStarted(true);
Here's how to use the image animator from QML:
Container {
ImageView {
id: imageView
imageSource: "foo.gif"
attachedObjects: [
ImageAnimator {
id: imageAnimator
animatedImage: imageView.image
started: true
}
]
}
}
BlackBerry 10.0.0
Inheritance
| bb::cascades::BaseObject | ||
| bb::cascades::ImageAnimator | ||
QML properties
| animatedImage | : bb::cascades::Image |
| started | : bool |
| running | : bool [read-only] |
| playing | : bool |
| objectName | : QString |
| parent | : QObject [read-only] |
QML signals
Properties Index
| QVariant | animatedImage |
| bool | started |
| bool | running [read-only] |
| bool | playing |
| QString | objectName |
| QObject | parent [read-only] |
Public Functions Index
| ImageAnimator (QObject *parent=0) | |
| virtual | ~ImageAnimator () |
| bb::cascades::Image | animatedImage () const |
| Q_SLOT void | setAnimatedImage (const bb::cascades::Image &image) |
| Q_SLOT void | resetAnimatedImage () |
| bool | isStarted () const |
| Q_SLOT void | setStarted (bool started) |
| Q_SLOT void | resetStarted () |
| bool | isRunning () const |
| Q_SLOT void | start () |
| Q_SLOT void | stop () |
| Q_SLOT void | stopAt (bb::cascades::ImageAnimatorAnchor::Type anchor, bb::cascades::ImageAnimatorSeekMode::Type seekMode=bb::cascades::ImageAnimatorSeekMode::Default) |
| bool | isPlaying () const |
| Q_SLOT void | setPlaying (bool playing) |
| Q_SLOT void | resetPlaying () |
| void | setObjectName (const QString &name) |
| virtual Q_INVOKABLE QString | toDebugString () const |
Protected Functions Index
Only has inherited protected functions
| BaseObject (QObject *parent=0) |
Signals Index
| void | animatedImageChanged (const bb::cascades::Image &animatedImage) |
| void | startedChanged (bool started) |
| void | runningChanged (bool running) |
| void | playingChanged (bool playing) |
| void | creationCompleted () |
| void | objectNameChanged (const QString &objectName) |
Properties
bool
Specifies whether the attached image shoud animate or not.
Changing this property informs the attached image to start or stop playing, and emits the startedChanged() signal.
Setting this property to true has the same effect as invoking play().
Setting this property to false has the same effect as invoking stop() or stopAt(ImageAnimatorAnchor::CurrentFrame, ImageAnimatorSeekMode::Immediate).
Invoking play(), stop() or stopAt() will change this property immediatly.
When an ImageAnimator is created, this property will have the value false, which means that any image attached to an unaltered animator will pause.
Due to the asyncronous nature of Cascades this property does not indicate whether the attached image is currently animating or not, but rather, if the image has been informed that it should animate or not. The property running can be used to find out if the currently attached image is actually animating.
BlackBerry 10.0.0
bool
A read-only property representing whether the attached image is currently animating of not.
This property can be used to track whether the attached image is currently animating or not. When this property is changed the runningChanged() signal will be emitted.
Due to the asyncronous nature of Cascades, changing the started property or invoking play(), stop() or stopAt() will not change this property immediatly. This property will only be changed after the image has actually stopped animating.
BlackBerry 10.0.0
bool
Specifies whether the attached image should animate or not.
This property is deprecated in favor or the started property
Use started property instead
BlackBerry 10.0.0
QString
This property is overridden from QObject.
As the objectName property is overridden from the QObject class, this signal will not be emitted if setObjectName() function is called directly on QObject.
The default value of this property is QString::null.
QObject::objectName().
BlackBerry 10.0.0
QObject
A read-only property that represents this object's parent.
The parent of an object is specified using QObject::setParent(QObject*). The purpose of the property is to expose the object's parent to QML.
This property is read-only to prevent modifications from QML, where typically the parent is declaratively set. In C++ code, the parent can be explicitly set using QObject::setParent(QObject*), or implicitly set by adding it to a visual container.
The default value of this property is 0.
BlackBerry 10.0.0
Public Functions
virtual
Destructor.
bb::cascades::Image
Returns the currently attached image.
If no image is attached a null image will be returned.
The currently attached image, or a null image If no image is being animated.
BlackBerry 10.0.0
Q_SLOT void
Sets an image on the animator.
The started state of the animator will be pushed to the image. The running state of the image will be pushed to the animator.
An image can only be attached to one animator. If the image was already attached to an animator when this method is called, the image will be detached from the old animator and attached to this one. A null image will be attached to the old animator.
When attaching a new image to an animator, the old image does not lose the started state that was pushed to it by the animator, but you cannot control it any longer with the animator.
| Parameters | |
|---|---|
| image |
to attach to the animator |
BlackBerry 10.0.0
Q_SLOT void
Resets the attached image to a null image.
This will detach the currently attached image and attach a null image to the animator.
BlackBerry 10.0.0
bool
Returns the started state of the animator.
The started state of the animator.
BlackBerry 10.0.0
Q_SLOT void
Sets the started state of the animator.
| Parameters | |
|---|---|
| started |
If true the animation is started and if false the animation is stopped. |
BlackBerry 10.0.0
Q_SLOT void
Stops the animation by resetting the started state to false.
BlackBerry 10.0.0
bool
Returns the running state of the animator.
The running state of the animator.
BlackBerry 10.0.0
Q_SLOT void
Starts the animation of the attached image.
Calling this function has the same effect as calling setStarted(true).
BlackBerry 10.0.0
Q_SLOT void
Stops the animation of the attached image.
Calling this function has the same effect as calling setStarted(false).
BlackBerry 10.0.0
Q_SLOT void
Stops the animation of the attached image in a specified way.
This function can be used to stop the animation of the attached image at specific points in the animation.
How to use this function and how it relates to the started and running properties is illustrated in the following examples:
Invoke stopAt(ImageAnimatorAnchor::CurrentFrame, ImageAnimatorSeekMode::Immediate) or invoke stopAt(ImageAnimatorAnchor::CurrentFrame, ImageAnimatorSeekMode::Animate) while animation is running.
startedChanged(false) will be emitted immediately.
Cascades will stop the animation as soon as possible on the frame the animation is currently on and then runningChanged(false) will be emitted.
Invoke stopAt(ImageAnimatorAnchor::FirstFrame, ImageAnimatorSeekMode::Immediate) while animation is running.
startedChanged(false) will be emitted immediately.
Cascades will stop the animation as soon as possible, jumping to the first frame of the image animation and then runningChanged(false) will be emitted.
Invoke stopAt(ImageAnimatorAnchor::LastFrame, ImageAnimatorSeekMode::Immediate) while animation is running.
startedChanged(false) will be emitted immediately.
Cascades will stop the animation as soon as possible, jumping to the first frame of the image animation and then runningChanged(false) will be emitted.
Invoke stopAt(ImageAnimatorAnchor::FirstFrame, ImageAnimatorSeekMode::Animate) while animation is running.
startedChanged(false) will be emitted immediately.
Cascades will continue to run the animation until the first frame is shown, at which point runningChanged(false) will be emitted.
Invoke stopAt(ImageAnimatorAnchor::LastFrame, ImageAnimatorSeekMode::Animate) while animation is running.
startedChanged(false) will be emitted immediately.
Cascades will continue to run the animation until the last frame is shown, at which point runningChanged(false) will be emitted.
Invoke stopAt(ImageAnimatorAnchor::FirstFrame, ImageAnimatorSeekMode::Animate) while animation is not running and the first frame is not currently showing.
Cascades will emit runningChanged(true), run the animation until the first frame is shown, at which point runningChanged(false) will be emitted.
Invoke stopAt(ImageAnimatorAnchor::LastFrame, ImageAnimatorSeekMode::Animate) while animation is not running and the last frame is not currently showing.
Cascades will emit runningChanged(true), run the animation until the last frame is shown, at which point runningChanged(false) will be emitted.
BlackBerry 10.0.0
bool
Returns the started state of the animator.
in favor of isStarted()
The started state of the animator
BlackBerry 10.0.0
Q_SLOT void
Sets the started state of the animator.
in favor of setStarted()
| Parameters | |
|---|---|
| playing |
start animation or not |
BlackBerry 10.0.0
Q_SLOT void
Resets the started state of the animator.
in favor of resetStarted()
BlackBerry 10.0.0
void 
Sets the objectName property.
| Parameters | |
|---|---|
| name |
The new name for the object. |
BlackBerry 10.0.0
virtual Q_INVOKABLE QString 
Returns a debug string representing this object.
A debug string for the object.
BlackBerry 10.0.0
Protected Functions
(Only has inherited protected functions)
Constructs an instance of BaseObject's subclass.
| Parameters | |
|---|---|
| parent |
An optional parent, defaults to 0. |
BlackBerry 10.0.0
Signals
void
Emitted when the attached image changes.
| Parameters | |
|---|---|
| animatedImage |
The new Image that was attached to the animator |
BlackBerry 10.0.0
void
Emitted when the started state of the animator changes.
| Parameters | |
|---|---|
| started |
The new started state of the animator |
BlackBerry 10.0.0
void
Emitted when the running state of the animator changes.
| Parameters | |
|---|---|
| running |
The new running state of the animator |
BlackBerry 10.0.0
void
Emitted when the started state of the animator changes.
in favor or startedChanged()
| Parameters | |
|---|---|
| playing |
The new started state of the animator |
BlackBerry 10.0.0
void 
This signal is emitted only when this object is instantiated as a result of loading a QML document and creating the root node, or when an object is being constructed using its builder class.
This signal is emitted only when this object is instantiated as a result of loading a QML document and creating the root node (only after the root component that caused this instantiation has completed construction), or when the object is being constructed from its builder class. This signal is emitted to indicate that the construction and initialization of the object has been completed, the properties are initialized, and any QML binding values have been assigned to the object.
This signal is not emitted when the object is constructed from C++ using the constructor. If the object is constructed using its builder class, the signal is emitted when the the builder class returns the fully constructed object.
This signal can be used when there is an activity that needs to be performed, such as a property state integrity verification after the object is instantiated from a QML document or a builder, but before control is returned to the application.
BlackBerry 10.0.0
void 
This signal is emitted when the objectName property is changed.
BlackBerry 10.0.0