28 GrowAnimation::GrowAnimation(
QObject *parent, qreal factor)
29 : EasingAnimation(parent), m_animFactor(factor)
33 void GrowAnimation::setFactor(
const qreal factor)
35 m_animFactor = qMax(qreal(0.0), factor);
38 qreal GrowAnimation::factor()
const
43 void GrowAnimation::updateEffectiveTime(
int currentTime)
46 if (w && state() == QAbstractAnimation::Running) {
47 const qreal delta = currentTime / qreal(duration());
49 geometry.setTopLeft(m_startGeometry.topLeft() * (1-delta) + (m_targetGeometry.topLeft() * delta));
50 geometry.setSize(m_startGeometry.size() * (1-delta) + (m_targetGeometry.size() * delta));
51 w->setGeometry(geometry);
55 void GrowAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
57 if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) {
63 QSizeF minimum = widget->effectiveSizeHint(Qt::MinimumSize);
64 QSizeF maximum = widget->effectiveSizeHint(Qt::MaximumSize);
65 m_startGeometry = widget->geometry();
66 qreal w = m_startGeometry.width();
67 qreal h = m_startGeometry.height();
68 qreal factor = m_animFactor;
73 if (direction() == QAbstractAnimation::Forward) {
74 newWidth = qBound(minimum.width(), w * factor, maximum.width());
75 newHeight = qBound(minimum.height(), h * factor, maximum.height());
77 newWidth = qBound(minimum.width(), w / factor, maximum.width());
78 newHeight = qBound(minimum.height(), h / factor, maximum.height());
83 newX = m_startGeometry.x() - (newWidth - w)/2;
84 newY = m_startGeometry.y() - (newHeight - h)/2;
86 if (direction() == QAbstractAnimation::Forward) {
88 m_targetGeometry = QRect(newX, newY, newWidth, newHeight);
90 m_targetGeometry = m_startGeometry;
91 m_startGeometry = QRectF(newX, newY, newWidth, newHeight);