[ Oops, forgot to CC the list on my previous reply. ]
Here is an answer to my own question, using a somewhat hacky polling
loop to replace the conditional pause in Nigel's example:
SequentialAnimation {
loops: buttonMouseArea.pressed?Animation.Infinite:0
ScriptAction {
script: {
if(!buttonMouseArea.pressed) {
conditionalPause.running = false
}
}
}
PauseAnimation { duration: 200 }
}
Or, more generically:
ConditionPauseAnimation.qml
=====================
SequentialAnimation {
id: root
property bool condition
loops: condition ? 0 : Animation.Infinite
ScriptAction {
script: {
if(condition) {
root.running = false
}
}
}
PauseAnimation { duration: 200 }
}
Usage in Nigel's example:
ConditionPauseAnimation { condition: buttonMouseArea.pressed == false }
Cheers,
Alex
On Fri, Aug 27, 2010 at 2:36 PM, Alex <[email protected]> wrote:
> Your example pauses for a predefined amount of time if
> buttonMouseArea.pressed is true. What I am trying to accomplish is to
> pause for an undefined amount of time, *until* -- given your example
> -- buttonMouseArea.pressed becomes false.
>
> Any ideas?
>
> Cheers,
> Alex
>
>
> On Fri, Aug 27, 2010 at 1:19 PM, <[email protected]> wrote:
>> What is wrong with the following for a conditional pause? This seems to
>> cause a glitch where the first time the button is pressed the rotating
>> rectangle jumps to the pause position. Bug?
>>
>> import Qt 4.7
>>
>> Rectangle {
>>
>> width: 640
>>
>> height: 480
>>
>> Rectangle{
>>
>> width: 200
>>
>> height: 200
>>
>> radius: 5
>>
>> border.width: 3
>>
>> anchors.centerIn: parent
>>
>> gradient: Gradient {
>>
>> GradientStop { position: 0.0; color: "grey" }
>>
>> GradientStop { position: 0.33; color: "darkgrey" }
>>
>> GradientStop { position: 1.0; color: "lightgrey" }
>>
>> }
>>
>> SequentialAnimation on rotation {
>>
>> NumberAnimation { from: 0; to: 180; duration: 700 }
>>
>> // Conditonal pause based on single line javascript if setting
>> pause duration
>>
>> PauseAnimation { duration: buttonMouseArea.pressed ? 300 : 0 }
>>
>> NumberAnimation { from: 180; to: 360; duration: 700 }
>>
>> loops: Animation.Infinite
>>
>> }
>>
>> }
>>
>> Rectangle {
>>
>> width: 150
>>
>> height: 40
>>
>> radius: 5
>>
>> border.width: 3
>>
>> anchors.bottom: parent.bottom
>>
>> Text {
>>
>> text: "Pause when pressed"
>>
>> anchors.centerIn: parent
>>
>> }
>>
>> MouseArea {
>>
>> id: buttonMouseArea
>>
>> anchors.fill: parent
>>
>> }
>>
>> }
>>
>> }
>>
>> - Nigel
>>
>> On Thu, Aug 26, 2010 at 9:11 PM, <[email protected]> wrote:
>>
>> On 27/08/2010, at 8:21 AM, ext Alex wrote:
>>
>> SequentialAnimation {
>>
>> NumberAnimation {}
>>
>> ConditionalPauseAnimation { condition: myComponent.isReady }
>>
>> NumberAnimation {}
>>
>> }
>>
>> I can't think of anything currently available that's as elegant as the above
>> -- could you add a suggestion for this in JIRA?
>>
>> I just added QTBUG-13240.
>>
>>
>> You could try something like this to pause the animation:
>>
>> SequentialAnimation {
>>
>> id: group
>>
>> NumberAnimation { to: 200 }
>>
>> ScriptAction { script: if (!myComponent.isReady) group.pause() }
>>
>> NumberAnimation { to: 400 }
>>
>> }
>>
>> and then elsewhere call group.resume() whenever the condition is met.
>>
>> Thanks for the suggestion. It is a little clunky but should work...
>>
>> Cheers,
>> Alex
>>
>> _______________________________________________
>> Qt-qml mailing list
>> [email protected]
>> http://lists.trolltech.com/mailman/listinfo/qt-qml
>>
>>
>
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-qml