diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/fx/qfxtransform.cpp | 34 | ||||
-rw-r--r-- | src/declarative/util/qmlanimation.cpp | 78 | ||||
-rw-r--r-- | src/declarative/util/qmlbehaviour.cpp | 20 | ||||
-rw-r--r-- | src/declarative/util/qmlfollow.cpp | 36 | ||||
-rw-r--r-- | src/declarative/util/qmlsetproperties.cpp | 14 | ||||
-rw-r--r-- | src/declarative/util/qmlstateoperations.cpp | 41 | ||||
-rw-r--r-- | src/declarative/util/qmltransition.cpp | 6 |
7 files changed, 125 insertions, 104 deletions
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp index 2bed170..8ff4c54 100644 --- a/src/declarative/fx/qfxtransform.cpp +++ b/src/declarative/fx/qfxtransform.cpp @@ -93,7 +93,7 @@ void QFxTransform::update() between the points does matter for translation along an axis. \code - <Axis startX="0" startY="0" endX="20" endY="30"/> + Axis { startX: 0; startY: 0; endX: 20; endY: 30 } \endcode */ @@ -182,31 +182,7 @@ void QFxAxis::setEndZ(qreal z) \brief The Rotation3D element provides a way to rotate an Item around an axis. Here is an example of various rotations applied to an \l Image. - \code - <HorizontalLayout margin="10" spacing="10"> - <Image src="qt.png"/> - <Image src="qt.png"> - <transform> - <Rotation3D axis.startX="30" axis.endX="30" axis.endY="60" angle="18"/> - </transform> - </Image> - <Image src="qt.png"> - <transform> - <Rotation3D axis.startX="30" axis.endX="30" axis.endY="60" angle="36"/> - </transform> - </Image> - <Image src="qt.png"> - <transform> - <Rotation3D axis.startX="30" axis.endX="30" axis.endY="60" angle="54"/> - </transform> - </Image> - <Image src="qt.png"> - <transform> - <Rotation3D axis.startX="30" axis.endX="30" axis.endY="60" angle="72"/> - </transform> - </Image> - </HorizontalLayout> - \endcode + \snippet doc/src/snippets/declarative/rotation.qml 0 \image axisrotation.png */ @@ -233,6 +209,8 @@ QFxRotation3D::~QFxRotation3D() A rotation axis is specified by 2 points in 3D space: a start point and an end point. The z-position of the start point is assumed to be 0, and cannot be changed. + + \sa Axis */ QFxAxis *QFxRotation3D::axis() { @@ -374,6 +352,8 @@ QFxTranslation3D::~QFxTranslation3D() an end point. The z-position of the start point is assumed to be 0, and cannot be changed. Changing the z-position of the end point is only valid when running under OpenGL. + + \sa Axis */ QFxAxis *QFxTranslation3D::axis() { @@ -388,7 +368,7 @@ QFxAxis *QFxTranslation3D::axis() of 0.5 would translate to 50, 25. \code - <Translation3D axis.startX="0" axis.startY="0" axis.endX="100" axis.endY="50"/> + Translation3D { axis.startX: 0; axis.startY: 0; axis.endX: 100; axis.endY: 50 } \endcode */ qreal QFxTranslation3D::distance() const diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 4bcc550..d5765c1 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -177,12 +177,14 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj whenever the \l MouseRegion is pressed. \code - <Rect width="100" height="100"> - <x> - <NumericAnimation running="{MyMouse.pressed}" from="0" to="100" /> - </x> - <MouseRegion id="MyMouse" /> - </Rect> + Rect { + width: 100; height: 100 + x: NumericAnimation { + running: MyMouse.pressed + from: 0; to: 100 + } + MouseRegion { id: MyMouse } + } \endcode Likewise, the \c running property can be read to determine if the animation @@ -190,8 +192,8 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj or not the animation is running. \code - <NumericAnimation id="MyAnimation" /> - <Text text="{MyAnimation.running?'Animation is running':'Animation is not running'}" /> + NumericAnimation { id: MyAnimation } + Text { text: MyAnimation.running ? "Animation is running" : "Animation is not running" } \endcode Animations can also be started and stopped imperatively from JavaScript @@ -304,11 +306,9 @@ void QmlAbstractAnimation::setFinishPlaying(bool f) In the following example, the rectangle will spin indefinately. \code - <Rect> - <rotation> - <NumericAnimation running="true" repeat="true" from="0" to="360" /> - </rotation> - </Rect> + Rect { + rotation: NumericAnimation { running: true; repeat: true; from: 0 to: 360 } + } \endcode */ bool QmlAbstractAnimation::repeat() const @@ -435,11 +435,9 @@ void QmlAbstractAnimation::start() Normally \c stop() stops the animation immediately, and the animation has no further influence on property values. In this example animation \code - <Rect> - <x> - <NumericAnimation from="0" to="100" duration="500" /> - </x> - </Rect> + Rect { + x: NumericAnimation { from: 0; to: 100; duration: 500 } + } \endcode was stopped at time 250ms, the \c x property will have a value of 50. @@ -475,11 +473,9 @@ void QmlAbstractAnimation::restart() Unlike \c stop(), \c complete() immediately fast-forwards the animation to its end. In the following example, \code - <Rect> - <x> - <NumericAnimation from="0" to="100" duration="500" /> - </x> - </Rect> + Rect { + x: NumericAnimation { from: 0; to: 100; duration: 500 } + } \endcode calling \c stop() at time 250ms will result in the \c x property having a value of 50, while calling \c complete() will set the \c x property to @@ -529,11 +525,11 @@ void QmlAbstractAnimation::timelineComplete() A 500ms animation sequence, with a 100ms pause between two animations: \code - <SequentialAnimation> - <NumericAnimation ... duration="200"/> - <PauseAnimation duration="100"/> - <NumericAnimation ... duration="200"/> - </SequentialAnimation> + SequentialAnimation { + NumericAnimation { ... duration: 200 } + PauseAnimation { duration: 100 } + NumericAnimation { ... duration: 200 } + } \endcode */ /*! @@ -621,7 +617,7 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation() \brief The ColorAnimation allows you to animate color changes. \code - <ColorAnimation from="white" to="#c0c0c0" duration="100"/> + ColorAnimation { from: "white" to: "#c0c0c0"; duration: 100 } \endcode The default property animated is \c color, but like other animations, @@ -1016,12 +1012,12 @@ QML_DEFINE_TYPE(QmlRunScriptAction, RunScriptAction); Explicitly set \c theimage.smooth=true during a transition: \code - <SetPropertyAction target="{theimage}" property="smooth" value="true"/> + SetPropertyAction { target: theimage; property: "smooth"; value: true } \endcode Set \c thewebview.url to the value set for the destination state: \code - <SetPropertyAction target="{thewebview}" property="url"/> + SetPropertyAction { target: thewebview; property: "url" } \endcode The SetPropertyAction is immediate - @@ -1324,7 +1320,7 @@ QML_DEFINE_TYPE(QmlParentChangeAction,ParentChangeAction); Animate a set of properties over 200ms, from their values in the start state to their values in the end state of the transition: \code - <NumericAnimation properties="x,y,scale" duration="200"/> + NumericAnimation { properties: "x,y,scale"; duration: 200 } \endcode */ @@ -1723,10 +1719,10 @@ QmlList<QmlAbstractAnimation *> *QmlAnimationGroup::animations() object will animate from its current x position to 100, and then back to 0. \code - <SequentialAnimation> - <NumericAnimation target="{MyItem}" property="x" to="100" /> - <NumericAnimation target="{MyItem}" property="x" to="0" /> - <SequentialAnimation> + SequentialAnimation { + NumericAnimation { target: MyItem; property: "x"; to: 100 } + NumericAnimation { target: MyItem; property: "x"; to: 0 } + } \endcode \sa ParallelAnimation @@ -1800,10 +1796,10 @@ QML_DEFINE_TYPE(QmlSequentialAnimation,SequentialAnimation); to (100,100) by animating the x and y properties in parallel. \code - <ParallelAnimation> - <NumericAnimation target="{MyItem}" property="x" to="100" /> - <NumericAnimation target="{MyItem}" property="y" to="100" /> - </ParallelAnimation> + ParallelAnimation { + NumericAnimation { target: MyItem; property: "x"; to: 100 } + NumericAnimation { target: MyItem; property: "y"; to: 100 } + } \endcode \sa SequentialAnimation @@ -1924,7 +1920,7 @@ void QmlVariantAnimationPrivate::convertVariant(QVariant &variant, QVariant::Typ Animate a size property over 200ms, from its current size to 20-by-20: \code - <VariantAnimation property="size" to="20x20" duration="200"/> + VariantAnimation { property: "size"; to: "20x20"; duration: 200 } \endcode */ diff --git a/src/declarative/util/qmlbehaviour.cpp b/src/declarative/util/qmlbehaviour.cpp index 58e515f..354c7e3 100644 --- a/src/declarative/util/qmlbehaviour.cpp +++ b/src/declarative/util/qmlbehaviour.cpp @@ -105,15 +105,19 @@ public: \qmlclass Behaviour QmlBehaviour \brief The Behaviour element allows you to specify a default animation for a property change. - In example below, Rect1 will use a bounce easing curve over 200 millisecond for any changes to its y property: + In example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property: \code - <Rect id="Rect1" y="200" width="20" height="20" color="#00ff00"> - <y> - <Behaviour> - <NumericAnimation easing="easeOutBounce(amplitude:100)" duration="200" /> - </Behaviour> - </y> - </Rect> + Rect { + width: 20; height: 20 + color: "#00ff00" + y: 200 //initial value + y: Behaviour { + NumericAnimation { + easing: "easeOutBounce(amplitude:100)" + duration: 200 + } + } + } \endcode */ diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp index 35f3c49..998166a 100644 --- a/src/declarative/util/qmlfollow.cpp +++ b/src/declarative/util/qmlfollow.cpp @@ -174,19 +174,29 @@ void QmlFollowPrivate::stop() In example below, Rect2 will follow Rect1 moving with a velocity of up to 200: \code - <Rect id="Rect1" y="{200}" width="20" height="20" color="#00ff00"> - <y> - <SequentialAnimation running="true" repeat="true"> - <NumericAnimation to="{200}" easing="easeOutBounce(amplitude:100)" duration="2000" /> - <PauseAnimation duration="1000" /> - </SequentialAnimation> - </y> - </Rect> - <Rect id="Rect2" x="{Rect1.width}" width="20" height="20" color="#ff0000"> - <y> - <Follow source="{Rect1.y}" velocity="200"/> - </y> - </Rect> + Rect { + id: Rect1 + width: 20; height: 20 + color: "#00ff00" + y: 200 //initial value + y: SequentialAnimation { + running: true + repeat: true + NumericAnimation { + to: 200 + easing: "easeOutBounce(amplitude:100)" + duration: 2000 + } + PauseAnimation { duration: 1000 } + } + } + Rect { + id: Rect2 + x: Rect1.width + width: 20; height: 20 + color: "#ff0000" + y: Follow { source: Rect1.y; velocity: 200 } + } \endcode */ diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp index 108f2b2..9b5a58e 100644 --- a/src/declarative/util/qmlsetproperties.cpp +++ b/src/declarative/util/qmlsetproperties.cpp @@ -108,7 +108,12 @@ void QmlSetPropertiesMetaObject::propertyWrite(int id) you normally would specify them for the actual item: \code - <SetProperties target="{myRect}" x="52" y="300" width="48"/> + SetProperties { + target: myRect + x: 52 + y: 300 + width: 48 + } \endcode \c target is a property of \c SetProperties, so if the property you want to change @@ -129,7 +134,12 @@ void QmlSetPropertiesMetaObject::propertyWrite(int id) you normally would specify them for the actual item: \code - <SetProperties target="{myRect}" x="52" y="300" width="48"/> + SetProperties { + target: myRect + x: 52 + y: 300 + width: 48 + } \endcode \c target is a property of \c SetProperties, so if the property you want to change diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 755befe..01f9cdd 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -212,17 +212,36 @@ QmlRunScript::ActionList QmlRunScript::actions() the current state: \code - <Rect id="myrect" width="50" height="50" color="red"/> - - <states> - <State name="Position1"> - <SetProperty target="{myrect}" property="x" value="150"/> - <SetProperty target="{myrect}" property="y" value="50"/> - </State> - <State name="Position2"> - <SetProperty target="{myrect}" property="y" value="200"/> - </State> - </states> + Rect { + id: myrect + width: 50 + height: 50 + color: "red" + } + + states: [ + State { + name: "Position1" + SetProperty { + target: myrect + property: "x" + value: 150 + } + SetProperty { + target: myrect + property: "y" + value: 50 + } + }, + State { + name: "Position2" + SetProperty { + target: myrect + property: "y" + value: 200 + } + } + ] \endcode \sa SetProperties diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index a515f58..47e70ad 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -188,9 +188,11 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions, be applied. By default fromState and toState are both "*" (any state). In the following example, the transition is applied when changing from state1 to state2. \code - <Transition fromState="state1" toState="state2"> + Transition { + fromState: "state1" + toState: "state2" ... - </Transition> + } \endcode */ |