[Qt-qml] State transition proposal: PropertyChangesLater
Thomas Perl
th.perl at gmail.com
Sun Feb 6 14:40:54 CET 2011
Hi,
I often have the case where items have two states: One state being
"on-screen" and visible, the other state being "off-screen" and not
visible. I'd like to animate between those states, so that the user
"knows" that the view is going away and coming back. For performance
reasons, the "off-screen" state should set "opacity" to 0. Now, if I
use PropertyChanges in the state to set the opacity, the "sliding out"
animation isn't visible, because the property changes as soon as the
state is entered, therefore the animation isn't visible anymore. I'm
currently working around this using a SequentialAnimation and
ScriptAction in the transition, like this:
transitions: Transition {
SequentialAnimation {
ScriptAction { script: inner.opacity = 1 }
AnchorAnimation {}
ScriptAction { script: inner.opacity = (inner.state=='onscreen') }
}
}
(where "inner" is the object that i move, and it has two states
"onscreen" and "offscreen")
I imagine this is a common use case. How do you handle it currently? I
could imagine something like a "PropertyChangesLater" being useful,
behaving the same way as PropertyChanges, but carrying out the changes
after all transitions have finished. This way, I could just say (in
the "offscreen" state):
PropertyChangesLater {
target: inner
opacity: 0
}
Does this make sense? Can this be considered for a future QML version,
or is there an easier, obvious way to accomplish what I'm trying to
do?
Attached are two files: state.qml (my current workaround) and
state-proposed.qml (example of how the same feature would be
implemented using PropertyChangesLater).
Thanks,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: state.qml
Type: application/octet-stream
Size: 1262 bytes
Desc: not available
Url : http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110206/5089048c/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: state-proposed.qml
Type: application/octet-stream
Size: 1307 bytes
Desc: not available
Url : http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110206/5089048c/attachment-0001.obj
More information about the Qt-qml
mailing list