[Qt-interest] Kinetic code overhead
SABROG
sabrog at inbox.ru
Wed Oct 21 18:12:12 CEST 2009
I found this example:
http://qt.gitorious.com/+qt-kinetic-developers/qt/kinetic/blobs/40eab4cb38588e929d72dc7e9e397cad50c6ad4e/examples/animation/states/main.cpp
This source contain next code:
-------
state1->assignProperty(button, "text", "Switch to state 2");
state1->assignProperty(widget, "geometry", QRectF(0, 0, 400, 150));
state1->assignProperty(box, "geometry", QRect(-200, 150, 200, 150));
state1->assignProperty(p1, "geometry", QRectF(68, 185, 64, 64));
state1->assignProperty(p2, "geometry", QRectF(168, 185, 64, 64));
state1->assignProperty(p3, "geometry", QRectF(268, 185, 64, 64));
state1->assignProperty(p4, "geometry", QRectF(68-150, 48-150, 64, 64));
state1->assignProperty(p5, "geometry", QRectF(168, 48-150, 64, 64));
state1->assignProperty(p6, "geometry", QRectF(268+150, 48-150, 64,
64));
state1->assignProperty(p1, "zRotation", qreal(0));
state1->assignProperty(p2, "zRotation", qreal(0));
state1->assignProperty(p3, "zRotation", qreal(0));
state1->assignProperty(p4, "zRotation", qreal(-270));
state1->assignProperty(p5, "zRotation", qreal(-90));
state1->assignProperty(p6, "zRotation", qreal(270));
state1->assignProperty(boxProxy, "opacity", qreal(0));
state1->assignProperty(p1, "opacity", qreal(1));
state1->assignProperty(p2, "opacity", qreal(1));
state1->assignProperty(p3, "opacity", qreal(1));
state1->assignProperty(p4, "opacity", qreal(0));
state1->assignProperty(p5, "opacity", qreal(0));
state1->assignProperty(p6, "opacity", qreal(0));
...
animation1.addAnimation(new QPropertyAnimation(widget, "geometry"));
animation1.addAnimation(new QPropertyAnimation(p1, "geometry"));
animation1.addAnimation(new QPropertyAnimation(p2, "geometry"));
animation1.addAnimation(new QPropertyAnimation(p3, "geometry"));
animation1.addAnimation(new QPropertyAnimation(p4, "geometry"));
animation1.addAnimation(new QPropertyAnimation(p5, "geometry"));
animation1.addAnimation(new QPropertyAnimation(p6, "geometry"));
animation1.addAnimation(new QPropertyAnimation(p1, "zRotation"));
animation1.addAnimation(new QPropertyAnimation(p2, "zRotation"));
animation1.addAnimation(new QPropertyAnimation(p3, "zRotation"));
animation1.addAnimation(new QPropertyAnimation(p4, "zRotation"));
animation1.addAnimation(new QPropertyAnimation(p5, "zRotation"));
animation1.addAnimation(new QPropertyAnimation(p6, "zRotation"));
animation1.addAnimation(new QPropertyAnimation(p1, "opacity"));
animation1.addAnimation(new QPropertyAnimation(p2, "opacity"));
animation1.addAnimation(new QPropertyAnimation(p3, "opacity"));
animation1.addAnimation(new QPropertyAnimation(p4, "opacity"));
animation1.addAnimation(new QPropertyAnimation(p5, "opacity"));
animation1.addAnimation(new QPropertyAnimation(p6, "opacity"));
----------
I think this is not good code style. I think, what trolls must create
container class for this, or stream class, what we can use it like this:
QListProperties lstProp;
lstProp << button << "text" << "Switch to state 2"
<< widget << "geometry" << QRectF(0, 0, 400, 150)
<< box << "geometry" << QRect(-200, 150, 200, 150)
<< p1 << "geometry" << QRectF(68, 185, 64, 64)
...
state1->assignProperty(lstProp);
...
QListPropertyAnimation lstPropAnim;
lstPropAnim << widget << "geometry"
<< p1 << "geometry"
<< p2 << "geometry"
...
animation1.addAnimation(lstPropAnim);
Or something like this... Just suggestion.
More information about the Qt-interest-old
mailing list