mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
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>
This commit is contained in:
parent
a649bcc7bc
commit
4ccd6fb3b6
1 changed files with 4 additions and 9 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue