aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2014-02-05 18:57:02 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-05 09:27:39 -0800
commit4ccd6fb3b6b593bf5de4b668afe612a916853efb (patch)
tree5e57f22a989c6cef8db1e8f9d9f70620d67f2966
parenta649bcc7bc0006cc78ac547716d8bebf8b63267c (diff)
downloadsubsurface-4ccd6fb3b6b593bf5de4b668afe612a916853efb.tar.gz
Fix the zoom-panning for the new profile
This works in a different way compared to the old widget. To make it work we use vieport()'s height() and width() and simplify the scroll position to: scrollPosition = (mousePosition / totalLength) * scrollMaximum Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/profile/profilewidget2.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 0de11966c..8c255c8be 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -518,15 +518,10 @@ void ProfileWidget2::scrollViewTo(const QPoint& pos)
return;
QScrollBar *vs = verticalScrollBar();
QScrollBar *hs = horizontalScrollBar();
- const qreal yRat = pos.y() / sceneRect().height();
- const qreal xRat = pos.x() / sceneRect().width();
- const int vMax = vs->maximum();
- const int hMax = hs->maximum();
- const int vMin = vs->minimum();
- const int hMin = hs->minimum();
- /* QScrollBar receives crazy negative values for minimum */
- vs->setValue(yRat * (vMax - vMin) + vMin * 0.9);
- hs->setValue(xRat * (hMax - hMin) + hMin * 0.9);
+ const qreal yRat = (qreal)pos.y() / viewport()->height();
+ const qreal xRat = (qreal)pos.x() / viewport()->width();
+ vs->setValue(yRat * vs->maximum());
+ hs->setValue(xRat * hs->maximum());
}
void ProfileWidget2::mouseMoveEvent(QMouseEvent* event)