FadeTransition
#include <bb/cascades/FadeTransition>
An animation that controls the opacity of a VisualNode.
The opacity property of a node is specified by the VisualNode::opacity property. How the opacity changes is determined by the fromOpacity and toOpacity values that are specified in the transition. By default, a visual node's opacity is 1.0, meaning that it is fully opaque. A value of 0.0 indicates that the node is fully transparent. The duration of the animation and the easing curve are specified by the AbstractTransition::duration and AbstractTransition::easingCurve properties, respectively.
When both the from and to properties are specified, the transition will run as normal in the specified duration, using the specified easing curve.
If only the from property is specified, the transition will run from the from value specified to the current value of the VisualNode::opacity property at the time the animation started.
If only the to property is specified, the transition will run from the current value of the VisualNode::opacity property at the time animation started to the to value specified by property.
By not specifying a to or from property, the actual value remains undefined. So, you should not attempt to read the value unless the corresponding isSet function is set to true (for example, isToOpacitySet()).
While a property is being animated, its value does not change. It's only when the animation is completed that the animated property is updated with a new value. If you need access to the intermediate values for an animated property, you can be notified of changes through the VisualNode::opacityChanging() signal. However, because of the frequency that these signals are triggered, performance issues can arise, so they should only be used when absolutely necessary.
Once an animation is playing, changing its properties will not have an effect until the next time animation is started.
Here's an example of how you can animate the opacity property of a button, from 0 to 1 in 1000 milliseconds:
Button *button1 = Button::create("Fade me away");
FadeTransition *fade = FadeTransition::create(button1)
.from(0).to(1)
.duration(1000);
fade->play();
This examples shows how you can animate the opacity property of the button from its current value to 0 using the StockCurve::CubicIn curve. Once the transition is complete it is auto-deleted.Button *button2 = Button::create("Fade me away");
FadeTransition *fade2 = FadeTransition::create(button2)
.to(0)
.easingCurve(StockCurve::CubicIn)
.autoDeleted(true);
fade2->play();
And here is how you can create a FadeTransition in QML:Button {
text: "Fade me away"
onClicked: fade.play()
animations: [
FadeTransition {
id: fade
duration: 1000
easingCurve: StockCurve.CubicOut
fromOpacity: 1.0
toOpacity: 0.2
}
]
}
BlackBerry 10.0.0
Inheritance
| bb::cascades::BaseObject | |||||
| bb::cascades::UIObject | |||||
| bb::cascades::AbstractAnimation | |||||
| bb::cascades::AbstractTransition | |||||
| bb::cascades::FadeTransition | |||||
QML properties
| toOpacity | : float |
| toOpacitySet | : bool [read-only] |
| fromOpacity | : float |
| fromOpacitySet | : bool [read-only] |
| attachedObjects | : QDeclarativeListProperty< QObject > [read-only] |
| delay | : int |
| duration | : int |
| easingCurve | : bb::cascades::EasingCurve |
| objectName | : QString |
| parent | : QObject [read-only] |
| repeatCount | : int |
| state | : bb::cascades::AnimationState::Type [read-only] |
| target | : bb::cascades::VisualNode |
QML signals
| onFromOpacityChanged | : {} |
| onToOpacityChanged | : {} |
| onCreationCompleted | |
| onDelayChanged | |
| onDurationChanged | |
| onEasingCurveChanged | |
| onEnded | |
| onObjectNameChanged | |
| onRepeatCountChanged | |
| onStarted | |
| onStateChanged | |
| onStopped | |
| onTargetChanged |
Properties Index
| float | toOpacity |
| bool | toOpacitySet [read-only] |
| float | fromOpacity |
| bool | fromOpacitySet [read-only] |
| QDeclarativeListProperty< QObject > | attachedObjects [read-only] |
| int | delay |
| int | duration |
| QVariant | easingCurve |
| QString | objectName |
| QObject | parent [read-only] |
| int | repeatCount |
| bb::cascades::AnimationState::Type | state [read-only] |
| bb::cascades::VisualNode | target |
Public Static Attributes Index
Only has inherited public static attributes
| const int | RepeatForever |
Public Functions Index
| FadeTransition () | |
| virtual | ~FadeTransition () |
| float | fromOpacity () const |
| Q_SLOT void | setFromOpacity (float value) |
| Q_SLOT void | resetFromOpacity () |
| float | toOpacity () const |
| Q_SLOT void | setToOpacity (float value) |
| Q_SLOT void | resetToOpacity () |
| bool | isToOpacitySet () const |
| bool | isFromOpacitySet () const |
| int | delay () const |
| int | duration () const |
| QVariant | easingCurve () const |
| virtual bool | event (QEvent *event) |
| Q_INVOKABLE bool | isEnded () const |
| Q_INVOKABLE bool | isPlaying () const |
| Q_INVOKABLE bool | isStarted () const |
| Q_INVOKABLE bool | isStopped () const |
| Q_SLOT void | play () |
| int | repeatCount () const |
| Q_SLOT void | resetDelay () |
| Q_INVOKABLE void | resetDuration () |
| Q_INVOKABLE void | resetEasingCurve () |
| Q_SLOT void | resetRepeatCount () |
| Q_SLOT void | resetTarget () |
| void | setDelay (int delay) |
| Q_SLOT void | setDuration (int duration) |
| Q_SLOT void | setEasingCurve (const bb::cascades::EasingCurve &curve) |
| void | setObjectName (const QString &name) |
| void | setRepeatCount (int repeatCount) |
| Q_SLOT void | setTarget (bb::cascades::VisualNode *target) |
| bb::cascades::AnimationState::Type | state () const |
| Q_SLOT void | stop () |
| bb::cascades::VisualNode * | target () const |
| virtual Q_INVOKABLE QString | toDebugString () const |
Static Public Functions Index
| Builder | create (VisualNode *target=0) |
Protected Functions Index
Only has inherited protected functions
| BaseObject (QObject *parent=0) | |
| virtual void | connectNotify (const char *signal) |
| virtual void | disconnectNotify (const char *signal) |
Signals Index
| void | fromOpacityChanged (float fromOpacity) |
| void | toOpacityChanged (float toOpacity) |
| void | creationCompleted () |
| void | delayChanged (int delay) |
| void | durationChanged (int duration) |
| void | easingCurveChanged (const QVariant &easingCurve) |
| void | ended () |
| void | objectNameChanged (const QString &objectName) |
| void | repeatCountChanged (int repeatCount) |
| void | started () |
| void | stateChanged (bb::cascades::AnimationState::Type newState) |
| void | stopped () |
| void | targetChanged (bb::cascades::VisualNode *target) |
Properties
float
Specifies the value that the VisualNode::opacity attribute is animated to.
The value of this attribute is in [0..1] range.
If the animation was playing when this property is set the change will not take effect until the next time the animation is started.
By default the value of this property is not set.
BlackBerry 10.0.0
bool
Indicates whether the toOpacity property of the transition is set.
If true the toOpacity property been set for this transition; if false the toOpacity property is not set.
By default, toOpacitySet is false meaning toOpacity has not been set.
BlackBerry 10.0.0
float
Specifies the value from which the VisualNode::opacity attribute is animated from.
The value of this attribute is in [0..1] range.
If the animation was playing when this property is set the change will not take effect until the next time the animation is started.
By default the value of this property is not set.
BlackBerry 10.0.0
bool
Indicates whether the fromOpacity property of the transition is set.
If true the fromOpacity property been set for this transition; if false the fromOpacity property is not set.
By default, fromOpacitySet is false meaning fromOpacity has not been set.
BlackBerry 10.0.0
QDeclarativeListProperty< QObject >
A hierarchical list of the UIObject's attached objects.
This QDeclarativeListProperty can contain any QObject. When a QObject is added to property, the UIObject takes ownership of the attached object.
This feature is typically used from QML to specify business logic object or any other shared objects for the subnodes of this UIObject. In C++ the same functionality can be achived by setting a parent of a QObject to be attached to the QObject which is going to own it.
QML usage example (MyObject is a custom class registered for QML using the qmlRegisterType() function):
Container {
Label { text: "Title: " + myObject.title }
Label { text: "Subject: " + myObject.subject }
attachedObjects: [
MyObject { id: myObject
title: "Hello World"
subject: "Nice Day"
}
]
}
BlackBerry 10.0.0
int
The delay (in milliseconds) before an animation executes when the play() function is invoked.
Once an animation is playing, changing its properties will not take effect until the next time animation is started.
The default delay is 0.
BlackBerry 10.0.0
int
The duration of the transition (in milliseconds).
The value of this property must be non-negative. A duration of 0 milliseconds means the transition is instantaneous.
If the duration is 0, the value of AbstractAnimation::repeatCount is ignored (it is treated if it was 1).
If the animation was playing when this property is set the change will not take effect until the next time the animation is started.
The default value of this property is 300 milliseconds.
BlackBerry 10.0.0
QVariant
Specifies the easing curve for this transition.
If the animation was playing when this property is set the change will not take effect until the next time the animation is started.
The default value of this attribute is StockCurve::CubicIn
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
int
The number of times that an animation runs.
Once an animation is playing, changing its properties will not take effect until the next time animation is started.
To have an animation run forever, you can specify AnimationRepeatCount::Forever. Here's how you can set an animation to run forever in QML:
Container {
background: Color.Black
preferredHeight: 50
preferredWidth: 50
animations: [
TranslateTransition {
id: foreverandever
fromX: 0
toX: 500
duration: 1000
repeatCount: AnimationRepeatCount.Forever
}
]
onCreationCompleted: foreverandever.play()
}
The default value is 1. This must not be a negative value.BlackBerry 10.0.0
bb::cascades::AnimationState::Type
The current state of the animation.
The default value is bb::cascades:AnimationState::Stopped.
BlackBerry 10.0.0
bb::cascades::VisualNode
The target for the animation.
Even if a target is not explicitly set, the animation can have an implicit target in the following instances:
If the animation is a child of a VisualNode object, the parent is assumed to be the animation's implicit target
If the animation is a child of a GroupAnimation object, the GroupAnimation object's target is assumed to be the animation's implicit target
If an animation has children, setting the explicit target for the animation causes the children's implicit targets to change accordingly.
When the target node is explicitly set on the animation, the node it is attached to does not take ownership, meaning that if the target node is destroyed, the animation is not removed with it. To help manage the animation lifecycle, the ownership of an animation can assigned to a VisualNode by calling VisualNode::addAnimation(). This can help ensure that the animation's memory is cleaned up properly.
Once an animation is playing, changing its properties will not take effect until the next time animation is started.
The default value of this property is 0.
BlackBerry 10.0.0
Public Static Attributes
(Only has inherited public static attributes)
const int 
A constant to be used for specifying an animation that repeats forever.
Use bb::cascades::AnimationRepeatCount::Forever instead.
BlackBerry 10.0.0
Public Functions
Creates a FadeTransition object with unspecified to and from properties.
BlackBerry 10.0.0
virtual
Destructor.
BlackBerry 10.0.0
float
Returns the value of the transition's fromOpacity property if it is set.
A valid value is returned if the fromOpacitySet property is set to true, otherwise the default value of 0 is returned.
The value of fromOpacity property if specified, 0 otherwise
BlackBerry 10.0.0
Q_SLOT void
Sets the fromOpacity property of this transition.
Setting a value of the property will also change the value of fromOpacitySet property to true
| Parameters | |
|---|---|
| value |
the new value of fromOpacity property |
BlackBerry 10.0.0
Q_SLOT void
Resets the fromOpacity property to its default value of 0.
Once reset, the property is marked as unset from the point of view of the transition. Resetting this property will also change the value of the fromOpacitySet property to false.
BlackBerry 10.0.0
float
Returns the value of toOpacity property of this transition if it is set.
A valid value is returned if the toOpacitySet property is set to true, otherwise the default value of 0 is returned.
The value of toOpacity property if specified, 0 otherwise
BlackBerry 10.0.0
Q_SLOT void
Sets the toOpacity property of this transition.
Setting a value of the property will also change the value of toOpacitySet propety to true
| Parameters | |
|---|---|
| value |
The new value of the toOpacity property. |
BlackBerry 10.0.0
Q_SLOT void
Resets the toOpacity property to its default value of 0.
Once reset, the property is marked as unset from the point of view of the transition. Resetting this property will also change the value of the toOpacitySet property to false.
BlackBerry 10.0.0
bool
Indicates whether the toOpacity property of the transition is set.
true the toOpacity property is set, false otherwise.
BlackBerry 10.0.0
bool
Indicates whether the fromOpacity property of the transition is set.
true the fromOpacity property is set, false otherwise.
BlackBerry 10.0.0
int 
Returns the delay (in milliseconds) before an animation executes after the play() function is invoked.
A non-negative number indicating the delay of this animation.
BlackBerry 10.0.0
int 
Returns the duration of this transition.
A positive number indicating the duration of the transition, in milliseconds.
BlackBerry 10.0.0
QVariant 
Returns a QVariant containing the easingCurve for the transition.
A QVariant containing current easing curve for this transition.
BlackBerry 10.0.0
virtual bool 
Overloaded to implement the event mechanism in Cascades.
If this function is overridden, it must be called by the derived class for events to work properly in Cascades.
| Parameters | |
|---|---|
| event |
The received event. |
True if the received event was recognized and processed, false otherwise.
BlackBerry 10.0.0
Q_INVOKABLE bool 
Indicates whether the animation has ended.
An animation has ended if it has run its course without being stopped. It should be noted that if this node is a child of GroupAnimation this method cannot be used to determine the state of this animation node. Only the root GroupAnimation in an animation tree will indicate its state correctly.
true if the animation has ended, false otherwise.
BlackBerry 10.0.0
Q_INVOKABLE bool 
Indicates whether the animation is currently playing.
Note that if this node is a child of GroupAnimation this method cannot be used to determine the state of this animation node. Only the root GroupAnimation in an animation tree will indicate its state correctly.
true if the animation is currently playing, false otherwise.
BlackBerry 10.0.0
Q_INVOKABLE bool 
Indicates whether the animation has been started but is not yet playing.
If the animation is a child of a GroupAnimation object, this function cannot be used to determine the state of this animation node. Only the root GroupAnimation in an animation tree will indicate its state correctly.
true if the animation is started, but not yet playing, false otherwise.
BlackBerry 10.0.0
Q_INVOKABLE bool 
Indicates whether the animation was interrupted by the stop() function.
It should be noted that if this node is a child of GroupAnimation this method cannot be used to determine the state of this animation node. Only the root GroupAnimation in an animation tree will indicate its state correctly.
true if the animation was interrupted, false otherwise.
BlackBerry 10.0.0
Q_SLOT void 
Plays the animation.
Only the root animation in a tree of animations can be played explicitly. If this function is called on a child animation, the function is ignored.
If more than one animation is affecting the same property, calling play() on more than one will stop the running one.
BlackBerry 10.0.0
int 
Returns the value of the repeatCount property.
The repeatCount property is the number of times the animation will be repeated after it started.
A positive number indicating the number of times this animation will be repeated. If repeatCount is equal to bb::cascades::AnimationRepeatCount::Forever, the animation will repeat indefinitely.
BlackBerry 10.0.0
Q_INVOKABLE void 
Resets the duration property to its default value of 300 milliseconds.
BlackBerry 10.0.0
Q_INVOKABLE void 
Resets the easingCurve to its default value of StockCurve::CubicIn.
BlackBerry 10.0.0
void 
Sets the delay (in milliseconds) before an animation executes after the play() function is invoked.
The passed argument must be non-negative or it is ignored.
| Parameters | |
|---|---|
| delay |
A non-negative number representing animation delay in milliseconds. |
BlackBerry 10.0.0
Q_SLOT void 
Sets the duration for the transition, in millseconds.
Passed argument must be non-negative or it is ignored. A duration of 0 indicates an instantaneous transition.
| Parameters | |
|---|---|
| duration |
A non-negative value in milliseconds. |
BlackBerry 10.0.0
Q_SLOT void 
Sets the value of the easingCurve for the transition.
The passed value must be an EasingCurve or one of its subclasses, or the passed value will be ignored and a warning will be printed on the console.
| Parameters | |
|---|---|
| curve |
A derivative of EasingCurve. |
BlackBerry 10.0.0
void 
Sets the objectName property.
| Parameters | |
|---|---|
| name |
The new name for the object. |
BlackBerry 10.0.0
void 
Sets the value of the repeatCount property.
The repeatCount property is the number of times that the animation will be repeated after it started. The passed argument must be positive or it is ignored.
bb::cascades::AnimationRepeatCount::Forever can be used to specify an animation that repeats forever.
| Parameters | |
|---|---|
| repeatCount |
A positive number representing number of times animation will be repeated. |
BlackBerry 10.0.0
Q_SLOT void 
Sets the explicit target for the animation.
Once the operation is completed, ownership of the passed object does not change. The animation does not become a child of the target VisualNode.
Once an animation is playing, changing its properties will not take effect until the next time animation is started.
If an animation has children, setting the explicit target for the animation causes the children's implicit targets to change accordingly (unless they already have an explicit target).
| Parameters | |
|---|---|
| target |
The explicit target for the animation, or 0 to remove the current target. |
BlackBerry 10.0.0
Q_SLOT void 
Stops this animation.
If the animation is started again it will restart from the beginning.
Only the root animation in a tree of animations can be stopped explicitly. If this function is called on a child animation, the function is ignored.
BlackBerry 10.0.0
bb::cascades::VisualNode * 
Returns the explicit target for the animation.
Once the operation is completed, ownership of the animation does not change. This function only works for explicit targets; implicit targets are not returned.
The explicit target for the animation, or 0 if a target is not set.
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
Static Public Functions
Builder
Creates and returns a builder with an optional explicit target.
Button *button1 = Button::create("Fade me away");
FadeTransition *fade = FadeTransition::create(button1)
.from(0).to(1)
.duration(1000);
fade->play();
| Parameters | |
|---|---|
| target |
An optional explicit target for the transition. |
A builder for creating the transition.
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
virtual void 
Overloaded to implement the event mechanism in Cascades.
If this function is overridden, it must be called by the derived class for events to work properly in Cascades.
| Parameters | |
|---|---|
| signal |
The connected signal. |
BlackBerry 10.0.0
virtual void 
Overloaded to implement the event mechanism in Cascades.
If this function is overridden, it must be called by the derived class for events to work properly in Cascades.
| Parameters | |
|---|---|
| signal |
The disconnected signal. |
BlackBerry 10.0.0
Signals
void
Emitted when the fromOpacity of the transition changes.
| Parameters | |
|---|---|
| fromOpacity |
The new fromOpacity value for the transition. |
BlackBerry 10.0.0
void
Emitted when the toOpacity of the transition changes.
| Parameters | |
|---|---|
| toOpacity |
The new toOpacity value for the transition. |
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 
Emitted when the delay of the animation changes.
| Parameters | |
|---|---|
| delay |
The new delay for the animation. |
BlackBerry 10.0.0
void 
Emitted when the duration of the transition changes.
| Parameters | |
|---|---|
| duration |
The new duration for the transition. |
BlackBerry 10.0.0
void 
Emitted when the easingCurve of the transition changes.
| Parameters | |
|---|---|
| easingCurve |
The new easingCurve for the transition. |
BlackBerry 10.0.0
void 
Emitted when the animation has ended.
The animation can be deleted from this signal only using QObject::deleteLater() signal.
This signal is not emitted for child animations.
BlackBerry 10.0.0
void 
This signal is emitted when the objectName property is changed.
BlackBerry 10.0.0
void 
Emitted when the repeatCount of the animation changes.
| Parameters | |
|---|---|
| repeatCount |
The new repeat count for the animation. |
BlackBerry 10.0.0
void 
Emitted when the animation is started.
Note that this may happen sometimes after the play() method is invoked.
This signal is not emitted for child animations.
BlackBerry 10.0.0
void 
Emitted when the state of the animation changes.
| Parameters | |
|---|---|
| newState |
The new state of the animation. |
BlackBerry 10.0.0
void 
Emitted when the animation is stopped.
Note that this may happen sometimes after the stop() method is invoked. It will also be emitted if an animation is stopped because a different animation, implicit or explicit, is started on the same value.
The animation can be deleted from this signal only using QObject::deleteLater() signal.
This signal is not emitted for child animations.
BlackBerry 10.0.0
void 
Emitted when the target property changed.
| Parameters | |
|---|---|
| target |
The new target or 0 if it was unset. |
BlackBerry 10.0.0