20 #include "geometry_p.h"
29 GeometryAnimation::GeometryAnimation(
QObject *parent)
30 : EasingAnimation(parent),
31 m_startGeometry(-1, -1, -1, -1)
35 GeometryAnimation::~GeometryAnimation()
39 void GeometryAnimation::setStartGeometry(
const QRectF &geometry)
41 m_startGeometry = geometry;
44 QRectF GeometryAnimation::startGeometry()
const
46 return m_startGeometry;
49 void GeometryAnimation::setTargetGeometry(
const QRectF &geometry)
51 m_targetGeometry = geometry;
54 QRectF GeometryAnimation::targetGeometry()
const
56 return m_targetGeometry;
59 void GeometryAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
66 if (m_startGeometry ==
QRectF(-1, -1, -1, -1)) {
70 if (oldState == Stopped && newState == Running) {
71 w->
setGeometry(direction() == Forward ? m_startGeometry : m_targetGeometry);
72 }
else if (newState == Stopped) {
73 w->
setGeometry(direction() == Forward ? m_targetGeometry : m_startGeometry);
77 void GeometryAnimation::updateEffectiveTime(
int currentTime)
81 const qreal delta = currentTime / qreal(duration());
85 newGeo.
moveTopLeft(
QPointF(m_startGeometry.left()*(1-delta) + m_targetGeometry.left()*(delta),
86 m_startGeometry.top()*(1-delta) + m_targetGeometry.top()*(delta)));
87 if (m_startGeometry.size() != m_targetGeometry.size()) {
88 newGeo.
setSize(
QSizeF(m_startGeometry.width()*(1-delta) + m_targetGeometry.width()*(delta),
89 m_startGeometry.height()*(1-delta) + m_targetGeometry.height()*(delta)));
91 newGeo.
setSize(m_targetGeometry.size());
99 #include "geometry_p.moc"
void moveTopLeft(const QPointF &position)
void setSize(const QSizeF &size)