resizing of applets is less jumpy now, there is still a problem at big applet sizes though

svn path=/trunk/KDE/kdelibs/; revision=896200
This commit is contained in:
Beat Wolf 2008-12-12 20:20:07 +00:00
parent be2ae212ed
commit 26c61a6205

View File

@ -674,13 +674,18 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (ignoreAspectRatio) { if (ignoreAspectRatio) {
// free resizing // free resizing
qreal newScaleWidth = 0; qreal newScaleWidth = 1.0;
qreal newScaleHeight = 0; qreal newScaleHeight = 1.0;
QPointF startDistance(resizePoint - m_resizeAnchor); qreal x = deltaScene.x() / m_applet->size().width();
QPointF currentDistance((event->pos() - m_resizeOffset) - m_resizeAnchor); qreal y = -deltaScene.y() / m_applet->size().height();
newScaleWidth = currentDistance.x() / startDistance.x();
newScaleHeight = currentDistance.y() / startDistance.y(); if (!m_buttonsOnRight) {
x *= -1.0;
}
newScaleWidth += x;
newScaleHeight += y;
if (qAbs(event->pos().x() - pressPos.x()) <= KGlobalSettings::dndEventDelay()) { if (qAbs(event->pos().x() - pressPos.x()) <= KGlobalSettings::dndEventDelay()) {
newScaleWidth = m_originalSize.width() / originalRect.width(); newScaleWidth = m_originalSize.width() / originalRect.width();
@ -705,11 +710,16 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
} }
} else { } else {
// maintain aspect ratio // maintain aspect ratio
qreal newScale = 0; qreal newScale = 1.0;
newScale = qreal x = deltaScene.x() / m_applet->size().width();
_k_distanceForPoint((event->pos() - m_resizeOffset) - m_resizeAnchor) / qreal y = -deltaScene.y() / m_applet->size().height();
_k_distanceForPoint(resizePoint - m_resizeAnchor);
if (!m_buttonsOnRight) {
x *= -1.0;
}
newScale += (x + y) / 2; //divide by two to have slower resizing
if (qAbs(event->pos().y() - pressPos.y()) <= KGlobalSettings::dndEventDelay()) { if (qAbs(event->pos().y() - pressPos.y()) <= KGlobalSettings::dndEventDelay()) {
newScale = m_originalSize.height() / originalRect.height(); newScale = m_originalSize.height() / originalRect.height();