src/declarative/util/qdeclarativestateoperations.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   159 }
   159 }
   160 
   160 
   161 /*!
   161 /*!
   162     \preliminary
   162     \preliminary
   163     \qmlclass ParentChange QDeclarativeParentChange
   163     \qmlclass ParentChange QDeclarativeParentChange
       
   164     \ingroup qml-state-elements
   164     \brief The ParentChange element allows you to reparent an Item in a state change.
   165     \brief The ParentChange element allows you to reparent an Item in a state change.
   165 
   166 
   166     ParentChange reparents an item while preserving its visual appearance (position, size,
   167     ParentChange reparents an item while preserving its visual appearance (position, size,
   167     rotation, and scale) on screen. You can then specify a transition to move/resize/rotate/scale
   168     rotation, and scale) on screen. You can then specify a transition to move/resize/rotate/scale
   168     the item to its final intended appearance.
   169     the item to its final intended appearance.
   587     QString name;
   588     QString name;
   588 };
   589 };
   589 
   590 
   590 /*!
   591 /*!
   591     \qmlclass StateChangeScript QDeclarativeStateChangeScript
   592     \qmlclass StateChangeScript QDeclarativeStateChangeScript
       
   593     \ingroup qml-state-elements
   592     \brief The StateChangeScript element allows you to run a script in a state.
   594     \brief The StateChangeScript element allows you to run a script in a state.
   593 
   595 
   594     A StateChangeScript is run upon entering a state. You can optionally use
   596     A StateChangeScript is run upon entering a state. You can optionally use
   595     ScriptAction to specify the point in the transition at which
   597     ScriptAction to specify the point in the transition at which
   596     the StateChangeScript should to be run.
   598     the StateChangeScript should to be run.
   691     return QLatin1String("StateChangeScript");
   693     return QLatin1String("StateChangeScript");
   692 }
   694 }
   693 
   695 
   694 /*!
   696 /*!
   695     \qmlclass AnchorChanges QDeclarativeAnchorChanges
   697     \qmlclass AnchorChanges QDeclarativeAnchorChanges
       
   698     \ingroup qml-state-elements
   696     \brief The AnchorChanges element allows you to change the anchors of an item in a state.
   699     \brief The AnchorChanges element allows you to change the anchors of an item in a state.
   697 
   700 
   698     The AnchorChanges element is used to modify the anchors of an item in a \l State.
   701     The AnchorChanges element is used to modify the anchors of an item in a \l State.
   699 
   702 
   700     AnchorChanges cannot be used to modify the margins on an item. For this, use
   703     AnchorChanges cannot be used to modify the margins on an item. For this, use
  1422 {
  1425 {
  1423     Q_D(QDeclarativeAnchorChanges);
  1426     Q_D(QDeclarativeAnchorChanges);
  1424     if (!d->target)
  1427     if (!d->target)
  1425         return;
  1428         return;
  1426 
  1429 
       
  1430     //### should this (saving "from" values) be moved to saveCurrentValues()?
  1427     d->fromX = d->target->x();
  1431     d->fromX = d->target->x();
  1428     d->fromY = d->target->y();
  1432     d->fromY = d->target->y();
  1429     d->fromWidth = d->target->width();
  1433     d->fromWidth = d->target->width();
  1430     d->fromHeight = d->target->height();
  1434     d->fromHeight = d->target->height();
  1431 
  1435 
  1481     Q_D(QDeclarativeAnchorChanges);
  1485     Q_D(QDeclarativeAnchorChanges);
  1482     if (!d->target)
  1486     if (!d->target)
  1483         return;
  1487         return;
  1484 
  1488 
  1485     QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
  1489     QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
  1486     //restore previous anchors
  1490 
  1487     if (d->rewindLeft.anchorLine != QDeclarativeAnchorLine::Invalid)
  1491     //restore previous values (but not previous bindings, i.e. anchors)
  1488         targetPrivate->anchors()->setLeft(d->rewindLeft);
       
  1489     if (d->rewindRight.anchorLine != QDeclarativeAnchorLine::Invalid)
       
  1490         targetPrivate->anchors()->setRight(d->rewindRight);
       
  1491     if (d->rewindHCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
       
  1492         targetPrivate->anchors()->setHorizontalCenter(d->rewindHCenter);
       
  1493     if (d->rewindTop.anchorLine != QDeclarativeAnchorLine::Invalid)
       
  1494         targetPrivate->anchors()->setTop(d->rewindTop);
       
  1495     if (d->rewindBottom.anchorLine != QDeclarativeAnchorLine::Invalid)
       
  1496         targetPrivate->anchors()->setBottom(d->rewindBottom);
       
  1497     if (d->rewindVCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
       
  1498         targetPrivate->anchors()->setVerticalCenter(d->rewindVCenter);
       
  1499     if (d->rewindBaseline.anchorLine != QDeclarativeAnchorLine::Invalid)
       
  1500         targetPrivate->anchors()->setBaseline(d->rewindBaseline);
       
  1501 
       
  1502     d->target->setX(d->rewindX);
  1492     d->target->setX(d->rewindX);
  1503     d->target->setY(d->rewindY);
  1493     d->target->setY(d->rewindY);
  1504     if (targetPrivate->widthValid) {
  1494     if (targetPrivate->widthValid) {
  1505         d->target->setWidth(d->rewindWidth);
  1495         d->target->setWidth(d->rewindWidth);
  1506     }
  1496     }